use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class AttributeValueListDaoImpl method getAttributeValueLists.
@Override
public List<AttributeValueListKey> getAttributeValueLists(Collection<String> namespaces) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<AttributeValueListEntity> criteria = builder.createQuery(AttributeValueListEntity.class);
// The criteria root is the attribute value list entity.
Root<AttributeValueListEntity> attributeValueListEntityRoot = criteria.from(AttributeValueListEntity.class);
// Join to the other tables we can filter on.
Join<AttributeValueListEntity, NamespaceEntity> namespaceEntityJoin = attributeValueListEntityRoot.join(AttributeValueListEntity_.namespace);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
if (CollectionUtils.isNotEmpty(namespaces)) {
predicates.add(namespaceEntityJoin.get(NamespaceEntity_.code).in(namespaces));
}
// Order the results by namespace and job name.
List<Order> orderBy = new ArrayList<>();
orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code)));
orderBy.add(builder.asc(attributeValueListEntityRoot.get(AttributeValueListEntity_.name)));
// Add all clauses to the query.
criteria.select(attributeValueListEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy);
// Execute the query and build a list of keys.
List<AttributeValueListKey> attributeValueListKeys = new ArrayList<>();
for (AttributeValueListEntity attributeValueListEntity : entityManager.createQuery(criteria).getResultList()) {
attributeValueListKeys.add(new AttributeValueListKey(attributeValueListEntity.getNamespace().getCode(), attributeValueListEntity.getName()));
}
return attributeValueListKeys;
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class BusinessObjectDataAttributeDaoImpl method getBusinessObjectDataAttributeByKey.
@Override
public BusinessObjectDataAttributeEntity getBusinessObjectDataAttributeByKey(BusinessObjectDataAttributeKey businessObjectDataAttributeKey) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDataAttributeEntity> criteria = builder.createQuery(BusinessObjectDataAttributeEntity.class);
// The criteria root is the business object data attribute.
Root<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntityRoot = criteria.from(BusinessObjectDataAttributeEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDataAttributeEntity, BusinessObjectDataEntity> businessObjectDataEntityJoin = businessObjectDataAttributeEntityRoot.join(BusinessObjectDataAttributeEntity_.businessObjectData);
Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntityJoin = businessObjectDataEntityJoin.join(BusinessObjectDataEntity_.businessObjectFormat);
Join<BusinessObjectFormatEntity, FileTypeEntity> fileTypeEntityJoin = businessObjectFormatEntityJoin.join(BusinessObjectFormatEntity_.fileType);
Join<BusinessObjectFormatEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectFormatEntityJoin.join(BusinessObjectFormatEntity_.businessObjectDefinition);
Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntityJoin = businessObjectDefinitionEntityJoin.join(BusinessObjectDefinitionEntity_.namespace);
// 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)), businessObjectDataAttributeKey.getNamespace().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataAttributeKey.getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataAttributeKey.getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.usage)), businessObjectDataAttributeKey.getBusinessObjectFormatUsage().toUpperCase()));
predicates.add(builder.equal(builder.upper(fileTypeEntityJoin.get(FileTypeEntity_.code)), businessObjectDataAttributeKey.getBusinessObjectFormatFileType().toUpperCase()));
predicates.add(builder.equal(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.businessObjectFormatVersion), businessObjectDataAttributeKey.getBusinessObjectFormatVersion()));
predicates.add(getQueryRestrictionOnPartitionValues(builder, businessObjectDataEntityJoin, businessObjectDataAttributeKey.getPartitionValue(), businessObjectDataAttributeKey.getSubPartitionValues()));
predicates.add(builder.equal(businessObjectDataEntityJoin.get(BusinessObjectDataEntity_.version), businessObjectDataAttributeKey.getBusinessObjectDataVersion()));
predicates.add(builder.equal(builder.upper(businessObjectDataAttributeEntityRoot.get(BusinessObjectDataAttributeEntity_.name)), businessObjectDataAttributeKey.getBusinessObjectDataAttributeName().toUpperCase()));
// Add the clauses for the query.
criteria.select(businessObjectDataAttributeEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
return executeSingleResultQuery(criteria, String.format("Found more than one business object data attribute instance with parameters {namespace=\"%s\", businessObjectDefinitionName=\"%s\"," + " businessObjectFormatUsage=\"%s\", businessObjectFormatFileType=\"%s\", businessObjectFormatVersion=\"%d\"," + " businessObjectDataPartitionValue=\"%s\", businessObjectDataSubPartitionValues=\"%s\", businessObjectDataVersion=\"%d\"," + " businessObjectDataAttributeName=\"%s\"}.", businessObjectDataAttributeKey.getNamespace(), businessObjectDataAttributeKey.getBusinessObjectDefinitionName(), businessObjectDataAttributeKey.getBusinessObjectFormatUsage(), businessObjectDataAttributeKey.getBusinessObjectFormatFileType(), businessObjectDataAttributeKey.getBusinessObjectFormatVersion(), businessObjectDataAttributeKey.getPartitionValue(), CollectionUtils.isEmpty(businessObjectDataAttributeKey.getSubPartitionValues()) ? "" : StringUtils.join(businessObjectDataAttributeKey.getSubPartitionValues(), ","), businessObjectDataAttributeKey.getBusinessObjectDataVersion(), businessObjectDataAttributeKey.getBusinessObjectDataAttributeName()));
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationDaoImpl method getBusinessObjectDataNotificationRegistrationByAltKey.
@Override
public BusinessObjectDataNotificationRegistrationEntity getBusinessObjectDataNotificationRegistrationByAltKey(NotificationRegistrationKey key) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDataNotificationRegistrationEntity> criteria = builder.createQuery(BusinessObjectDataNotificationRegistrationEntity.class);
// The criteria root is the business object data notification registration entity.
Root<BusinessObjectDataNotificationRegistrationEntity> businessObjectDataNotificationEntity = criteria.from(BusinessObjectDataNotificationRegistrationEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> namespaceEntity = businessObjectDataNotificationEntity.join(BusinessObjectDataNotificationRegistrationEntity_.namespace);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate queryRestriction = builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), key.getNamespace().toUpperCase());
queryRestriction = builder.and(queryRestriction, builder.equal(builder.upper(businessObjectDataNotificationEntity.get(BusinessObjectDataNotificationRegistrationEntity_.name)), key.getNotificationName().toUpperCase()));
criteria.select(businessObjectDataNotificationEntity).where(queryRestriction);
return executeSingleResultQuery(criteria, String.format("Found more than one business object data notification registration with with parameters {namespace=\"%s\", notificationName=\"%s\"}.", key.getNamespace(), key.getNotificationName()));
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationDaoImpl method getBusinessObjectDataNotificationRegistrations.
@Override
public List<BusinessObjectDataNotificationRegistrationEntity> getBusinessObjectDataNotificationRegistrations(String notificationEventTypeCode, BusinessObjectDataKey businessObjectDataKey, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus, String notificationRegistrationStatus) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDataNotificationRegistrationEntity> criteria = builder.createQuery(BusinessObjectDataNotificationRegistrationEntity.class);
// The criteria root is the business object data notification registration entity.
Root<BusinessObjectDataNotificationRegistrationEntity> businessObjectDataNotificationEntityRoot = criteria.from(BusinessObjectDataNotificationRegistrationEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> namespaceEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.namespace);
Join<BusinessObjectDataNotificationRegistrationEntity, NotificationEventTypeEntity> notificationEventTypeEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.notificationEventType);
Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.businessObjectDefinition);
Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntityJoin = businessObjectDefinitionEntityJoin.join(BusinessObjectDefinitionEntity_.namespace);
Join<BusinessObjectDataNotificationRegistrationEntity, FileTypeEntity> fileTypeEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.fileType, JoinType.LEFT);
Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDataStatusEntity> newBusinessObjectDataStatusEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.newBusinessObjectDataStatus, JoinType.LEFT);
Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDataStatusEntity> oldBusinessObjectDataStatusEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.oldBusinessObjectDataStatus, JoinType.LEFT);
Join<BusinessObjectDataNotificationRegistrationEntity, NotificationRegistrationStatusEntity> notificationRegistrationStatusEntityJoin = businessObjectDataNotificationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.notificationRegistrationStatus);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(builder.upper(notificationEventTypeEntityJoin.get(NotificationEventTypeEntity_.code)), notificationEventTypeCode.toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionNamespaceEntityJoin.get(NamespaceEntity_.code)), businessObjectDataKey.getNamespace().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataKey.getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.usage)), builder.equal(builder.upper(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.usage)), businessObjectDataKey.getBusinessObjectFormatUsage().toUpperCase())));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.fileType)), builder.equal(builder.upper(fileTypeEntityJoin.get(FileTypeEntity_.code)), businessObjectDataKey.getBusinessObjectFormatFileType().toUpperCase())));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion)), builder.equal(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion), businessObjectDataKey.getBusinessObjectFormatVersion())));
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.newBusinessObjectDataStatus)), builder.equal(builder.upper(newBusinessObjectDataStatusEntityJoin.get(BusinessObjectDataStatusEntity_.code)), newBusinessObjectDataStatus.toUpperCase())));
// Please note that old business object data status parameter value is null for a business object data registration event.
predicates.add(builder.or(builder.isNull(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.oldBusinessObjectDataStatus)), builder.equal(builder.upper(oldBusinessObjectDataStatusEntityJoin.get(BusinessObjectDataStatusEntity_.code)), oldBusinessObjectDataStatus == null ? null : oldBusinessObjectDataStatus.toUpperCase())));
predicates.add(builder.equal(builder.upper(notificationRegistrationStatusEntityJoin.get(NotificationRegistrationStatusEntity_.code)), notificationRegistrationStatus.toUpperCase()));
// Order the results by namespace and notification name.
List<Order> orderBy = new ArrayList<>();
orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code)));
orderBy.add(builder.asc(businessObjectDataNotificationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.name)));
// Add the clauses for the query.
criteria.select(businessObjectDataNotificationEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy);
// Execute the query and return the results.
return entityManager.createQuery(criteria).getResultList();
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class AbstractHerdDao method getQueryRestriction.
/**
* TODO This method may be bformat specific. Consider creating new abstract class to group all bformat related DAO. Builds a query restriction predicate for
* the specified business object format entity as per business object format key values.
*
* @param builder the criteria builder
* @param businessObjectFormatEntity the business object format entity that appears in the from clause
* @param fileTypeEntity the file type entity that appears in the from clause
* @param businessObjectDefinitionEntity the business object definition entity that appears in the from clause
* @param businessObjectFormatKey the business object format key
* @param ignoreBusinessObjectFormatVersion specifies whether to ignore the business object format version when building the predicate
*
* @return the query restriction predicate
*/
protected Predicate getQueryRestriction(CriteriaBuilder builder, From<?, BusinessObjectFormatEntity> businessObjectFormatEntity, From<?, FileTypeEntity> fileTypeEntity, From<?, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity, BusinessObjectFormatKey businessObjectFormatKey, boolean ignoreBusinessObjectFormatVersion) {
// Join to the other tables we can filter on.
Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntity = businessObjectDefinitionEntity.join(BusinessObjectDefinitionEntity_.namespace);
// Create the standard restrictions based on the business object format key values (i.e. the standard where clauses).
// Create a restriction on namespace code.
Predicate predicate = builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), businessObjectFormatKey.getNamespace().toUpperCase());
// Create and append a restriction on business object definition name.
predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name)), businessObjectFormatKey.getBusinessObjectDefinitionName().toUpperCase()));
// Create and append a restriction on business object format usage.
predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.usage)), businessObjectFormatKey.getBusinessObjectFormatUsage().toUpperCase()));
// Create and append a restriction on business object format file type.
predicate = builder.and(predicate, builder.equal(builder.upper(fileTypeEntity.get(FileTypeEntity_.code)), businessObjectFormatKey.getBusinessObjectFormatFileType().toUpperCase()));
// If specified, create and append a restriction on business object format version.
if (!ignoreBusinessObjectFormatVersion && businessObjectFormatKey.getBusinessObjectFormatVersion() != null) {
predicate = builder.and(predicate, builder.equal(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion), businessObjectFormatKey.getBusinessObjectFormatVersion()));
}
return predicate;
}
Aggregations