DOBO boForm = DOBO.getDOBOByName("do_ui_formmodel");
DOBO boFormLink = DOBO.getDOBOByName("DO_UI_FormLinks");
DOBO boFormTarget = DOBO.getDOBOByName("DO_UI_FormTargets");
// /还要复制子面板连接(子面板内部不复制)
BOInstance biPane = boPane.getCorrInstance();
DOPaneModel pm = DOPaneModel.getPaneModelByID(biPane.getUid());
DOGridModel gm = pm.getGridModel();
// //如果连接的是表格:::::暂时只实现这个
if (gm != null) {
// /////保存GridModel
BOInstance biGrid = boGrid.getInstance(gm.getObjUid());
biGrid.putValue("objuid", null);
biGrid.putValue("name", biGrid.getValue("name") + "_copy");
biGrid.putValue("l10n", biGrid.getValue("l10n") + "_copy");
BOInstance newBiGrid = boGrid.getDInsertService().invokeUpdate(
biGrid);
// //保存GridModel
// /保存面板
biPane.putValue("objuid", null);
biPane.putValue("name", biPane.getValue("name") + "_copy");
biPane.putValue("l10n", biPane.getValue("l10n") + "_copy");
biPane.putValue("linkuid", newBiGrid.getUid());
boPane.getDInsertService().invokeUpdate(biPane);
// /保存面板
List<DOFormModel> fms = gm.getAllGridFormLinks();
Map<DOFormModel,BOInstance> map = new HashMap<DOFormModel,BOInstance>();
for (Iterator<DOFormModel> it = fms.iterator(); it.hasNext();) {
DOFormModel aFm = it.next();
// ///保存FormModel
BOInstance biForm = boForm.getInstance(aFm.getObjUid());
biForm.putValue("objuid", null);
biForm.putValue("gridModelUid", newBiGrid.getUid());
DOService fmInsert = boForm.getDInsertService();
if("en".equals(DOGlobals.getValue("lang.local"))){
fmInsert = DOService.getService("DO_UI_FormModel_Insert_EN");
}
BOInstance newBiForm = fmInsert.invokeUpdate(biForm);
map.put(aFm, newBiForm);
// //保存FormModel
for(Iterator<DOFormTarget> itTargetGrid = aFm.getTargetGridModels().iterator();itTargetGrid.hasNext(); ){
DOFormTarget aFt = itTargetGrid.next();
BOInstance biFt = boFormTarget.getInstance(aFt.getObjUid());
biFt.putValue("objuid", null);
biFt.putValue("formUid", newBiForm.getUid());
boFormTarget.getDInsertService().invokeUpdate(biFt);
}
}
/////linkForms 需要单独处理
for (Iterator<DOFormModel> it = fms.iterator(); it.hasNext();) {
DOFormModel aFm = it.next();
BOInstance newBiForm = map.get(aFm);
// //FormModel linkForms
for(Iterator<DOFormModel> itLinkForms = aFm.getLinkForms().iterator(); itLinkForms.hasNext();){
DOFormModel linkForm = itLinkForms.next();
BOInstance newLinkBiForm = new BOInstance();
if(map.get(linkForm)!=null){
newLinkBiForm = map.get(linkForm);
}else{
newLinkBiForm = boForm.getInstance(linkForm.getObjUid());
}
//
Map<String,String> paras = new HashMap<String,String>();
paras.put("formuid", newBiForm.getUid());
paras.put("linkformuid", newLinkBiForm.getUid());
boFormLink.getDInsertService().invokeUpdate(paras);
}
}