Java Code Examples for org.apache.olingo.commons.api.edm.Edm#getEntityTypeWithAnnotations()
The following examples show how to use
org.apache.olingo.commons.api.edm.Edm#getEntityTypeWithAnnotations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationOnAnEntityType() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityType entity = edm.getEntityTypeWithAnnotations( new FullQualifiedName("SEPMRA_SO_MAN2", "SEPMRA_C_CountryVHType")); assertEquals(1, entity.getAnnotations().size()); assertNotNull(entity.getAnnotations().get(0).getTerm()); assertEquals("HeaderInfo", entity.getAnnotations().get(0).getTerm().getName()); assertNotNull(entity.getAnnotations().get(0).getExpression()); EdmEntityType entity1 = edm.getEntityTypeWithAnnotations( new FullQualifiedName("SEPMRA_SO_MAN2", "SEPMRA_C_SalesOrderCustCntctVHType")); EdmAnnotation annotation = entity1.getAnnotations().get(0); assertNotNull(annotation); assertEquals(6, entity1.getAnnotations().size()); assertEquals("FieldGroup", annotation.getTerm().getName()); assertEquals("ContactPerson", annotation.getQualifier()); EdmExpression expression = annotation.getExpression(); assertNotNull(expression); assertTrue(expression.isDynamic()); EdmRecord record = expression.asDynamic().asRecord(); assertNotNull(record); assertEquals(2, record.asRecord().getPropertyValues().size()); List<EdmPropertyValue> propertyValues = record.asRecord().getPropertyValues(); assertEquals("Data", propertyValues.get(0).getProperty()); assertTrue(propertyValues.get(0).getValue().isDynamic()); List<EdmExpression> items = propertyValues.get(0).getValue().asDynamic().asCollection().getItems(); assertEquals(4, items.size()); assertEquals("Label", propertyValues.get(1).getProperty()); assertEquals("Contact Person", propertyValues.get(1).getValue().asConstant().asPrimitive()); assertEquals(2, entity1.getNavigationProperty("to_Customer").getAnnotations().size()); EdmNavigationProperty navProperty = entity1.getNavigationProperty("to_Customer"); assertEquals("ThingPerspective", navProperty. getAnnotations().get(0).getTerm().getName()); }
Example 2
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationOnAProperty() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityType entity = edm.getEntityTypeWithAnnotations( new FullQualifiedName("SEPMRA_SO_MAN2", "I_DraftAdministrativeDataType")); EdmProperty property = (EdmProperty) entity.getProperty("DraftUUID"); assertNotNull(property.getAnnotations()); assertEquals(1, property.getAnnotations().size()); assertEquals("UI.HeaderInfo", property.getAnnotations().get(0).getTerm(). getFullQualifiedName().getFullQualifiedNameAsString()); }
Example 3
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void readAnnotationOnEntitySet() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); EdmEntitySet entitySet = container.getEntitySet("I_DraftAdministrativeData"); assertEquals(1, entitySet.getAnnotations().size()); assertEquals("HeaderInfo", entitySet.getAnnotations().get(0).getTerm().getName()); EdmEntityType entityType50 = edm.getEntityTypeWithAnnotations( new FullQualifiedName("SEPMRA_SO_MAN2", "I_DraftAdministrativeDataType")); assertEquals(1, ((EdmProperty) entityType50.getProperty("DraftUUID")).getAnnotations().size()); assertEquals("UI.HeaderInfo", ((EdmProperty) entityType50.getProperty("DraftUUID")).getAnnotations().get(0) .getTerm().getFullQualifiedName().getFullQualifiedNameAsString()); // Annotations on properties of entity type included in EntitySet EdmEntityType entityType3 = entitySet.getEntityTypeWithAnnotations(); assertEquals(3, ((EdmProperty) entityType3.getProperty("DraftUUID")).getAnnotations().size()); assertEquals("AdditionalInfo", ((EdmProperty) entityType3.getProperty("DraftUUID")) .getAnnotations().get(0).getTerm().getName()); assertEquals("HeaderInfo", ((EdmProperty) entityType3.getProperty("DraftUUID")) .getAnnotations().get(1).getTerm().getName()); // Annotations on navigation properties of entity type included in EntitySet EdmEntitySet entitySet1 = container.getEntitySet("SEPMRA_C_SalesOrderCustCntctVH"); EdmEntityType entityType5 = entitySet1.getEntityTypeWithAnnotations(); assertEquals(2, ((EdmNavigationProperty) entityType5.getNavigationProperty("to_Customer")) .getAnnotations().size()); assertEquals("AdditionalInfo", ((EdmNavigationProperty) entityType5 .getNavigationProperty("to_Customer")) .getAnnotations().get(0).getTerm().getName()); assertEquals("HeaderInfo", ((EdmNavigationProperty) entityType5 .getNavigationProperty("to_Customer")) .getAnnotations().get(1).getTerm().getName()); EdmComplexType complexType = edm.getComplexTypeWithAnnotations( new FullQualifiedName("SEPMRA_SO_MAN2", "CTPrim")); EdmProperty complexTypeProp = (EdmProperty) complexType.getProperty("PropertyInt16"); assertEquals(1, complexTypeProp.getAnnotations().size()); assertEquals("HeaderInfo", complexTypeProp.getAnnotations().get(0).getTerm().getName()); // Annotations on properties of complex properties of entity type included in EntitySet EdmProperty complexProp = (EdmProperty) entityType3.getProperty("ComplexProperty"); EdmComplexType compType = (EdmComplexType) complexProp.getTypeWithAnnotations(); EdmProperty prop = (EdmProperty) compType.getProperty("PropertyInt16"); assertEquals(2, prop.getAnnotations().size()); assertEquals("AdditionalInfo", prop.getAnnotations().get(0).getTerm().getName()); // Annotations on navigation properties of complex properties of entity type included in EntitySet EdmNavigationProperty navProp = (EdmNavigationProperty) compType .getProperty("NavPropertyDraftAdministrativeDataType"); assertEquals(2, navProp.getAnnotations().size()); assertEquals("AdditionalInfo", navProp.getAnnotations().get(0).getTerm().getName()); }