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