当前位置: 首页>>代码示例>>Java>>正文


Java EdmProperty.isNullable方法代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmProperty.isNullable方法的典型用法代码示例。如果您正苦于以下问题:Java EdmProperty.isNullable方法的具体用法?Java EdmProperty.isNullable怎么用?Java EdmProperty.isNullable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.commons.api.edm.EdmProperty的用法示例。


在下文中一共展示了EdmProperty.isNullable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createComplexValue

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private ComplexValue createComplexValue(final EdmProperty edmProperty,
    final ComplexValue complexValue, final boolean patch) throws DataProviderException {
  final ComplexValue result = new ComplexValue();
  final EdmComplexType edmType = (EdmComplexType) edmProperty.getType();
  final List<Property> givenProperties = complexValue.getValue();

  // Create ALL properties, even if no value is given. Check if null is allowed
  for (final String propertyName : edmType.getPropertyNames()) {
    final EdmProperty innerEdmProperty = (EdmProperty) edmType.getProperty(propertyName);
    final Property currentProperty = findProperty(propertyName, givenProperties);
    final Property newProperty = createProperty(innerEdmProperty, propertyName);
    result.getValue().add(newProperty);

    if (currentProperty != null) {
      updateProperty(innerEdmProperty, newProperty, currentProperty, patch);
    } else if (innerEdmProperty.isNullable()) {
      // Check complex properties ... may be null is not allowed
      if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
        updateProperty(innerEdmProperty, newProperty, null, patch);
      }
    }
  }

  return result;
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:26,代码来源:DataProvider.java

