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


Java EdmTypeKind.COMPLEX属性代码示例

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


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

示例1: createPropertyList

@SuppressWarnings("unchecked")
private Property createPropertyList(String name, List<Object> valueObject,
        EdmStructuredType structuredType) {
    ValueType valueType;
    EdmElement property = structuredType.getProperty(name);
    EdmTypeKind propertyKind = property.getType().getKind();
    if (propertyKind == EdmTypeKind.COMPLEX) {
        valueType = ValueType.COLLECTION_COMPLEX;
    } else {
        valueType = ValueType.COLLECTION_PRIMITIVE;
    }
    List<Object> properties = new ArrayList<>();
    for (Object value : valueObject) {
        if (value instanceof Map) {
            properties.add(createComplexValue((Map<String, Object>) value, property));
        } else {
            properties.add(value);
        }
    }
    return new Property(null, name, valueType, properties);
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:21,代码来源:PropertyCreator.java

示例2: createComplexValue

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,代码行数:25,代码来源:DataProvider.java

示例3: parsePathSegment

private UriResource parsePathSegment(final EdmElement property) throws UriParserException {
  if (property == null
      || !(property.getType().getKind() == EdmTypeKind.COMPLEX
      || property instanceof EdmNavigationProperty)) {
    // Could be a customAggregate or $count.
    return null;
  }
  if (tokenizer.next(TokenKind.SLASH)) {
    final EdmStructuredType typeCast = ParserHelper.parseTypeCast(tokenizer, edm,
        (EdmStructuredType) property.getType());
    if (typeCast != null) {
      ParserHelper.requireNext(tokenizer, TokenKind.SLASH);
    }
    return property.getType().getKind() == EdmTypeKind.COMPLEX ?
        new UriResourceComplexPropertyImpl((EdmProperty) property).setTypeFilter(typeCast) :
        new UriResourceNavigationPropertyImpl((EdmNavigationProperty) property).setCollectionTypeFilter(typeCast);
  } else {
    return null;
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ApplyParser.java

示例4: updateProperty

@SuppressWarnings("unchecked")
public void updateProperty(final EdmProperty edmProperty, Property property,
    final Property newProperty, final boolean patch) throws DataProviderException {
  if (edmProperty.isPrimitive()) {
    if (newProperty != null || !patch) {
      final Object value = newProperty == null ? null : newProperty.getValue();
      updatePropertyValue(property, value);
    }
  } else if (edmProperty.isCollection()) {
    // Updating collection properties means replacing all entries with the given ones.
    property.asCollection().clear();

    if (newProperty != null) {
      if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
        // Complex type
        final List<ComplexValue> complexValues = (List<ComplexValue>) newProperty.asCollection();

        // Create each complex value
        for (final ComplexValue complexValue : complexValues) {
          ((List<ComplexValue>) property.asCollection())
              .add(createComplexValue(edmProperty, complexValue, patch));
        }
      } else {
        // Primitive type
        final List<Object> values = (List<Object>) newProperty.asCollection();
        ((List<Object>) property.asCollection()).addAll(values);
      }
    }
  } else {
    final EdmComplexType type = (EdmComplexType) edmProperty.getType();
    for (final String propertyName : type.getPropertyNames()) {
      final List<Property> newProperties = newProperty == null || newProperty.asComplex() == null
          ? null : newProperty.asComplex().getValue();
      updateProperty(type.getStructuralProperty(propertyName),
          findProperty(propertyName, property.asComplex().getValue()),
          newProperties == null ? null : findProperty(propertyName, newProperties), patch);
    }
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:39,代码来源:DataProvider.java

示例5: updateProperty

@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,代码行数:39,代码来源:DataProvider.java

示例6: createComplexValue

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,代码行数:33,代码来源:DataProvider.java

示例7: parseCustomFunction

private CustomFunction parseCustomFunction(final FullQualifiedName functionName,
    final EdmStructuredType referencedType) throws UriParserException, UriValidationException {
  final List<UriParameter> parameters =
      ParserHelper.parseFunctionParameters(tokenizer, edm, referencedType, true, aliases);
  final List<String> parameterNames = ParserHelper.getParameterNames(parameters);
  final EdmFunction function = edm.getBoundFunction(functionName,
      referencedType.getFullQualifiedName(), true, parameterNames);
  if (function == null) {
    throw new UriParserSemanticException("No function '" + functionName + "' found.",
        UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND,
        functionName.getFullQualifiedNameAsString());
  }
  ParserHelper.validateFunctionParameters(function, parameters, edm, referencedType, aliases);

  // The binding parameter and the return type must be of type complex or entity collection.
  final EdmParameter bindingParameter = function.getParameter(function.getParameterNames().get(0));
  final EdmReturnType returnType = function.getReturnType();
  if (bindingParameter.getType().getKind() != EdmTypeKind.ENTITY
      && bindingParameter.getType().getKind() != EdmTypeKind.COMPLEX
      || !bindingParameter.isCollection()
      || returnType.getType().getKind() != EdmTypeKind.ENTITY
      && returnType.getType().getKind() != EdmTypeKind.COMPLEX
      || !returnType.isCollection()) {
    throw new UriParserSemanticException("Only entity- or complex-collection functions are allowed.",
        UriParserSemanticException.MessageKeys.FUNCTION_MUST_USE_COLLECTIONS,
        functionName.getFullQualifiedNameAsString());
  }

  return new CustomFunctionImpl().setFunction(function).setParameters(parameters);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:30,代码来源:ApplyParser.java

示例8: parseAliasValue

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,代码行数:31,代码来源:ParserHelper.java

示例9: writePropertyType

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,代码行数:36,代码来源:ODataJsonSerializer.java

示例10: EdmComplexTypeImpl

public EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final CsdlComplexType complexType) {
  super(edm, name, EdmTypeKind.COMPLEX, complexType);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:3,代码来源:EdmComplexTypeImpl.java

示例11: isReturnTypeComplex

public boolean isReturnTypeComplex() {
  return getReturnType().getType().getKind() == EdmTypeKind.COMPLEX;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:3,代码来源:OperationRequest.java


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