Commit 8bfa8cc197567f40dfcbd494e4eab5c6707f55db

Authored by Carlos Alberto
1 parent 8db761c3
Exists in master

Correção do controle de exceção no workflow

cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/FlowElement.java
... ... @@ -401,4 +401,7 @@ public class FlowElement extends PersistentFlowObject {
401 401 return false;
402 402 }
403 403  
  404 + public boolean stopExecutionOnError() {
  405 + return true;
  406 + }
404 407 }
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/event/Event.java
... ... @@ -52,5 +52,10 @@ public abstract class Event extends FlowElement {
52 52 public boolean isEvent() {
53 53 return true;
54 54 }
  55 +
  56 + @Override
  57 + public boolean stopExecutionOnError() {
  58 + return false;
  59 + }
55 60  
56 61 }
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/task/EmailTask.java
... ... @@ -235,4 +235,10 @@ public class EmailTask extends Activity {
235 235 this.emailText = "";
236 236 }
237 237 }
  238 +
  239 + @Override
  240 + public boolean stopExecutionOnError() {
  241 + return false;
  242 + }
  243 +
238 244 }
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/model/ProcessInstance.java
... ... @@ -221,6 +221,8 @@ public class ProcessInstance extends PersistentObject implements Serializable {
221 221 @JsonIgnore
222 222 protected NotificationTemplate assignmentRemovalTemplate;
223 223  
  224 + @JsonIgnore
  225 + protected Boolean errorStatus;
224 226  
225 227 /**
226 228 * Retorna o valor do atributo <code>stopOnException</code>
... ... @@ -473,6 +475,7 @@ public class ProcessInstance extends PersistentObject implements Serializable {
473 475 if (this.hasOwner()) {
474 476 this.getOwner().setErrorLog(errorLog);
475 477 }
  478 + this.errorStatus = errorLog != null;
476 479 }
477 480  
478 481  
... ... @@ -508,6 +511,10 @@ public class ProcessInstance extends PersistentObject implements Serializable {
508 511 }
509 512  
510 513 public boolean hasError() {
  514 + return this.hasErrorLog() && this.errorStatus != null && this.errorStatus;
  515 + }
  516 +
  517 + public boolean hasErrorLog() {
511 518 return this.getErrorLog() != null;
512 519 }
513 520  
... ... @@ -1083,5 +1090,19 @@ public class ProcessInstance extends PersistentObject implements Serializable {
1083 1090 public boolean hasNewWorkItems() {
1084 1091 return this.newWorkItems != null && this.newWorkItems.size() > 0;
1085 1092 }
  1093 +
  1094 +
  1095 + public void clearErrorStatus() {
  1096 + this.errorStatus = false;
  1097 + }
  1098 +
  1099 + public boolean getErrorStatus() {
  1100 + return errorStatus;
  1101 + }
  1102 +
  1103 +
  1104 + public void setErrorStatus(boolean errorStatus) {
  1105 + this.errorStatus = errorStatus;
  1106 + }
1086 1107 }
1087 1108  
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/model/WorkItem.java
... ... @@ -112,7 +112,7 @@ public class WorkItem extends PersistentObject {
112 112 private User owner;
113 113  
114 114 @ManyToOne(cascade = { CascadeType.ALL }, fetch=FetchType.LAZY, optional=true)
115   - @JsonView({ Views.EsiRuntimeLogView.class})
  115 + @JsonView({Views.EsiListView.class, Views.EsiRuntimeLogView.class })
116 116 private ErrorLog errorLog;
117 117  
118 118 @ManyToOne(fetch=FetchType.LAZY, optional=true)
... ... @@ -328,7 +328,7 @@ public class WorkItem extends PersistentObject {
328 328 public boolean isCompleted() {
329 329 if (this.getStatus() == null)
330 330 return false;
331   - return this.getStatus().equals(WorkItemStatusEnum.COMPLETED) || this.getStatus().equals(WorkItemStatusEnum.CANCELLED);
  331 + return this.getStatus().equals(WorkItemStatusEnum.COMPLETED) || this.getStatus().equals(WorkItemStatusEnum.CANCELLED) || this.getStatus().equals(WorkItemStatusEnum.ERROR);
332 332 }
333 333  
334 334 public boolean isSolved() {
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/impl/ProcessInstanceServiceBaseImpl.java
... ... @@ -208,6 +208,9 @@ public abstract class ProcessInstanceServiceBaseImpl extends GenericServiceImpl&lt;
208 208 this.intializeObjects(runtimeEnvironment, processInstance);
209 209 WorkItemService workItemService = runtimeContext.getWorkItemService(flowElement);
210 210 WorkItem workItem = workItemService.solve(runtimeEnvironment, processInstance, flowElement);
  211 + if (!flowElement.stopExecutionOnError() && processInstance.hasError()) {
  212 + processInstance.clearErrorStatus();
  213 + }
211 214 if (workItem != null && workItem.getTargets() != null) {
212 215 return workItem.getTargets();
213 216 }else{
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/impl/WorkItemServiceImpl.java
... ... @@ -109,7 +109,7 @@ public class WorkItemServiceImpl&lt;E extends FlowElement&gt; extends GenericServiceIm
109 109  
110 110 protected List<FlowElement> getTargetElements(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, WorkItem workItem) {
111 111 List<FlowElement> targets = new ArrayList<FlowElement>();
112   - if (!processInstance.hasError() || this.isErrorEvent(workItem.getFlowElement())) {
  112 + if (!processInstance.hasError() || !workItem.getFlowElement().stopExecutionOnError()) {
113 113 List<FlowConnection> connections = this.getCompliedTargetConnections(runtimeEnvironment, this.getFlowElement(workItem), processInstance);
114 114 for (FlowConnection flowConnection : connections) {
115 115 this.flowConnectionService.executeAction(runtimeEnvironment, processInstance, flowConnection);
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/runtime/service/impl/RuntimeManagerBaseImpl.java
... ... @@ -120,7 +120,7 @@ public abstract class RuntimeManagerBaseImpl implements RuntimeManagerBase {
120 120 if (runtimeEnvironment.getInstances() != null) {
121 121 boolean hasSaved = false;
122 122 for (ProcessInstance processInstance : runtimeEnvironment.getInstances()) {
123   - if (hasSaved || processInstance.hasError() || processInstance.isPersistentExecution()) {
  123 + if (hasSaved || processInstance.hasErrorLog() || processInstance.isPersistentExecution() || (processInstance.hasOwner() && processInstance.getOwner().isPersistentExecution())) {
124 124 this.getProcessInstanceService().saveOrUpdate(runtimeEnvironment, processInstance);
125 125 hasSaved = true;
126 126 }
... ... @@ -157,7 +157,7 @@ public abstract class RuntimeManagerBaseImpl implements RuntimeManagerBase {
157 157 ProcessInstance processInstance = this.getProcessInstanceService().start(runtimeEnvironment, originWorkItem, flowVersion);
158 158 RuntimeEnvironmentOutput output = finalize(processInstance, runtimeEnvironment);
159 159  
160   - if (createLog && (processInstance.isPersistentExecution() || processInstance.hasError())) {
  160 + if (createLog && (processInstance.isPersistentExecution() || processInstance.hasErrorLog())) {
161 161 runtimeLogService.create( runtimeEnvironment.getInput().isSignal() ? RuntimeActionEnum.SIGNAL_EVENT
162 162 : flowVersion.isBusinessRule() ? RuntimeActionEnum.BUSINESS_RULE
163 163 : RuntimeActionEnum.START, null,
... ...
cit-esi-web/src/main/webapp/assets/js/angular/custom/directive/ProcessInstanceTimelineDirective.js
... ... @@ -175,6 +175,8 @@ citApp.directive(&quot;esiProcessInstanceTimeline&quot;, [&#39;RuntimeManagerRepository&#39;, &#39;Dom
175 175 processInstance.activities.push(item);
176 176 }
177 177 $scope.loadingActivities = false;
  178 + }else{
  179 + $scope.loadingActivities = false;
178 180 }
179 181 }, function() {
180 182 $scope.loadingActivities = false;
... ...
cit-esi-web/src/main/webapp/assets/js/angular/custom/directive/html/processInstanceTimeline.html
... ... @@ -258,7 +258,7 @@
258 258 </li>
259 259 </ul>
260 260  
261   - <div class="widget-box" style="margin: 0 0 0 0 !important" ng-show="activity.processInstance.id == processInstance.id && activity.errorLog">
  261 + <div class="widget-box" style="margin: 0 0 0 0 !important" ng-show="(activity.processInstance.id == processInstance.id || !processInstance.errorLog) && activity.errorLog">
262 262 <div class="widget-header">
263 263 <span class="timeline-item-icon" style="margin: 0px 16px 0 0 !important">
264 264 <i class="fa fa-bug red"></i>
... ...
cit-esi-web/src/main/webapp/assets/js/angular/custom/utils/DesenhoFluxo.js
... ... @@ -1618,9 +1618,7 @@ function DesenhoFluxo(idCanvas, idDivCanvas, scope, window){
1618 1618 self.getCanvasParent().scrollLeft = self.getCanvasParent().scrollLeft + elemento.getLargura();
1619 1619 }
1620 1620 if (limiteTempY < elemento.getPosicaoY2()) {
1621   - self.getCanvas().height = self.getCanvas().height + elemento.getAltura();
1622   - if (self.getCanvasParent != null)
1623   - self.getCanvasParent().scrollTop = self.getCanvasParent().scrollTop + elemento.getAltura();
  1621 + self.getCanvas().height = self.getCanvas().height + elemento.getAltura()*1.5;
1624 1622 }
1625 1623 },
1626 1624  
... ... @@ -2194,9 +2192,9 @@ function DesenhoFluxo(idCanvas, idDivCanvas, scope, window){
2194 2192 var relacionamento = new RelacionamentoFluxo(self);
2195 2193  
2196 2194 var attachToBoundary = ATTACHED_CATCH;
2197   - for (var i = 0; i < elementoBoundary.attachToBoundary.length; i++) {
2198   - if (elementoBoundary.attachToBoundary[i] != ATTACHED_NONE) {
2199   - attachToBoundary = elementoBoundary.attachToBoundary[i];
  2195 + for (var i = 0; i < elemento.attachToBoundary.length; i++) {
  2196 + if (elemento.attachToBoundary[i] != ATTACHED_NONE) {
  2197 + attachToBoundary = elemento.attachToBoundary[i];
2200 2198 break;
2201 2199 }
2202 2200 }
... ... @@ -2303,6 +2301,7 @@ function DesenhoFluxo(idCanvas, idDivCanvas, scope, window){
2303 2301 self.prevent(e);
2304 2302  
2305 2303 var posicao = self.getPosicaoRelativaCursor(e);
  2304 +
2306 2305 var sel = self.buscaElementoNaPosicao(posicao);
2307 2306  
2308 2307 self.divInfoElemento.style.display = 'none';
... ... @@ -2329,6 +2328,7 @@ function DesenhoFluxo(idCanvas, idDivCanvas, scope, window){
2329 2328 angular.element('#spanPosicao')[0].innerHTML = posicao.x + ", " + posicao.y ;
2330 2329 }
2331 2330 }
  2331 +
2332 2332 },
2333 2333  
2334 2334 this.mouseDown = function(e) {
... ... @@ -2357,7 +2357,7 @@ function DesenhoFluxo(idCanvas, idDivCanvas, scope, window){
2357 2357 var posicao = self.getPosicaoRelativaCursor(e);
2358 2358  
2359 2359 self.atualiza();
2360   -
  2360 +
2361 2361 var tipo = self.buscaTipoElementoPorId(idDragOver);
2362 2362 if(tipo == null){
2363 2363 return;
... ... @@ -2367,6 +2367,11 @@ function DesenhoFluxo(idCanvas, idDivCanvas, scope, window){
2367 2367 elemento.posiciona(posicao);
2368 2368 if (self.isPosicaoValida(elemento)) {
2369 2369 self.exibePosicaoCursor(posicao.x, posicao.y, posicao.x+10, posicao.y+10, elemento);
  2370 + if (self.getCanvasParent != null) {
  2371 + if (self.existeElementoNoCentro(posicao.x,posicao.y,null)) {
  2372 + window.scrollTo(self.getCanvasParent().scrollTop, posicao.y);
  2373 + }
  2374 + }
2370 2375 }
2371 2376 },
2372 2377  
... ...