Java Code Examples for org.apache.olingo.odata2.api.edm.provider.EntityContainer#getAssociationSets()
The following examples show how to use
org.apache.olingo.odata2.api.edm.provider.EntityContainer#getAssociationSets() .
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: AnnotationEdmProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { EntityContainer container = name2Container.get(entityContainer); if (container != null) { List<AssociationSet> associations = container.getAssociationSets(); for (AssociationSet associationSet : associations) { if (associationSet.getAssociation().equals(association)) { final AssociationSetEnd endOne = associationSet.getEnd1(); if (endOne.getRole().equals(sourceEntitySetRole) && endOne.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } final AssociationSetEnd endTwo = associationSet.getEnd2(); if (endTwo.getRole().equals(sourceEntitySetRole) && endTwo.getEntitySet().equals(sourceEntitySetName)) { return associationSet; } } } } return null; }
Example 2
Source File: EdmEntityContainerImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public List<EdmAssociationSet> getAssociationSets() throws EdmException { try { List<EntityContainer> containers = getEntityContainerHierachy(); List<EdmAssociationSet> edmAssociationSetsList = new ArrayList<EdmAssociationSet>(); for (EntityContainer entityContainer : containers) { List<AssociationSet> associationSets = entityContainer.getAssociationSets(); for (AssociationSet associationSet : associationSets) { EdmAssociationSet eas = createAssociationSet(associationSet); edmAssociationSetsList.add(eas); } } return edmAssociationSetsList; } catch (ODataException e) { throw new EdmException(EdmException.PROVIDERPROBLEM, e); } }
Example 3
Source File: EdmxProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association, final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException { for (Schema schema : dataServices.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { if (container.getName().equals(entityContainer)) { for (AssociationSet associationSet : container.getAssociationSets()) { if (associationSet.getAssociation().equals(association) && ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1() .getRole().equals(sourceEntitySetRole)) || (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2() .getRole().equals(sourceEntitySetRole)))) { return associationSet; } } } } } return null; }
Example 4
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testAssociationSet() throws XMLStreamException, EntityProviderException { XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmlWithAssociation); DataServices result = parser.readMetadata(reader, true); for (Schema schema : result.getSchemas()) { for (EntityContainer container : schema.getEntityContainers()) { assertEquals(NAMESPACE2, schema.getNamespace()); assertEquals("Container1", container.getName()); assertEquals(Boolean.TRUE, container.isDefaultEntityContainer()); for (AssociationSet assocSet : container.getAssociationSets()) { assertEquals(ASSOCIATION, assocSet.getName()); assertEquals(ASSOCIATION, assocSet.getAssociation().getName()); assertEquals(NAMESPACE, assocSet.getAssociation().getNamespace()); AssociationSetEnd end; if ("Employees".equals(assocSet.getEnd1().getEntitySet())) { end = assocSet.getEnd1(); } else { end = assocSet.getEnd2(); } assertEquals("r_Employees", end.getRole()); } } } }