本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmProperty.isCollection方法的典型用法代码示例。如果您正苦于以下问题:Java EdmProperty.isCollection方法的具体用法?Java EdmProperty.isCollection怎么用?Java EdmProperty.isCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.edm.EdmProperty
的用法示例。
在下文中一共展示了EdmProperty.isCollection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validatePropertyValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void validatePropertyValue(final Property property, final EdmProperty edmProperty,
final EdmBindingTarget edmBindingTarget, final List<String> path)
throws DataProviderException {
final ArrayList<String> newPath = new ArrayList<String>(path);
newPath.add(edmProperty.getName());
if (edmProperty.isCollection()) {
if (edmProperty.getType() instanceof EdmComplexType && property != null) {
for (final Object value : property.asCollection()) {
validateComplexValue((ComplexValue) value, edmBindingTarget,
(EdmComplexType) edmProperty.getType(), newPath);
}
}
} else if (edmProperty.getType() instanceof EdmComplexType) {
validateComplexValue((property == null) ? null : property.asComplex(), edmBindingTarget,
(EdmComplexType) edmProperty.getType(), newPath);
}
}
示例2: createProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private Property createProperty(final EdmProperty edmProperty, final String propertyName)
throws DataProviderException {
Property newProperty;
if (edmProperty.isPrimitive()) {
newProperty = edmProperty.isCollection() ? DataCreator.createPrimitiveCollection(propertyName)
: DataCreator.createPrimitive(propertyName, null);
} else if (edmProperty.isCollection()) {
@SuppressWarnings("unchecked")
Property newProperty2 = DataCreator.createComplexCollection(propertyName);
newProperty = newProperty2;
} else {
newProperty = DataCreator.createComplex(propertyName);
createProperties((EdmComplexType) edmProperty.getType(), newProperty.asComplex().getValue());
}
return newProperty;
}
示例3: validatePropertyValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void validatePropertyValue(final Property property, final EdmProperty edmProperty,
final EdmBindingTarget edmBindingTarget, final List<String> path) throws DataProviderException {
final ArrayList<String> newPath = new ArrayList<String>(path);
newPath.add(edmProperty.getName());
if (edmProperty.isCollection()) {
if (edmProperty.getType() instanceof EdmComplexType && property != null) {
for (final Object value : property.asCollection()) {
validateComplexValue((ComplexValue) value,
edmBindingTarget,
(EdmComplexType) edmProperty.getType(),
newPath);
}
}
} else if (edmProperty.getType() instanceof EdmComplexType) {
validateComplexValue((property == null) ? null : property.asComplex(),
edmBindingTarget,
(EdmComplexType) edmProperty.getType(),
newPath);
}
}
示例4: createProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的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;
}
示例5: validatePropertyOperations
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
throws UriValidationException {
final List<UriResource> parts = uriInfo.getUriResourceParts();
final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null;
final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null;
if (last != null
&& (last.getKind() == UriResourceKind.primitiveProperty
|| last.getKind() == UriResourceKind.complexProperty
|| (last.getKind() == UriResourceKind.value
&& previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
final EdmProperty property = ((UriResourceProperty)
(last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
if (method == HttpMethod.PATCH && property.isCollection()) {
throw new UriValidationException("Attempt to patch collection property.",
UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
}
if (method == HttpMethod.DELETE && !property.isNullable()) {
throw new UriValidationException("Attempt to delete non-nullable property.",
UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
}
}
}
示例6: updateProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
@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);
}
}
}
示例7: updateProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的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);
}
}
}
示例8: writeProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
protected void writeProperty(final ServiceMetadata metadata,
final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths, final JsonGenerator json)
throws IOException, SerializerException {
boolean isStreamProperty = isStreamProperty(edmProperty);
writePropertyType(edmProperty, json);
if (!isStreamProperty) {
json.writeFieldName(edmProperty.getName());
}
if (property == null || property.isNull()) {
if (edmProperty.isNullable() == Boolean.FALSE && !isStreamProperty) {
throw new SerializerException("Non-nullable property not present!",
SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
} else {
if (!isStreamProperty) {
if (edmProperty.isCollection()) {
json.writeStartArray();
json.writeEndArray();
} else {
json.writeNull();
}
}
}
} else {
writePropertyValue(metadata, edmProperty, property, selectedPaths, json);
}
}
示例9: writePropertyType
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的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());
}
}
示例10: writePropertyValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的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());
}
}
示例11: writePropertyValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的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());
}
}
示例12: toProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Property toProperty(
String propertyName, Object sourceValue, EdmProperty description) {
ValueType valueType;
Object value;
EdmTypeKind kind = description.getType().getKind();
switch (kind) {
case COMPLEX:
if (description.isCollection()) {
valueType = ValueType.COLLECTION_COMPLEX;
value = toCollection(
(EdmComplexType) description.getType(), sourceValue);
} else if (sourceValue instanceof List) {
valueType = ValueType.COMPLEX;
List<Map<String, Object>> list = (List<Map<String, Object>>) sourceValue;
if (list.isEmpty()) {
value = null;
} else {
log.warn("Discarded all elements from list {} except first", propertyName);
value = toComplexValue(
(EdmComplexType) description.getType(), list.get(0));
}
} else {
valueType = ValueType.COMPLEX;
value = toComplexValue(
(EdmComplexType) description.getType(), (Map<String, Object>) sourceValue);
}
break;
case PRIMITIVE:
valueType = ValueType.PRIMITIVE;
if (description.getType() instanceof EdmBinary) {
value = toByteArray((String) sourceValue);
} else if (description.getType() instanceof EdmDateTimeOffset) {
value = toDate((String) sourceValue);
} else if (description.getType() instanceof EdmGeographyPoint) {
value = toPoint((Map<String, Double>) sourceValue);
} else {
value = sourceValue;
}
break;
default:
throw new UnsupportedOperationException("Cannot convert from EdmTypeKind " + kind);
}
return new Property(null, propertyName, valueType, value);
}
示例13: appendProperties
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void appendProperties(final JsonGenerator json,
final EdmStructuredType type) throws SerializerException, IOException {
List<String> propertyNames = new ArrayList<String>(type.getPropertyNames());
if (type.getBaseType() != null) {
propertyNames.removeAll(type.getBaseType().getPropertyNames());
}
for (String propertyName : propertyNames) {
EdmProperty property = type.getStructuralProperty(propertyName);
json.writeObjectFieldStart(propertyName);
String fqnString;
if (property.isPrimitive()) {
fqnString = getFullQualifiedName(property.getType());
} else {
fqnString = getAliasedFullQualifiedName(property.getType());
}
json.writeStringField(TYPE, fqnString);
if (property.isCollection()) {
json.writeBooleanField(COLLECTION, property.isCollection());
}
// Facets
if (!property.isNullable()) {
json.writeBooleanField(NULLABLE, property.isNullable());
}
if (!property.isUnicode()) {
json.writeBooleanField(UNICODE, property.isUnicode());
}
if (property.getDefaultValue() != null) {
json.writeStringField(DEFAULT_VALUE, property.getDefaultValue());
}
if (property.getMaxLength() != null) {
json.writeNumberField(MAX_LENGTH, property.getMaxLength());
}
if (property.getPrecision() != null) {
json.writeNumberField(PRECISION, property.getPrecision());
}
if (property.getScale() != null) {
json.writeNumberField(SCALE, property.getScale());
}
appendAnnotations(json, property, null);
json.writeEndObject();
}
}
示例14: writePropertyValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入方法依赖的package包/类
private void writePropertyValue(final ServiceMetadata metadata,
final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths,
final String xml10InvalidCharReplacement, final XMLStreamWriter writer)
throws XMLStreamException, SerializerException {
try {
if (edmProperty.isPrimitive()
|| edmProperty.getType().getKind() == EdmTypeKind.ENUM
|| edmProperty.getType().getKind() == EdmTypeKind.DEFINITION) {
if (edmProperty.isCollection()) {
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE,
edmProperty.isPrimitive() ?
"#Collection(" + edmProperty.getType().getName() + ")" :
collectionType(edmProperty.getType()));
writePrimitiveCollection((EdmPrimitiveType) edmProperty.getType(), property,
edmProperty.isNullable(), edmProperty.getMaxLength(),
edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
xml10InvalidCharReplacement,writer);
} else {
writePrimitive((EdmPrimitiveType) edmProperty.getType(), property,
edmProperty.isNullable(), edmProperty.getMaxLength(),
edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
xml10InvalidCharReplacement, writer);
}
} else if (property.isComplex()) {
if (edmProperty.isCollection()) {
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, collectionType(edmProperty.getType()));
writeComplexCollection(metadata, (EdmComplexType) edmProperty.getType(), property, selectedPaths,
xml10InvalidCharReplacement, writer);
} else {
writeComplex(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer);
}
} 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());
}
}