Java Code Examples for org.apache.olingo.commons.api.edm.Edm#getSchema()
The following examples show how to use
org.apache.olingo.commons.api.edm.Edm#getSchema() .
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 | 6 votes |
@Test public void readAnnotationOnSchema() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmSchema schema = edm.getSchema("sepmra_so_man2_anno_mdl.v1"); assertNotNull(schema); assertEquals(117, schema.getAnnotationGroups().size()); EdmAnnotations annotations = edm.getSchema("SEPMRA_SO_MAN2").getAnnotationGroups().get(22); assertEquals("SEPMRA_SO_MAN2.SEPMRA_C_SalesOrderCustCntctVHType", annotations.getTargetPath()); assertEquals(1, annotations.getAnnotations().size()); assertEquals("SelectionFields", annotations.getAnnotations() .get(0).getTerm().getName()); assertTrue(annotations.getAnnotations().get(0).getExpression().isDynamic()); }
Example 2
Source File: MetadataTestITCase.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void vocabularies() { final Edm edm = client.getRetrieveRequestFactory(). getMetadataRequest(testVocabulariesServiceRootURL).execute().getBody(); assertNotNull(edm); final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core", "IsLanguageDependent")); assertNotNull(isLanguageDependent); assertTrue(isLanguageDependent.getAppliesTo().contains(TargetType.Property)); assertTrue(isLanguageDependent.getAppliesTo().contains(TargetType.Term)); assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core", "Tag")), isLanguageDependent.getType()); assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean), ((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType()); final EdmTerm permissions = edm.getTerm(new FullQualifiedName("Core", "Permissions")); assertNotNull(permissions); assertTrue(permissions.getType() instanceof EdmEnumType); // 2. measures final EdmSchema measures = edm.getSchema("UoM"); assertNotNull(measures); final EdmTerm scale = edm.getTerm(new FullQualifiedName("UoM", "Scale")); assertNotNull(scale); final EdmAnnotation requiresTypeInScale = scale.getAnnotation(edm.getTerm(new FullQualifiedName("Core", "RequiresType")), null); assertNotNull(requiresTypeInScale); assertEquals("Edm.Decimal", requiresTypeInScale.getExpression().asConstant().getValueAsString()); // 3. capabilities final EdmTerm deleteRestrictions = edm.getTerm(new FullQualifiedName("Capabilities", "DeleteRestrictions")); assertNotNull(deleteRestrictions); assertEquals(deleteRestrictions.getType().getFullQualifiedName(), edm.getComplexType(new FullQualifiedName("Capabilities", "DeleteRestrictionsType")).getFullQualifiedName()); }
Example 3
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void demo() { final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML). toMetadata(getClass().getResourceAsStream("demo-metadata.xml")); assertNotNull(metadata); assertFalse(metadata.getSchema(0).getAnnotationGroups().isEmpty()); final CsdlAnnotations annots = metadata.getSchema(0).getAnnotationGroup("ODataDemo.DemoService/Suppliers", null); assertNotNull(annots); assertFalse(annots.getAnnotations().isEmpty()); assertEquals(CsdlConstantExpression.ConstantExpressionType.String, annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getType()); assertEquals("http://www.odata.org/", annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getValue()); // Now let's test some edm:Annotations final Edm edm = client.getReader(). readMetadata(getClass().getResourceAsStream("demo-metadata.xml")); assertNotNull(edm); final EdmSchema schema = edm.getSchema("ODataDemo"); assertNotNull(schema); assertTrue(schema.getAnnotations().isEmpty()); assertFalse(schema.getAnnotationGroups().isEmpty()); final EdmAnnotations annotationGroup = schema.getAnnotationGroups().get(2); assertNotNull(annotationGroup); //TODO; Once there is a working getTarget method comment back in // final EdmAnnotationsTarget annotationsTarget = annotationGroup.getTarget(); // assertNotNull(annotationsTarget); // assertTrue(EdmAnnotationsTarget.TargetType.Property == annotationsTarget.getAnnotationsTargetType()); assertEquals("ODataDemo.Product/Name", annotationGroup.getTargetPath()); final EdmAnnotation annotation = annotationGroup.getAnnotations().get(0); assertNotNull(annotation); assertTrue(annotation.getExpression().isConstant()); assertEquals("String", annotation.getExpression().asConstant().getExpressionName()); assertEquals(10, schema.getAnnotationGroups().get(3).getAnnotations().size()); }
Example 4
Source File: NavPropertyBindingDetails.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public NavPropertyBindingDetails(final Edm edm, final EdmStructuredType type) { this.edm = edm; this.type = type; this.entitySet = getNavigationBindingDetails(type); this.container = this.entitySet.getEntityContainer(); this.schema = edm.getSchema(container.getNamespace()); }
Example 5
Source File: NavPropertyBindingDetails.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public NavPropertyBindingDetails( final Edm edm, final EdmStructuredType sourceType, final EdmNavigationProperty property) { this.edm = edm; this.entitySet = getNavigationBindingDetails(sourceType, property); this.container = this.entitySet.getEntityContainer(); this.schema = edm.getSchema(container.getNamespace()); this.type = entitySet.getEntityType(); }
Example 6
Source File: NavPropertyContainsTarget.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public NavPropertyContainsTarget(final Edm edm, final EdmEntityType type) { super(); this.edm = edm; this.entitySet = null; this.container = null; this.type = type; schema = edm.getSchema(type.getNamespace()); }