@Test public void testMultiplebaseTypeOrderChange() throws Exception { final String metadata = "" + "<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=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + " <EntityType Name= \"ConfigParameter\" BaseType= \"RefScenario2.Parameter\" >" + " <Property Name=\"ConfigName\" Type=\"Edm.String\" Nullable=\"false\" />" + " </EntityType>" + " <EntityType Name= \"DataConfigParameter\" BaseType= \"RefScenario2.ConfigParameter\" >" + " <Key> " + " <PropertyRef Name=\"Name\" />" + " </Key>" + " <Property Name=\"Name\" Type=\"Edm.String\" Nullable=\"false\" />" + " </EntityType>" + " <EntityType Name= \"Parameter\">" + " <Key> " + " <PropertyRef Name=\"Id\" />" + " </Key>" + " <Property Name=\"Id\" Type=\"Edm.Int16\" Nullable=\"false\" />" + " </EntityType>" + " <EntityType Name= \"StringDataConfigParameter\" BaseType= \"RefScenario2.DataConfigParameter\" />" + " <EntityType Name= \"AnotherDataConfigParameter\" BaseType= \"RefScenario2.DataConfigParameter\" />" + " </Schema>" + " </edmx:DataServices>" + "</edmx:Edmx>"; XmlMetadataDeserializer parser = new XmlMetadataDeserializer(); InputStream reader = createStreamReader(metadata); EdmDataServices result = parser.readMetadata(reader, true); assertEquals(1, result.getEdm().getSchemas().size()); List<EdmEntityType> entityTypes = result.getEdm().getSchemas().get(0).getEntityTypes(); assertEquals(5, entityTypes.size()); for(EdmEntityType entityType:entityTypes){ if(entityType.getName().equalsIgnoreCase("StringDataConfigParameter")){ assertEquals(3, entityType.getPropertyNames().size()); assertEquals("Name", entityType.getPropertyNames().get(0)); assertEquals("ConfigName", entityType.getPropertyNames().get(1)); assertEquals("Id", entityType.getPropertyNames().get(2)); }else if(entityType.getName().equalsIgnoreCase("DataConfigParameter")){ assertEquals(3, entityType.getPropertyNames().size()); assertEquals("Name", entityType.getPropertyNames().get(0)); assertEquals("ConfigName", entityType.getPropertyNames().get(1)); assertEquals("Id", entityType.getPropertyNames().get(2)); }else if(entityType.getName().equalsIgnoreCase("ConfigParameter")){ assertEquals(2, entityType.getPropertyNames().size()); assertEquals("ConfigName", entityType.getPropertyNames().get(0)); assertEquals("Id", entityType.getPropertyNames().get(1)); }else if(entityType.getName().equalsIgnoreCase("Parameter")){ assertEquals(1, entityType.getPropertyNames().size()); assertEquals("Id", entityType.getPropertyNames().get(0)); }else if(entityType.getName().equalsIgnoreCase("AnotherDataConfigParameter")){ assertEquals(3, entityType.getPropertyNames().size()); assertEquals("Name", entityType.getPropertyNames().get(0)); assertEquals("ConfigName", entityType.getPropertyNames().get(1)); assertEquals("Id", entityType.getPropertyNames().get(2)); } } }
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);  }