@Override public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException { for (Schema schema : dataServices.getSchemas()) { if (schema.getNamespace().equals(edmFQName.getNamespace())) { for (ComplexType complexType : schema.getComplexTypes()) { if (complexType.getName().equals(edmFQName.getName())) { return complexType; } } } } return null; }
@Override public EntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException { for (Schema schema : dataServices.getSchemas()) { if (schema.getNamespace().equals(edmFQName.getNamespace())) { for (EntityType entityType : schema.getEntityTypes()) { if (entityType.getName().equals(edmFQName.getName())) { return entityType; } } } } return null; }
@Override public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException { for (Schema schema : dataServices.getSchemas()) { if (schema.getNamespace().equals(edmFQName.getNamespace())) { for (Association association : schema.getAssociations()) { if (association.getName().equals(edmFQName.getName())) { return association; } } } } return null; }
public Schema build() { Schema s = new Schema(); s.setUsings(usings); s.setEntityTypes(entityTypes); s.setComplexTypes(complexTypes); s.setAssociations(new ArrayList<Association>(name2Associations.values())); s.setEntityContainers(entityContainers); s.setAnnotationAttributes(annotationAttributes); s.setAnnotationElements(annotationElements); s.setNamespace(namespace); return s; } }
@Override public List<AliasInfo> getAliasInfos() { List<AliasInfo> aliasInfos = new ArrayList<AliasInfo>(); for (Schema schema : dataServices.getSchemas()) { if (schema.getAlias() != null) { aliasInfos.add(new AliasInfo().setAlias(schema.getAlias()).setNamespace(schema.getNamespace())); } } return aliasInfos; } }
Schema schema = new Schema(); List<Using> usings = new ArrayList<Using>(); List<ComplexType> complexTypes = new ArrayList<ComplexType>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); schema.setNamespace(reader.getAttributeValue(null, XmlMetadataConstants.EDM_SCHEMA_NAMESPACE)); inscopeMap.put(schema.getNamespace(), new HashSet<String>()); schema.setAlias(reader.getAttributeValue(null, XmlMetadataConstants.EDM_SCHEMA_ALIAS)); schema.setAnnotationAttributes(readAnnotationAttribute(reader)); currentNamespace = schema.getNamespace(); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) currentHandledStartTagName = reader.getLocalName(); if (XmlMetadataConstants.EDM_USING.equals(currentHandledStartTagName)) { usings.add(readUsing(reader, schema.getNamespace())); } else if (XmlMetadataConstants.EDM_ENTITY_TYPE.equals(currentHandledStartTagName)) { entityTypes.add(readEntityType(reader)); if (schema.getAlias() != null) { aliasNamespaceMap.put(schema.getAlias(), schema.getNamespace()); schema.setAnnotationElements(annotationElements); schema.setUsings(usings).setEntityTypes(entityTypes).setComplexTypes(complexTypes).setAssociations(associations) .setEntityContainers(entityContainers); return schema;
for (Schema schema : schemas) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_SCHEMA); if (schema.getAlias() != null) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_SCHEMA_ALIAS, schema.getAlias()); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_SCHEMA_NAMESPACE, schema.getNamespace()); xmlStreamWriter.writeDefaultNamespace(defaultNamespace); writeAnnotationAttributes(schema.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); Collection<Using> usings = schema.getUsings(); if (usings != null) { for (Using using : usings) { Collection<EntityType> entityTypes = schema.getEntityTypes(); if (entityTypes != null) { for (EntityType entityType : entityTypes) { Collection<ComplexType> complexTypes = schema.getComplexTypes(); if (complexTypes != null) { for (ComplexType complexType : complexTypes) { Collection<Association> associations = schema.getAssociations(); if (associations != null) { for (Association association : associations) { Collection<EntityContainer> entityContainers = schema.getEntityContainers(); if (entityContainers != null) { for (EntityContainer entityContainer : entityContainers) {
@Override public void build() throws ODataJPAModelException, ODataJPARuntimeException { schema = new Schema(); JPAEdmNameBuilder.build(JPAEdmSchema.this); schema.setEntityContainers(entityContainerView.getConsistentEdmEntityContainerList()); JPAEdmEntityTypeView entityTypeView = entitySetView.getJPAEdmEntityTypeView(); if (entityTypeView.isConsistent() && !entityTypeView.getConsistentEdmEntityTypes().isEmpty()) { schema.setEntityTypes(entityTypeView.getConsistentEdmEntityTypes()); schema.setComplexTypes(existingComplexTypes); schema.setAssociations(consistentAssociationList); for (Association association : consistentAssociationList) { existingAssociationList.add(association.getName());
List<ComplexType> complexTypes = schema.getComplexTypes(); if (complexTypes != null) { for (ComplexType type : complexTypes) { List<EntityType> entityTypes = schema.getEntityTypes(); if (entityTypes != null) { for (EntityType type : entityTypes) { List<Association> associations = schema.getAssociations(); if (associations != null) { for (Association association : associations) { List<EntityContainer> containers = schema.getEntityContainers(); if (containers == null || containers.size() < 1) { return;
private static String getAssociationKey(Schema schema, Association association) { return schema.getNamespace() + "~" + association.getName(); }
private void includeAssociation(Schema targetSchema, IServiceInfo service, Association sourceAssociation) throws ODataException { List<Association> associations = targetSchema.getAssociations(); if (associations != null) { for (Association type : associations) { if (type.getName().equals(sourceAssociation.getName())) { throw new ODataException("association " + sourceAssociation.getName() + " already defined"); } } } else { associations = new ArrayList<Association>(); } Association newAssociation = clone(sourceAssociation); newAssociation.getEnd1().setType( new FullQualifiedName(targetSchema.getNamespace(), newAssociation.getEnd1().getType().getName())); newAssociation.getEnd2().setType( new FullQualifiedName(targetSchema.getNamespace(), newAssociation.getEnd2().getType().getName())); associations.add(newAssociation); targetSchema.setAssociations(associations); }
private void includeComplexType(Schema targetSchema, IServiceInfo service, ComplexType sourceType) throws ODataException { List<ComplexType> types = targetSchema.getComplexTypes(); if (types != null) { for (ComplexType type : types) { if (type.getName().equals(sourceType.getName())) { throw new ODataException("complex type " + sourceType.getName() + " already defined"); } } } else { types = new ArrayList<ComplexType>(); } ComplexType newType = clone(sourceType); if (newType.getProperties() != null) { for (Property property : newType.getProperties()) { if (property instanceof ComplexProperty) { ((ComplexProperty) property).setType(new FullQualifiedName( targetSchema.getNamespace(), ((ComplexProperty) property).getType().getName())); } } } types.add(newType); targetSchema.setComplexTypes(types); }
private void includeEntityType(Schema targetSchema, IServiceInfo service, EntityType sourceType) throws ODataException { List<EntityType> types = targetSchema.getEntityTypes(); if (types != null) { for (EntityType type : types) { .getNavigationProperties()) { property.setRelationship(new FullQualifiedName(targetSchema .getNamespace(), property.getRelationship().getName())); if (property instanceof ComplexProperty) { ((ComplexProperty) property).setType(new FullQualifiedName( targetSchema.getNamespace(), ((ComplexProperty) property).getType().getName())); targetSchema.setEntityTypes(types);
private EntityType getEntityType(Schema schema, String entityTypeName) throws ODataException { List<EntityType> types = schema.getEntityTypes(); if (types == null) { return null; } for (EntityType type : types) { if (type.getName().equals(entityTypeName)) { return type; } } return null; }
List<Schema> schemaList = ( ((EdmProviderAccessor) context.getService().getEntityDataModel()).getEdmProvider()).getSchemas(); Schema schema = schemaList.get(0); List<EntityType> eTypes = schema.getEntityTypes(); List<ComplexType> eCompTypes = schema.getComplexTypes(); String entityName = uriInfo.getTargetEntitySet().getEntityType().getName(); String[] propNameArr = new String[propNameList.size()];
@Override public String getNamespace() throws EdmException{ try { if (namespace == null) { List<Schema> schemas; schemas = edm.edmProvider.getSchemas(); for (Schema schema : schemas) { List<EntityContainer> containers = schema.getEntityContainers(); for (EntityContainer container : containers) { if (container.getName().equals(entityContainerInfo.getName())) { this.namespace = schema.getNamespace(); break; } } if (namespace != null) { break; } } } } catch (ODataException e) { throw new EdmException(EdmException.PROVIDERPROBLEM, e); } return namespace; } }
@Override public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException { Schema schema = namespace2Schema.get(edmFQName.getNamespace()); if (schema != null) { List<ComplexType> complexTypes = schema.getComplexTypes(); for (ComplexType complexType : complexTypes) { if (complexType.getName().equals(edmFQName.getName())) { return complexType; } } } return null; }
@Override public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException { Schema schema = namespace2Schema.get(edmFQName.getNamespace()); if (schema != null) { List<Association> associations = schema.getAssociations(); for (Association association : associations) { if (association.getName().equals(edmFQName.getName())) { return association; } } } return null; }
public static void build(final JPAEdmSchemaView view) throws ODataJPAModelException { view.getEdmSchema().setNamespace(buildNamespace(view)); }
Schema schema = new Schema(); List<Using> usings = new ArrayList<Using>(); List<ComplexType> complexTypes = new ArrayList<ComplexType>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); schema.setNamespace(reader.getAttributeValue(null, XmlMetadataConstants.EDM_SCHEMA_NAMESPACE)); inscopeMap.put(schema.getNamespace(), new HashSet<String>()); schema.setAlias(reader.getAttributeValue(null, XmlMetadataConstants.EDM_SCHEMA_ALIAS)); schema.setAnnotationAttributes(readAnnotationAttribute(reader)); currentNamespace = schema.getNamespace(); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) currentHandledStartTagName = reader.getLocalName(); if (XmlMetadataConstants.EDM_USING.equals(currentHandledStartTagName)) { usings.add(readUsing(reader, schema.getNamespace())); } else if (XmlMetadataConstants.EDM_ENTITY_TYPE.equals(currentHandledStartTagName)) { entityTypes.add(readEntityType(reader)); if (schema.getAlias() != null) { aliasNamespaceMap.put(schema.getAlias(), schema.getNamespace()); schema.setAnnotationElements(annotationElements); schema.setUsings(usings).setEntityTypes(entityTypes).setComplexTypes(complexTypes).setAssociations(associations) .setEntityContainers(entityContainers); return schema;