List of usage examples for java.util Collection containsAll
boolean containsAll(Collection<?> c);
From source file:org.kuali.rice.devtools.jpa.eclipselink.conv.parser.helper.resolver.ManyToOneResolver.java
/** gets the annotation but also adds an import in the process if a Convert annotation is required. */ @Override/*from w w w . j a va2s . c o m*/ protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final ObjectReferenceDescriptor ord = OjbUtil.findObjectReferenceDescriptor(mappedClass, fieldName, descriptorRepositories); if (ord != null) { final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>(); final Collection<ImportDeclaration> additionalImports = new ArrayList<ImportDeclaration>(); final Collection<String> fks = ord.getForeignKeyFields(); if (fks == null || fks.isEmpty()) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName + " but does not have any foreign keys configured"); return null; } final Collection<String> pks = OjbUtil.getPrimaryKeyNames(mappedClass, descriptorRepositories); if (!(pks.size() == fks.size() && pks.containsAll(fks))) { final String className = ord.getItemClassName(); if (StringUtils.isBlank(className)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName + " but does not class name attribute"); } else { final String shortClassName = ClassUtils.getShortClassName(className); final String packageName = ClassUtils.getPackageName(className); pairs.add(new MemberValuePair("targetEntity", new NameExpr(shortClassName + ".class"))); additionalImports.add(new ImportDeclaration( new QualifiedNameExpr(new NameExpr(packageName), shortClassName), false, false)); } final boolean proxy = ord.isLazy(); if (proxy) { pairs.add(new MemberValuePair("fetch", new NameExpr("FetchType.LAZY"))); additionalImports.add(new ImportDeclaration( new QualifiedNameExpr(new NameExpr(PACKAGE), "FetchType"), false, false)); } final boolean refresh = ord.isRefresh(); if (refresh) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has refresh set to " + refresh + ", unsupported conversion to @OneToOne attributes"); } final List<Expression> cascadeTypes = new ArrayList<Expression>(); final boolean autoRetrieve = ord.getCascadeRetrieve(); if (autoRetrieve) { cascadeTypes.add(new NameExpr("CascadeType.REFRESH")); } else { // updated default logging - false would result no additional annotations if (LOG.isDebugEnabled()) { LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-retrieve set to " + autoRetrieve + ", unsupported conversion to CascadeType"); } } final int autoDelete = ord.getCascadingDelete(); if (autoDelete == ObjectReferenceDescriptor.CASCADE_NONE) { // updated default logging - none would result no additional annotations if (LOG.isDebugEnabled()) { LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-delete set to none, unsupported conversion to CascadeType"); } } else if (autoDelete == ObjectReferenceDescriptor.CASCADE_LINK) { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-delete set to link, unsupported conversion to CascadeType"); } else if (autoDelete == ObjectReferenceDescriptor.CASCADE_OBJECT) { cascadeTypes.add(new NameExpr("CascadeType.REMOVE")); } else { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-delete set to an invalid value"); } final int autoUpdate = ord.getCascadingStore(); if (autoUpdate == ObjectReferenceDescriptor.CASCADE_NONE) { // updated default logging - none would result no additional annotations if (LOG.isDebugEnabled()) { LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-update set to none, unsupported conversion to CascadeType"); } } else if (autoUpdate == ObjectReferenceDescriptor.CASCADE_LINK) { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-update set to link, unsupported conversion to CascadeType"); } else if (autoUpdate == ObjectReferenceDescriptor.CASCADE_OBJECT) { cascadeTypes.add(new NameExpr("CascadeType.PERSIST")); } else { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-update set to an invalid value"); } if (!cascadeTypes.isEmpty()) { pairs.add(new MemberValuePair("cascade", new ArrayInitializerExpr(cascadeTypes))); additionalImports.add(new ImportDeclaration( new QualifiedNameExpr(new NameExpr(PACKAGE), "CascadeType"), false, false)); } return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), pairs), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), additionalImports); } } return null; }
From source file:it.smartcommunitylab.aac.controller.ResourceAccessController.java
/** * Check the access to the specified resource using the client app token header * @param token/*from ww w . j a v a 2 s .c om*/ * @param resourceUri * @param request * @return */ @ApiOperation(value = "Check scope access for token") @RequestMapping(method = RequestMethod.GET, value = "/resources/access") @Deprecated public @ResponseBody Boolean canAccessResource(@RequestParam String scope, HttpServletRequest request) { try { String parsedToken = it.smartcommunitylab.aac.common.Utils.parseHeaderToken(request); OAuth2Authentication auth = resourceServerTokenServices.loadAuthentication(parsedToken); Collection<String> actualScope = auth.getOAuth2Request().getScope(); Collection<String> scopeSet = StringUtils.commaDelimitedListToSet(scope); if (actualScope != null && !actualScope.isEmpty() && actualScope.containsAll(scopeSet)) { return true; } } catch (AuthenticationException e) { logger.error("Error validating token: " + e.getMessage()); } return false; }
From source file:pt.ist.expenditureTrackingSystem.domain.acquisitions.ProjectFinancer.java
@Override public boolean hasAllInvoicesAllocatedInProject() { Collection<PaymentProcessInvoice> allocatedInvoices = getAllocatedInvoicesInProject(); for (UnitItem unitItem : getUnitItems()) { if (!allocatedInvoices.containsAll(unitItem.getConfirmedInvoices())) { return false; }//from w w w .j a v a2 s . co m } return true; }
From source file:org.kuali.student.common.util.krms.proposition.CourseCompletionProposition.java
@Override public PropositionResult evaluate(ExecutionEnvironment environment) { Collection<String> completedCourses = environment .resolveTerm(RulesExecutionConstants.STUDENT_COMPLETED_COURSE_IDS_TERM, this); Collection<String> termCourses = getTermCourseIds(environment); PropositionResult result = null;//from w w w . j a v a2 s . c o m if (checkForAllCompleted) { result = new PropositionResult(completedCourses.containsAll(termCourses)); } else { result = new PropositionResult( CollectionUtils.intersection(completedCourses, termCourses).size() >= minToComplete); } environment.getEngineResults().addResult( new BasicResult(ResultEvent.PROPOSITION_EVALUATED, this, environment, result.getResult())); return result; }
From source file:org.kuali.student.common.util.krms.proposition.CourseEnrollmentProposition.java
@Override public PropositionResult evaluate(ExecutionEnvironment environment) { Collection<String> enrolledCourses = environment .resolveTerm(RulesExecutionConstants.STUDENT_ENROLLED_COURSE_IDS_TERM, this); Collection<String> requiredCourseIds = getRequiredCourseIds(environment); PropositionResult result = null;//from w w w. j av a 2 s .c o m if (checkForAllEnrolled) { result = new PropositionResult(enrolledCourses.containsAll(requiredCourseIds)); } else { result = new PropositionResult( CollectionUtils.intersection(enrolledCourses, requiredCourseIds).size() >= minToEnroll); } environment.getEngineResults().addResult( new BasicResult(ResultEvent.PROPOSITION_EVALUATED, this, environment, result.getResult())); return result; }
From source file:pt.ist.expenditureTrackingSystem.domain.acquisitions.ProjectFinancer.java
@Override public boolean hasAllocatedFundsPermanentlyForAllProjectFinancers() { Collection<PaymentProcessInvoice> allocatedInvoicesInProject = getAllocatedInvoicesInProject(); for (UnitItem unitItem : getUnitItems()) { if (!allocatedInvoicesInProject.containsAll(unitItem.getConfirmedInvoices())) { return false; }/*from w w w . j a v a 2 s . co m*/ } return getEffectiveProjectFundAllocationId() != null && !getEffectiveProjectFundAllocationId().isEmpty(); }
From source file:org.kuali.rice.devtools.jpa.eclipselink.conv.parser.helper.resolver.OneToOneResolver.java
/** gets the annotation but also adds an import in the process if a Convert annotation is required. */ @Override// w w w .j av a 2 s .co m protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final ObjectReferenceDescriptor ord = OjbUtil.findObjectReferenceDescriptor(mappedClass, fieldName, descriptorRepositories); if (ord != null) { final List<MemberValuePair> pairs = new ArrayList<MemberValuePair>(); final Collection<ImportDeclaration> additionalImports = new ArrayList<ImportDeclaration>(); final Collection<String> fks = ord.getForeignKeyFields(); if (fks == null || fks.isEmpty()) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName + " but does not have any foreign keys configured"); return null; } final Collection<String> pks = OjbUtil.getPrimaryKeyNames(mappedClass, descriptorRepositories); if (pks.size() == fks.size() && pks.containsAll(fks)) { final String itemClassName = ord.getItemClassName(); if (StringUtils.isBlank(itemClassName)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a reference descriptor for " + fieldName + " but does not class name attribute"); } else { final String shortClassName = ClassUtils.getShortClassName(itemClassName); final String packageName = ClassUtils.getPackageName(itemClassName); pairs.add(new MemberValuePair("targetEntity", new NameExpr(shortClassName + ".class"))); additionalImports.add(new ImportDeclaration( new QualifiedNameExpr(new NameExpr(packageName), shortClassName), false, false)); } final boolean proxy = ord.isLazy(); if (proxy) { pairs.add(new MemberValuePair("fetch", new NameExpr("FetchType.LAZY"))); additionalImports.add(new ImportDeclaration( new QualifiedNameExpr(new NameExpr(PACKAGE), "FetchType"), false, false)); } final boolean refresh = ord.isRefresh(); if (refresh) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has refresh set to " + refresh + ", unsupported conversion to @OneToOne attributes"); } final List<Expression> cascadeTypes = new ArrayList<Expression>(); final boolean autoRetrieve = ord.getCascadeRetrieve(); if (autoRetrieve) { cascadeTypes.add(new NameExpr("CascadeType.REFRESH")); } else { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-retrieve set to " + autoRetrieve + ", unsupported conversion to CascadeType"); } final int autoDelete = ord.getCascadingDelete(); if (autoDelete == ObjectReferenceDescriptor.CASCADE_NONE) { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-delete set to none, unsupported conversion to CascadeType"); } else if (autoDelete == ObjectReferenceDescriptor.CASCADE_LINK) { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-delete set to link, unsupported conversion to CascadeType"); } else if (autoDelete == ObjectReferenceDescriptor.CASCADE_OBJECT) { cascadeTypes.add(new NameExpr("CascadeType.REMOVE")); pairs.add(new MemberValuePair("orphanRemoval", new BooleanLiteralExpr(true))); } else { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-delete set to an invalid value"); } final int autoUpdate = ord.getCascadingStore(); if (autoUpdate == ObjectReferenceDescriptor.CASCADE_NONE) { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-update set to none, unsupported conversion to CascadeType"); } else if (autoUpdate == ObjectReferenceDescriptor.CASCADE_LINK) { LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-update set to link, unsupported conversion to CascadeType"); } else if (autoUpdate == ObjectReferenceDescriptor.CASCADE_OBJECT) { cascadeTypes.add(new NameExpr("CascadeType.PERSIST")); } else { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has auto-update set to an invalid value"); } if (!cascadeTypes.isEmpty()) { pairs.add(new MemberValuePair("cascade", new ArrayInitializerExpr(cascadeTypes))); additionalImports.add(new ImportDeclaration( new QualifiedNameExpr(new NameExpr(PACKAGE), "CascadeType"), false, false)); } final NodeData nodeData; if (isBidirectional(mappedClass, itemClassName)) { LOG.info(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " bi-directional OneToOne relationship detected"); final String mappedBy = getMappedBy(mappedClass, itemClassName); final Comment fixme = new BlockComment("\nFIXME: JPA_CONVERSION \n" + "For one-to-one bidirectional relationships, the owning side corresponds to the side that contains the corresponding foreign key.\n" + "Even in the absence of a foreign key, one side must be the owning side.\n" + "If this is not the owning side, the required annotation should be:\n@OneToOne(mappedBy=\"" + mappedBy + "\")\n"); final NormalAnnotationExpr annotation = new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), pairs); annotation.setComment(fixme); nodeData = new NodeData(annotation, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), additionalImports); } else { nodeData = new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), pairs), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), additionalImports); } return nodeData; } } return null; }
From source file:org.hydracache.data.partitioning.ConsistentHashNodePartitionTest.java
@Test public void ensureServerListRetrieval() { final ConsistentHashNodePartition<ServerNode> circle = new ConsistentHashNodePartition<ServerNode>( hashFunction, Arrays.asList(A, B, C)); final Collection<ServerNode> servers = circle.getNodes(); assertEquals("Number of server is incorrect", 3, servers.size()); assertTrue("Server list should contain all servers", servers.containsAll(Arrays.asList(A, B, C))); }
From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java
@SuppressWarnings("unchecked") private boolean areCollectionsEqual(Collection col1, Collection col2) { return col1.containsAll(col2) && col2.containsAll(col1); }
From source file:pt.ist.expenditureTrackingSystem.domain.acquisitions.ProjectFinancer.java
@Override public boolean hasAllocatedFundsPermanentlyForAnyProjectFinancers() { Collection<PaymentProcessInvoice> allocatedInvoicesInProject = getAllocatedInvoicesInProject(); for (UnitItem unitItem : getUnitItems()) { if (!allocatedInvoicesInProject.isEmpty() && allocatedInvoicesInProject.containsAll(unitItem.getConfirmedInvoices())) { return true; }// w w w.ja v a 2 s .c o m } return getEffectiveProjectFundAllocationId() != null && !getEffectiveProjectFundAllocationId().isEmpty(); }