Example usage for java.util List containsAll

List of usage examples for java.util List containsAll

Introduction

In this page you can find the example usage for java.util List containsAll.

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

Returns true if this list contains all of the elements of the specified collection.

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.components.ExperimentPackageManagePanel.java

/**
 *
 * @return list of experiments that can be added to the package
 *//*from   ww  w  .  ja v a  2 s.c om*/
private IModel<List<Experiment>> listExperimentsToAdd() {
    return new LoadableDetachableModel<List<Experiment>>() {

        @Override
        protected List<Experiment> load() {
            ExperimentPackage pckg = epModel.getObject();
            List<Experiment> list = experimentsFacade.getExperimentsWithoutPackage(pckg);

            // remove all experiments that do not match package licenses
            // TODO doing this in one database query would be more efficient
            final List<License> pckgLicenses = licenseFacade.getLicensesForPackage(pckg);
            Iterator<Experiment> it = list.iterator();
            while (it.hasNext()) {
                List<License> expLicenses = licenseFacade.getLicensesForExperiment(it.next().getExperimentId());
                if (!expLicenses.containsAll(pckgLicenses))
                    it.remove();
            }

            return list;
        }

    };
}

From source file:org.apache.falcon.metadata.EntityRelationshipGraphBuilder.java

public boolean areFeedClustersSame(List<org.apache.falcon.entity.v0.feed.Cluster> oldClusters,
        List<org.apache.falcon.entity.v0.feed.Cluster> newClusters) {
    if (oldClusters.size() != newClusters.size()) {
        return false;
    }/* ww w .j  a  va2  s . c  om*/

    List<String> oldClusterNames = getFeedClusterNames(oldClusters);
    List<String> newClusterNames = getFeedClusterNames(newClusters);

    return oldClusterNames.size() == newClusterNames.size() && oldClusterNames.containsAll(newClusterNames)
            && newClusterNames.containsAll(oldClusterNames);
}

From source file:org.apache.falcon.metadata.EntityRelationshipGraphBuilder.java

public boolean areProcessClustersSame(List<org.apache.falcon.entity.v0.process.Cluster> oldClusters,
        List<org.apache.falcon.entity.v0.process.Cluster> newClusters) {
    if (oldClusters.size() != newClusters.size()) {
        return false;
    }//from   w ww. j a  v a2s. c  o  m

    List<String> oldClusterNames = getProcessClusterNames(oldClusters);
    List<String> newClusterNames = getProcessClusterNames(newClusters);

    return oldClusterNames.size() == newClusterNames.size() && oldClusterNames.containsAll(newClusterNames)
            && newClusterNames.containsAll(oldClusterNames);
}

From source file:org.keycloak.testsuite.console.authentication.FlowsTest.java

@Test
public void navigationTest() {
    flowsPage.selectFlowOption(Flows.FlowOption.BROWSER);
    flowsPage.clickCopy();/*from  w  ww  . jav  a2 s  .  c  o m*/
    modalDialog.ok();

    //init order
    //first should be Cookie
    //second Kerberos
    //third Identity provider redirector
    //fourth Test Copy Of Browser Forms
    //a) Username Password Form
    //b) OTP Form

    flowsPage.table().clickLevelDownButton("Cookie");
    assertAlertSuccess();

    flowsPage.table().clickLevelUpButton("Cookie");
    assertAlertSuccess();

    flowsPage.table().clickLevelUpButton("Kerberos");
    assertAlertSuccess();

    flowsPage.table().clickLevelDownButton("Identity Provider Redirector");
    assertAlertSuccess();

    flowsPage.table().clickLevelUpButton("OTP Form");
    assertAlertSuccess();

    List<String> expectedOrder = new ArrayList<>();
    Collections.addAll(expectedOrder, "Kerberos", "Cookie", "Copy Of Browser Forms", "OTP Form",
            "Username Password Form", "Identity Provider Redirector");

    //UI
    assertEquals(6, flowsPage.table().getFlowsAliasesWithRequirements().size());
    assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().keySet()));

    //REST
    assertEquals("auth-spnego", getLastFlowFromREST().getAuthenticationExecutions().get(0).getAuthenticator());
    assertEquals("auth-cookie", getLastFlowFromREST().getAuthenticationExecutions().get(1).getAuthenticator());
    assertEquals("Copy of browser forms",
            getLastFlowFromREST().getAuthenticationExecutions().get(2).getFlowAlias());
    assertEquals("identity-provider-redirector",
            getLastFlowFromREST().getAuthenticationExecutions().get(3).getAuthenticator());
    flowsPage.clickDelete();
    modalDialog.confirmDeletion();
}

