Commit 05c1e75da19e1faaf1b8b5267cc667ccb9e09796
1 parent
61cdd37d
Exists in
master
Correção da execução de SQLs
Showing
4 changed files
with
32 additions
and
7 deletions
Show diff stats
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteSql.java
| @@ -17,23 +17,32 @@ import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; | @@ -17,23 +17,32 @@ import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; | ||
| 17 | import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | 17 | import br.com.centralit.esi.api.runtime.RuntimeEnvironment; |
| 18 | import br.com.centralit.esi.api.util.ConvertUtilsESI; | 18 | import br.com.centralit.esi.api.util.ConvertUtilsESI; |
| 19 | import br.com.centralit.esi.exception.EsiBusinessException; | 19 | import br.com.centralit.esi.exception.EsiBusinessException; |
| 20 | +import br.com.centralit.framework.util.UtilString; | ||
| 20 | 21 | ||
| 21 | public class ExecuteSql { | 22 | public class ExecuteSql { |
| 22 | 23 | ||
| 23 | public static void execute(RuntimeEnvironment runtimeEnvironment) { | 24 | public static void execute(RuntimeEnvironment runtimeEnvironment) { |
| 25 | + String beanName = (String) runtimeEnvironment.getObject("NAMEBEANSUBST"); | ||
| 26 | + Object beanObj = null; | ||
| 27 | + if (!UtilString.isNullOrEmpty(beanName)){ | ||
| 28 | + beanObj = (Object) runtimeEnvironment.getObject(beanName); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + String sql = null; | ||
| 32 | + if (beanObj != null) { | ||
| 33 | + sql = (String) runtimeEnvironment.getObjectNotParsed("SQLCONTENT"); | ||
| 34 | + }else{ | ||
| 35 | + sql = (String) runtimeEnvironment.getObject("SQLCONTENT"); | ||
| 36 | + } | ||
| 37 | + | ||
| 24 | String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | 38 | String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); |
| 25 | - String sql = (String) runtimeEnvironment.getObject("SQLCONTENT"); | ||
| 26 | String sqlType = (String) runtimeEnvironment.getObject("SQLTYPE"); | 39 | String sqlType = (String) runtimeEnvironment.getObject("SQLTYPE"); |
| 27 | String nameResultSql = (String) runtimeEnvironment.getObject("NAMERESULTSQL"); | 40 | String nameResultSql = (String) runtimeEnvironment.getObject("NAMERESULTSQL"); |
| 28 | Object saida = null; | 41 | Object saida = null; |
| 42 | + | ||
| 29 | if (connName != null) { | 43 | if (connName != null) { |
| 30 | Connection connection = (Connection) runtimeEnvironment.getObject(connName); | 44 | Connection connection = (Connection) runtimeEnvironment.getObject(connName); |
| 31 | if (connection != null) { | 45 | if (connection != null) { |
| 32 | - String nameBeanSubt = (String) runtimeEnvironment.getObject("NAMEBEANSUBST"); | ||
| 33 | - Object beanObj = null; | ||
| 34 | - if (nameBeanSubt != null && !nameBeanSubt.trim().equalsIgnoreCase("")){ | ||
| 35 | - beanObj = (Object) runtimeEnvironment.getObject(nameBeanSubt); | ||
| 36 | - } | ||
| 37 | 46 | ||
| 38 | HashMap<String, Object> map = ConvertUtilsESI.convertToMap(beanObj); | 47 | HashMap<String, Object> map = ConvertUtilsESI.convertToMap(beanObj); |
| 39 | 48 |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/map/MapObjects.java
| @@ -64,5 +64,9 @@ public class MapObjects extends HashMap<String, Object> { | @@ -64,5 +64,9 @@ public class MapObjects extends HashMap<String, Object> { | ||
| 64 | else | 64 | else |
| 65 | return obj; | 65 | return obj; |
| 66 | } | 66 | } |
| 67 | + | ||
| 68 | + public Object getNotParsed(String key) { | ||
| 69 | + return super.get(key); | ||
| 70 | + } | ||
| 67 | 71 | ||
| 68 | } | 72 | } |
cit-esi-api/src/main/java/br/com/centralit/esi/api/runtime/RuntimeEnvironment.java
| @@ -95,7 +95,7 @@ public interface RuntimeEnvironment { | @@ -95,7 +95,7 @@ public interface RuntimeEnvironment { | ||
| 95 | public boolean hasObject(String name); | 95 | public boolean hasObject(String name); |
| 96 | 96 | ||
| 97 | /** | 97 | /** |
| 98 | - * Retorna o objeto com o nome informado | 98 | + * Retorna o objeto com o nome informado já parseado |
| 99 | * @param name | 99 | * @param name |
| 100 | * @return | 100 | * @return |
| 101 | */ | 101 | */ |
| @@ -199,4 +199,11 @@ public interface RuntimeEnvironment { | @@ -199,4 +199,11 @@ public interface RuntimeEnvironment { | ||
| 199 | */ | 199 | */ |
| 200 | public void addObjects(MapObjects buildEnvironmentObjects); | 200 | public void addObjects(MapObjects buildEnvironmentObjects); |
| 201 | 201 | ||
| 202 | + /** | ||
| 203 | + * Retorna o objeto com o nome informado sem parse | ||
| 204 | + * @param name | ||
| 205 | + * @return | ||
| 206 | + */ | ||
| 207 | + public Object getObjectNotParsed(String name); | ||
| 208 | + | ||
| 202 | } | 209 | } |
cit-esi-api/src/main/java/br/com/centralit/esi/api/runtime/RuntimeEnvironmentImpl.java
| @@ -346,6 +346,11 @@ public class RuntimeEnvironmentImpl implements RuntimeEnvironment { | @@ -346,6 +346,11 @@ public class RuntimeEnvironmentImpl implements RuntimeEnvironment { | ||
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | @Override | 348 | @Override |
| 349 | + public Object getObjectNotParsed(String name) { | ||
| 350 | + return this.getObjects().getNotParsed(name); | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + @Override | ||
| 349 | public String parseString(String str) { | 354 | public String parseString(String str) { |
| 350 | return this.getObjects().parseString(str); | 355 | return this.getObjects().parseString(str); |
| 351 | } | 356 | } |