Example usage for java.util Set containsAll

List of usage examples for java.util Set containsAll

Introduction

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

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

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

Usage

From source file:de.appsolve.padelcampus.admin.controller.events.AdminEventsController.java

@RequestMapping(value = { "edit/{eventId}/groupdraws/{round}" }, method = POST)
public ModelAndView postGroupDrawsForRound(@PathVariable Long eventId, @PathVariable Integer round,
        @ModelAttribute("Model") @Valid EventGroups eventGroups, BindingResult bindingResult,
        HttpServletRequest request) {/*from ww  w.j av  a2s. c  o m*/
    Event event = eventDAO.findByIdFetchWithParticipantsAndGames(eventId);
    Iterator<Map.Entry<Integer, Set<Participant>>> iterator = eventGroups.getGroupParticipants().entrySet()
            .iterator();
    while (iterator.hasNext()) {
        Map.Entry<Integer, Set<Participant>> entry = iterator.next();
        if (entry.getValue() == null) {
            bindingResult.reject("PleaseSelectParticipantsForEachGroup");
        }
    }

    if (bindingResult.hasErrors()) {
        return getGroupDrawsView(event, eventGroups, round);
    }

    //remove games of players who no longer participate
    gameUtil.removeObsoleteGames(event);

    //remove games with teams that are no longer part of a group in the current round
    Iterator<Game> gameIterator = event.getGames().iterator();
    while (gameIterator.hasNext()) {
        Game game = gameIterator.next();
        Integer groupNumber = game.getGroupNumber();
        if (groupNumber != null && game.getRound().equals(round)) {
            Set<Participant> groupParticipants = eventGroups.getGroupParticipants().get(groupNumber);
            if (!groupParticipants.containsAll(game.getParticipants())) {
                gameIterator.remove();
                gameDAO.deleteById(game.getId());
            }
        }
    }

    //create missing games
    for (int groupNumber = 0; groupNumber < event.getNumberOfGroupsSecondRound(); groupNumber++) {
        Set<Participant> groupParticipants = eventGroups.getGroupParticipants().get(groupNumber);
        gameUtil.createMissingGames(event, groupParticipants, groupNumber, round);
    }

    return new ModelAndView("redirect:/events/event/" + eventId + "/groupgames/" + round);
}

From source file:de.appsolve.padelcampus.admin.controller.events.AdminEventsController.java

@RequestMapping(value = { "edit/{eventId}/groupdraws" }, method = POST)
public ModelAndView postGroupDraws(@PathVariable("eventId") Long eventId,
        @ModelAttribute("Model") @Valid EventGroups eventGroups, BindingResult bindingResult,
        HttpServletRequest request) {//from ww  w.j  ava  2  s  .  c  o m
    Event event = eventDAO.findByIdFetchWithParticipantsAndGames(eventId);
    Iterator<Map.Entry<Integer, Set<Participant>>> iterator = eventGroups.getGroupParticipants().entrySet()
            .iterator();
    while (iterator.hasNext()) {
        Map.Entry<Integer, Set<Participant>> entry = iterator.next();
        if (entry.getValue() == null) {
            bindingResult.reject("PleaseSelectParticipantsForEachGroup");
        }
    }

    //prevent modification of group draws if knockout round games have already begun
    if (event.getEventType().equals(EventType.Knockout)) {
        SortedMap<Integer, List<Game>> roundGames = eventsUtil.getRoundGameMap(event);
        if (!roundGames.isEmpty()) {
            bindingResult.reject("CannotModifyEventAfterGroupPhaseHasEnded");
        }
    }

    if (bindingResult.hasErrors()) {
        return getGroupDrawsView(event, eventGroups);
    }

    //remove games that have not been played yet
    gameUtil.removeObsoleteGames(event);

    //remove games with teams that are no longer part of a group
    Iterator<Game> gameIterator = event.getGames().iterator();
    while (gameIterator.hasNext()) {
        Game game = gameIterator.next();
        Integer groupNumber = game.getGroupNumber();
        if (groupNumber != null) {
            Set<Participant> groupParticipants = eventGroups.getGroupParticipants().get(groupNumber);
            if (!groupParticipants.containsAll(game.getParticipants())) {
                gameDAO.deleteById(game.getId());
                gameIterator.remove();
            }
        }
    }

    //create missing games
    for (int groupNumber = 0; groupNumber < event.getNumberOfGroups(); groupNumber++) {
        Set<Participant> groupParticipants = eventGroups.getGroupParticipants().get(groupNumber);
        Integer roundNumber = null;
        switch (event.getEventType()) {
        case GroupKnockout:
            //for GroupKnockout events, only knockout games have a round
            roundNumber = ROUND_NONE;
            break;
        case GroupTwoRounds:
            //for GroupTwoRound events, every round has a number
            roundNumber = ROUND_ONE;
            break;
        }
        gameUtil.createMissingGames(event, groupParticipants, groupNumber, roundNumber);
    }

    return new ModelAndView("redirect:/admin/events/edit/" + eventId + "/groupschedule");
}

