List of usage examples for java.util Set removeAll
boolean removeAll(Collection<?> c);
From source file:com.siemens.sw360.importer.ComponentImportUtils.java
private static HashSet<Attachment> removeAutogeneratedAttachments( AttachmentService.Iface attachmentClient /*read value*/, Attachment attachment /*read value*/, Release release /*return value*/) throws TException { final HashSet<Attachment> attachmentsToRemove = new HashSet<>(); if (release.isSetAttachments()) { final AttachmentContent attachmentContent = attachmentClient .getAttachmentContent(attachment.getAttachmentContentId()); final Set<Attachment> attachments = release.getAttachments(); if (attachmentContent.isSetRemoteUrl()) { for (Attachment existentAttachment : attachments) { final AttachmentContent existentAttachmentContent = attachmentClient .getAttachmentContent(existentAttachment.getAttachmentContentId()); if (existentAttachmentContent.isSetRemoteUrl()) { if (existentAttachmentContent.getRemoteUrl().equals(attachmentContent.getRemoteUrl())) { attachmentsToRemove.add(existentAttachment); }//from w w w. jav a 2 s.com } } //This changes the release and this is actually used. attachments.removeAll(attachmentsToRemove); } } return attachmentsToRemove; }
From source file:es.uvigo.ei.sing.adops.datatypes.BatchProjectOutput.java
public boolean isFinished() { synchronized (this.projects) { final Set<Project> projects = new HashSet<>(this.projects.values()); projects.removeAll(this.projectErrors.keySet()); projects.removeAll(this.projectOutputs.keySet()); return projects.isEmpty(); }//from w ww . j ava2 s. c o m }
From source file:com.bluexml.side.Integration.alfresco.sql.synchronization.dialects.CreateTableStatement.java
public TableStatus checkStatus(Connection connection) { TableStatus status = TableStatus.EXISTS_MATCHED; ResultSet rs = null;/*from ww w . j a va 2 s . c o m*/ try { DatabaseMetaData databaseMetaData = connection.getMetaData(); rs = databaseMetaData.getColumns(null, null, tableName, "%"); if (!rs.next()) { status = TableStatus.NOT_EXISTS; } else { if (logger.isDebugEnabled()) logger.debug("Checking table '" + tableName + "'"); Map<String, Integer> tableColumns = new LinkedHashMap<String, Integer>(); do { String columnName = rs.getString("COLUMN_NAME"); Integer dataType = rs.getInt("DATA_TYPE"); if (logger.isDebugEnabled()) { String dataTypeDepName = rs.getString("TYPE_NAME"); logger.debug("Column '" + columnName + "' with type '" + dataTypeDepName + "'(" + dataType + ")"); } tableColumns.put(columnName, dataType); } while (rs.next()); rs.close(); // TODO : Implement type checking to return EXIST_SIMILAR if types are compatible Set<String> propertySet = columns.keySet(); propertySet.removeAll(tableColumns.keySet()); if (!propertySet.isEmpty()) { status = TableStatus.EXISTS_UNMATCHED; } if (customActionManager != null) { status = customActionManager.doInSchemaChecking(tableColumns, status, tableType); } else { if (logger.isDebugEnabled()) logger.debug( "Cannot execute any custom checking since no custom action manager has been defined on create statement for table '" + tableName + "'"); } } } catch (SQLException e) { logger.error("Cannot get meta-data for checking table status"); logger.debug(e); return TableStatus.NOT_CHECKABLE; } if (logger.isDebugEnabled()) logger.debug("Checking table output status '" + tableName + "': " + status.name()); return status; }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.op.manifest.KubernetesDeployManifestOperation.java
@Override public OperationResult operate(List _unused) { getTask().updateStatus(OP_NAME, "Beginning deployment of manifest..."); List<KubernetesManifest> inputManifests = description.getManifests(); List<KubernetesManifest> deployManifests = new ArrayList<>(); if (inputManifests == null || inputManifests.isEmpty()) { log.warn("Relying on deprecated single manifest input: " + description.getManifest()); inputManifests = Collections.singletonList(description.getManifest()); }/*from www . j a va 2 s . com*/ inputManifests = inputManifests.stream().filter(Objects::nonNull).collect(Collectors.toList()); List<Artifact> requiredArtifacts = description.getRequiredArtifacts(); if (requiredArtifacts == null) { requiredArtifacts = new ArrayList<>(); } List<Artifact> optionalArtifacts = description.getOptionalArtifacts(); if (optionalArtifacts == null) { optionalArtifacts = new ArrayList<>(); } List<Artifact> artifacts = new ArrayList<>(); artifacts.addAll(requiredArtifacts); artifacts.addAll(optionalArtifacts); Set<Artifact> boundArtifacts = new HashSet<>(); for (KubernetesManifest manifest : inputManifests) { if (StringUtils.isEmpty(manifest.getNamespace()) && manifest.getKind().isNamespaced()) { manifest.setNamespace(credentials.getDefaultNamespace()); } KubernetesResourceProperties properties = findResourceProperties(manifest); if (properties == null) { throw new IllegalArgumentException("Unsupported Kubernetes object kind '" + manifest.getKind().toString() + "', unable to continue."); } KubernetesHandler deployer = properties.getHandler(); if (deployer == null) { throw new IllegalArgumentException("No deployer available for Kubernetes object kind '" + manifest.getKind().toString() + "', unable to continue."); } getTask().updateStatus(OP_NAME, "Swapping out artifacts in " + manifest.getFullResourceName() + " from context..."); ReplaceResult replaceResult = deployer.replaceArtifacts(manifest, artifacts); deployManifests.add(replaceResult.getManifest()); boundArtifacts.addAll(replaceResult.getBoundArtifacts()); } Set<Artifact> unboundArtifacts = new HashSet<>(requiredArtifacts); unboundArtifacts.removeAll(boundArtifacts); getTask().updateStatus(OP_NAME, "Checking if all requested artifacts were bound..."); if (!unboundArtifacts.isEmpty()) { throw new IllegalArgumentException("The following artifacts could not be bound: '" + unboundArtifacts + "' . Failing the stage as this is likely a configuration error."); } getTask().updateStatus(OP_NAME, "Sorting manifests by priority..."); deployManifests.sort(Comparator.comparingInt(m -> findResourceProperties(m).getHandler().deployPriority())); getTask().updateStatus(OP_NAME, "Deploy order is: " + String.join(", ", deployManifests.stream() .map(KubernetesManifest::getFullResourceName).collect(Collectors.toList()))); OperationResult result = new OperationResult(); for (KubernetesManifest manifest : deployManifests) { KubernetesResourceProperties properties = findResourceProperties(manifest); boolean versioned = description.getVersioned() == null ? properties.isVersioned() : description.getVersioned(); KubernetesArtifactConverter converter = versioned ? properties.getVersionedConverter() : properties.getUnversionedConverter(); KubernetesHandler deployer = properties.getHandler(); Moniker moniker = description.getMoniker(); Artifact artifact = converter.toArtifact(provider, manifest); getTask().updateStatus(OP_NAME, "Annotating manifest " + manifest.getFullResourceName() + " with artifact, relationships & moniker..."); KubernetesManifestAnnotater.annotateManifest(manifest, artifact); namer.applyMoniker(manifest, moniker); manifest.setName(converter.getDeployedName(artifact)); getTask().updateStatus(OP_NAME, "Swapping out artifacts in " + manifest.getFullResourceName() + " from other deployments..."); ReplaceResult replaceResult = deployer.replaceArtifacts(manifest, new ArrayList<>(result.getCreatedArtifacts())); boundArtifacts.addAll(replaceResult.getBoundArtifacts()); manifest = replaceResult.getManifest(); getTask().updateStatus(OP_NAME, "Submitting manifest " + manifest.getFullResourceName() + " to kubernetes master..."); result.merge(deployer.deploy(credentials, manifest)); result.getCreatedArtifacts().add(artifact); } result.getBoundArtifacts().addAll(boundArtifacts); result.removeSensitiveKeys(registry, accountName); return result; }
From source file:com.atolcd.alfresco.web.scripts.shareStats.SelectUsersGet.java
@SuppressWarnings("unchecked") public Set<String> selectNeverConnectedUsers(AuditQueryParameters auditQueryParameters, AtolAuthorityParameters atolAuthorityParameters) { List<String> auditUsers = new ArrayList<String>(); auditUsers = (List<String>) this.sqlSessionTemplate.selectList(SELECT_CONNECTED_USERS, auditQueryParameters);//from w w w . ja v a 2 s . com Set<String> usersSet = this.selectSiteMembers(atolAuthorityParameters); // Differentiel usersSet.removeAll(auditUsers); return usersSet; }
From source file:com.ggvaidya.scinames.summary.HigherStabilityView.java
private String calculateDifferenceWithoutSynonymy(Set<Name> prevNames, Set<Name> names) { // There are three possibilities: // 1. IDENTICAL: no difference between these two sets. // 2. CONTRACTED: names contains every but not all names in prevNames // 3. EXPANDED: prevNames contains every but not all names in names // 4. COMPLEX: names have both EXPANDED and CONTRACTED Set<Name> prevButNotCurrent = new HashSet<>(prevNames); prevButNotCurrent.removeAll(names); Set<Name> currentButNotPrev = new HashSet<>(names); currentButNotPrev.removeAll(prevNames); if (prevButNotCurrent.isEmpty() && currentButNotPrev.isEmpty()) { return String.format("%.2g%% (IDENTICAL)", 100 * calculateSimilarity(prevNames, names)); } else if (!prevButNotCurrent.isEmpty() && currentButNotPrev.isEmpty()) { return String.format("%.2g%% (CONTRACTED BY " + prevButNotCurrent.size() + ")", 100 * calculateSimilarity(prevNames, names)); } else if (prevButNotCurrent.isEmpty() && !currentButNotPrev.isEmpty()) { return String.format("%.2g%% (EXPANDED BY " + currentButNotPrev.size() + ")", 100 * calculateSimilarity(prevNames, names)); } else {//from w w w .ja v a 2 s . c o m return String.format("%.2g%% (COMPLEX: " + prevButNotCurrent.size() + " deleted, " + currentButNotPrev.size() + " added)", 100 * calculateSimilarity(prevNames, names)); } }
From source file:com.gst.portfolio.self.loanaccount.data.SelfLoansDataValidator.java
public void validateRetrieveLoan(final UriInfo uriInfo) { List<String> unsupportedParams = new ArrayList<>(); Set<String> associationParameters = ApiParameterHelper .extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); if (!associationParameters.isEmpty()) { associationParameters.removeAll(allowedAssociationParameters); if (!associationParameters.isEmpty()) { unsupportedParams.addAll(associationParameters); }// www . j a va 2s . co m } if (uriInfo.getQueryParameters().getFirst("exclude") != null) { unsupportedParams.add("exclude"); } throwExceptionIfReqd(unsupportedParams); }
From source file:org.cloudfoundry.reconfiguration.spring.DataSourceCloudServiceBeanFactoryPostProcessor.java
@Override protected void filterBeanNames(ConfigurableListableBeanFactory beanFactory, Set<String> beanNames) { if (ClassUtils.isPresent(DELEGATING_DATA_SOURCE_CLASS, null)) { Set<String> delegatingBeanNames = Sets.asSet(beanFactory.getBeanNamesForType( ClassUtils.resolveClassName(DELEGATING_DATA_SOURCE_CLASS, null), true, false)); beanNames.removeAll(delegatingBeanNames); }// ww w. j av a 2 s . co m }
From source file:com.floragunn.searchguard.dlic.rest.validation.AbstractConfigurationValidator.java
public boolean validateSettings() { // no payload for DELETE and GET requests if (method.equals(Method.DELETE) || method.equals(Method.GET)) { return true; }/* w w w .j ava 2 s. co m*/ // try to parse payload try { this.settingsBuilder = toSettingsBuilder(content); } catch (ElasticsearchException e) { this.errorType = ErrorType.BODY_NOT_PARSEABLE; return false; } Settings settings = settingsBuilder.build(); Set<String> requested = settings.names(); // check if payload is accepted at all if (!this.payloadAllowed && !requested.isEmpty()) { this.errorType = ErrorType.PAYLOAD_NOT_ALLOWED; return false; } // check if payload is mandatory if (this.payloadMandatory && requested.isEmpty()) { this.errorType = ErrorType.PAYLOAD_MANDATORY; return false; } // mandatory settings, one of ... if (Collections.disjoint(requested, mandatoryOrKeys)) { this.missingMandatoryOrKeys.addAll(mandatoryOrKeys); } // mandatory settings Set<String> mandatory = new HashSet<>(mandatoryKeys); mandatory.removeAll(requested); missingMandatoryKeys.addAll(mandatory); // invalid settings Set<String> allowed = new HashSet<>(allowedKeys.keySet()); requested.removeAll(allowed); this.invalidKeys.addAll(requested); boolean valid = missingMandatoryKeys.isEmpty() && invalidKeys.isEmpty() && missingMandatoryOrKeys.isEmpty(); if (!valid) { this.errorType = ErrorType.INVALID_CONFIGURATION; } // check types try { if (!checkDatatypes()) { this.errorType = ErrorType.WRONG_DATATYPE; return false; } } catch (Exception e) { this.errorType = ErrorType.BODY_NOT_PARSEABLE; return false; } return valid; }
From source file:com.redhat.lightblue.metadata.mongo.BSONParser.java
@Override public Set<String> findFieldsNotIn(BSONObject elements, Set<String> removeAllFields) { final Set<String> strings = new HashSet<>(elements.keySet()); strings.removeAll(removeAllFields); return strings; }