org.apache.olingo.odata2.api.edm.EdmEntityContainer Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.edm.EdmEntityContainer.
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: ServiceTicketODataConsumer.java From C4CODATAAPIDEVGUIDE with Apache License 2.0 | 6 votes |
public ODataEntry readEntry(String serviceUri, String contentType, String entitySetName, String keyValue, SystemQueryOptions options) throws IllegalStateException, IOException, EdmException, EntityProviderException { EdmEntityContainer entityContainer = readEdm() .getDefaultEntityContainer(); logger.info("Entity container is => " + entityContainer.getName()); String absolutUri = createUri(serviceUri, entitySetName, keyValue, options); InputStream content = executeGet(absolutUri, contentType); return EntityProvider.readEntry(contentType, entityContainer.getEntitySet(entitySetName), content, EntityProviderReadProperties.init().build()); }
Example #2
Source File: EntitySetTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private UriInfo mockUriResult(final String entitySetName) throws ODataException, URISyntaxException { EdmEntityType entityType = mock(EdmEntityType.class); when(entityType.getName()).thenReturn(entitySetName); EdmEntityContainer entityContainer = mock(EdmEntityContainer.class); when(entityContainer.isDefaultEntityContainer()).thenReturn(true); EdmEntitySet entitySet = mock(EdmEntitySet.class); when(entitySet.getName()).thenReturn(entitySetName); when(entitySet.getEntityType()).thenReturn(entityType); when(entitySet.getEntityContainer()).thenReturn(entityContainer); UriInfo uriResult = mock(UriInfo.class); when(uriResult.getStartEntitySet()).thenReturn(entitySet); when(uriResult.getTargetEntitySet()).thenReturn(entitySet); when(uriResult.getTop()).thenReturn(null); return uriResult; }
Example #3
Source File: EdmAssociationSetEndImplProvTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@BeforeClass public static void getEdmEntityContainerImpl() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); EntityContainerInfo entityContainer = new EntityContainerInfo().setName("Container"); EdmEntityContainer edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, entityContainer); AssociationSetEnd associationSetEnd = new AssociationSetEnd().setRole("end1Role").setEntitySet("entitySetRole1"); EntitySet entitySet = new EntitySet().setName("entitySetRole1"); when(edmProvider.getEntitySet("Container", "entitySetRole1")).thenReturn(entitySet); edmAssociationSetEnd = new EdmAssociationSetEndImplProv(associationSetEnd, edmEntityContainer.getEntitySet("entitySetRole1")); }
Example #4
Source File: EdmImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override protected List<EdmEntitySet> createEntitySets() throws ODataException { List<EdmEntitySet> edmEntitySets = new ArrayList<EdmEntitySet>(); if (schemas == null) { schemas = edmProvider.getSchemas(); } for (Schema schema : schemas) { for (EntityContainer entityContainer : schema.getEntityContainers()) { for (EntitySet entitySet : entityContainer.getEntitySets()) { EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName()); edmEntitySets.add(new EdmEntitySetImplProv(this, entitySet, edmEntityContainer)); } } } return edmEntitySets; }
Example #5
Source File: EdmImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override protected List<EdmFunctionImport> createFunctionImports() throws ODataException { List<EdmFunctionImport> edmFunctionImports = new ArrayList<EdmFunctionImport>(); if (schemas == null) { schemas = edmProvider.getSchemas(); } for (Schema schema : schemas) { for (EntityContainer entityContainer : schema.getEntityContainers()) { for (FunctionImport functionImport : entityContainer.getFunctionImports()) { EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName()); edmFunctionImports.add(new EdmFunctionImportImplProv(this, functionImport, edmEntityContainer)); } } } return edmFunctionImports; }
Example #6
Source File: XmlMetadataDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testMetadataWithNavigatons() throws XMLStreamException, EntityProviderException, EdmException, IOException { XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); String xml = readFile("metadataWithNavigations.xml"); InputStream reader = createStreamReader(xml); EdmDataServices result = parser.readMetadata(reader, true); assertEquals(2, result.getEdm().getSchemas().size()); ClientEdm edm = result.getEdm(); assertNotNull(edm); for (EdmSchema schema : result.getEdm().getSchemas()) { for (EdmEntityContainer container : schema.getEntityContainers()) { assertNotNull(container.getEntitySets()); int i=0; for(EdmEntitySet entitySet:container.getEntitySets()){ assertEquals(edm.getSchemas().get(1).getEntityTypes().get(i).getName(), entitySet.getEntityType().getName()); assertEquals(edm.getSchemas().get(1).getEntityTypes().get(i++).getKeyProperties().get(0), entitySet.getEntityType().getKeyProperties().get(0)); } } } }
Example #7
Source File: XmlMetadataAssociationTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testRelatedEntitySet() throws XMLStreamException, EntityProviderException, EdmException, UnsupportedEncodingException { XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); InputStream content = createStreamReader(xmlWithAssociation); EdmDataServices result = parser.readMetadata(content, true); for (EdmSchema schema : result.getEdm().getSchemas()) { for (EdmEntityContainer container : schema.getEntityContainers()) { assertEquals(NAMESPACE2, schema.getNamespace()); assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); for (EdmEntitySet entitySet : container.getEntitySets()) { assertNotNull(entitySet.getEntityContainer()); for (EdmEntityType entityType : result.getEdm().getSchemas().get(0).getEntityTypes()) { for (String navigationPropertyName : entityType.getNavigationPropertyNames()) { EdmNavigationProperty navigationProperty = (EdmNavigationProperty) entityType .getProperty(navigationPropertyName); if(entitySet.getName().equals("Managers") && navigationProperty.getName().equals("nm_Employees")){ assertNotNull(entitySet.getRelatedEntitySet(navigationProperty)); } } } } } } }
Example #8
Source File: CMODataAbapClient.java From devops-cm-client with Apache License 2.0 | 6 votes |
public Transport createTransport(Map<String, Object> transport) throws IOException, URISyntaxException, ODataException, UnexpectedHttpResponseException { try (CloseableHttpClient client = clientFactory.createClient()) { HttpPost post = requestBuilder.createTransport(); post.setHeader("x-csrf-token", getCSRFToken()); EdmEntityContainer entityContainer = getEntityDataModel().getDefaultEntityContainer(); EdmEntitySet entitySet = entityContainer.getEntitySet(TransportRequestBuilder.getEntityKey()); URI rootUri = new URI(endpoint.toASCIIString() + "/"); EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(rootUri).build(); ODataResponse marshaller = null; try { marshaller = EntityProvider.writeEntry(post.getHeaders(HttpHeaders.CONTENT_TYPE)[0].getValue(), entitySet, transport, properties); post.setEntity(EntityBuilder.create().setStream(marshaller.getEntityAsStream()).build()); try(CloseableHttpResponse httpResponse = client.execute(post)) { hasStatusOrFail(httpResponse, SC_CREATED); return getTransport(httpResponse); } } finally { if(marshaller != null) marshaller.close(); } } }
Example #9
Source File: EdmFunctionImportImplProv.java From olingo-odata2 with Apache License 2.0 | 5 votes |
public EdmFunctionImportImplProv(final EdmImplProv edm, final FunctionImport functionImport, final EdmEntityContainer edmEntityContainer) throws EdmException { super(edm, functionImport.getName()); this.functionImport = functionImport; this.edmEntityContainer = edmEntityContainer; buildFunctionImportParametersInternal(); edmParameters = new HashMap<String, EdmParameter>(); }
Example #10
Source File: ODataJPAResponseBuilderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private EdmEntityContainer getLocalEdmEntityContainer() { EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class); EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true); try { EasyMock.expect(edmEntityContainer.getName()).andStubReturn("salesorderprocessingContainer"); } catch (EdmException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } EasyMock.replay(edmEntityContainer); return edmEntityContainer; }
Example #11
Source File: JPAProcessorImplTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private EdmEntityContainer getLocalEdmEntityContainer() { EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class); EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true); try { EasyMock.expect(edmEntityContainer.getName()).andStubReturn(SALESORDERPROCESSING_CONTAINER); } catch (EdmException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } EasyMock.replay(edmEntityContainer); return edmEntityContainer; }
Example #12
Source File: EdmMock.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private static EdmEntitySet createEntitySetMock(final EdmEntityContainer container, final String name, final EdmSimpleTypeKind kind, final String keyPropertyId) throws EdmException { final EdmEntityType entityType = createEntityTypeMock(name.substring(0, name.length() - 1), kind, keyPropertyId); EdmEntitySet entitySet = mock(EdmEntitySet.class); when(entitySet.getName()).thenReturn(name); when(entitySet.getEntityType()).thenReturn(entityType); when(entitySet.getEntityContainer()).thenReturn(container); when(container.getEntitySet(name)).thenReturn(entitySet); return entitySet; }
Example #13
Source File: EdmMockUtilV2.java From olingo-odata2 with Apache License 2.0 | 5 votes |
public static EdmEntityContainer mockEdmEntityContainer(final String entityName) throws EdmException { EdmEntityContainer entityContainer = EasyMock.createMock(EdmEntityContainer.class); entityContainer = EasyMock.createMock(EdmEntityContainer.class); EasyMock.expect(entityContainer.getEntitySet(JPATypeMock.ENTITY_NAME)).andReturn( mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false)); EasyMock.expect(entityContainer.getFunctionImport(JPATypeMock.ENTITY_NAME)).andReturn(null); EasyMock.expect(entityContainer.getEntitySet("JPATypeMockInvalid")).andReturn(null); EasyMock.expect(entityContainer.getFunctionImport("JPATypeMockInvalid")).andReturn(null); EasyMock.replay(entityContainer); return entityContainer; }
Example #14
Source File: FunctionImportJsonTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private EdmEntityContainer getEntityContainer() throws Exception { final HttpResponse response = callUri("$metadata"); final EdmEntityContainer entityContainer = EntityProvider.readMetadata(response.getEntity().getContent(), false) .getDefaultEntityContainer(); getBody(response); return entityContainer; }
Example #15
Source File: EdmImpl.java From olingo-odata2 with Apache License 2.0 | 5 votes |
public EdmImpl(final EdmServiceMetadata edmServiceMetadata) { edmEntityContainers = new HashMap<String, EdmEntityContainer>(); edmEntityTypes = new HashMap<FullQualifiedName, EdmEntityType>(); edmComplexTypes = new HashMap<FullQualifiedName, EdmComplexType>(); edmAssociations = new HashMap<FullQualifiedName, EdmAssociation>(); this.edmServiceMetadata = edmServiceMetadata; }
Example #16
Source File: UriParserImpl.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private void handleNormalInitialSegment() throws UriSyntaxException, UriNotMatchingException, EdmException { final Matcher matcher = INITIAL_SEGMENT_PATTERN.matcher(currentPathSegment); if (!matcher.matches()) { throw new UriNotMatchingException(UriNotMatchingException.MATCHPROBLEM.addContent(currentPathSegment)); } final String entityContainerName = percentDecode(matcher.group(1)); final String segmentName = percentDecode(matcher.group(2)); final String keyPredicate = matcher.group(3); final String emptyParentheses = matcher.group(4); final EdmEntityContainer entityContainer = entityContainerName == null ? edm.getDefaultEntityContainer() : edm.getEntityContainer(entityContainerName); if (entityContainer == null) { throw new UriNotMatchingException(UriNotMatchingException.CONTAINERNOTFOUND.addContent(entityContainerName)); } uriResult.setEntityContainer(entityContainer); final EdmEntitySet entitySet = entityContainer.getEntitySet(segmentName); if (entitySet != null) { uriResult.setStartEntitySet(entitySet); handleEntitySet(entitySet, keyPredicate); } else { final EdmFunctionImport functionImport = entityContainer.getFunctionImport(segmentName); if (functionImport == null) { throw new UriNotMatchingException(UriNotMatchingException.NOTFOUND.addContent(segmentName)); } uriResult.setFunctionImport(functionImport); handleFunctionImport(functionImport, emptyParentheses, keyPredicate); } }
Example #17
Source File: EdmImplProv.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override protected EdmEntityContainer createEntityContainer(final String name) throws ODataException { EntityContainerInfo enitityContainerInfo = edmProvider.getEntityContainerInfo(name); if (enitityContainerInfo == null) { return null; } return new EdmEntityContainerImplProv(this, enitityContainerInfo); }
Example #18
Source File: EntityTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private UriInfo mockUriResult(final String entitySetName, final String keyName, final String keyValue) throws EdmException { EdmProperty keyProperty = mock(EdmProperty.class); when(keyProperty.getName()).thenReturn(keyName); when(keyProperty.getType()).thenReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()); when(keyProperty.isSimple()).thenReturn(true); EdmMapping mapping = mock(EdmMapping.class); when(mapping.getInternalName()).thenReturn("getId"); when(keyProperty.getMapping()).thenReturn(mapping); KeyPredicate key = mock(KeyPredicate.class); when(key.getProperty()).thenReturn(keyProperty); when(key.getLiteral()).thenReturn(keyValue); ArrayList<KeyPredicate> keys = new ArrayList<KeyPredicate>(); keys.add(key); EdmEntityType entityType = mock(EdmEntityType.class); when(entityType.getName()).thenReturn(entitySetName); when(entityType.getProperty(keyProperty.getName())).thenReturn(keyProperty); when(entityType.getPropertyNames()).thenReturn(Arrays.asList(keyName)); EdmEntitySet entitySet = mock(EdmEntitySet.class); when(entitySet.getName()).thenReturn(entitySetName); when(entitySet.getEntityType()).thenReturn(entityType); EdmEntityContainer entityContainer = mock(EdmEntityContainer.class); when(entityContainer.isDefaultEntityContainer()).thenReturn(true); when(entitySet.getEntityContainer()).thenReturn(entityContainer); UriInfo uriResult = mock(UriInfo.class); when(uriResult.getStartEntitySet()).thenReturn(entitySet); when(uriResult.getTargetEntitySet()).thenReturn(entitySet); when(uriResult.getKeyPredicates()).thenReturn(keys); return uriResult; }
Example #19
Source File: AtomEntrySerializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private static EdmEntitySet createEntitySetMock(final EdmEntityContainer container, final String name, final EdmSimpleTypeKind kind, final String keyPropertyId) throws EdmException { final EdmEntityType entityType = createEntityTypeMock(name.substring(0, name.length() - 1), kind, keyPropertyId); EdmEntitySet entitySet = mock(EdmEntitySet.class); when(entitySet.getName()).thenReturn(name); when(entitySet.getEntityType()).thenReturn(entityType); when(entitySet.getEntityContainer()).thenReturn(container); when(container.getEntitySet(name)).thenReturn(entitySet); return entitySet; }
Example #20
Source File: Client.java From olingo-odata2 with Apache License 2.0 | 5 votes |
public ODataFeed readFeed(final String entityContainerName, final String entitySetName, final String contentType, final String query) throws IOException, ODataException, HttpException { EdmEntityContainer entityContainer = edm.getEntityContainer(entityContainerName); String relativeUri; if (entityContainer.isDefaultEntityContainer()) { relativeUri = entitySetName; } else { relativeUri = entityContainerName + "." + entitySetName; } InputStream content = (InputStream) connect(relativeUri, query, contentType, "GET").getContent(); return EntityProvider.readFeed(contentType, entityContainer.getEntitySet(entitySetName), content, EntityProviderReadProperties.init().build()); }
Example #21
Source File: EdmMock.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private static EdmFunctionImport createActionImportMock(final EdmEntityContainer container, final String name, final EdmType type, final EdmMultiplicity multiplicity) throws EdmException { EdmFunctionImport functionImport = mock(EdmFunctionImport.class); when(functionImport.getName()).thenReturn(name); when(functionImport.getReturnType()).thenReturn(null); when(functionImport.getHttpMethod()).thenReturn(ODataHttpMethod.GET.name()); when(container.getFunctionImport(name)).thenReturn(functionImport); return functionImport; }
Example #22
Source File: XmlMetadataDeserializer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private void validateAssociation() throws EntityProviderException, EdmException { for (Map.Entry<FullQualifiedName, EdmEntityContainer> container : containerMap.entrySet()) { for (EdmAssociationSet associationSet : container.getValue().getAssociationSets()) { FullQualifiedName association = new FullQualifiedName(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName()); if (associationsMap.containsKey(association)) { validateAssociationEnd(((EdmAssociationSetImpl) associationSet).getEnd1(), associationsMap.get(association)); validateAssociationEnd(((EdmAssociationSetImpl) associationSet).getEnd2(), associationsMap.get(association)); boolean end1 = false; boolean end2 = false; for (EdmEntitySet entitySet : container.getValue().getEntitySets()) { EdmAssociationSetEnd associationSetEnd1 = ((EdmAssociationSetImpl) associationSet).getEnd1(); if (entitySet.getName().equals(((EdmAssociationSetEndImpl) associationSetEnd1).getEntitySetName())) { end1 = true; } EdmAssociationSetEnd associationSetEnd2 = ((EdmAssociationSetImpl) associationSet).getEnd2(); if (entitySet.getName().equals(((EdmAssociationSetEndImpl) associationSetEnd2).getEntitySetName())) { end2 = true; } } if (!(end1 && end2)) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } else { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Invalid AssociationSet")); } } } }
Example #23
Source File: XmlMetadataDeserializer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private void validateEntitySet() throws EntityProviderException, EdmException { for (Map.Entry<FullQualifiedName, EdmEntityContainer> container : containerMap.entrySet()) { for (EdmEntitySet entitySet : container.getValue().getEntitySets()) { FullQualifiedName entityType = extractFQNameFromEntityType(entitySet.getEntityType()); if (!(entityTypesMap.containsKey(entityType))) { validateEntityTypeWithAlias(entityType); } } } }
Example #24
Source File: EdmImpl.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public EdmEntityContainer getEntityContainer(final String name) throws EdmException { for (Entry<FullQualifiedName, EdmEntityContainer> entry : edmEntityContainers.entrySet()) { if (entry.getKey().getName().equals(name)) { return entry.getValue(); } } return null; }
Example #25
Source File: EdmEntityImplTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void entityContainerTest() throws EdmException { EdmEntityContainerImpl cont = new EdmEntityContainerImpl(edm); cont.setAnnotations(annotations); cont.setDefaultContainer(true); cont.setDocumentation(documentation); cont.setEdm(edm); cont.setEdmAssociationSets(new ArrayList<EdmAssociationSet>()); List<EdmEntitySet> entitySets = new ArrayList<EdmEntitySet>(); cont.setEdmEntitySets(entitySets); cont.setEdmExtendedEntityContainer(new EdmEntityContainerImpl(edm)); cont.setEdmFunctionImports(new ArrayList<EdmFunctionImport>()); cont.setEntityContainerHierachy(new ArrayList<EdmEntityContainer>()); cont.setExtendz(name); cont.setName(name); assertNotNull(cont); EdmEntitySet entitySet = new EdmEntitySetImpl(); ((EdmEntitySetImpl) entitySet).setName(name); EdmNavigationProperty nav = new EdmNavigationPropertyImpl(); ((EdmNavigationPropertyImpl) nav).setEdm(edm); ((EdmNavigationPropertyImpl) nav).setRelationshipName(entityTypeName); entitySets.add(entitySet); assertNotNull(cont.getAssociationSets()); assertNotNull(cont.getDocumentation()); assertNotNull(cont.getEdm()); assertNotNull(cont.getEdmAssociationSets()); assertNotNull(cont.getEdmEntitySets()); assertNotNull(cont.getEdmExtendedEntityContainer()); assertNotNull(cont.getEdmFunctionImports()); assertNotNull(cont.getEntitySet(name)); assertNotNull(cont.getEntitySets()); assertNotNull(cont.getExtendz()); assertNull(cont.getFunctionImport(name)); assertNotNull(cont.getName()); }
Example #26
Source File: XmlMetadataDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testEntitySet() throws XMLStreamException, EntityProviderException, EdmException, UnsupportedEncodingException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); InputStream reader = createStreamReader(xmWithEntityContainer); EdmDataServices result = parser.readMetadata(reader, true); assertEquals("Container1", result.getEdm().getEntityContainer("Container1").getName()); for (EdmSchema schema : result.getEdm().getSchemas()) { for (EdmEntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); for (EdmEntitySet entitySet : container.getEntitySets()) { assertEquals("Employees", entitySet.getName()); assertEquals("Employee", entitySet.getEntityType().getName()); assertEquals(NAMESPACE, entitySet.getEntityType().getNamespace()); } } } }
Example #27
Source File: XmlMetadataDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testAssociationSet() throws XMLStreamException, EntityProviderException, EdmException, UnsupportedEncodingException { XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); InputStream reader = createStreamReader(xmlWithAssociation); EdmDataServices result = parser.readMetadata(reader, true); for (EdmSchema schema : result.getEdm().getSchemas()) { for (EdmEntityContainer container : schema.getEntityContainers()) { assertEquals(NAMESPACE2, schema.getNamespace()); assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); assertNotNull(result.getEdm().getDefaultEntityContainer()); assertEquals("Container1", result.getEdm().getDefaultEntityContainer().getName()); for (EdmAssociationSet assocSet : container.getAssociationSets()) { assertEquals(ASSOCIATION, assocSet.getName()); assertEquals(ASSOCIATION, assocSet.getAssociation().getName()); assertEquals(NAMESPACE, assocSet.getAssociation().getNamespace()); EdmAssociationSetEnd end; if ("Employees".equals(assocSet.getEnd("r_Employees").getEntitySet().getName())) { end = assocSet.getEnd("r_Employees"); } else { end = assocSet.getEnd("r_Manager"); } assertEquals("r_Employees", end.getRole()); } } } }
Example #28
Source File: XmlMetadataDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testEntityTypeInOtherSchema() throws XMLStreamException, EntityProviderException, EdmException, UnsupportedEncodingException { final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Photos\" EntityType=\"" + NAMESPACE2 + ".Photo\"/>" + "</EntityContainer>" + "</Schema>" + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Photo\">" + "<Key><PropertyRef Name=\"Id\"/></Key>" + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\"/>" + "</EntityType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); InputStream reader = createStreamReader(xmWithEntityContainer); EdmDataServices result = parser.readMetadata(reader, true); assertEquals("2.0", result.getDataServiceVersion()); for (EdmSchema schema : result.getEdm().getSchemas()) { for (EdmEntityContainer container : schema.getEntityContainers()) { assertEquals("Container1", container.getName()); for (EdmEntitySet entitySet : container.getEntitySets()) { assertEquals(NAMESPACE2, entitySet.getEntityType().getNamespace()); assertEquals("Photo", entitySet.getEntityType().getName()); } } } }
Example #29
Source File: Client.java From olingo-odata2 with Apache License 2.0 | 5 votes |
public ODataDeltaFeed readDeltaFeed(final String entityContainerName, final String entitySetName, final String contentType, final String deltaLink) throws IOException, ODataException, HttpException { EdmEntityContainer entityContainer = edm.getEntityContainer(entityContainerName); InputStream content = (InputStream) connect(deltaLink, contentType, "GET").getContent(); return EntityProvider.readDeltaFeed(contentType, entityContainer.getEntitySet(entitySetName), content, EntityProviderReadProperties.init().build()); }
Example #30
Source File: EdmImpl.java From olingo-odata2 with Apache License 2.0 | 4 votes |
public Map<FullQualifiedName, EdmEntityContainer> getEdmEntityContainers() { return edmEntityContainers; }