List of usage examples for java.util Set containsAll
boolean containsAll(Collection<?> c);
From source file:net.iaeste.iws.core.services.ExchangeCSVService.java
public OfferCSVUploadResponse uploadOffers(final Authentication authentication, final OfferCSVUploadRequest request) { final Map<String, OfferCSVUploadResponse.ProcessingResult> processingResult = new HashMap<>(); final OfferCSVUploadResponse response = new OfferCSVUploadResponse(); final Map<String, CSVProcessingErrors> errors = new HashMap<>(); try (Reader reader = new StringReader(request.getCsv()); CSVParser parser = getDefaultCsvParser(reader, request.getDelimiter().getDescription())) { final Set<String> headers = readHeader(parser); final Set<String> expectedHeaders = new HashSet<>(createFirstRow(OfferFields.Type.UPLOAD)); if (headers.containsAll(expectedHeaders)) { for (final CSVRecord record : parser.getRecords()) { process(processingResult, errors, authentication, record); }/*from w w w . j a va 2 s . co m*/ } else { throw new IWSException(IWSErrors.PROCESSING_FAILURE, "Invalid CSV header"); } } catch (IllegalArgumentException e) { throw new IWSException(IWSErrors.PROCESSING_FAILURE, "The header is invalid: " + e.getMessage() + '.', e); } catch (IOException e) { throw new IWSException(IWSErrors.PROCESSING_FAILURE, "CSV upload processing failed", e); } response.setProcessingResult(processingResult); response.setErrors(errors); return response; }
From source file:org.camelcookbook.splitjoin.aggregateparallel.AggregateExecutorServiceSpringTest.java
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2);//from w ww .j a va 2 s . c o m template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); final List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); final Message message1 = receivedExchanges.get(0).getIn(); final Message message2 = receivedExchanges.get(1).getIn(); log.info("exchange(0).header.group = {}", message1.getHeader("group")); log.info("exchange(0).property.CamelAggregatedCompletedBy = {}", message1.getExchange().getProperty("CamelAggregatedCompletedBy")); log.info("exchange(1).header.group = {}", message2.getHeader("group")); log.info("exchange(1).property.CamelAggregatedCompletedBy = {}", message2.getExchange().getProperty("CamelAggregatedCompletedBy")); final List<String> odd = Arrays.asList("One", "Three", "Five", "Seven", "Nine"); final List<String> even = Arrays.asList("Two", "Four", "Six", "Eight", "Ten"); @SuppressWarnings("unchecked") final Set<String> set1 = Collections.checkedSet(message1.getBody(Set.class), String.class); @SuppressWarnings("unchecked") final Set<String> set2 = Collections.checkedSet(message2.getBody(Set.class), String.class); if ("odd".equals(message1.getHeader("group"))) { assertTrue(set1.containsAll(odd)); assertTrue(set2.containsAll(even)); } else { assertTrue(set1.containsAll(even)); assertTrue(set2.containsAll(odd)); } }
From source file:com.griddynamics.banshun.DependencySorter.java
private List<Location> pullLocationListHead(Deque<Location> locations) { Set<String> resolvedBeans = new LinkedHashSet<>(); List<Location> resolvedLocations = new LinkedList<>(); for (Iterator<Location> it = locations.iterator(); it.hasNext();) { Location location = it.next(); if (resolvedBeans.containsAll(location.getImportBeanNames())) { resolvedBeans.addAll(location.getExportBeanNames()); resolvedLocations.add(location); it.remove(); //remove location from unresolved it = locations.iterator(); //reset iterator }/* w w w. j a v a 2 s . c o m*/ } return resolvedLocations; }
From source file:gaffer.graph.hook.OperationAuthoriser.java
protected void authorise(final Operation operation, final User user) { if (null != operation) { final Class<? extends Operation> opClass = operation.getClass(); final Set<String> userOpAuths = user.getOpAuths(); boolean authorised = true; for (final Entry<Class<? extends Operation>, Set<String>> entry : opAuthsMap.entrySet()) { if (entry.getKey().isAssignableFrom(opClass)) { if (!userOpAuths.containsAll(entry.getValue())) { authorised = false;/*from w w w.ja v a 2 s . co m*/ break; } } } if (!authorised) { throw new UnauthorisedException( "User does not have permission to run operation: " + operation.getClass().getName()); } } }
From source file:org.apache.calcite.rel.rules.AbstractMaterializedViewRule.java
/** * Given the query and view equivalence classes, it extracts the possible mappings * from each view equivalence class to each query equivalence class. * * <p>If any of the view equivalence classes cannot be mapped to a query equivalence * class, it returns null./*from www .jav a 2s .c o m*/ */ private static Mapping extractPossibleMapping(List<Set<RexTableInputRef>> queryEquivalenceClasses, List<Set<RexTableInputRef>> viewEquivalenceClasses) { Mapping mapping = Mappings.create(MappingType.FUNCTION, viewEquivalenceClasses.size(), queryEquivalenceClasses.size()); for (int i = 0; i < viewEquivalenceClasses.size(); i++) { boolean foundQueryEquivalenceClass = false; final Set<RexTableInputRef> viewEquivalenceClass = viewEquivalenceClasses.get(i); for (int j = 0; j < queryEquivalenceClasses.size(); j++) { final Set<RexTableInputRef> queryEquivalenceClass = queryEquivalenceClasses.get(j); if (queryEquivalenceClass.containsAll(viewEquivalenceClass)) { mapping.set(i, j); foundQueryEquivalenceClass = true; break; } } // end for if (!foundQueryEquivalenceClass) { // View equivalence class not found in query equivalence class return null; } } // end for return mapping; }
From source file:org.commonjava.cartographer.INTERNAL.ops.GraphOpsImpl.java
@Override public GraphExport exportGraph(final SingleGraphRequest recipe) throws CartoDataException, CartoRequestException { final ValueHolder<GraphExport> holder = new ValueHolder<>(); final GraphFunction extractor = (graph) -> { final Set<ProjectRelationship<?, ?>> rels = graph.getAllRelationships(); final Set<ProjectVersionRef> missing = graph.getAllIncompleteSubgraphs(); if (missing != null && missing.containsAll(recipe.getGraph().getRoots())) { holder.consumer().accept(null); }//from w w w. j a va 2 s. com final Set<ProjectVersionRef> variable = graph.getAllVariableSubgraphs(); final Set<EProjectCycle> cycles = graph.getCycles(); final Map<ProjectVersionRef, String> errorMap = graph.getAllProjectErrors(); ProjectErrors errors = new ProjectErrors(); for (ProjectVersionRef key : errorMap.keySet()) { errors.addProject(new ProjectError(key, errorMap.get(key))); } holder.consumer().accept(new GraphExport(rels, missing, variable, errors, cycles)); }; resolver.resolveAndExtractSingleGraph(AnyFilter.INSTANCE, recipe, extractor); return holder.get(); }
From source file:org.glite.slcs.struts.action.LoginAction.java
/** * Checks if all required attributes are present. * //from w ww.j a va 2s.c o m * @param attributes * List of user's attributes. * @throws AuthException * If a required attribute is missing * * @see AbstractAction#getRequiredAttributeNames() */ protected void checkRequiredAttributes(List userAttributes) throws AuthException { // get list of required attribute names List requiredAttributeNames = getRequiredAttributeNames(); // get list of user attribute names Set userAttributeNames = new HashSet(); Iterator attributes = userAttributes.iterator(); while (attributes.hasNext()) { Attribute attribute = (Attribute) attributes.next(); String attributeName = attribute.getName(); userAttributeNames.add(attributeName); } // compare with user attribute names if (!userAttributeNames.containsAll(requiredAttributeNames)) { Set missingAttributeNames = new HashSet(); Iterator requiredNames = requiredAttributeNames.iterator(); while (requiredNames.hasNext()) { String requiredName = (String) requiredNames.next(); if (!userAttributeNames.contains(requiredName)) { missingAttributeNames.add(requiredName); } } LOG.error("Missing required attribute(s): " + missingAttributeNames); throw new AuthException("Missing required attribute(s): " + missingAttributeNames); } }
From source file:com.hp.autonomy.frontend.find.idol.configuration.StatsServerConfig.java
public ValidationResult<?> validate(final AciService aciService, final Set<Statistic> requiredStatistics, final IdolAnnotationsProcessorFactory processorFactory) { final ValidationResult<?> serverResult = server.validate(aciService, null, processorFactory); if (!serverResult.isValid()) { return serverResult; }// w w w . j ava2s.co m final Set<Statistic> statistics; try { statistics = aciService.executeAction(server.toAciServerDetails(), new AciParameters("GetStatus"), new StatisticProcessor(processorFactory)); } catch (final ProcessorException | AciServiceException e) { return new ValidationResult<>(false, ValidationKey.CONNECTION_ERROR); } if (!statistics.containsAll(requiredStatistics)) { for (final Statistic statistic : statistics) { if (!requiredStatistics.contains(statistic)) { log.debug("Additional statistic present in StatsServer: {}", statistic); } } for (final Statistic requiredStatistic : requiredStatistics) { if (!statistics.contains(requiredStatistic)) { log.debug("Required statistic missing from StatsServer: {}", requiredStatistic); } } return new ValidationResult<>(false, ValidationKey.INVALID_CONFIGURATION); } return new ValidationResult<>(true); }
From source file:org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache.java
private boolean compareDataTypes(Map<String, ImmutablePair<Long, Long>> dataTypeNameToModificationTime, Map<String, ImmutablePair<Long, Long>> currentDataTypeToModificationTime) { if (dataTypeNameToModificationTime.size() != currentDataTypeToModificationTime.size()) { return true; } else {/* ww w .ja v a 2 s.com*/ Set<String> currentkeySet = currentDataTypeToModificationTime.keySet(); Set<String> keySet = dataTypeNameToModificationTime.keySet(); if (currentkeySet.containsAll(keySet)) { for (Entry<String, ImmutablePair<Long, Long>> entry : dataTypeNameToModificationTime.entrySet()) { String dataTypeName = entry.getKey(); ImmutablePair<Long, Long> creationAndModificationTimes = entry.getValue(); long creationTime = creationAndModificationTimes.getLeft() == null ? 0 : creationAndModificationTimes.getLeft().longValue(); long modificationTime = creationAndModificationTimes.getRight() == null ? 0 : creationAndModificationTimes.getRight().longValue(); ImmutablePair<Long, Long> currentEntry = currentDataTypeToModificationTime.get(dataTypeName); long currentCreationTime = currentEntry.getLeft() == null ? 0 : currentEntry.getLeft().longValue(); long currentModificationTime = currentEntry.getRight() == null ? 0 : currentEntry.getRight().longValue(); if (creationTime > currentCreationTime || modificationTime > currentModificationTime) { log.debug("Datatype {} was updated. Creation Time {} vs {}. Modification Time {} vs {}", dataTypeName, currentCreationTime, creationTime, currentModificationTime, modificationTime); return true; } } } else { return true; } } return false; }
From source file:org.apache.asterix.optimizer.rules.subplan.InlineLeftNtsInSubplanJoinFlatteningVisitor.java
@Override public ILogicalOperator visitUnnestMapOperator(UnnestMapOperator op, Void arg) throws AlgebricksException { visitSingleInputOperator(op);/*from w ww .ja va 2 s. c om*/ if (!rewritten) { return op; } Set<LogicalVariable> liveVars = new HashSet<>(); VariableUtilities.getLiveVariables(op, liveVars); if (!liveVars.containsAll(liveVarsFromSubplanInput)) { op.setPropagatesInput(true); } return op; }