本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmType类的典型用法代码示例。如果您正苦于以下问题:Java EdmType类的具体用法?Java EdmType怎么用?Java EdmType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmType类属于org.apache.olingo.commons.api.edm包,在下文中一共展示了EdmType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseOrderByOption
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private void parseOrderByOption(OrderByOption orderByOption, final EdmType contextType,
final List<String> entitySetNames, final Map<String, AliasQueryOption> aliases)
throws UriParserException, UriValidationException {
if (orderByOption != null) {
final String optionValue = orderByOption.getText();
UriTokenizer orderByTokenizer = new UriTokenizer(optionValue);
final OrderByOption option = new OrderByParser(edm, odata).parse(orderByTokenizer,
contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null,
entitySetNames,
aliases);
checkOptionEOF(orderByTokenizer, orderByOption.getName(), optionValue);
for (final OrderByItem item : option.getOrders()) {
((OrderByOptionImpl) orderByOption).addOrder(item);
}
}
}
示例2: 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;
}
示例3: getContextUrl
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private ContextURL getContextUrl(final EdmEntitySet entitySet, final Entity entity, final List<String> path,
final EdmType type, final RepresentationType representationType,
final ExpandOption expand, final SelectOption select) throws ODataLibraryException {
final UriHelper helper = odata.createUriHelper();
Builder builder = ContextURL.with();
builder = entitySet == null ?
representationType == RepresentationType.PRIMITIVE || representationType == RepresentationType.COMPLEX ?
builder.type(type) :
builder.type(type).asCollection() :
builder.entitySet(entitySet).keyPath(helper.buildKeyPredicate(entitySet.getEntityType(), entity));
if (entitySet != null && !path.isEmpty()) {
builder = builder.navOrPropertyPath(buildPropertyPath(path));
}
builder = builder.selectList(
type.getKind() == EdmTypeKind.PRIMITIVE
|| type.getKind() == EdmTypeKind.ENUM
|| type.getKind() == EdmTypeKind.DEFINITION ?
null :
helper.buildContextURLSelectList((EdmStructuredType) type, expand, select));
return builder.build();
}
示例4: compatibleTo
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
@Override
public boolean compatibleTo(final EdmType targetType) {
EdmStructuredType sourceType = this;
if (targetType == null) {
throw new EdmException("Target type must not be null");
}
while (!sourceType.getName().equals(targetType.getName())
|| !sourceType.getNamespace().equals(targetType.getNamespace())) {
sourceType = sourceType.getBaseType();
if (sourceType == null) {
return false;
}
}
return true;
}
示例5: collection
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private void collection(final JsonGenerator json, final EdmType itemType, final String typeName,
final EdmProperty edmProperty, final ValueType valueType, final List<?> value)
throws IOException, SerializerException {
json.writeStartArray();
for (final Object item : value) {
switch (valueType) {
case COLLECTION_PRIMITIVE:
primitiveValue(json, (EdmPrimitiveType) itemType, typeName, edmProperty, item);
break;
case COLLECTION_GEOSPATIAL:
case COLLECTION_ENUM:
throw new SerializerException("Geo and enum types are not supported.", MessageKeys.NOT_IMPLEMENTED);
case COLLECTION_COMPLEX:
complexValue(json, (EdmComplexType) itemType, typeName, (ComplexValue) item);
break;
default:
}
}
json.writeEndArray();
}
示例6: getTypeReturnsComplexType
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
@Test
public void getTypeReturnsComplexType() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName complexTypeName = new FullQualifiedName("ns", "complex");
CsdlComplexType complexTypeProvider = new CsdlComplexType();
when(provider.getComplexType(complexTypeName)).thenReturn(complexTypeProvider);
CsdlParameter parameterProvider = new CsdlParameter();
parameterProvider.setType(complexTypeName);
final EdmParameter parameter = new EdmParameterImpl(edm, parameterProvider);
assertFalse(parameter.isCollection());
final EdmType type = parameter.getType();
assertEquals(EdmTypeKind.COMPLEX, type.getKind());
assertEquals("ns", type.getNamespace());
assertEquals("complex", type.getName());
}
示例7: getTypeInformation
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
protected static EdmType getTypeInformation(final UriResourcePartTyped resourcePart) {
EdmType type = null;
if (resourcePart instanceof UriResourceWithKeysImpl) {
final UriResourceWithKeysImpl lastPartWithKeys = (UriResourceWithKeysImpl) resourcePart;
if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
type = lastPartWithKeys.getTypeFilterOnEntry();
} else if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
type = lastPartWithKeys.getTypeFilterOnCollection();
} else {
type = lastPartWithKeys.getType();
}
} else if (resourcePart instanceof UriResourceTypedImpl) {
final UriResourceTypedImpl lastPartTyped = (UriResourceTypedImpl) resourcePart;
type = lastPartTyped.getTypeFilter() == null ?
lastPartTyped.getType() :
lastPartTyped.getTypeFilter();
} else {
type = resourcePart.getType();
}
return type;
}
示例8: 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;
}
示例9: createUriParameter
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private static UriParameter createUriParameter(final EdmProperty edmProperty, final String parameterName,
final String literalValue, final Edm edm, final EdmType referringType,
final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException {
final AliasQueryOption alias = literalValue.startsWith("@") ?
getKeyAlias(literalValue, edmProperty, edm, referringType, aliases) :
null;
final String value = alias == null ? literalValue : alias.getText();
final EdmPrimitiveType primitiveType = (EdmPrimitiveType) edmProperty.getType();
try {
if (!(primitiveType.validate(primitiveType.fromUriLiteral(value), edmProperty.isNullable(),
edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode()))) {
throw new UriValidationException("Invalid key property",
UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, parameterName);
}
} catch (final EdmPrimitiveTypeException e) {
throw new UriValidationException("Invalid key property", e,
UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, parameterName);
}
return new UriParameterImpl()
.setName(parameterName)
.setText("null".equals(literalValue) ? null : literalValue)
.setAlias(alias == null ? null : literalValue)
.setExpression(alias == null ? null :
alias.getValue() == null ? new LiteralImpl(value, primitiveType) : alias.getValue());
}
示例10: getODataAnnotation
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
public static ClientAnnotation getODataAnnotation(
final EdmEnabledODataClient client, final String term, final EdmType type, final Object obj) {
ClientAnnotation annotation;
if (obj == null) {
annotation = new ClientAnnotationImpl(term, null);
} else {
final EdmTypeInfo valueType = type == null
? guessTypeFromObject(client, obj)
: new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).
setTypeExpression(type.getFullQualifiedName().toString()).build();
annotation = new ClientAnnotationImpl(term, getODataValue(client, valueType, obj));
}
return annotation;
}
示例11: 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;
}
示例12: getODataProperty
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private static ClientProperty getODataProperty(
final EdmEnabledODataClient client,
final EdmElement edmProperty,
final String property,
final Object obj) {
final EdmTypeInfo type;
if (edmProperty == null) {
// maybe opentype ...
type = null;
} else {
final EdmType edmType = edmProperty.getType();
type = new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(
edmProperty.isCollection()
? "Collection(" + edmType.getFullQualifiedName().toString() + ")"
: edmType.getFullQualifiedName().toString()).build();
}
return getODataProperty(client, property, type, obj);
}
示例13: keyValuePair
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private static UriParameter keyValuePair(UriTokenizer tokenizer,
final String keyPredicateName, final EdmEntityType edmEntityType,
final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases)
throws UriParserException, UriValidationException {
final EdmKeyPropertyRef keyPropertyRef = edmEntityType.getKeyPropertyRef(keyPredicateName);
final EdmProperty edmProperty = keyPropertyRef == null ? null : keyPropertyRef.getProperty();
if (edmProperty == null) {
throw new UriValidationException(keyPredicateName + " is not a valid key property name.",
UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, keyPredicateName);
}
ParserHelper.requireNext(tokenizer, TokenKind.EQ);
if (tokenizer.next(TokenKind.COMMA) || tokenizer.next(TokenKind.CLOSE) || tokenizer.next(TokenKind.EOF)) {
throw new UriParserSyntaxException("Key value expected.", UriParserSyntaxException.MessageKeys.SYNTAX);
}
if (nextPrimitiveTypeValue(tokenizer, (EdmPrimitiveType) edmProperty.getType(), edmProperty.isNullable())) {
return createUriParameter(edmProperty, keyPredicateName, tokenizer.getText(), edm, referringType, aliases);
} else {
throw new UriParserSemanticException(keyPredicateName + " has not a valid key value.",
UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, keyPredicateName);
}
}
示例14: parseApplyOption
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private void parseApplyOption(ApplyOption applyOption, EdmType contextType,
final List<String> entitySetNames, final Map<String, AliasQueryOption> aliases)
throws UriParserException, UriValidationException {
if (applyOption != null) {
final String optionValue = applyOption.getText();
UriTokenizer applyTokenizer = new UriTokenizer(optionValue);
final ApplyOption option = new ApplyParser(edm, odata).parse(applyTokenizer,
contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null,
entitySetNames,
aliases);
checkOptionEOF(applyTokenizer, applyOption.getName(), optionValue);
for (final ApplyItem item : option.getApplyItems()) {
((ApplyOptionImpl) applyOption).add(item);
}
}
}
示例15: parseFunction
import org.apache.olingo.commons.api.edm.EdmType; //导入依赖的package包/类
private void parseFunction(final FullQualifiedName fullQualifiedName, UriInfoImpl uriInfo,
final EdmType lastType, final boolean lastIsCollection) throws UriParserException, UriValidationException {
final List<UriParameter> parameters =
ParserHelper.parseFunctionParameters(tokenizer, edm, referringType, true, aliases);
final List<String> parameterNames = ParserHelper.getParameterNames(parameters);
final EdmFunction boundFunction = edm.getBoundFunction(fullQualifiedName,
lastType.getFullQualifiedName(), lastIsCollection, parameterNames);
if (boundFunction != null) {
ParserHelper.validateFunctionParameters(boundFunction, parameters, edm, referringType, aliases);
parseFunctionRest(uriInfo, boundFunction, parameters);
return;
}
final EdmFunction unboundFunction = edm.getUnboundFunction(fullQualifiedName, parameterNames);
if (unboundFunction != null) {
ParserHelper.validateFunctionParameters(unboundFunction, parameters, edm, referringType, aliases);
parseFunctionRest(uriInfo, unboundFunction, parameters);
return;
}
throw new UriParserSemanticException("No function '" + fullQualifiedName + "' found.",
UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND, fullQualifiedName.getFullQualifiedNameAsString());
}