示例2: validateProperties

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void validateProperties(final List<Property> properties, final EdmBindingTarget edmBindingTarget,
    final EdmStructuredType edmType, final List<String> keyPredicateNames, final List<String> path)
    throws DataProviderException {

  for (final String propertyName : edmType.getPropertyNames()) {
    final EdmProperty edmProperty = (EdmProperty) edmType.getProperty(propertyName);

    // Ignore key properties, they are set automatically
    if (!keyPredicateNames.contains(propertyName)) {
      final Property property = getProperty(properties, propertyName);

      // Check if all "not nullable" properties are set
      if (!edmProperty.isNullable()) {
        if ((property != null && property.isNull()) // Update,insert; Property is explicit set to null
            || (isInsert && property == null) // Insert; Property not provided
            || (!isInsert && !isPatch && property == null)) { // Insert(Put); Property not provided
          throw new DataProviderException("Property " + propertyName + " must not be null",
              HttpStatusCode.BAD_REQUEST);
        }
      }

      // Validate property value
      validatePropertyValue(property, edmProperty, edmBindingTarget, path);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:RequestValidator.java

示例3: validatePropertyOperations

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
    throws UriValidationException {
  final List<UriResource> parts = uriInfo.getUriResourceParts();
  final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null;
  final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null;
  if (last != null
      && (last.getKind() == UriResourceKind.primitiveProperty
      || last.getKind() == UriResourceKind.complexProperty
      || (last.getKind() == UriResourceKind.value
          && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
    final EdmProperty property = ((UriResourceProperty)
        (last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
    if (method == HttpMethod.PATCH && property.isCollection()) {
      throw new UriValidationException("Attempt to patch collection property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
    if (method == HttpMethod.DELETE && !property.isNullable()) {
      throw new UriValidationException("Attempt to delete non-nullable property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:UriValidator.java

示例4: writeProperty

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
protected void writeProperty(final ServiceMetadata metadata,
    final EdmProperty edmProperty, final Property property,
    final Set<List<String>> selectedPaths,
    final String xml10InvalidCharReplacement, final XMLStreamWriter writer)
    throws XMLStreamException, SerializerException {
  writer.writeStartElement(DATA, edmProperty.getName(), NS_DATA);
  if (property == null || property.isNull()) {
    if (edmProperty.isNullable()) {
      writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_NULL, "true");
    } else {
      throw new SerializerException("Non-nullable property not present!",
          SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
    }
  } else {
    writePropertyValue(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer);
  }
  writer.writeEndElement();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:ODataXmlSerializer.java

示例5: validateProperties

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void validateProperties(final List<Property> properties,
    final EdmBindingTarget edmBindingTarget, final EdmStructuredType edmType,
    final List<String> keyPredicateNames, final List<String> path) throws DataProviderException {

  for (final String propertyName : edmType.getPropertyNames()) {
    final EdmProperty edmProperty = (EdmProperty) edmType.getProperty(propertyName);

    // Ignore key properties, they are set automatically
    if (!keyPredicateNames.contains(propertyName)) {
      final Property property = getProperty(properties, propertyName);

      // Check if all "not nullable" properties are set
      if (!edmProperty.isNullable()) {
        if ((property != null && property.isNull()) // Update,insert; Property is explicit set to
                                                    // null
            || (isInsert && property == null) // Insert; Property not provided
            || (!isInsert && !isPatch && property == null)) { // Insert(Put); Property not
                                                              // provided
          throw new DataProviderException("Property " + propertyName + " must not be null",
              HttpStatusCode.BAD_REQUEST);
        }
      }

      // Validate property value
      validatePropertyValue(property, edmProperty, edmBindingTarget, path);
    }
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:29,代码来源:RequestValidator.java

示例6: createComplexValue

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private ComplexValue createComplexValue(final EdmProperty edmProperty, final ComplexValue complexValue,
    final boolean patch) throws DataProviderException {
  final ComplexValue result = new ComplexValue();
  EdmComplexType edmType = (EdmComplexType) edmProperty.getType();
  final List<Property> givenProperties = complexValue.getValue();
  if(complexValue.getTypeName()!=null){
    EdmComplexType derivedType = edm.getComplexType(new FullQualifiedName(complexValue.getTypeName()));
    if(derivedType.getBaseType()!=null && edmType.getFullQualifiedName().getFullQualifiedNameAsString()
        .equals(derivedType.getBaseType().getFullQualifiedName().getFullQualifiedNameAsString())){
    edmType = derivedType;
    }
  }
  // Create ALL properties, even if no value is given. Check if null is allowed
  for (final String propertyName : edmType.getPropertyNames()) {
    final EdmProperty innerEdmProperty = (EdmProperty) edmType.getProperty(propertyName);
    final Property currentProperty = findProperty(propertyName, givenProperties);
    final Property newProperty = createProperty(innerEdmProperty, propertyName);
    result.getValue().add(newProperty);

    if (currentProperty != null) {
      updateProperty(innerEdmProperty, newProperty, currentProperty, patch);
    } else {
      if (innerEdmProperty.isNullable()) {
        // Check complex properties ... may be null is not allowed
        if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
          updateProperty(innerEdmProperty, newProperty, null, patch);
        }
      }
    }
  }
  result.setTypeName(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
  return result;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:34,代码来源:DataProvider.java

示例7: facetsFrom

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
/** Sets all facets from an EDM property. */
public Builder facetsFrom(final EdmProperty property) {
  options.isNullable = property.isNullable();
  options.maxLength = property.getMaxLength();
  options.precision = property.getPrecision();
  options.scale = property.getScale();
  options.isUnicode = property.isUnicode();
  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:PrimitiveSerializerOptions.java

示例8: writeProperty

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
protected void writeProperty(final ServiceMetadata metadata,
    final EdmProperty edmProperty, final Property property,
    final Set<List<String>> selectedPaths, final JsonGenerator json)
    throws IOException, SerializerException {
  boolean isStreamProperty = isStreamProperty(edmProperty);
  writePropertyType(edmProperty, json);
  if (!isStreamProperty) {
    json.writeFieldName(edmProperty.getName());
  }
  if (property == null || property.isNull()) {
    if (edmProperty.isNullable() == Boolean.FALSE && !isStreamProperty) {
      throw new SerializerException("Non-nullable property not present!",
          SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
    } else {
      if (!isStreamProperty) {
        if (edmProperty.isCollection()) {
          json.writeStartArray();
          json.writeEndArray();
        } else {
          json.writeNull();
        }
      }
    }
  } else {
    writePropertyValue(metadata, edmProperty, property, selectedPaths, json);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:28,代码来源:ODataJsonSerializer.java

示例9: updateProperty

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void updateProperty(final ODataRequest request, ODataResponse response, final UriInfo uriInfo,
    final ContentType requestFormat, final ContentType responseFormat, final RepresentationType representationType)
    throws ODataApplicationException, ODataLibraryException {
  final UriInfoResource resource = uriInfo.asUriInfoResource();
  validatePath(resource);
  final EdmEntitySet edmEntitySet = getEdmEntitySet(resource);

  Entity entity = readEntity(uriInfo);
  odata.createETagHelper().checkChangePreconditions(entity.getETag(),
      request.getHeaders(HttpHeader.IF_MATCH),
      request.getHeaders(HttpHeader.IF_NONE_MATCH));

  final List<UriResource> resourceParts = resource.getUriResourceParts();
  final int trailing = representationType == RepresentationType.VALUE ? 1 : 0;
  final List<String> path = getPropertyPath(resourceParts, trailing);
  final EdmProperty edmProperty = ((UriResourceProperty) resourceParts.get(resourceParts.size() - trailing - 1))
      .getProperty();

  Property property = getPropertyData(entity, path);

  if (representationType == RepresentationType.VALUE) {
    final FixedFormatDeserializer deserializer = odata.createFixedFormatDeserializer();
    final Object value = edmProperty.getType() == odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Binary) ?
        deserializer.binary(request.getBody()) :
        deserializer.primitiveValue(request.getBody(), edmProperty);
    dataProvider.updatePropertyValue(property, value);
  } else {
    final Property changedProperty = odata.createDeserializer(requestFormat)
        .property(request.getBody(), edmProperty).getProperty();
    if (changedProperty.isNull() && !edmProperty.isNullable()) {
      throw new ODataApplicationException("Not nullable.", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
    }
    dataProvider.updateProperty(edmProperty, property, changedProperty, request.getMethod() == HttpMethod.PATCH);
  }

  dataProvider.updateETag(entity);

  final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
  if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
    if (representationType == RepresentationType.VALUE) {
      response.setContent(
          serializePrimitiveValue(property, edmProperty, (EdmPrimitiveType) edmProperty.getType(), null));
    } else {
      final SerializerResult result = serializeProperty(entity, edmEntitySet, path, property, edmProperty,
          edmProperty.getType(), null, representationType, responseFormat, null, null);
      response.setContent(result.getContent());
    }
    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
  } else {
    response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
  }
  if (returnPreference != null) {
    response.setHeader(HttpHeader.PREFERENCE_APPLIED,
        PreferencesApplied.with().returnRepresentation(returnPreference).build().toValueString());
  }
  if (entity.getETag() != null) {
    response.setHeader(HttpHeader.ETAG, entity.getETag());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:61,代码来源:TechnicalPrimitiveComplexProcessor.java

示例10: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity,
    List<UriParameter> keyParams) {

  // loop over all keys
  for (final UriParameter key : keyParams) {
    // key
    String keyName = key.getName();
    String keyText = key.getText();

    // note: below line doesn't consider: keyProp can be part of a complexType in V4
    // in such case, it would be required to access it via getKeyPropertyRef()
    // but since this isn't the case in our model, we ignore it in our implementation
    EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
    // Edm: we need this info for the comparison below
    Boolean isNullable = edmKeyProperty.isNullable();
    Integer maxLength = edmKeyProperty.getMaxLength();
    Integer precision = edmKeyProperty.getPrecision();
    Boolean isUnicode = edmKeyProperty.isUnicode();
    Integer scale = edmKeyProperty.getScale();
    // get the EdmType in order to compare
    EdmType edmType = edmKeyProperty.getType();
    // if(EdmType instanceof EdmPrimitiveType) // do we need this?
    EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;

    // Runtime data: the value of the current entity
    // don't need to check for null, this is done in FWK
    Object valueObject = rt_entity.getProperty(keyName).getValue();
    // TODO if the property is a complex type

    // now need to compare the valueObject with the keyText String
    // this is done using the type.valueToString
    String valueAsString = null;
    try {
      valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable,
          maxLength, precision, scale, isUnicode);
    } catch (EdmPrimitiveTypeException e) {
      return false; // TODO proper Exception handling
    }

    if (valueAsString == null) {
      return false;
    }

    boolean matches = valueAsString.equals(keyText);
    // if any of the key properties is not found in the entity, we don't need to search further
    if (!matches) {
      return false;
    }
    // if the given key value is found in the current entity, continue with the next key
  }

  return true;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:54,代码来源:Util.java

示例11: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
        throws ODataApplicationException {

  // loop over all keys
  for (final UriParameter key : keyParams) {
    // key
    String keyName = key.getName();
    String keyText = key.getText();

    // Edm: we need this info for the comparison below
    EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
    Boolean isNullable = edmKeyProperty.isNullable();
    Integer maxLength = edmKeyProperty.getMaxLength();
    Integer precision = edmKeyProperty.getPrecision();
    Boolean isUnicode = edmKeyProperty.isUnicode();
    Integer scale = edmKeyProperty.getScale();
    // get the EdmType in order to compare
    EdmType edmType = edmKeyProperty.getType();
    EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;

    // Runtime data: the value of the current entity
    // don't need to check for null, this is done in olingo library
    Object valueObject = entity.getProperty(keyName).getValue();

    // now need to compare the valueObject with the keyText String
    // this is done using the type.valueToString
    String valueAsString;
    try {
      valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
    } catch (EdmPrimitiveTypeException e) {
      throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR
              .getStatusCode(), Locale.ENGLISH, e);
    }

    if (valueAsString == null) {
      return false;
    }

    boolean matches = valueAsString.equals(keyText);
    if (!matches) {
      // if any of the key properties is not found in the entity, we don't need to search further
      return false;
    }
  }

  return true;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:48,代码来源:Util.java

示例12: appendProperties

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void appendProperties(final JsonGenerator json, 
    final EdmStructuredType type) throws SerializerException, IOException {
  List<String> propertyNames = new ArrayList<String>(type.getPropertyNames());
  if (type.getBaseType() != null) {
    propertyNames.removeAll(type.getBaseType().getPropertyNames());
  }
  for (String propertyName : propertyNames) {
    EdmProperty property = type.getStructuralProperty(propertyName);
    json.writeObjectFieldStart(propertyName);
    String fqnString;
    if (property.isPrimitive()) {
      fqnString = getFullQualifiedName(property.getType());
    } else {
      fqnString = getAliasedFullQualifiedName(property.getType());
    }
    json.writeStringField(TYPE, fqnString);
    if (property.isCollection()) {
      json.writeBooleanField(COLLECTION, property.isCollection());
    }

    // Facets
    if (!property.isNullable()) {
      json.writeBooleanField(NULLABLE, property.isNullable());
    }

    if (!property.isUnicode()) {
      json.writeBooleanField(UNICODE, property.isUnicode());
    }

    if (property.getDefaultValue() != null) {
      json.writeStringField(DEFAULT_VALUE, property.getDefaultValue());
    }

    if (property.getMaxLength() != null) {
      json.writeNumberField(MAX_LENGTH, property.getMaxLength());
    }

    if (property.getPrecision() != null) {
      json.writeNumberField(PRECISION, property.getPrecision());
    }

    if (property.getScale() != null) {
      json.writeNumberField(SCALE, property.getScale());
    }

    appendAnnotations(json, property, null);
    json.writeEndObject();
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:50,代码来源:MetadataDocumentJsonSerializer.java

示例13: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
        throws ODataApplicationException {

  // loop over all keys
  for (final UriParameter key : keyParams) {
    // key
    String keyName = key.getName();
    String keyText = key.getText();
    
    // Edm: we need this info for the comparison below
    EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
    Boolean isNullable = edmKeyProperty.isNullable();
    Integer maxLength = edmKeyProperty.getMaxLength();
    Integer precision = edmKeyProperty.getPrecision();
    Boolean isUnicode = edmKeyProperty.isUnicode();
    Integer scale = edmKeyProperty.getScale();
    // get the EdmType in order to compare
    EdmType edmType = edmKeyProperty.getType();
    EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;

    // Runtime data: the value of the current entity
    // don't need to check for null, this is done in olingo library
    Object valueObject = entity.getProperty(keyName).getValue();

    // now need to compare the valueObject with the keyText String
    // this is done using the type.valueToString //
    String valueAsString = null;
    try {
      valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
    } catch (EdmPrimitiveTypeException e) {
      throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR
          .getStatusCode(), Locale.ENGLISH, e);
    }

    if (valueAsString == null) {
      return false;
    }

    boolean matches = valueAsString.equals(keyText);
    if (!matches) {
      // if any of the key properties is not found in the entity, we don't need to search further
      return false;
    }
  }

  return true;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:48,代码来源:Util.java

示例14: appendProperties

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void appendProperties(final XMLStreamWriter writer, final EdmStructuredType type) throws XMLStreamException {
  List<String> propertyNames = new ArrayList<String>(type.getPropertyNames());
  if (type.getBaseType() != null) {
    propertyNames.removeAll(type.getBaseType().getPropertyNames());
  }
  for (String propertyName : propertyNames) {
    EdmProperty property = type.getStructuralProperty(propertyName);
    writer.writeStartElement(XML_PROPERTY);
    writer.writeAttribute(XML_NAME, propertyName);
    String fqnString;
    if (property.isPrimitive()) {
      fqnString = getFullQualifiedName(property.getType(), property.isCollection());
    } else {
      fqnString = getAliasedFullQualifiedName(property.getType(), property.isCollection());
    }
    writer.writeAttribute(XML_TYPE, fqnString);

    // Facets
    if (!property.isNullable()) {
      writer.writeAttribute(XML_NULLABLE, "" + property.isNullable());
    }

    if (!property.isUnicode()) {
      writer.writeAttribute(XML_UNICODE, "" + property.isUnicode());
    }

    if (property.getDefaultValue() != null) {
      writer.writeAttribute(XML_DEFAULT_VALUE, property.getDefaultValue());
    }

    if (property.getMaxLength() != null) {
      writer.writeAttribute(XML_MAX_LENGTH, "" + property.getMaxLength());
    }

    if (property.getPrecision() != null) {
      writer.writeAttribute(XML_PRECISION, "" + property.getPrecision());
    }

    if (property.getScale() != null) {
      writer.writeAttribute(XML_SCALE, "" + property.getScale());
    }

    appendAnnotations(writer, property);
    writer.writeEndElement();
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:47,代码来源:MetadataDocumentXmlSerializer.java

示例15: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
public static boolean
    entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams)
        throws ODataApplicationException {

  // loop over all keys
  for (final UriParameter key : keyParams) {
    // key
    String keyName = key.getName();
    String keyText = key.getText();

    // Edm: we need this info for the comparison below
    EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
    Boolean isNullable = edmKeyProperty.isNullable();
    Integer maxLength = edmKeyProperty.getMaxLength();
    Integer precision = edmKeyProperty.getPrecision();
    Boolean isUnicode = edmKeyProperty.isUnicode();
    Integer scale = edmKeyProperty.getScale();
    // get the EdmType in order to compare
    EdmType edmType = edmKeyProperty.getType();
    // if(EdmType instanceof EdmPrimitiveType) // do we need this?
    EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;

    // Runtime data: the value of the current entity
    // don't need to check for null, this is done in olingo library
    Object valueObject = rt_entity.getProperty(keyName).getValue();

    // now need to compare the valueObject with the keyText String
    // this is done using type.valueToString
    String valueAsString = null;
    try {
      valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
    } catch (EdmPrimitiveTypeException e) {
      throw new ODataApplicationException("Failed to retrieve String value",
				HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH, e);
    }

    if (valueAsString == null) {
      return false;
    }

    boolean matches = valueAsString.equals(keyText);
    if (!matches) {
      // if any of the key properties is not found in the entity, we don't need to search further
      return false;
    }
  }

  return true;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:50,代码来源:Util.java


注:本文中的org.apache.olingo.commons.api.edm.EdmProperty.isNullable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。