List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:cc.kave.episodes.mining.evaluation.PatternsIdentifier.java
public void validationCode(int numbRepos, int frequency, double entropy) throws Exception { List<Event> trainEvents = mappingParser.parse(numbRepos); Map<Integer, Set<Episode>> patterns = episodeProcessor.postprocess(numbRepos, frequency, entropy); List<Event> stream = repos.validationStream(numbRepos); Map<Event, Integer> mapEvents = mergeTrainingValidationEvents(stream, trainEvents); List<List<Fact>> streamMethods = streamOfMethods(stream, mapEvents); List<Event> listEvents = mapToList(mapEvents); StringBuilder sb = new StringBuilder(); int patternId = 0; for (Map.Entry<Integer, Set<Episode>> entry : patterns.entrySet()) { if ((entry.getKey() < 2) || (entry.getValue().size() == 0)) { continue; }//from w w w .j a v a 2s. com sb.append("Patterns of size: " + entry.getKey() + "-events\n"); sb.append("Pattern\tFrequency\toccurrencesAsSet\toccurrencesOrder\n"); for (Episode episode : entry.getValue()) { EnclosingMethods methodsNoOrderRelation = new EnclosingMethods(false); EnclosingMethods methodsOrderRelation = new EnclosingMethods(true); for (List<Fact> method : streamMethods) { if (method.containsAll(episode.getEvents())) { methodsNoOrderRelation.addMethod(episode, method, listEvents); methodsOrderRelation.addMethod(episode, method, listEvents); } } sb.append(patternId + "\t" + episode.getFrequency() + "\t" + methodsNoOrderRelation.getOccurrences() + "\t" + methodsOrderRelation.getOccurrences() + "\n"); patternsWriter(episode, trainEvents, numbRepos, frequency, entropy, patternId); patternId++; } sb.append("\n"); Logger.log("Processed %d-node patterns!", entry.getKey()); } FileUtils.writeStringToFile(getValidationPath(getPath(numbRepos, frequency, entropy)), sb.toString()); }
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 www .j a v a 2 s.com List<Map<String, ?>> actualMaps = getActualMaps(); if (!actualMaps.containsAll(expectedMaps)) { expectedMaps.removeAll(actualMaps); throw new AssertionError("Expected but missing elements " + expectedMaps.toString()); } return this; }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.SubplanOutOfGroupRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op0 = (AbstractLogicalOperator) opRef.getValue(); if (op0.getOperatorTag() != LogicalOperatorTag.GROUP) { return false; }//from w w w. j a v a2s . com GroupByOperator gby = (GroupByOperator) op0; Iterator<ILogicalPlan> plansIter = gby.getNestedPlans().iterator(); ILogicalPlan p = null; while (plansIter.hasNext()) { p = plansIter.next(); } if (p == null) { return false; } if (p.getRoots().size() != 1) { return false; } Mutable<ILogicalOperator> op1Ref = p.getRoots().get(0); AbstractLogicalOperator op1 = (AbstractLogicalOperator) op1Ref.getValue(); boolean found = false; while (op1.getInputs().size() == 1) { if (op1.getOperatorTag() == LogicalOperatorTag.SUBPLAN) { SubplanOperator subplan = (SubplanOperator) op1; AbstractLogicalOperator op2 = (AbstractLogicalOperator) subplan.getInputs().get(0).getValue(); if (OperatorPropertiesUtil.isNullTest(op2)) { if (subplan.getNestedPlans().size() == 1) { ILogicalPlan p1 = subplan.getNestedPlans().get(0); if (p1.getRoots().size() == 1) { AbstractLogicalOperator r1 = (AbstractLogicalOperator) p1.getRoots().get(0).getValue(); if (r1.getOperatorTag() == LogicalOperatorTag.INNERJOIN || r1.getOperatorTag() == LogicalOperatorTag.LEFTOUTERJOIN) { // now, check that it propagates all variables, // so it can be pushed List<LogicalVariable> op2Vars = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(op2, op2Vars); List<LogicalVariable> op1Vars = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(subplan, op1Vars); if (op1Vars.containsAll(op2Vars)) { found = true; break; } } } } } } op1Ref = op1.getInputs().get(0); op1 = (AbstractLogicalOperator) op1Ref.getValue(); } if (!found) { return false; } ILogicalOperator subplan = op1; ILogicalOperator op2 = op1.getInputs().get(0).getValue(); op1Ref.setValue(op2); Mutable<ILogicalOperator> opUnderRef = gby.getInputs().get(0); ILogicalOperator opUnder = opUnderRef.getValue(); subplan.getInputs().clear(); subplan.getInputs().add(new MutableObject<ILogicalOperator>(opUnder)); opUnderRef.setValue(subplan); return true; }
From source file:org.apache.hyracks.algebricks.rewriter.rules.subplan.SubplanOutOfGroupRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op0 = (AbstractLogicalOperator) opRef.getValue(); if (op0.getOperatorTag() != LogicalOperatorTag.GROUP) { return false; }/*ww w .ja va 2 s. c o m*/ GroupByOperator gby = (GroupByOperator) op0; Iterator<ILogicalPlan> plansIter = gby.getNestedPlans().iterator(); ILogicalPlan p = null; while (plansIter.hasNext()) { p = plansIter.next(); } if (p == null) { return false; } if (p.getRoots().size() != 1) { return false; } Mutable<ILogicalOperator> op1Ref = p.getRoots().get(0); AbstractLogicalOperator op1 = (AbstractLogicalOperator) op1Ref.getValue(); boolean found = false; while (op1.getInputs().size() == 1) { if (op1.getOperatorTag() == LogicalOperatorTag.SUBPLAN) { SubplanOperator subplan = (SubplanOperator) op1; AbstractLogicalOperator op2 = (AbstractLogicalOperator) subplan.getInputs().get(0).getValue(); if (OperatorPropertiesUtil.isMissingTest(op2)) { if (subplan.getNestedPlans().size() == 1) { ILogicalPlan p1 = subplan.getNestedPlans().get(0); if (p1.getRoots().size() == 1) { AbstractLogicalOperator r1 = (AbstractLogicalOperator) p1.getRoots().get(0).getValue(); if (r1.getOperatorTag() == LogicalOperatorTag.INNERJOIN || r1.getOperatorTag() == LogicalOperatorTag.LEFTOUTERJOIN) { // now, check that it propagates all variables, // so it can be pushed List<LogicalVariable> op2Vars = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(op2, op2Vars); List<LogicalVariable> op1Vars = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(subplan, op1Vars); if (op1Vars.containsAll(op2Vars)) { found = true; break; } } } } } } op1Ref = op1.getInputs().get(0); op1 = (AbstractLogicalOperator) op1Ref.getValue(); } if (!found) { return false; } ILogicalOperator subplan = op1; ILogicalOperator op2 = op1.getInputs().get(0).getValue(); op1Ref.setValue(op2); Mutable<ILogicalOperator> opUnderRef = gby.getInputs().get(0); ILogicalOperator opUnder = opUnderRef.getValue(); subplan.getInputs().clear(); subplan.getInputs().add(new MutableObject<ILogicalOperator>(opUnder)); opUnderRef.setValue(subplan); return true; }
From source file:it.unibas.spicy.model.algebra.NestedLoopJoinOperator.java
@SuppressWarnings("unchecked") private boolean equalListsForJoin(List list1, List list2) { if (isEmpty(list1) || isEmpty(list2)) { return false; }// w w w. ja v a2 s.c om return (list1.containsAll(list2) && list2.containsAll(list1)); }
From source file:gobblin.source.extractor.extract.google.GoogleDriveFsHelperTest.java
public void testList() throws IOException, FileBasedHelperException { java.util.List<String> filesRoot = Lists.newArrayList("f0_1", "f0_2", "f0_3", "f0_4", "f0_5"); java.util.List<String> filesL1 = Lists.newArrayList("f1_1", "f1_2", "f1_3", "f1_4"); java.util.List<String> filesL2 = Lists.newArrayList("f2_1", "f2_2"); String folderL1 = "folderL1"; String folderL2 = "folderL2"; String fileName = "test"; FileList rootFileList = createFileList(filesRoot, folderL1); FileList FileListL1 = createFileList(filesL1, folderL2); FileList FileListL2 = createFileList(filesL2, null); State state = new State(); state.appendToSetProp(GoogleDriveFileSystem.PAGE_SIZE, Integer.toString(1)); GoogleDriveFsHelper fsHelper = new GoogleDriveFsHelper(state, client, Closer.create()); List listRequest = mock(List.class); when(files.list()).thenReturn(listRequest); when(listRequest.setFields(anyString())).thenReturn(listRequest); when(listRequest.setPageSize(anyInt())).thenReturn(listRequest); GoogleDriveFileSystem fs = new GoogleDriveFileSystem(); when(listRequest.execute()).thenReturn(rootFileList); List ListL1Request = mock(List.class); when(listRequest.setQ(fs.buildQuery(folderL1, null).get())).thenReturn(ListL1Request); when(ListL1Request.execute()).thenReturn(FileListL1); List ListL2Request = mock(List.class); when(listRequest.setQ(fs.buildQuery(folderL2, null).get())).thenReturn(ListL2Request); when(ListL2Request.execute()).thenReturn(FileListL2); java.util.List<String> actual = fsHelper.ls(folderL2); java.util.List<String> expected = Lists.newArrayList(filesL2); Assert.assertTrue(actual.containsAll(expected) && expected.containsAll(actual)); actual = fsHelper.ls(folderL1);/*from w w w . j av a2 s .com*/ expected.addAll(filesL1); Assert.assertTrue(actual.containsAll(expected) && expected.containsAll(actual)); actual = fsHelper.ls(null); expected.addAll(filesRoot); Assert.assertTrue(actual.containsAll(expected) && expected.containsAll(actual)); }
From source file:com.threewks.thundr.module.Modules.java
/** * Determines the dependency order of all modules. * //from w w w. j av a 2 s.c om * @return */ protected List<Module> determineDependencyOrder() { List<Module> orderedModules = new ArrayList<Module>(); while (!orderedModules.containsAll(instances.values())) { boolean anyAdded = false; for (Map.Entry<Class<? extends Module>, Module> entry : instances.entrySet()) { Module instance = entry.getValue(); if (!orderedModules.contains(instance)) { Class<? extends Module> configurationClass = entry.getKey(); Collection<Class<? extends Module>> dependencies = moduleDependencies.get(configurationClass); List<? extends Module> injectionConfigurations = getModules(dependencies); if (orderedModules.containsAll(injectionConfigurations)) { orderedModules.add(instance); anyAdded = true; } } } if (!anyAdded) { List<Module> unloaded = Expressive.list(instances.values()).removeItems(orderedModules); EList<String> moduleNames = Transformers.toModuleNamesFromInstance.from(unloaded); throw new ModuleLoadingException( "Unable to load modules - there are unloaded modules whose dependencies cannot be satisfied. This probably indicates a cyclical dependency. The following modules have not been loaded: %s", StringUtils.join(moduleNames, " ")); } } return orderedModules; }
From source file:fi.vm.sade.organisaatio.auth.PermissionChecker.java
public void checkSaveOrganisation(OrganisaatioRDTO organisaatio, boolean update) { final OrganisaatioContext authContext = OrganisaatioContext.get(organisaatio); if (checkCRUDRyhma(authContext)) { return;/*from w w w.ja v a 2s .c o m*/ } if (update) { final Organisaatio current = organisaatioDAO.findByOid(organisaatio.getOid()); if (!Objects.equal(current.getNimi(), convertMapToMonikielinenTeksti(organisaatio.getNimi()))) { LOG.info("Nimi muuttunut"); // name changed checkPermission(permissionService.userCanEditName(authContext)); } if (OrganisaatioUtil.isSameDay(organisaatio.getAlkuPvm(), current.getAlkuPvm()) == false) { LOG.info("Alkupivmr muuttunut: " + current.getAlkuPvm() + " -> " + organisaatio.getAlkuPvm()); // date(s) changed checkPermission(permissionService.userCanEditDates(authContext)); } if (OrganisaatioUtil.isSameDay(organisaatio.getLakkautusPvm(), current.getLakkautusPvm()) == false) { LOG.info("Lakkautuspivmr muuttunut: " + current.getLakkautusPvm() + " -> " + organisaatio.getLakkautusPvm()); // date(s) changed checkPermission(permissionService.userCanEditDates(authContext)); } // TODO organisation type List<String> stringTyypit = organisaatio.getTyypit(); if (!(stringTyypit.size() == current.getTyypit().size() && stringTyypit.containsAll(current.getTyypit()))) { ///XXX what then? } checkPermission(permissionService.userCanUpdateOrganisation(authContext)); } else { checkPermission(permissionService .userCanCreateOrganisation(OrganisaatioContext.get(organisaatio.getParentOid()))); //TODO types } }
From source file:org.surfnet.oaaas.resource.resourceserver.ResourceServerResource.java
/** * Delete all scopes from clients that are not valid anymore with the new * resource server//from w w w.j a va2 s.c o m * * @param newScopes the newly saved scopes * @param oldScopes the scopes from the existing resource server * @param clients the clients of the resource server */ @SuppressWarnings("unchecked") protected void pruneClientScopes(final List<String> newScopes, List<String> oldScopes, Set<Client> clients) { if (!newScopes.containsAll(oldScopes)) { subtract(oldScopes, newScopes); Collection<String> outdatedScopes = subtract(oldScopes, newScopes); LOG.info("Resource server has updated scopes. Will remove all outdated scopes from clients: {}", outdatedScopes); for (Client c : clients) { final List<String> clientScopes = c.getScopes(); if (CollectionUtils.containsAny(clientScopes, outdatedScopes)) { ArrayList<String> prunedScopes = new ArrayList<String>(subtract(clientScopes, outdatedScopes)); LOG.info( "Client scopes of client {} were: {}. After pruning (because resourceServer has new scopes): {}", new Object[] { c.getClientId(), c.getScopes(), prunedScopes }); c.setScopes(prunedScopes); } } } }
From source file:org.apache.vxquery.compiler.rewriter.rules.algebricksalternatives.ExtractFunctionsFromJoinConditionRule.java
private boolean assignFunctionExpressions(AbstractLogicalOperator joinOp, ILogicalExpression expr, IOptimizationContext context) throws AlgebricksException { if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false; }/*ww w . jav a 2 s.c om*/ AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) expr; FunctionIdentifier fi = fexp.getFunctionIdentifier(); boolean modified = false; if (fi.equals(AlgebricksBuiltinFunctions.AND) || fi.equals(AlgebricksBuiltinFunctions.OR)) { for (Mutable<ILogicalExpression> a : fexp.getArguments()) { if (assignFunctionExpressions(joinOp, a.getValue(), context)) { modified = true; } } return modified; } else if (AlgebricksBuiltinFunctions.isComparisonFunction(fi)) { for (Mutable<ILogicalExpression> exprRef : fexp.getArguments()) { if (exprRef.getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { LogicalVariable newVar = context.newVar(); AssignOperator newAssign = new AssignOperator(newVar, new MutableObject<ILogicalExpression>(exprRef.getValue().cloneExpression())); newAssign.setExecutionMode(joinOp.getExecutionMode()); // Place assign below joinOp. List<LogicalVariable> used = new ArrayList<LogicalVariable>(); VariableUtilities.getUsedVariables(newAssign, used); Mutable<ILogicalOperator> leftBranchRef = joinOp.getInputs().get(0); ILogicalOperator leftBranch = leftBranchRef.getValue(); List<LogicalVariable> leftBranchVariables = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(leftBranch, leftBranchVariables); if (leftBranchVariables.containsAll(used)) { // place assign on left branch newAssign.getInputs().add(new MutableObject<ILogicalOperator>(leftBranch)); leftBranchRef.setValue(newAssign); modified = true; } else { Mutable<ILogicalOperator> rightBranchRef = joinOp.getInputs().get(1); ILogicalOperator rightBranch = rightBranchRef.getValue(); List<LogicalVariable> rightBranchVariables = new ArrayList<LogicalVariable>(); VariableUtilities.getLiveVariables(rightBranch, rightBranchVariables); if (rightBranchVariables.containsAll(used)) { // place assign on right branch newAssign.getInputs().add(new MutableObject<ILogicalOperator>(rightBranch)); rightBranchRef.setValue(newAssign); modified = true; } } if (modified) { // Replace original expr with variable reference. exprRef.setValue(new VariableReferenceExpression(newVar)); context.computeAndSetTypeEnvironmentForOperator(newAssign); context.computeAndSetTypeEnvironmentForOperator(joinOp); } } } return modified; } else { return false; } }