List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:com.cimpoint.mes.server.services.BatchServiceImpl.java
@Override public Set<String> findBatchNumbersByWorkOrderNumber(String workOrderNumber) throws Exception { Set<String> result = new HashSet<String>(); result.addAll(batchRepository.findBatchByWorkOrderNumber(workOrderNumber)); return result; }
From source file:com.nebhale.buildmonitor.web.ControllerUtils.java
@ExceptionHandler(ConstraintViolationException.class) ResponseEntity<Set<String>> handleConstraintViolation(ConstraintViolationException e) { Set<ConstraintViolation<?>> constraintViolations = e.getConstraintViolations(); Set<String> messages = new HashSet<>(constraintViolations.size()); messages.addAll(constraintViolations.stream() .map(constraintViolation -> String.format("%s value '%s' %s", constraintViolation.getPropertyPath(), constraintViolation.getInvalidValue(), constraintViolation.getMessage())) .collect(Collectors.toList())); return new ResponseEntity<>(messages, HttpStatus.BAD_REQUEST); }
From source file:act.installer.brenda.BrendaChebiOntology.java
/** * This function fetches and construct the set of main and direct applications for each ontology that has a role. * @param ontologyMap map {chebi id -> ChebiOntology object} * @param isSubtypeOfRelationships map {chebi id -> set of chebi id for its subtypes} * @param hasRoleRelationships map {chebi id -> set of chebi id for its roles} * @return a map from ChebiOntology objects to a ChebiApplicationSet object *//*from w w w. ja v a2 s. c o m*/ public static Map<ChebiOntology, ChebiApplicationSet> getApplications(Map<String, ChebiOntology> ontologyMap, Map<String, Set<String>> isSubtypeOfRelationships, Map<String, Set<String>> hasRoleRelationships) { Map<String, Set<String>> applicationToMainApplicationsMap = getApplicationToMainApplicationsMap( isSubtypeOfRelationships, APPLICATION_CHEBI_ID); // Filter out the roles that are not applications Map<String, Set<String>> directApplicationMap = new HashMap<>(); hasRoleRelationships.forEach((key, value) -> directApplicationMap.put(key, value.stream().filter(ontology -> applicationToMainApplicationsMap.keySet().contains(ontology)) .collect(Collectors.toSet()))); // Compute the set of main applications for each ontology that has a role (aka is a chemical entity). Map<ChebiOntology, Set<ChebiOntology>> chemicalEntityToMainApplicationMap = new HashMap<>(); for (String chemicalEntity : directApplicationMap.keySet()) { Set<ChebiOntology> mainApplicationsSet = chemicalEntityToMainApplicationMap .get(ontologyMap.get(chemicalEntity)); if (mainApplicationsSet == null) { mainApplicationsSet = new HashSet<>(); chemicalEntityToMainApplicationMap.put(ontologyMap.get(chemicalEntity), mainApplicationsSet); } for (String parentApplication : directApplicationMap.get(chemicalEntity)) { Set<String> mainApplications = applicationToMainApplicationsMap.get(parentApplication); if (mainApplications != null) { mainApplicationsSet.addAll(mainApplications.stream().map(ontologyMap::get) .filter(Objects::nonNull).collect(Collectors.toSet())); } } } // Finally, construct a ChebiApplicationSet object containing direct and main applications for the molecules. Map<ChebiOntology, ChebiApplicationSet> chemicalEntityToApplicationsMap = new HashMap<>(); for (String chemicalEntity : directApplicationMap.keySet()) { Set<ChebiOntology> directApplications = directApplicationMap.get(chemicalEntity).stream() .map(ontologyMap::get).filter(Objects::nonNull).collect(Collectors.toSet()); Set<ChebiOntology> mainApplications = chemicalEntityToMainApplicationMap .get(ontologyMap.get(chemicalEntity)); if (directApplications.size() > 0 || mainApplications.size() > 0) { ChebiApplicationSet applications = new ChebiApplicationSet(directApplications, mainApplications); chemicalEntityToApplicationsMap.put(ontologyMap.get(chemicalEntity), applications); } } return chemicalEntityToApplicationsMap; }
From source file:de.fuberlin.wiwiss.r2r.Mapping.java
private static String hasCorrectVariableDependencies(Mapping mapping) { StringBuilder error = new StringBuilder(); Set<String> variablesForTargetPattern = new HashSet<String>(); Set<String> targetPatternVariablesDep = mapping.variableDependenciesOfTargetPatterns; Set<String> transformationVariablesDep = mapping.variableDependenciesOfTransformations; Set<String> transformationGeneratedVariables = mapping.transformationGeneratedVariables; Set<String> sourcePatternVariables = mapping.sourcePattern.getVariablesInPattern(); variablesForTargetPattern.addAll(transformationGeneratedVariables); variablesForTargetPattern.addAll(sourcePatternVariables); // Transformations depend on source pattern variables for (String var : transformationVariablesDep) if (!sourcePatternVariables.contains(var)) { error.append("Transformation definition depends on non existing variable: ?"); error.append(var); error.append(" of the source pattern. "); }/*from ww w. ja va2 s . c om*/ // Target Pattern depend on source pattern AND transformation variables for (String var : targetPatternVariablesDep) if (!variablesForTargetPattern.contains(var)) { error.append("Target Pattern definition depends on non existing variable: ?"); error.append(var); error.append(". "); } return error.toString(); }
From source file:models.NotificationEvent.java
private static Set<User> getReceivers(Organization organization) { Set<User> receivers = new HashSet<>(); List<User> managers = User.findUsersByOrganization(organization.id, RoleType.ORG_ADMIN); receivers.addAll(managers); return receivers; }
From source file:eu.itesla_project.modules.histo.cache.TwoLevelsHistoDbCache.java
@Override public List<String> listUrls() throws IOException { Set<String> urls = new LinkedHashSet<>(); urls.addAll(cache1.listUrls()); urls.addAll(cache2.listUrls());/*ww w .jav a2 s . c o m*/ return new ArrayList<>(urls); }
From source file:models.NotificationEvent.java
public static Set<User> getMentionedUsers(String body) { Matcher matcher = Pattern.compile("@" + User.LOGIN_ID_PATTERN_ALLOW_FORWARD_SLASH).matcher(body); Set<User> users = new HashSet<>(); while (matcher.find()) { String mentionWord = matcher.group().substring(1); users.addAll(findOrganizationMembers(mentionWord)); users.addAll(findProjectMembers(mentionWord)); users.add(User.findByLoginId(mentionWord)); }/* ww w . j a va 2 s . c om*/ users.remove(User.anonymous); return users; }
From source file:org.obiba.onyx.print.impl.PdfTemplateReport.java
public Set<Locale> availableLocales() { List<Locale> availableLocalesList = reportTemplateLoader.getAvailableLocales(); Set<Locale> availableLocales = new HashSet<Locale>(); availableLocales.addAll(availableLocalesList); return availableLocales; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.PeopleForUnitGroups.java
private Collection<Person> getPeopleForUnit(Unit unit) { Set<Person> people = new HashSet<Person>(); people.addAll(unit.getPossibleGroupMembers()); for (Unit subUnit : unit.getAllSubUnits()) { if (subUnit.isResearchUnit()) { people.addAll(subUnit.getPossibleGroupMembers()); }//from w w w .ja va 2 s.c om } for (PersistentGroupMembers persistentGroupMembers : unit.getPersistentGroupsSet()) { for (Person person : persistentGroupMembers.getPersonsSet()) { if (!people.contains(person)) { people.add(person); } } } return people; }
From source file:org.elasticsearch.xpack.security.authc.saml.SamlRealm.java
private static List<X509Credential> buildCredential(RealmConfig config, X509KeyPairSettings keyPairSettings, Setting<String> aliasSetting, final boolean allowMultiple) { final X509KeyManager keyManager = CertParsingUtils.getKeyManager(keyPairSettings, config.settings(), null, config.env());/*from w w w .ja v a2s . c om*/ if (keyManager == null) { return null; } final Set<String> aliases = new HashSet<>(); final String configuredAlias = aliasSetting.get(config.settings()); if (Strings.isNullOrEmpty(configuredAlias)) { final String[] serverAliases = keyManager.getServerAliases("RSA", null); if (serverAliases != null) { aliases.addAll(Arrays.asList(serverAliases)); } if (aliases.isEmpty()) { throw new IllegalArgumentException("The configured key store for " + RealmSettings.getFullSettingKey(config, keyPairSettings.getPrefix()) + " does not contain any RSA key pairs"); } else if (allowMultiple == false && aliases.size() > 1) { throw new IllegalArgumentException("The configured key store for " + RealmSettings.getFullSettingKey(config, keyPairSettings.getPrefix()) + " has multiple keys but no alias has been specified (from setting " + RealmSettings.getFullSettingKey(config, aliasSetting) + ")"); } } else { aliases.add(configuredAlias); } final List<X509Credential> credentials = new ArrayList<>(); for (String alias : aliases) { if (keyManager.getPrivateKey(alias) == null) { throw new IllegalArgumentException("The configured key store for " + RealmSettings.getFullSettingKey(config, keyPairSettings.getPrefix()) + " does not have a key associated with alias [" + alias + "] " + ((Strings.isNullOrEmpty(configuredAlias) == false) ? "(from setting " + RealmSettings.getFullSettingKey(config, aliasSetting) + ")" : "")); } final String keyType = keyManager.getPrivateKey(alias).getAlgorithm(); if (keyType.equals("RSA") == false) { throw new IllegalArgumentException("The key associated with alias [" + alias + "] " + "(from setting " + RealmSettings.getFullSettingKey(config, aliasSetting) + ") uses unsupported key algorithm type [" + keyType + "], only RSA is supported"); } credentials.add(new X509KeyManagerX509CredentialAdapter(keyManager, alias)); } return credentials; }