@Override public Map<String, Object> asJavaMap() { final Map<String, Object> result = new LinkedHashMap<String, Object>(); for (Map.Entry<String, ClientProperty> entry : fields.entrySet()) { Object value = null; if (entry.getValue().hasPrimitiveValue()) { value = entry.getValue().getPrimitiveValue().toValue(); } else if (entry.getValue().hasComplexValue()) { value = entry.getValue().getComplexValue().asJavaMap(); } else if (entry.getValue().hasCollectionValue()) { value = entry.getValue().getCollectionValue().asJavaCollection(); } else if (entry.getValue().hasEnumValue()) { value = entry.getValue().getEnumValue().toString(); } result.put(entry.getKey(), value); } return result; }
@Override public Map<String, Object> asJavaMap() { final Map<String, Object> result = new LinkedHashMap<String, Object>(); for (Map.Entry<String, ClientProperty> entry : fields.entrySet()) { Object value = null; if (entry.getValue().hasPrimitiveValue()) { value = entry.getValue().getPrimitiveValue().toValue(); } else if (entry.getValue().hasComplexValue()) { value = entry.getValue().getComplexValue().asJavaMap(); } else if (entry.getValue().hasCollectionValue()) { value = entry.getValue().getCollectionValue().asJavaCollection(); } else if (entry.getValue().hasEnumValue()) { value = entry.getValue().getEnumValue().toString(); } result.put(entry.getKey(), value); } return result; }
@Override public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest( final URI targetURI, final ClientProperty property) { if (!property.hasCollectionValue()) { throw new IllegalArgumentException("A collection value is required"); } final ODataPropertyUpdateRequest req; if (client.getConfiguration().isUseXHTTPMethod()) { req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.POST, targetURI, property); req.setXHTTPMethod(HttpMethod.PUT.name()); } else { req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.PUT, targetURI, property); } return req; }
@Override public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest( final URI targetURI, final ClientProperty property) { if (!property.hasCollectionValue()) { throw new IllegalArgumentException("A collection value is required"); } final ODataPropertyUpdateRequest req; if (client.getConfiguration().isUseXHTTPMethod()) { req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.POST, targetURI, property); req.setXHTTPMethod(HttpMethod.PUT.name()); } else { req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.PUT, targetURI, property); } return req; }
} else if (property.hasCollectionValue()) { final ParameterizedType collType = (ParameterizedType) getter.getGenericReturnType(); final Class<?> collItemClass = (Class<?>) collType.getActualTypeArguments()[0];
} else if (property.hasCollectionValue()) { final ParameterizedType collType = (ParameterizedType) getter.getGenericReturnType(); final Class<?> collItemClass = (Class<?>) collType.getActualTypeArguments()[0];
@SuppressWarnings("unchecked") @Override public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) { final ODataPropertyRequest<ClientProperty> req = getClient().getRetrieveRequestFactory().getPropertyRequest(uri); req.setPrefer(getClient().newPreferences().includeAnnotations("*")); final ODataRetrieveResponse<ClientProperty> res = req.execute(); final List<T> resItems = new ArrayList<T>(); final ClientProperty property = res.getBody(); if (property != null && property.hasCollectionValue()) { for (ClientValue item : (ClientCollectionValue<ClientValue>) property.getValue()) { Class<?> actualRef = null; if (StringUtils.isNotBlank(item.getTypeName())) { actualRef = service.getComplexTypeClass(item.getTypeName()); } if (actualRef == null) { actualRef = typeRef; } resItems.add((T) getComplex(property.getName(), item, actualRef, null, null, true)); } } return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>( resItems, null, Collections.<ClientAnnotation> emptyList()); } }
@SuppressWarnings("unchecked") @Override public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) { final ODataPropertyRequest<ClientProperty> req = getClient().getRetrieveRequestFactory().getPropertyRequest(uri); req.setPrefer(getClient().newPreferences().includeAnnotations("*")); final ODataRetrieveResponse<ClientProperty> res = req.execute(); final List<T> resItems = new ArrayList<T>(); final ClientProperty property = res.getBody(); if (property != null && property.hasCollectionValue()) { for (ClientValue item : (ClientCollectionValue<ClientValue>) property.getValue()) { Class<?> actualRef = null; if (StringUtils.isNotBlank(item.getTypeName())) { actualRef = service.getComplexTypeClass(item.getTypeName()); } if (actualRef == null) { actualRef = typeRef; } resItems.add((T) getComplex(property.getName(), item, actualRef, null, null, true)); } } return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>( resItems, null, Collections.<ClientAnnotation> emptyList()); } }