From source file:org.apache.geode.internal.util.CollectionUtilsJUnitTest.java

@Test
public void testAsList() {
    final Integer[] numbers = { 0, 1, 2, 1, 0 };

    final List<Integer> numberList = CollectionUtils.asList(numbers);

    assertNotNull(numberList);/*  w  ww . j av a 2s.c o  m*/
    assertFalse(numberList.isEmpty());
    assertEquals(numbers.length, numberList.size());
    assertTrue(numberList.containsAll(Arrays.asList(numbers)));
    assertEquals(new Integer(0), numberList.remove(0));
    assertEquals(numbers.length - 1, numberList.size());
}

From source file:com.facebook.android.friendsmash.HomeFragment.java

private void facebookPostAll() {
    pendingPost = false;/*from  w  w  w  . ja  va 2  s .c o m*/
    Session session = Session.getActiveSession();

    if (session == null || !session.isOpened()) {
        return;
    }

    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingPost = true;
        requestPublishPermissions(session);
        return;
    }

    // If you get this far, then you'll have write permissions to post

    // Post the score to Facebook
    postScore();

    // Post Achievemnt to Facebook
    postAchievement();

    // Post Custom OG action to Facebook
    postOG();
}

From source file:es.upm.fi.dia.oeg.ogsadai.sparql.optimizers.WellDesignedRule2Optimiser.java

/**
 * checks safe condition (variables in P1 are in P2 and P')
 * /* w ww  .  ja va2 s .  c  om*/
 * @param ousideOperator
 *            operator P'
 * @param optionalOperator
 *            (P1 OPT P2)
 * 
 * @return true if pattern is safe
 */
private boolean checkSafeCondition(Operator ousideOperator, Operator optionalOperator) {
    List<String> pPrimeAttrs = new ArrayList<String>();
    // getting variables from left side of AND (parent operator)
    for (Attribute attribute : ousideOperator.getHeading().getAttributes()) {
        pPrimeAttrs.add(attribute.getName());
    }

    // getting variables from P2
    List<String> p2Attrs = new ArrayList<String>();
    for (Attribute attribute : optionalOperator.getChild(1).getHeading().getAttributes()) {
        p2Attrs.add(attribute.getName());
    }

    List<String> intersection = null;
    intersection = new ArrayList<String>();
    intersection = ListUtils.intersection(pPrimeAttrs, p2Attrs);
    // getting variables from P2
    List<String> p1Attrs = new ArrayList<String>();
    for (Attribute attribute : optionalOperator.getChild(0).getHeading().getAttributes()) {
        p1Attrs.add(attribute.getName());
    }

    if (p1Attrs.containsAll(intersection)) {
        return true;
    }
    return false;
}

From source file:org.glite.slcs.struts.action.EditAccessControlRuleAction.java

