@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()); } } } }
public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } } }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  EdmDataServices readMetadata(final InputStream content, final boolean validate); }
XmlMetadataDeserializer { public EdmDataServices readMetadata(final InputStream content, final boolean validate) throws EntityProviderException, EdmException { try { initialize(); EdmDataServices dataServices = new EdmDataServices(); List<EdmSchema> schemas = new ArrayList<EdmSchema>(); EdmImpl edm = new EdmImpl(); XMLStreamReader reader = XmlHelper.createStreamReader(content); while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_EDMX_2007_06.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); if (XmlMetadataConstants.EDM_SCHEMA.equals(reader.getLocalName())) { edmNamespace = reader.getNamespaceURI(); checkEdmNamespace(); schemas.add(readSchema(reader, edm)); } else if (XmlMetadataConstants.EDM_DATA_SERVICES.equals(reader .getLocalName())) { dataServices.setDataServiceVersion(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "DataServiceVersion")); } } } if (!reader.isEndElement() || !XmlMetadataConstants.EDMX_TAG.equals(reader.getLocalName())) { throw new EntityProviderException(EntityProviderException.MISSING_TAG .addContent(XmlMetadataConstants.EDMX_TAG)); } setBaseTypeForEntityType(); setBaseTypeForComplexType(); setDetailsForEntitySet(); setAssociationSetForNavigations(); if (validate) { validate(); } edm.setEdmSchemas(schemas); dataServices.setClientEdm(edm); reader.close(); return dataServices; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  EdmDataServices readMetadata(final InputStream content, final boolean validate);  }