com.pureinfo.srm.project.CardIdGeneratorForNongsheAndGaoxinban.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srm.project.CardIdGeneratorForNongsheAndGaoxinban.java

Source

/**
 * PureInfo Command
 * @(#)CardIdGenerator.java   1.0 2006-5-9
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srm.project;

import org.apache.commons.lang.StringUtils;

import com.pureinfo.ark.content.ArkContentHelper;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.srm.org.domain.IOrganizationMgr;
import com.pureinfo.srm.org.model.Organization;
import com.pureinfo.srm.project.model.Project;

/**
 * <P>
 * Created on 2006-5-9 15:59:22<BR>
 * Last modified on 2006-5-9
 * </P>
 * /<BR>
 * 
 * <ol>
 * <li> as String
 * <li> as Integer
 * <li> as String
 * </ol>
 * @author elmar.chen
 * @version 1.0, 2006-5-9
 * @since Command 1.0 
 */
public class CardIdGeneratorForNongsheAndGaoxinban extends CodeGenerator {

    protected String getIndentifier() {
        return "CARD-ID-NG";
    }

    protected int getMaxSerial() {
        return 99;
    }

    protected String getPattern() {
        return "$0$1-$2$Y2$S";
    }

    protected int getSerialWidth() {
        return 2;
    }

    protected String[] getTokens(Object[] _params) throws PureException {
        String sCampus = (String) _params[0];

        Integer iOrgId = (Integer) _params[1];
        int nOrgId = iOrgId.intValue();
        IOrganizationMgr mgr = (IOrganizationMgr) ArkContentHelper.getContentMgrOf(Organization.class);
        Organization org = (Organization) mgr.lookupById(nOrgId);
        String sOrgCode = org.getCode();
        sOrgCode = StringUtils.rightPad(sOrgCode, 5, '0');

        String sPrjType = (String) _params[2];

        return new String[] { sCampus, sOrgCode, sPrjType };
    }

    protected CarageInof getCarageInof() {
        return new CarageInof(Project.class, "cardId");
    }

    protected int[] getKeyTokenIdxes() {
        return new int[] { 0, 2 };
    }
}