Check if the global workflow regions and the regions of stages (apps) match.
    If the workflow contains any applets, the workflow can be currently enabled
    in only one region - the region in which the applets are stored.
769927
def _assert_executable_regions_match(workflow_enabled_regions, workflow_spec):
    
    executables = [i.get("executable") for i in workflow_spec.get("stages")]

    for exect in executables:

        if exect.startswith("applet-") and len(workflow_enabled_regions) > 1:
            raise WorkflowBuilderException("Building a global workflow with applets in more than one region is not yet supported.")

        elif exect.startswith("app-"):
            app_regional_options = dxpy.api.app_describe(exect, input_params={"fields": {"regionalOptions": True}})
            app_regions = set(app_regional_options['regionalOptions'].keys())
            if not workflow_enabled_regions.issubset(app_regions):
                additional_workflow_regions = workflow_enabled_regions - app_regions
                mesg = "The app {} is enabled in regions {} while the global workflow in {}.".format(
                    exect, ", ".join(app_regions), ", ".join(workflow_enabled_regions))
                mesg += " The workflow will not be able to run in {}.".format(", ".join(additional_workflow_regions))
                mesg += " If you are a developer of the app, you can enable the app in {} to run the workflow in that region(s).".format(
                    ", ".join(additional_workflow_regions))
                logger.warn(mesg)

        elif exect.startswith("workflow-"):
             # We recurse to check the regions of the executables of the inner workflow
            inner_workflow_spec = dxpy.api.workflow_describe(exect)
            _assert_executable_regions_match(workflow_enabled_regions, inner_workflow_spec)

        elif exect.startswith("globalworkflow-"):
            raise WorkflowBuilderException("Building a global workflow with nested global workflows is not yet supported")
619443
function (coord) {
        var regions = this.regions;
        for (var i = 0; i < regions.length; i++) {
            if (regions[i].contain(coord)) {
                return true;
            }
        }
        return false;
    }
685806
protected boolean isWorkflowProject(CmsUUID projectId) {

        try {
            return m_workflowProjectStatus.get(projectId).booleanValue();
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return false;
        }
    }
241230
function askRegion() {
    if (this.abort) return null;
    const done = this.async();
    const prompts = [
        {
            type: 'list',
            name: 'region',
            message: 'Which region?',
            choices: regionList,
            default: this.aws.region ? _.indexOf(regionList, this.aws.region) : this.awsFacts.defaultRegion
        }
    ];

    return this.prompt(prompts).then(props => {
        const region = props.region;
        if (region) {
            this.aws.region = region;
            done();
        } else {
            this.abort = true;
            done();
        }
    });
}
659101
private static boolean checkVerticesForIntersection_(
			MultiVertexGeometryImpl geom, RasterizedGeometry2D rgeom) {
		// Do a quick raster test for each point. If any point is inside, then
		// there is an intersection.
		int pointCount = geom.getPointCount();
		Point2D pt = new Point2D();
		for (int ipoint = 0; ipoint < pointCount; ipoint++) {
			geom.getXY(ipoint, pt);
			RasterizedGeometry2D.HitType hit = rgeom.queryPointInGeometry(pt.x,
					pt.y);
			if (hit == RasterizedGeometry2D.HitType.Inside) {
				return true;
			}
		}

		return false;
	}
665058
public boolean actionCheckSiblings() {

        List<String> resourceList = getResourceList();
        String resourcePath;
        Iterator<String> itResourcePaths = resourceList.iterator();
        boolean foundSibling = false;
        while (itResourcePaths.hasNext()) {
            resourcePath = itResourcePaths.next();
            try {
                foundSibling = recursiveCheckSiblings(resourcePath);
                if (foundSibling) {
                    break; // shortcut
                }

            } catch (CmsException e) {
                LOG.error(Messages.get().getBundle(getLocale()).key(
                    Messages.ERR_UNDO_CHANGES_1,
                    new String[] {resourcePath}));
            }

        }
        return foundSibling;
    }
