package com.vci.server.bof; import java.util.HashMap; import java.util.Map; import javax.xml.rpc.holders.LongHolder; import com.vci.corba.bofactory.BOFactoryService; import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.data.BusinessObject; import com.vci.corba.omd.data.LinkObject; import com.vci.corba.omd.data.RevisionDataInfo; import com.vci.corba.omd.data.VersionDataInfo; import com.vci.corba.omd.lcm.TransitionVO; import com.vci.server.BaseService; import com.vci.server.bof.delegate.BOFactoryServerBODelegate; import com.vci.server.bof.delegate.BOFactoryServerDelegate; import com.vci.server.bof.delegate.BatchSqlServerDelegate; import com.vci.server.bof.delegate.CustomSqlServerDelegate; import com.vci.server.bof.delegate.LOFacotryServerLODelegate; import com.vci.server.bof.delegate.LOFactoryServerDelegate; import com.vci.server.bof.service.BatchTransferService; import com.zeroc.Ice.Current; import com.vci.corba.common.VCIError; import com.vci.common.ServiceNames; import com.vci.common.log.ServerWithLog4j; import com.vci.corba.framework.data.UserInfo; public class BOFactoryServiceImpl extends BaseService implements BOFactoryService { @Override public String getServiceName() { return ServiceNames.BOFSERVICE; } /* * 初始化BOF服务 */ public BOFactoryServiceImpl() { //HibernateSessionFactory.getSessionFactory(); } @Override public void test(Current current) { } @Override public BusinessObject initBusinessObject(String btmName, Current current) throws VCIError { BOFactoryServerBODelegate bofDelegate = BOFactoryServerBODelegate.getInstance(); return bofDelegate.initBusinessObject(btmName); } @Override public BusinessObject revisionBusinessObject(BusinessObject bo, LinkObject[] los, boolean isRev, boolean isSave, boolean isFromLinkCopy, boolean isToLinkCopy, Current current) throws VCIError { BOFactoryServerBODelegate bofDelegate = BOFactoryServerBODelegate.getInstance(); return bofDelegate.revisionBusinessObject(bo, los, isRev, isSave, isFromLinkCopy, isToLinkCopy); } @Override public BusinessObject revisionBusinessObjectWithLink(BusinessObject bo, String[] linkTypes, boolean isRev, boolean isSave, boolean isFromLinkCopy, boolean isToLinkCopy, Current current) throws VCIError { BOFactoryServerBODelegate bofDelegate = BOFactoryServerBODelegate.getInstance(); return bofDelegate.revisionBusinessObject(bo, linkTypes, isRev, isSave, isFromLinkCopy, isToLinkCopy); } public BusinessObject createBusinessObject(BusinessObject bo, boolean isRevision, boolean isNewVersion, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.createBusinessObject(bo, isRevision, isNewVersion); } @Override public boolean createBusinessObjectWithLink(BusinessObject[] bos, LinkObject lo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.createBusinessObject(bos, lo); } public UpdateBusinessObjectResult updateBusinessObject(BusinessObject bo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); boolean success = bofDelegate.updateBuinessObject(bo); return new UpdateBusinessObjectResult(success, bo.ts); } public boolean updateBusinessObjectOut(BusinessObject bo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.updateBuinessObject(bo); } public boolean deleteBusinessObject(BusinessObject bo, long type, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.deleteBusinessObject(bo, (int) type); } @Override public BusinessObject readBusinessObject(String oid, String btwName, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); BusinessObject bo = bofDelegate.getInfoBusinessObject(oid, btwName); if (bo == null) { bo = new BusinessObject(); bo.newAttrValList = new AttributeValue[0]; bo.hisAttrValList = new AttributeValue[0]; } return bo; } @Override public BusinessObject[] getLastRevisionBusinessObject(String oid, String btwName, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); BusinessObject[] bos = bofDelegate.getLastRevisionBusinessObject(oid, btwName); if (bos == null) { bos = new BusinessObject[0]; } return bos; } public BusinessObject[] getBatchBusinessObject(String[] oids, String btmName, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); BusinessObject[] bos = bofDelegate.getBatchBusinessObject(oids, btmName); return bos; } @Override public BusinessObject[] batchGetBusinessObjects(String btName, int page, int pageSize, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); BusinessObject[] bos = bofDelegate.getBatchBusinessObjects(btName, page, pageSize); return bos; } @Override public boolean checkInBusinessObject(BusinessObject bo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.checkInBusinessObject(bo); } @Override public boolean checkoutBusinessObject(BusinessObject bo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.checkoutBusinessObject(bo); } @Override public boolean unCheckOutBusinessObject(BusinessObject bo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.undoCheckoutBusinessObject(bo); } @Override public boolean changeBusinessObjectOwner(BusinessObject bo, UserInfo userInfo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.changeBusinessObjectOwner(bo, userInfo); } @Override public boolean transferBusinessObject(BusinessObject bo, TransitionVO vo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.transferBusinessObject(bo, vo, ""); } @Override public boolean transferBusinessObjectAndRelease(BusinessObject bo, TransitionVO vo, String releaseStatus, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.transferBusinessObject(bo, vo, releaseStatus); } @Override public LinkObject initLinkObject(String ltName, Current current) throws VCIError { LOFacotryServerLODelegate bofDelegate = LOFacotryServerLODelegate.getInstance(); return bofDelegate.initLinkObject(ltName); } @Override public LinkObject[] readLinkObjectByFromBO(BusinessObject bo, String linkTypeName, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); LinkObject[] los = lofDelegate.getLinkObjectByBO(bo, linkTypeName, true); if (los == null) { return new LinkObject[0]; } int len = los.length; for (int i = 0; i < len; i++) { if (los[i].newAttrValList == null) { los[i].newAttrValList = new AttributeValue[0]; } if (los[i].hisAttrValList == null) { los[i].hisAttrValList = new AttributeValue[0]; } } return los; } @Override public LinkObject[] readLinkObjectByToBO(BusinessObject bo, String linkTypeName, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); LinkObject[] los = lofDelegate.getLinkObjectByBO(bo, linkTypeName, false); if (los == null) { return new LinkObject[0]; } int len = los.length; for (int i = 0; i < len; i++) { if (los[i].newAttrValList == null) { los[i].newAttrValList = new AttributeValue[0]; } if (los[i].hisAttrValList == null) { los[i].hisAttrValList = new AttributeValue[0]; } } return los; } @Override public LinkObject createLinkObject(LinkObject lo, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.createLinkObject(lo); } @Override public boolean updateLinkObject(LinkObject lo, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.updateBuinessObject(lo); } @Override public boolean deleteLinkObject(LinkObject lo, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.deleteLinkObject(lo); } @Override public RevisionDataInfo getNextRevisionValueObject(String btName, String nameOid, String revisionRule, boolean revInput, String revisionVal, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.getNextRevisionValueObject(btName, nameOid, revisionRule, revInput, revisionVal); } @Override public RevisionDataInfo getNextRevisionValue(String revisonValue, short revisionSeq, String revisionRule, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.getNextRevisionValueObject(revisonValue, revisionSeq, revisionRule); } @Override public VersionDataInfo getNextVersionValue(String btName, String revisionOid, String nameOid, long versionType, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.getNextVersionValue(btName, revisionOid, nameOid, (int) versionType); } @Override public BusinessObject[] batchCreateBusinessObject(BusinessObject[] bos, boolean isRevision, boolean isNewVersion, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); ServerWithLog4j.logger.debug("=== BOFactoryServiceImpl.batchCreateBusinessObject ==========="); return bofDelegate.batchCreateBusinessObject(bos, isRevision, isNewVersion); } @Override public boolean batchCreateBusinessObjectWithLink(BusinessObject[] bos, LinkObject[] los, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchCreateBusinessObjectWithLink(bos, los); } @Override public boolean batchUpdateBusinessObject(BusinessObject[] bos, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchUpdateBusinessObject(bos); } @Override public boolean batchDeleteBusinessObject(BusinessObject[] bos, long type, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchDeleteBusinessObject(bos, (int) type); } @Override public boolean batchCheckInBusinessObject(BusinessObject[] bos, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchCheckInBusinessObject(bos); } @Override public boolean batchCheckoutBusinessObject(BusinessObject[] bos, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchCheckoutBusinessObject(bos); } @Override public boolean batchUnCheckOutBusinessObject(BusinessObject[] bos, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchUnCheckOutBusinessObject(bos); } @Override public boolean batchChangeBusinessObjectOwner(BusinessObject[] bos, UserInfo[] userList, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchChangeBusinessObjectOwner(bos, userList); } @Override public LinkObject[] batchCreateLinkObject(LinkObject[] los, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.batchCreateLinkObject(los); } @Override public boolean batchUpdateLinkObject(LinkObject[] los, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.batchUpdateLinkObject(los); } @Override public boolean batchDeleteLinkObject(LinkObject[] los, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.batchDeleteLinkObject(los); } @Override public String[] getClssficationValue(String sql, AttributeValue[] attrVals, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.getClssficationValue(sql, attrVals); } @Override public String[][] getSqlQueryResult(String sql, AttributeValue[] attrVals, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.getSqlQueryResult(sql, attrVals); } @Override public String[][] getCustomSqlValue(String[] sqls, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.getCustomSqlValue(sqls); } /** * 创建带有链接的对象,并返回ts */ @Override public CreateBusinessObjectWithLinkTSResult createBusinessObjectWithLinkTS(BusinessObject[] bos, LinkObject lo, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); LongHolder ts = new LongHolder();//new StringBuilder(); boolean success = bofDelegate.CreateBusinessObjectWithLinkTS(bos, lo, ts); return new CreateBusinessObjectWithLinkTSResult(success, ts.value); } /** * 批量创建业务对象和链接对象,并返回业务对象的ts */ @Override public BatchCreateBusinessObjectWithLinkTSResult batchCreateBusinessObjectWithLinkTS(BusinessObject[] bos, LinkObject[] los, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); LongHolder ts = new LongHolder(); boolean success = bofDelegate.batchCreateBusinessObjectWithLinkTS(bos, los, ts); return new BatchCreateBusinessObjectWithLinkTSResult(success, ts.value); } /** * 批量升版本 */ @Override public boolean batchRevisonBusinessObject(String[] oids, String btmName, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchRevisonBusinessObject(oids, btmName); } @Override public LinkObject readLinkObjectById(String oid, String linkTypeName, Current current) throws VCIError { LOFactoryServerDelegate lofDelegate = LOFactoryServerDelegate.getInstance(); return lofDelegate.readLinkObjectById(oid, linkTypeName); } @Override public boolean batchCreateDeleteBOLO(BusinessObject[] createBOs, LinkObject[] createLOs, BusinessObject[] deleteBOs, LinkObject[] deleteLOs, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchCreateDeleteBOLO(createBOs, createLOs, deleteBOs, deleteLOs); } @Override public boolean batchCUDBOLO(BusinessObject[] createBOs, LinkObject[] createLOs, BusinessObject[] updateBOs, LinkObject[] updateLOs, BusinessObject[] deleteBOs, LinkObject[] deleteLOs, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchCUDBOLO(createBOs, createLOs, updateBOs, updateLOs, deleteBOs, deleteLOs); } @Override public boolean batchTransferBusinessObjectAndRelease(BusinessObject[] bos, TransitionVO[] vos, String[] releaseStatus, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchTransferBusinessObject(bos, vos, releaseStatus); } @Override public boolean executeUpdateSql(String sql, Current current) throws VCIError { return CustomSqlServerDelegate.getInstance().executeUpdateSql(sql); } @Override public boolean batchCreateBOWithLinkNoCheckNoLog(BusinessObject[] bos, LinkObject[] los, Current current) throws VCIError { BOFactoryServerDelegate bofDelegate = BOFactoryServerDelegate.getInstance(); return bofDelegate.batchCreateBOWithLinkNoCheckNoLog(bos, los); } @Override public boolean executeUpdateSqls(String[] sqls, Current current) throws VCIError { return BatchSqlServerDelegate.getInstance().executeUpdateSqls(sqls); } @Override public boolean executeUpdateSqlByParams(String sql, AttributeValue[] attrVals, Current current) throws VCIError { Map params = new HashMap(); if (attrVals != null && attrVals.length > 0) { for (int i = 0; i < attrVals.length; i++) { AttributeValue attr = attrVals[i]; params.put(attr.attrName, attr.attrVal); } } return CustomSqlServerDelegate.getInstance().executeUpdateSql(sql, params); } /** * 开始长事务 */ @Override public String beginTransaction(Current current) { return BatchTransferService.getInstance().beginTransaction(); } /** * 传递长事务数据 */ @Override public boolean batchCUDBOLOByTransaction(String sessionKey, BusinessObject[] createBOs, LinkObject[] createLOs, BusinessObject[] updateBOs, LinkObject[] updateLOs, BusinessObject[] deleteBOs, LinkObject[] deleteLOs, Current current) throws VCIError { return BatchTransferService.getInstance().batchCUDBOLO(sessionKey, createBOs, createLOs, updateBOs, updateLOs, deleteBOs, deleteLOs); } /** * 提交长事务 */ @Override public CommitTransactionResult commitTransaction(String sessionKey, Current current) throws VCIError { boolean success = BatchTransferService.getInstance().commitTransaction(sessionKey); return new CommitTransactionResult(success, 0); } }