Java tutorial
/** * PureInfo Command-PHASE2 * @(#)GeneratePrjCardId.java 1.0 2007-12-5 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.studio.db.cmd2srm.ref.impl; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import com.pureinfo.dolphin.mapping.EntityMetadata; import com.pureinfo.dolphin.model.DolphinObject; import com.pureinfo.dolphin.persister.ISession; import com.pureinfo.force.exception.PureException; import com.pureinfo.importer.ref.IImportorRef; import com.pureinfo.srm.org.model.Organization; import com.pureinfo.srm.project.CardIdGenerator; import com.pureinfo.srm.project.model.Project; /** * <P> * Created on 2007-12-5 03:42:42<BR> * Last modified on 2007-12-5 * </P> * GeneratePrjCardId * * @author sunjie * @version 1.0, 2007-12-5 * @since Command-PHASE2 1.0 */ public class GeneratePrjCardId implements IImportorRef { private Logger logger = Logger.getLogger(this.getClass().getName()); /** * @see com.pureinfo.importer.ref.IImportorRef#convert(com.pureinfo.dolphin.model.DolphinObject, * com.pureinfo.dolphin.model.DolphinObject, java.lang.String, * java.lang.String, com.pureinfo.dolphin.persister.ISession, * com.pureinfo.dolphin.persister.ISession, * com.pureinfo.dolphin.mapping.EntityMetadata, java.lang.String, * java.lang.String) */ public Object convert(DolphinObject _old, DolphinObject _new, String _sFromProperty, String _sToProperty, ISession _fromSession, ISession _toSession, EntityMetadata _metadata, String _sKey, String _sToTable) throws PureException { String sCampus = null; String sOrgCode = null; String sPrjSort = null; String sAS = null; Project project = (Project) _new; sCampus = project.getCampus();// sAS = project.getStrProperty("administerSection");// Organization org = project.getDepartment(); if (org == null) { logger.error("error occur when generate prjCardId. project has no department."); return null; } sOrgCode = org.getCode(); sOrgCode = StringUtils.rightPad(sOrgCode, 5, '0'); sPrjSort = project.getPrjSortId();//.getRequiredParameter("prjSortId", ""); logger.debug("to generate prjCardId of:"); logger.debug("" + sCampus); logger.debug("" + sAS); logger.debug("" + sPrjSort); logger.debug("" + sOrgCode); CardIdGenerator cg = CardIdGenerator.instance(sCampus, sOrgCode, sPrjSort, sAS); String nextValue = cg.getNextId(); cg.advance(); return nextValue; } }