List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:de.innovationgate.webgate.api.jdbc.filehandling.CS41FileAttachmentHandler.java
@Override public List<String> getFileNames() throws WGAPIException { List<String> files = new ArrayList<String>(_entity.getFileEntities().keySet()); files.removeAll(_removedFiles.keySet()); return files; }
From source file:gr.abiss.calipso.wicket.components.validators.NonDuplicateInputValidator.java
protected void onValidate(IValidatable validatable) { String s = (String) validatable.getValue(); // the original list of the text area // split by win/unix new lines just in case and remove empty new lines. List<String> _originalOptions = Arrays.asList(s.split("[\\r\\n]+")); // the above cannot be modified... List<String> originalOptions = new ArrayList<String>(_originalOptions); Set<String> uniqueOptions = new HashSet<String>(originalOptions); Map<String, String> errorVars = new HashMap<String, String>(); boolean valid = true; // check for entering dupes within the textarea if (originalOptions.size() != uniqueOptions.size()) { valid = false;//from w w w . j a va 2s . co m // remove the rest to add a message for the duplicates originalOptions.removeAll(uniqueOptions); errorVars.put("duplicateEntry", (String) CollectionUtils.disjunction(originalOptions, uniqueOptions).iterator().next()); } else { // check for entering an existing option for (String originalOption : originalOptions) { if (field.hasOption(originalOption)) { valid = false; errorVars.put("duplicateEntry", originalOption); } } } if (!valid) { error(validatable, errorVars); } }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.database.DbHelperTest.java
@NonNull private List<Sign> getTestSigns() { final List<Sign> signsFromDb = signDAO.read(); final List<Sign> nonTestSigns = new ArrayList<>(); for (Sign sign : signsFromDb) { if (!sign.getName().startsWith("Test_Sign_")) { nonTestSigns.add(sign);//from w w w. j a v a 2 s . com } } signsFromDb.removeAll(nonTestSigns); return signsFromDb; }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationDocumentVisualizer.java
@Override protected String getDocumentData() { if (!dirty) { return docData; }//from www .ja v a 2 s.c om dirty = false; // Clear the rendered document docData = EMPTY_DOC; // Check if a document is set if (getModelObject() == null) { return docData; } // Get CAS from the repository JCas jCas = null; try { jCas = repository.readAnnotationCas(getModelObject()); } catch (DataRetrievalFailureException e) { error(e.getCause().getMessage()); } catch (IOException e) { error("Unable to read annotation document " + ExceptionUtils.getRootCauseMessage(e)); } // Generate BRAT object model from CAS GetDocumentResponse response = new GetDocumentResponse(); response.setText(jCas.getDocumentText()); BratAnnotatorModel bratAnnotatorModel = new BratAnnotatorModel(); SpanAdapter.renderTokenAndSentence(jCas, response, bratAnnotatorModel); int i = 0; for (AnnotationLayer layer : bratAnnotatorModel.getAnnotationLayers()) { if (layer.getName().equals(Token.class.getName())) { continue; } List<AnnotationFeature> features = annotationService.listAnnotationFeature(layer); List<AnnotationFeature> invisibleFeatures = new ArrayList<AnnotationFeature>(); for (AnnotationFeature feature : features) { if (!feature.isVisible()) { invisibleFeatures.add(feature); } } features.removeAll(invisibleFeatures); ColoringStrategy coloringStrategy = ColoringStrategy.getBestStrategy(layer, bratAnnotatorModel.getPreferences(), i); getAdapter(annotationService, layer).render(jCas, features, response, bratAnnotatorModel, coloringStrategy); i++; } // Serialize BRAT object model to JSON try { StringWriter out = new StringWriter(); JsonGenerator jsonGenerator = JSONUtil.getJsonConverter().getObjectMapper().getJsonFactory() .createJsonGenerator(out); jsonGenerator.writeObject(response); docData = out.toString(); } catch (IOException e) { error(ExceptionUtils.getRootCauseMessage(e)); } return docData; }
From source file:com.stratio.ingestion.sink.druid.DruidSink.java
private List<Event> takeEventsFromChannel(Channel channel, long eventsToTake) throws ChannelException { List<Event> events = new ArrayList<Event>(); Event event;/* w w w. ja va2s . co m*/ for (int i = 0; i < eventsToTake; i++) { event = buildEvent(channel); events.add(event); if (event != null) { sinkCounter.incrementEventDrainAttemptCount(); } } events.removeAll(Collections.singleton(null)); return events; }
From source file:io.lavagna.service.BulkOperationService.java
private List<Integer> addLabel(String projectShortName, LabelValue value, List<Integer> cardIds, User user, CardLabel cl) {//from w w w. java2 s .c om int labelId = cl.getId(); Project p = projectService.findByShortName(projectShortName); Validate.isTrue(cl.getProjectId() == p.getId()); List<Integer> filteredCardIds = keepCardIdsInProject(cardIds, projectShortName); Collection<Integer> alreadyWithLabel = keepCardWithMatching(filteredCardIds, new FilterByLabelIdAndLabelValueAndUniqueness(labelId, value)).keySet(); filteredCardIds.removeAll(alreadyWithLabel); // labelService.addLabelValueToCards(labelId, filteredCardIds, value, user, new Date()); return filteredCardIds; }
From source file:cepdest.pattern.holder.EnhancedPatternsHolder.java
@Override public void insertNewItinerary(Itinerary it) { if (it.getNumOfAllNamedAreas() > 1) { String patternId = null;/*from w w w.j av a 2s. co m*/ AreaOfInterest a1 = it.getAllNamedAreas().get(it.getNumOfAllNamedAreas() - 2); AreaOfInterest a2 = it.getAllNamedAreas().get(it.getNumOfAllNamedAreas() - 1); EnhancedPatternNode node1 = getNodeWithArea(a1); EnhancedPatternNode lastNode = getNodeWithArea(a2); Set<String> outPatternIds = lastNode.getPatternIds(); List<String> prevPatternIds = node1.getPatternIdsForSon(a2.getID()); if (prevPatternIds != null) { if (outPatternIds != null) { prevPatternIds.removeAll(outPatternIds); } int init = it.getNumOfAllNamedAreas() - 2; a2 = a1; for (int i = init; i > 0; i--) { a1 = it.getAllNamedAreas().get(i - 1); EnhancedPatternNode node = getNodeWithArea(a1); List<String> patternIds = node.getPatternIdsForSon(a2.getID()); if (patternIds == null) { break; } prevPatternIds.retainAll(patternIds); if (prevPatternIds.size() == 1) { patternId = prevPatternIds.get(0); break; } a2 = a1; } } if (patternId == null) { a1 = it.getAllNamedAreas().get(0); node1 = getNodeWithArea(a1); patternId = node1.createNewOwnPatternId(); } insertNewItineraryWithPatternId(it, patternId); } }
From source file:io.github.jeddict.jpa.modeler.widget.JavaClassWidget.java
public void scanDuplicateAttributes(String previousName, String newName) { int previousNameCount = 0, newNameCount = 0; List<AttributeWidget<? extends Attribute>> attributeWidgets = this.getAllAttributeWidgets(true); JavaClass javaClass = this.getBaseElementSpec(); List<Attribute> hiddenAttributes = new ArrayList<>(javaClass.getAttributes().getAllAttribute(true)); hiddenAttributes.removeAll( attributeWidgets.stream().map(aw -> (Attribute) aw.getBaseElementSpec()).collect(toList())); for (Attribute attribute : hiddenAttributes) { if (attribute.getName().equals(previousName)) { ++previousNameCount;/* w w w . j a va2s. co m*/ } if (attribute.getName().equals(newName)) { ++newNameCount; } } for (AttributeWidget<? extends Attribute> attributeWidget : attributeWidgets) { Attribute attribute = attributeWidget.getBaseElementSpec(); if (attribute.getName().equals(previousName)) { if (++previousNameCount > 1) { attributeWidget.getSignalManager().fire(ERROR, AttributeValidator.NON_UNIQUE_ATTRIBUTE_NAME); } else if (!attributeWidget.getSignalManager().getSignalList(ERROR).isEmpty()) { attributeWidget.getSignalManager().clear(ERROR, AttributeValidator.NON_UNIQUE_ATTRIBUTE_NAME); } } if (attribute.getName().equals(newName)) { if (++newNameCount > 1) { attributeWidget.getSignalManager().fire(ERROR, AttributeValidator.NON_UNIQUE_ATTRIBUTE_NAME); } else if (!attributeWidget.getSignalManager().getSignalList(ERROR).isEmpty()) { attributeWidget.getSignalManager().clear(ERROR, AttributeValidator.NON_UNIQUE_ATTRIBUTE_NAME); } } } }
From source file:org.obiba.mica.study.service.IndividualStudyService.java
private List<String> populationsOrDceAffected(Study study, Study oldStudy, boolean withDceStartField) { if (oldStudy != null) { List<String> newDceUIDs = toListOfDceUids(study, withDceStartField); List<String> oldDceUIDs = toListOfDceUids(oldStudy, withDceStartField); boolean isChangeSignificant = newDceUIDs.size() <= oldDceUIDs.size() && !newDceUIDs.containsAll(oldDceUIDs); if (isChangeSignificant) { oldDceUIDs.removeAll(newDceUIDs); return oldDceUIDs; } else/*www . ja v a 2 s . co m*/ return null; } else return null; }
From source file:net.cpollet.jixture.asserts.JixtureAssert.java
public JixtureAssert containsAtLeast(List<Fixture> fixtures) { List<Map<String, ?>> expectedMaps = new LinkedList<Map<String, ?>>(); for (Fixture fixture : fixtures) { expectedMaps.addAll(getExpectedMaps(fixture)); }/*from w ww. ja v a 2 s. c om*/ List<Map<String, ?>> actualMaps = getActualMaps(); if (!actualMaps.containsAll(expectedMaps)) { expectedMaps.removeAll(actualMaps); throw new AssertionError("Expected but missing elements " + expectedMaps.toString()); } return this; }