Commit 902af8ddb47d994f53bd000bbf3514cddf0dbc52

Authored by Carlos Alberto
1 parent 05c1e75d
Exists in master

Correções nos componentes de banco de dados

cit-esi-api/src/main/java/br/com/centralit/esi/api/data/service/impl/DataManager.java
@@ -34,7 +34,6 @@ import br.com.centralit.esi.api.enumerated.RelationshipTypeEnum; @@ -34,7 +34,6 @@ import br.com.centralit.esi.api.enumerated.RelationshipTypeEnum;
34 import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; 34 import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum;
35 import br.com.centralit.esi.api.parameter.service.ParameterService; 35 import br.com.centralit.esi.api.parameter.service.ParameterService;
36 import br.com.centralit.esi.api.util.ConvertUtilsESI; 36 import br.com.centralit.esi.api.util.ConvertUtilsESI;
37 -import br.com.centralit.esi.exception.EsiBusinessException;  
38 import br.com.centralit.esi.exception.EsiControlledException; 37 import br.com.centralit.esi.exception.EsiControlledException;
39 import br.com.centralit.esi.exception.EsiExecutionException; 38 import br.com.centralit.esi.exception.EsiExecutionException;
40 import br.com.centralit.framework.esi.enumerated.VariableTypeEnum; 39 import br.com.centralit.framework.esi.enumerated.VariableTypeEnum;
@@ -126,7 +125,7 @@ public class DataManager { @@ -126,7 +125,7 @@ public class DataManager {
126 } 125 }
127 } 126 }
128 if (!errors.equals("")) { 127 if (!errors.equals("")) {
129 - throw new EsiBusinessException(errors); 128 + throw new EsiExecutionException(errors);
130 } 129 }
131 } 130 }
132 131
@@ -196,7 +195,7 @@ public class DataManager { @@ -196,7 +195,7 @@ public class DataManager {
196 result = DataObjectUtil.executeQuery(dataObject, connection, sql, map); 195 result = DataObjectUtil.executeQuery(dataObject, connection, sql, map);
197 } catch (SQLException e) { 196 } catch (SQLException e) {
198 e.printStackTrace(); 197 e.printStackTrace();
199 - throw new EsiBusinessException(e); 198 + throw new EsiExecutionException(e);
200 }finally{ 199 }finally{
201 dataSourceService.close(connection); 200 dataSourceService.close(connection);
202 } 201 }
@@ -233,7 +232,7 @@ public class DataManager { @@ -233,7 +232,7 @@ public class DataManager {
233 result = DataObjectUtil.executeQuery(dataObject, connection, query, map); 232 result = DataObjectUtil.executeQuery(dataObject, connection, query, map);
234 233
235 } catch (Exception e) { 234 } catch (Exception e) {
236 - throw new EsiBusinessException(e); 235 + throw new EsiExecutionException(e);
237 }finally{ 236 }finally{
238 this.dataSourceService.close(connection); 237 this.dataSourceService.close(connection);
239 } 238 }
@@ -272,7 +271,7 @@ public class DataManager { @@ -272,7 +271,7 @@ public class DataManager {
272 return map; 271 return map;
273 } catch (Exception e) { 272 } catch (Exception e) {
274 this.dataSourceService.rollback(connection); 273 this.dataSourceService.rollback(connection);
275 - throw new EsiBusinessException(e); 274 + throw new EsiExecutionException(e);
276 }finally{ 275 }finally{
277 this.dataSourceService.close(connection); 276 this.dataSourceService.close(connection);
278 } 277 }
@@ -302,7 +301,7 @@ public class DataManager { @@ -302,7 +301,7 @@ public class DataManager {
302 return map; 301 return map;
303 } catch (Exception e) { 302 } catch (Exception e) {
304 this.dataSourceService.rollback(connection); 303 this.dataSourceService.rollback(connection);
305 - throw new EsiBusinessException(e); 304 + throw new EsiExecutionException(e);
306 }finally{ 305 }finally{
307 this.dataSourceService.close(connection); 306 this.dataSourceService.close(connection);
308 } 307 }
@@ -326,7 +325,7 @@ public class DataManager { @@ -326,7 +325,7 @@ public class DataManager {
326 this.dataSourceService.commit(connection); 325 this.dataSourceService.commit(connection);
327 } catch (Exception e) { 326 } catch (Exception e) {
328 this.dataSourceService.rollback(connection); 327 this.dataSourceService.rollback(connection);
329 - throw new EsiBusinessException(e); 328 + throw new EsiExecutionException(e);
330 }finally{ 329 }finally{
331 this.dataSourceService.close(connection); 330 this.dataSourceService.close(connection);
332 } 331 }
@@ -357,7 +356,7 @@ public class DataManager { @@ -357,7 +356,7 @@ public class DataManager {
357 this.updateRelationships(dataObject, map); 356 this.updateRelationships(dataObject, map);
358 } catch (Exception e) { 357 } catch (Exception e) {
359 this.dataSourceService.rollback(connection); 358 this.dataSourceService.rollback(connection);
360 - throw new EsiBusinessException(e); 359 + throw new EsiExecutionException(e);
361 }finally{ 360 }finally{
362 this.dataSourceService.close(connection); 361 this.dataSourceService.close(connection);
363 } 362 }
@@ -386,7 +385,7 @@ public class DataManager { @@ -386,7 +385,7 @@ public class DataManager {
386 this.updateRelationships(dataObject, map); 385 this.updateRelationships(dataObject, map);
387 } catch (Exception e) { 386 } catch (Exception e) {
388 this.dataSourceService.rollback(connection); 387 this.dataSourceService.rollback(connection);
389 - throw new EsiBusinessException(e); 388 + throw new EsiExecutionException(e);
390 }finally{ 389 }finally{
391 this.dataSourceService.close(connection); 390 this.dataSourceService.close(connection);
392 } 391 }
@@ -409,7 +408,7 @@ public class DataManager { @@ -409,7 +408,7 @@ public class DataManager {
409 } 408 }
410 } catch (SQLException e) { 409 } catch (SQLException e) {
411 e.printStackTrace(); 410 e.printStackTrace();
412 - throw new EsiBusinessException(e); 411 + throw new EsiExecutionException(e);
413 }finally{ 412 }finally{
414 this.dataSourceService.close(connection); 413 this.dataSourceService.close(connection);
415 } 414 }
@@ -434,7 +433,7 @@ public class DataManager { @@ -434,7 +433,7 @@ public class DataManager {
434 this.dataSourceService.commit(connection); 433 this.dataSourceService.commit(connection);
435 } catch (Exception e) { 434 } catch (Exception e) {
436 this.dataSourceService.rollback(connection); 435 this.dataSourceService.rollback(connection);
437 - throw new EsiBusinessException(e); 436 + throw new EsiExecutionException(e);
438 }finally{ 437 }finally{
439 this.dataSourceService.close(connection); 438 this.dataSourceService.close(connection);
440 } 439 }
@@ -500,10 +499,10 @@ public class DataManager { @@ -500,10 +499,10 @@ public class DataManager {
500 return DataObjectUtil.buildColumns(dataSource, connection, schemaName, tableName); 499 return DataObjectUtil.buildColumns(dataSource, connection, schemaName, tableName);
501 } catch (SQLException e) { 500 } catch (SQLException e) {
502 e.printStackTrace(); 501 e.printStackTrace();
503 - throw new EsiBusinessException(e); 502 + throw new EsiExecutionException(e);
504 } 503 }
505 }else{ 504 }else{
506 - throw new EsiBusinessException("Conexão de banco de dados não encontrada"); 505 + throw new EsiExecutionException("Conexão de banco de dados não encontrada");
507 } 506 }
508 } 507 }
509 508
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteDBRollback.java 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +package br.com.centralit.esi.api.execution.component;
  2 +
  3 +import java.sql.Connection;
  4 +import java.sql.SQLException;
  5 +
  6 +import br.com.centralit.esi.api.runtime.RuntimeEnvironment;
  7 +import br.com.centralit.esi.exception.EsiExecutionException;
  8 +
  9 +public class ExecuteDBRollback {
  10 + public static void execute(RuntimeEnvironment runtimeEnvironment) {
  11 + String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME");
  12 + if (connName != null){
  13 + Connection connection = (Connection) runtimeEnvironment.getObject(connName);
  14 + if (connection != null){
  15 + try {
  16 + connection.rollback();
  17 + } catch (SQLException e) {
  18 + e.printStackTrace();
  19 + throw new EsiExecutionException(e);
  20 + }
  21 + }
  22 + }
  23 + }
  24 +}
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteRollbackTransactionSql.java
@@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
1 -package br.com.centralit.esi.api.execution.component;  
2 -  
3 -import java.sql.Connection;  
4 -import java.sql.SQLException;  
5 -  
6 -import br.com.centralit.esi.api.runtime.RuntimeEnvironment;  
7 -import br.com.centralit.esi.exception.EsiExecutionException;  
8 -  
9 -public class ExecuteRollbackTransactionSql {  
10 - public static void execute(RuntimeEnvironment runtimeEnvironment) {  
11 - String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME");  
12 - if (connName != null){  
13 - Connection connection = (Connection) runtimeEnvironment.getObject(connName);  
14 - if (connection != null){  
15 - try {  
16 - connection.rollback();  
17 - } catch (SQLException e) {  
18 - e.printStackTrace();  
19 - throw new EsiExecutionException(e);  
20 - } finally{  
21 - try {  
22 - connection.close();  
23 - } catch (SQLException e) {  
24 - e.printStackTrace();  
25 - }  
26 - connection = null;  
27 - }  
28 - }  
29 - runtimeEnvironment.addOrUpdateObject(connName, null);  
30 - }  
31 - }  
32 -}  
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseRollbackServiceImpl.java
@@ -5,7 +5,7 @@ import org.springframework.stereotype.Service; @@ -5,7 +5,7 @@ import org.springframework.stereotype.Service;
5 5
6 import br.com.centralit.esi.api.design.model.FlowElement; 6 import br.com.centralit.esi.api.design.model.FlowElement;
7 import br.com.centralit.esi.api.design.model.connector.DatabaseRollback; 7 import br.com.centralit.esi.api.design.model.connector.DatabaseRollback;
8 -import br.com.centralit.esi.api.execution.component.ExecuteRollbackTransactionSql; 8 +import br.com.centralit.esi.api.execution.component.ExecuteDBRollback;
9 import br.com.centralit.esi.api.execution.dao.WorkItemDao; 9 import br.com.centralit.esi.api.execution.dao.WorkItemDao;
10 import br.com.centralit.esi.api.execution.model.ProcessInstance; 10 import br.com.centralit.esi.api.execution.model.ProcessInstance;
11 import br.com.centralit.esi.api.execution.model.WorkItem; 11 import br.com.centralit.esi.api.execution.model.WorkItem;
@@ -36,7 +36,7 @@ public class WorkItemDatabaseRollbackServiceImpl extends WorkItemServiceImpl<Dat @@ -36,7 +36,7 @@ public class WorkItemDatabaseRollbackServiceImpl extends WorkItemServiceImpl<Dat
36 runtimeEnvironment.addOrUpdateObject("CONNECTIONNAME", 36 runtimeEnvironment.addOrUpdateObject("CONNECTIONNAME",
37 element.getConnectionName()); 37 element.getConnectionName());
38 38
39 - ExecuteRollbackTransactionSql.execute(runtimeEnvironment); 39 + ExecuteDBRollback.execute(runtimeEnvironment);
40 40
41 complete(runtimeEnvironment, workItem); 41 complete(runtimeEnvironment, workItem);
42 return retrieveTargets(runtimeEnvironment,workItem); 42 return retrieveTargets(runtimeEnvironment,workItem);
cit-esi-api/src/main/java/br/com/centralit/esi/exception/EsiExecutionException.java
@@ -12,7 +12,7 @@ public class EsiExecutionException extends BusinessException { @@ -12,7 +12,7 @@ public class EsiExecutionException extends BusinessException {
12 super(); 12 super();
13 this.setCodigoErro(702); 13 this.setCodigoErro(702);
14 } 14 }
15 - public EsiExecutionException(Throwable e){ 15 + public EsiExecutionException(Exception e){
16 super(e); 16 super(e);
17 this.setCodigoErro(702); 17 this.setCodigoErro(702);
18 } 18 }
@@ -20,4 +20,13 @@ public class EsiExecutionException extends BusinessException { @@ -20,4 +20,13 @@ public class EsiExecutionException extends BusinessException {
20 super(s); 20 super(s);
21 this.setCodigoErro(702); 21 this.setCodigoErro(702);
22 } 22 }
  23 + public EsiExecutionException(Throwable e){
  24 + super(e);
  25 + if (e instanceof BusinessException && ((BusinessException) e).getCodigoErro() != null) {
  26 + this.setCodigoErro(((BusinessException) e).getCodigoErro());
  27 + }else{
  28 + this.setCodigoErro(702);
  29 + }
  30 + }
  31 +
23 } 32 }