protected ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    // cancel clicked on addRule.jsp?
    if (isCancelled(request)) {
        return mapping.findForward("admin.go.listRules");
    }/* w  ww  .  j  a va  2 s  . c  om*/

    if (isEditRuleAction(request)) {
        LOG.info("edit rule");
        AccessControlListEditor editor = AccessControlListEditorFactory.getInstance();
        int ruleId = getEditRuleId(request);
        AccessControlRule rule = editor.getAccessControlRule(ruleId);
        if (rule != null) {
            GroupManager groupManager = GroupManagerFactory.getInstance();
            String groupName = rule.getGroupName();
            Group group = groupManager.getGroup(groupName);
            List attributesConstraint = group.getRuleAttributesConstraint();
            AccessControlRuleBean ruleBean = new AccessControlRuleBean();
            ruleBean.setGroupName(rule.getGroupName());
            ruleBean.setId(rule.getId());
            ruleBean.setAttributes(rule.getAttributes());
            ruleBean.addConstrainedAttributes(attributesConstraint);
            ruleBean.updateAttributesDiplayName();
            request.setAttribute("ruleBean", ruleBean);
            // forward/send response
            return mapping.findForward("admin.page.editRule");
        }
        // TODO: error rule doesn't exist!!!!
    } else if (isAddRuleAttributeAction(request)) {
        LOG.info("add rule attribute");
        AccessControlRuleForm ruleForm = (AccessControlRuleForm) form;
        AccessControlRuleBean ruleBean = addRuleAttribute(ruleForm, request);
        request.setAttribute("ruleBean", ruleBean);
        // forward/send response
        return mapping.findForward("admin.page.editRule");
    } else if (isDeleteRuleAttributeAction(request)) {
        LOG.debug("delete rule attribute");
        AccessControlRuleForm ruleForm = (AccessControlRuleForm) form;
        AccessControlRuleBean ruleBean = deleteRuleAttribute(ruleForm, request);
        request.setAttribute("ruleBean", ruleBean);
        // forward/send response
        return mapping.findForward("admin.page.editRule");
    } else if (isSaveRuleAction(request)) {
        LOG.info("save rule");
        List userAttributes = getUserAttributes(request);
        GroupManager groupManager = GroupManagerFactory.getInstance();
        // read rule group and attributes from form
        AccessControlRuleForm ruleForm = (AccessControlRuleForm) form;
        String ruleGroup = ruleForm.getGroupName();
        List ruleAttributes = getValidRuleAttributes(ruleForm);
        if (groupManager.inGroup(ruleGroup, userAttributes) || groupManager.isAdministrator(userAttributes)) {

            int ruleId = getSaveRuleId(request);
            // check the rule constraint
            Group group = groupManager.getGroup(ruleGroup);
            List attributesContraint = group.getRuleAttributesConstraint();
            if (ruleAttributes.containsAll(attributesContraint)) {
                AccessControlListEditor editor = AccessControlListEditorFactory.getInstance();
                AccessControlRule rule = editor.getAccessControlRule(ruleId);
                if (rule != null) {
                    rule.setGroupName(ruleGroup);
                    rule.setAttributes(ruleAttributes);
                    LOG.info("replace rule: " + rule);
                    editor.replaceAccessControlRule(rule);
                } else {
                    // someone deleted the rule while another edited it
                    rule = new AccessControlRule(ruleGroup);
                    rule.setAttributes(ruleAttributes);
                    LOG.info("replace/save rule: " + rule);
                    editor.addAccessControlRule(rule);
                }
                return mapping.findForward("admin.go.listRules");
            } else {
                // use ActionMessage for error...
                LOG.warn("rule did not contain the mandatory attributes constraint: " + attributesContraint);
                ActionMessages messages = new ActionMessages();
                StringBuffer messageText = new StringBuffer();
                messageText.append("<ul>");
                Iterator attributes = attributesContraint.iterator();
                while (attributes.hasNext()) {
                    Attribute attribute = (Attribute) attributes.next();
                    messageText.append("<li>Attribute ").append(attribute.getDisplayName());
                    messageText.append(" = ").append(attribute.getValue());
                    messageText.append(" was added</li>");
                }
                messageText.append("</ul>");
                ActionMessage warn = new ActionMessage("rule.error.save.constraint.missing", ruleGroup,
                        messageText);
                messages.add(ActionMessages.GLOBAL_MESSAGE, warn);
                saveErrors(request, messages);

                // set the rule bean again
                List userGroupNames = groupManager.getGroupNames(userAttributes);
                AccessControlRuleBean ruleBean = new AccessControlRuleBean();
                ruleBean.setId(ruleId);
                ruleBean.setUserGroupNames(userGroupNames);
                ruleBean.setGroupName(ruleGroup);
                ruleBean.setAttributes(ruleAttributes);
                // add the missing constrained attribute
                ruleBean.addConstrainedAttributes(attributesContraint);
                request.setAttribute("ruleBean", ruleBean);
                // forward/send response
                return mapping.findForward("admin.page.editRule");
            }
        } else {
            // TODO: use ActionMessage for error...
            LOG.error("User: " + userAttributes + " is not a member of group: " + ruleGroup);
            ActionMessages messages = new ActionMessages();
            ActionMessage error = new ActionMessage("user.error.notmember", userAttributes, ruleGroup);
            messages.add(ActionMessages.GLOBAL_MESSAGE, error);
            saveErrors(request, messages);

        }

    }
    LOG.warn("Unknown action");
    return mapping.findForward("admin.go.home");
}

