List of usage examples for javax.persistence.criteria Predicate getExpressions
List<Expression<Boolean>> getExpressions();
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of {@link DataType} with the ids. * * @param modelVersion/*from ww w. j a v a2 s .c o m*/ * the model version. * @param ids * the list of ids to return. * @return the list of {@link DataType}. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<DataType> getDataTypesById(final String modelVersion, final List<String> ids) { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<DataType> q = cb.createQuery(DataType.class); final Root<DataType> f = q.from(DataType.class); final Predicate orIds = cb.disjunction(); ids.stream().forEach(id -> orIds.getExpressions().add(cb.equal(f.<String>get(DataType_.id), id))); q.where(cb.equal(f.<String>get(DataType_.modelVersion), modelVersion), orIds); q.orderBy(cb.asc(f.<String>get(DataType_.name)), cb.asc(f.<String>get(DataType_.id))); final TypedQuery<DataType> typedQuery = this.em.createQuery(q); final List<DataType> value = typedQuery.getResultList(); value.stream().forEach(dt -> EagerLoader.load(dt)); return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of {@link FlowType}s matching the name pattern. * * @param modelVersion// w w w.j av a 2 s. c om * the model version. * @param namePattern * the name pattern. * @return the list of {@link FlowType}s matching the name pattern. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<FlowType> getFlowByNamePattern(final String modelVersion, final Collection<String> namePattern) { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<FlowType> q = cb.createQuery(FlowType.class); final Root<FlowType> f = q.from(FlowType.class); final Predicate or = cb.disjunction(); namePattern.stream() .forEach(id -> or.getExpressions().add(cb.like(f.<String>get(FlowType_.name), "%" + id + "%"))); final Predicate and = cb.conjunction(); and.getExpressions().add(cb.equal(f.<String>get(FlowType_.modelVersion), modelVersion)); and.getExpressions().add(or); q.where(and); final TypedQuery<FlowType> typedQuery = this.em.createQuery(q); final List<FlowType> value = typedQuery.getResultList(); value.stream().forEach(ft -> EagerLoader.load(ft)); return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
private List<String> getInterfaceMappingFieldDefinitionIds(final String modelVersion, final List<String> interfaceMappingIds) { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<String> q = cb.createQuery(String.class); final Root<FieldType> f = q.from(FieldType.class); final Predicate orParentIds = cb.disjunction(); interfaceMappingIds.stream()//from w w w . j a v a 2 s . com .forEach(id -> orParentIds.getExpressions().add(cb.equal(f.<String>get(FieldType_.parentId), id))); q.select(f.<String>get(FieldType_.fieldTypeDefinitionId)); q.where(cb.equal(f.<String>get(FieldType_.modelVersion), modelVersion), orParentIds); final TypedQuery<String> typedQuery = this.em.createQuery(q); final List<String> value = typedQuery.getResultList(); return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
private List<String> getFlowMappingInterfaceMappingTypeIds(final String modelVersion, final List<String> flowProcessTypeIds) { final List<String> value = new ArrayList<String>(); final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<Long> q = cb.createQuery(Long.class); final Root<FlowMapInOutType> f = q.from(FlowMapInOutType.class); final Predicate orParentIds = cb.disjunction(); flowProcessTypeIds.stream().forEach( id -> orParentIds.getExpressions().add(cb.equal(f.<String>get(FlowMapInOutType_.parentId), id))); q.select(f.<Long>get(FlowMapInOutType_.hjid)); q.where(cb.equal(f.<String>get(FlowMapInOutType_.modelVersion), modelVersion), orParentIds); final TypedQuery<Long> typedQuery = this.em.createQuery(q); typedQuery.getResultList().stream().forEach(hjid -> { value.addAll(this.em.getReference(FlowMapInOutType.class, hjid).getInterfaceMappingId()); });//from ww w .ja v a2 s .com return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
private void getInterfaceMappingInheritents(final String modelVersion, final List<String> interfaceMappingIds, final List<InterfaceMappingType> interfaceMappings) { if (interfaceMappingIds.size() > 0) { List<InterfaceMappingType> value = new ArrayList<InterfaceMappingType>(); final List<String> fieldDefinitionIds = this.getInterfaceMappingFieldDefinitionIds(modelVersion, interfaceMappingIds);//from w w w . java 2 s. com final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<InterfaceMappingType> q = cb.createQuery(InterfaceMappingType.class); final Root<InterfaceMappingType> f = q.from(InterfaceMappingType.class); final Predicate orIds = cb.disjunction(); fieldDefinitionIds.stream().forEach( id -> orIds.getExpressions().add(cb.equal(f.<String>get(InterfaceMappingType_.id), id))); q.where(cb.equal(f.<String>get(InterfaceMappingType_.modelVersion), modelVersion), orIds); final TypedQuery<InterfaceMappingType> typedQuery = this.em.createQuery(q); value = typedQuery.getResultList(); interfaceMappings.addAll(value); final List<String> foundIds = value.stream().map(i -> i.getId()).collect(Collectors.toList()); this.getInterfaceMappingInheritents(modelVersion, foundIds, interfaceMappings); } }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of {@link InterfaceMappingType}s of the flow with id. * * @param modelVersion//from w w w . j a v a 2 s . c o m * the model version. * @param flowId * the flow id. * @return the list of {@link InterfaceMappingType}s of the flow with id. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<InterfaceMappingType> getFlowInterfaceMappingTypes(final String modelVersion, final String flowId) { final List<InterfaceMappingType> value = new ArrayList<InterfaceMappingType>(); final List<String> flowProcessTypeIds = this.getFlowProcessTypeIds(modelVersion, flowId); final List<String> flowMappingInterfaceMappingTypeIds = this .getFlowMappingInterfaceMappingTypeIds(modelVersion, flowProcessTypeIds); final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<InterfaceMappingType> q = cb.createQuery(InterfaceMappingType.class); final Root<InterfaceMappingType> f = q.from(InterfaceMappingType.class); final Predicate orIds = cb.disjunction(); flowMappingInterfaceMappingTypeIds.stream() .forEach(id -> orIds.getExpressions().add(cb.equal(f.<String>get(InterfaceMappingType_.id), id))); q.where(cb.equal(f.<String>get(InterfaceMappingType_.modelVersion), modelVersion), orIds); final TypedQuery<InterfaceMappingType> typedQuery = this.em.createQuery(q); value.addAll(typedQuery.getResultList()); final List<String> interfaceMappingIds = value.stream().map(i -> i.getId()).collect(Collectors.toList()); this.getInterfaceMappingInheritents(modelVersion, interfaceMappingIds, value); value.stream().forEach(im -> EagerLoader.load(im)); return value; }
From source file:org.egov.infra.security.audit.repository.specs.LoginAuditSpec.java
public static final Specification<LoginAudit> loginAuditSearchSpec( LoginAuditReportRequest loginAuditReportRequest) { return (root, query, builder) -> { final Predicate predicate = builder.conjunction(); if (isNotBlank(loginAuditReportRequest.getUserName())) predicate.getExpressions() .add(builder.equal(root.get("user").get("name"), loginAuditReportRequest.getUserName())); if (loginAuditReportRequest.getUserType() != null) predicate.getExpressions()/*from w w w . j a va 2s . c o m*/ .add(builder.equal(root.get("user").get("type"), loginAuditReportRequest.getUserType())); if (isNotBlank(loginAuditReportRequest.getIpAddress())) predicate.getExpressions() .add(builder.equal(root.get("ipAddress"), loginAuditReportRequest.getIpAddress())); if (loginAuditReportRequest.getLoginFrom() != null) predicate.getExpressions().add(builder.greaterThanOrEqualTo(root.get("loginTime"), loginAuditReportRequest.getLoginFrom())); if (loginAuditReportRequest.getLoginTo() != null) predicate.getExpressions().add(builder.lessThanOrEqualTo(root.get("loginTime"), DateUtils.endOfDay(loginAuditReportRequest.getLoginTo()))); return predicate; }; }
From source file:org.egov.pgr.integration.ivrs.repository.specs.IVRSFeedbackReviewSearchSpec.java
public static Specification<IVRSFeedback> search(IVRSFeedbackSearchRequest ivrsFeedbackSearchRequest) { return (root, query, builder) -> { final Predicate predicate = builder.conjunction(); if (ivrsFeedbackSearchRequest.getComplaintId() != null) predicate.getExpressions().add(builder.equal(root.get(COMPALINT).get("complaintType").get("id"), ivrsFeedbackSearchRequest.getComplaintId())); if (isNotBlank(ivrsFeedbackSearchRequest.getCrn())) predicate.getExpressions()/*w w w . j a va 2 s .c o m*/ .add(builder.equal(root.get(COMPALINT).get("crn"), ivrsFeedbackSearchRequest.getCrn())); if (ivrsFeedbackSearchRequest.getToDate() != null) predicate.getExpressions().add(builder.lessThanOrEqualTo(root.get(COMPALINT).get(CREATEDDATE), endOfDay(ivrsFeedbackSearchRequest.getToDate()))); if (ivrsFeedbackSearchRequest.getFromDate() != null) predicate.getExpressions().add(builder.greaterThanOrEqualTo(root.get(COMPALINT).get(CREATEDDATE), startOfDay(ivrsFeedbackSearchRequest.getFromDate()))); if (ivrsFeedbackSearchRequest.getLocationId() != null) predicate.getExpressions().add(builder.equal(root.get(COMPALINT).get("location").get("id"), ivrsFeedbackSearchRequest.getLocationId())); if (ivrsFeedbackSearchRequest.getChildLocationId() != null) predicate.getExpressions().add(builder.equal(root.get(COMPALINT).get("childLocation").get("id"), ivrsFeedbackSearchRequest.getChildLocationId())); if (ivrsFeedbackSearchRequest.getComplaintTypeCategoryId() != null) predicate.getExpressions() .add(builder.equal(root.get(COMPALINT).get("complaintType").get("category"), ivrsFeedbackSearchRequest.getComplaintTypeCategoryId())); predicate.getExpressions().add(builder.isTrue(root.get("ivrsRating").get("requiredReview"))); predicate.getExpressions() .add(builder.equal(root.get(COMPALINT).get("status").get("name"), COMPLAINT_COMPLETED)); return predicate; }; }
From source file:org.egov.tl.repository.specs.DCBReportSpec.java
public static Specification<DCBReportResult> dCBReportSpecification( final DCBReportSearchRequest dCBReportSearchRequest) { return (root, query, builder) -> { final Predicate result = builder.conjunction(); if (isNotBlank(dCBReportSearchRequest.getLicenseNumber())) result.getExpressions() .add(builder.equal(root.get("licenseNumber"), dCBReportSearchRequest.getLicenseNumber())); if (dCBReportSearchRequest.getLicenseId() != null) result.getExpressions()/*ww w .ja v a 2 s.com*/ .add(builder.equal(root.get("licenseId"), dCBReportSearchRequest.getLicenseId())); if (dCBReportSearchRequest.getActiveLicense() > 0) result.getExpressions() .add(builder.equal(root.get("active"), dCBReportSearchRequest.getActiveLicense() == 1)); if (dCBReportSearchRequest.getWardId() != null && !dCBReportSearchRequest.getWardId().isEmpty()) result.getExpressions().add(root.get("wardId").in(dCBReportSearchRequest.getWardId())); if (dCBReportSearchRequest.getAdminWardId() != null && !dCBReportSearchRequest.getAdminWardId().isEmpty()) result.getExpressions().add(root.get("adminWard").in(dCBReportSearchRequest.getAdminWardId())); return result; }; }