/**
 * Copyright 2005-2018 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.rice.kew.engine;

import org.kuali.rice.kew.actiontaken.ActionTakenValue;
import org.kuali.rice.kew.api.KewApiConstants;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;


/**
 * Specifies configuration for orchestration through the engine.
 * 
 * @author Kuali Rice Team (rice.collab@kuali.org)
 */
public class OrchestrationConfig {

    public enum EngineCapability { STANDARD, BLANKET_APPROVAL, SIMULATION }
    
    private final EngineCapability capability;
    private final boolean sendNotifications;
    private final String notificationType = KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ;
    private final Set<String> destinationNodeNames;
    private final ActionTakenValue cause;
    private final boolean runPostProcessorLogic;
    //KULRICE-12283: Added two new flags to indicate if acknowledgements and FYIs should be deactivated
    private final boolean deactivateAcknowledgements;
    private final boolean deactivateFYIs;
    private final boolean supressRequestsNodePolicyErrors;

    public OrchestrationConfig(EngineCapability capability) {
        this(capability, Collections.<String>emptySet(), null, true, true);
    }
    
    public OrchestrationConfig(EngineCapability capability, boolean isRunPostProcessorLogic) {
        this(capability, Collections.<String>emptySet(), null, true, isRunPostProcessorLogic);
    }
    
    public OrchestrationConfig(EngineCapability capability, Set<String> destinationNodeNames, ActionTakenValue cause) {
        this(capability, destinationNodeNames, cause, true, true);
    }

    //KULRICE-12283: Added new constructors which set up the two new properties
    public OrchestrationConfig(EngineCapability capability, Set<String> destinationNodeNames, ActionTakenValue cause,
            boolean sendNotifications, boolean doRunPostProcessorLogic) {
        this(capability, destinationNodeNames, cause, sendNotifications, doRunPostProcessorLogic, false, false, false);
    }

    public OrchestrationConfig(EngineCapability capability, Set<String> destinationNodeNames, ActionTakenValue cause,
            boolean sendNotifications, boolean doRunPostProcessorLogic, boolean deactivateAcknowledgements,
            boolean deactivateFYIs, boolean supressRequestsNodePolicyErrors) {
        this.capability = capability;
        this.destinationNodeNames = Collections.unmodifiableSet(new HashSet<String>(destinationNodeNames));
        this.cause = cause;
        this.sendNotifications = sendNotifications;
        this.runPostProcessorLogic = doRunPostProcessorLogic;
        this.deactivateAcknowledgements = deactivateAcknowledgements;
        this.deactivateFYIs = deactivateFYIs;
        this.supressRequestsNodePolicyErrors = supressRequestsNodePolicyErrors;
    }

    public boolean isSupressRequestsNodePolicyErrors() {
        return supressRequestsNodePolicyErrors;
    }

    public Set<String> getDestinationNodeNames() {
        return destinationNodeNames;
    }

    public String getNotificationType() {
        return notificationType;
    }

    public boolean isSendNotifications() {
        return sendNotifications;
    }

    public ActionTakenValue getCause() {
        return cause;
    }

	public boolean isRunPostProcessorLogic() {
		return this.runPostProcessorLogic;
	}

    /**
     * @return the capability
     */
    public EngineCapability getCapability() {
        return this.capability;
    }

    //KULRICE-12283: Added getters for two new properties
    public boolean isDeactivateAcknowledgements() {
        return deactivateAcknowledgements;
    }

    public boolean isDeactivateFYIs() {
        return deactivateFYIs;
    }

}