From source file:org.commonjava.cartographer.INTERNAL.graph.agg.DefaultGraphAggregator.java

/**
 * Process the output from a discovery runnable (discovery of relationships
 * related to a given GAV). This includes:
 *
 * <ul>//  ww w.  j a  v  a 2s . co  m
 *   <li>Adding any accumulated metadata for the GAV</li>
 *   <li>Determining which new relationships to store in the graph db related to the relationships in this result</li>
 *   <li>Generating the next set of {@link DiscoveryTodo}'s related to the relationships in this result</li>
 * </ul>
 *
 * @param r The runnable containing discovery output to process for a specific
 * input GAV
 * @param nextTodos The accumulated next crop of {@link DiscoveryTodo}'s, which
 * MAY be augmented by output from this discovery runnable
 * @param config Configuration for how discovery should proceed
 * @param seen map of seen projects pointing at the set of dependency exclusions used by the filter
 * @param pass For diagnostic/logging purposes, the number of discovery passes
 * since discovery was initiated by the caller (part of the graph may have been pre-existing)
 * @return true if output contained a valid result, or false to indicate the
 * GAV should be marked missing.
 * @throws CartoDataException
 */
private boolean processDiscoveryOutput(final DiscoveryRunnable r,
        final Map<ProjectVersionRef, DiscoveryTodo> nextTodos, final DiscoveryConfig config,
        final Map<ProjectVersionRef, Set<ProjectRef>> seen, final int pass) throws CartoDataException {
    final DiscoveryTodo todo = r.getTodo();
    final Throwable error = r.getError();
    if (error != null) {
        try {
            todo.getGraph().storeProjectError(todo.getRef(), error);
        } catch (final RelationshipGraphException e) {
            logger.error(String.format(
                    "Failed to store error for project: %s (%s). Error was:\n\n%s.\n\nStorage error:\n",
                    todo.getRef(), e.getMessage(), ExceptionUtils.getFullStackTrace(error)), e);
        }

        return false;
    }

    final DiscoveryResult result = r.getResult();

    if (result != null) {
        final RelationshipGraph graph = todo.getGraph();

        final Map<String, String> metadata = result.getMetadata();

        if (metadata != null) {
            try {
                graph.addMetadata(result.getSelectedRef(), metadata);
            } catch (final RelationshipGraphException e) {
                logger.error(String.format("Failed to store metadata for: %s in: %s. Reason: %s",
                        result.getSelectedRef(), graph, e.getMessage()), e);
            }
        }

        final Set<ProjectRelationship<?, ?>> discoveredRels = result.getAcceptedRelationships();
        if (discoveredRels != null) {
            final Map<GraphPath<?>, GraphPathInfo> parentPathMap = todo.getParentPathMap();

            if (seen.containsKey(todo.getRef())) {
                seen.get(todo.getRef()).retainAll(todo.getDepExcludes());
            } else {
                seen.put(todo.getRef(), todo.getDepExcludes());
            }

            final int index = r.getIndex();

            // De-selected relationships (not mutated) should be stored but NOT followed for discovery purposes.
            // Likewise, mutated (selected) relationships should be followed but NOT stored.
            logger.info("{}.{}. Processing {} new relationships for: {}", pass, index, discoveredRels.size(),
                    result.getSelectedRef());
            logger.debug("Relationships:\n  {}", new JoinString("\n  ", discoveredRels));

            boolean contributedRels = false;

            int idx = 0;
            for (final ProjectRelationship<?, ?> rel : discoveredRels) {
                final ProjectVersionRef relTarget = rel.getTarget().asProjectVersionRef();
                Set<ProjectRef> currentExc;
                if (rel instanceof DependencyRelationship) {
                    currentExc = new HashSet<>(todo.getDepExcludes());
                    currentExc.addAll(((DependencyRelationship) rel).getExcludes());
                } else {
                    currentExc = todo.getDepExcludes();
                }
                if (!seen.containsKey(relTarget) || !currentExc.containsAll(seen.get(relTarget))) {
                    for (final Entry<GraphPath<?>, GraphPathInfo> entry : parentPathMap.entrySet()) {
                        GraphPath<?> path = entry.getKey();
                        GraphPathInfo pathInfo = entry.getValue();

                        final ProjectRelationship<?, ?> selected = pathInfo.selectRelationship(rel, path);
                        if (selected == null) {
                            continue;
                        }

                        final ProjectVersionRef selectedTarget = selected.getTarget().asProjectVersionRef();
                        pathInfo = pathInfo.getChildPathInfo(selected);
                        Set<ProjectRef> exc = getDepExcludes(pathInfo);

                        if (seen.containsKey(selectedTarget) && exc.containsAll(seen.get(selectedTarget))) {
                            continue;
                        }

                        contributedRels = true;

                        path = graph.createPath(path, selected);

                        if (path == null) {
                            continue;
                        }

                        DiscoveryTodo nextTodo = nextTodos.get(selectedTarget);
                        if (nextTodo == null) {
                            nextTodo = new DiscoveryTodo(selectedTarget, path, pathInfo, graph, exc);
                            nextTodos.put(selectedTarget, nextTodo);

                            logger.info("DISCOVER += {}", selectedTarget);
                        } else {
                            nextTodo.addParentPath(path, pathInfo);
                            nextTodo.getDepExcludes().retainAll(exc);
                        }
                    }

                    if (rel.isManaged()) {
                        logger.debug(
                                "{}.{}.{}. FORCE; NON-TRAVERSE: Adding managed relationship (for mutator use later): {}",
                                pass, index, idx, rel);
                        contributedRels = true;
                    } else if (rel.getType() == RelationshipType.PARENT) {
                        logger.debug("{}.{}.{}. FORCE; NON-TRAVERSE: Adding parent relationship: {}", pass,
                                index, idx, rel);
                        contributedRels = true;
                    } else {
                        logger.debug("{}.{}.{}. SKIP: {}", pass, index, idx, relTarget);
                    }
                } else {
                    logger.debug("{}.{}.{}. SKIP (already discovered): {}", pass, index, idx, relTarget);
                }

                idx++;
            }

            // if all relationships have been discarded by filter...
            if (!contributedRels && !discoveredRels.isEmpty()) {
                logger.debug(
                        "{}.{}. INJECT: Adding terminal parent relationship to mark {} as resolved in the dependency graph.",
                        pass, index, result.getSelectedRef());

                try {
                    graph.storeRelationships(new SimpleParentRelationship(result.getSelectedRef()));
                } catch (final RelationshipGraphException e) {
                    logger.error(String.format("Failed to store relationships for: %s in: %s. Reason: %s",
                            result.getSelectedRef(), graph, e.getMessage()), e);
                }
            }
        } else {
            logger.debug("{}.{}. discovered relationships were NULL for: {}", pass, r.getIndex(),
                    result.getSelectedRef());
        }

        return true;
    } else {
        return false;
    }
}

