use of org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey 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.api.xml.BusinessObjectDefinitionTagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagRestControllerTest method testGetBusinessObjectDefinitionTagsByTag.
@Test
public void testGetBusinessObjectDefinitionTagsByTag() {
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
BusinessObjectDefinitionTagKeys businessObjectDefinitionTagKeys = new BusinessObjectDefinitionTagKeys(Arrays.asList(businessObjectDefinitionTagKey));
when(businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByTag(tagKey)).thenReturn(businessObjectDefinitionTagKeys);
// Get business object definition tags by tag.
BusinessObjectDefinitionTagKeys result = businessObjectDefinitionTagRestController.getBusinessObjectDefinitionTagsByTag(TAG_TYPE, TAG_CODE);
// Verify the external calls.
verify(businessObjectDefinitionTagService).getBusinessObjectDefinitionTagsByTag(tagKey);
verifyNoMoreInteractions(businessObjectDefinitionTagService);
// Validate the returned object.
assertEquals(businessObjectDefinitionTagKeys, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagRestControllerTest method testCreateBusinessObjectDefinitionTag.
@Test
public void testCreateBusinessObjectDefinitionTag() {
// Create a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create a business object definition tag key.
BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, new TagKey(TAG_TYPE, TAG_CODE));
BusinessObjectDefinitionTag businessObjectDefinitionTag = new BusinessObjectDefinitionTag(ID, businessObjectDefinitionTagKey);
BusinessObjectDefinitionTagCreateRequest request = new BusinessObjectDefinitionTagCreateRequest(businessObjectDefinitionTagKey);
when(businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(request)).thenReturn(businessObjectDefinitionTag);
// Create a business object definition tag.
BusinessObjectDefinitionTag result = businessObjectDefinitionTagRestController.createBusinessObjectDefinitionTag(request);
// Verify the external calls.
verify(businessObjectDefinitionTagService).createBusinessObjectDefinitionTag(request);
verifyNoMoreInteractions(businessObjectDefinitionTagService);
// Validate the returned object.
assertEquals(businessObjectDefinitionTag, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagRestControllerTest method testDeleteBusinessObjectDefinitionTag.
@Test
public void testDeleteBusinessObjectDefinitionTag() {
// Create a business object definition tag key.
BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
BusinessObjectDefinitionTag businessObjectDefinitionTag = new BusinessObjectDefinitionTag(ID, businessObjectDefinitionTagKey);
when(businessObjectDefinitionTagService.deleteBusinessObjectDefinitionTag(businessObjectDefinitionTagKey)).thenReturn(businessObjectDefinitionTag);
// Delete this business object definition tag.
BusinessObjectDefinitionTag result = businessObjectDefinitionTagRestController.deleteBusinessObjectDefinitionTag(BDEF_NAMESPACE, BDEF_NAME, TAG_TYPE, TAG_CODE);
// Verify the external calls.
verify(businessObjectDefinitionTagService).deleteBusinessObjectDefinitionTag(businessObjectDefinitionTagKey);
verifyNoMoreInteractions(businessObjectDefinitionTagService);
// Validate the returned object.
assertEquals(businessObjectDefinitionTag, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagRestControllerTest method testGetBusinessObjectDefinitionTagsByBusinessObjectDefinition.
@Test
public void testGetBusinessObjectDefinitionTagsByBusinessObjectDefinition() {
// Create a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create tag keys.
List<TagKey> tagKeys = Arrays.asList(new TagKey(TAG_TYPE, TAG_CODE), new TagKey(TAG_TYPE_2, TAG_CODE_2));
BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, new TagKey(TAG_TYPE, TAG_CODE));
BusinessObjectDefinitionTagKeys BusinessObjectDefinitionTagKeys = new BusinessObjectDefinitionTagKeys(Arrays.asList(businessObjectDefinitionTagKey));
when(businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByBusinessObjectDefinition(businessObjectDefinitionKey)).thenReturn(BusinessObjectDefinitionTagKeys);
// Get business object definition tags by business object definition.
BusinessObjectDefinitionTagKeys result = businessObjectDefinitionTagRestController.getBusinessObjectDefinitionTagsByBusinessObjectDefinition(BDEF_NAMESPACE, BDEF_NAME);
// Verify the external calls.
verify(businessObjectDefinitionTagService).getBusinessObjectDefinitionTagsByBusinessObjectDefinition(businessObjectDefinitionKey);
verifyNoMoreInteractions(businessObjectDefinitionTagService);
// Validate the returned object.
assertEquals(BusinessObjectDefinitionTagKeys, result);
}
Aggregations