From source file:be.fedict.eid.pkira.blm.model.contracthandler.services.FieldValidatorBean.java

private void validateDNAgainsSANs(String distinguishedName, List<String> alternativeNames,
        List<String> messages) {
    DistinguishedName distinguisedName = null;
    try {// w  w w. ja  va  2s .  c  om
        distinguisedName = distinguishedNameManager.createDistinguishedName(distinguishedName);
    } catch (InvalidDistinguishedNameException e) {
        messages.add("invalid distinguished name");
    }

    if (distinguisedName != null && !alternativeNames.isEmpty()) {
        if (!alternativeNames.containsAll(distinguisedName.getPart("cn"))) {
            messages.add("subject alternative names do not contain the CN in the distinguished name.");
        }
    }
}

From source file:org.voltdb.exportclient.hive.PartitionedJsonDecoder.java

protected PartitionedJsonDecoder(List<VoltType> columnTypes, List<String> columnNames,
        List<String> partitionColumnNames, int firstFieldOffset, TimeZone timeZone, String unspecifiedToken,
        HiveEndPointFactory endPointFactory) {

    super(columnTypes, columnNames, firstFieldOffset);

    HiveEndPointFactory.checkPartitionValues(partitionColumnNames);
    Preconditions.checkArgument(columnNames.containsAll(partitionColumnNames),
            "partition columns %s are not in table columns %s", partitionColumnNames, columnNames);
    for (String partitionColumn : partitionColumnNames) {
        if (m_typeMap.get(partitionColumn) != DecodeType.STRING) {
            throw new IllegalArgumentException("partition column \"" + partitionColumn
                    + "\" must be of VARCHAR type, " + "but it is of type " + m_typeMap.get(partitionColumn));
        }/*  www  .jav a  2  s.  co  m*/
    }

    Preconditions.checkArgument(unspecifiedToken != null && !unspecifiedToken.trim().isEmpty(),
            "unspecified token is null or empty");
    m_unspecifiedToken = unspecifiedToken;
    m_dateFormatter.setTimeZone(Preconditions.checkNotNull(timeZone, "timezone is null"));
    m_endPointFactory = Preconditions.checkNotNull(endPointFactory, "endPointFactory is null");
    m_partitionColumns = partitionColumnNames;
    m_writer = new StringWriter(4096);

    m_columnNames = new String[m_typeMap.size()];
    m_fieldDecoders = new JsonFieldDecoder[m_typeMap.size()];

    int i = 0;
    for (Entry<String, DecodeType> e : m_typeMap.entrySet()) {
        final String columnName = e.getKey().intern();
        m_columnNames[i] = columnName;
        m_fieldDecoders[i++] = e.getValue().accept(decodingVisitor, columnName, null);
    }
}