From source file:org.apache.lens.cube.parse.join.AutoJoinContext.java

private void pruneAllPaths(final Map<Dimension, CandidateDim> dimsToQuery) throws LensException {
    // Remove join paths which cannot be satisfied by the resolved dimension
    // tables//from  ww w .j  a v  a2  s  .c o  m
    if (dimsToQuery != null && !dimsToQuery.isEmpty()) {
        for (CandidateDim candidateDim : dimsToQuery.values()) {
            Set<String> dimCols = candidateDim.getTable().getAllFieldNames();
            for (List<JoinPath> paths : allPaths.values()) {
                for (int i = 0; i < paths.size(); i++) {
                    JoinPath jp = paths.get(i);
                    List<String> candidateDimCols = jp.getColumnsForTable(candidateDim.getBaseTable());
                    if (candidateDimCols != null && !dimCols.containsAll(candidateDimCols)) {
                        // This path requires some columns from the dimension which are
                        // not present in the candidate dim
                        // Remove this path
                        log.info("Removing join path:{} as columns :{} dont exist", jp, candidateDimCols);
                        paths.remove(i);
                        i--;
                    }
                }
            }
        }
        pruneEmptyPaths(allPaths);
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.bookkeeper.metadata.TestBookKeeperJournalMetadataManager.java

@Test
public void testListLedgers() throws Exception {
    Set<EditLogLedgerMetadata> metadata = ImmutableSet.of(
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION, 1, 1, 100),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION, 2, 101, 200),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION, 3, 201, -1),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION - 1, 4, 11, -1),
            new EditLogLedgerMetadata(FSConstants.LAYOUT_VERSION - 1, 5, 2, 10));
    for (EditLogLedgerMetadata e : metadata) {
        String fullLedgerPath = manager.fullyQualifiedPathForLedger(e);
        manager.writeEditLogLedgerMetadata(fullLedgerPath, e);
    }/*from w  w w.j a va2 s  . c  om*/
    Collection<EditLogLedgerMetadata> allLedgers = manager.listLedgers(true);
    assertTrue("listLedgers(true) returns all ledgers and all ledgers once",
            allLedgers.containsAll(metadata) && metadata.containsAll(allLedgers));

    EditLogLedgerMetadata prev = null;
    for (EditLogLedgerMetadata curr : allLedgers) {
        if (prev != null) {
            assertTrue("List must be ordered by firsTxId", prev.getFirstTxId() <= curr.getFirstTxId());
        }
        prev = curr;
    }

    Collection<EditLogLedgerMetadata> finalizedOnly = manager.listLedgers(false);
    for (EditLogLedgerMetadata e : finalizedOnly) {
        assertFalse("listLedgers(false) does not return in-progress ledgers" + e, e.getLastTxId() == -1);
    }
    TreeSet<EditLogLedgerMetadata> expectedFinalizedOnly = new TreeSet<EditLogLedgerMetadata>();
    for (EditLogLedgerMetadata e : allLedgers) {
        if (e.getLastTxId() != -1) {
            expectedFinalizedOnly.add(e);
        }
    }
    assertTrue("listLedgers(false) returns all finalized ledgers",
            finalizedOnly.containsAll(expectedFinalizedOnly)
                    && expectedFinalizedOnly.containsAll(finalizedOnly));
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

