static EntityPropertyInfo create(final EdmProperty property) throws EdmException { return new EntityPropertyInfo( property.getName(), property.getType(), property.getFacets(), property.getCustomizableFeedMappings(), property.getMimeType(), property.getMapping()); }
static EntityComplexPropertyInfo create(final EdmProperty property, final List<String> propertyNames, final Map<String, EntityPropertyInfo> childEntityInfos) throws EdmException { List<EntityPropertyInfo> childEntityInfoList = new ArrayList<EntityPropertyInfo>(childEntityInfos.size()); for (String name : propertyNames) { childEntityInfoList.add(childEntityInfos.get(name)); } EntityComplexPropertyInfo info = new EntityComplexPropertyInfo( property.getName(), property.getType(), property.getFacets(), property.getCustomizableFeedMappings(), childEntityInfoList); return info; }
private List<KeyPredicate> getKeyPredicates(EdmEntityType entityType, Map<String, Object> result) throws EdmException { List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>(); for (EdmProperty keyProperty : entityType.getKeyProperties()) { Object value = result.get(keyProperty.getName()); EdmSimpleType edmSimpleType = (EdmSimpleType) keyProperty.getType(); String literal = edmSimpleType.valueToString(value, EdmLiteralKind.DEFAULT, keyProperty.getFacets()); keyPredicates.add(new GWKeyPredicate(literal, keyProperty)); } return keyPredicates; }
private List<KeyPredicate> getPropertyValuesAsKeyPredicates(EdmEntityType entityType, Map<String, Object> result, List<String> propertyNames) throws EdmException { List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>(); for(String property:propertyNames){ Object value = result.get(property); EdmProperty entityProperty = (EdmProperty) entityType.getProperty(property); EdmSimpleType edmSimpleType = (EdmSimpleType) entityProperty.getType(); String literal = edmSimpleType.valueToString(value, EdmLiteralKind.DEFAULT, entityProperty.getFacets()); keyPredicates.add(new GWKeyPredicate(literal, entityProperty)); } return keyPredicates; }
private String getGetterMethodName(final EdmProperty property) throws EdmException { final String prefix = isBooleanProperty(property) ? "is" : "get"; final String defaultMethodName = prefix + property.getName(); return property.getMapping() == null || property.getMapping().getInternalName() == null ? defaultMethodName : property.getMapping().getInternalName(); }
private <T> Map<String, Object> getStructuralTypeValueMap(final T data, final EdmStructuralType type) throws ODataException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeValueMap"); Map<String, Object> valueMap = new HashMap<String, Object>(); EdmMapping mapping = type.getMapping(); if (mapping != null) { handleMimeType(data, mapping, valueMap); } for (final String propertyName : type.getPropertyNames()) { final EdmProperty property = (EdmProperty) type.getProperty(propertyName); final Object value = valueAccess.getPropertyValue(data, property); if (property.isSimple()) { if (property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null) { valueMap.put(propertyName, value); } else { // TODO: enable MIME type mapping outside the current subtree valueMap.put(propertyName, getSimpleTypeValueMap(data, Arrays.asList(property))); } } else { valueMap.put(propertyName, getStructuralTypeValueMap(value, (EdmStructuralType) property.getType())); } } context.stopRuntimeMeasurement(timingHandle); return valueMap; }
final Object value = values.get(property.getName()); if (property.isSimple()) { valueAccess.setPropertyValue(data, property, value); } else { final Map<String, Object> propertyValue = (Map<String, Object>) value; setStructuralTypeValuesFromMap(valueAccess.getPropertyValue(data, property), (EdmStructuralType) property.getType(), propertyValue, merge);
private EdmProperty getEntityKey(List<EdmProperty> entityKeys, String key, boolean isDraft) throws EdmException { EdmProperty entityKeyProperty = null; for(EdmProperty property : entityKeys){ if(isDraft && DraftUtilsV2.DRAFTS_ISACTIVE_ENTITY.equals(property.getName())){ continue; } if(key.equals(property.getName())) { entityKeyProperty = property; } } return entityKeyProperty; }
private void checkETagRelevant(final EdmProperty edmProperty) throws EntityProviderException { try { if (edmProperty.getFacets() != null && edmProperty.getFacets().getConcurrencyMode() == EdmConcurrencyMode.Fixed) { etagPropertyNames.add(edmProperty.getName()); } } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
String propertyName = property.getName(); Method method = accessModifierMap.get(propertyName); if (method == null) { if (methodName != null) { boolean isVirtualAccess = false; if (property.getMapping() != null && property.getMapping() instanceof JPAEdmMappingImpl) { isVirtualAccess = ((JPAEdmMappingImpl) property.getMapping()).isVirtualAccess(); propertyValue = getPropertyValue(accessModifierMap.get(propertyName), propertyValue, propertyName); if (property.getType().getKind() .equals(EdmTypeKind.COMPLEX)) { propertyValue = parse2EdmPropertyValueMap(propertyValue, (EdmStructuralType) property.getType());
public static String getUUIDkeyPropertyName(EdmEntitySet entSet) throws EdmException { String refKeyName = null; EdmEntityType entType = entSet.getEntityType(); for(EdmProperty refs:entType.getKeyProperties()) { if(refs.getType().getName().equalsIgnoreCase("Guid")) { refKeyName = refs.getName(); break; } } return refKeyName; }
private static List<ContentType> getSupportedContentTypes(final EdmProperty property) throws EdmException { if (property != null) { return property.getType() == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ? Collections.singletonList(property.getMimeType() == null ? ContentType.WILDCARD : ContentType.create(property.getMimeType())) : Arrays.asList(ContentType.TEXT_PLAIN, ContentType.TEXT_PLAIN_CS_UTF_8); } else { return null; } }
private static String getPropertyName(final CommonExpression whereExpression) throws EdmException, ODataJPARuntimeException { EdmTyped edmProperty = ((PropertyExpression) whereExpression).getEdmProperty(); EdmMapping mapping; if (edmProperty instanceof EdmNavigationProperty) { EdmNavigationProperty edmNavigationProperty = (EdmNavigationProperty) edmProperty; mapping = edmNavigationProperty.getMapping(); } else if(edmProperty instanceof EdmProperty) { EdmProperty property = (EdmProperty) edmProperty; mapping = property.getMapping(); } else { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null); } return mapping != null ? mapping.getInternalName() : edmProperty.getName(); } }
private void appendProperty(EdmProperty property, String segmentValue) { try { state = property.getType().getKind() == EdmTypeKind.SIMPLE? SegmentType.SIMPLEPROPERTY : SegmentType.COMPLEXPROPERTY; } catch (EdmException e) { throw new RuntimeException("Unexpected EDM Exception: ", e);//NOSONAR } segments.add(new Segment(state, segmentValue)); }
responseContentType = simpleProperty.getMimeType(); if (uriInfo.isValue()) { response = EntityProvider.writePropertyValue(simpleProperty, content);
private void checkTargetPathInfo(final EdmProperty property, final EntityPropertyInfo propertyInfo) throws EntityProviderException { try { EdmCustomizableFeedMappings customizableFeedMappings = property.getCustomizableFeedMappings(); if (customizableFeedMappings != null) { String targetPath = customizableFeedMappings.getFcTargetPath(); targetPath2EntityPropertyInfo.put(targetPath, propertyInfo); if (!SYN_TARGET_PATHS.contains(targetPath)) { noneSyndicationTargetPaths.add(targetPath); } } } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
private static Map<String, Object> mapKey(final List<KeyPredicate> keys) throws EdmException { Map<String, Object> keyMap = new HashMap<String, Object>(); for (final KeyPredicate key : keys) { final EdmProperty property = key.getProperty(); final EdmSimpleType type = (EdmSimpleType) property.getType(); keyMap.put(property.getName(), type.valueOfString(key.getLiteral(), EdmLiteralKind.DEFAULT, property.getFacets(), type.getDefaultType())); } return keyMap; }
private String convertKeyValuesToString(Map<String, Object> keys, EdmEntityType entityType) throws EdmException { String keyPredicateString = ""; for (Entry<String, Object> e : keys.entrySet()) { if (!keyPredicateString.isEmpty()) keyPredicateString += ','; String key = e.getKey(); Object value = e.getValue(); EdmProperty prop = (EdmProperty) entityType.getProperty(key); EdmSimpleType type = (EdmSimpleType) (prop.getType()); String convertedValue = type .toUriLiteral(type.valueToString(value, EdmLiteralKind.DEFAULT, prop.getFacets())); keyPredicateString += key + '=' + convertedValue; } return keyPredicateString; }