Java Code Examples for org.apache.olingo.commons.api.data.ValueType#COLLECTION_COMPLEX
The following examples show how to use
org.apache.olingo.commons.api.data.ValueType#COLLECTION_COMPLEX .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionData.java From olingo-odata4 with Apache License 2.0 | 6 votes |
protected static Property complexCollectionAction(final String name, final Map<String, Parameter> parameters) throws DataProviderException { if ("UARTCollCTTwoPrimParam".equals(name)) { List<ComplexValue> complexCollection = new ArrayList<ComplexValue>(); final Parameter paramInt16 = parameters.get("ParameterInt16"); final Short number = paramInt16 == null || paramInt16.isNull() ? 0 : (Short) paramInt16.asPrimitive(); if (number >= 1) { complexCollection.add(createCTTwoPrimComplexProperty("PropertyComp", (short) 16, "Test123").asComplex()); } if (number >= 2) { complexCollection.add(createCTTwoPrimComplexProperty("PropertyComp", (short) 17, "Test456").asComplex()); } if (number >= 3) { complexCollection.add(createCTTwoPrimComplexProperty("PropertyComp", (short) 18, "Test678").asComplex()); } return new Property("PropertyCollComp", name, ValueType.COLLECTION_COMPLEX, complexCollection); } throw new DataProviderException("Action " + name + " is not yet implemented.", HttpStatusCode.NOT_IMPLEMENTED); }
Example 2
Source File: DataCreator.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private Property createComplexDerievedCollection(final String name, String type, final List<ComplexValue> list) { List<ComplexValue> complexCollection = new ArrayList<ComplexValue>(); complexCollection.addAll(list); Property property = new Property(type, name, ValueType.COLLECTION_COMPLEX, complexCollection); createOperations(name, type, property); return property; }
Example 3
Source File: DataCreator.java From olingo-odata4 with Apache License 2.0 | 5 votes |
protected static Property createComplexCollection(final String name, String type, final List<Property>... propertiesList) { List<ComplexValue> complexCollection = new ArrayList<ComplexValue>(); for (final List<Property> properties : propertiesList) { ComplexValue complexValue = new ComplexValue(); complexValue.getValue().addAll(properties); if (null != name) { complexValue.setId(URI.create(name)); } complexCollection.add(complexValue); } Property property = new Property(type, name, ValueType.COLLECTION_COMPLEX, complexCollection); createOperations(name, type, property); return property; }
Example 4
Source File: ODataXmlDeserializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private ValueType getValueType(final EdmType edmType, final boolean isCollection) { if (edmType instanceof EdmPrimitiveType) { if (edmType instanceof EdmEnumType) { return isCollection ? ValueType.COLLECTION_ENUM : ValueType.ENUM; } else { return isCollection ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE; } } else if (edmType instanceof EdmComplexType) { return isCollection ? ValueType.COLLECTION_COMPLEX : ValueType.COMPLEX; } else { return ValueType.PRIMITIVE; } }
Example 5
Source File: ResponseUtil.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public static Property createComplexCollection(final String name, final String type, final List<Property>... propertiesList) { List<ComplexValue> complexCollection = new ArrayList<ComplexValue>(); for (final List<Property> properties : propertiesList) { ComplexValue complexValue = new ComplexValue(); complexValue.getValue().addAll(properties); complexCollection.add(complexValue); } return new Property(type, name, ValueType.COLLECTION_COMPLEX, complexCollection); }
Example 6
Source File: ODataBinderImpl.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void updateValuable(final Valuable propertyResource, final ClientValuable odataValuable) { final Object propertyValue = getValue(odataValuable.getValue()); if (odataValuable.hasPrimitiveValue()) { propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName()); propertyResource.setValue( propertyValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE, propertyValue); } else if (odataValuable.hasEnumValue()) { propertyResource.setType(odataValuable.getEnumValue().getTypeName()); propertyResource.setValue(ValueType.ENUM, propertyValue); } else if (odataValuable.hasComplexValue()) { propertyResource.setType(odataValuable.getComplexValue().getTypeName()); propertyResource.setValue(ValueType.COMPLEX, propertyValue); } else if (odataValuable.hasCollectionValue()) { final ClientCollectionValue<ClientValue> collectionValue = odataValuable.getCollectionValue(); propertyResource.setType(collectionValue.getTypeName()); final ClientValue value = collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null; ValueType valueType = ValueType.COLLECTION_PRIMITIVE; if (value == null) { valueType = ValueType.COLLECTION_PRIMITIVE; } else if (value.isPrimitive()) { valueType = value.asPrimitive().toValue() instanceof Geospatial ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE; } else if (value.isEnum()) { valueType = ValueType.COLLECTION_ENUM; } else if (value.isComplex()) { valueType = ValueType.COLLECTION_COMPLEX; } propertyResource.setValue(valueType, propertyValue); } }
Example 7
Source File: AtomDeserializer.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void fromCollection(final Valuable valuable, final XMLEventReader reader, final StartElement start, final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException { List<Object> values = new ArrayList<>(); ValueType valueType = ValueType.COLLECTION_PRIMITIVE; final EdmTypeInfo type = typeInfo == null ? null : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build(); boolean foundEndProperty = false; while (reader.hasNext() && !foundEndProperty) { final XMLEvent event = reader.nextEvent(); if (event.isStartElement()) { switch (guessPropertyType(reader, typeInfo)) { case COMPLEX: final Object complexValue = fromComplexOrEnum(reader, event.asStartElement()); valueType = ValueType.COLLECTION_COMPLEX; final Attribute typeAttr = event.asStartElement().getAttributeByName(typeQName); final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue(); final EdmTypeInfo typeInfoEle = StringUtils.isBlank(typeAttrValue) ? null : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build(); if (typeInfoEle != null) { ((ComplexValue)complexValue).setTypeName(typeInfoEle.external()); } values.add(complexValue); break; case ENUM: valueType = ValueType.COLLECTION_ENUM; values.add(fromComplexOrEnum(reader, event.asStartElement())); break; case PRIMITIVE: final Object value = fromPrimitive(reader, event.asStartElement(), type); valueType = value instanceof Geospatial ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE; values.add(value); break; default: // do not add null or empty values } } if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) { foundEndProperty = true; } } valuable.setValue(valueType, values); }