List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.EnforceVariablesVisitor.java
@Override public ILogicalOperator visitUnnestMapOperator(UnnestMapOperator op, Collection<LogicalVariable> varsToRecover) throws AlgebricksException { Set<LogicalVariable> liveVars = new HashSet<>(); VariableUtilities.getLiveVariables(op, liveVars); varsToRecover.remove(liveVars); if (!varsToRecover.isEmpty()) { op.setPropagatesInput(true);// www .j a v a2s .c om return visitsInputs(op, varsToRecover); } return op; }
From source file:org.artifactory.ui.rest.service.builds.buildsinfo.tabs.licenses.BuildLicensesService.java
@Override public void execute(ArtifactoryRestRequest request, RestResponse response) { try {/*from w ww . j a v a2 s . c o m*/ String name = request.getPathParamByKey("name"); String buildNumber = request.getPathParamByKey("number"); String buildStarted = DateUtils.formatBuildDate(Long.parseLong(request.getPathParamByKey("date"))); Boolean authFind = Boolean.valueOf(request.getQueryParamByKey("autoFind")); Build build = getBuild(name, buildNumber, buildStarted, response); // fetch license Multimap<RepoPath, ModuleLicenseModel> repoPathLicenseModuleModel = getRepoPathLicenseModuleModelMultimap( build, authFind); if (repoPathLicenseModuleModel != null && !repoPathLicenseModuleModel.isEmpty()) { Collection<ModuleLicenseModel> values = repoPathLicenseModuleModel.values(); // fetch published modules Set<ModuleLicenseModel> publishedModules = getPublishedModulesFromModelList(values, build.getModules()); // filter published modules from licenses publishedModules.forEach(published -> values.remove(published)); // fetch build license summary Set<String> scopes = getScopeMapping(values); BuildLicenseModel buildLicenseModel = new BuildLicenseModel(values, publishedModules, scopes); response.iModel(buildLicenseModel); // get scopes } } catch (ParseException e) { log.error(e.toString()); response.error("error with retrieving build licenses"); return; } }
From source file:uk.ac.ebi.intact.psimitab.converters.expansion.SpokeExpansion.java
/** * Interaction having more than 2 components get split following the spoke model expansion. That is, we build * pairs of components following bait-prey and enzyme-target associations. * * @param interaction a non null interaction. * @return a non null collection of interaction, in case the expansion is not possible, we may return an empty * collection.//from w w w. j a va 2 s .c o m */ public Collection<BinaryInteraction> expand(Interaction interaction) throws NotExpandableInteractionException { if (interaction == null) { throw new NotExpandableInteractionException("Interaction is not expandable: " + interaction); } InteractionCategory category = findInteractionCategory(interaction); if (category == null) { return Collections.EMPTY_LIST; } Collection<BinaryInteraction> interactions = new ArrayList<BinaryInteraction>(); if (category.equals(InteractionCategory.binary)) { logger.debug("Interaction was binary, no further processing involved."); BinaryInteraction binary = interactionConverter.toBinaryInteraction(interaction); if (binary != null) { interactions.add(binary); } } else if (category.equals(InteractionCategory.self_intra_molecular)) { logger.debug("Interaction was self/intra molecular, no further processing involved."); BinaryInteraction binary2 = interactionConverter.toBinaryInteraction(interaction); if (binary2 != null) { interactions.add(binary2); } } else if (category.equals(InteractionCategory.self_inter_molecular)) { logger.debug("Interaction was self/inter molecular, we duplicate interactor."); BinaryInteraction binaryTemplateSelf = this.interactionConverter .processInteractionDetailsWithoutInteractors(interaction); if (binaryTemplateSelf == null) { return Collections.EMPTY_LIST; } Component uniqueComponent = interaction.getComponents().iterator().next(); MitabExpandedInteraction newInteraction = buildInteraction(binaryTemplateSelf, uniqueComponent, uniqueComponent, false); BinaryInteraction expandedBinary = newInteraction.getBinaryInteraction(); interactions.add(expandedBinary); // process participant detection methods after setting the interactors if not done at the level of interactiors if (interactionConverter.isProcessExperimentDetails() && newInteraction.getMitabInteractorA() .getInteractor().getParticipantIdentificationMethods().isEmpty()) { interactionConverter.processExperimentParticipantIdentificationMethods(interaction, newInteraction.getMitabInteractorA().getInteractor()); } if (interactionConverter.isProcessExperimentDetails() && newInteraction.getMitabInteractorB() .getInteractor().getParticipantIdentificationMethods().isEmpty()) { interactionConverter.processExperimentParticipantIdentificationMethods(interaction, newInteraction.getMitabInteractorB().getInteractor()); } // reset stoichiometry of duplicated interactor to 0 Interactor interactorB = expandedBinary.getInteractorB(); interactorB.getStoichiometry().clear(); interactorB.getStoichiometry().add(0); // computes Rigid if necessary RigDataModel rigDatamodel = newInteraction.getMitabInteractorA().getRigDataModel(); if (rigDatamodel != null) { String rigid = interactionConverter.calculateRigidFor(Arrays.asList(rigDatamodel)); if (rigid != null) { Checksum checksum = new ChecksumImpl(InteractionConverter.RIGID, rigid); expandedBinary.getChecksums().add(checksum); } } // flip interactors if necessary interactionConverter.flipInteractorsIfNecessary(expandedBinary); } else { logger.debug("Interaction was n-ary, will be expanded"); BinaryInteraction binaryTemplate = this.interactionConverter .processInteractionDetailsWithoutInteractors(interaction); if (binaryTemplate == null) { return Collections.EMPTY_LIST; } Component baitComponent = interaction.getBait(); if (baitComponent != null) { Collection<Component> preyComponents = new ArrayList<Component>(interaction.getComponents().size()); preyComponents.addAll(interaction.getComponents()); preyComponents.remove(baitComponent); Set<RigDataModel> rigDataModels = new HashSet<RigDataModel>(preyComponents.size()); boolean isFirst = true; boolean onlyProtein = true; for (Component preyComponent : preyComponents) { MitabExpandedInteraction newInteraction = buildInteraction(binaryTemplate, baitComponent, preyComponent, true); BinaryInteraction expandedBinary2 = newInteraction.getBinaryInteraction(); interactions.add(expandedBinary2); // process participant detection methods after setting the interactors if not done at the level of interactiors if (newInteraction.getMitabInteractorA().getInteractor().getParticipantIdentificationMethods() .isEmpty()) { interactionConverter.processExperimentParticipantIdentificationMethods(interaction, newInteraction.getMitabInteractorA().getInteractor()); } if (newInteraction.getMitabInteractorB().getInteractor().getParticipantIdentificationMethods() .isEmpty()) { interactionConverter.processExperimentParticipantIdentificationMethods(interaction, newInteraction.getMitabInteractorB().getInteractor()); } // count the first interactor rogid only once if (isFirst) { isFirst = false; if (newInteraction.getMitabInteractorA().getRigDataModel() != null) { rigDataModels.add(newInteraction.getMitabInteractorA().getRigDataModel()); } else { onlyProtein = false; } } if (newInteraction.getMitabInteractorB().getRigDataModel() != null) { rigDataModels.add(newInteraction.getMitabInteractorB().getRigDataModel()); } else { onlyProtein = false; } // flip interactors if necessary interactionConverter.flipInteractorsIfNecessary(expandedBinary2); } // process rigid if possible if (onlyProtein) { String rigid = interactionConverter.calculateRigidFor(rigDataModels); // add rigid to the first binary interaction because all the biary interactions are pointing to the same checksum list if (rigid != null) { Checksum checksum = new ChecksumImpl(InteractionConverter.RIGID, rigid); interactions.iterator().next().getChecksums().add(checksum); } } } else { Collection<BinaryInteraction> expandedWithoutBait = processExpansionWithoutBait(interaction, binaryTemplate); interactions.addAll(expandedWithoutBait); } logger.debug("After expansion: " + interactions.size() + " binary interaction(s) were generated."); } return interactions; }
From source file:com.eucalyptus.images.Images.java
public static Predicate<ImageInfo> filterExecutableBy(final Collection<String> executableSet) { final boolean executableSelf = executableSet.remove(SELF); final boolean executableAll = executableSet.remove("all"); return new Predicate<ImageInfo>() { @Override//from w ww .ja v a 2 s.c o m public boolean apply(ImageInfo image) { if (executableSet.isEmpty() && !executableSelf && !executableAll) { return true; } else { UserFullName userFullName = Contexts.lookup().getUserFullName(); return (executableAll && image.getImagePublic()) || (executableSelf && image.hasPermission(userFullName.getAccountNumber())) || image.hasPermission(executableSet.toArray(new String[executableSet.size()])); } } }; }
From source file:com.silverpeas.gallery.process.GalleryProcessManagement.java
/** * Adds processes to delete all media from the given album * @param albumPk//from w w w. j a v a2 s. com * @throws Exception */ private void addDeleteMediaAlbumProcesses(final NodePK albumPk) throws Exception { for (final Media media : getGalleryBm().getAllMedia(albumPk, MediaCriteria.VISIBILITY.FORCE_GET_ALL)) { Collection<String> albumIds = getGalleryBm().getAlbumIdsOf(media); if (albumIds.size() > 1) { // the image is in several albums // delete only the link between it and album to delete albumIds.remove(albumPk.getId()); media.setToAlbums(albumIds.toArray(new String[albumIds.size()])); } else { addDeleteMediaProcesses(media); } } }
From source file:org.apache.hadoop.ha.HAAdmin.java
/** * Checks whether other target node is active or not * @param targetNodeToActivate//from w w w . jav a 2s . co m * @return true if other target node is active or some other exception * occurred and forceActive was set otherwise false * @throws IOException */ private boolean isOtherTargetNodeActive(String targetNodeToActivate, boolean forceActive) throws IOException { Collection<String> targetIds = getTargetIds(targetNodeToActivate); targetIds.remove(targetNodeToActivate); for (String targetId : targetIds) { HAServiceTarget target = resolveTarget(targetId); if (!checkManualStateManagementOK(target)) { return true; } try { HAServiceProtocol proto = target.getProxy(getConf(), 5000); if (proto.getServiceStatus().getState() == HAServiceState.ACTIVE) { errOut.println("transitionToActive: Node " + targetId + " is already active"); printUsage(errOut, "-transitionToActive"); return true; } } catch (Exception e) { //If forceActive switch is false then return true if (!forceActive) { errOut.println("Unexpected error occurred " + e.getMessage()); printUsage(errOut, "-transitionToActive"); return true; } } } return false; }
From source file:de.dhke.projects.cutil.collections.aspect.AspectMultiMapTest.java
/** * Test of get method, of class AspectMultiMap. *//*from www. j a v a 2 s . c om*/ @Test public void testGet() { TestHelper.assertSequenceEquals(Arrays.asList("a", "A"), _aspectMap.get("1")); assertEquals("b", _aspectMap.remove("2", "b")); TestHelper.assertSequenceEquals(Arrays.asList("B"), _aspectMap.get("2")); Collection<String> values = _aspectMap.get("3"); assertTrue(values.remove("c")); assertFalse(_aspectMap.containsValue("3", "c")); }
From source file:org.limewire.mojito.handler.request.FindNodeRequestHandler.java
/** * This method returns a list of nodes along with a SecurityToken generated for this node. * The SecurityToken will can then be used by the querying node to store data at this node. * /*from w w w. j a v a 2 s. c o m*/ * If the local node is passive (e.g. firewalled), it returns a list of Most Recently Seen * nodes instead of returning the closest nodes to the lookup key. The reason for this is that * passive nodes do not have accurate routing tables. * * @param message the RequestMessage for this lookup * @throws IOException */ @Override protected void request(RequestMessage message) throws IOException { // Cast to LookupRequest because FindValueRequestHandler // is delegating requests to this class! LookupRequest request = (LookupRequest) message; KUID lookupId = request.getLookupID(); Contact node = request.getContact(); Collection<Contact> nodes = Collections.emptyList(); if (!context.isBootstrapping()) { if (context.isFirewalled()) { nodes = ContactUtils.sort(context.getRouteTable().getContacts(), KademliaSettings.REPLICATION_PARAMETER.getValue()); // If the external port is not set then make sure // we're not in the list! if (context.getExternalPort() == 0) { nodes.remove(context.getLocalNode()); } } else { nodes = context.getRouteTable().select(lookupId, KademliaSettings.REPLICATION_PARAMETER.getValue(), SelectMode.ALIVE); } } if (LOG.isTraceEnabled()) { if (!nodes.isEmpty()) { LOG.trace("Sending back: " + CollectionUtils.toString(nodes) + " to: " + node); } else { LOG.trace("Sending back an empty list to: " + node); } } context.getNetworkStats().LOOKUP_REQUESTS.incrementStat(); FindNodeResponse response = context.getMessageHelper().createFindNodeResponse(request, nodes); context.getMessageDispatcher().send(node, response); }
From source file:org.silverpeas.components.gallery.process.GalleryProcessManagement.java
/** * Adds processes to delete all media from the given album * @param albumPk//from ww w. j a v a 2 s .c om * @throws Exception */ private void addDeleteMediaAlbumProcesses(final NodePK albumPk) { for (final Media media : getGalleryService().getAllMedia(albumPk, MediaCriteria.VISIBILITY.FORCE_GET_ALL)) { Collection<String> albumIds = getGalleryService().getAlbumIdsOf(media); if (albumIds.size() > 1) { // the image is in several albums // delete only the link between it and album to delete albumIds.remove(albumPk.getId()); media.setToAlbums(albumIds.toArray(new String[albumIds.size()])); } else { addDeleteMediaProcesses(media); } } }
From source file:org.sonar.java.JavaClasspath.java
private List<File> getMatchingFiles(String pattern, File dir, boolean libraryProperty) { WilcardPatternFileFilter wilcardPatternFileFilter = new WilcardPatternFileFilter(dir, pattern); FileFilter fileFilter = wilcardPatternFileFilter; List<File> files = Lists.newArrayList(); if (libraryProperty) { if (pattern.endsWith("*")) { fileFilter = new AndFileFilter((IOFileFilter) fileFilter, new OrFileFilter(Lists.newArrayList(suffixFileFilter(".jar", IOCase.INSENSITIVE), suffixFileFilter(".zip", IOCase.INSENSITIVE)))); }//from ww w .j a v a 2s . c o m //find jar and zip files files.addAll( Lists.newArrayList(FileUtils.listFiles(dir, (IOFileFilter) fileFilter, TrueFileFilter.TRUE))); } //find directories matching pattern. IOFileFilter subdirectories = pattern.isEmpty() ? FalseFileFilter.FALSE : TrueFileFilter.TRUE; Collection<File> dirs = FileUtils.listFilesAndDirs(dir, new AndFileFilter(wilcardPatternFileFilter, DirectoryFileFilter.DIRECTORY), subdirectories); //remove searching dir from matching as listFilesAndDirs always includes it in the list see https://issues.apache.org/jira/browse/IO-328 if (!pattern.isEmpty()) { dirs.remove(dir); //remove subdirectories that were included during search Iterator<File> iterator = dirs.iterator(); while (iterator.hasNext()) { File matchingDir = iterator.next(); if (!wilcardPatternFileFilter.accept(matchingDir)) { iterator.remove(); } } } if (libraryProperty) { for (File directory : dirs) { files.addAll(getMatchingFiles("**/*.jar", directory, true)); files.addAll(getMatchingFiles("**/*.zip", directory, true)); } } files.addAll(dirs); return files; }