package com.vci.server.portal.delegate; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; import org.omg.CORBA.IntHolder; import com.vci.common.utility.ObjectUtility; import com.vci.corba.common.VCIError; import com.vci.corba.portal.data.Constraint; import com.vci.corba.portal.data.PLAction; import com.vci.corba.portal.data.PLActionCls; import com.vci.corba.portal.data.PLActionParam; import com.vci.corba.portal.data.PLCommandParameter; import com.vci.corba.portal.data.PLPageDefination; import com.vci.corba.portal.data.PLUILayout; import com.vci.corba.portal.data.PLTabButton; import com.vci.corba.portal.data.PLTabPage; import com.vci.corba.portal.data.PLTypeAction; import com.vci.corba.portal.data.PortalVI; import com.vci.server.portal.cache.ActionCacheUtil; import com.vci.server.portal.cache.ActionClsCacheUtil; import com.vci.server.portal.cache.ActionParamCacheUtil; import com.vci.server.portal.cache.ButtonParamCacheUtil; import com.vci.server.portal.cache.ComponentBtnCacheUtil; import com.vci.server.portal.cache.ComponentCacheUtil; import com.vci.server.portal.cache.PortalVICacheUtil; import com.vci.server.portal.cache.TabPageCacheUtil; import com.vci.server.portal.cache.UIContextCacheUtil; import com.vci.server.portal.entity.PLActionClsEntity; import com.vci.server.portal.entity.PLActionEntity; import com.vci.server.portal.entity.PLActionParamEntity; import com.vci.server.portal.entity.PLCommandParameterEntity; import com.vci.server.portal.entity.PLPageDefinationEntity; import com.vci.server.portal.entity.PLUILayoutEntity; import com.vci.server.portal.entity.PLTabButtonEntity; import com.vci.server.portal.entity.PLTabPageEntity; import com.vci.server.portal.entity.PortalVIEntity; import com.vci.server.portal.service.PLActionEntityService; import com.vci.server.portal.service.PLCommandParameterEntityService; import com.vci.server.portal.service.PLPageDefinationEntityService; import com.vci.server.portal.service.PLUILayoutEntityService; import com.vci.server.portal.service.PLTabButtonEntityService; import com.vci.server.portal.service.PLTabPageEntityService; import com.vci.server.portal.service.PLTypeActionEntityService; import com.vci.server.portal.service.PortalVIEntityService; import com.vci.server.portal.service.UIDeleteService; import com.vci.server.portal.tools.ServerTool; public class PortalServiceDelegate {//implements IPortalServiceDelegate { private PortalVIEntityService portaVIService = null; private PLActionEntityService plActionEntityService = null; private PLCommandParameterEntityService plCommandParameterEntityService = null; private PLUILayoutEntityService plUILayoutEntityService = null; private PLTabButtonEntityService plTabButtonEntityService = null; private PLTabPageEntityService plTabPageEntityService = null; private PLPageDefinationEntityService plPageDefinationEntityService = null; private PLTypeActionEntityService plTypeActionEntityService = null; public static PortalServiceDelegate getInstance() { PortalServiceDelegate delegate = null; delegate = new PortalServiceDelegate(); return delegate; } private PortalServiceDelegate() { portaVIService = PortalVIEntityService.getInstance(); plActionEntityService = PLActionEntityService.getInstance(); plCommandParameterEntityService = PLCommandParameterEntityService.getInstance(); plUILayoutEntityService = PLUILayoutEntityService.getInstance(); plTabButtonEntityService = PLTabButtonEntityService.getInstance(); plTabPageEntityService = PLTabPageEntityService.getInstance(); plPageDefinationEntityService = PLPageDefinationEntityService.getInstance(); plTypeActionEntityService = PLTypeActionEntityService.getInstance(); } ////@Override public boolean savePortalVI(PortalVI portalVI) throws Throwable { PortalVIEntity obj = ServerTool.getPortalVIEntity(portalVI); boolean success = portaVIService.savePortalVIEntity(obj); if (success) { PortalVICacheUtil.getInstance().setObject(portalVI); } return success; } //@Override public boolean updatePortalVI(PortalVI portalVI) throws Throwable { PortalVIEntity obj = ServerTool.getPortalVIEntity(portalVI); boolean success = portaVIService.updatePortalVIEntity(obj); if (success) { PortalVICacheUtil.getInstance().setObject(portalVI); } return success; } //@Override public boolean deletePortalVI(PortalVI portalVI) throws Throwable { PortalVIEntity obj = ServerTool.getPortalVIEntity(portalVI); boolean success = portaVIService.deletePortalVIEntity(obj); if (success) { PortalVICacheUtil.getInstance().delObject(portalVI); } return success; } //@Override public boolean deletePortalVIByID(String id) throws Throwable { boolean success = portaVIService.deletePortalVIEntityById(id); if (success) { PortalVICacheUtil.getInstance().delItem(id); } return success; } //@Override public PortalVI[] getPortalVIArrayByTypeName(String typeName) throws Throwable { //PortalVI[] objs = portaVIService.getPortalVIArrayByTypeName(typeName); return PortalVICacheUtil.getInstance().getPortalVIArrayByTypeName(typeName); //return objs; } //@Override public int getPortalVICountByTypeName(String typeName) throws Throwable { //return portaVIService.getPortalVICountByTypeName(typeName); return PortalVICacheUtil.getInstance().getPortalVICountByTypeName(typeName); } //@Override public int getPortalVICountByCondition(String typeName, int sheetType, String sheetName) throws Throwable { //return portaVIService.getPortalVICountByCondition(typeName, sheetType, sheetName); return PortalVICacheUtil.getInstance().getPortalVICountByCondition(typeName, sheetType, sheetName); } //@Override // public PortalVI[] getPagePortalVIArrayByTypeName(String typeName, long startPage, long endPage) throws Throwable { // PortalVI[] objs = portaVIService.getPagePortalVIArrayByTypeName(typeName, (int) startPage, (int) endPage); // return objs; // } // //@Override // public PortalVI[] getPagePortalVIArrayByCondition(String typeName, short sheetType, String sheetName, // long startPage, long endPage) throws Throwable { // PortalVI[] objs = portaVIService.getPagePortalVIArrayByCondition(typeName, sheetType, sheetName, // (int) startPage, (int) endPage); // return objs; // } /** * 根据翻页参数返回表单 * * @param typeName 表单所在类型名称 * @param viName 表单名称 模糊查询 * @param viType 表单类型 PortalVIType.Table|Form * @param viTypeFlag 表单类型标识 PortalVITypeFlag.BtmType|LinkType * @param pageIndex 页号 * @param pageSize 页大小 * @param total 输出参数总数 * @return * @throws Throwable */ //@Override public PortalVI[] getPagePortalVIArrayByPageInfo(String typeName, String viName, short viType, short viTypeFlag, long pageIndex, long pageSize, IntHolder total) throws Throwable { return portaVIService.getPagePortalVIArrayByPageInfo(typeName, viName, viType, viTypeFlag, pageIndex, pageSize, total); } /** * 根据OID级联删除表单 * * @param oids 表单 oids * @return * @throws Throwable */ //@Override public boolean deletePagePortalVIForCascade(String[] oids) throws Throwable { boolean success = portaVIService.deletePagePortalVIForCascade(oids); return success; } //@Override public PortalVI getPortalVIById(String id) throws Throwable { return PortalVICacheUtil.getInstance().getObject(id); // PortalVIEntity obj = portaVIService.getPortalVIEntityById(id); // PortalVI obj_ = ServerTool.getPortalVI(obj); // if (obj == null) { // return ServerTool.getDefaultPortalVI(); // } // return obj_; } //@Override public PortalVI getPortalVIBySymbol(String name) throws Throwable { return PortalVICacheUtil.getInstance().getObjectByName(name); // PortalVIEntity obj = portaVIService.getPortalVIBySymbol(symbol); // PortalVI obj_ = ServerTool.getPortalVI(obj); // if (obj == null) { // return ServerTool.getDefaultPortalVI(); // } // return obj_; } //@Override public boolean savePLAction(PLAction plAction) throws Throwable { PLActionEntity obj = ServerTool.getPLActionEntity(plAction); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); boolean success = plActionEntityService.savePLActionEntity(obj); if (success) { ActionCacheUtil.getInstance().setObject(plAction); } return success; } //@Override public boolean updatePLAction(PLAction plAction) throws Throwable { PLActionEntity obj = ServerTool.getPLActionEntity(plAction); Date today = Calendar.getInstance().getTime(); obj.setPlModifyTime(today); boolean success = plActionEntityService.updatePLActionEntity(obj); if (success) { ActionCacheUtil.getInstance().setObject(plAction); } return success; } //@Override public boolean deletePLAction(PLAction plAction) throws Throwable { PLActionEntity obj = ServerTool.getPLActionEntity(plAction); boolean success = plActionEntityService.deletePLActionEntity(obj); if (success) { ActionCacheUtil.getInstance().delObject(plAction); } return success; } //@Override public boolean deletePLActionByID(String id) throws Throwable { boolean success = plActionEntityService.deletePLActionEntityById(id); if (success) { ActionCacheUtil.getInstance().delItem(id); } return success; } /** * 保存command参数 */ //@Override public boolean savePLCommandParameter(PLCommandParameter plCommandParameter) throws Throwable { PLCommandParameterEntity obj = ServerTool.getPLCommandParameterEntity(plCommandParameter); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); boolean success = plCommandParameterEntityService.savePLCommandParameterEntity(obj); if (success) { ButtonParamCacheUtil.getInstance().setObject(plCommandParameter); } return success; } /** * 更新command参数 */ //@Override public boolean updatePLCommandParameter(PLCommandParameter plCommandParameter) throws Throwable { PLCommandParameterEntity obj = ServerTool.getPLCommandParameterEntity(plCommandParameter); Date today = Calendar.getInstance().getTime(); obj.setPlModifyTime(today); boolean success = plCommandParameterEntityService.updatePLCommandParameterEntity(obj); if (success) { ButtonParamCacheUtil.getInstance().setObject(plCommandParameter); } return success; } /** * 删除command参数 */ //@Override public boolean deletePLCommandParameter(PLCommandParameter plCommandParameter) throws Throwable { PLCommandParameterEntity obj = ServerTool.getPLCommandParameterEntity(plCommandParameter); boolean success = plCommandParameterEntityService.deletePLCommandParameterEntity(obj); if (success) { ButtonParamCacheUtil.getInstance().delObject(plCommandParameter); } return success; } /** * 删除command参数 */ //@Override public boolean deletePLCommandParameterByID(String id) throws Throwable { boolean success = plCommandParameterEntityService.deletePLCommandParameterEntityById(id); if (success) { ButtonParamCacheUtil.getInstance().delItem(id); } return success; } /** * 根据TabButtonID删除参数信息 */ //@Override public boolean deletePLCommandParameterByTabButtonId(String id) throws Throwable { boolean success = plCommandParameterEntityService.deletePLCommandParameterByTabButtonId(id); if (success) { ButtonParamCacheUtil.getInstance().delItem(id); } return success; } /** * 保存页面布局 */ //@Override public boolean savePLUILayout(PLUILayout plUILayout) throws Throwable { PLUILayoutEntity obj = ServerTool.getPLUILayoutEntity(plUILayout); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); boolean success = plUILayoutEntityService.savePLUILayoutEntity(obj); if (success) { UIContextCacheUtil.getInstance().setObject(plUILayout); } return success; } //@Override public boolean batchSavePLUILayout(PLUILayout[] plPageLayoutDefinations) throws Throwable { PLUILayoutEntity[] newObjs = new PLUILayoutEntity[plPageLayoutDefinations.length]; for (int i = 0; i < plPageLayoutDefinations.length; i++) { PLUILayoutEntity obj = ServerTool.getPLUILayoutEntity(plPageLayoutDefinations[i]); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); newObjs[i] = obj; } boolean success = plUILayoutEntityService.batchsavePLUILayoutEntity(newObjs); if (success) { for (PLUILayout ui : plPageLayoutDefinations) UIContextCacheUtil.getInstance().setObject(ui); } return success; } /** * 更新页面布局 */ //@Override public boolean updatePLUILayout(PLUILayout plUILayout) throws Throwable { PLUILayoutEntity obj = ServerTool.getPLUILayoutEntity(plUILayout); Date today = Calendar.getInstance().getTime(); obj.setPlModifyTime(today); boolean success = plUILayoutEntityService.updatePLUILayoutEntity(obj); if (success) { UIContextCacheUtil.getInstance().setObject(plUILayout); } return success; } /** * 删除页面布局 */ //@Override public boolean deletePLUILayout(PLUILayout plUILayout) throws Throwable { PLUILayoutEntity obj = ServerTool.getPLUILayoutEntity(plUILayout); boolean success = plUILayoutEntityService.deletePLUILayoutEntity(obj); if (success) { UIContextCacheUtil.getInstance().delObject(plUILayout); } return success; } /** * 删除页面布局 */ //@Override public boolean deletePLUILayoutByID(String id) throws Throwable { boolean success = plUILayoutEntityService.deletePLUILayoutEntityById(id); if (success) { UIContextCacheUtil.getInstance().delItem(id); } return success; } /** * 根据OID删除上下文(级联) */ //@Override public boolean deletePLUILayoutByOidsForCascade(String[] oids) throws Throwable { boolean success = new UIDeleteService().deleteUIByOidsForCascade(oids, UIDeleteService.DELETE_CONTEXT); if (success) { for (String id : oids) UIContextCacheUtil.getInstance().delItem(id); } return success; } /** * 保存页签按钮 */ //@Override public boolean savePLTabButton(PLTabButton plTabButton) throws Throwable { if (plTabButton.displayMode.equals("")) { plTabButton.displayMode = "textandimage"; } if (plTabButton.authorization.equals("")) { plTabButton.authorization = "0"; } PLTabButtonEntity obj = ServerTool.getPLTabButtonEntity(plTabButton); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); boolean success = plTabButtonEntityService.savePLTabButtonEntity(obj); if (success) { ComponentBtnCacheUtil.getInstance().setObject(plTabButton); } return success; } /** * 保存按钮及参数 */ //@Override public boolean savePLTabButtonAndParams(PLTabButton[] plTabButton, PLCommandParameter[] btnParams) throws Throwable { boolean res = batchSavePLTabButton(plTabButton); res = res && batchSavePLCommandParameter(btnParams); return res; } /** * 更新页签按钮 */ //@Override public boolean updatePLTabButton(PLTabButton plTabButton) throws Throwable { PLTabButtonEntity obj = ServerTool.getPLTabButtonEntity(plTabButton); Date today = Calendar.getInstance().getTime(); obj.setPlModifyTime(today); boolean success = plTabButtonEntityService.updatePLTabButtonEntity(obj); if (success) { ComponentBtnCacheUtil.getInstance().setObject(plTabButton); } return success; } /** * 删除页签按钮 */ //@Override public boolean deletePLTabButton(PLTabButton plTabButton) throws Throwable { PLTabButtonEntity obj = ServerTool.getPLTabButtonEntity(plTabButton); boolean success = plTabButtonEntityService.deletePLTabButtonEntity(obj); if (success) { ComponentBtnCacheUtil.getInstance().delObject(plTabButton); } return success; } /** * 删除页签按钮 */ //@Override public boolean deletePLTabButtonByID(String id) throws Throwable { boolean success = plTabButtonEntityService.deletePLTabButtonEntityById(id); if (success) { ComponentBtnCacheUtil.getInstance().delItem(id); } return success; } /** * 根据OID删除按钮(级联) */ //@Override public boolean deletePLTabButtonByOidsForCascade(String[] oids) throws Throwable { boolean success = new UIDeleteService().deleteUIByOidsForCascade(oids, UIDeleteService.DELETE_BUTTON); if (success) { for (String oid : oids) ComponentBtnCacheUtil.getInstance().delItem(oid); } return success; } /** * 保存页签 */ //@Override public boolean savePLTabPage(PLTabPage plTabPage) throws Throwable { PLTabPageEntity obj = ServerTool.getPLTabPageEntity(plTabPage); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); boolean success = plTabPageEntityService.savePLTabPageEntity(obj); if (success) { TabPageCacheUtil.getInstance().setObject(plTabPage); } return success; } /** * 更新页签 */ //@Override public boolean updatePLTabPage(PLTabPage plTabPage) throws Throwable { PLTabPageEntity obj = ServerTool.getPLTabPageEntity(plTabPage); Date today = Calendar.getInstance().getTime(); obj.setPlModifyTime(today); boolean success = plTabPageEntityService.updatePLTabPageEntity(obj); if (success) { TabPageCacheUtil.getInstance().setObject(plTabPage); } return success; } /** * 删除页签 */ //@Override public boolean deletePLTabPage(PLTabPage plTabPage) throws Throwable { PLTabPageEntity obj = ServerTool.getPLTabPageEntity(plTabPage); boolean success = plTabPageEntityService.deletePLTabPageEntity(obj); if (success) { TabPageCacheUtil.getInstance().delObject(plTabPage); } return success; } /** * 删除页签 */ //@Override public boolean deletePLTabPageByID(String id) throws Throwable { boolean success = plTabPageEntityService.deletePLTabPageEntityById(id); if (success) { TabPageCacheUtil.getInstance().delItem(id); } return success; } /** * 根据OID删除页签(级联) */ //@Override public boolean deletePLTabPageByOidsForCascade(String[] oids) throws Throwable { boolean success = new UIDeleteService().deleteUIByOidsForCascade(oids, UIDeleteService.DELETE_TAB); if (success) { for (String oid : oids) TabPageCacheUtil.getInstance().delItem(oid); } return success; } /** * 根据ID获取指定的PLAction */ //@Override public PLAction getPLActionById(String plOId) throws Throwable { return ActionCacheUtil.getInstance().getObject(plOId); // PLActionEntity obj = plActionEntityService.getPLActionEntityById(plOId); // PLAction obj_ = ServerTool.getPLAction(obj); // if (obj_ == null) { // return ServerTool.getDefaultPLAction(); // } // return obj_; } /** * 获取所有PLAction */ //@Override public PLAction[] getAllPLAction() throws Throwable { return ActionCacheUtil.getInstance().getObjects(); // List list = plActionEntityService.getAllPLActionEntity(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLActionEntity obj = list.get(i); // PLAction obj_ = ServerTool.getPLAction(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLAction[0]); } /** * 根据ID获取指定的PLCommandParameter */ //@Override public PLCommandParameter getPLCommandParameterById(String plOId) throws Throwable { return ButtonParamCacheUtil.getInstance().getObject(plOId); // PLCommandParameterEntity obj = plCommandParameterEntityService.getPLCommandParameterEntityById(plOId); // PLCommandParameter obj_ = ServerTool.getPLCommandParameter(obj); // if (obj_ == null) { // return ServerTool.getDefaultPLCommandParameter(); // } // return obj_; } /** * 根据plCommandOId获取PLCommandParameterArray */ //@Override public PLCommandParameter[] getPLCommandParametersByCommandOId(String plCommandOId) throws Throwable { return ButtonParamCacheUtil.getInstance().getCommandParameters(plCommandOId); // List list = plCommandParameterEntityService // .getPLCommandParameterEntitysByCommandOId(plCommandOId); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLCommandParameterEntity obj = list.get(i); // PLCommandParameter obj_ = ServerTool.getPLCommandParameter(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLCommandParameter[0]); } /** * 根据ID获取指定的PLUILayout */ //@Override public PLUILayout getPLUILayoutById(String plOId) throws Throwable { return UIContextCacheUtil.getInstance().getObject(plOId); // PLUILayoutEntity obj = plUILayoutEntityService.getPLUILayoutEntityById(plOId); // PLUILayout obj_ = ServerTool.getPLUILayout(obj); // if (obj_ == null) { // return ServerTool.getDefaultPLUILayout(); // } // return obj_; } //@Override public PLUILayout[] getPLUILayoutEntity(String contentStr) throws Throwable { List list = plUILayoutEntityService.getPLUILayoutEntity(contentStr); return pageLayoutDefinationListToArrayListToArray(list); } /** * 根据关联类型获取PLUILayoutArray */ //@Override public PLUILayout[] getPLUILayoutsByRelatedType(String plRelatedType) throws Throwable { return UIContextCacheUtil.getInstance().getContext(plRelatedType, null); // List list = plUILayoutEntityService.getPLUILayoutsByRelatedType(plRelatedType); // return pageLayoutDefinationListToArrayListToArray(list); } public PLUILayout[] getPLUILayoutsByRelatedTypeAndQueryInfo(String plRelatedType, String name, String code, int pageIndex, int pageSize, IntHolder total) throws Throwable { List list = plUILayoutEntityService.getPLUILayoutsByRelatedTypeAndQueryInfo(plRelatedType, name, code, pageIndex, pageSize, total); return pageLayoutDefinationListToArrayListToArray(list); } private PLUILayout[] pageLayoutDefinationListToArrayListToArray(List list) { List list_ = new ArrayList(); for (int i = 0; i < list.size(); i++) { PLUILayoutEntity obj = list.get(i); PLUILayout obj_ = ServerTool.getPLUILayout(obj); if (obj_ != null) { list_.add(obj_); } } return list_.toArray(new PLUILayout[0]); } /** * 根据关联类型获取PLUILayoutArray */ //@Override public PLUILayout[] getPLUILayoutEntity(String plRelatedType, String code) throws Throwable { return UIContextCacheUtil.getInstance().getContext(plRelatedType, code); // List list = plUILayoutEntityService.getPLUILayoutEntity(plRelatedType, code); // return pageLayoutDefinationListToArrayListToArray(list); } /** * 根据ID获取指定的PLTabPage */ //@Override public PLTabPage getPLTabPageById(String plOId) throws Throwable { return TabPageCacheUtil.getInstance().getObject(plOId); // PLTabPageEntity obj = plTabPageEntityService.getPLTabPageEntityById(plOId); // PLTabPage obj_ = ServerTool.getPLTabPage(obj); // if (obj_ == null) { // return ServerTool.getDefaultPLTabPage(); // } // return obj_; } /** * 根据plPageDefinationOId获取PLUILayoutArray */ //@Override public PLTabPage[] getPLTabPagesByPageDefinationOId(String plContextOId) throws Throwable { return TabPageCacheUtil.getInstance().getTabPages(plContextOId, -1); // List list = plTabPageEntityService.getPLTabPageEntitysByPageDefinationOId(plPageDefinationOId); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLTabPageEntity obj = list.get(i); // PLTabPage obj_ = ServerTool.getPLTabPage(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLTabPage[0]); } /** * 根据上下文ID和区域类型,按顺序获取当前区域的tab页 */ public PLTabPage[] getTabPagesByContextIdAndType(String contextId, int areaType) throws Throwable { return TabPageCacheUtil.getInstance().getTabPages(contextId, areaType); // List list = plTabPageEntityService.getTabPageByContextIdAndType(contextId, areaType); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLTabPageEntity obj = list.get(i); // PLTabPage obj_ = ServerTool.getPLTabPage(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLTabPage[0]); } /** * 根据ID获取指定的PLTabButton */ //@Override public PLTabButton getPLTabButtonById(String plOId) throws Throwable { return ComponentBtnCacheUtil.getInstance().getObject(plOId); // PLTabButtonEntity obj = plTabButtonEntityService.getPLTabButtonEntityById(plOId); // PLTabButton obj_ = ServerTool.getPLTabButton(obj); // if (obj_ == null) { // return ServerTool.getDefaultPLTabButton(); // } // return obj_; } /** * 根据plTableOId获取PLTabButtonArray */ //@Override public PLTabButton[] getPLTabButtonsByTableOId(String plTableOId) throws Throwable { return ComponentBtnCacheUtil.getInstance().getButtons(plTableOId); // List list = plTabButtonEntityService.getPLTabButtonEntitysByTableOId(plTableOId); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLTabButtonEntity obj = list.get(i); // PLTabButton obj_ = ServerTool.getPLTabButton(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLTabButton[0]); } /** * 保存界面 */ //@Override public boolean savePLPageDefination(PLPageDefination plPageDefination) throws Throwable { PLPageDefinationEntity obj = ServerTool.getPLPageDefinationEntity(plPageDefination); boolean success = plPageDefinationEntityService.savePLPageDefinationEntity(obj); if (success) { ComponentCacheUtil.getInstance().setObject(plPageDefination); } return success; } /** * 更新界面 */ //@Override public boolean updatePLPageDefination(PLPageDefination plPageDefination) throws Throwable { PLPageDefinationEntity obj = ServerTool.getPLPageDefinationEntity(plPageDefination); boolean success = plPageDefinationEntityService.updatePLPageDefinationEntity(obj); if (success) { ComponentCacheUtil.getInstance().setObject(plPageDefination); } return success; } /** * 删除界面 */ //@Override public boolean deletePLPageDefination(PLPageDefination plPageDefination) throws Throwable { PLPageDefinationEntity obj = ServerTool.getPLPageDefinationEntity(plPageDefination); boolean success = plPageDefinationEntityService.deletePLPageDefinationEntity(obj); if (success) { ComponentCacheUtil.getInstance().delObject(plPageDefination);; } return success; } /** * 删除界面 */ //@Override public boolean deletePLPageDefinationByID(String id) throws Throwable { boolean success = plPageDefinationEntityService.deletePLPageDefinationEntityById(id); if (success) { ComponentCacheUtil.getInstance().delItem(id); } return success; } /** * 根据OID删除组件(级联) */ //@Override public boolean deletePLPageDefinationByOidsForCascade(String[] oids) throws Throwable { boolean success = new UIDeleteService().deleteUIByOidsForCascade(oids, UIDeleteService.DELETE_COMPONENT); if (success) { for (String oid : oids) ComponentCacheUtil.getInstance().delItem(oid);; } return success; } /** * 根据ID获取指定的PLPageDefination */ //@Override public PLPageDefination getPLPageDefinationById(String plOId) throws Throwable { return ComponentCacheUtil.getInstance().getObject(plOId); // PLPageDefinationEntity obj = plPageDefinationEntityService.getPLPageDefinationEntityById(plOId); // PLPageDefination obj_ = ServerTool.getPLPageDefination(obj); // if (obj_ == null) { // return ServerTool.getDefaultPLPageDefination(); // } // return obj_; } /** * 根据plPageContextOId获取指定的PLPageDefinationArray */ //@Override public PLPageDefination[] getPLPageDefinationsByPageContextOId(String plPageContextOId) throws Throwable { return ComponentCacheUtil.getInstance().getComopnent(plPageContextOId); // List list = plPageDefinationEntityService // .getPLPageDefinationEntitysByPageContextOId(plPageContextOId); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLPageDefinationEntity obj = list.get(i); // PLPageDefination obj_ = ServerTool.getPLPageDefination(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLPageDefination[0]); } /** * 根据type,code获取指定的PLTabPage */ //@Override public PLTabPage[] getPLTabPagesByTypeANDCode(String type, String code) throws Throwable { List list = plTabPageEntityService.getPLTabPageEntitysByTypeANDCode(type, code); List list_ = new ArrayList(); for (int i = 0; i < list.size(); i++) { PLTabPageEntity obj = list.get(i); PLTabPage obj_ = ServerTool.getPLTabPage(obj); if (obj_ != null) { list_.add(obj_); } } return list_.toArray(new PLTabPage[0]); } /** * 根据类型名和视图名获取视图 */ //@Override public PortalVI getPortalVIByTypeNameAndVIName(String typeName, String viName) throws Throwable { return PortalVICacheUtil.getInstance().getPortalVIByCondition(typeName, -1, viName); // PortalVIEntity obj = portaVIService.getPortalVIEntityByTypeNameAndVIName(typeName, viName); // PortalVI obj_ = ServerTool.getPortalVI(obj); // if (obj_ == null) { // return ServerTool.getDefaultPortalVI(); // } // return obj_; } /** * 根据约束条件组查询数组, 查询PLActions */ //@Override public PLAction[] getPLActionsByConsArray(Constraint[] consArray) throws Throwable { List list = plActionEntityService.getPLActionEntitysByConsMap(consArray); List list_ = new ArrayList(); for (int i = 0; i < list.size(); i++) { PLActionEntity obj = list.get(i); PLAction obj_ = ServerTool.getPLAction(obj); if (obj_ != null) { list_.add(obj_); } } return list_.toArray(new PLAction[0]); } /** * 查询所有Action分类 */ //@Override public PLActionCls[] getPLActionClsArray() throws VCIError { return ActionClsCacheUtil.getInstance().getObjects(); // List clsList = plActionEntityService.getAllActionCls(); // if (clsList == null || clsList.isEmpty()) { // return new PLActionCls[0]; // } // PLActionCls[] clses = new PLActionCls[clsList.size()]; // for (int i = 0; i < clsList.size(); i++) { // PLActionClsEntity entity = clsList.get(i); // clses[i] = ServerTool.getPLActionCls(entity); // } // return clses; } /** * 创建Action分类 */ //@Override public String creaetePLActionCls(PLActionCls cls) { String res = plActionEntityService.createPLActionCls(ServerTool.getPLActionClsEntity(cls)); if (res.equals("1")) { ActionClsCacheUtil.getInstance().setObject(cls); } return res; } /** * 修改Action分类信息 */ //@Override public String editPLActionCls(PLActionCls cls) { String res = plActionEntityService.editPLActionCls(ServerTool.getPLActionClsEntity(cls)); if (res.equals("1")) { ActionClsCacheUtil.getInstance().setObject(cls); } return res; } /** * 删除分类 */ //@Override public String deletePLActionClsById(String id) { String res = plActionEntityService.deletePLActionCls(id); if (res.equals("1")) { ActionClsCacheUtil.getInstance().delItem(id); } return res; } /** * 根据ActionID查询按钮参数列表 */ //@Override public PLActionParam[] getPLActionParamArrayByActionId(String actionId) throws VCIError { return ActionParamCacheUtil.getInstance().getAParamByAction(actionId); // List paramList = plActionEntityService.getActionParamsById(actionId); // if (paramList == null || paramList.isEmpty()) { // return new PLActionParam[0]; // } // PLActionParam[] params = new PLActionParam[paramList.size()]; // for (int i = 0; i < paramList.size(); i++) { // PLActionParamEntity entity = paramList.get(i); // params[i] = ServerTool.getPLActionParam(entity); // } // return params; } /** * 创建参数分类 */ //@Override public String createPLActionParam(PLActionParam param) { String res = plActionEntityService.createPLActionParam(ServerTool.getPLActionParmaEntity(param)); if (res.equals("1")) { ActionParamCacheUtil.getInstance().setObject(param); } return res; } /** * 批量创建分类 */ //@Override public String createPLActionParamBatch(PLActionParam[] params) { return null; } /** * 修改参数 */ //@Override public String editPLActionParam(PLActionParam param) { String res = plActionEntityService.editPLActionParam(ServerTool.getPLActionParmaEntity(param)); if (res.equals("1")) { ActionParamCacheUtil.getInstance().setObject(param); } return res; } /** * 删除参数 */ //@Override public String deletePLActionParam(String id) { String res = plActionEntityService.deletePLActionParam(id); if (res.equals("1")) { ActionParamCacheUtil.getInstance().delItem(id); } return res; } //@Override public boolean savePLTypeActionEntity(PLTypeAction plTypeAction) throws Throwable { boolean success = plTypeActionEntityService.savePLTypeActionEntity(ServerTool.getPLTypeActionEntity(plTypeAction)); if (success) { ActionCacheUtil.getInstance().setTypeAction(plTypeAction); } return success; } //@Override public boolean deletePLTypeActionEntityByTypeAndAction(String type, String actionoId) throws Throwable { boolean success = plTypeActionEntityService.deletePLTypeActionEntityByTypeAndAction(type, actionoId); if (success) { ActionCacheUtil.getInstance().delTypeAction(type, actionoId); } return success; } //@Override public PLAction[] getAllPLActionEntityByType(String type) throws Throwable { return ActionCacheUtil.getInstance().getActionsByType(type); // List list = plTypeActionEntityService.getAllPLActionEntityByType(type); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLActionEntity obj = list.get(i); // PLAction obj_ = ServerTool.getPLAction(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLAction[0]); } /** * 根据type和formName判断表单是否能被修改 * * @param type * @param name * @return */ //@Override public boolean judgeUpdateButton(int type, String viName, String typeName) throws Throwable { boolean flag = false; PLTabButtonEntityService service = PLTabButtonEntityService.getInstance(); flag = service.judgeUpdateButton(type, viName, typeName); return flag; } /** * 根据id判断表单是否能被删除 * * @param type * @param name * @return */ //@Override public boolean judgeDeleteButton(String id, String typeName) throws Throwable { boolean flag = false; PLTabButtonEntityService service = PLTabButtonEntityService.getInstance(); flag = service.judgeDeleteButton(id, typeName); return flag; } //@Override public PLUILayout[] getAllPLUILayouts() throws Throwable { return UIContextCacheUtil.getInstance().getObjects(); // List list = plUILayoutEntityService.getAllPLUILayoutEntitys(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLUILayoutEntity obj = list.get(i); // PLUILayout obj_ = ServerTool.getPLUILayout(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLUILayout[0]); } //@Override public PLTabPage[] getAllPLTabPages() throws Throwable { return TabPageCacheUtil.getInstance().getObjects(); // List list = plTabPageEntityService.getAllTabPages(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLTabPageEntity obj = list.get(i); // PLTabPage obj_ = ServerTool.getPLTabPage(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLTabPage[0]); } //@Override public PLPageDefination[] getAllPLPageDefinations() throws Throwable { return ComponentCacheUtil.getInstance().getObjects(); // List list = plPageDefinationEntityService.getAllPLPageDefinations(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLPageDefinationEntity obj = list.get(i); // PLPageDefination obj_ = ServerTool.getPLPageDefination(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLPageDefination[0]); } //@Override public PLPageDefination[] getAllPLPageDefinationsWithNoConf() throws Throwable { return ComponentCacheUtil.getInstance().getObjects(); // List list = plPageDefinationEntityService.getAllPLPageDefinationsWithNoConf(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLPageDefinationEntity obj = list.get(i); // PLPageDefination obj_ = ServerTool.getPLPageDefination(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLPageDefination[0]); } //@Override public PLTabButton[] getAllPLTabButtons() throws Throwable { return ComponentBtnCacheUtil.getInstance().getObjects(); // List list = plTabButtonEntityService.getAllPLTabButtonEntitys(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLTabButtonEntity obj = list.get(i); // PLTabButton obj_ = ServerTool.getPLTabButton(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLTabButton[0]); } //@Override public PLCommandParameter[] getAllPLCommandParameters() throws Throwable { return ButtonParamCacheUtil.getInstance().getObjects(); // List list = plCommandParameterEntityService.getAllPLCommandParameterEntitys(); // List list_ = new ArrayList(); // for (int i = 0; i < list.size(); i++) { // PLCommandParameterEntity obj = list.get(i); // PLCommandParameter obj_ = ServerTool.getPLCommandParameter(obj); // if (obj_ != null) { // list_.add(obj_); // } // } // return list_.toArray(new PLCommandParameter[0]); } //@Override public PortalVI[] getAllPortalVI() throws Throwable { return PortalVICacheUtil.getInstance().getObjects(); // PortalVI[] objs = portaVIService.getAllPortalVI(); // return objs; } //@Override public boolean batchSavePLCommandParameter(PLCommandParameter[] plCommandParameters) throws Throwable { PLCommandParameterEntity[] objs = new PLCommandParameterEntity[plCommandParameters.length]; for (int i = 0; i < plCommandParameters.length; i++) { PLCommandParameterEntity obj = ServerTool.getPLCommandParameterEntity(plCommandParameters[i]); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); objs[i] = obj; } boolean success = plCommandParameterEntityService.batchSavePLCommandParameterEntity(objs); if (success) { for (PLCommandParameter plCmdParam : plCommandParameters) ButtonParamCacheUtil.getInstance().setObject(plCmdParam); } return success; } //@Override public boolean batchSavePLTabButton(PLTabButton[] plTabButtons) throws Throwable { PLTabButtonEntity[] objs = new PLTabButtonEntity[plTabButtons.length]; for (int i = 0; i < plTabButtons.length; i++) { if (plTabButtons[i].displayMode.equals("")) { plTabButtons[i].displayMode = "textandimage"; } if (plTabButtons[i].authorization.equals("")) { plTabButtons[i].authorization = "0"; } PLTabButtonEntity obj = ServerTool.getPLTabButtonEntity(plTabButtons[i]); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); objs[i] = obj; } boolean success = plTabButtonEntityService.bacthSavePLTabButtonEntity(objs); if (success) { for (PLTabButton plTabButton : plTabButtons) ComponentBtnCacheUtil.getInstance().setObject(plTabButton); } return success; } //@Override public boolean batchSavePLTabPage(PLTabPage[] plTabPages) throws Throwable { PLTabPageEntity[] objs = new PLTabPageEntity[plTabPages.length]; for (int i = 0; i < plTabPages.length; i++) { PLTabPageEntity obj = ServerTool.getPLTabPageEntity(plTabPages[i]); Date today = Calendar.getInstance().getTime(); obj.setPlCreateTime(today); obj.setPlModifyTime(today); objs[i] = obj; } boolean success = plTabPageEntityService.batchSavePLTabPageEntity(objs); if (success) { for (PLTabPage plTabPage : plTabPages) TabPageCacheUtil.getInstance().setObject(plTabPage); } return success; } //@Override public boolean batchSavePLPageDefination(PLPageDefination[] plPageDefinations) throws Throwable { PLPageDefinationEntity[] objs = new PLPageDefinationEntity[plPageDefinations.length]; for (int i = 0; i < plPageDefinations.length; i++) { PLPageDefinationEntity obj = ServerTool.getPLPageDefinationEntity(plPageDefinations[i]); objs[i] = obj; } boolean success = plPageDefinationEntityService.batchSavePLPageDefinationEntity(objs); if (success) { for (PLPageDefination plPageDef : plPageDefinations) ComponentCacheUtil.getInstance().setObject(plPageDef); } return success; } //@Override public boolean batchSavePortalVI(PortalVI[] portalVIs) throws Throwable { PortalVIEntity[] objs = new PortalVIEntity[portalVIs.length]; for (int i = 0; i < portalVIs.length; i++) { PortalVIEntity obj = ServerTool.getPortalVIEntity(portalVIs[i]); objs[i] = obj; } boolean success = portaVIService.batchSavePortalVIEntity(objs); if (success) { for (PortalVI portalVI : portalVIs) PortalVICacheUtil.getInstance().setObject(portalVI); } return success; } //@Override public PortalVI[] getPortalVIBySymbolAndTypeName(String viName, String type) throws Throwable { return PortalVICacheUtil.getInstance().getPortalVIByObjTypeAndLikeName(type, viName); // PortalVI[] objs = portaVIService.getPortalVIBySymbolAndTypeName(viName, type); // return objs; } //@Override public PortalVI[] getPortalVIByQueryInfo(String typeName, int typeFlag, String viName, int viType, IntHolder total) throws Throwable { return portaVIService.getPortalVIByQueryInfo(typeName, typeFlag, viName, viType, total); } //@Override public boolean copyTabPageToPageLayout(String[] tabPageOids, PLUILayout plUILayout, short areaType) throws Throwable { PLTabPage[] tps = getTabPagesByContextIdAndType(plUILayout.plOId, areaType); if (tps != null && tps.length > 0) { Arrays.sort(tps, new Comparator() { //@Override public int compare(PLTabPage o1, PLTabPage o2) { return new Integer(o1.plSeq).compareTo(new Integer(o2.plSeq)); } }); } copyExistTabPageToExistPageLayoutDefination(plUILayout, tps, tabPageOids, areaType); return true; } /** * 将已存在的页签得到到已经存在的上下文中 * * @param pld 目标上下文 * @param tps 目标上下文中已经存在着的页签 * @param tabPageOids 待复制的已经存在着的页签 * @param seq * @param areaType * @throws Throwable */ private void copyExistTabPageToExistPageLayoutDefination(PLUILayout pld, PLTabPage[] tps, String[] tabPageOids, short areaType) throws Throwable { short seq = 1; // 计算出合适的页签序号 if (tps != null && tps.length > 0) { seq = (short) (tps[tps.length - 1].plSeq + 1); } // 循环 准备复制 for (int i = 0; i < tabPageOids.length; i++) { // 查出页签 PLTabPageEntity tpe = plTabPageEntityService.getPLTabPageEntityById(tabPageOids[i]); // 克隆页签 PLTabPage tpNew = ServerTool.getPLTabPage(tpe); // 设置新OID tpNew.plOId = ObjectUtility.getNewObjectID36(); // 与目标上下文关联 tpNew.plContextOId = pld.plOId; // 设置页签编码 // 如果页签编码已存在,则添加后缀 boolean codeIsExist = codeIsExistInTabPage(tpe.getPlCode(), tps); if (codeIsExist) { tpNew.plCode = tpe.getPlCode() + "_copy"; while ((codeIsExist) = codeIsExistInTabPage(tpNew.plCode, tps)) { tpNew.plCode = tpNew.plCode + "_copy"; } } // 序号 tpNew.plSeq = seq; // 区域类型 tpNew.plAreaType = areaType; // 保存新创建的页签 plTabPageEntityService.savePLTabPageEntity(ServerTool.getPLTabPageEntity(tpNew)); TabPageCacheUtil.getInstance().setObject(tpNew); // 原页签下的组件 List pdes = plPageDefinationEntityService .getPLPageDefinationEntitysByPageContextOId(tpe.getPlOId()); // 将原页签下的组件复制到新克隆出的页签 copyPageDefinationToNewTabPage(tpNew, pdes); // 序号递增 seq += 1; } } /** * 将组件复制到页签 * * @param tpNew 页签 * @param pdes 组件列表 * @throws Throwable */ private void copyPageDefinationToNewTabPage(PLTabPage tpNew, List pdes) throws Throwable { for (PLPageDefinationEntity pde : pdes) { // 克隆组件 PLPageDefination pdNew = ServerTool.getPLPageDefination(pde); // 设置新OID pdNew.plOId = ObjectUtility.getNewObjectID36(); // 与新页签关联 pdNew.plTabPageOId = tpNew.plOId; // 类型等于页签的区域类型 pdNew.plType = tpNew.plAreaType; // 保存新组件 plPageDefinationEntityService.savePLPageDefinationEntity(ServerTool.getPLPageDefinationEntity(pdNew)); ComponentCacheUtil.getInstance().setObject(pdNew); // 原组件上的按钮 List btnes = plTabButtonEntityService.getPLTabButtonEntitysByTableOId(pde.getPlOId()); // 复制原组件上的按钮到新克隆出的组件 copyBtnToNewPageDefination(pdNew, btnes); } } /** * 将按钮复制到组件 * * @param pdNew 组件 * @param btnes 按钮列表 * @throws Throwable */ private void copyBtnToNewPageDefination(PLPageDefination pdNew, List btnes) throws Throwable { HashMap mapOID = new HashMap(); // List lstBtn = new ArrayList(); List lstBtn = new ArrayList(); List lstBtnParame = new ArrayList(); for (PLTabButtonEntity btne : btnes) { // 克隆按钮 PLTabButton btnNew = ServerTool.getPLTabButton(btne); // 设置新OID btnNew.plOId = ObjectUtility.getNewObjectID36(); mapOID.put(btne.getPlOId(), btnNew.plOId); // 与组件关联 btnNew.plTableOId = pdNew.plOId; PLTabButtonEntity btnNewEnt = ServerTool.getPLTabButtonEntity(btnNew); lstBtn.add(btnNewEnt); // 原按钮上的参数 List cpes = plCommandParameterEntityService .getPLCommandParameterEntitysByCommandOId(btne.getPlOId()); for (PLCommandParameterEntity cpe : cpes) { // 克隆按钮参数 PLCommandParameter cpNew = ServerTool.getPLCommandParameter(cpe); // 设置新OID cpNew.plOId = ObjectUtility.getNewObjectID36(); // 与新按钮关联 cpNew.plCommandOId = btnNew.plOId; // 保存新按钮的参数 lstBtnParame.add(ServerTool.getPLCommandParameterEntity(cpNew)); } } for (PLTabButtonEntity btn : lstBtn) { String oidParent = btn.getPlParentOid(); if (oidParent != null && !oidParent.isEmpty()) { if (mapOID.containsKey(oidParent)) btn.setPlParentOid(mapOID.get(oidParent)); else btn.setPlParentOid(""); // lstNewBtn.add(ServerTool.getPLTabButtonEntity(btn)); // plTabButtonEntityService.savePLTabButtonEntity(); } } plTabButtonEntityService.bacthSavePLTabButtonEntity(lstBtn.toArray(new PLTabButtonEntity[0])); for (PLTabButtonEntity ent : lstBtn) { ComponentBtnCacheUtil.getInstance().setObject(ent); } plCommandParameterEntityService.batchSavePLCommandParameterEntity(lstBtnParame.toArray(new PLCommandParameterEntity[0])); for (PLCommandParameterEntity ent : lstBtnParame) { ButtonParamCacheUtil.getInstance().setObject(ServerTool.getPLCommandParameter(ent)); } } /** * 将参数复制到按钮 * * @param btnNew 按钮 * @param cpes 按钮参数列表 * @throws Throwable */ // private void copyParamToNewTabButton(PLTabButton btnNew, List cpes) throws Throwable{ // List lstBtnParame = new ArrayList(); // // for (PLCommandParameterEntity cpe : cpes) { // // 克隆按钮参数 // PLCommandParameter cpNew = ServerTool.getPLCommandParameter(cpe); // // 设置新OID // cpNew.plOId = ObjectUtility.getNewObjectID36(); // // 与新按钮关联 // cpNew.plCommandOId = btnNew.plOId; // // 保存新按钮的参数 // // lstBtnParame.add(ServerTool.getPLCommandParameterEntity(cpNew)); // } // plCommandParameterEntityService.batchSavePLCommandParameterEntity(lstBtnParame.toArray(new PLCommandParameterEntity[0])); // } /** * 检查指定的编码在页签列表中是否已经存在 * * @param code 编码 * @param tps 页签列表 * @return */ private boolean codeIsExistInTabPage(String code, PLTabPage[] tps) { boolean res = false; for (PLTabPage tp : tps) { if (code.equalsIgnoreCase(tp.plCode)) { res = true; break; } } return res; } //@Override public boolean copyComptToTabPage(String[] comptOids, PLTabPage plTabPage) throws Throwable { PLPageDefination[] pds = getPLPageDefinationsByPageContextOId(plTabPage.plOId); if (pds != null && pds.length > 0) { Arrays.sort(pds, new Comparator() { @Override public int compare(PLPageDefination o1, PLPageDefination o2) { return new Integer(o1.seq).compareTo(new Integer(o2.seq)); } }); } copyExistComptToExistTabPage(plTabPage, pds, comptOids); return true; } /** * 将已经存在的组件复制到已经存在的页签 * * @param plTabPage 页签 * @param pds 页下已经存在的组件 * @param comptOids 待复制的组件oids * @throws Throwable */ private void copyExistComptToExistTabPage(PLTabPage plTabPage, PLPageDefination[] pds, String[] comptOids) throws Throwable { short seq = 1; if (pds != null && pds.length > 0) { seq = (short) (pds[pds.length - 1].seq + 1); } for (String comptOid : comptOids) { // 原组件 PLPageDefinationEntity pde = plPageDefinationEntityService.getPLPageDefinationEntityById(comptOid); // 克隆组件 PLPageDefination pdNew = ServerTool.getPLPageDefination(pde); // 设置新OID pdNew.plOId = ObjectUtility.getNewObjectID36(); // 新页签关联 pdNew.plTabPageOId = plTabPage.plOId; // 设置顺序 pdNew.seq = seq; // 设置编码 // 如果编码已经存在,则为其添加后缀_copy boolean codeIsExist = codeIsExistInPageDefination(pde.getName(), pds); if (codeIsExist) { pdNew.name = pde.getName() + "_copy"; while ((codeIsExist) = codeIsExistInPageDefination(pdNew.name, pds)) { pdNew.name = pdNew.name + "_copy"; } } // 保存新组件 plPageDefinationEntityService.savePLPageDefinationEntity(ServerTool.getPLPageDefinationEntity(pdNew)); ComponentCacheUtil.getInstance().setObject(pdNew); // 原组件下的按钮 List btnes = plTabButtonEntityService.getPLTabButtonEntitysByTableOId(comptOid); // 克隆原组件的按钮到新组件 copyBtnToNewPageDefination(pdNew, btnes); seq += 1; } } /** * 检查指定的编码在组件中是否已经存在 * * @param code 编码 * @param pds 组件列表 * @return */ private boolean codeIsExistInPageDefination(String code, PLPageDefination[] pds) { boolean res = false; for (PLPageDefination pd : pds) { if (code.equalsIgnoreCase(pd.name)) { res = true; break; } } return res; } }