use of org.finra.herd.model.jpa.GlobalAttributeDefinitionLevelEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoImpl method getGlobalAttributeDefinitionByKey.
@Override
public GlobalAttributeDefinitionEntity getGlobalAttributeDefinitionByKey(GlobalAttributeDefinitionKey globalAttributeDefinitionKey) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<GlobalAttributeDefinitionEntity> criteria = builder.createQuery(GlobalAttributeDefinitionEntity.class);
// The criteria root is the global attribute definition entity.
Root<GlobalAttributeDefinitionEntity> globalAttributeDefinitionEntityRoot = criteria.from(GlobalAttributeDefinitionEntity.class);
// Join on the other tables that we filter on
Join<GlobalAttributeDefinitionEntity, GlobalAttributeDefinitionLevelEntity> globalAttributeDefinitionLevelEntityJoin = globalAttributeDefinitionEntityRoot.join(GlobalAttributeDefinitionEntity_.globalAttributeDefinitionLevel);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(builder.upper(globalAttributeDefinitionLevelEntityJoin.get(GlobalAttributeDefinitionLevelEntity_.globalAttributeDefinitionLevel)), globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel().toUpperCase()));
predicates.add(builder.equal(builder.upper(globalAttributeDefinitionEntityRoot.get(GlobalAttributeDefinitionEntity_.globalAttributeDefinitionName)), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName().toUpperCase()));
// Add all clauses to the query.
criteria.select(globalAttributeDefinitionEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
return executeSingleResultQuery(criteria, String.format("Found more than one global attribute definition with parameters {globalAttributeDefinitionLevel=\"%s\", globalAttributeDefinitionLevel=\"%s\"}.", globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel(), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName()));
}
use of org.finra.herd.model.jpa.GlobalAttributeDefinitionLevelEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionLevelDaoImpl method getGlobalAttributeDefinitionLevel.
@Override
public GlobalAttributeDefinitionLevelEntity getGlobalAttributeDefinitionLevel(String code) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<GlobalAttributeDefinitionLevelEntity> criteria = builder.createQuery(GlobalAttributeDefinitionLevelEntity.class);
// The criteria root is the global attribute definition level
Root<GlobalAttributeDefinitionLevelEntity> globalAttributeDefinitionLevelEntityRoot = criteria.from(GlobalAttributeDefinitionLevelEntity.class);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate predicate = builder.equal(builder.upper(globalAttributeDefinitionLevelEntityRoot.get(GlobalAttributeDefinitionLevelEntity_.globalAttributeDefinitionLevel)), code.toUpperCase());
// Add all clauses to the query.
criteria.select(globalAttributeDefinitionLevelEntityRoot).where(predicate);
// Execute the query and return the result.
return executeSingleResultQuery(criteria, String.format("Found more than one global attribute definition level with code \"%s\".", code));
}
use of org.finra.herd.model.jpa.GlobalAttributeDefinitionLevelEntity in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceImpl method createGlobalAttributeDefinition.
@Override
public GlobalAttributeDefinition createGlobalAttributeDefinition(GlobalAttributeDefinitionCreateRequest request) {
// Validate and trim the request parameters.
validateGlobalAttributeDefinitionCreateRequest(request);
// Validate the global Attribute Definition entity does not already exist in the database.
globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(request.getGlobalAttributeDefinitionKey());
// Get the existing global Attribute Definition level entity
GlobalAttributeDefinitionLevelEntity globalAttributeDefinitionLevelEntity = globalAttributeDefinitionLevelDao.getGlobalAttributeDefinitionLevel(request.getGlobalAttributeDefinitionKey().getGlobalAttributeDefinitionLevel());
AttributeValueListEntity attributeValueListEntity = null;
// Get the attribute value list if the attribute value key exists
if (request.getAttributeValueListKey() != null) {
// Get the existing attribute list and ensure it exists
attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey());
}
// Create and persist a new global Attribute Definition entity from the request information.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntity(request.getGlobalAttributeDefinitionKey(), globalAttributeDefinitionLevelEntity, attributeValueListEntity);
// Create and return the global Attribute Definition object from the persisted entity.
return createGlobalAttributeDefinitionFromEntity(globalAttributeDefinitionEntity);
}
Aggregations