private boolean isValidMarkupPipeline(String pipelineName, List<TaskDefinitionRef> taskDefinitions,
        Set<StateDefinition> currentStates) {
    if (taskDefinitions.size() == 1) {
        // There's only one task in the pipeline, and we know it to be markup.
        boolean rValue = true;
        Set<StateDefinitionRef> requiredStates = requiredTaskStates
                .get(StringUtils.upperCase(taskDefinitions.get(0).getName()));
        if (!currentStates.containsAll(requiredStates)) {
            log.error("{}: The states for {} are not satisfied. Current: {}. Required: {}.", pipelineName,
                    taskDefinitions.get(0).getName(), currentStates, requiredStates);
            rValue = false;/*w  w w  .  j  a  v  a 2s .  com*/
        }
        return rValue;
    } else {
        log.error("{}: No tasks may follow a markup task of {}.", pipelineName,
                taskDefinitions.get(0).getName());
        return false;
    }
}

From source file:org.opennms.ng.dao.support.PropertiesGraphDao.java

private boolean verifyAttributesExist(PrefabGraph query, String type, List<String> requiredList,
        Set<String> availableRrdAttributes) {
    if (availableRrdAttributes.containsAll(requiredList)) {
        return true;
    } else {//ww w.  j  av  a 2  s  . com
        LOG.debug(
                "not adding {} to prefab graph list because the required list of {} attributes ({}) is not in the list of {} attributes on the resource ({})",
                query.getName(), type, StringUtils.collectionToDelimitedString(requiredList, ", "), type,
                StringUtils.collectionToDelimitedString(availableRrdAttributes, ", "));
        return false;
    }
}

