use of org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnDaoImpl method getBusinessObjectDefinitionColumnByKey.
@Override
public BusinessObjectDefinitionColumnEntity getBusinessObjectDefinitionColumnByKey(BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDefinitionColumnEntity> criteria = builder.createQuery(BusinessObjectDefinitionColumnEntity.class);
// The criteria root is the business object definition column.
Root<BusinessObjectDefinitionColumnEntity> businessObjectDefinitionColumnEntityRoot = criteria.from(BusinessObjectDefinitionColumnEntity.class);
// Join to the other tables we can filter on.
Join<BusinessObjectDefinitionColumnEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectDefinitionColumnEntityRoot.join(BusinessObjectDefinitionColumnEntity_.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)), businessObjectDefinitionColumnKey.getNamespace().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)), businessObjectDefinitionColumnKey.getBusinessObjectDefinitionName().toUpperCase()));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionColumnEntityRoot.get(BusinessObjectDefinitionColumnEntity_.name)), businessObjectDefinitionColumnKey.getBusinessObjectDefinitionColumnName().toUpperCase()));
// Add the clauses for the query.
criteria.select(businessObjectDefinitionColumnEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
return executeSingleResultQuery(criteria, String.format("Found more than one business object definition column instance with parameters {namespace=\"%s\", businessObjectDefinitionName=\"%s\"," + " businessObjectDefinitionColumnName=\"%s\"}.", businessObjectDefinitionColumnKey.getNamespace(), businessObjectDefinitionColumnKey.getBusinessObjectDefinitionName(), businessObjectDefinitionColumnKey.getBusinessObjectDefinitionColumnName()));
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnDaoImpl method getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName.
@Override
public BusinessObjectDefinitionColumnEntity getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String businessObjectDefinitionColumnName) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<BusinessObjectDefinitionColumnEntity> criteria = builder.createQuery(BusinessObjectDefinitionColumnEntity.class);
// The criteria root is the business object definition column.
Root<BusinessObjectDefinitionColumnEntity> businessObjectDefinitionColumnEntityRoot = criteria.from(BusinessObjectDefinitionColumnEntity.class);
// Create the standard restrictions (i.e. the standard where clauses).
List<Predicate> predicates = new ArrayList<>();
predicates.add(builder.equal(businessObjectDefinitionColumnEntityRoot.get(BusinessObjectDefinitionColumnEntity_.businessObjectDefinition), businessObjectDefinitionEntity));
predicates.add(builder.equal(builder.upper(businessObjectDefinitionColumnEntityRoot.get(BusinessObjectDefinitionColumnEntity_.name)), businessObjectDefinitionColumnName.toUpperCase()));
// Add the clauses for the query.
criteria.select(businessObjectDefinitionColumnEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
return executeSingleResultQuery(criteria, String.format("Found more than one business object definition column instance with parameters {namespace=\"%s\", businessObjectDefinitionName=\"%s\"," + " businessObjectDefinitionColumnName=\"%s\"}.", businessObjectDefinitionEntity.getNamespace().getCode(), businessObjectDefinitionEntity.getName(), businessObjectDefinitionColumnName));
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnServiceImpl method deleteBusinessObjectDefinitionColumn.
@NamespacePermission(fields = "#businessObjectDefinitionColumnKey.namespace", permissions = { NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT, NamespacePermissionEnum.WRITE })
@Override
public BusinessObjectDefinitionColumn deleteBusinessObjectDefinitionColumn(BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey) {
// Validate and trim the business object definition column key.
validateBusinessObjectDefinitionColumnKey(businessObjectDefinitionColumnKey);
// Retrieve and ensure that a business object definition column exists with the business object definition.
BusinessObjectDefinitionColumnEntity businessObjectDefinitionColumnEntity = businessObjectDefinitionColumnDaoHelper.getBusinessObjectDefinitionColumnEntity(businessObjectDefinitionColumnKey);
// Unlink schema columns from the business object definition column.
for (SchemaColumnEntity schemaColumnEntity : businessObjectDefinitionColumnEntity.getSchemaColumns()) {
schemaColumnEntity.setBusinessObjectDefinitionColumn(null);
}
// Delete the business object definition column.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionColumnEntity.getBusinessObjectDefinition();
businessObjectDefinitionEntity.getColumns().remove(businessObjectDefinitionColumnEntity);
businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionEntity);
// Notify the search index that a business object definition must be updated.
searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
// Create and return the business object definition column object from the deleted entity.
return createBusinessObjectDefinitionColumnFromEntity(businessObjectDefinitionColumnEntity, true, getValidSearchResponseFields(), false);
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnServiceImpl method createBusinessObjectDefinitionColumn.
@NamespacePermission(fields = "#request.businessObjectDefinitionColumnKey.namespace", permissions = { NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT, NamespacePermissionEnum.WRITE })
@Override
public BusinessObjectDefinitionColumn createBusinessObjectDefinitionColumn(BusinessObjectDefinitionColumnCreateRequest request) {
// Validate and trim the business object definition column create request.
validateBusinessObjectDefinitionColumnCreateRequest(request);
// Get the business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = businessObjectDefinitionHelper.getBusinessObjectDefinitionKey(request.getBusinessObjectDefinitionColumnKey());
// Get the business object definition and ensure it exists.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey);
// Ensure a business object definition column with the specified name doesn't already exist for the business object definition.
if (businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionEntity, request.getBusinessObjectDefinitionColumnKey().getBusinessObjectDefinitionColumnName()) != null) {
throw new AlreadyExistsException(String.format("Unable to create business object definition column with name \"%s\" because it already exists for the business object definition {%s}.", request.getBusinessObjectDefinitionColumnKey().getBusinessObjectDefinitionColumnName(), businessObjectDefinitionHelper.businessObjectDefinitionKeyToString(businessObjectDefinitionKey)));
}
// Retrieve schema column entities from all format instances for the business object definition that match the specified schema column name.
Collection<SchemaColumnEntity> schemaColumnEntities = schemaColumnDao.getSchemaColumns(businessObjectDefinitionEntity, request.getSchemaColumnName());
// Ensure that exists at least one schema column that matches the specified schema column name.
if (CollectionUtils.isEmpty(schemaColumnEntities)) {
if (businessObjectDefinitionEntity.getDescriptiveBusinessObjectFormat() == null) {
throw new ObjectNotFoundException(String.format("Unable to create business object definition column because there are no format schema " + "columns with name \"%s\" for the business object definition {%s}.", request.getSchemaColumnName(), businessObjectDefinitionHelper.businessObjectDefinitionKeyToString(businessObjectDefinitionKey)));
} else {
throw new ObjectNotFoundException(String.format("Unable to create business object definition column because there are no format schema " + "columns with name \"%s\" in the descriptive business object format for the business object definition {%s}.", request.getSchemaColumnName(), businessObjectDefinitionHelper.businessObjectDefinitionKeyToString(businessObjectDefinitionKey)));
}
}
// Ensure a business object definition column with the specified schema column name doesn't already exist for this business object definition.
for (SchemaColumnEntity schemaColumnEntity : schemaColumnEntities) {
if (schemaColumnEntity.getBusinessObjectDefinitionColumn() != null) {
throw new AlreadyExistsException(String.format("Unable to create business object definition column because a business object definition column " + "with schema column name \"%s\" already exists for the business object definition {%s}.", request.getSchemaColumnName(), businessObjectDefinitionHelper.businessObjectDefinitionKeyToString(businessObjectDefinitionKey)));
}
}
// Create a business object definition column entity from the request information.
BusinessObjectDefinitionColumnEntity businessObjectDefinitionColumnEntity = createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, request);
// Link schema columns with the business object definition column.
for (SchemaColumnEntity schemaColumnEntity : schemaColumnEntities) {
schemaColumnEntity.setBusinessObjectDefinitionColumn(businessObjectDefinitionColumnEntity);
}
// Persist the change event entity
businessObjectDefinitionColumnDaoHelper.saveBusinessObjectDefinitionColumnChangeEvents(businessObjectDefinitionColumnEntity);
// Persist the new entity.
businessObjectDefinitionColumnEntity = businessObjectDefinitionColumnDao.saveAndRefresh(businessObjectDefinitionColumnEntity);
// Notify the search index that a business object definition must be updated.
searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
// Create and return the business object definition column object from the persisted entity.
return createBusinessObjectDefinitionColumnFromEntity(businessObjectDefinitionColumnEntity, true, getValidSearchResponseFields(), false);
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnServiceImpl method updateBusinessObjectDefinitionColumn.
@NamespacePermission(fields = "#businessObjectDefinitionColumnKey.namespace", permissions = { NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT, NamespacePermissionEnum.WRITE })
@Override
public BusinessObjectDefinitionColumn updateBusinessObjectDefinitionColumn(BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey, BusinessObjectDefinitionColumnUpdateRequest request) {
// Validate and trim the business object definition column key.
validateBusinessObjectDefinitionColumnKey(businessObjectDefinitionColumnKey);
// Validate and trim the business object definition column update request.
validateBusinessObjectDefinitionColumnUpdateRequest(request);
// Retrieve and ensure that a business object definition column exists with the business object definition.
BusinessObjectDefinitionColumnEntity businessObjectDefinitionColumnEntity = businessObjectDefinitionColumnDaoHelper.getBusinessObjectDefinitionColumnEntity(businessObjectDefinitionColumnKey);
// Update the entity with the new values.
businessObjectDefinitionColumnEntity.setDescription(request.getDescription());
// Persist the change event entity
businessObjectDefinitionColumnDaoHelper.saveBusinessObjectDefinitionColumnChangeEvents(businessObjectDefinitionColumnEntity);
// Persist the entity.
businessObjectDefinitionColumnEntity = businessObjectDefinitionColumnDao.saveAndRefresh(businessObjectDefinitionColumnEntity);
// Notify the search index that a business object definition must be updated.
searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionColumnEntity.getBusinessObjectDefinition(), SEARCH_INDEX_UPDATE_TYPE_UPDATE);
// Create and return the business object definition column object from the persisted entity.
return createBusinessObjectDefinitionColumnFromEntity(businessObjectDefinitionColumnEntity, true, getValidSearchResponseFields(), false);
}
Aggregations