From c2e13eb8ca3257e9c537eb03f6cb2c008a6320b6 Mon Sep 17 00:00:00 2001 From: DedunuKarunarathne <46235093+DedunuKarunarathne@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:16:37 +0530 Subject: [PATCH] Add the original SQL query to the data service OMElement Add the original SQL query to the data service OMElement that will be displayed in the dashboard data service source view. Fixes: https://github.com/wso2/micro-integrator/issues/3587 --- .../core/description/query/ExpressionQuery.java | 7 +++++++ .../core/description/query/QuerySerializer.java | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/ExpressionQuery.java b/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/ExpressionQuery.java index 800cb21d37..9497a2f77e 100644 --- a/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/ExpressionQuery.java +++ b/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/ExpressionQuery.java @@ -44,6 +44,8 @@ public abstract class ExpressionQuery extends Query { private String query; + private String originalQuery; + private List namedParamNames; private int paramCount; @@ -57,12 +59,17 @@ public ExpressionQuery(DataService dataService, String queryId, List super(dataService, queryId, queryParams, result, configId, inputEventTrigger, outputEventTrigger, advancedProperties, inputNamespace); this.query = query; + this.originalQuery = query; } public String getQuery() { return query; } + public String getOriginalQuery() { + return originalQuery; + } + public int getParamCount() { return paramCount; } diff --git a/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/QuerySerializer.java b/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/QuerySerializer.java index 8e6bf682e8..12c832e6fb 100644 --- a/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/QuerySerializer.java +++ b/components/data/data-services/org.wso2.micro.integrator.dataservices.core/src/main/java/org/wso2/micro/integrator/dataservices/core/description/query/QuerySerializer.java @@ -121,7 +121,7 @@ private static void serializeAdvancedProps(Query query, OMElement queryEl, OMFac private static void serializeSQLQueryProps(SQLQuery sqlQuery, OMElement queryEl, OMFactory fac) { OMElement sqlEl = fac.createOMElement(new QName(DBSFields.SQL)); - sqlEl.setText(sqlQuery.getQuery()); + sqlEl.setText(sqlQuery.getOriginalQuery()); queryEl.addChild(sqlEl); if (sqlQuery.isReturnGeneratedKeys()) { queryEl.addAttribute(DBSFields.RETURN_GENERATED_KEYS, Boolean.TRUE.toString(), null); @@ -310,7 +310,7 @@ private static void serializeQueryParams(List queryParams, } defaultValue = queryParam.getDefaultValue(); if (defaultValue != null && defaultValue.getScalarValue() != null) { - queryParamEl.addAttribute(DBSFields.ORDINAL, defaultValue.getScalarValue(), null); + queryParamEl.addAttribute(DBSFields.DEFAULT_VALUE, defaultValue.getScalarValue(), null); } /* add validators */ serializeValidators(queryParam.getValidators(), queryParamEl, fac);