workflow.js revision 6c48312a132cb29f83b7b1b6bc87db4d7901f88e
0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0N/A *
0N/A * Copyright (c) 2012 ForgeRock AS. All Rights Reserved
2362N/A *
0N/A * The contents of this file are subject to the terms
0N/A * of the Common Development and Distribution License
0N/A * (the License). You may not use this file except in
0N/A * compliance with the License.
2362N/A *
0N/A * You can obtain a copy of the License at
2362N/A * http://forgerock.org/license/CDDLv1.0.html
0N/A * See the License for the specific language governing
0N/A * permission and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL
0N/A * Header Notice in each file and include the License file
0N/A * at http://forgerock.org/license/CDDLv1.0.html
0N/A * If applicable, add the following below the CDDL Header,
0N/A * with the fields enclosed by brackets [] replaced by
0N/A * your own identifying information:
0N/A * "Portions Copyrighted [year] [name of copyright owner]"
0N/A */
0N/A
0N/A/*
0N/A Try to find running process started by the previous reconciliation.
0N/A */
0N/A
0N/A/*global workflowName,recon */
0N/A
0N/A(function () {
0N/A var queryParams = {
0N/A "_queryId" : "filtered-query",
0N/A "processDefinitionKey": workflowName,
0N/A "_var-mapping":recon.actionParam.mapping,
0N/A "_var-situation":recon.actionParam.situation,
0N/A "_var-action":recon.actionParam.action
0N/A },
0N/A process,
0N/A businessKey = "sourceId: " + recon.actionParam.sourceId + ", targetId: " + recon.actionParam.targetId + ", reconId: " + recon.actionParam.reconId;
0N/A
0N/A if (typeof recon.actionParam.sourceId !== "undefined" && null !== recon.actionParam.sourceId) {
0N/A queryParams["_var-sourceId"] = recon.actionParam.sourceId;
0N/A }
0N/A if (typeof recon.actionParam.targetId !== "undefined" && null !== recon.actionParam.targetId) {
0N/A queryParams["_var-targetId"] = recon.actionParam.targetId;
0N/A }
0N/A
0N/A process = openidm.query('workflow/processinstance', queryParams);
0N/A logger.trace("asynchronous reconciliation: process.result.length => {}", process.result.length);
0N/A
0N/A /*
0N/A Check if the result of the search.
0N/A */
0N/A if (typeof process.result === "undefined" || null === process.result || 0 === process.result.length) {
0N/A /*
0N/A There is no process instance found so we start one.
0N/A */
0N/A recon.actionParam._key = workflowName;
0N/A recon.actionParam._businessKey = businessKey;
0N/A logger.trace("asynchronous reconciliation: Start '{}' process", recon.actionParam._key);
0N/A openidm.action('workflow/processinstance', {"_action" : "createProcessInstance"}, recon.actionParam);
0N/A }
0N/A
0N/A /*
0N/A Return "ASYNC" for the Reconciliation engine to finish processing the job.
0N/A */
0N/A return "ASYNC";
0N/A}());