private static String getValueAsString(String key, ClientEntity transport) { ClientProperty property = transport.getProperty(key); if(property == null) return null; ClientValue value = property.getValue(); if(value == null) return null; return value.toString(); }
private static String getValueAsString(String key, ClientEntity transport) { ClientProperty property = transport.getProperty(key); if(property == null) return null; ClientValue value = property.getValue(); if(value == null) return null; return value.toString(); }
@Override protected void load() { try { if (this.uri != null) { final ODataPropertyRequest<ClientProperty> req = getClient().getRetrieveRequestFactory().getPropertyRequest(uri.build()); final ODataRetrieveResponse<ClientProperty> res = req.execute(); this.internal = res.getBody().getValue(); } } catch (IllegalArgumentException e) { LOG.warn("Complex at '" + uri + "' not found", e); throw e; } catch (Exception e) { LOG.warn("Error retrieving complex '" + uri + "'", e); throw new IllegalArgumentException("Error retrieving " + typeRef.getSimpleName(), e); } }
@Override protected void load() { try { if (this.uri != null) { final ODataPropertyRequest<ClientProperty> req = getClient().getRetrieveRequestFactory().getPropertyRequest(uri.build()); final ODataRetrieveResponse<ClientProperty> res = req.execute(); this.internal = res.getBody().getValue(); } } catch (IllegalArgumentException e) { LOG.warn("Complex at '" + uri + "' not found", e); throw e; } catch (Exception e) { LOG.warn("Error retrieving complex '" + uri + "'", e); throw new IllegalArgumentException("Error retrieving " + typeRef.getSimpleName(), e); } }
response = request.execute(); ClientEntity body = response.getBody(); String changeId = body.getProperty("ChangeID").getValue().toString(); if(!changeID.equals(changeId)) throw new RuntimeException( format("ChangeId contained in server response ('%s') does not match request change (%s).", changeId, changeID)); boolean isInDevelopment = Boolean.valueOf(body.getProperty("IsInDevelopment").getValue().toString()); logger.debug(format("Change '%s' found. isInDevelopment: '%b'", changeID, isInDevelopment)); return new CMODataChange(changeID, isInDevelopment);
response = request.execute(); ClientEntity body = response.getBody(); String changeId = body.getProperty("ChangeID").getValue().toString(); if(!changeID.equals(changeId)) throw new RuntimeException( format("ChangeId contained in server response ('%s') does not match request change (%s).", changeId, changeID)); boolean isInDevelopment = Boolean.valueOf(body.getProperty("IsInDevelopment").getValue().toString()); logger.debug(format("Change '%s' found. isInDevelopment: '%b'", changeID, isInDevelopment)); return new CMODataChange(changeID, isInDevelopment);
res = getComplex( name, property == null || property.hasNullValue() ? null : property.getValue(), ref, getEntityHandler(), List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(getComplex( name, } else { List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(item.asPrimitive().toValue()); res = property == null || property.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(property.getValue(), type, service);
ComplexInvocationHandler.getInstance(typeHandler, getter.getReturnType())); populate(client, typeHandler, complex, Property.class, property.getValue().asComplex().iterator()); setPropertyValue(bean, getter, complex); } else if (property.hasCollectionValue()) { final Iterator<ClientValue> collPropItor = property.getValue().asCollection().iterator(); while (collPropItor.hasNext()) { final ClientValue value = collPropItor.next();
res = getComplex( name, property == null || property.hasNullValue() ? null : property.getValue(), ref, getEntityHandler(), List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(getComplex( name, } else { List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(item.asPrimitive().toValue()); res = property == null || property.hasNullValue() ? null : CoreUtils.getObjectFromODataValue(property.getValue(), type, service);
ComplexInvocationHandler.getInstance(typeHandler, getter.getReturnType())); populate(client, typeHandler, complex, Property.class, property.getValue().asComplex().iterator()); setPropertyValue(bean, getter, complex); } else if (property.hasCollectionValue()) { final Iterator<ClientValue> collPropItor = property.getValue().asCollection().iterator(); while (collPropItor.hasNext()) { final ClientValue value = collPropItor.next();
@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()); } }
final List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(ProxyUtils.getComplexProxy( service, final List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(item.asPrimitive().toValue()); if (returnType.isComplexType()) { res = ProxyUtils.getComplexProxy( service, property.getName(), property.getValue().asComplex(), ref, null, null, false); } else { res = CoreUtils.getObjectFromODataValue(property.getValue(), targetRef, service);
final List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(ProxyUtils.getComplexProxy( service, final List items = new ArrayList(); for (ClientValue item : property.getValue().asCollection()) { items.add(item.asPrimitive().toValue()); if (returnType.isComplexType()) { res = ProxyUtils.getComplexProxy( service, property.getName(), property.getValue().asComplex(), ref, null, null, false); } else { res = CoreUtils.getObjectFromODataValue(property.getValue(), targetRef, service);