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


Java EdmEntityType.getProperty方法代码示例

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


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

示例1: uriResourceComplexPropertyImpl

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
@Test
public void uriResourceComplexPropertyImpl() {
  EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
  EdmProperty property = (EdmProperty) entityType.getProperty("PropertyCompNav");
  UriResourceComplexPropertyImpl impl = new UriResourceComplexPropertyImpl(property);
  assertEquals(UriResourceKind.complexProperty, impl.getKind());
  assertEquals(property, impl.getProperty());
  assertEquals(property.getName(), impl.toString());
  assertFalse(impl.isCollection());
  assertEquals(property.getType(), impl.getType());
  assertEquals(property.getType(), impl.getComplexType());
  impl.getComplexType();

  EdmComplexType complexTypeImplType = edm.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav);

  impl.setTypeFilter(complexTypeImplType);
  assertEquals(complexTypeImplType, impl.getTypeFilter());
  assertEquals(complexTypeImplType, impl.getComplexTypeFilter());
  impl.getComplexTypeFilter();

}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:UriResourceImplTest.java

示例2: uriResourceNavigationPropertyImpl

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
@Test
public void uriResourceNavigationPropertyImpl() {
  EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
  EdmNavigationProperty property = (EdmNavigationProperty) entityType.getProperty("NavPropertyETKeyNavMany");
  assertNotNull(property);

  UriResourceNavigationPropertyImpl impl = new UriResourceNavigationPropertyImpl(property);
  assertEquals(UriResourceKind.navigationProperty, impl.getKind());
  assertEquals(property, impl.getProperty());

  assertEquals("NavPropertyETKeyNavMany", impl.toString());
  assertEquals(property.getType(), impl.getType());

  assertTrue(impl.isCollection());
  impl.setKeyPredicates(Collections.singletonList(
      (UriParameter) new UriParameterImpl().setName("ParameterInt16")));
  assertFalse(impl.isCollection());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:UriResourceImplTest.java

示例3: consumeEntityProperties

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node,
    final Entity entity) throws DeserializerException {
  List<String> propertyNames = edmEntityType.getPropertyNames();
  for (String propertyName : propertyNames) {
    JsonNode jsonNode = node.get(propertyName);
    if (jsonNode != null) {
      EdmProperty edmProperty = (EdmProperty) edmEntityType.getProperty(propertyName);
      if (jsonNode.isNull() && !edmProperty.isNullable()) {
        throw new DeserializerException("Property: " + propertyName + " must not be null.",
            DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName);
      }
      Property property = consumePropertyNode(edmProperty.getName(), edmProperty.getType(),
          edmProperty.isCollection(), edmProperty.isNullable(), edmProperty.getMaxLength(),
          edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), edmProperty.getMapping(),
          jsonNode);
      entity.addProperty(property);
      node.remove(propertyName);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ODataJsonDeserializer.java

示例4: getMatch

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
private List<Entity> getMatch(UriParameter param, List<Entity> es)
    throws ODataApplicationException {
  ArrayList<Entity> list = new ArrayList<Entity>();
  for (Entity entity : es) {

    EdmEntityType entityType = this.metadata.getEdm().getEntityType(
        new FullQualifiedName(entity.getType()));

    EdmProperty property = (EdmProperty) entityType.getProperty(param.getName());
    EdmType type = property.getType();
    if (type.getKind() == EdmTypeKind.PRIMITIVE) {
      Object match = readPrimitiveValue(property, param.getText());
      Property entityValue = entity.getProperty(param.getName());
      if (match.equals(entityValue.asPrimitive())) {
        list.add(entity);
      }
    } else {
      throw new RuntimeException("Can not compare complex objects");
    }
  }
  return list;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:TripPinDataModel.java

示例5: read

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet,
    final List<UriParameter> keys) throws DataProviderException {
  try {
    for (final Entity entity : entitySet.getEntities()) {
      boolean found = true;
      for (final UriParameter key : keys) {
        final EdmProperty property = (EdmProperty) edmEntityType.getProperty(key.getName());
        final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
        final Object value = entity.getProperty(key.getName()).getValue();
        final Object keyValue =
            type.valueOfString(type.fromUriLiteral(key.getText()), property.isNullable(),
                property.getMaxLength(), property.getPrecision(), property.getScale(),
                property.isUnicode(), Calendar.class.isAssignableFrom(value.getClass())
                    ? Calendar.class : value.getClass());
        if (!value.equals(keyValue)) {
          found = false;
          break;
        }
      }
      if (found) {
        return entity;
      }
    }
    return null;
  } catch (final EdmPrimitiveTypeException e) {
    throw new DataProviderException("Wrong key!", e);
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:29,代码来源:DataProvider.java

示例6: updateEntity

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
/**
 * This method updates entity in tables where the request doesn't specify the odata e-tag.
 *
 * @param edmEntityType Entity type
 * @param entity        Entity
 * @param keys          Keys
 * @param merge         Merge
 * @throws DataServiceFault
 * @throws ODataApplicationException
 */
private void updateEntity(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keys, boolean merge)
        throws DataServiceFault, ODataApplicationException {
    ODataEntry entry = new ODataEntry();
    for (UriParameter key : keys) {
        String value = key.getText();
        if (value.startsWith("'") && value.endsWith("'")) {
            value = value.substring(1, value.length() - 1);
        }
        entry.addValue(key.getName(), value);
    }
    for (String property : edmEntityType.getPropertyNames()) {
        Property updateProperty = entity.getProperty(property);
        if (isKey(edmEntityType, property)) {
            continue;
        }
        // the request payload might not consider ALL properties, so it can be null
        if (updateProperty == null) {
            // if a property has NOT been added to the request payload
            // depending on the HttpMethod, our behavior is different
            if (merge) {
                // as of the OData spec, in case of PATCH, the existing property is not touched
                continue;
            } else {
                // as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
                entry.addValue(property, null);
                continue;
            }
        }
        EdmProperty propertyType = (EdmProperty) edmEntityType.getProperty(property);
        entry.addValue(property, readPrimitiveValueInString(propertyType, updateProperty.getValue()));
    }
    this.dataHandler.updateEntityInTable(edmEntityType.getName(), entry);
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:44,代码来源:ODataAdapter.java

示例7: uriResourcePrimitivePropertyImpl

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
@Test
public void uriResourcePrimitivePropertyImpl() {
  EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
  EdmProperty property = (EdmProperty) entityType.getProperty("PropertyInt16");
  UriResourcePrimitivePropertyImpl impl = new UriResourcePrimitivePropertyImpl(property);
  assertEquals(UriResourceKind.primitiveProperty, impl.getKind());
  assertEquals(property, impl.getProperty());
  assertEquals(property.getName(), impl.toString());
  assertFalse(impl.isCollection());
  assertEquals(property.getType(), impl.getType());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:UriResourceImplTest.java

示例8: buildLocation

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
public static String buildLocation(String baseURL, Entity entity, String enitySetName, EdmEntityType type) 
    throws EdmPrimitiveTypeException {
  StringBuilder location = new StringBuilder();

  location.append(baseURL).append("/").append(enitySetName);
  
  int i = 0;
  boolean usename = type.getKeyPredicateNames().size() > 1;
  location.append("(");
  for (String key : type.getKeyPredicateNames()) {
    if (i > 0) {
      location.append(",");
    }
    i++;
    if (usename) {
      location.append(key).append("=");
    }
    
    EdmProperty property = (EdmProperty)type.getProperty(key);
    String propertyType = entity.getProperty(key).getType();
    Object propertyValue = entity.getProperty(key).getValue();
    
    if (propertyValue == null) {
      throw new EdmPrimitiveTypeException("The key value for property "+key+" is invalid; Key value cannot be null");
    }
    
    if(propertyType.startsWith("Edm.")) {
      propertyType = propertyType.substring(4);
    }
    EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(propertyType);
    String value =  EdmPrimitiveTypeFactory.getInstance(kind).valueToString(
        propertyValue, true, property.getMaxLength(), property.getPrecision(), property.getScale(), true);
    if (kind == EdmPrimitiveTypeKind.String) {
        value = EdmString.getInstance().toUriLiteral(Encoder.encode(value));
    }
    location.append(value);
  }
  location.append(")");
  return location.toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:EntityResponse.java

示例9: validateReferentialConstraint

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
/**
 * @param sourceEntityType
 * @param targetEntityType
 * @param navProperty
 */
private void validateReferentialConstraint(EdmEntityType sourceEntityType, EdmEntityType targetEntityType,
    EdmNavigationProperty navProperty) {
  if (!navProperty.getReferentialConstraints().isEmpty()) {
    String propertyName = navProperty.getReferentialConstraints().get(0).getPropertyName();
    if (sourceEntityType.getProperty(propertyName) == null) {
      throw new RuntimeException("Property name "+ propertyName + " not part of the source entity.");
    }
    String referencedPropertyName = navProperty.getReferentialConstraints().get(0).getReferencedPropertyName();
    if (targetEntityType.getProperty(referencedPropertyName) == null) {
      throw new RuntimeException("Property name " + referencedPropertyName + " not part of the target entity.");
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:EdmTypeValidator.java

示例10: wrapEntityToDataEntry

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
/**
 * This method wraps Entity object into DataEntry object.
 *
 * @param entity Entity
 * @return DataEntry
 * @see DataEntry
 */
private ODataEntry wrapEntityToDataEntry(EdmEntityType entityType, Entity entity) throws ODataApplicationException {
    ODataEntry entry = new ODataEntry();
    for (Property property : entity.getProperties()) {
        EdmProperty propertyType = (EdmProperty) entityType.getProperty(property.getName());
        entry.addValue(property.getName(), readPrimitiveValueInString(propertyType, property.getValue()));
    }
    return entry;
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:16,代码来源:ODataAdapter.java

示例11: updateEntityWithETagMatched

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的package包/类
/**
   * This method updates the entity to the table by invoking ODataDataHandler updateEntityInTable method.
   *
   * @param edmEntityType  EdmEntityType
   * @param entity         entity with changes
   * @param existingEntity existing entity
   * @param merge          PUT/PATCH
   * @throws ODataApplicationException
   * @throws DataServiceFault
   * @see ODataDataHandler#updateEntityInTableTransactional(String, ODataEntry, ODataEntry)
   */
  private boolean updateEntityWithETagMatched(EdmEntityType edmEntityType, Entity entity, Entity existingEntity,
                                              boolean merge) throws ODataApplicationException, DataServiceFault {
/* loop over all properties and replace the values with the values of the given payload
   Note: ignoring ComplexType, as we don't have it in wso2dss oData model */
      List<Property> oldProperties = existingEntity.getProperties();
      ODataEntry newProperties = new ODataEntry();
      Map<String, EdmProperty> propertyMap = new HashMap<>();
      for (String property : edmEntityType.getPropertyNames()) {
          Property updateProperty = entity.getProperty(property);
          EdmProperty propertyType = (EdmProperty) edmEntityType.getProperty(property);
          if (isKey(edmEntityType, property)) {
              propertyMap.put(property, (EdmProperty) edmEntityType.getProperty(property));
              continue;
          }
          // the request payload might not consider ALL properties, so it can be null
          if (updateProperty == null) {
              // if a property has NOT been added to the request payload
              // depending on the HttpMethod, our behavior is different
              if (merge) {
                  // as of the OData spec, in case of PATCH, the existing property is not touched
                  propertyMap.put(property, (EdmProperty) edmEntityType.getProperty(property));
                  continue;
              } else {
                  // as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
                  propertyMap.put(property, (EdmProperty) edmEntityType.getProperty(property));
                  newProperties.addValue(property, null);
                  continue;
              }
          }
          propertyMap.put(property, (EdmProperty) edmEntityType.getProperty(property));
          newProperties.addValue(property, readPrimitiveValueInString(propertyType, updateProperty.getValue()));
      }
      return this.dataHandler.updateEntityInTableTransactional(edmEntityType.getName(),
                                                               wrapPropertiesToDataEntry(edmEntityType, oldProperties,
                                                                                         propertyMap), newProperties);
  }
 
开发者ID:wso2,项目名称:carbon-data,代码行数:48,代码来源:ODataAdapter.java

示例12: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的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

示例13: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的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

示例14: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的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

示例15: entityMatchesAllKeys

import org.apache.olingo.commons.api.edm.EdmEntityType; //导入方法依赖的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


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