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


Java EdmType.getKind方法代码示例

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


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

示例1: createProperty

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private Property createProperty(final EdmProperty edmProperty, final String propertyName)
    throws DataProviderException {
  final EdmType type = edmProperty.getType();
  Property newProperty;
  if (edmProperty.isPrimitive()
      || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
    newProperty = edmProperty.isCollection() ?
        DataCreator.createPrimitiveCollection(propertyName) :
        DataCreator.createPrimitive(propertyName, null);
  } else {
    if (edmProperty.isCollection()) {
      @SuppressWarnings("unchecked")
      Property newProperty2 = DataCreator.createComplexCollection(propertyName, 
          edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString());
      newProperty = newProperty2;
    } else {
      newProperty = DataCreator.createComplex(propertyName,
          edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString());
      createProperties((EdmComplexType) type, newProperty.asComplex().getValue());
    }
  }
  return newProperty;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:DataProvider.java

示例2: checkEqualityTypes

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private void checkEqualityTypes(final Expression left, final Expression right) throws UriParserException {
  checkNoCollection(left);
  checkNoCollection(right);

  final EdmType leftType = getType(left);
  final EdmType rightType = getType(right);
  if (leftType == null || rightType == null || leftType.equals(rightType)) {
    return;
  }

  // Numeric promotion for Edm.Byte and Edm.SByte
  if (isType(leftType, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte)
      && isType(rightType, EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte)) {
    return;
  }

  if (leftType.getKind() != EdmTypeKind.PRIMITIVE
      || rightType.getKind() != EdmTypeKind.PRIMITIVE
      || !(((EdmPrimitiveType) leftType).isCompatible((EdmPrimitiveType) rightType)
      || ((EdmPrimitiveType) rightType).isCompatible((EdmPrimitiveType) leftType))) {
    throw new UriParserSemanticException("Incompatible types.",
        UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE,
        leftType.getFullQualifiedName().getFullQualifiedNameAsString(),
        rightType.getFullQualifiedName().getFullQualifiedNameAsString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:ExpressionParser.java

示例3: parseComputeTrafo

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private Compute parseComputeTrafo(EdmStructuredType referencedType)
    throws UriParserException, UriValidationException {
  ComputeImpl compute = new ComputeImpl();
  do {
    final Expression expression = new ExpressionParser(edm, odata)
        .parse(tokenizer, referencedType, crossjoinEntitySetNames, aliases);
    final EdmType expressionType = ExpressionParser.getType(expression);
    if (expressionType.getKind() != EdmTypeKind.PRIMITIVE) {
      throw new UriParserSemanticException("Compute expressions must return primitive values.",
          UriParserSemanticException.MessageKeys.ONLY_FOR_PRIMITIVE_TYPES, "compute");
    }
    final String alias = parseAsAlias(referencedType, true);
    ((DynamicStructuredType) referencedType).addProperty(createDynamicProperty(alias, expressionType));
    compute.addExpression(new ComputeExpressionImpl()
        .setExpression(expression)
        .setAlias(alias));
  } while (tokenizer.next(TokenKind.COMMA));
  ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
  return compute;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ApplyParser.java

示例4: getMatch

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

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
/**
 * This method returns matched entity list, where it uses in getEntity method to get the matched entity.
 *
 * @param entityType EdmEntityType
 * @param param      UriParameter
 * @param entityList List of entities
 * @return list of entities
 * @throws ODataApplicationException
 * @throws ODataServiceFault
 */
private List<Entity> getMatch(EdmEntityType entityType, UriParameter param, List<Entity> entityList)
        throws ODataApplicationException, ODataServiceFault {
    ArrayList<Entity> list = new ArrayList<>();
    for (Entity entity : entityList) {
        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 != null) {
                if (match.equals(entityValue.asPrimitive())) {
                    list.add(entity);
                }
            } else {
                if (null == entityValue.asPrimitive()) {
                    list.add(entity);
                }
            }
        } else {
            throw new ODataServiceFault("Complex elements are not supported, couldn't compare complex objects.");
        }
    }
    return list;
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:35,代码来源:ODataAdapter.java

示例6: updateProperty

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void updateProperty(final EdmProperty edmProperty, Property property, final Property newProperty,
    final boolean patch) throws DataProviderException {
  if(property == null){
    throw new DataProviderException("Cannot update type of the entity",
        HttpStatusCode.BAD_REQUEST);
  }
  final EdmType type = edmProperty.getType();
  if (edmProperty.isCollection()) {
    // Updating collection properties means replacing all entries with the given ones.
    property.asCollection().clear();

    if (newProperty != null) {
      if (type.getKind() == EdmTypeKind.COMPLEX) {
        // Create each complex value.
        for (final ComplexValue complexValue : (List<ComplexValue>) newProperty.asCollection()) {
          ((List<ComplexValue>) property.asCollection()).add(createComplexValue(edmProperty, complexValue, patch));
        }
      } else {
        // Primitive type
        ((List<Object>) property.asCollection()).addAll(newProperty.asCollection());
      }
    }
  } else if (type.getKind() == EdmTypeKind.COMPLEX) {
    for (final String propertyName : ((EdmComplexType) type).getPropertyNames()) {
      final List<Property> newProperties = newProperty == null || newProperty.asComplex() == null ? null :
          newProperty.asComplex().getValue();
      updateProperty(((EdmComplexType) type).getStructuralProperty(propertyName),
          findProperty(propertyName, property.asComplex().getValue()),
          newProperties == null ? null : findProperty(propertyName, newProperties),
          patch);
    }
  } else {
    if (newProperty != null || !patch) {
      final Object value = newProperty == null ? null : newProperty.getValue();
      updatePropertyValue(property, value);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:40,代码来源:DataProvider.java

示例7: consumePropertySingleNode

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private void consumePropertySingleNode(final String name, final EdmType type,
    final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
    final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode, final Property property)
    throws DeserializerException {
  switch (type.getKind()) {
  case PRIMITIVE:
  case DEFINITION:
  case ENUM:
    Object value = readPrimitiveValue(name, (EdmPrimitiveType) type,
        isNullable, maxLength, precision, scale, isUnicode, mapping, jsonNode);
    property.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE,
        value);
    break;
  case COMPLEX:
    EdmType derivedType = getDerivedType((EdmComplexType) type,
        jsonNode);
    property.setType(derivedType.getFullQualifiedName()
        .getFullQualifiedNameAsString());

    value = readComplexNode(name, derivedType, isNullable, jsonNode);
    property.setValue(ValueType.COMPLEX, value);
    break;
  default:
    throw new DeserializerException("Invalid Type Kind for a property found: " + type.getKind(),
        DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, name);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:28,代码来源:ODataJsonDeserializer.java

示例8: getType

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
protected static EdmType getType(final Expression expression) throws UriParserException {
  EdmType type;
  if (expression instanceof Literal) {
    type = ((Literal) expression).getType();
  } else if (expression instanceof TypeLiteral) {
    type = ((TypeLiteral) expression).getType();
  } else if (expression instanceof Enumeration) {
    type = ((Enumeration) expression).getType();
  } else if (expression instanceof Member) {
    type = ((Member) expression).getType();
  } else if (expression instanceof Unary) {
    type = ((UnaryImpl) expression).getType();
  } else if (expression instanceof Binary) {
    type = ((BinaryImpl) expression).getType();
  } else if (expression instanceof Method) {
    type = ((MethodImpl) expression).getType();
  } else if (expression instanceof Alias) {
    final AliasQueryOption alias = ((AliasImpl) expression).getAlias();
    type = alias == null || alias.getValue() == null ? null : getType(alias.getValue());
  } else if (expression instanceof LambdaRef) {
    throw new UriParserSemanticException("Type determination not implemented.",
        UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED, expression.toString());
  } else {
    throw new UriParserSemanticException("Unknown expression type.",
        UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED, expression.toString());
  }
  if (type != null && type.getKind() == EdmTypeKind.DEFINITION) {
    type = ((EdmTypeDefinition) type).getUnderlyingType();
  }
  return type;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:32,代码来源:ExpressionParser.java

示例9: isEnumType

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private boolean isEnumType(final Expression expression) throws UriParserException {
  final EdmType expressionType = getType(expression);
  return expressionType == null
      || expressionType.getKind() == EdmTypeKind.ENUM
      || isType(expressionType,
          EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
          EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:ExpressionParser.java

示例10: parseAliasValue

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
protected static AliasQueryOption parseAliasValue(final String name, final EdmType type, final boolean isNullable,
    final boolean isCollection, final Edm edm, final EdmType referringType,
    final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException {
  final EdmTypeKind kind = type == null ? null : type.getKind();
  final AliasQueryOption alias = aliases.get(name);
  if (alias != null && alias.getText() != null) {
    UriTokenizer aliasTokenizer = new UriTokenizer(alias.getText());
    if (kind == null
        || !((isCollection || kind == EdmTypeKind.COMPLEX || kind == EdmTypeKind.ENTITY ?
        aliasTokenizer.next(TokenKind.jsonArrayOrObject) :
        nextPrimitiveTypeValue(aliasTokenizer, (EdmPrimitiveType) type, isNullable))
        && aliasTokenizer.next(TokenKind.EOF))) {
      // The alias value is not an allowed literal value, so parse it again as expression.
      aliasTokenizer = new UriTokenizer(alias.getText());
      // Don't pass on the current alias to avoid circular references.
      Map<String, AliasQueryOption> aliasesInner = new HashMap<String, AliasQueryOption>(aliases);
      aliasesInner.remove(name);
      final Expression expression = new ExpressionParser(edm, odata)
          .parse(aliasTokenizer, referringType, null, aliasesInner);
      final EdmType expressionType = ExpressionParser.getType(expression);
      if (aliasTokenizer.next(TokenKind.EOF)
          && (expressionType == null || type == null || expressionType.equals(type))) {
        ((AliasQueryOptionImpl) alias).setAliasValue(expression);
      } else {
        throw new UriParserSemanticException("Illegal value for alias '" + alias.getName() + "'.",
            UriParserSemanticException.MessageKeys.UNKNOWN_PART, alias.getText());
      }
    }
  }
  return alias;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:32,代码来源:ParserHelper.java

示例11: writePropertyType

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private void writePropertyType(final EdmProperty edmProperty, JsonGenerator json)
    throws SerializerException, IOException {
  if (!isODataMetadataFull) {
    return;
  }
  String typeName = edmProperty.getName() + constants.getType();
  final EdmType type = edmProperty.getType();
  if (type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
    if (edmProperty.isCollection()) {
      json.writeStringField(typeName, 
          "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")");
    } else {
      json.writeStringField(typeName, "#" + type.getFullQualifiedName().getFullQualifiedNameAsString());
    }
  } else if (edmProperty.isPrimitive()) {
    if (edmProperty.isCollection()) {
      json.writeStringField(typeName, "#Collection(" + type.getFullQualifiedName().getName() + ")");
    } else {
      // exclude the properties that can be heuristically determined
      if (type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean) &&
          type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double) &&
          type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String)) {
        json.writeStringField(typeName, "#" + type.getFullQualifiedName().getName());                  
      }
    }
  } else if (type.getKind() == EdmTypeKind.COMPLEX) {
    // non-collection case written in writeComplex method directly.
    if (edmProperty.isCollection()) {
      json.writeStringField(typeName, 
          "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")");
    }
  } else {
    throw new SerializerException("Property type not yet supported!",
        SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
  }    
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:37,代码来源:ODataJsonSerializer.java

示例12: writePropertyValue

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty,
    final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json)
    throws IOException, SerializerException {
  final EdmType type = edmProperty.getType();
  try {
    if (edmProperty.isPrimitive()
        || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writePrimitiveCollection((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      } else {
        writePrimitive((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      }
    } else if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writeComplexCollection(metadata, (EdmComplexType) type, property, selectedPaths, json);
      } else {
       writeComplex(metadata, (EdmComplexType) type, property, selectedPaths, json);
      }
    } else {
      throw new SerializerException("Property type not yet supported!",
          SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
    }
  } catch (final EdmPrimitiveTypeException e) {
    throw new SerializerException("Wrong value for property!", e,
        SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
        edmProperty.getName(), property.getValue().toString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:ODataJsonSerializer.java

示例13: writePropertyValue

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty,
    final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json)
    throws IOException, SerializerException {
  final EdmType type = edmProperty.getType();
  try {
    if (edmProperty.isPrimitive()
        || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writePrimitiveCollection((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      } else {
        writePrimitive((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      }
    } else if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writeComplexCollection(metadata, (EdmComplexType) type, property, selectedPaths, json);
      } else {
        writeComplex(metadata, (EdmComplexType) type, property, selectedPaths, json);
      }
    } else {
      throw new SerializerException("Property type not yet supported!",
          SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
    }
  } catch (final EdmPrimitiveTypeException e) {
    throw new SerializerException("Wrong value for property!", e,
        SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
        edmProperty.getName(), property.getValue().toString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:JsonDeltaSerializerWithNavigations.java

示例14: writeProperty

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
public void writeProperty(EdmType edmType, Property property) throws SerializerException {
  assert (!isClosed());

  if (property == null) {
    writeNotFound(true);
    return;
  }

  if (property.getValue() == null) {
    writeNoContent(true);
    return;
  }
  
  if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) {
    ContextURL contextURL = (this.complexOptions != null)
        ? this.complexOptions.getContextURL()
        : this.primitiveOptions.getContextURL();
    EdmAction action = this.metadata.getEdm().getBoundActionWithBindingType(
        edmType.getFullQualifiedName(), this.collection);
    if (action != null) {
      property.getOperations().add(buildOperation(action, buildOperationTarget(contextURL)));
    }
    
    List<EdmFunction> functions = this.metadata.getEdm()
        .getBoundFunctionsWithBindingType(edmType.getFullQualifiedName(), this.collection);
    
    for (EdmFunction function:functions) {
      property.getOperations().add(buildOperation(function, buildOperationTarget(contextURL)));
    }
  }    

  if (edmType.getKind() == EdmTypeKind.PRIMITIVE) {
    writePrimitiveProperty((EdmPrimitiveType) edmType, property);
  } else {
    writeComplexProperty((EdmComplexType) edmType, property);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:38,代码来源:PropertyResponse.java

示例15: setType

import org.apache.olingo.commons.api.edm.EdmType; //导入方法依赖的package包/类
@Override
public BuilderImpl setType(final EdmType type) {
  EdmPrimitiveTypeKind primitiveTypeKind = null;
  if (type != null) {
    if (type.getKind() != EdmTypeKind.PRIMITIVE) {
      throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type));
    }
    primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName());
  }
  return setType(primitiveTypeKind);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:ClientPrimitiveValueImpl.java


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