001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.model.control.workflow.server.logic;
018
019import com.echothree.control.user.workflow.common.spec.WorkflowDestinationUniversalSpec;
020import com.echothree.model.control.core.common.ComponentVendors;
021import com.echothree.model.control.core.common.EntityTypes;
022import com.echothree.model.control.core.common.exception.InvalidParameterCountException;
023import com.echothree.model.control.core.server.logic.EntityInstanceLogic;
024import com.echothree.model.control.party.server.logic.PartyLogic;
025import com.echothree.model.control.security.server.logic.SecurityRoleLogic;
026import com.echothree.model.control.selector.server.logic.SelectorLogic;
027import com.echothree.model.control.workflow.common.exception.MissingRequiredWorkflowNameException;
028import com.echothree.model.control.workflow.common.exception.MissingRequiredWorkflowStepNameException;
029import com.echothree.model.control.workflow.common.exception.UnknownDefaultWorkflowDestinationException;
030import com.echothree.model.control.workflow.common.exception.UnknownDestinationWorkflowNameException;
031import com.echothree.model.control.workflow.common.exception.UnknownDestinationWorkflowStepNameException;
032import com.echothree.model.control.workflow.common.exception.UnknownWorkflowDestinationPartyTypeException;
033import com.echothree.model.control.workflow.common.exception.UnknownWorkflowDestinationSecurityRoleException;
034import com.echothree.model.control.workflow.common.exception.UnknownWorkflowDestinationSelectorException;
035import com.echothree.model.control.workflow.common.exception.UnknownWorkflowDestinationStepException;
036import com.echothree.model.control.workflow.common.exception.UnknownWorkflowNameException;
037import com.echothree.model.control.workflow.common.exception.WorkflowMissingSecurityRoleGroupException;
038import com.echothree.model.control.workflow.common.exception.WorkflowMissingSelectorTypeException;
039import com.echothree.model.control.workflow.server.control.WorkflowControl;
040import com.echothree.model.data.party.server.entity.PartyType;
041import com.echothree.model.data.workflow.server.entity.Workflow;
042import com.echothree.model.data.workflow.server.entity.WorkflowDestination;
043import com.echothree.model.data.workflow.server.entity.WorkflowDestinationPartyType;
044import com.echothree.model.data.workflow.server.entity.WorkflowDestinationSecurityRole;
045import com.echothree.model.data.workflow.server.entity.WorkflowDestinationSelector;
046import com.echothree.model.data.workflow.server.entity.WorkflowDestinationStep;
047import com.echothree.model.data.workflow.server.entity.WorkflowStep;
048import com.echothree.util.common.message.ExecutionErrors;
049import com.echothree.util.server.control.BaseLogic;
050import com.echothree.util.server.message.ExecutionErrorAccumulator;
051import com.echothree.util.server.persistence.EntityPermission;
052import com.echothree.util.server.persistence.Session;
053import com.echothree.util.server.validation.ParameterUtils;
054import java.util.HashMap;
055import java.util.HashSet;
056import java.util.Map;
057import java.util.Set;
058import javax.enterprise.context.ApplicationScoped;
059import javax.enterprise.inject.spi.CDI;
060
061@ApplicationScoped
062public class WorkflowDestinationLogic
063        extends BaseLogic {
064
065    protected WorkflowDestinationLogic() {
066        super();
067    }
068
069    public static WorkflowDestinationLogic getInstance() {
070        return CDI.current().select(WorkflowDestinationLogic.class).get();
071    }
072    
073    public WorkflowDestination getWorkflowDestinationByName(final ExecutionErrorAccumulator eea, final WorkflowStep workflowStep,
074            final String workflowDestinationName, final EntityPermission entityPermission) {
075        var workflowControl = Session.getModelController(WorkflowControl.class);
076        var workflowDestination = workflowControl.getWorkflowDestinationByName(workflowStep, workflowDestinationName,
077                entityPermission);
078
079        if(workflowDestination == null) {
080            var workflowStepDetail = workflowStep.getLastDetail();
081            
082            handleExecutionError(UnknownWorkflowNameException.class, eea, ExecutionErrors.UnknownWorkflowDestinationName.name(),
083                    workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName(), workflowStepDetail.getWorkflowStepName(), workflowDestinationName);
084        }
085
086        return workflowDestination;
087    }
088
089    public WorkflowDestination getWorkflowDestinationByName(final ExecutionErrorAccumulator eea, final WorkflowStep workflowStep,
090            final String workflowDestinationName) {
091        return getWorkflowDestinationByName(eea, workflowStep, workflowDestinationName, EntityPermission.READ_ONLY);
092    }
093
094    public WorkflowDestination getWorkflowDestinationByNameForUpdate(final ExecutionErrorAccumulator eea, final WorkflowStep workflowStep,
095            final String workflowDestinationName) {
096        return getWorkflowDestinationByName(eea, workflowStep, workflowDestinationName, EntityPermission.READ_WRITE);
097    }
098
099    public WorkflowDestination getWorkflowDestinationByName(final ExecutionErrorAccumulator eea, final Workflow workflow, final String workflowStepName,
100            final String workflowDestinationName) {
101        var workflowStep = WorkflowStepLogic.getInstance().getWorkflowStepByName(eea, workflow, workflowStepName);
102        WorkflowDestination workflowDestination = null;
103
104        if(eea == null || !eea.hasExecutionErrors()) {
105            workflowDestination = getWorkflowDestinationByName(eea, workflowStep, workflowDestinationName, EntityPermission.READ_ONLY);
106        }
107
108        return workflowDestination;
109    }
110
111    public WorkflowDestination getWorkflowDestinationByName(final ExecutionErrorAccumulator eea, final String workflowName, final String workflowStepName,
112            final String workflowDestinationName) {
113        var workflowStep = WorkflowStepLogic.getInstance().getWorkflowStepByName(eea, workflowName, workflowStepName);
114        WorkflowDestination workflowDestination = null;
115        
116        if(eea == null || !eea.hasExecutionErrors()) {
117            workflowDestination = getWorkflowDestinationByName(eea, workflowStep, workflowDestinationName, EntityPermission.READ_ONLY);
118        }
119        
120        return workflowDestination;
121    }
122
123    public WorkflowDestination getWorkflowDestinationByUniversalSpec(final ExecutionErrorAccumulator eea, final WorkflowDestinationUniversalSpec universalSpec,
124            final boolean allowDefault, final EntityPermission entityPermission) {
125        var workflowControl = Session.getModelController(WorkflowControl.class);
126        var workflowName = universalSpec.getWorkflowName();
127        var workflowStepName = universalSpec.getWorkflowStepName();
128        var workflowDestinationName = universalSpec.getWorkflowDestinationName();
129        var nameParameterCount= ParameterUtils.getInstance().countNonNullParameters(workflowName, workflowStepName, workflowDestinationName);
130        var possibleEntitySpecs= EntityInstanceLogic.getInstance().countPossibleEntitySpecs(universalSpec);
131        WorkflowDestination workflowDestination = null;
132
133        if(nameParameterCount < 4 && possibleEntitySpecs == 0) {
134            WorkflowStep workflowStep = null;
135
136            if(workflowName != null && workflowStepName != null) {
137                workflowStep = WorkflowStepLogic.getInstance().getWorkflowStepByName(eea, workflowName, workflowStepName);
138            } else {
139                if(workflowName != null) {
140                    handleExecutionError(MissingRequiredWorkflowNameException.class, eea, ExecutionErrors.MissingRequiredWorkflowName.name());
141                }
142
143                if(workflowStepName != null) {
144                    handleExecutionError(MissingRequiredWorkflowStepNameException.class, eea, ExecutionErrors.MissingRequiredWorkflowStepName.name());
145                }
146            }
147
148            if(!eea.hasExecutionErrors()) {
149                if(workflowDestinationName == null) {
150                    if(allowDefault) {
151                        workflowDestination = workflowControl.getDefaultWorkflowDestination(workflowStep, entityPermission);
152
153                        if(workflowDestination == null) {
154                            handleExecutionError(UnknownDefaultWorkflowDestinationException.class, eea, ExecutionErrors.UnknownDefaultWorkflowDestination.name());
155                        }
156                    } else {
157                        handleExecutionError(InvalidParameterCountException.class, eea, ExecutionErrors.InvalidParameterCount.name());
158                    }
159                } else {
160                    workflowDestination = getWorkflowDestinationByName(eea, workflowStep, workflowDestinationName, entityPermission);
161                }
162            }
163        } else if(nameParameterCount == 0 && possibleEntitySpecs == 1) {
164            var entityInstance = EntityInstanceLogic.getInstance().getEntityInstance(eea, universalSpec,
165                    ComponentVendors.ECHO_THREE.name(), EntityTypes.WorkflowDestination.name());
166
167            if(!eea.hasExecutionErrors()) {
168                workflowDestination = workflowControl.getWorkflowDestinationByEntityInstance(entityInstance, entityPermission);
169            }
170        } else {
171            handleExecutionError(InvalidParameterCountException.class, eea, ExecutionErrors.InvalidParameterCount.name());
172        }
173
174        return workflowDestination;
175    }
176
177    public WorkflowDestination getWorkflowDestinationByUniversalSpec(final ExecutionErrorAccumulator eea, final WorkflowDestinationUniversalSpec universalSpec,
178            boolean allowDefault) {
179        return getWorkflowDestinationByUniversalSpec(eea, universalSpec, allowDefault, EntityPermission.READ_ONLY);
180    }
181
182    public WorkflowDestination getWorkflowDestinationByUniversalSpecForUpdate(final ExecutionErrorAccumulator eea, final WorkflowDestinationUniversalSpec universalSpec,
183            boolean allowDefault) {
184        return getWorkflowDestinationByUniversalSpec(eea, universalSpec, allowDefault, EntityPermission.READ_WRITE);
185    }
186
187    public Set<WorkflowStep> getWorkflowDestinationStepsAsSet(final WorkflowDestination workflowDestination) {
188        var workflowControl = Session.getModelController(WorkflowControl.class);
189        var workflowDestinationSteps = workflowControl.getWorkflowDestinationStepsByWorkflowDestination(workflowDestination);
190        Set<WorkflowStep> workflowSteps = new HashSet<>(workflowDestinationSteps.size());
191        
192        workflowDestinationSteps.forEach((workflowDestinationStep) -> {
193            workflowSteps.add(workflowDestinationStep.getWorkflowStep());
194        });
195        
196        return workflowSteps;
197    }
198    
199    public Map<String, Set<String>> getWorkflowDestinationsAsMap(final WorkflowDestination workflowDestination) {
200        var workflowControl = Session.getModelController(WorkflowControl.class);
201        var workflowDestinationSteps = workflowControl.getWorkflowDestinationStepsByWorkflowDestination(workflowDestination);
202        Map<String, Set<String>> map = new HashMap<>();
203        
204        workflowDestinationSteps.stream().map((workflowDestinationStep) -> workflowDestinationStep.getWorkflowStep().getLastDetail()).forEach((workflowStepDetail) -> {
205            var workflowStepName = workflowStepDetail.getWorkflowStepName();
206            var workflowName = workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName();
207            
208            workflowDestinationMapContainsStep(map, workflowName, workflowStepName, true);
209        });
210        
211        return map;
212    }
213    
214    private boolean workflowDestinationMapContainsStep(final Map<String, Set<String>> map, final String workflowName,
215            final String workflowStepName, final boolean addIt) {
216        var workflowSteps = map.get(workflowName);
217
218        if(workflowSteps == null && addIt) {
219            workflowSteps = new HashSet<>();
220            map.put(workflowName, workflowSteps);
221        }
222
223        var found = workflowSteps != null && workflowSteps.contains(workflowStepName);
224
225        if(!found && addIt) {
226            workflowSteps.add(workflowStepName);
227        }
228        
229        return found;
230    }
231
232    public boolean workflowDestinationMapContainsStep(final Map<String, Set<String>> map, final String workflowName,
233            final String workflowStepName) {
234       return workflowDestinationMapContainsStep(map, workflowName, workflowStepName, false);
235    }
236
237    public WorkflowDestinationPartyType getWorkflowDestinationPartyType(final ExecutionErrorAccumulator eea, final WorkflowDestination workflowDestination,
238            final PartyType partyType, final EntityPermission entityPermission) {
239        WorkflowDestinationPartyType workflowDestinationPartyType = null;
240
241        if(eea == null || !eea.hasExecutionErrors()) {
242            var workflowControl = Session.getModelController(WorkflowControl.class);
243
244            workflowDestinationPartyType = workflowControl.getWorkflowDestinationPartyType(workflowDestination, partyType, entityPermission);
245
246            if(workflowDestinationPartyType == null) {
247               var workflowDestinationDetail = workflowDestination.getLastDetail();
248               var workflowStepDetail = workflowDestinationDetail.getWorkflowStep().getLastDetail();
249
250                handleExecutionError(UnknownWorkflowDestinationPartyTypeException.class, eea, ExecutionErrors.UnknownWorkflowDestinationPartyType.name(),
251                        workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName(), workflowStepDetail.getWorkflowStepName(),
252                        workflowDestinationDetail.getWorkflowDestinationName(), partyType.getPartyTypeName());
253            }
254        }
255
256        return workflowDestinationPartyType;
257    }
258
259    public WorkflowDestinationPartyType getWorkflowDestinationPartyType(final ExecutionErrorAccumulator eea, final WorkflowDestination workflowDestination,
260            final PartyType partyType) {
261        return getWorkflowDestinationPartyType(eea, workflowDestination, partyType, EntityPermission.READ_ONLY);
262    }
263
264    public WorkflowDestinationPartyType getWorkflowDestinationPartyTypeForUpdate(final ExecutionErrorAccumulator eea, final WorkflowDestination workflowDestination,
265            final PartyType partyType) {
266        return getWorkflowDestinationPartyType(eea, workflowDestination, partyType, EntityPermission.READ_WRITE);
267    }
268
269    public WorkflowDestinationPartyType getWorkflowDestinationPartyTypeByName(final ExecutionErrorAccumulator eea, final String workflowName,
270            final String workflowStepName, final String workflowDestinationName, final String partyTypeName, final EntityPermission entityPermission) {
271        var workflowDestination = getWorkflowDestinationByName(eea, workflowName, workflowStepName, workflowDestinationName);
272        var partyType = PartyLogic.getInstance().getPartyTypeByName(eea, partyTypeName);
273
274        return getWorkflowDestinationPartyType(eea, workflowDestination, partyType, entityPermission);
275    }
276
277    public WorkflowDestinationPartyType getWorkflowDestinationPartyTypeByName(final ExecutionErrorAccumulator eea, final String workflowName,
278            final String workflowStepName, final String workflowDestinationName, final String partyTypeName) {
279        return getWorkflowDestinationPartyTypeByName(eea, workflowName, workflowStepName, workflowDestinationName, partyTypeName,
280                EntityPermission.READ_ONLY);
281    }
282
283
284    public WorkflowDestinationPartyType getWorkflowDestinationPartyTypeByNameForUpdate(final ExecutionErrorAccumulator eea, final String workflowName,
285            final String workflowStepName, final String workflowDestinationName, final String partyTypeName) {
286        return getWorkflowDestinationPartyTypeByName(eea, workflowName, workflowStepName, workflowDestinationName, partyTypeName,
287                EntityPermission.READ_WRITE);
288    }
289    
290    public WorkflowDestinationSecurityRole getWorkflowDestinationSecurityRoleByName(final ExecutionErrorAccumulator eea, final String workflowName,
291            final String workflowStepName, final String workflowDestinationName, final String partyTypeName, final String securityRoleName,
292            final EntityPermission entityPermission) {
293        var workflowDestination = getWorkflowDestinationByName(eea, workflowName, workflowStepName, workflowDestinationName);
294        var partyType = PartyLogic.getInstance().getPartyTypeByName(eea, partyTypeName);
295        WorkflowDestinationSecurityRole workflowDestinationSecurityRole = null;
296
297        if(eea == null || !eea.hasExecutionErrors()) {
298            var securityRoleGroup = workflowDestination.getLastDetail().getWorkflowStep().getLastDetail().getWorkflow().getLastDetail().getSecurityRoleGroup();
299
300            if(securityRoleGroup != null) {
301                var securityRole = SecurityRoleLogic.getInstance().getSecurityRoleByName(eea, securityRoleGroup, securityRoleName);
302
303                if(eea == null || !eea.hasExecutionErrors()) {
304                    var workflowDestinationPartyType = getWorkflowDestinationPartyType(eea, workflowDestination, partyType);
305
306                    if(eea == null || !eea.hasExecutionErrors()) {
307                        var workflowControl = Session.getModelController(WorkflowControl.class);
308
309                        workflowDestinationSecurityRole = workflowControl.getWorkflowDestinationSecurityRole(workflowDestinationPartyType,
310                                securityRole, entityPermission);
311
312                        if(workflowDestinationSecurityRole == null) {
313                            var workflowDestinationDetail = workflowDestination.getLastDetail();
314                            var workflowStepDetail = workflowDestinationDetail.getWorkflowStep().getLastDetail();
315                            var securityRoleDetail = securityRole.getLastDetail();
316
317                            handleExecutionError(UnknownWorkflowDestinationSecurityRoleException.class, eea, ExecutionErrors.UnknownWorkflowDestinationSecurityRole.name(),
318                                    workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName(),
319                                    workflowStepDetail.getWorkflowStepName(), workflowDestinationDetail.getWorkflowDestinationName(),
320                                    partyType.getPartyTypeName(), securityRoleDetail.getSecurityRole().getLastDetail().getSecurityRoleName());
321                        }
322                    }
323                }
324            } else {
325                var workflowStepDetail = workflowDestination.getLastDetail().getWorkflowStep().getLastDetail();
326
327                handleExecutionError(WorkflowMissingSecurityRoleGroupException.class, eea, ExecutionErrors.WorkflowMissingSecurityRoleGroup.name(),
328                        workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName());
329            }
330        }
331
332        return workflowDestinationSecurityRole;
333    }
334
335    public WorkflowDestinationSecurityRole getWorkflowDestinationSecurityRoleByName(final ExecutionErrorAccumulator eea, final String workflowName,
336            final String workflowStepName, final String workflowDestinationName, final String partyTypeName, final String securityRoleName) {
337        return getWorkflowDestinationSecurityRoleByName(eea, workflowName, workflowStepName, workflowDestinationName, partyTypeName,
338                securityRoleName, EntityPermission.READ_ONLY);
339    }
340
341
342    public WorkflowDestinationSecurityRole getWorkflowDestinationSecurityRoleByNameForUpdate(final ExecutionErrorAccumulator eea, final String workflowName,
343            final String workflowStepName, final String workflowDestinationName, final String partyTypeName, final String securityRoleName) {
344        return getWorkflowDestinationSecurityRoleByName(eea, workflowName, workflowStepName, workflowDestinationName, partyTypeName,
345                securityRoleName, EntityPermission.READ_WRITE);
346    }
347    
348    public WorkflowDestinationSelector getWorkflowDestinationSelectorByName(final ExecutionErrorAccumulator eea, final String workflowName,
349            final String workflowStepName, final String workflowDestinationName, final String selectorName,
350            final EntityPermission entityPermission) {
351        var workflowDestination = getWorkflowDestinationByName(eea, workflowName, workflowStepName, workflowDestinationName);
352        WorkflowDestinationSelector workflowDestinationSelector = null;
353
354        if(eea == null || !eea.hasExecutionErrors()) {
355            var selectorType = workflowDestination.getLastDetail().getWorkflowStep().getLastDetail().getWorkflow().getLastDetail().getSelectorType();
356
357            if(selectorType != null) {
358                var selector = SelectorLogic.getInstance().getSelectorByName(eea, selectorType, selectorName);
359
360                if(eea == null || !eea.hasExecutionErrors()) {
361                    var workflowControl = Session.getModelController(WorkflowControl.class);
362
363                    workflowDestinationSelector = workflowControl.getWorkflowDestinationSelector(workflowDestination,
364                            selector, entityPermission);
365
366                    if(workflowDestinationSelector == null) {
367                        var workflowDestinationDetail = workflowDestination.getLastDetail();
368                        var workflowStepDetail = workflowDestinationDetail.getWorkflowStep().getLastDetail();
369                        var selectorDetail = selector.getLastDetail();
370
371                        handleExecutionError(UnknownWorkflowDestinationSelectorException.class, eea, ExecutionErrors.UnknownWorkflowDestinationSelector.name(),
372                                workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName(),
373                                workflowStepDetail.getWorkflowStepName(), workflowDestinationDetail.getWorkflowDestinationName(),
374                                selectorDetail.getSelector().getLastDetail().getSelectorName());
375                    }
376                }
377            } else {
378                var workflowStepDetail = workflowDestination.getLastDetail().getWorkflowStep().getLastDetail();
379
380                handleExecutionError(WorkflowMissingSelectorTypeException.class, eea, ExecutionErrors.WorkflowMissingSelectorType.name(),
381                        workflowStepDetail.getWorkflow().getLastDetail().getWorkflowName());
382            }
383        }
384
385        return workflowDestinationSelector;
386    }
387
388    public WorkflowDestinationSelector getWorkflowDestinationSelectorByName(final ExecutionErrorAccumulator eea, final String workflowName,
389            final String workflowStepName, final String workflowDestinationName, final String selectorName) {
390        return getWorkflowDestinationSelectorByName(eea, workflowName, workflowStepName, workflowDestinationName, selectorName,
391                EntityPermission.READ_ONLY);
392    }
393
394
395    public WorkflowDestinationSelector getWorkflowDestinationSelectorByNameForUpdate(final ExecutionErrorAccumulator eea, final String workflowName,
396            final String workflowStepName, final String workflowDestinationName, final String selectorName) {
397        return getWorkflowDestinationSelectorByName(eea, workflowName, workflowStepName, workflowDestinationName, selectorName,
398                EntityPermission.READ_WRITE);
399    }
400
401    public WorkflowStep getDestinationWorkflowStep(final ExecutionErrorAccumulator eea, final String destinationWorkflowName,
402            final String destinationWorkflowStepName) {
403        return WorkflowStepLogic.getInstance().getWorkflowStepByName(
404                UnknownDestinationWorkflowNameException.class, ExecutionErrors.UnknownDestinationWorkflowName,
405                UnknownDestinationWorkflowStepNameException.class, ExecutionErrors.UnknownDestinationWorkflowStepName,
406                eea, destinationWorkflowName, destinationWorkflowStepName);
407    }
408
409    public WorkflowDestinationStep getWorkflowDestinationStep(final ExecutionErrorAccumulator eea,
410            WorkflowDestination workflowDestination, WorkflowStep destinationWorkflowStep) {
411        var workflowControl = Session.getModelController(WorkflowControl.class);
412        var workflowDestinationStep = workflowControl.getWorkflowDestinationStep(workflowDestination, destinationWorkflowStep);
413
414        if(workflowDestinationStep == null) {
415            var workflowDestinationDetail = workflowDestination.getLastDetail();
416            var destinationWorkflowStepDetail = destinationWorkflowStep.getLastDetail();
417
418            handleExecutionError(UnknownWorkflowDestinationStepException.class, eea, ExecutionErrors.UnknownWorkflowDestinationStep.name(),
419                    workflowDestinationDetail.getWorkflowStep().getLastDetail().getWorkflow().getLastDetail().getWorkflowName(),
420                    workflowDestinationDetail.getWorkflowStep().getLastDetail().getWorkflowStepName(),
421                    workflowDestinationDetail.getWorkflowDestinationName(),
422                    destinationWorkflowStepDetail.getWorkflow().getLastDetail().getWorkflowName(),
423                    destinationWorkflowStepDetail.getWorkflowStepName());
424        }
425
426        return workflowDestinationStep;
427    }
428
429    public WorkflowDestinationStep getWorkflowDestinationStepByName(final ExecutionErrorAccumulator eea,
430            final String workflowName, final String workflowStepName, final String workflowDestinationName,
431            final String destinationWorkflowName, final String destinationWorkflowStepName) {
432        var workflowDestination = getWorkflowDestinationByName(eea, workflowName, workflowStepName, workflowDestinationName);
433        var destinationWorkflowStep = getDestinationWorkflowStep(eea, destinationWorkflowName, destinationWorkflowStepName);
434        WorkflowDestinationStep workflowDestinationStep = null;
435
436        if(eea == null || !eea.hasExecutionErrors()) {
437            workflowDestinationStep = getWorkflowDestinationStep(eea, workflowDestination, destinationWorkflowStep);
438        }
439
440        return workflowDestinationStep;
441    }
442
443}