List of usage examples for javax.persistence.criteria CriteriaBuilder createQuery
<T> CriteriaQuery<T> createQuery(Class<T> resultClass);
CriteriaQuery
object with the specified result type. From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of serviceIds available. * * @param modelVersion// ww w .java 2 s . c o m * the model version. * @return the list of serviceIds available. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<String> getRevisions() { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<String> q = cb.createQuery(String.class); final Root<EnterpriseType> f = q.from(EnterpriseType.class); q.select(f.<String>get(EnterpriseType_.modelVersion)); q.orderBy(cb.asc(f.<String>get(EnterpriseType_.modelVersion))); 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> getFlowProcessTypeIds(final String modelVersion, final String flowId) { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<String> q = cb.createQuery(String.class); final Root<FlowProcessType> f = q.from(FlowProcessType.class); q.select(f.<String>get(FlowProcessType_.id)); q.where(cb.equal(f.<String>get(FlowProcessType_.modelVersion), modelVersion), cb.equal(f.<String>get(FlowProcessType_.parentId), flowId)); q.orderBy(cb.asc(f.<Long>get(FlowProcessType_.hjid))); 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> 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. ja v a 2 s. c om .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
/** * Get the last model version (lexical compare). * * @return the last model version.//from ww w . ja v a2 s .co m * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public String getLastModelVersion() { String value = null; final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<String> q = cb.createQuery(String.class); final Root<EnterpriseType> f = q.from(EnterpriseType.class); q.select(f.<String>get(EnterpriseType_.modelVersion)); q.orderBy(cb.desc(f.<String>get(EnterpriseType_.modelVersion))); final TypedQuery<String> typedQuery = this.em.createQuery(q); final List<String> list = typedQuery.getResultList(); if (Objects.nonNull(list) && list.size() > 0) { value = list.get(0); } return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of {@link DataType} with the ids. * * @param modelVersion//w w w . j a v a 2 s . c om * 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 all {@link EnterpriseType}s. * * @return the list of all {@link EnterpriseType}s. *//* w w w . j a v a 2 s. c o m*/ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<EnterpriseType> getEnterprises() { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<EnterpriseType> q = cb.createQuery(EnterpriseType.class); q.from(EnterpriseType.class); final TypedQuery<EnterpriseType> typedQuery = this.em.createQuery(q); final List<EnterpriseType> value = typedQuery.getResultList(); return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of {@link ComplexType} with the ids. * * @param modelVersion/* w w w .j a va 2 s.c o m*/ * the model version. * @param ids * the list of ids to return. * @return the list of {@link ComplexType}. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<ComplexType> getComplexTypesById(final String modelVersion, final List<String> ids) { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<ComplexType> q = cb.createQuery(ComplexType.class); final Root<ComplexType> f = q.from(ComplexType.class); final Predicate orIds = cb.disjunction(); ids.stream().forEach(id -> orIds.getExpressions().add(cb.equal(f.<String>get(ComplexType_.id), id))); q.where(cb.equal(f.<String>get(ComplexType_.modelVersion), modelVersion), orIds); final TypedQuery<ComplexType> typedQuery = this.em.createQuery(q); final List<ComplexType> value = typedQuery.getResultList(); value.stream().forEach(ct -> EagerLoader.load(ct)); return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of {@link ElementType} with the ids. * * @param modelVersion/*from w ww. jav a 2 s .co m*/ * the model version. * @param ids * the list of ids to return. * @return the list of {@link ElementType}. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<ElementType> getElementTypesById(final String modelVersion, final List<String> ids) { final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<ElementType> q = cb.createQuery(ElementType.class); final Root<ElementType> f = q.from(ElementType.class); final Predicate orIds = cb.disjunction(); ids.stream().forEach(id -> orIds.getExpressions().add(cb.equal(f.<String>get(ElementType_.id), id))); q.where(cb.equal(f.<String>get(ElementType_.modelVersion), modelVersion), orIds); final TypedQuery<ElementType> typedQuery = this.em.createQuery(q); final List<ElementType> value = typedQuery.getResultList(); value.stream().forEach(ct -> EagerLoader.load(ct)); 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 w w w . ja v a 2s .co m*/ return value; }
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * Get the list of serviceIds available. * * @param modelVersion//from w w w.j ava2 s . c om * the model version. * @return the list of serviceIds available. * @since 3.5.1 */ @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public List<String> getServiceIds(final String modelVersion) { final List<String> value = new ArrayList<String>(); final CriteriaBuilder cb = this.em.getCriteriaBuilder(); final CriteriaQuery<ServiceType> q = cb.createQuery(ServiceType.class); final Root<ServiceType> f = q.from(ServiceType.class); q.where(cb.equal(f.<String>get(ServiceType_.modelVersion), modelVersion)); q.orderBy(cb.asc(f.<String>get(ServiceType_.serviceId)), cb.asc(f.<String>get(ServiceType_.namespace))); final TypedQuery<ServiceType> typedQuery = this.em.createQuery(q); final List<ServiceType> services = typedQuery.getResultList(); services.stream().filter(s -> Objects.nonNull(s.getServiceId())).forEach(s -> value.add(s.getServiceId())); return value; }