private List<KeyPredicate> getKeysFromFunctionImportParams(GetFunctionImportUriInfo uriInfo, boolean removeIsActiveEntity) throws EdmException { List<KeyPredicate> allKeys = new ArrayList<>(); Map<String, EdmLiteral> parameters = uriInfo.getFunctionImportParameters(); List<EdmProperty> keyList = uriInfo.getFunctionImport().getEntitySet().getEntityType().getKeyProperties(); Iterator<EdmProperty> keysPropItr = keyList.iterator(); while(keysPropItr.hasNext()){ EdmProperty property = keysPropItr.next(); if(removeIsActiveEntity && DraftUtilsV2.DRAFTS_ISACTIVE_ENTITY.equalsIgnoreCase(property.getName())){ continue; } String literal = parameters.get(property.getName()).getLiteral(); allKeys.add(new KeyPredicateImpl(literal, property)); } return allKeys; }
@Override public IDataProviderResponse executeFunctionImport(GetFunctionImportUriInfo uriInfo, ODataContext context) throws ODataException { String functionName = uriInfo.getFunctionImport().getName(); String draftActivate = ""; String draftEdit = ""; String draftPrepare = ""; if(uriInfo.getFunctionImport() != null && uriInfo.getFunctionImport().getEntitySet() != null){ //V2 metadata function imports are embedded with entityset name. draftActivate = uriInfo.getFunctionImport().getEntitySet().getName() + "_" + "draftActivate"; draftEdit = uriInfo.getFunctionImport().getEntitySet().getName() + "_" + "draftEdit"; draftPrepare = uriInfo.getFunctionImport().getEntitySet().getName() + "_" + "draftPrepare"; } if(draftActivate.equals(functionName)){ return handleActionForDraftActivate(uriInfo, context); }else if(draftEdit.equals(functionName)){ return handleActionForDraftEdit(uriInfo, context); }else if(draftPrepare.equals(functionName)){ return handleActionForDraftPrepare(uriInfo, context); }else{ return handleFunctionGenericNormalFlow(uriInfo, context); } }
BaseDataProviderResponse response = new BaseDataProviderResponse(); List<Map<String, Object>> resultEntities = new ArrayList<Map<String, Object>>(); EdmFunctionImport function = uriInfo.getFunctionImport(); OperationResponseImpl operationResponse = null; Map<String, Object> funcParams = new HashMap<String, Object>(); Map<String, EdmLiteral> functionParameters = uriInfo.getFunctionImportParameters(); try { if (functionParameters.isEmpty()) { HttpStatusCodes.BAD_REQUEST, "")); if ((params == null || params.isEmpty()) && !uriInfo.getCustomQueryOptions().isEmpty()) { ErrorResponseImpl errorResp = new ErrorResponseImpl(400, "", "Invalid Function Import Parameter", null, null);
private Object[] getArguments() throws EdmException { Map<String, EdmLiteral> edmArguments = functionView.getFunctionImportParameters(); if (edmArguments == null) { return null; } else { Collection<String> paramNames = functionImport.getParameterNames(); Object[] args = new Object[paramNames.size()]; int i = 0; for (String paramName : functionImport.getParameterNames()) { EdmLiteral literal = edmArguments.get(paramName); EdmParameter parameter = functionImport.getParameter(paramName); JPAEdmMapping mappingValue = (JPAEdmMapping) parameter.getMapping(); args[i++] = convertArgument(literal, parameter.getFacets(), mappingValue.getJPAType()); } return args; } }
@Override public IDataProviderResponse executeFunctionImport(GetFunctionImportUriInfo uriInfo, ODataContext context) throws ODataException { IDataProvider provider = getTargetDataProvider(uriInfo.getFunctionImport(), null); if (provider == null) { throw new DataProviderException(DataProviderException.NOT_IMPLEMENTED.addContent("executeFunctionImport"), context.getAcceptableLanguages().get(0)); } else { return provider.executeFunctionImport(uriInfo, context); } }
private Object[] getArguments() throws EdmException { Map<String, EdmLiteral> edmArguments = functionView.getFunctionImportParameters(); if (edmArguments == null) { return null; } else { Collection<String> paramNames = functionImport.getParameterNames(); Object[] args = new Object[paramNames.size()]; int i = 0; for (String paramName : functionImport.getParameterNames()) { EdmLiteral literal = edmArguments.get(paramName); EdmParameter parameter = functionImport.getParameter(paramName); JPAEdmMapping mappingValue = (JPAEdmMapping) parameter.getMapping(); args[i++] = convertArgument(literal, parameter.getFacets(), mappingValue.getJPAType()); } return args; } }
@Override public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriInfo, final String contentType) throws ODataException { final EdmFunctionImport functionImport = uriInfo.getFunctionImport(); final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType(); final Object data = dataSource.readData( functionImport, mapFunctionParameters(uriInfo.getFunctionImportParameters()), null); if (data == null) { throw new ODataNotFoundException(ODataHttpException.COMMON); } ODataResponse response; if (type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) { response = EntityProvider.writeBinary(((BinaryData) data).getMimeType(), ((BinaryData) data).getData()); } else { final String value = type.valueToString(data, EdmLiteralKind.DEFAULT, null); response = EntityProvider.writeText(value == null ? "" : value); } return ODataResponse.fromResponse(response).build(); }
if (uriInfo.getFunctionImport().getEntitySet() != null) { List<String> propertNames = uriInfo.getFunctionImport().getEntitySet().getEntityType().getPropertyNames(); for (String propertyName : propertNames) { if (uriInfo.getFunctionImport().getEntitySet().getEntityType().getProperty(propertyName) .getType() instanceof EdmGuid) { coloumnNames.add(propertyName); String functionName = uriInfo.getFunctionImport().getName(); ExtensionHolder holder = null; boolean withinChangeSet = extensionMethodForTransaction != null; if (uriInfo.getFunctionImport().getHttpMethod().compareTo("GET") == 0) { } else if (uriInfo.getFunctionImport().getHttpMethod().compareTo("POST") == 0) {
@Override public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriInfo, final String contentType) throws ODataException { final EdmFunctionImport functionImport = uriInfo.getFunctionImport(); final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType(); final Object data = dataSource.readData( functionImport, mapFunctionParameters(uriInfo.getFunctionImportParameters()), null); if (data == null) { throw new ODataNotFoundException(ODataHttpException.COMMON); } ODataResponse response; if (type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) { response = EntityProvider.writeBinary(((BinaryData) data).getMimeType(), ((BinaryData) data).getData()); } else { final String value = type.valueToString(data, EdmLiteralKind.DEFAULT, null); response = EntityProvider.writeText(value == null ? "" : value); } return ODataResponse.fromResponse(response).build(); }
@Override public IDataProviderResponse executeFunctionImport(GetFunctionImportUriInfo uriInfo, ODataContext context) throws ODataException { IDataProvider dataProvider = null; dataProvider = getDataProvider(getFunctionFqn(uriInfo.getFunctionImport())); try{ if (dataProvider !=null){ return dataProvider.executeFunctionImport(uriInfo, context); } else return null; } catch (ODataException e) { logger.error("Error in executeFunctionImport",e); throw new ODataException(e.getMessage(),e); } }
@Override public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriInfo, final String contentType) throws ODataException { final EdmFunctionImport functionImport = uriInfo.getFunctionImport(); final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType(); final Object data = dataSource.readData( functionImport, mapFunctionParameters(uriInfo.getFunctionImportParameters()), null); if (data == null) { throw new ODataNotFoundException(ODataHttpException.COMMON); } ODataResponse response; if (type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) { response = EntityProvider.writeBinary(((BinaryData) data).getMimeType(), ((BinaryData) data).getData()); } else { final String value = type.valueToString(data, EdmLiteralKind.DEFAULT, null); response = EntityProvider.writeText(value == null ? "" : value); } return ODataResponse.fromResponse(response).build(); }
@Override public JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException { if (functionView != null) { functionImport = functionView.getFunctionImport(); try { mapping = functionImport.getMapping(); List<JPAFunction> jpaFunctionList = new ArrayList<JPAFunction>(); jpaFunctionList.add(generateJPAFunction()); setJpaFunction(jpaFunctionList); setEnclosingObject(generateEnclosingObject()); } catch (EdmException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (InstantiationException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (IllegalAccessException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (IllegalArgumentException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (InvocationTargetException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (NoSuchMethodException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (SecurityException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } } return JPAFunctionContext.this; }
@Override public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType) throws ODataException { final EdmFunctionImport functionImport = uriInfo.getFunctionImport(); final EdmType type = functionImport.getReturnType().getType(); mapFunctionParameters(uriInfo.getFunctionImportParameters()), null);
@Override public JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException { if (functionView != null) { functionImport = functionView.getFunctionImport(); try { mapping = functionImport.getMapping(); List<JPAFunction> jpaFunctionList = new ArrayList<JPAFunction>(); jpaFunctionList.add(generateJPAFunction()); setJpaFunction(jpaFunctionList); setEnclosingObject(generateEnclosingObject()); } catch (EdmException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (InstantiationException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (IllegalAccessException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (IllegalArgumentException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (InvocationTargetException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (NoSuchMethodException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (SecurityException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } } return JPAFunctionContext.this; }
@Override public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType) throws ODataException { final EdmFunctionImport functionImport = uriInfo.getFunctionImport(); final EdmType type = functionImport.getReturnType().getType(); mapFunctionParameters(uriInfo.getFunctionImportParameters()), null);
Object[] args = jpaFunction.getArguments(); if (uriParserResultView.getFunctionImport().getReturnType() .getMultiplicity().equals(EdmMultiplicity.MANY)) {
@Override public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType) throws ODataException { final EdmFunctionImport functionImport = uriInfo.getFunctionImport(); final EdmType type = functionImport.getReturnType().getType(); mapFunctionParameters(uriInfo.getFunctionImportParameters()), null);
Object[] args = jpaFunction.getArguments(); if (uriParserResultView.getFunctionImport().getReturnType() .getMultiplicity().equals(EdmMultiplicity.MANY)) {
EdmFunctionImport functionImport = uriInfo.getFunctionImport(); EdmTyped edmTyped = functionImport.getReturnType(); if(edmTyped != null){
functionImport = uriInfo.getFunctionImport(); edmTyped = functionImport.getReturnType();