From source file:net.solarnetwork.central.dras.biz.dao.test.ibatis.DaoUserBizTest.java

@Test
public void assignNewMembers() {
    setupTestLocation();/*ww  w  .ja  v  a2  s.com*/
    setupTestUserGroup(TEST_GROUP_ID, TEST_GROUPNAME, TEST_LOCATION_ID);
    setupTestUser(-8888L, "User A");
    setupTestUser(-8887L, "User B");

    // verify no users in group
    Set<Member> members = userGroupDao.getMembers(TEST_GROUP_ID, null);
    assertNotNull(members);
    assertEquals(0, members.size());

    members.add(new User(-8888L));
    members.add(new User(-8887L));

    MembershipCommand membership = new MembershipCommand();
    membership.setParentId(TEST_GROUP_ID);
    membership.setMode(Mode.Replace);
    membership.setMembers(members);

    EffectiveCollection<UserGroup, ? extends Member> result = userBiz.assignUserGroupMembers(membership);
    assertNotNull(result);
    assertNotNull(result.getObject());
    assertEquals(TEST_GROUP_ID, result.getObject().getId());
    assertNotNull(result.getEffective());
    assertNotNull(result.getEffective().getId());
    assertNotNull(result.getCollection());

    Collection<? extends Member> assigned = result.getCollection();
    assertEquals(members.size(), assigned.size());
    assertTrue(members.containsAll(assigned));
}

From source file:fr.mby.portal.coreimpl.context.PropertiesAppConfigFactory.java

/**
 * Process ACL roles map from OPA config.
 * //from w  w  w.  j av a 2  s  .  com
 * @param bundleApp
 * @param appConfig
 * @param opaConfig
 * @param permissionsMap
 * 
 * @return the map of all configured roles.
 * @throws AppConfigNotFoundException
 * @throws BadAppConfigException
 */
