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 | 17 | import br.com.centralit.esi.api.runtime.RuntimeEnvironment; |
| 18 | 18 | import br.com.centralit.esi.api.util.ConvertUtilsESI; |
| 19 | 19 | import br.com.centralit.esi.exception.EsiBusinessException; |
| 20 | +import br.com.centralit.framework.util.UtilString; | |
| 20 | 21 | |
| 21 | 22 | public class ExecuteSql { |
| 22 | 23 | |
| 23 | 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 | 38 | String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); |
| 25 | - String sql = (String) runtimeEnvironment.getObject("SQLCONTENT"); | |
| 26 | 39 | String sqlType = (String) runtimeEnvironment.getObject("SQLTYPE"); |
| 27 | 40 | String nameResultSql = (String) runtimeEnvironment.getObject("NAMERESULTSQL"); |
| 28 | 41 | Object saida = null; |
| 42 | + | |
| 29 | 43 | if (connName != null) { |
| 30 | 44 | Connection connection = (Connection) runtimeEnvironment.getObject(connName); |
| 31 | 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 | 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
cit-esi-api/src/main/java/br/com/centralit/esi/api/runtime/RuntimeEnvironment.java
| ... | ... | @@ -95,7 +95,7 @@ public interface RuntimeEnvironment { |
| 95 | 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 | 99 | * @param name |
| 100 | 100 | * @return |
| 101 | 101 | */ |
| ... | ... | @@ -199,4 +199,11 @@ public interface RuntimeEnvironment { |
| 199 | 199 | */ |
| 200 | 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 | 346 | } |
| 347 | 347 | |
| 348 | 348 | @Override |
| 349 | + public Object getObjectNotParsed(String name) { | |
| 350 | + return this.getObjects().getNotParsed(name); | |
| 351 | + } | |
| 352 | + | |
| 353 | + @Override | |
| 349 | 354 | public String parseString(String str) { |
| 350 | 355 | return this.getObjects().parseString(str); |
| 351 | 356 | } | ... | ... |