List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:io.cloudslang.lang.tools.build.SlangBuildMain.java
/** * Displays an informative message in case there is at least one test suite left for default run mode. * * @param unspecifiedTestSuiteRunMode the default run mode for suites that don't explicitly mention a run mode. * @param activeSuites the suite names that are active * @param sequentialSuites the suite names to be executed in sequential manner * @param parallelSuites the suite names to be executed in parallel */// w w w. j ava2 s .c o m private static void addInformativeNoteForUnspecifiedRules(final TestCaseRunMode unspecifiedTestSuiteRunMode, final List<String> activeSuites, final List<String> sequentialSuites, final List<String> parallelSuites) { List<String> union = union(sequentialSuites, parallelSuites); if (!union.containsAll(activeSuites)) { List<String> copy = new ArrayList<>(activeSuites); copy.removeAll(union); log.info(format(MESSAGE_TEST_SUITES_WITH_UNSPECIFIED_MAPPING, getListForPrint(copy), unspecifiedTestSuiteRunMode.name())); } }
From source file:io.cloudslang.lang.tools.build.SlangBuildMain.java
/** * Displays a warning message for test suites that have rules defined for sequential or parallel execution * but are not in active test suites.// w w w . j a v a 2 s. c o m * * @param testSuites suite names contained in 'container' suites * @param testSuitesContained suite names contained in 'contained' suites * @param key run configuration property key */ private static void addWarningForSubsetOfRules(List<String> testSuites, List<String> testSuitesContained, String key) { List<String> intersectWithContained = ListUtils.intersection(testSuites, testSuitesContained); if (intersectWithContained.size() != testSuitesContained.size()) { List<String> notScheduledForRun = new ArrayList<>(testSuitesContained); notScheduledForRun.removeAll(intersectWithContained); log.warn(format(MESSAGE_NOT_SCHEDULED_FOR_RUN_RULES, getListForPrint(notScheduledForRun), key)); } }
From source file:com.flexive.shared.content.FxDelta.java
/** * Compare <code>original</code> to <code>compare</code> FxContent. * Both contents should be compacted and empty entries removed for correct results. * Flatstorage entries will only be added to the remove list. * * @param original original content// ww w . j a va2 s . c o m * @param compare content that original is compared against * @return deltas * @throws FxInvalidParameterException on errors * @throws FxNotFoundException on errors */ public static FxDelta processDelta(final FxContent original, final FxContent compare) throws FxNotFoundException, FxInvalidParameterException { List<String> org = original.getAllXPaths("/"); List<String> comp = compare.getAllXPaths("/"); List<FxDeltaChange> updates = null, adds = null, removes = null; //remove all xpaths from comp that are not contained in org => updates List<String> update = new ArrayList<String>(comp); update.retainAll(org); for (String xp : update) { if (xp.endsWith("/")) { //group xp = xp.substring(0, xp.length() - 1); if (!compare.getGroupData(xp).equals(original.getGroupData(xp))) { if (updates == null) updates = new ArrayList<FxDeltaChange>(10); updates.add(new FxDeltaChange(FxDeltaChange.ChangeType.Update, xp, original.getGroupData(xp), compare.getGroupData(xp))); } } else if (!compare.getData(xp).equals(original.getData(xp))) { //property if (updates == null) updates = new ArrayList<FxDeltaChange>(10); final FxPropertyData orgData = original.getPropertyData(xp); updates.add(new FxDeltaChange(FxDeltaChange.ChangeType.Update, xp, orgData, compare.getPropertyData(xp))); } } List<String> add = new ArrayList<String>(comp); add.removeAll(org); for (String xp : add) { if (adds == null) adds = new ArrayList<FxDeltaChange>(10); if (xp.endsWith("/")) { //group xp = xp.substring(0, xp.length() - 1); adds.add(new FxDeltaChange(FxDeltaChange.ChangeType.Add, xp, null, compare.getGroupData(xp))); } else { //property final FxPropertyData pdata = compare.getPropertyData(xp); adds.add(new FxDeltaChange(FxDeltaChange.ChangeType.Add, xp, null, pdata)); } } List<String> rem = new ArrayList<String>(org); rem.removeAll(comp); for (String xp : rem) { if (removes == null) removes = new ArrayList<FxDeltaChange>(10); if (xp.endsWith("/")) { xp = xp.substring(0, xp.length() - 1); final FxGroupData groupData = original.getGroupData(xp); if (!groupData.isEmpty()) { removes.add(new FxDeltaChange(FxDeltaChange.ChangeType.Remove, xp, groupData, null)); } } else { final FxPropertyData propertyData = original.getPropertyData(xp); if (!propertyData.isEmpty()) { removes.add(new FxDeltaChange(FxDeltaChange.ChangeType.Remove, xp, propertyData, null)); } } } return new FxDelta(updates, adds, removes); }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.controller.BratAjaxCasController.java
/** * wrap JSON responses to BRAT visualizer * * @param aResponse/*from w ww .j a v a2s.c om*/ * the response. * @param aBModel * the annotator model. * @param aJCas * the JCas. * @param aAnnotationService * the annotation service.s */ public static void render(GetDocumentResponse aResponse, BratAnnotatorModel aBModel, JCas aJCas, AnnotationService aAnnotationService) { aResponse.setRtlMode(ScriptDirection.RTL.equals(aBModel.getScriptDirection())); // Render invisible baseline annotations (sentence, tokens) SpanAdapter.renderTokenAndSentence(aJCas, aResponse, aBModel); // Render visible (custom) layers Map<String[], Queue<String>> colorQueues = new HashMap<>(); for (AnnotationLayer layer : aBModel.getAnnotationLayers()) { if (layer.getName().equals(Token.class.getName()) || layer.getName().equals(Sentence.class.getName()) || (layer.getType().equals(CHAIN_TYPE) && (aBModel.getMode().equals(Mode.AUTOMATION) || aBModel.getMode().equals(Mode.CORRECTION) || aBModel.getMode().equals(Mode.CURATION))) || !layer.isEnabled()) { /* Hide layer if not enabled */ continue; } ColoringStrategy coloringStrategy = ColoringStrategy.getBestStrategy(aAnnotationService, layer, aBModel.getPreferences(), colorQueues); List<AnnotationFeature> features = aAnnotationService.listAnnotationFeature(layer); List<AnnotationFeature> invisibleFeatures = new ArrayList<AnnotationFeature>(); for (AnnotationFeature feature : features) { if (!feature.isVisible()) { invisibleFeatures.add(feature); } } features.removeAll(invisibleFeatures); TypeAdapter adapter = getAdapter(aAnnotationService, layer); adapter.render(aJCas, features, aResponse, aBModel, coloringStrategy); } }
From source file:com.espertech.esper.epl.core.ResultSetProcessorFactory.java
private static void validateHaving(Set<Pair<Integer, String>> propertiesGroupedBy, ExprNode havingNode) throws ExprValidationException { List<ExprAggregateNode> aggregateNodesHaving = new LinkedList<ExprAggregateNode>(); if (aggregateNodesHaving != null) { ExprAggregateNodeUtil.getAggregatesBottomUp(havingNode, aggregateNodesHaving); }/* w w w .j a v a 2s . c o m*/ // Any non-aggregated properties must occur in the group-by clause (if there is one) if (!propertiesGroupedBy.isEmpty()) { ExprNodeIdentifierVisitor visitor = new ExprNodeIdentifierVisitor(true); havingNode.accept(visitor); List<Pair<Integer, String>> allPropertiesHaving = visitor.getExprProperties(); Set<Pair<Integer, String>> aggPropertiesHaving = ExprNodeUtility .getAggregatedProperties(aggregateNodesHaving); allPropertiesHaving.removeAll(aggPropertiesHaving); allPropertiesHaving.removeAll(propertiesGroupedBy); if (!allPropertiesHaving.isEmpty()) { String name = allPropertiesHaving.iterator().next().getSecond(); throw new ExprValidationException("Non-aggregated property '" + name + "' in the HAVING clause must occur in the group-by clause"); } } }
From source file:ai.serotonin.haystack.validator.Source.java
public static void clean(List<HMap> rows) throws Exception { Set<String> tags = Tags.getTags(); // Dump the fields we're not interested in. List<HMap> rowDump = new ArrayList<>(); for (HMap row : rows) { Set<String> keyDump = new HashSet<>(); for (String key : row.keySet()) { if (!tags.contains(key)) keyDump.add(key);// www . j av a2s .co m } for (String key : keyDump) row.delete(key); row.delete("id"); row.delete("dis"); if (row.isEmpty()) rowDump.add(row); } rows.removeAll(rowDump); }
From source file:main.java.spatialrelex.Evaluator.java
/** * /* w ww. j a v a 2 s . c o m*/ * @param fileDocumentObject * @throws java.io.IOException */ public static void setSievesOrder(Map<String, Doc> fileDocumentObject) throws IOException { Map<String, Map<String, List<String>>> extractedMovelinks = combineMovelinkSubparts(); String bestSieve = ""; double bestSievePrecision = 0.0; //repeat for all remaining optional elements for (String relation : SpatialRelation.RELATION_ROLENAME.keySet()) { if (SpatialRelation.ORDERED_SIEVES.contains(relation)) continue; double tp = 0.0; double fp = 0.0; for (String file : fileDocumentObject.keySet()) { Doc document = fileDocumentObject.get(file); Map<String, Map<String, List<String>>> goldMovelinks = document.triggerMoverRoleOtherElements; for (String triggerMover : goldMovelinks.keySet()) { Map<String, List<String>> extractedRoleOtherElements = extractedMovelinks.get(triggerMover); if (extractedRoleOtherElements == null) continue; Map<String, List<String>> roleOtherElements = goldMovelinks.get(triggerMover); if (roleOtherElements != null) { for (String role : roleOtherElements.keySet()) { List<String> otherElements = roleOtherElements.get(role); if (!extractedRoleOtherElements.containsKey(role)) continue; List<String> extractedOtherElements = extractedRoleOtherElements.get(role); List<String> tempList = new ArrayList<>(otherElements); tempList.retainAll(extractedOtherElements); tp += tempList.size(); tempList = new ArrayList<>(extractedOtherElements); tempList.removeAll(otherElements); fp += tempList.size(); } continue; } for (String role : extractedRoleOtherElements.keySet()) { List<String> extractedOtherElements = extractedRoleOtherElements.get(role); fp += extractedOtherElements.size(); } } } double precision = getPrecision(tp, fp); if (precision > bestSievePrecision) { bestSieve = relation; bestSievePrecision = precision; } } SpatialRelation.ORDERED_SIEVES.add(bestSieve); addChosenSieveResults(extractedMovelinks, bestSieve); }
From source file:com.floragunn.searchguard.util.SecurityUtil.java
public static InetAddress getProxyResolvedHostAddressFromRequest(final RestRequest request, final Settings settings) throws UnknownHostException { // this.logger.debug(request.getClass().toString()); final String oaddr = ((InetSocketAddress) request.getRemoteAddress()).getHostString(); // this.logger.debug("original hostname: " + addr); String raddr = oaddr;// www . j av a2 s .c o m if (oaddr == null || oaddr.isEmpty()) { throw new UnknownHostException("Original host is <null> or <empty>"); } final InetAddress iaddr = InetAddress.getByName(oaddr); final String xForwardedForHeader = settings.get(ConfigConstants.SEARCHGUARD_HTTP_XFORWARDEDFOR_HEADER, "X-Forwarded-For"); if (xForwardedForHeader != null && !xForwardedForHeader.isEmpty()) { final String xForwardedForValue = request.header(xForwardedForHeader); //logger.trace("xForwardedForHeader is " + xForwardedForHeader + ":" + xForwardedForValue); final String[] xForwardedTrustedProxies = settings .getAsArray(ConfigConstants.SEARCHGUARD_HTTP_XFORWARDEDFOR_TRUSTEDPROXIES); final boolean xForwardedEnforce = settings .getAsBoolean(ConfigConstants.SEARCHGUARD_HTTP_XFORWARDEDFOR_ENFORCE, false); if (xForwardedForValue != null && !xForwardedForValue.isEmpty()) { final List<String> addresses = Arrays.asList(xForwardedForValue.replace(" ", "").split(",")); final List<String> proxiesPassed = new ArrayList<String>(addresses.subList(1, addresses.size())); if (xForwardedTrustedProxies.length == 0) { throw new UnknownHostException("No trusted proxies"); } proxiesPassed.removeAll(Arrays.asList(xForwardedTrustedProxies)); //logger.debug(proxiesPassed.size() + "/" + proxiesPassed); if (proxiesPassed.size() == 0 && (Arrays.asList(xForwardedTrustedProxies).contains(oaddr) || iaddr.isLoopbackAddress())) { raddr = addresses.get(0).trim(); } else { throw new UnknownHostException("Not all proxies are trusted"); } } else { if (xForwardedEnforce) { throw new UnknownHostException("Forward header enforced but not present"); } } } if (raddr == null || raddr.isEmpty()) { throw new UnknownHostException("Host is <null> or <empty>"); } if (raddr.equals(oaddr)) { return iaddr; } else { // if null or "" then loopback is returned return InetAddress.getByName(raddr); } }
From source file:com.petalmd.armor.util.SecurityUtil.java
public static InetAddress getProxyResolvedHostAddressFromRequest(final RestRequest request, final Settings settings) throws UnknownHostException { // this.logger.debug(request.getClass().toString()); final String oaddr = ((InetSocketAddress) request.getRemoteAddress()).getHostString(); // this.logger.debug("original hostname: " + addr); String raddr = oaddr;/* w w w . j av a 2 s .co m*/ if (oaddr == null || oaddr.isEmpty()) { throw new UnknownHostException("Original host is <null> or <empty>"); } final InetAddress iaddr = InetAddress.getByName(oaddr); final String xForwardedForHeader = settings.get(ConfigConstants.ARMOR_HTTP_XFORWARDEDFOR_HEADER, "X-Forwarded-For"); if (xForwardedForHeader != null && !xForwardedForHeader.isEmpty()) { final String xForwardedForValue = request.header(xForwardedForHeader); //logger.trace("xForwardedForHeader is " + xForwardedForHeader + ":" + xForwardedForValue); final String[] xForwardedTrustedProxies = settings .getAsArray(ConfigConstants.ARMOR_HTTP_XFORWARDEDFOR_TRUSTEDPROXIES); final boolean xForwardedEnforce = settings .getAsBoolean(ConfigConstants.ARMOR_HTTP_XFORWARDEDFOR_ENFORCE, false); if (xForwardedForValue != null && !xForwardedForValue.isEmpty()) { final List<String> addresses = Arrays.asList(xForwardedForValue.replace(" ", "").split(",")); final List<String> proxiesPassed = new ArrayList<String>(addresses.subList(1, addresses.size())); if (xForwardedTrustedProxies.length == 0) { throw new UnknownHostException("No trusted proxies"); } proxiesPassed.removeAll(Arrays.asList(xForwardedTrustedProxies)); //logger.debug(proxiesPassed.size() + "/" + proxiesPassed); if (proxiesPassed.size() == 0 && (Arrays.asList(xForwardedTrustedProxies).contains(oaddr) || iaddr.isLoopbackAddress())) { raddr = addresses.get(0).trim(); } else { throw new UnknownHostException("Not all proxies are trusted"); } } else { if (xForwardedEnforce) { throw new UnknownHostException("Forward header enforced but not present"); } } } if (raddr == null || raddr.isEmpty()) { throw new UnknownHostException("Host is <null> or <empty>"); } if (raddr.equals(oaddr)) { return iaddr; } else { // if null or "" then loopback is returned return InetAddress.getByName(raddr); } }
From source file:com.sapienter.jbilling.server.metafields.MetaFieldHelper.java
/** * Remove metafields from the entity with a value of null or '' * * @param entity// w w w . j a va2 s. c o m */ public static void removeEmptyMetaFields(MetaContent entity) { List<MetaFieldValue> metaFields = entity.getMetaFields(); List<MetaFieldValue> valuesToRemove = new ArrayList<MetaFieldValue>(metaFields.size()); for (MetaFieldValue mfValue : metaFields) { Object value = mfValue.getValue(); if (value == null || value.toString().trim().isEmpty()) { valuesToRemove.add(mfValue); } } metaFields.removeAll(valuesToRemove); }