本文整理汇总了Java中org.apache.olingo.commons.api.edm.constants.EdmTypeKind.ENTITY属性的典型用法代码示例。如果您正苦于以下问题:Java EdmTypeKind.ENTITY属性的具体用法?Java EdmTypeKind.ENTITY怎么用?Java EdmTypeKind.ENTITY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.olingo.commons.api.edm.constants.EdmTypeKind
的用法示例。
在下文中一共展示了EdmTypeKind.ENTITY属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleCountDispatching
private void handleCountDispatching(final ODataRequest request, final ODataResponse response,
final int lastPathSegmentIndex) throws ODataApplicationException, ODataLibraryException {
final UriResource resource = uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1);
if (resource instanceof UriResourceEntitySet
|| resource instanceof UriResourceNavigation
|| resource instanceof UriResourceFunction
&& ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.ENTITY) {
handler.selectProcessor(CountEntityCollectionProcessor.class)
.countEntityCollection(request, response, uriInfo);
} else if (resource instanceof UriResourcePrimitiveProperty
|| resource instanceof UriResourceFunction
&& ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.PRIMITIVE) {
handler.selectProcessor(CountPrimitiveCollectionProcessor.class)
.countPrimitiveCollection(request, response, uriInfo);
} else {
handler.selectProcessor(CountComplexCollectionProcessor.class)
.countComplexCollection(request, response, uriInfo);
}
}
示例2: parseTypeCast
protected static EdmStructuredType parseTypeCast(UriTokenizer tokenizer, final Edm edm,
final EdmStructuredType referencedType) throws UriParserException {
if (tokenizer.next(TokenKind.QualifiedName)) {
final FullQualifiedName qualifiedName = new FullQualifiedName(tokenizer.getText());
final EdmStructuredType type = referencedType.getKind() == EdmTypeKind.ENTITY ?
edm.getEntityType(qualifiedName) :
edm.getComplexType(qualifiedName);
if (type == null) {
throw new UriParserSemanticException("Type '" + qualifiedName + "' not found.",
UriParserSemanticException.MessageKeys.UNKNOWN_PART, qualifiedName.getFullQualifiedNameAsString());
} else {
if (!type.compatibleTo(referencedType)) {
throw new UriParserSemanticException("The type cast '" + qualifiedName + "' is not compatible.",
UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER, type.getName());
}
}
return type;
}
return null;
}
示例3: getResultReference
@SuppressWarnings("unchecked")
protected <RES extends ClientInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) {
Class<RES> result;
if (returnType == null) {
result = (Class<RES>) ClientNoContent.class;
} else {
if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (Class<RES>) ClientEntitySet.class;
} else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (Class<RES>) ClientEntity.class;
} else {
result = (Class<RES>) ClientProperty.class;
}
}
return result;
}
示例4: getResultReference
@SuppressWarnings("unchecked")
private <RES extends ClientInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) {
Class<RES> result;
if (returnType == null) {
result = (Class<RES>) ClientNoContent.class;
} else {
if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (Class<RES>) ClientEntitySet.class;
} else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (Class<RES>) ClientEntity.class;
} else {
result = (Class<RES>) ClientProperty.class;
}
}
return result;
}
示例5: createParameter
private Parameter createParameter(final JsonNode node, final String paramName, final EdmParameter edmParameter)
throws DeserializerException {
Parameter parameter = new Parameter();
parameter.setName(paramName);
if (node == null || node.isNull()) {
if (!edmParameter.isNullable()) {
throw new DeserializerException("Non-nullable parameter not present or null: " + paramName,
MessageKeys.INVALID_NULL_PARAMETER, paramName);
}
if (edmParameter.isCollection()) {
throw new DeserializerException("Collection must not be null for parameter: " + paramName,
MessageKeys.INVALID_NULL_PARAMETER, paramName);
}
parameter.setValue(ValueType.PRIMITIVE, null);
} else if (edmParameter.getType().getKind() == EdmTypeKind.ENTITY) {
if (edmParameter.isCollection()) {
EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().addAll(
consumeEntitySetArray((EdmEntityType) edmParameter.getType(), node, null));
parameter.setValue(ValueType.COLLECTION_ENTITY, entityCollection);
} else {
final Entity entity = consumeEntityNode((EdmEntityType) edmParameter.getType(), (ObjectNode) node, null);
parameter.setValue(ValueType.ENTITY, entity);
}
} else {
final Property property =
consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
edmParameter.isNullable(), edmParameter.getMaxLength(),
edmParameter.getPrecision(), edmParameter.getScale(), true, edmParameter.getMapping(), node);
parameter.setValue(property.getValueType(), property.getValue());
parameter.setType(property.getType());
}
return parameter;
}
示例6: getDerivedType
private EdmType getDerivedType(final EdmStructuredType edmType, final JsonNode jsonNode)
throws DeserializerException {
JsonNode odataTypeNode = jsonNode.get(Constants.JSON_TYPE);
if (odataTypeNode != null) {
String odataType = odataTypeNode.asText();
if (!odataType.isEmpty()) {
odataType = odataType.substring(1);
if (odataType.equalsIgnoreCase(edmType.getFullQualifiedName().getFullQualifiedNameAsString())) {
return edmType;
} else if (this.serviceMetadata == null) {
throw new DeserializerException(
"Failed to resolve Odata type " + odataType + " due to metadata is not available",
DeserializerException.MessageKeys.UNKNOWN_CONTENT);
}
final EdmStructuredType currentEdmType = edmType.getKind() == EdmTypeKind.ENTITY ?
serviceMetadata.getEdm().getEntityType(new FullQualifiedName(odataType)) :
serviceMetadata.getEdm().getComplexType(new FullQualifiedName(odataType));
if (!isAssignable(edmType, currentEdmType)) {
throw new DeserializerException("Odata type " + odataType + " not allowed here",
DeserializerException.MessageKeys.UNKNOWN_CONTENT);
}
return currentEdmType;
}
}
return edmType;
}
示例7: functionCall
private UriResource functionCall(final EdmFunctionImport edmFunctionImport,
final FullQualifiedName boundFunctionName, final FullQualifiedName bindingParameterTypeName,
final boolean isBindingParameterCollection) throws UriParserException, UriValidationException {
final List<UriParameter> parameters = ParserHelper.parseFunctionParameters(tokenizer, edm, null, false, aliases);
final List<String> names = ParserHelper.getParameterNames(parameters);
EdmFunction function = null;
if (edmFunctionImport != null) {
function = edmFunctionImport.getUnboundFunction(names);
if (function == null) {
throw new UriParserSemanticException(
"Function of function import '" + edmFunctionImport.getName() + "' "
+ "with parameters " + names.toString() + " not found.",
UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND, edmFunctionImport.getName(), names.toString());
}
} else {
function = edm.getBoundFunction(boundFunctionName,
bindingParameterTypeName, isBindingParameterCollection, names);
if (function == null) {
throw new UriParserSemanticException(
"Function " + boundFunctionName + " not found.",
UriParserSemanticException.MessageKeys.UNKNOWN_PART, boundFunctionName.getFullQualifiedNameAsString());
}
}
ParserHelper.validateFunctionParameters(function, parameters, edm, null, aliases);
UriResourceFunctionImpl resource = new UriResourceFunctionImpl(edmFunctionImport, function, parameters);
if (tokenizer.next(TokenKind.OPEN)) {
if (function.getReturnType() != null
&& function.getReturnType().getType().getKind() == EdmTypeKind.ENTITY
&& function.getReturnType().isCollection()) {
resource.setKeyPredicates(
ParserHelper.parseKeyPredicate(tokenizer,
(EdmEntityType) function.getReturnType().getType(), null, edm, null, aliases));
} else {
throw new UriParserSemanticException("A key is not allowed.",
UriParserSemanticException.MessageKeys.KEY_NOT_ALLOWED);
}
}
ParserHelper.requireTokenEnd(tokenizer);
return resource;
}
示例8: 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);
}
示例9: 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;
}
示例10: EdmEntityTypeImpl
public EdmEntityTypeImpl(final Edm edm, final FullQualifiedName name, final CsdlEntityType entityType) {
super(edm, name, EdmTypeKind.ENTITY, entityType);
this.entityType = entityType;
hasStream = entityType.hasStream();
}