Search in sources :

Example 11 with FileTypeEntity

use of org.finra.herd.model.jpa.FileTypeEntity in project herd by FINRAOS.

the class FileTypeDaoTest method testGetFileTypeByCodeInUpperCase.

@Test
public void testGetFileTypeByCodeInUpperCase() {
    // Create relative database entities.
    fileTypeDaoTestHelper.createFileTypeEntity(FORMAT_FILE_TYPE_CODE.toLowerCase(), "Description of " + FORMAT_FILE_TYPE_CODE.toLowerCase());
    // Retrieve file type entity.
    FileTypeEntity fileTypeEntity = fileTypeDao.getFileTypeByCode(FORMAT_FILE_TYPE_CODE.toUpperCase());
    // Validate the results.
    assertNotNull(fileTypeEntity);
    assertTrue(fileTypeEntity.getCode().equals(FORMAT_FILE_TYPE_CODE.toLowerCase()));
    assertTrue(fileTypeEntity.getDescription().equals("Description of " + FORMAT_FILE_TYPE_CODE.toLowerCase()));
}
Also used : FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) Test(org.junit.Test)

Example 12 with FileTypeEntity

use of org.finra.herd.model.jpa.FileTypeEntity in project herd by FINRAOS.

the class FileTypeDaoTestHelper method createFileTypeEntity.

/**
 * Creates and persists a new file type entity.
 *
 * @param fileTypeCode the file type code value
 * @param fileTypeDescription the description of this file type
 *
 * @return the newly created file type entity.
 */
public FileTypeEntity createFileTypeEntity(String fileTypeCode, String fileTypeDescription) {
    FileTypeEntity fileTypeEntity = new FileTypeEntity();
    fileTypeEntity.setCode(fileTypeCode);
    fileTypeEntity.setDescription(fileTypeDescription);
    return fileTypeDao.saveAndRefresh(fileTypeEntity);
}
Also used : FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity)

Example 13 with FileTypeEntity

use of org.finra.herd.model.jpa.FileTypeEntity 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()));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) ArrayList(java.util.ArrayList) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Predicate(javax.persistence.criteria.Predicate) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity)

Example 14 with FileTypeEntity

use of org.finra.herd.model.jpa.FileTypeEntity 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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Order(javax.persistence.criteria.Order) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) ArrayList(java.util.ArrayList) Predicate(javax.persistence.criteria.Predicate) NotificationEventTypeEntity(org.finra.herd.model.jpa.NotificationEventTypeEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) NotificationRegistrationStatusEntity(org.finra.herd.model.jpa.NotificationRegistrationStatusEntity) BusinessObjectDataNotificationRegistrationEntity(org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity)

Example 15 with FileTypeEntity

use of org.finra.herd.model.jpa.FileTypeEntity in project herd by FINRAOS.

the class BusinessObjectFormatDaoImpl method getBusinessObjectFormatByAltKey.

@Override
public BusinessObjectFormatEntity getBusinessObjectFormatByAltKey(BusinessObjectFormatKey businessObjectFormatKey) {
    // Create the criteria builder and the criteria.
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<BusinessObjectFormatEntity> criteria = builder.createQuery(BusinessObjectFormatEntity.class);
    // The criteria root is the business object format.
    Root<BusinessObjectFormatEntity> businessObjectFormatEntity = criteria.from(BusinessObjectFormatEntity.class);
    // Join to the other tables we can filter on.
    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).
    // Please note that we specify not to ignore the business object format version.
    Predicate queryRestriction = getQueryRestriction(builder, businessObjectFormatEntity, fileTypeEntity, businessObjectDefinitionEntity, businessObjectFormatKey, false);
    // If a business format version was not specified, use the latest one.
    if (businessObjectFormatKey.getBusinessObjectFormatVersion() == null) {
        queryRestriction = builder.and(queryRestriction, builder.isTrue(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.latestVersion)));
    }
    criteria.select(businessObjectFormatEntity).where(queryRestriction);
    return executeSingleResultQuery(criteria, String.format("Found more than one business object format instance with parameters " + "{namespace=\"%s\", businessObjectDefinitionName=\"%s\", businessObjectFormatUsage=\"%s\", businessObjectFormatFileType=\"%s\", " + "businessObjectFormatVersion=\"%d\"}.", businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), businessObjectFormatKey.getBusinessObjectFormatVersion()));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Predicate(javax.persistence.criteria.Predicate)

Aggregations

FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)45 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)38 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)25 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)24 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)23 Predicate (javax.persistence.criteria.Predicate)23 ArrayList (java.util.ArrayList)20 StorageEntity (org.finra.herd.model.jpa.StorageEntity)17 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)14 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)13 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)10 Order (javax.persistence.criteria.Order)8 NotificationEventTypeEntity (org.finra.herd.model.jpa.NotificationEventTypeEntity)8 NotificationRegistrationStatusEntity (org.finra.herd.model.jpa.NotificationRegistrationStatusEntity)8 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)8 StorageUnitStatusEntity (org.finra.herd.model.jpa.StorageUnitStatusEntity)8 Tuple (javax.persistence.Tuple)6 NamespacePermissions (org.finra.herd.model.annotation.NamespacePermissions)6 JobAction (org.finra.herd.model.api.xml.JobAction)6 BusinessObjectDataNotificationRegistrationEntity (org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity)5