private void validateFunctionImport() throws EntityProviderException, EdmException { for (EdmFunctionImport functionImport : edmFunctionImportList) { EdmTyped returnType = functionImport.getReturnType(); if (returnType != null) { FullQualifiedName fqn = extractFQName(returnType.toString()); String entitySet = ((EdmFunctionImportImpl)functionImport).getEntitySetName(); if (returnType.getMultiplicity() == EdmMultiplicity.MANY && entitySet == null && entityTypesMap.get( fqn) != null) { throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent("EntitySet = " + entitySet, XmlMetadataConstants.EDM_FUNCTION_IMPORT + " = " + functionImport.getName())); } else if (returnType.getMultiplicity() != EdmMultiplicity.MANY && entitySet != null && entityTypesMap.get( fqn) == null) { throw new EntityProviderException(EntityProviderException.INVALID_ATTRIBUTE.addContent("EntitySet = " + entitySet, XmlMetadataConstants.EDM_FUNCTION_IMPORT + " = " + functionImport.getName())); } } } }
@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; }
@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, 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 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 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); } } }
final EdmTyped returnType = functionImport.getReturnType(); final EdmType type = returnType.getType(); final boolean isCollection = returnType.getMultiplicity() == EdmMultiplicity.MANY;
@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); } }
final EdmTyped returnType = functionImport.getReturnType(); final EdmType type = returnType.getType(); final boolean isCollection = returnType.getMultiplicity() == EdmMultiplicity.MANY;
@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); } }
value = type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ? ((BinaryData) data).getData() : data; } else if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) { List<Map<String, Object>> values = new ArrayList<Map<String, Object>>(); for (final Object typeData : (List<?>) data) {
protected void validateEdmPropertyOfStructuredType(final EdmStructuralType parentType, final PropertyExpressionImpl property, final Token propertyToken) throws ExpressionParserException, ExpressionParserInternalError { try { String propertyName = property.getUriLiteral(); EdmTyped edmProperty = parentType.getProperty(propertyName); if (edmProperty != null) { property.setEdmProperty(edmProperty); property.setEdmType(edmProperty.getType()); if(isLastFilterElement(propertyName)) { if (edmProperty.getMultiplicity() == EdmMultiplicity.MANY && strictFilter == true) { throw new ExpressionParserException( ExpressionParserException.INVALID_MULTIPLICITY.create() .addContent(propertyName) .addContent(propertyToken.getPosition() + 1)); } } } else { // Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 3 throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken, curExpression); } } catch (EdmException e) { // not Tested, should not occur throw ExpressionParserInternalError.createERROR_ACCESSING_EDM(e); } }
value = type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ? ((BinaryData) data).getData() : data; } else if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) { List<Map<String, Object>> values = new ArrayList<Map<String, Object>>(); for (final Object typeData : (List<?>) data) {
protected void validateEdmPropertyOfStructuredType(final EdmStructuralType parentType, final PropertyExpressionImpl property, final Token propertyToken) throws ExpressionParserException, ExpressionParserInternalError { try { String propertyName = property.getUriLiteral(); EdmTyped edmProperty = parentType.getProperty(propertyName); if (edmProperty != null) { property.setEdmProperty(edmProperty); property.setEdmType(edmProperty.getType()); if(isLastFilterElement(propertyName)) { if (edmProperty.getMultiplicity() == EdmMultiplicity.MANY) { throw new ExpressionParserException( ExpressionParserException.INVALID_MULTIPLICITY.create() .addContent(propertyName) .addContent(propertyToken.getPosition() + 1)); } } } else { // Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 3 throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken, curExpression); } } catch (EdmException e) { // not Tested, should not occur throw ExpressionParserInternalError.createERROR_ACCESSING_EDM(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); } }
@Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { try { if(functionImport.getReturnType() !=null){ 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); } }else{ return ODataResponse.newBuilder().status(HttpStatusCodes.ACCEPTED).build(); } } catch (EdmException e) { throw new EntityProviderProducerException(e.getMessageReference(), e); } }