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)); }
private EntityPropertyInfo createEntityPropertyInfo(final EdmFunctionImport functionImport, final EdmType type) throws EdmException, EntityProviderException { EntityPropertyInfo epi; if (type.getKind() == EdmTypeKind.COMPLEX) { EdmComplexType complex = (EdmComplexType) type; Map<String, EntityPropertyInfo> eia = EntityInfoAggregator.create(complex); List<EntityPropertyInfo> childEntityInfoList = new ArrayList<EntityPropertyInfo>(); for (String propertyName : complex.getPropertyNames()) { childEntityInfoList.add(eia.get(propertyName)); } epi = new EntityComplexPropertyInfo(functionImport.getName(), type, null, null, childEntityInfoList); } else if (type.getKind() == EdmTypeKind.SIMPLE) { epi = new EntityPropertyInfo(functionImport.getName(), type, null, null, null, null); } else { throw new EntityProviderException(EntityProviderException.UNSUPPORTED_PROPERTY_TYPE.addContent(type.getKind())); } return epi; }
private EntityPropertyInfo createEntityPropertyInfo(final EdmFunctionImport functionImport, final EdmType type) throws EdmException, EntityProviderException { EntityPropertyInfo epi; if (type.getKind() == EdmTypeKind.COMPLEX) { EdmComplexType complex = (EdmComplexType) type; Map<String, EntityPropertyInfo> eia = EntityInfoAggregator.create(complex); List<EntityPropertyInfo> childEntityInfoList = new ArrayList<EntityPropertyInfo>(); for (String propertyName : complex.getPropertyNames()) { childEntityInfoList.add(eia.get(propertyName)); } epi = new EntityComplexPropertyInfo(functionImport.getName(), type, null, null, childEntityInfoList); } else if (type.getKind() == EdmTypeKind.SIMPLE) { epi = new EntityPropertyInfo(functionImport.getName(), type, null, null, null, null); } else { throw new EntityProviderException(EntityProviderException.UNSUPPORTED_PROPERTY_TYPE.addContent(type.getKind())); } return epi; }
private EntityPropertyInfo createEntityPropertyInfo(final EdmFunctionImport functionImport, final EdmType type) throws EdmException, EntityProviderException { EntityPropertyInfo epi; if (type.getKind() == EdmTypeKind.COMPLEX) { EdmComplexType complex = (EdmComplexType) type; Map<String, EntityPropertyInfo> eia = EntityInfoAggregator.create(complex); List<EntityPropertyInfo> childEntityInfoList = new ArrayList<EntityPropertyInfo>(); for (String propertyName : complex.getPropertyNames()) { childEntityInfoList.add(eia.get(propertyName)); } epi = new EntityComplexPropertyInfo(functionImport.getName(), type, null, null, childEntityInfoList); } else if (type.getKind() == EdmTypeKind.SIMPLE) { epi = new EntityPropertyInfo(functionImport.getName(), type, null, null, null, null); } else { throw new EntityProviderException(EntityProviderException.UNSUPPORTED_PROPERTY_TYPE.addContent(type.getKind())); } return epi; }
@Override public ElementType getElementType(String elementName) { try { if(entityType.getProperty(elementName).getType().getKind().equals(EdmTypeKind.COMPLEX)) return ElementType.STRUCTURED_TYPE; } catch (EdmException e) { return null; } return ElementType.SIMPLE_TYPE; }
@Override public EdmURIBuilder appendFunctionImportSegment(EdmFunctionImport functionImport) { try { state = functionImport.getReturnType() != null ? (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY && functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY ? SegmentType.FUNCTIONIMPORT_MANY : SegmentType.FUNCTIONIMPORT) : SegmentType.FUNCTIONIMPORT; segments.add(new Segment(state, functionImport.getName())); } catch (EdmException e) { throw new RuntimeException("Unexpected EDM Exception: ", e);//NOSONAR } return this; }
private List<String> getNavigationUUIDColumns(EdmEntitySet navigatedEntitySet) throws EdmException{ List<String> coloumnNames = new ArrayList<>(); List<String> propertNames = null; EdmStructuralType entityType = null; if(navigatedEntitySet != null){ entityType = navigatedEntitySet.getEntityType(); propertNames = entityType.getPropertyNames(); } if(entityType != null){ for (String propertyName : propertNames) { EdmTyped property = entityType.getProperty(propertyName) ; if (property.getType() instanceof EdmGuid) { coloumnNames.add(propertyName); } else if(property.getType().getKind().equals(EdmTypeKind.COMPLEX) ){ boolean isUUIDinComplextype = getUUIDColumnsInComplexType(entityType, property); if(isUUIDinComplextype)coloumnNames.add(propertyName); } } } return coloumnNames; }
coloumnNames.add(propertyName); else if(property.getType().getKind().equals(EdmTypeKind.COMPLEX) ){ boolean isUUIDinComplextype = getUUIDColumnsInComplexType(entityType, property); if(isUUIDinComplextype)coloumnNames.add(propertyName);
@Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { try { final EdmType type = functionImport.getReturnType().getType(); final boolean isCollection = functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY; if (type.getKind() == EdmTypeKind.ENTITY) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) data; return writeEntry(functionImport.getEntitySet(), map, properties); } final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); if (isCollection) { return writeCollection(info, (List<?>) data); } else { return writeSingleTypedElement(info, data); } } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
@Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) data; return writeEntry(functionImport.getEntitySet(), map, properties); } final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) { return writeCollection(info, (List<?>) data); } else { return writeSingleTypedElement(info, data); } } catch (final EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
@Override public Object readFunctionImport(final EdmFunctionImport functionImport, InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { return new XmlEntityConsumer().readEntry(functionImport.getEntitySet(), content, properties); } else { final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new XmlEntityConsumer().readCollection(info, content, properties) : new XmlEntityConsumer().readProperty(info, content, properties).get(info.getName()); } } catch (final EdmException e) { throw new EntityProviderException(e.getMessageReference(), e); } } }
private String getEtagPropertyName(UriInfo uriInfo) throws EdmException { String etagPropName = ""; EdmEntityType originEntityType = uriInfo.getTargetEntitySet().getEntityType(); List<String> propertyNames = originEntityType.getPropertyNames(); for (String name : propertyNames) { EdmTyped edmTyped = originEntityType.getProperty(name); EdmTypeKind typeKind = edmTyped.getType().getKind(); if (EdmTypeKind.SIMPLE.equals(typeKind)) { EdmProperty edmProperty = (EdmProperty) edmTyped; EdmFacets facet = edmProperty.getFacets(); if(null != facet && null != facet.getConcurrencyMode() && facet.getConcurrencyMode() == EdmConcurrencyMode.Fixed ) { etagPropName = getTechnicalName(edmTyped);; break; } } } return etagPropName; } private String getTechnicalName(Object edmMappable)
@Override public Object readFunctionImport(final EdmFunctionImport functionImport, InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { return new XmlEntityConsumer().readEntry(functionImport.getEntitySet(), content, properties); } else { final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new XmlEntityConsumer().readCollection(info, content, properties) : new XmlEntityConsumer().readProperty(info, content, properties).get(info.getName()); } } catch (final EdmException e) { throw new EntityProviderException(e.getMessageReference(), e); } } }
@Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { try { final EdmType type = functionImport.getReturnType().getType(); final boolean isCollection = functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY; if (type.getKind() == EdmTypeKind.ENTITY) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) data; return writeEntry(functionImport.getEntitySet(), map, properties); } final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); if (isCollection) { return writeCollection(info, (List<?>) data); } else { return writeSingleTypedElement(info, data); } } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } }
@Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) data; return writeEntry(functionImport.getEntitySet(), map, properties); } final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) { return writeCollection(info, (List<?>) data); } else { return writeSingleTypedElement(info, data); } } catch (final EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } }
@Override public Object readFunctionImport(final EdmFunctionImport functionImport, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new JsonEntityConsumer().readFeed(functionImport.getEntitySet(), content, properties) : new JsonEntityConsumer().readEntry(functionImport.getEntitySet(), content, properties); } else { final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new JsonEntityConsumer().readCollection(info, content, properties) : new JsonEntityConsumer().readProperty(info, content, properties).get(info.getName()); } } catch (final EdmException e) { throw new EntityProviderException(e.getMessageReference(), e); } }
@Override public Object readFunctionImport(final EdmFunctionImport functionImport, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new JsonEntityConsumer().readFeed(functionImport.getEntitySet(), content, properties) : new JsonEntityConsumer().readEntry(functionImport.getEntitySet(), content, properties); } else { final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new JsonEntityConsumer().readCollection(info, content, properties) : new JsonEntityConsumer().readProperty(info, content, properties).get(info.getName()); } } catch (final EdmException e) { throw new EntityProviderException(e.getMessageReference(), e); } }
@Override public Object readFunctionImport(EdmFunctionImport functionImport, EntityStream content) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new XmlEntityDeserializer().readFeed(functionImport.getEntitySet(), content) : new XmlEntityDeserializer().readEntry(functionImport.getEntitySet(), content); } else { final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new XmlEntityDeserializer().readCollection(info, content) : new XmlEntityDeserializer().readProperty(info, content).get(info.getName()); } } catch (final EdmException e) { throw new EntityProviderException(e.getMessageReference(), e); } } }
@Override public Object readFunctionImport(EdmFunctionImport functionImport, EntityStream content) throws EntityProviderException { try { if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new JsonEntityDeserializer().readFeed(functionImport.getEntitySet(), content) : new JsonEntityDeserializer().readEntry(functionImport.getEntitySet(), content); } else { final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ? new JsonEntityDeserializer().readCollection(info, content) : new JsonEntityDeserializer().readProperty(info, content).get(info.getName()); } } catch (final EdmException e) { throw new EntityProviderException(e.getMessageReference(), e); } } }
@Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { try { if(functionImport.getReturnType() !=null){ if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) data; return writeEntry(functionImport.getEntitySet(), map, properties); } final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport); if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) { return writeCollection(info, (List<?>) data); } else { return writeSingleTypedElement(info, data); } }else{ return ODataResponse.newBuilder().status(HttpStatusCodes.ACCEPTED).build(); } } catch (final EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } }