Search in sources :

Example 1 with BusinessObjectDefinitionTagKey

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;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity) ArrayList(java.util.ArrayList) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) Predicate(javax.persistence.criteria.Predicate) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) Tuple(javax.persistence.Tuple)

Example 2 with BusinessObjectDefinitionTagKey

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);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKeys(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Example 3 with BusinessObjectDefinitionTagKey

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);
}
Also used : BusinessObjectDefinitionTag(org.finra.herd.model.api.xml.BusinessObjectDefinitionTag) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) BusinessObjectDefinitionTagCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagCreateRequest) Test(org.junit.Test)

Example 4 with BusinessObjectDefinitionTagKey

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);
}
Also used : BusinessObjectDefinitionTag(org.finra.herd.model.api.xml.BusinessObjectDefinitionTag) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Example 5 with BusinessObjectDefinitionTagKey

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);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKeys(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)34 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)34 TagKey (org.finra.herd.model.api.xml.TagKey)34 Test (org.junit.Test)32 BusinessObjectDefinitionTagKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys)11 BusinessObjectDefinitionTag (org.finra.herd.model.api.xml.BusinessObjectDefinitionTag)10 BusinessObjectDefinitionTagCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagCreateRequest)10 BusinessObjectDefinitionTagEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)10 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)6 TagEntity (org.finra.herd.model.jpa.TagEntity)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)3 ArrayList (java.util.ArrayList)2 Tuple (javax.persistence.Tuple)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 Predicate (javax.persistence.criteria.Predicate)2 Order (javax.persistence.criteria.Order)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1