protected Map<String, IRole> processAclRoles(final Bundle bundleApp, final BasicAppConfig appConfig,
        final Properties opaConfig, final Map<String, IPermission> permissionsMap)
        throws BadAppConfigException {
    final Map<String, IRole> rolesByAclName = new HashMap<String, IRole>(4);

    // Special Roles
    final Set<String> specialRolesNames = new HashSet<String>(SpecialRole.values().length);
    final Map<SpecialRole, IRole> specialRoles = new HashMap<SpecialRole, IRole>(SpecialRole.values().length);
    for (final SpecialRole srEnum : SpecialRole.values()) {
        specialRolesNames.add(srEnum.name());
    }

    // Declared Roles
    final Set<String> aclRolesNames = new HashSet<String>();
    aclRolesNames.addAll(specialRolesNames);
    final String aclRolesVal = this.getOptionalValue(opaConfig, OpaConfigKeys.ACL_ROLES.getKey());
    final String[] aclRolesArray = StringUtils.delimitedListToStringArray(aclRolesVal,
            IAppConfigFactory.OPA_CONFIG_LIST_SPLITER);
    if (aclRolesArray != null) {
        for (final String aclRoleName : aclRolesArray) {
            if (StringUtils.hasText(aclRoleName)) {
                aclRolesNames.add(aclRoleName);
            }
        }
    }

    // Search permissions assignment
    final Map<String, Set<IPermission>> permissionsAssignment = new HashMap<String, Set<IPermission>>(4);
    for (final String aclRoleName : aclRolesNames) {
        // For each role search perm assignment
        final Set<IPermission> rolePermissionSet;
        final String permKey = OpaConfigKeys.ACL_ROLES.getKey().concat(".").concat(aclRoleName)
                .concat(OpaConfigKeys.ACL_PERMISSIONS_ASSIGNMENT_SUFFIX.getKey());
        final String rolePermissionsVal = this.getOptionalValue(opaConfig, permKey);
        final String[] rolePermissionsArray = StringUtils.delimitedListToStringArray(rolePermissionsVal,
                IAppConfigFactory.OPA_CONFIG_LIST_SPLITER);
        if (rolePermissionsArray != null) {
            // We found a perm assignment
            rolePermissionSet = new HashSet<IPermission>();
            for (final String rolePermissionName : rolePermissionsArray) {
                if (StringUtils.hasText(rolePermissionName)) {
                    final IPermission perm = permissionsMap.get(rolePermissionName);
                    if (perm != null) {
                        rolePermissionSet.add(perm);
                    } else {
                        final String message = String.format(
                                "Try to assign undeclared permission: [%1$s] to role: [%2$s] in OPA: [%3$s] !",
                                rolePermissionName, aclRoleName, bundleApp.getSymbolicName());
                        throw new BadAppConfigException(message);
                    }
                }
            }
        } else {
            rolePermissionSet = Collections.emptySet();
        }

        permissionsAssignment.put(aclRoleName, rolePermissionSet);
    }

    // Search sub-roles assignment
    final Map<String, Set<String>> subRolesAssignment = new HashMap<String, Set<String>>(4);
    for (final String aclRoleName : aclRolesNames) {
        final Set<String> subRolesSet;
        final String key = OpaConfigKeys.ACL_ROLES.getKey().concat(".").concat(aclRoleName)
                .concat(OpaConfigKeys.ACL_SUBROLES_ASSIGNMENT_SUFFIX.getKey());
        final String subRolesVal = this.getOptionalValue(opaConfig, key);
        final String[] subRolesArray = StringUtils.delimitedListToStringArray(subRolesVal,
                IAppConfigFactory.OPA_CONFIG_LIST_SPLITER);
        if (subRolesArray != null) {
            subRolesSet = new HashSet<String>();
            for (final String subRoleName : subRolesArray) {
                if (StringUtils.hasText(subRoleName) && aclRolesNames.contains(subRoleName)) {
                    subRolesSet.add(subRoleName);
                } else {
                    final String message = String.format(
                            "Try to assign undeclared sub-role: [%1$s] to role: [%2$s] in OPA: [%3$s] !",
                            subRoleName, aclRoleName, bundleApp.getSymbolicName());
                    throw new BadAppConfigException(message);
                }
            }
        } else {
            subRolesSet = Collections.emptySet();
        }

        subRolesAssignment.put(aclRoleName, subRolesSet);
    }

    // Build roles : begin with the sub-roles
    final Set<String> rolesToBuild = new HashSet<String>(aclRolesNames);
    final Set<String> builtRoles = new HashSet<String>(rolesToBuild.size());
    while (!rolesToBuild.isEmpty()) {
        // Loop while some roles are not built yet
        final Iterator<String> rolesToBuildIt = rolesToBuild.iterator();
        while (rolesToBuildIt.hasNext()) {
            // Loop on all roles not built yet to find one candidate to build
            final String aclRoleName = rolesToBuildIt.next();
            final Set<String> subRolesNames = subRolesAssignment.get(aclRoleName);
            if (builtRoles.containsAll(subRolesNames)) {
                // If all sub-roles are already built we can build the role
                final String finalRoleName = this.buildFinalRoleName(bundleApp, aclRoleName);
                final Set<IPermission> permissions = permissionsAssignment.get(aclRoleName);
                final Set<IRole> subRoles = new HashSet<IRole>(subRolesNames.size());
                for (final String subRoleName : subRolesNames) {
                    subRoles.add(rolesByAclName.get(subRoleName));
                }

                final IRole newRole = this.roleFactory.initializeRole(finalRoleName, permissions, subRoles);
                rolesByAclName.put(aclRoleName, newRole);
                builtRoles.add(aclRoleName);
                rolesToBuildIt.remove();

                if (specialRolesNames.contains(aclRoleName)) {
                    // Current role is special
                    specialRoles.put(Enum.valueOf(SpecialRole.class, aclRoleName), newRole);
                }
            }
        }
    }

    appConfig.setSpecialRoles(Collections.unmodifiableMap(specialRoles));
    final Set<IRole> rolesSet = new HashSet<IRole>(rolesByAclName.values());
    appConfig.setDeclaredRoles(Collections.unmodifiableSet(rolesSet));

    return rolesByAclName;
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

private boolean isValidDetectionPipeline(String pipelineName, List<TaskDefinitionRef> taskDefinitions,
        Set<StateDefinition> currentStates) {
    if (taskDefinitions.size() == 1) {
        // There's only one task in the pipeline, and we know it to be detection.
        boolean rValue = true;
        Set<StateDefinitionRef> requiredStates = requiredTaskStates
                .get(StringUtils.upperCase(taskDefinitions.get(0).getName()));
        if (!currentStates.containsAll(requiredStates)) {
            log.error("{}: The states for {} are not satisfied. Current: {}. Required: {}.", pipelineName,
                    taskDefinitions.get(0).getName(), currentStates, requiredStates);
            rValue = false;//from  w w  w .  j  a  va2s .  c o m
        }
        return rValue;
    } else if (getTask(taskDefinitions.get(0)).getActions().size() > 1) {
        // There's more than one task, and the number of actions in the first task exceeds 1.
        log.error("{}: No tasks may follow the multi-detection task of {}.", pipelineName,
                taskDefinitions.get(0).getName());
        return false;
    } else if (getTask(taskDefinitions.get(1)) == null) {
        // At this point, we've determined there's at least one more task. The next task name must exist.
        log.error("{}: Task with name {} does not exist.", pipelineName, taskDefinitions.get(1).getName());
        return false;
    } else {
        currentStates.addAll(providedTaskStates.get(StringUtils.upperCase(taskDefinitions.get(0).getName())));
        ActionType nextTaskType = getTaskType(taskDefinitions.get(1));
        switch (nextTaskType) {
        case DETECTION:
            currentStates.clear(); // If the next task is detection-based, we should disregard the current states as we're downselecting.
            return isValidDetectionPipeline(pipelineName, taskDefinitions.subList(1, taskDefinitions.size()),
                    currentStates);
        case MARKUP:
            return isValidMarkupPipeline(pipelineName, taskDefinitions.subList(1, taskDefinitions.size()),
                    currentStates);
        default:
            log.error("{}: {} is a detection task and may not be followed by {}.", pipelineName,
                    taskDefinitions.get(0).getName(), taskDefinitions.get(1).getName());
            return false;
        }
    }
}