688478
function () {

      var wfInput = this._events[0].workflowExecutionStartedEventAttributes.input;

      try {
         var d = JSON.parse(wfInput);
         return d;
      } catch (ex) {
         return wfInput;
      }
   }
896662
def find_workflow_path(self):
        
        for pth in settings.WORKFLOW_PACKAGES_PATHS:
            path = "%s/%s.bpmn" % (pth, self.current.workflow_name)
            if os.path.exists(path):
                return path
        err_msg = "BPMN file cannot found: %s" % self.current.workflow_name
        log.error(err_msg)
        raise RuntimeError(err_msg)
30527
def getObjectWorkflowStates(self):
        
        workflow = getToolByName(self, 'portal_workflow')
        states = {}
        for w in workflow.getWorkflowsFor(self):
            state = api.get_workflow_status_of(self, w.state_var)
            states[w.state_var] = state
        return states
863212
function (options) {
    var regions;
    this._initRegionManager();

    if (_.isFunction(this.regions)) {
      regions = this.regions(options);
    } else {
      regions = this.regions || {};
    }

    this.addRegions(regions);
  }
586165
@Override
    protected final QueryResult executeWorkFlow(LogicalWorkflow workflow) throws ConnectorException {

        checkIsSupported(workflow);
        ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();

        return execute((Project) workflow.getInitialSteps().get(0),
                connectionHandler.getConnection(clusterName.getName()));
    }
999249
private boolean isServiceSupportedInRegion(String serviceName) {
        return partition.getServices().get(serviceName) != null
                && partition.getServices().get(serviceName).getEndpoints()
                .containsKey(region);
    }
203453
def complete(self):
        
        if self.task.local_workflow_require_branches:
            return self._has_run
        else:
            return super(LocalWorkflowProxy, self).complete()
685470
private boolean isStageActive(Pipeline pipeline, StageConfig nextStage) {
        return stageDao.isStageActive(pipeline.getName(), CaseInsensitiveString.str(nextStage.name()));
    }
956575
public boolean isGlobalTxActive()
   {
      TransactionContext ctx;
      try
      {
         // We need to check the status also to be able to manage properly suspend and resume
         return (ctx = contexts.get()) != null && ctx.getXidContext() != null && tm.getStatus() != Status.STATUS_NO_TRANSACTION;
      }
      catch (SystemException e)
      {
         log.warn("Could not check if a global Tx has been started", e);
      }
      return false;
   }
282229
def _build_underlying_workflows(enabled_regions, json_spec, args):
    
    projects_by_region = _create_temporary_projects(enabled_regions, args)
    workflows_by_region = {}

    try:
        for region, project in projects_by_region.items():
            json_spec['project'] = project
            workflow_id = _build_regular_workflow(json_spec)
            logger.debug("Created workflow " + workflow_id + " successfully")
            workflows_by_region[region] = workflow_id
    except:
        # Clean up
        if projects_by_region:
            dxpy.executable_builder.delete_temporary_projects(projects_by_region.values())
        raise

    return workflows_by_region, projects_by_region
30148
public DeciderOutcome decide(Workflow workflow) throws TerminateWorkflowException {

        //In case of a new workflow the list of tasks will be empty.
        final List<Task> tasks = workflow.getTasks();
        // Filter the list of tasks and include only tasks that are not executed,
        // not marked to be skipped and not ready for rerun.
        // For a new workflow, the list of unprocessedTasks will be empty
        List<Task> unprocessedTasks = tasks.stream()
                .filter(t -> !t.getStatus().equals(SKIPPED) && !t.getStatus().equals(READY_FOR_RERUN) && !t.isExecuted())
                .collect(Collectors.toList());

        List<Task> tasksToBeScheduled = new LinkedList<>();
        if (unprocessedTasks.isEmpty()) {
            //this is the flow that the new workflow will go through
            tasksToBeScheduled = startWorkflow(workflow);
            if (tasksToBeScheduled == null) {
                tasksToBeScheduled = new LinkedList<>();
            }
        }
        return decide(workflow, tasksToBeScheduled);
    }