public void loadForm(JParamObject PO, EFFormDataModel formDataModel) { JConnection conn = null; JStatement stmt = null; Object object = null; try { conn = JConnection.getInstance(jdbcTemplate.getDataSource().getConnection()); stmt = conn.createStatement(); object = formServiceUtil.loadFormService(request, PO.GetValueByParamName(SYS_MODEL.SERVICE_ID)); EMPComposeFormInfo formInfo = (EMPComposeFormInfo) object; pluginsMap = (HashMap) formInfo.getDataContainerStub().getRefCompStubMap(); prepareSaveForm(PO, stmt, formDataModel); saveBillData(PO, stmt, formDataModel); finishSaveForm(PO, stmt, formDataModel); } catch (Exception ce) { ce.printStackTrace(); formDataModel.setFormSaveMessage(ce.getCause().getMessage()); } finally { closeAllResources(null, stmt, conn); } }
/** * @param loginStub LoginStub * @return AccountStub * @throws Exception */ protected static AccountStub getAccountStub(JParamObject loginStub) throws Exception { java.util.List accountSetList = (List) ConfigManager.getDefault().getCfgData("AccountSet", null); if (accountSetList == null || accountSetList.size() == 0) return null; AccountStub accountStub = null; for (int i = 0; i < accountSetList.size(); i++) { accountStub = (AccountStub) accountSetList.get(i); if (accountStub.getDataStorageId().equals(loginStub.GetValueByEnvName("DataBaseName", null)) && accountStub.getAccountId().equals(loginStub.GetValueByEnvName("DBNO", null))) { return accountStub; } } return null; }
/** * @param serviceKey String * @param runType int * @param paramObject JParamObject * @param dataObject Object * @param customObject Object * @param addinObject Object * @return JResponseObject * @throws Exception */ public static JResponseObject runEnterpriseService( String serviceKey, int runType, JParamObject paramObject, Object dataObject, Object customObject, Object addinObject) throws Exception { if (serviceKey == null || serviceKey.trim().length() == 0) return null; // paramObject.SetValueByEnvName("ServiceKey", serviceKey); if (runType == 0x0001) // return (JResponseObject) EAI.DAL.IOM( "BZServiceComponentManager", "syncRunService", paramObject, dataObject, customObject, addinObject); if (runType == 0x0002) // �������ú�̨���� return (JResponseObject) EAI.DAL.IOM( "BZServiceComponentManager", "asyncRunService", paramObject, dataObject, customObject, addinObject); return null; }
boolean lookDataSource(JConnection jconn, JParamObject PO) throws Exception { boolean hasDataSource = false; if (jconn != null) { String dataSource = PO.GetValueByEnvName("DataSource"); if (dataSource != null && !"".equals(dataSource)) { DataSource ds = null; // try { // ds = (DataSource) jconn.getDBContext().lookup("jdbc/" + // dataSource); // } // catch (Exception e) { // Context context = new InitialContext(); // Context envContext = (Context) context.lookup( // "java:/comp/env"); // ds = (DataSource) envContext.lookup("jdbc/" + dataSource); // // } if (ds != null) { jconn.getInstance(ds.getConnection()); hasDataSource = true; } } } return hasDataSource; }
public void finishSaveForm(JParamObject PO, JStatement stmt, EFFormDataModel formDataModel) throws Exception { Class types[] = {JStatement.class, formDataModel.getClass(), PO.getClass()}; Object object[] = {stmt, formDataModel, PO}; List<String> finishSaveFormList = (List<String>) pluginsMap.get("3"); declareClassMethod(finishSaveFormList, types, object, "finishLoadForm"); }
public void saveBillData(JParamObject PO, JStatement stmt, EFFormDataModel formDataModel) throws Exception { Class types[] = {JStatement.class, formDataModel.getClass(), PO.getClass()}; Object object[] = {stmt, formDataModel, PO}; List<String> saveBillDataList = (List<String>) pluginsMap.get("2"); declareClassMethod(saveBillDataList, types, object, "loadBillData"); declareClassMethod(saveBillDataList, types, object, "loadBillItemData"); declareClassMethod(saveBillDataList, types, object, "loadFormInfo"); }
/** * @param serviceKey String * @param paramObject JParamObject * @param dataObject Object * @param customObject Object * @param addinObject Object * @return JResponseObject * @throws Exception */ public static JResponseObject runAyncService( String serviceKey, JParamObject paramObject, Object dataObject, Object customObject, Object addinObject) throws Exception { if (serviceKey == null || serviceKey.trim().length() == 0) return null; // paramObject.SetValueByEnvName("ServiceKey", serviceKey); return runEnterpriseService( serviceKey, 0x0002, paramObject, dataObject, customObject, addinObject); }
/** * @param paramObject JParamObject * @return JConnection * @throws Exception */ public JConnection getConnection( JParamObject paramObject, Object Data, Object CustomObject, Object AdditiveObject) throws Exception { JConnection conn = null; AccountStub accountStub = getAccountStub(paramObject); if (accountStub == null) return null; // 设置dbOwner paramObject.SetValueByEnvName("dbOwner", accountStub.getUserId()); DataStorageStub dataStorageStub = getDataStorageStub(accountStub); if (dataStorageStub == null) return null; JDataSourceStub dataSourceStub = (JDataSourceStub) getDataSourceStub(dataStorageStub); conn = createConnection(dataSourceStub); return initConnection(conn, paramObject, dataSourceStub, accountStub, dataStorageStub); }
/** * @param ParamObject Object * @param DataObject Object * @param CustomObject Object * @param AdditiveObject Object * @return Object * @throws Exception */ public Object CheckDBDataSource( Object ParamObject, Object DataObject, Object CustomObject, Object AdditiveObject) throws Exception { JParamObject PO; String DBType; JDataSourceStub DSS; JConnection jconn = null; boolean hasDataSource = false; PO = (JParamObject) ParamObject; DBType = PO.GetValueByEnvName("DataBaseType"); for (int i = 0; i < DBList.size(); i++) { DSS = (JDataSourceStub) DBList.get(i); if (DSS.DataBaseType.toLowerCase().equals(DBType.toLowerCase()) == true) { if (DSS.DBClass == null) { DSS.DBClass = Class.forName(DSS.classname); } if (DSS.NAClass == null) { DSS.NAClass = Class.forName(DSS.dbclass); } if (DSS.NAClass != null) { jconn = (JConnection) DSS.NAClass.newInstance(); try { hasDataSource = lookDataSource(jconn, PO); } catch (Exception e) { e.printStackTrace(); } if (hasDataSource) break; } } } if (!hasDataSource) { throw new Exception("ϵͳû���ṩ" + DBType + "������ݿ�������!"); } if (hasDataSource) return jconn; return null; }
public Object getExtendAgentObject() { if (extendAgentObject == null) extendAgentObject = JParamObject.Create(); // setAgentSafety(extendAgentObject.isSecurity()); // if ( EAI.Server != null && !"".equals(EAI.Server) ) { // if (!extendAgentObject.isSecurity()) { // setAgentServer(extendAgentObject.getEAIServer(EAI.Server)); // setAgentPort(extendAgentObject.getEAIPort(EAI.Port)); // } else { // setAgentServer(extendAgentObject.getSSLEAIServer(EAI.SSLServer)); // setAgentSafetyPort(extendAgentObject.getSSLEAIPort(EAI.SSLPort)); // } // setAgentAppName(extendAgentObject.getEnterpriseServer(EAI.Path)); // return extendAgentObject; // } return extendAgentObject; }
/** * @param conn JConnection * @param PO JParamObject * @param DSS JDataSourceStub * @param custObj Object * @return JConnection * @throws Exception */ protected static JConnection initConnection( JConnection conn, JParamObject PO, JDataSourceStub dataSourceStub, AccountStub accountStub, DataStorageStub dataStorageStub) throws Exception { if (conn.InitConnection(PO, dataSourceStub, accountStub, dataStorageStub) == null) return null; // if (PO.isAutoConnection()) { // PO.addConn(conn); // } // 写入日志 writeLoginfo(conn, PO); // add by fsz List sqlList = (List) PO.getValue("$$SQL_VIEWLIST", null); if (sqlList != null) { // conn.setSqlLogList(sqlList); } return conn; }
/** * 分析并计算各报表函数 返回一个计算后的表达式 * * @param f1string String * @param PO JParamObject * @param ConnObject Object * @param Scan IScanFunction * @param UserObject Object * @param OwnerObject Object * @return String * @throws Exception */ public String ScanFunctionFromF1( String f1string, JParamObject PO, Object ConnObject, IScanFunction Scan, Object UserObject, Object OwnerObject) throws Exception { Stack SourceStack = new Stack(); int i = 0, b = 0, f = 0; String sTmp1, sTmp2, FTag, FString, F1String; JFunctionStub FS = null; F1String = f1string; int itmp = 1; while (i < F1String.length()) { sTmp1 = F1String.substring(i, i + 1); // 如果等"("压栈 if (sTmp1.equals("(")) { SourceStack.push(String.valueOf(i)); } // 括号封闭 if (sTmp1.equals(")")) { sTmp2 = (String) SourceStack.pop(); b = Integer.valueOf(sTmp2).intValue(); f = b - 1; // 找出函数的左边的开始位置 while (f >= 0) { sTmp2 = F1String.substring(f, f + 1); if (FunctionTag.indexOf(sTmp2) != -1) { break; } else f--; } f++; FTag = F1String.substring(f, b); FString = F1String.substring(f, i + 1); /** * 将函数取TRIM,因为在函数两端可能存在空格,这样会导致函数计算不出来 如:KMJE(1001,JFFS) + KMJE(1002,JFFS) modified by * hufeng 2005.9.7 */ FTag = FTag.trim(); FS = getFunctionByID(FTag, OwnerObject); // if ( FS == null ) { // System.out.println("找不到函数的实现类"+FTag); // throw new Exception("找不到函数的实现类"+FTag); // } if (PO != null && FS != null && Scan instanceof JCalculateZbRequestObject) { PO.SetValueByParamName("TMP_NUM", String.valueOf(itmp)); itmp++; } FTag = (String) Scan.ScanReplace(FS, FString, PO, ConnObject, UserObject); // 第一条语句出处 // add by fsz 2004.5.`14 如果没有错误,返回SQL if (FS != null) Text += FS.Function.getErrText(); // end if (FTag != null) { F1String = F1String.substring(0, f) + FTag + F1String.substring(i + 1, F1String.length()); // i从替换后听位置处开始处理 i = f + FTag.length(); continue; } else { i = f + FString.length(); continue; } } i++; } if (SourceStack.size() != 0) { throw new Exception("公式定义错误,左右括号不匹配!"); } Boolean boo = false; while (b < F1String.length()) { sTmp2 = F1String.substring(b, b + 1); if (sTmp2.equals(";")) { boo = true; b = 0; break; } b++; } if (boo == true) { throw new Exception("公式定义中不允许包含字符 ';' !"); } return F1String; }