@Override public List<String> getKeyPropertyNames() throws EdmException { if (edmKeyPropertyNames == null) { if (edmBaseType != null) { return ((EdmEntityType) edmBaseType).getKeyPropertyNames(); } edmKeyPropertyNames = new ArrayList<String>(); if (entityType.getKey() != null) { for (final PropertyRef keyProperty : entityType.getKey().getKeys()) { edmKeyPropertyNames.add(keyProperty.getName()); } } else { // Entity Type does not define a key throw new EdmException(EdmException.COMMON); } } return edmKeyPropertyNames; }
@Override public List<String> getKeyPropertyNames() throws EdmException { if (edmKeyPropertyNames == null) { if (edmBaseType != null) { return ((EdmEntityType) edmBaseType).getKeyPropertyNames(); } edmKeyPropertyNames = new ArrayList<String>(); if (entityType.getKey() != null) { for (final PropertyRef keyProperty : entityType.getKey().getKeys()) { edmKeyPropertyNames.add(keyProperty.getName()); } } else { // Entity Type does not define a key throw new EdmException(EdmException.COMMON); } } return edmKeyPropertyNames; }
@Override public List<String> getKeyPropertyNames() throws EdmException { if (edmKeyPropertyNames == null) { if (edmBaseType != null) { return ((EdmEntityType) edmBaseType).getKeyPropertyNames(); } edmKeyPropertyNames = new ArrayList<String>(); if (entityType.getKey() != null) { for (final PropertyRef keyProperty : entityType.getKey().getKeys()) { edmKeyPropertyNames.add(keyProperty.getName()); } } else { // Entity Type does not define a key throw new EdmException(EdmException.COMMON); } } return edmKeyPropertyNames; }
private EntityType fetchLastBaseType (FullQualifiedName baseTypeFQName, Map<FullQualifiedName, EntityType> entityTypesMap) throws EntityProviderException { EntityType baseEntityType = null ; while(baseTypeFQName!=null){ baseEntityType = entityTypesMap.get(baseTypeFQName); if(baseEntityType.getKey()!=null){ break; }else if(baseEntityType !=null && baseEntityType.getBaseType() !=null){ baseTypeFQName = baseEntityType.getBaseType(); }else if(baseEntityType.getBaseType() == null){ break; } } return baseEntityType; }
private EntityType fetchLastBaseType (FullQualifiedName baseTypeFQName, Map<FullQualifiedName, EntityType> entityTypesMap) throws EntityProviderException { EntityType baseEntityType = null ; while(baseTypeFQName!=null){ baseEntityType = entityTypesMap.get(baseTypeFQName); if(baseEntityType.getKey()!=null){ break; }else if(baseEntityType !=null && baseEntityType.getBaseType() !=null){ baseTypeFQName = baseEntityType.getBaseType(); }else if(baseEntityType.getBaseType() == null){ break; } } return baseEntityType; }
private void validateEntityTypes() throws EntityProviderException { for (Map.Entry<FullQualifiedName, EntityType> entityTypes : entityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType(); EntityType baseEntityType; if (!entityTypesMap.containsKey(baseTypeFQName)) { FullQualifiedName fqName = validateEntityTypeWithAlias(baseTypeFQName); baseEntityType = entityTypesMap.get(fqName); } else { baseEntityType = entityTypesMap.get(baseTypeFQName); } if (baseEntityType.getKey() == null) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Missing key for EntityType " + baseEntityType.getName())); } } else if (entityType.getKey() == null) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Missing key for EntityType " + entityType.getName())); } } } }
private void validateEntityTypes() throws EntityProviderException { for (Map.Entry<FullQualifiedName, EntityType> entityTypes : entityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType(); EntityType baseEntityType; if (!entityTypesMap.containsKey(baseTypeFQName)) { FullQualifiedName fqName = validateEntityTypeWithAlias(baseTypeFQName); baseEntityType = entityTypesMap.get(fqName); } else { baseEntityType = fetchLastBaseType(baseTypeFQName,entityTypesMap); } if (baseEntityType != null && baseEntityType.getKey() == null) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Missing key for EntityType " + baseEntityType.getName())); } } else if (entityType.getKey() == null) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Missing key for EntityType " + entityType.getName())); } } } }
private void validateEntityTypes() throws EntityProviderException { for (Map.Entry<FullQualifiedName, EntityType> entityTypes : entityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType(); EntityType baseEntityType; if (!entityTypesMap.containsKey(baseTypeFQName)) { FullQualifiedName fqName = validateEntityTypeWithAlias(baseTypeFQName); baseEntityType = entityTypesMap.get(fqName); } else { baseEntityType = fetchLastBaseType(baseTypeFQName,entityTypesMap); } if (baseEntityType != null && baseEntityType.getKey() == null) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Missing key for EntityType " + baseEntityType.getName())); } } else if (entityType.getKey() == null) { throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT .addContent("Missing key for EntityType " + entityType.getName())); } } } }
Key key = entityType.getKey(); if (key != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ENTITY_TYPE_KEY); Collection<PropertyRef> propertyRefs = entityType.getKey().getKeys(); for (PropertyRef propertyRef : propertyRefs) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_PROPERTY_REF);
Key key = entityType.getKey(); if (key != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ENTITY_TYPE_KEY); Collection<PropertyRef> propertyRefs = entityType.getKey().getKeys(); for (PropertyRef propertyRef : propertyRefs) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_PROPERTY_REF);
Key key = entityType.getKey(); if (key != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_ENTITY_TYPE_KEY); Collection<PropertyRef> propertyRefs = entityType.getKey().getKeys(); for (PropertyRef propertyRef : propertyRefs) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_PROPERTY_REF);
private EntityType clone(EntityType type) { if (type == null) { return null; } EntityType newType = new EntityType(); newType.setAbstract(type.isAbstract()); newType.setAnnotationAttributes(type.getAnnotationAttributes()); newType.setAnnotationElements(type.getAnnotationElements()); newType.setBaseType(type.getBaseType()); newType.setCustomizableFeedMappings(type.getCustomizableFeedMappings()); newType.setDocumentation(type.getDocumentation()); newType.setHasStream(type.isHasStream()); newType.setKey(type.getKey()); newType.setMapping(type.getMapping()); newType.setName(type.getName()); newType.setNavigationProperties(cloneNavigationProperties(type .getNavigationProperties())); newType.setProperties(cloneProperties(type.getProperties())); return newType; }