/** * Set the derived edm entity type. * @param derivedType the derived edm entity type * @return Builder */ public Builder derived(final EdmEntityType derivedType) { contextURL.derivedEntity = derivedType.getFullQualifiedName().getFullQualifiedNameAsString(); return this; }
/** * Set the derived edm entity type. * @param derivedType the derived edm entity type * @return Builder */ public Builder derived(final EdmEntityType derivedType) { contextURL.derivedEntity = derivedType.getFullQualifiedName().getFullQualifiedNameAsString(); return this; }
/** * This method validates Edm Entity types. * Looks for correct namespace aliases and correct base types */ private void validateEdmEntityTypes() { for (Map.Entry<FullQualifiedName, EdmEntityType> entityTypes : edmEntityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EdmEntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType().getFullQualifiedName(); EdmEntityType baseEntityType = edmEntityTypesMap.get(baseTypeFQName); if (baseEntityType != null && baseEntityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + baseEntityType.getName()); } } else if (entityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + entityType.getName()); } } } }
/** * This method validates Edm Entity types. * Looks for correct namespace aliases and correct base types */ private void validateEdmEntityTypes() { for (Map.Entry<FullQualifiedName, EdmEntityType> entityTypes : edmEntityTypesMap.entrySet()) { if (entityTypes.getValue() != null && entityTypes.getKey() != null) { EdmEntityType entityType = entityTypes.getValue(); if (entityType.getBaseType() != null) { FullQualifiedName baseTypeFQName = entityType.getBaseType().getFullQualifiedName(); EdmEntityType baseEntityType = edmEntityTypesMap.get(baseTypeFQName); if (baseEntityType != null && baseEntityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + baseEntityType.getName()); } } else if (entityType.getKeyPredicateNames().isEmpty()) { throw new RuntimeException("Missing key for EntityType " + entityType.getName()); } } } }
static Table findTable(EdmEntityType entityType, MetadataStore store) { FullQualifiedName fqn = entityType.getFullQualifiedName(); // remove the vdb name String withoutVDB = fqn.getNamespace().substring(fqn.getNamespace().lastIndexOf('.')+1); Schema schema = store.getSchema(withoutVDB); return schema.getTable(entityType.getName()); }
@Override public boolean hasETag(final EdmBindingTarget entitySetOrSingleton) { try { return getEntity(entitySetOrSingleton.getEntityType().getFullQualifiedName()).hasEtag(); } catch (ODataJPAModelException e) { // TODO Logging return false; } }
protected EdmEntityType resolveEntityType(final ServiceMetadata metadata, final EdmEntityType baseType, final String derivedTypeName) throws SerializerException { if (derivedTypeName == null || baseType.getFullQualifiedName().getFullQualifiedNameAsString().equals(derivedTypeName)) { return baseType; } EdmEntityType derivedType = metadata.getEdm().getEntityType(new FullQualifiedName(derivedTypeName)); if (derivedType == null) { throw new SerializerException("EntityType not found", SerializerException.MessageKeys.UNKNOWN_TYPE, derivedTypeName); } EdmEntityType type = derivedType.getBaseType(); while (type != null) { if (type.getFullQualifiedName().equals(baseType.getFullQualifiedName())) { return derivedType; } type = type.getBaseType(); } throw new SerializerException("Wrong base type", SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType.getFullQualifiedName().getFullQualifiedNameAsString()); }
protected EdmEntityType resolveEntityType(final ServiceMetadata metadata, final EdmEntityType baseType, final String derivedTypeName) throws SerializerException { if (derivedTypeName == null || baseType.getFullQualifiedName().getFullQualifiedNameAsString().equals(derivedTypeName)) { return baseType; } EdmEntityType derivedType = metadata.getEdm().getEntityType(new FullQualifiedName(derivedTypeName)); if (derivedType == null) { throw new SerializerException("EntityType not found", SerializerException.MessageKeys.UNKNOWN_TYPE, derivedTypeName); } EdmEntityType type = derivedType.getBaseType(); while (type != null) { if (type.getFullQualifiedName().getFullQualifiedNameAsString() .equals(baseType.getFullQualifiedName().getFullQualifiedNameAsString())) { return derivedType; } type = type.getBaseType(); } throw new SerializerException("Wrong base type", SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType .getFullQualifiedName().getFullQualifiedNameAsString()); }
protected EdmEntityType resolveEntityType(final ServiceMetadata metadata, final EdmEntityType baseType, final String derivedTypeName) throws SerializerException { if (derivedTypeName == null || baseType.getFullQualifiedName().getFullQualifiedNameAsString().equals(derivedTypeName)) { return baseType; } EdmEntityType derivedType = metadata.getEdm().getEntityType(new FullQualifiedName(derivedTypeName)); if (derivedType == null) { throw new SerializerException("EntityType not found", SerializerException.MessageKeys.UNKNOWN_TYPE, derivedTypeName); } EdmEntityType type = derivedType.getBaseType(); while (type != null) { if (type.getFullQualifiedName().equals(baseType.getFullQualifiedName())) { return derivedType; } type = type.getBaseType(); } throw new SerializerException("Wrong base type", SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType.getFullQualifiedName().getFullQualifiedNameAsString()); }
protected EdmEntityType resolveEntityType(final ServiceMetadata metadata, final EdmEntityType baseType, final String derivedTypeName) throws SerializerException { if (derivedTypeName == null || baseType.getFullQualifiedName().getFullQualifiedNameAsString().equals(derivedTypeName)) { return baseType; } EdmEntityType derivedType = metadata.getEdm().getEntityType(new FullQualifiedName(derivedTypeName)); if (derivedType == null) { throw new SerializerException("EntityType not found", SerializerException.MessageKeys.UNKNOWN_TYPE, derivedTypeName); } EdmEntityType type = derivedType.getBaseType(); while (type != null) { if (type.getFullQualifiedName().getFullQualifiedNameAsString() .equals(baseType.getFullQualifiedName().getFullQualifiedNameAsString())) { return derivedType; } type = type.getBaseType(); } throw new SerializerException("Wrong base type", SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType .getFullQualifiedName().getFullQualifiedNameAsString()); }
@Override public void visit(UriResourceEntitySet info) { EdmEntityType edmEntityType = info.getEntitySet().getEntityType(); if (this.root) { try { this.ctxExpression = DocumentNode.build(edmEntityType, info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, true, getUriInfo(), null); } catch (TeiidException e) { throw new TeiidRuntimeException(e); } } else { if (this.ctxQuery.getEdmEntityType().getFullQualifiedName().equals(edmEntityType.getFullQualifiedName())) { this.ctxExpression = this.ctxQuery; } else { for (DocumentNode er: this.ctxQuery.getSibilings()) { if (er.getEdmEntityType().getFullQualifiedName().equals(edmEntityType.getFullQualifiedName())) { this.ctxExpression = er; break; } } } } }
@Override public void validateMetadata(Edm edm) { Map<FullQualifiedName, EdmEntityType> edmEntityTypesMap = new HashMap<FullQualifiedName, EdmEntityType>(); Map<FullQualifiedName, EdmComplexType> edmComplexTypesMap = new HashMap<FullQualifiedName, EdmComplexType>(); Map<FullQualifiedName, EdmFunction> edmFunctionsMap = new HashMap<FullQualifiedName, EdmFunction>(); Map<FullQualifiedName, EdmEntityContainer> edmContainersMap = new HashMap<FullQualifiedName, EdmEntityContainer>(); Map<String, String> aliasNamespaceMap = new HashMap<String, String>(); List<EdmSchema> edmSchemas = edm.getSchemas(); for (EdmSchema edmSchema : edmSchemas) { List<EdmEntityType> edmEntityTypes = edmSchema.getEntityTypes(); for (EdmEntityType edmEntityType : edmEntityTypes) { edmEntityTypesMap.put(edmEntityType.getFullQualifiedName(), edmEntityType); } List<EdmComplexType> edmComplexTypes = edmSchema.getComplexTypes(); for (EdmComplexType edmComplexType : edmComplexTypes) { edmComplexTypesMap.put(edmComplexType.getFullQualifiedName(), edmComplexType); } List<EdmFunction> edmFunctions = edmSchema.getFunctions(); for (EdmFunction edmFunction : edmFunctions) { edmFunctionsMap.put(edmFunction.getFullQualifiedName(), edmFunction); } aliasNamespaceMap.put(edmSchema.getAlias(), edmSchema.getNamespace()); if (edmSchema.getEntityContainer() != null) { edmContainersMap.put(edmSchema.getEntityContainer().getFullQualifiedName(), edmSchema.getEntityContainer()); } } EdmTypeValidator edmTypeValidator = new EdmTypeValidator(aliasNamespaceMap, edmContainersMap, edmEntityTypesMap, edmComplexTypesMap, edmFunctionsMap); edmTypeValidator.validateEdm(); }
private void buildOperations(EdmEntityType entityType, EntityCollection entitySet) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), true); if (action != null) { entitySet.getOperations().add(buildOperation(action, buildOperationTarget(options.getContextURL()))); entityType.getFullQualifiedName(), false); if (action != null) { for (Entity entity:entitySet.getEntities()) { .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),true); .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false);
public void writeReadEntity(EdmEntityType entityType, Entity entity) throws SerializerException { assert (!isClosed()); if (entity == null) { writeNotFound(true); return; } if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), false); if (action != null) { entity.getOperations().add(buildOperation(action, entity.getId().toASCIIString())); } List<EdmFunction> functions = this.metadata.getEdm() .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false); for (EdmFunction function:functions) { entity.getOperations().add(buildOperation(function, entity.getId().toASCIIString())); } } // write the entity to response this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent()); writeOK(responseContentType); close(); }
private Entity consumeEntityNode(final EdmEntityType edmEntityType, final ObjectNode tree, final ExpandTreeBuilder expandBuilder) throws DeserializerException { Entity entity = new Entity(); entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString()); // Check and consume all Properties consumeEntityProperties(edmEntityType, tree, entity); // Check and consume all expanded Navigation Properties consumeExpandedNavigationProperties(edmEntityType, tree, entity, expandBuilder); // consume remaining json node fields consumeRemainingJsonNodeFields(edmEntityType, tree, entity); assertJsonNodeIsEmpty(tree); return entity; }
public void writeReadEntity(EdmEntityType entityType, Entity entity) throws SerializerException { assert (!isClosed()); if (entity == null) { writeNotFound(true); return; } if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) { EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType( entityType.getFullQualifiedName(), false); if (action != null) { entity.getOperations().add(buildOperation(action, entity.getId().toASCIIString())); } List<EdmFunction> functions = this.metadata.getEdm() .getBoundFunctionsWithBindingType(entityType.getFullQualifiedName(),false); for (EdmFunction function:functions) { entity.getOperations().add(buildOperation(function, entity.getId().toASCIIString())); } } // write the entity to response this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent()); writeOK(responseContentType); close(); }
private Entity consumeEntityNode(final EdmEntityType edmEntityType, final ObjectNode tree, final ExpandTreeBuilder expandBuilder) throws DeserializerException { Entity entity = new Entity(); entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString()); // Check and consume all Properties consumeEntityProperties(edmEntityType, tree, entity); // Check and consume all expanded Navigation Properties consumeExpandedNavigationProperties(edmEntityType, tree, entity, expandBuilder); // consume remaining json node fields consumeRemainingJsonNodeFields(edmEntityType, tree, entity); assertJsonNodeIsEmpty(tree); return entity; }
@Override public DeserializerResult entityCollection(final InputStream input, final EdmEntityType edmEntityType) throws DeserializerException { try { final XMLEventReader reader = getReader(input); final StartElement start = skipBeforeFirstStartElement(reader); EntityCollection entityCollection = entitySet(reader, start, edmEntityType); if (entityCollection != null) { for (Entity entity : entityCollection.getEntities()) { entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString()); } } return DeserializerResultImpl.with().entityCollection(entityCollection).build(); } catch (final XMLStreamException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.IO_EXCEPTION); } catch (final EdmPrimitiveTypeException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY); } }
private Entity consumeEntityNode(final EdmEntityType edmEntityType, final ObjectNode tree, final ExpandTreeBuilder expandBuilder) throws DeserializerException { Entity entity = new Entity(); entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString()); // Check and consume @id for v4.01 consumeId(edmEntityType, tree, entity); // Check and consume all Properties consumeEntityProperties(edmEntityType, tree, entity); // Check and consume all expanded Navigation Properties consumeExpandedNavigationProperties(edmEntityType, tree, entity, expandBuilder); // consume delta json node fields for v4.01 consumeDeltaJsonNodeFields(edmEntityType, tree, entity, expandBuilder); // consume remaining json node fields consumeRemainingJsonNodeFields(edmEntityType, tree, entity); assertJsonNodeIsEmpty(tree); return entity; }
@Override public DeserializerResult entityCollection(final InputStream input, final EdmEntityType edmEntityType) throws DeserializerException { try { final XMLEventReader reader = getReader(input); final StartElement start = skipBeforeFirstStartElement(reader); EntityCollection entityCollection = entitySet(reader, start, edmEntityType); if (entityCollection != null) { for (Entity entity : entityCollection.getEntities()) { entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString()); } } return DeserializerResultImpl.with().entityCollection(entityCollection).build(); } catch (final XMLStreamException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.IO_EXCEPTION); } catch (final EdmPrimitiveTypeException e) { throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY); } }