Java Code Examples for org.apache.olingo.commons.api.edm.Edm#getEntityContainer()
The following examples show how to use
org.apache.olingo.commons.api.edm.Edm#getEntityContainer() .
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: ODataMetaDataExtension.java From syndesis with Apache License 2.0 | 6 votes |
private static void extractEdmNames(ODataMetadata odataMetadata, Edm edm) { Set<EdmNamed> namedList = new HashSet<>(); EdmEntityContainer container = edm.getEntityContainer(); namedList.addAll(container.getEntitySets()); // // TODO // Consider whether we need these in the future. // // namedList.addAll(container.getFunctionImports()); // namedList.addAll(container.getSingletons()); // namedList.addAll(container.getActionImports()); // Set<String> names = new TreeSet<>(); namedList.stream().distinct().forEach((entity) -> { names.add(entity.getName()); }); odataMetadata.setEntityNames(names); }
Example 2
Source File: ODataMetaDataExtension.java From syndesis with Apache License 2.0 | 6 votes |
private static void extractEdmMetadata(ODataMetadata odataMetadata, Edm edm, String resourcePath) { if (ObjectHelper.isEmpty(resourcePath)) { LOG.warn("No method name with which to query OData service."); return; } EdmEntityContainer entityContainer = edm.getEntityContainer(); EdmEntitySet entitySet = entityContainer.getEntitySet(resourcePath); if (ObjectHelper.isEmpty(entitySet)) { LOG.warn("No entity set associated with the selected api name: {}.", resourcePath); return; } EdmTypeConvertor visitor = new EdmTypeConvertor(); EdmEntityType entityType = entitySet.getEntityType(); Set<PropertyMetadata> properties = visitor.visit(entityType); odataMetadata.setEntityProperties(properties); }
Example 3
Source File: EdmProviderImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void nothingSpecifiedMustNotResultInExceptions() throws Exception { CsdlEdmProvider localProvider = mock(CsdlEdmProvider.class); when(localProvider.getActions(FQN)).thenReturn(null); when(localProvider.getFunctions(FQN)).thenReturn(null); Edm localEdm = new EdmProviderImpl(localProvider); localEdm.getUnboundAction(FQN); localEdm.getUnboundFunction(FQN, null); localEdm.getBoundAction(FQN, FQN, true); localEdm.getBoundFunction(FQN, FQN, true, null); localEdm.getComplexType(FQN); localEdm.getEntityContainer(FQN); localEdm.getEntityType(FQN); localEdm.getEnumType(FQN); localEdm.getTypeDefinition(FQN); }
Example 4
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void readAnnotationWithAliasOnEntitySetProperties() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); EdmEntitySet entitySet = container.getEntitySet("I_DraftAdministrativeData"); EdmEntityType entityType = entitySet.getEntityTypeWithAnnotations(); List<EdmAnnotation> annotations = ((EdmProperty)entityType.getProperty("DraftUUID")).getAnnotations(); assertEquals(3, annotations.size()); FullQualifiedName termName = new FullQualifiedName("Integration", "Extractable"); EdmTerm term = edm.getTerm(termName); EdmAnnotation annotation = ((EdmProperty)entityType.getProperty("DraftUUID")).getAnnotation(term, null); assertNotNull(annotation); }
Example 5
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void testOLINGO1100() { final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("olingo1100.xml")); assertNotNull(edm); final EdmEntityContainer container = edm.getEntityContainer( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "EntityContainer")); assertNotNull(container); final EdmEntitySet providers = container.getEntitySet("Provider"); assertNotNull(providers); assertEquals(edm.getEntityType(new FullQualifiedName(container.getNamespace(), "Provider")), providers.getEntityType()); assertEquals(container.getEntitySet("ProviderLicense"), providers.getRelatedBindingTarget("ProviderLicense")); assertNull(providers.getRelatedBindingTarget("ProviderLicensePractice")); assertNull(providers.getRelatedBindingTarget("Provider")); final EdmEntitySet providerLicenses = container.getEntitySet("ProviderLicense"); assertEquals(edm.getEntityType(new FullQualifiedName(container.getNamespace(), "ProviderLicense")), providerLicenses.getEntityType()); assertEquals(container.getEntitySet("ProviderLicensePractice"), providerLicenses.getRelatedBindingTarget("ProviderLicensePractice")); assertNull(providerLicenses.getRelatedBindingTarget("ProviderLicense")); assertNull(providerLicenses.getRelatedBindingTarget("Provider")); final EdmEntitySet providerLicensePractices = container.getEntitySet("ProviderLicensePractice"); assertNull(providerLicensePractices.getRelatedBindingTarget("ProviderLicensePractice")); assertNull(providerLicensePractices.getRelatedBindingTarget("Provider")); assertNull(providerLicenses.getRelatedBindingTarget("ProviderLicense")); }
Example 6
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void readAnnotationOnASingleton() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); EdmSingleton singleton = container.getSingleton("SINav"); assertEquals(2, singleton.getAnnotations().size()); FullQualifiedName termName = new FullQualifiedName("UI", "HeaderInfo"); EdmTerm term = edm.getTerm(termName); EdmAnnotation annotation = singleton.getAnnotation(term, null); assertNotNull(annotation); EdmEntityType singletonET = singleton.getEntityType(); EdmProperty singlComplexProp = (EdmProperty) singletonET.getProperty("ComplexProperty"); EdmComplexType singlCompType = (EdmComplexType) singlComplexProp.getTypeWithAnnotations(); EdmNavigationProperty singlNavProp = (EdmNavigationProperty) singlCompType.getNavigationProperty( "NavPropertyDraftAdministrativeDataType"); assertEquals(2, singlNavProp.getAnnotations().size()); assertEquals("AdditionalInfo", singlNavProp.getAnnotations().get(0).getTerm().getName()); }
Example 7
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationFetchingAllEntitySets() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); List<EdmEntitySet> entitySets = container.getEntitySets(); assertEquals(4, entitySets.size()); FullQualifiedName termName = new FullQualifiedName("UI", "HeaderInfo"); EdmTerm term = edm.getTerm(termName); EdmAnnotation annotation = entitySets.get(0).getAnnotation(term, null); assertNotNull(annotation); }
Example 8
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationFetchingAllFunctionImports() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); List<EdmFunctionImport> functionImports = container.getFunctionImports(); assertEquals(1, functionImports.size()); FullQualifiedName termName = new FullQualifiedName("Integration", "Extractable"); EdmTerm term = edm.getTerm(termName); EdmAnnotation annotation = functionImports.get(0).getAnnotation(term, null); assertNotNull(annotation); }
Example 9
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationFetchingAllActionImports() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); List<EdmActionImport> actionImports = container.getActionImports(); assertEquals(1, actionImports.size()); }
Example 10
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationFetchingAllSingletons() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); List<EdmSingleton> singletons = container.getSingletons(); assertEquals(1, singletons.size()); FullQualifiedName termName = new FullQualifiedName("UI", "HeaderInfo"); EdmTerm term = edm.getTerm(termName); EdmAnnotation annotation = singletons.get(0).getAnnotation(term, null); assertNotNull(annotation); }
Example 11
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationOnFunctionImport() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); EdmFunctionImport functionImport = container.getFunctionImport("FIC_RTTimeOfDay_"); assertEquals(3, functionImport.getAnnotations().size()); FullQualifiedName termName = new FullQualifiedName("UI", "Identification"); EdmTerm term = edm.getTerm(termName); EdmAnnotation annotation = functionImport.getAnnotation(term, null); assertNotNull(annotation); }
Example 12
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationOnContainer() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); assertEquals(5, container.getAnnotations().size()); assertEquals("HeaderInfo", container.getAnnotations().get(1).getTerm().getName()); }
Example 13
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readAnnotationOnActionImport() { final Edm edm = fetchEdm(); assertNotNull(edm); EdmEntityContainer container = edm.getEntityContainer(); EdmActionImport actionImport = container.getActionImport("AIRTString"); assertEquals(4, actionImport.getAnnotations().size()); assertEquals("Description", actionImport.getAnnotations().get(0).getTerm().getName()); assertEquals("HeaderInfo", actionImport.getAnnotations().get(2).getTerm().getName()); }
Example 14
Source File: EdmProviderImplTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test(expected = EdmException.class) public void convertExceptionsAliasTest() throws Exception { CsdlEdmProvider localProvider = mock(CsdlEdmProvider.class); when(localProvider.getAliasInfos()).thenThrow(new ODataException("msg")); Edm localEdm = new EdmProviderImpl(localProvider); localEdm.getEntityContainer(); }
Example 15
Source File: BasicITCase.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void readMetadata() { EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI); assertNotNull(request); setCookieHeader(request); ODataRetrieveResponse<Edm> response = request.execute(); saveCookieHeader(response); assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode()); Edm edm = response.getBody(); assertNotNull(edm); final EdmEntityContainer container = edm.getEntityContainer( new FullQualifiedName("olingo.odata.test1", "Container")); assertNotNull(container); final EdmEntitySet esAllPrim = container.getEntitySet("ESAllPrim"); assertNotNull(esAllPrim); assertEquals("olingo.odata.test1", esAllPrim.getEntityType().getNamespace()); assertEquals(2, edm.getSchemas().size()); assertEquals(SERVICE_NAMESPACE, edm.getSchema(SERVICE_NAMESPACE).getNamespace()); assertEquals("Namespace1_Alias", edm.getSchema(SERVICE_NAMESPACE).getAlias()); assertEquals("Org.OData.Core.V1", edm.getSchema("Org.OData.Core.V1").getNamespace()); assertEquals("Core", edm.getSchema("Org.OData.Core.V1").getAlias()); }
Example 16
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()); }
Example 17
Source File: MetadataTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void parse() { final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("metadata.xml")); assertNotNull(edm); // 1. Enum final EdmEnumType responseEnumType = edm.getEnumType( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "ResponseType")); assertNotNull(responseEnumType); assertEquals(6, responseEnumType.getMemberNames().size()); assertEquals("3", responseEnumType.getMember("Accepted").getValue()); assertEquals(EdmTypeKind.ENUM, responseEnumType.getKind()); // 2. Complex final EdmComplexType responseStatus = edm.getComplexType( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "ResponseStatus")); assertNotNull(responseStatus); assertTrue(responseStatus.getNavigationPropertyNames().isEmpty()); assertEquals("Recipient", responseStatus.getBaseType().getName()); assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.DateTimeOffset), responseStatus.getProperty("Time").getType()); // 3. Entity final EdmEntityType user = edm.getEntityType( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "User")); assertNotNull(user); assertFalse(user.getPropertyNames().isEmpty()); assertFalse(user.getNavigationPropertyNames().isEmpty()); final EdmEntityType entity = edm.getEntityType( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Entity")); assertEquals(entity, user.getBaseType()); assertFalse(entity.getPropertyNames().isEmpty()); assertTrue(entity.getNavigationPropertyNames().isEmpty()); final EdmEntityType folder = edm.getEntityType( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder")); assertEquals(folder, user.getNavigationProperty("Inbox").getType()); // 4. Action final EdmAction move = edm.getBoundAction( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Move"), new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder"), false); assertNotNull(move); assertTrue(move.isBound()); assertEquals(2, move.getParameterNames().size()); assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String), move.getParameter("DestinationId").getType()); // 5. EntityContainer final EdmEntityContainer container = edm.getEntityContainer( new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "EntityContainer")); assertNotNull(container); final EdmEntitySet users = container.getEntitySet("Users"); assertNotNull(users); assertEquals(edm.getEntityType(new FullQualifiedName(container.getNamespace(), "User")), users.getEntityType()); assertEquals(container.getEntitySet("Folders"), users.getRelatedBindingTarget("Folders")); }
Example 18
Source File: ResourcePathParser.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public ResourcePathParser(final Edm edm, final Map<String, AliasQueryOption> aliases) { this.edm = edm; this.aliases = aliases; edmEntityContainer = edm.getEntityContainer(); }
Example 19
Source File: BasicITCase.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void readUpdatepdateEntity() throws Exception { EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI); assertNotNull(request); setCookieHeader(request); ODataRetrieveResponse<Edm> response = request.execute(); saveCookieHeader(response); assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode()); Edm edm = response.getBody(); assertNotNull(edm); final EdmEntityContainer container = edm.getEntityContainer( new FullQualifiedName("olingo.odata.test1", "Container")); assertNotNull(container); final EdmEntitySet esAllPrim = container.getEntitySet("ESAllPrim"); assertNotNull(esAllPrim); assertEquals("olingo.odata.test1", esAllPrim.getEntityType().getNamespace()); assertEquals(2, edm.getSchemas().size()); assertEquals(SERVICE_NAMESPACE, edm.getSchema(SERVICE_NAMESPACE).getNamespace()); assertEquals("Namespace1_Alias", edm.getSchema(SERVICE_NAMESPACE).getAlias()); assertEquals("Org.OData.Core.V1", edm.getSchema("Org.OData.Core.V1").getNamespace()); assertEquals("Core", edm.getSchema("Org.OData.Core.V1").getAlias()); ClientEntity newEntity = getFactory().newEntity(ET_ALL_PRIM); newEntity.getProperties().add(getFactory().newPrimitiveProperty(PROPERTY_INT64, getFactory().newPrimitiveValueBuilder().buildInt64((long) 42))); final URI uri = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(32767) .build(); final ODataEntityUpdateRequest<ClientEntity> request2 = getClient().getCUDRequestFactory().getEntityUpdateRequest( uri, UpdateType.REPLACE, newEntity); HttpUriRequest req = request2.getHttpRequest(); final ODataEntityUpdateResponse<ClientEntity> response2 = request2.execute(); assertNotNull(req); assertEquals(HttpStatusCode.OK.getStatusCode(), response2.getStatusCode()); // Check that the updated properties have changed and that other properties have their default values. StringWriter writer = new StringWriter(); InputStream stream = response2.getRawResponse(); IOUtils.copy(stream, writer); assertNotNull(writer.toString()); final ClientEntity entity = response2.getBody(); assertNotNull(entity); final ClientProperty property1 = entity.getProperty(PROPERTY_INT64); assertNotNull(property1); assertShortOrInt(42, property1.getPrimitiveValue().toValue()); final ClientProperty property2 = entity.getProperty(PROPERTY_DECIMAL); assertNotNull(property2); assertNull(property2.getPrimitiveValue().toValue()); }