private EdmProperty getKeyProperty(EdmEntityType type, String name) throws EdmException { List<EdmProperty> keyProperties = type.getKeyProperties(); for (EdmProperty property : keyProperties) { if (property.getName().equals(name)) { return property; } } return null; }
private static boolean hasConcurrencyControl(final EdmEntityType entityType) throws EdmException { boolean concurrency = false; for (final String propertyName : entityType.getPropertyNames()) { final EdmFacets facets = ((EdmProperty) entityType.getProperty(propertyName)).getFacets(); if (facets != null && facets.getConcurrencyMode() != null && facets.getConcurrencyMode() == EdmConcurrencyMode.Fixed) { concurrency = true; break; } } return concurrency; }
private <T> Map<String, ODataCallback> getCallbacks(final T data, final EdmEntityType entityType) throws EdmException { final List<String> navigationPropertyNames = entityType.getNavigationPropertyNames(); if (navigationPropertyNames.isEmpty()) { return null; } else { final WriteCallback callback = new WriteCallback(data); Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>(); for (final String name : navigationPropertyNames) { callbacks.put(name, callback); } return callbacks; } }
private FullQualifiedName extractFQNameFromEntityType(final EdmEntityType entity) throws EntityProviderException, EdmException { return new FullQualifiedName(entity.getNamespace(), entity.getName()); }
private boolean containsCrossServiceNavigationProperty(EdmEntityType type, ODataEntry content) throws EdmException { HashSet<String> crossServiceNavigationPropertyNames = MashServiceRegistry.getCrossServiceNavigationPropertyNames(_service, MashServiceRegistry.getEntityTypeKey(type.getNamespace(), type.getName())); if (crossServiceNavigationPropertyNames == null) { return false; } Map<String, Object> properties = content.getProperties(); for (String key : properties.keySet()) { if (crossServiceNavigationPropertyNames.contains(key)) { return true; } Object value = properties.get(key); if (value instanceof ODataEntry) { EdmType targetType = type.getProperty(key).getType(); if (targetType instanceof EdmEntityType) { if (containsCrossServiceNavigationProperty((EdmEntityType) targetType, (ODataEntry) value)) { return true; } } } } return false; }
private void handleCustomLinks(final EdmEntityType entityType) throws EdmException { for (Map.Entry<String, ExpandSelectTreeNode> entry : customExpandedNavigationProperties.entrySet()) { EdmTyped navigationProperty = entityType.getProperty(entry.getKey()); if (navigationProperty == null) { throw new EdmException(EdmException.NAVIGATIONPROPERTYNOTFOUND.addContent(entry.getKey())); } if (!(navigationProperty instanceof EdmNavigationProperty)) { throw new EdmException(EdmException.MUSTBENAVIGATIONPROPERTY.addContent(entry.getKey())); } putLink(entry.getKey(), (ExpandSelectTreeNodeImpl) entry.getValue()); } }
@Override public List<String> getKeyNames() { try { return entityType.getKeyPropertyNames(); } catch (EdmException e) { return new ArrayList<String>(); } }
private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException { String fromRole = navigationProperty.getFromRole(); EdmEntityType fromEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType(); EdmMapping mapping = fromEntityType.getMapping(); String entityName = null; if (mapping != null) { entityName = mapping.getInternalName(); } else { entityName = fromEntityType.getName(); } return entityName; }
public Map<String, List<String>> getAllNavigationUUIDColumns(UriInfo uriInfo) throws EdmException{ Map<String, List<String>> navigationsUUIDs = new HashMap<>(); if(uriInfo.getEntityContainer() == null){ return navigationsUUIDs; } List<EdmEntitySet> entitySets = uriInfo.getEntityContainer().getEntitySets(); for(int i=0; i<entitySets.size(); i++){ EdmEntitySet entitySet = entitySets.get(i); EdmEntityType entityType = entitySet.getEntityType(); List<String> navigationProperties = entityType.getNavigationPropertyNames(); for(int j=0; j<navigationProperties.size(); j++){ EdmNavigationProperty navigationProperty = (EdmNavigationProperty) entityType.getProperty(navigationProperties.get(j)); EdmEntitySet navigatedEntitySet = entitySet.getRelatedEntitySet(navigationProperty); navigationsUUIDs.put(navigationProperty.getName(), this.getNavigationUUIDColumns(navigatedEntitySet)); } } return navigationsUUIDs; }
if (entitySet.getEntityType().hasStream()) {
@Override public List<String> getElementNames() { try { return entityType.getPropertyNames(); } catch (EdmException e) { return null; } }
public EntityMetadataV2(EdmEntitySet entitySet) throws EdmException { this.entitySet = entitySet; entityType = entitySet.getEntityType(); name = entitySet.getName(); namespace = entityType.getNamespace(); }
private void appendAtomEditLink(final XMLStreamWriter writer, final EntityInfoAggregator eia, final Map<String, Object> data, final String selfLink) throws EntityProviderException { try { writer.writeStartElement(FormatXml.ATOM_LINK); writer.writeAttribute(FormatXml.ATOM_HREF, selfLink); writer.writeAttribute(FormatXml.ATOM_REL, Edm.LINK_REL_EDIT); writer.writeAttribute(FormatXml.ATOM_TITLE, eia.getEntityType().getName()); writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
public ODataJPATombstoneEntityListener getODataJPATombstoneEntityListener(UriInfo uriParserResultView) throws InstantiationException, IllegalAccessException, EdmException { JPAEdmMapping mapping = (JPAEdmMapping) uriParserResultView.getTargetEntitySet().getEntityType().getMapping(); if (mapping.getODataJPATombstoneEntityListener() != null) { return (ODataJPATombstoneEntityListener) mapping.getODataJPATombstoneEntityListener().newInstance(); } return null; }
private void handleCustomLinks(final EdmEntityType entityType) throws EdmException { for (Map.Entry<String, ExpandSelectTreeNode> entry : customExpandedNavigationProperties.entrySet()) { EdmTyped navigationProperty = entityType.getProperty(entry.getKey()); if (navigationProperty == null) { throw new EdmException(EdmException.NAVIGATIONPROPERTYNOTFOUND.addContent(entry.getKey())); } if (!(navigationProperty instanceof EdmNavigationProperty)) { throw new EdmException(EdmException.MUSTBENAVIGATIONPROPERTY.addContent(entry.getKey())); } putLink(entry.getKey(), (ExpandSelectTreeNodeImpl) entry.getValue()); } }
/** * @return list of all key property infos * @throws EntityProviderException */ public List<EntityPropertyInfo> getKeyPropertyInfos() throws EntityProviderException { if (keyPropertyInfos == null) { try { keyPropertyInfos = new ArrayList<EntityPropertyInfo>(); for (String keyPropertyName : entityType.getKeyPropertyNames()) { keyPropertyInfos.add(propertyInfo.get(keyPropertyName)); } } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } } return keyPropertyInfos; }
private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException { String fromRole = navigationProperty.getFromRole(); EdmEntityType fromEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType(); EdmMapping mapping = fromEntityType.getMapping(); String entityName = null; if (mapping != null) { entityName = mapping.getInternalName(); } else { entityName = fromEntityType.getName(); } return entityName; }
private void handleNavigationPathOptions() throws UriSyntaxException, UriNotMatchingException, EdmException { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI16); // Count of multiple entities is handled elsewhere } else if ("$value".equals(currentPathSegment)) { if (uriResult.getTargetEntitySet().getEntityType().hasStream()) { ensureLastSegment(); uriResult.setUriType(UriType.URI17); uriResult.setValue(true); } else { throw new UriSyntaxException(UriSyntaxException.NOMEDIARESOURCE); } } else if ("$links".equals(currentPathSegment)) { uriResult.setLinks(true); if (pathSegments.isEmpty()) { throw new UriSyntaxException(UriSyntaxException.MUSTNOTBELASTSEGMENT.addContent(currentPathSegment)); } currentPathSegment = pathSegments.remove(0); handleNavigationProperties(); } else { handleNavigationProperties(); } }
private void writeProperties(final EntityInfoAggregator entityInfo, final Map<String, Object> data, final EdmEntityType type, boolean containsMetadata) throws EdmException, EntityProviderException, IOException { // if the payload contains metadata we must not omit the first comm as it separates the _metadata object form the // properties boolean omitComma = !containsMetadata; List<String> propertyNames = type.getPropertyNames(); for (final String propertyName : propertyNames) { if (data.containsKey(propertyName)) { omitComma = appendPropertyNameValue(entityInfo, data, omitComma, propertyName); } } }
private static String getEntitySetKey(EdmEntitySet set) throws EdmException { return set.getEntityType().getNamespace() + "~" + set.getEntityContainer().getName() + "~" + set.getName(); }