/** * Ensure that non nullable navigation properties are present. * * @param entityType entityType * @throws ODataException If unable to ensure navigation properties are present */ public void ensureNavigationProperties(StructuredType entityType) throws ODataException { List<String> missingNavigationPropertyNames = new ArrayList<>(); entityType.getStructuralProperties().stream().filter(property -> (property instanceof NavigationProperty) && !property.isNullable()).forEach(property -> { LOG.debug("Validating non-nullable NavigationProperty property : {}", property.getName()); if (!links.containsKey(property.getName())) { missingNavigationPropertyNames.add(property.getName()); } }); if (missingNavigationPropertyNames.size() != 0) { StringJoiner joiner = new StringJoiner(","); missingNavigationPropertyNames.forEach(joiner::add); throw new ODataUnmarshallingException("The request does not specify the navigation links for '" + joiner.toString() + "."); } }
/** * Ensure that non nullable navigation properties are present. * * @param entityType entityType * @throws ODataException If unable to ensure navigation properties are present */ public void ensureNavigationProperties(StructuredType entityType) throws ODataException { List<String> missingNavigationPropertyNames = new ArrayList<>(); entityType.getStructuralProperties().stream().filter(property -> (property instanceof NavigationProperty) && !property.isNullable()).forEach(property -> { LOG.debug("Validating non-nullable NavigationProperty property : {}", property.getName()); if (!links.containsKey(property.getName())) { missingNavigationPropertyNames.add(property.getName()); } }); if (missingNavigationPropertyNames.size() != 0) { StringJoiner joiner = new StringJoiner(","); missingNavigationPropertyNames.forEach(joiner::add); throw new ODataUnmarshallingException("The request does not specify the navigation links for '" + joiner.toString() + "."); } }
/** * Ensure that non nullable collection are present. * * @param entityType entityType * @throws ODataException If unable to ensure collection is present */ public void ensureCollection(StructuredType entityType) throws ODataException { List<String> missingCollectionPropertyName = new ArrayList<>(); entityType.getStructuralProperties().stream() .filter(property -> (property.isCollection()) && !(property instanceof NavigationProperty) && !property.isNullable()).forEach(property -> { LOG.debug("Validating non-nullable collection property : {}", property.getName()); if (!fields.containsKey(property.getName())) { missingCollectionPropertyName.add(property.getName()); } }); if (missingCollectionPropertyName.size() != 0) { StringJoiner joiner = new StringJoiner(","); missingCollectionPropertyName.forEach(joiner::add); throw new ODataUnmarshallingException("The request does not specify the non-nullable collections: '" + joiner.toString() + "."); } }
/** * Ensure that non nullable collection are present. * * @param entityType entityType * @throws ODataException If unable to ensure collection is present */ public void ensureCollection(StructuredType entityType) throws ODataException { List<String> missingCollectionPropertyName = new ArrayList<>(); entityType.getStructuralProperties().stream() .filter(property -> (property.isCollection()) && !(property instanceof NavigationProperty) && !property.isNullable()).forEach(property -> { LOG.debug("Validating non-nullable collection property : {}", property.getName()); if (!fields.containsKey(property.getName())) { missingCollectionPropertyName.add(property.getName()); } }); if (missingCollectionPropertyName.size() != 0) { StringJoiner joiner = new StringJoiner(","); missingCollectionPropertyName.forEach(joiner::add); throw new ODataUnmarshallingException("The request does not specify the non-nullable collections: '" + joiner.toString() + "."); } }
private void ensureNonNullableNavigationPropertiesArePresent(Set<String> navigationPropertyNames, StructuredType entityType) throws ODataException { if (getRequest().getMethod() != ODataRequest.Method.POST) { return; } List<String> missingNavigationPropertyNames = new ArrayList<>(); entityType.getStructuralProperties().stream() .filter(property -> (property instanceof NavigationProperty) && (!property.isNullable())) .forEach(property -> { LOG.debug("Validating non-nullable property : {}", property.getName()); if (!navigationPropertyNames.contains(property.getName())) { missingNavigationPropertyNames.add(property.getName()); } }); if (missingNavigationPropertyNames.size() != 0) { LOG.debug("Non-nullable navigation properties of {} are not found in the request" + missingNavigationPropertyNames); // NOTE: We are just logging if a navigation property is not present. // In future, we will impose this restriction like ODataJsonParser after // we support 8.2 of docs.oasis-open.org/odata/odata-atom-format/v4.0/cs02/odata-atom-format-v4.0-cs02.html } }
private void ensureNonNullableNavigationPropertiesArePresent(Set<String> navigationPropertyNames, StructuredType entityType) throws ODataException { if (getRequest().getMethod() != ODataRequest.Method.POST) { return; } List<String> missingNavigationPropertyNames = new ArrayList<>(); entityType.getStructuralProperties().stream() .filter(property -> (property instanceof NavigationProperty) && (!property.isNullable())) .forEach(property -> { LOG.debug("Validating non-nullable property : {}", property.getName()); if (!navigationPropertyNames.contains(property.getName())) { missingNavigationPropertyNames.add(property.getName()); } }); if (missingNavigationPropertyNames.size() != 0) { LOG.debug("Non-nullable navigation properties of {} are not found in the request" + missingNavigationPropertyNames); // NOTE: We are just logging if a navigation property is not present. // In future, we will impose this restriction like ODataJsonParser after // we support 8.2 of docs.oasis-open.org/odata/odata-atom-format/v4.0/cs02/odata-atom-format-v4.0-cs02.html } }
private void ensureNonNullableCollectionArePresent(StructuredType entityType) throws ODataException { if (getRequest().getMethod() != ODataRequest.Method.POST) { return; } List<String> missingCollectionPropertyName = new ArrayList<>(); entityType.getStructuralProperties().stream() .filter(property -> (property.isCollection()) && !(property instanceof NavigationProperty) && (!property.isNullable())) .forEach(property -> { LOG.debug("Validating non-nullable collection property : {}", property.getName()); if (!foundCollectionProperties.contains(property.getName())) { missingCollectionPropertyName.add(property.getName()); } }); if (missingCollectionPropertyName.size() != 0) { StringJoiner joiner = new StringJoiner(","); missingCollectionPropertyName.forEach(joiner::add); LOG.debug("Non-nullable collections of {} are not found in the request" + missingCollectionPropertyName); throw new ODataUnmarshallingException("The request does not specify the non-nullable collections: '" + joiner.toString() + "."); } }
private void ensureNonNullableCollectionArePresent(StructuredType entityType) throws ODataException { if (getRequest().getMethod() != ODataRequest.Method.POST) { return; } List<String> missingCollectionPropertyName = new ArrayList<>(); entityType.getStructuralProperties().stream() .filter(property -> (property.isCollection()) && !(property instanceof NavigationProperty) && (!property.isNullable())) .forEach(property -> { LOG.debug("Validating non-nullable collection property : {}", property.getName()); if (!foundCollectionProperties.contains(property.getName())) { missingCollectionPropertyName.add(property.getName()); } }); if (missingCollectionPropertyName.size() != 0) { StringJoiner joiner = new StringJoiner(","); missingCollectionPropertyName.forEach(joiner::add); LOG.debug("Non-nullable collections of {} are not found in the request" + missingCollectionPropertyName); throw new ODataUnmarshallingException("The request does not specify the non-nullable collections: '" + joiner.toString() + "."); } }
/** * Gets the properties of a structural type, including the properties of its base types (recursively). * * @param structuredType structuredType * @param entityDataModel The entity data model * @return listOfProperties * @throws ODataException If unable to get all properties from edm */ public static List<StructuralProperty> getAllProperties(StructuredType structuredType, EntityDataModel entityDataModel) throws ODataException { List<StructuralProperty> properties = new ArrayList<>(); String baseTypeName = structuredType.getBaseTypeName(); if (!isNullOrEmpty(baseTypeName)) { StructuredType baseType = (StructuredType) entityDataModel.getType(baseTypeName); if (baseType == null) { throw new ODataUnmarshallingException("OData type not found: " + baseTypeName); } // Get the properties of the base type properties.addAll(getAllProperties(baseType, entityDataModel)); } properties.addAll(structuredType.getStructuralProperties()); LOG.info("Total number of properties returning are {} for given structured type {}", properties.size(), structuredType.getName()); return properties; }
/** * Gets the properties of a structural type, including the properties of its base types (recursively). * * @param structuredType structuredType * @param entityDataModel The entity data model * @return listOfProperties * @throws ODataException If unable to get all properties from edm */ public static List<StructuralProperty> getAllProperties(StructuredType structuredType, EntityDataModel entityDataModel) throws ODataException { List<StructuralProperty> properties = new ArrayList<>(); String baseTypeName = structuredType.getBaseTypeName(); if (!isNullOrEmpty(baseTypeName)) { StructuredType baseType = (StructuredType) entityDataModel.getType(baseTypeName); if (baseType == null) { throw new ODataUnmarshallingException("OData type not found: " + baseTypeName); } // Get the properties of the base type properties.addAll(getAllProperties(baseType, entityDataModel)); } properties.addAll(structuredType.getStructuralProperties()); LOG.info("Total number of properties returning are {} for given structured type {}", properties.size(), structuredType.getName()); return properties; }
/** * Calls a callback for each property of a structured type (entity or complex type), including the properties in * the base types that the type might derive from. * * @param entityDataModel The entity data model. * @param structType The structured type of which to visit the properties. * @param visitor The callback called for each property. * @param <E> The type of exception that the callback can throw. * @throws E If the callback throws an exception. */ public static <E extends ODataException> void visitProperties(EntityDataModel entityDataModel, StructuredType structType, PropertyVisitor<E> visitor) throws E { String baseTypeName = structType.getBaseTypeName(); if (!isNullOrEmpty(baseTypeName)) { visitProperties(entityDataModel, (StructuredType) entityDataModel.getType(baseTypeName), visitor); } for (StructuralProperty property : structType.getStructuralProperties()) { visitor.visit(property); } }
/** * Calls a callback for each property of a structured type (entity or complex type), including the properties in * the base types that the type might derive from. * * @param entityDataModel The entity data model. * @param structType The structured type of which to visit the properties. * @param visitor The callback called for each property. * @param <E> The type of exception that the callback can throw. * @throws E If the callback throws an exception. */ public static <E extends ODataException> void visitProperties(EntityDataModel entityDataModel, StructuredType structType, PropertyVisitor<E> visitor) throws E { String baseTypeName = structType.getBaseTypeName(); if (!isNullOrEmpty(baseTypeName)) { visitProperties(entityDataModel, (StructuredType) entityDataModel.getType(baseTypeName), visitor); } for (StructuralProperty property : structType.getStructuralProperties()) { visitor.visit(property); } }
StructuredType structuredType = lookup.getStructuredType(typeName); if (structuredType != null) { for (StructuralProperty property : structuredType.getStructuralProperties()) { String propertyTypeName = property.isCollection() ? property.getElementTypeName() : property.getTypeName();
StructuredType structuredType = lookup.getStructuredType(typeName); if (structuredType != null) { for (StructuralProperty property : structuredType.getStructuralProperties()) { String propertyTypeName = property.isCollection() ? property.getElementTypeName() : property.getTypeName();