WflLinkContextValue.java

package com.mycim.valueobject.prp;

import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.framework.utils.lang.collections.MapUtils;
import com.mycim.framework.utils.lang.math.NumberUtils;
import com.mycim.valueobject.consts.ContextNames;

import java.util.Map;

/**
 * @author andy
 */
public class WflLinkContextValue extends AbstractContextValue {

    private static final long serialVersionUID = -3124642219617636022L;

    public static final String SEPARATOR = ",";

    public static final String DEFAULT_LINK_ID = "DEFAULT";

    public WflLinkContextValue() {
        this.setContextId(ContextNames.WFL_LINK_CONTEXT);
    }

    /**
     * @param contextRrn
     */
    public WflLinkContextValue(long contextRrn) {
        super(contextRrn);
    }

    public WflLinkContextValue(ContextValue contextValue) {
        super.copy(contextValue);
    }

    /**
     * @return the lotRrn
     */
    @java.lang.Override
    public Long getLotRrn() {
        return NumberUtils.createLong(StringUtils.trimToNull(this.getContextKey5()));
    }

    /**
     * @param lotRrn the lotRrn to set
     */
    @java.lang.Override
    public void setLotRrn(Long lotRrn) {
        if (lotRrn != null) {
            this.setContextKey5(lotRrn + "");
        }
    }

    /**
     * @return the wflLinkType
     */
    public String getWflLinkType() {
        return StringUtils.trimToNull(this.getContextKey6());
    }

    /**
     * @param wflLinkType the wflLinkType to set
     */
    public void setWflLinkType(String wflLinkType) {
        if (wflLinkType != null) {
            this.setContextKey6(wflLinkType + "");
        }
    }

    /**
     * @return the wflLinkId
     */
    public String getWflLinkId() {
        return StringUtils.trimToNull(this.getResultValue1());
    }

    /**
     * @param wflLinkId the wflLinkId to set
     */
    public void setWflLinkId(String wflLinkId) {
        if (StringUtils.isNotEmpty(wflLinkId)) {
            this.setResultValue1(wflLinkId);
        }
    }

    /**
     * @return the recipeId
     */
    public String getRecipeId() {
        return StringUtils.trimToNull(this.getResultValue2());
    }

    /**
     * @param recipeId the recipeId to set
     */
    public void setRecipeId(String recipeId) {
        if (StringUtils.isNotBlank(recipeId)) {
            this.setResultValue2(recipeId);
        }
    }

    /**
     * @return the reticleId
     */
    public String getReticleId() {
        return StringUtils.trimToNull(this.getResultValue3());
    }

    /**
     * @param reticleId the reticleId to set
     */
    public void setReticleId(String reticleId) {
        if (StringUtils.isNotBlank(reticleId)) {
            this.setResultValue3(reticleId);
        }
    }

    /**
     * @return the parameterSetId
     */
    public String getParameterSetId() {
        return StringUtils.trimToNull(this.getResultValue4());
    }

    /**
     * @param parameterSetId the parameterSetId to set
     */
    public void setParameterSetId(String parameterSetId) {
        if (StringUtils.isNotBlank(parameterSetId)) {
            this.setResultValue4(parameterSetId);
        }
    }

    /**
     * @return the equipmentIdStr
     */
    public String getEquipmentIdStr() {
        return StringUtils.trimToNull(this.getResultValue5());
    }

    /**
     * @param equipmentIdStr the equipmentIdStr to set
     */
    public void setEquipmentIdStr(String equipmentIdStr) {
        if (StringUtils.isNotBlank(equipmentIdStr)) {
            this.setResultValue5(equipmentIdStr);
        }
    }

    public static WflLinkContextValue buildWithMap(Map matchingRules) {
        WflLinkContextValue wflLinkContextValue = new WflLinkContextValue();
        if (matchingRules.isEmpty()) {
            return wflLinkContextValue;
        }
        wflLinkContextValue.setProductRrn(MapUtils.getLong(matchingRules, "productRrn"));
        wflLinkContextValue.setProcessRrn(MapUtils.getLong(matchingRules, "processRrn"));
        wflLinkContextValue.setRouteRrn(MapUtils.getLong(matchingRules, "routeRrn"));
        wflLinkContextValue.setOperationRrn(MapUtils.getLong(matchingRules, "operationRrn"));
        wflLinkContextValue.setLotRrn(MapUtils.getLong(matchingRules, "lotRrn"));
        return wflLinkContextValue;
    }

    public String buildMatchRuleStr() {
        StringBuffer matchRule = new StringBuffer();
        matchRule.append(StringUtils.convertObjectToStr(this.getProductRrn())).append(SEPARATOR)
                 .append(StringUtils.convertObjectToStr(this.getProcessRrn())).append(SEPARATOR)
                 .append(StringUtils.convertObjectToStr(this.getRouteRrn())).append(SEPARATOR)
                 .append(StringUtils.convertObjectToStr(this.getOperationRrn())).append(SEPARATOR)
                 .append(StringUtils.convertObjectToStr(this.getLotRrn()));
        return matchRule.toString();
    }

    public String getRouteSeq() {
        return StringUtils.trimToNull(this.getContextKey7());
    }

    public void setRouteSeq(String routeSeq) {
        this.setContextKey7(routeSeq);
    }

    public String getOperationSeq() {
        return StringUtils.trimToNull(this.getContextKey8());
    }

    public void setOperationSeq(String operationSeq) {
        this.setContextKey8(operationSeq);
    }

    /**
     * contextKey14
     *
     * @return
     */
    public Integer getProcessVersion() {
        return NumberUtils.toInt(this.getContextKey14());
    }

    /**
     * contextKey14
     *
     * @param processVersion
     */
    public void setProcessVersion(Integer processVersion) {
        if (processVersion != null) {
            this.setContextKey14(StringUtils.toString(processVersion));
        }
    }

}