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.ItemRevision;

/**
 * This class is able to look for ChangeItem Revision objects in Teamcenter from a Part.
 */
public class ChangeFromPartQuery extends AbstractReplicatedQuery<ItemRevision, ChangeFromPartQuery> {
    /**
     * Query name of Teamcenter for request in Unit objects.
     */
    private static final String QUERY_SUFFIX_CHANGE_FROM_PART = "Change_from_Part";
    private static final String PARAM_PART_ID = "part_id";
    private static final String PARAM_PART_REVISION = "part_revision";

    /**
     * Constructor to build a Query for ChangeItem objects from a Part.
     *
     * @param session the session for the connection
     */
    public ChangeFromPartQuery(final TcSession session) {
        super(session, QUERY_SUFFIX_CHANGE_FROM_PART);
    }

    @Override
    public ChangeFromPartQuery searchID(final String partId) {
        return this.addParam(AbstractReplicatedQuery.REPCOL_PREFIX + PARAM_PART_ID, partId);
    }


    @Override
    public ChangeFromPartQuery searchRevision(final String partRevision) {
        return this.addParam(AbstractReplicatedQuery.REPCOL_PREFIX + PARAM_PART_REVISION, partRevision);
    }

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