use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDataDaoImpl method getBusinessObjectDataEntities.
@Override
public List<BusinessObjectDataEntity> getBusinessObjectDataEntities(BusinessObjectDataKey businessObjectDataKey) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDataEntity> criteria = builder.createQuery(BusinessObjectDataEntity.class);
// The criteria root is the business object data.
Root<BusinessObjectDataEntity> businessObjectDataEntity = criteria.from(BusinessObjectDataEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntity = businessObjectDataEntity.join(BusinessObjectDataEntity_.businessObjectFormat);
Join<BusinessObjectFormatEntity, FileTypeEntity> fileTypeEntity = businessObjectFormatEntity.join(BusinessObjectFormatEntity_.fileType);
Join<BusinessObjectFormatEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = businessObjectFormatEntity.join(BusinessObjectFormatEntity_.businessObjectDefinition);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate queryRestriction = getQueryRestriction(builder, businessObjectDataEntity, businessObjectFormatEntity, fileTypeEntity, businessObjectDefinitionEntity, businessObjectDataKey);
// Add the clauses for the query.
criteria.select(businessObjectDataEntity).where(queryRestriction);
// Order by business object format and data versions.
criteria.orderBy(builder.asc(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion)), builder.asc(businessObjectDataEntity.get(BusinessObjectDataEntity_.version)));
return entityManager.createQuery(criteria).getResultList();
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionTagDaoImpl method getBusinessObjectDefinitionTagsByBusinessObjectDefinitionEntity.
@Override
public List<BusinessObjectDefinitionTagKey> getBusinessObjectDefinitionTagsByBusinessObjectDefinitionEntity(BusinessObjectDefinitionEntity businessObjectDefinitionEntity) {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
// The criteria root is the business object definition.
Root<TagEntity> tagEntityRoot = criteria.from(TagEntity.class);
// Join to the other tables we can filter on.
Join<TagEntity, TagTypeEntity> tagTypeEntityJoin = tagEntityRoot.join(TagEntity_.tagType);
Join<TagEntity, BusinessObjectDefinitionTagEntity> businessObjectDefinitionTagEntityJoin = tagEntityRoot.join(TagEntity_.businessObjectDefinitionTags);
Join<BusinessObjectDefinitionTagEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectDefinitionTagEntityJoin.join(BusinessObjectDefinitionTagEntity_.businessObjectDefinition);
// Get the columns.
Path<String> tagTypeCodeColumn = tagTypeEntityJoin.get(TagTypeEntity_.code);
Path<String> tagCodeColumn = tagEntityRoot.get(TagEntity_.tagCode);
Path<String> tagDisplayNameColumn = tagEntityRoot.get(TagEntity_.displayName);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(businessObjectDefinitionEntityJoin, businessObjectDefinitionEntity));
// Add the clauses for the query.
criteria.multiselect(tagTypeCodeColumn, tagCodeColumn).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(builder.asc(tagDisplayNameColumn));
// Run the query to get a list of tuples back.
List<Tuple> tuples = entityManager.createQuery(criteria).getResultList();
// Get the business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(businessObjectDefinitionEntity.getNamespace().getCode(), businessObjectDefinitionEntity.getName());
// Populate the "keys" objects from the returned tuples (i.e. 1 tuple for each row).
List<BusinessObjectDefinitionTagKey> businessObjectDefinitionTagKeys = new ArrayList<>();
for (Tuple tuple : tuples) {
businessObjectDefinitionTagKeys.add(new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, new TagKey(tuple.get(tagTypeCodeColumn), tuple.get(tagCodeColumn))));
}
return businessObjectDefinitionTagKeys;
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionTagDaoImpl method getBusinessObjectDefinitionTagByKey.
@Override
public BusinessObjectDefinitionTagEntity getBusinessObjectDefinitionTagByKey(BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDefinitionTagEntity> criteria = builder.createQuery(BusinessObjectDefinitionTagEntity.class);
// The criteria root is the business object definition tag.
Root<BusinessObjectDefinitionTagEntity> businessObjectDefinitionTagEntityRoot = criteria.from(BusinessObjectDefinitionTagEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDefinitionTagEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectDefinitionTagEntityRoot.join(BusinessObjectDefinitionTagEntity_.businessObjectDefinition);
Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntityJoin = businessObjectDefinitionEntityJoin.join(BusinessObjectDefinitionEntity_.namespace);
Join<BusinessObjectDefinitionTagEntity, TagEntity> tagEntityJoin = businessObjectDefinitionTagEntityRoot.join(BusinessObjectDefinitionTagEntity_.tag);
Join<TagEntity, TagTypeEntity> tagTypeEntityJoin = tagEntityJoin.join(TagEntity_.tagType);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(builder.upper(namespaceEntityJoin.get(NamespaceEntity_.code)), businessObjectDefinitionTagKey.getBusinessObjectDefinitionKey().getNamespace().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDefinitionTagKey.getBusinessObjectDefinitionKey().getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.equal(builder.upper(tagTypeEntityJoin.get(TagTypeEntity_.code)), businessObjectDefinitionTagKey.getTagKey().getTagTypeCode().toUpperCase()));
predicates.add(builder.equal(builder.upper(tagEntityJoin.get(TagEntity_.tagCode)), businessObjectDefinitionTagKey.getTagKey().getTagCode().toUpperCase()));
// Add the clauses for the query.
criteria.select(businessObjectDefinitionTagEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
return executeSingleResultQuery(criteria, String.format("Found more than one business object definition tag instance with parameters {namespace=\"%s\", businessObjectDefinitionName=\"%s\"," + " tagType=\"%s\", tagCode=\"%s\"}.", businessObjectDefinitionTagKey.getBusinessObjectDefinitionKey().getNamespace(), businessObjectDefinitionTagKey.getBusinessObjectDefinitionKey().getBusinessObjectDefinitionName(), businessObjectDefinitionTagKey.getTagKey().getTagTypeCode(), businessObjectDefinitionTagKey.getTagKey().getTagCode()));
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionDaoImpl method getBusinessObjectDefinitionKeysByNamespace.
@Override
public List<BusinessObjectDefinitionKey> getBusinessObjectDefinitionKeysByNamespace(String namespaceCode) {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
// The criteria root is the business object definition.
Root<BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = criteria.from(BusinessObjectDefinitionEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntity = businessObjectDefinitionEntity.join(BusinessObjectDefinitionEntity_.namespace);
// Get the columns.
Path<String> namespaceCodeColumn = namespaceEntity.get(NamespaceEntity_.code);
Path<String> businessObjectDefinitionNameColumn = businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name);
// Add the select clause.
criteria.multiselect(namespaceCodeColumn, businessObjectDefinitionNameColumn);
// If namespace code is specified, add the where clause.
if (StringUtils.isNotBlank(namespaceCode)) {
criteria.where(builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), namespaceCode.toUpperCase()));
}
// Add the order by clause.
if (StringUtils.isNotBlank(namespaceCode)) {
criteria.orderBy(builder.asc(businessObjectDefinitionNameColumn));
} else {
criteria.orderBy(builder.asc(businessObjectDefinitionNameColumn), builder.asc(namespaceCodeColumn));
}
// Run the query to get a list of tuples back.
List<Tuple> tuples = entityManager.createQuery(criteria).getResultList();
// Populate the "keys" objects from the returned tuples (i.e. 1 tuple for each row).
List<BusinessObjectDefinitionKey> businessObjectDefinitionKeys = new ArrayList<>();
for (Tuple tuple : tuples) {
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey();
businessObjectDefinitionKeys.add(businessObjectDefinitionKey);
businessObjectDefinitionKey.setNamespace(tuple.get(namespaceCodeColumn));
businessObjectDefinitionKey.setBusinessObjectDefinitionName(tuple.get(businessObjectDefinitionNameColumn));
}
return businessObjectDefinitionKeys;
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionDaoImpl method getMostRecentBusinessObjectDefinitions.
@Override
public List<BusinessObjectDefinitionEntity> getMostRecentBusinessObjectDefinitions(int numberOfResults) {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDefinitionEntity> criteria = builder.createQuery(BusinessObjectDefinitionEntity.class);
// The criteria root is the business object definition.
Root<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityRoot = criteria.from(BusinessObjectDefinitionEntity.class);
// Get the columns.
Path<Timestamp> businessObjectDefinitionUpdatedOnColumn = businessObjectDefinitionEntityRoot.get(BusinessObjectDefinitionEntity_.updatedOn);
// Select the business object definitions and order descending by the updated on column
criteria.select(businessObjectDefinitionEntityRoot).orderBy(builder.desc(businessObjectDefinitionUpdatedOnColumn));
return entityManager.createQuery(criteria).setMaxResults(numberOfResults).getResultList();
}
Aggregations