package com.capgemini.reports.teamcenter.queries.saved;

import com.capgemini.framework.teamcenter.authent.TcSession;
import com.capgemini.framework.teamcenter.queries.saved.AbstractReplicatedQuery;
import com.teamcenter.soa.client.model.strong.EPMTask;

/**
 * This class is able to look for WKF objects in Teamcenter from a Part.
 */
public class WorkflowOnChangeQuery extends AbstractReplicatedQuery<EPMTask, WorkflowOnChangeQuery> {

    /**
     * Query name of Teamcenter for request in WKF objects.
     */
    private static final String QUERY_SUFFIX = "WKF_on_Change";
    private static final String PARAM_SUFFIX_WKF_NAME = REPCOL_PREFIX + "wkf_name";
    private static final String PARAM_SUFFIX_SEQUENCE_ID = REPCOL_PREFIX + "sequence_id";

    /**
     * Construct a Query to obtain the Workflow(s) acting on a specific ItemRevision.
     *
     * @param session the Tc session
     */
    public WorkflowOnChangeQuery(final TcSession session) {
        super(session, QUERY_SUFFIX);
    }

    @Override
    public WorkflowOnChangeQuery searchName(final String wkfName) {
        return this.addParam(PARAM_SUFFIX_WKF_NAME, wkfName);
    }

    /**
     * Add a search on the sequence_id param.
     *
     * @param sequenceId the sequence ID
     * @return the query
     */
    public WorkflowOnChangeQuery searchSequenceId(final String sequenceId) {
        return this.addParam(PARAM_SUFFIX_SEQUENCE_ID, sequenceId);
    }

    @Override
    protected WorkflowOnChangeQuery selfCast() {
        return this;
    }

}
