diff --git a/migration/i8.1z/oracle/202012180100_IDEMPIERE-4599.sql b/migration/i8.1z/oracle/202012180100_IDEMPIERE-4599.sql new file mode 100644 index 0000000000..c14d4f2e17 --- /dev/null +++ b/migration/i8.1z/oracle/202012180100_IDEMPIERE-4599.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Dec 18, 2020, 6:19:26 AM MYT +UPDATE AD_Process SET IsActive='N',Updated=TO_DATE('2020-12-18 06:19:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=208 +; + +SELECT register_migration_script('202012180100_IDEMPIERE-4599.sql') FROM dual +; + diff --git a/migration/i8.1z/postgresql/202012180100_IDEMPIERE-4599.sql b/migration/i8.1z/postgresql/202012180100_IDEMPIERE-4599.sql new file mode 100644 index 0000000000..ac83c61eff --- /dev/null +++ b/migration/i8.1z/postgresql/202012180100_IDEMPIERE-4599.sql @@ -0,0 +1,7 @@ +-- Dec 18, 2020, 6:19:26 AM MYT +UPDATE AD_Process SET IsActive='N',Updated=TO_TIMESTAMP('2020-12-18 06:19:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=208 +; + +SELECT register_migration_script('202012180100_IDEMPIERE-4599.sql') FROM dual +; + diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java b/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java deleted file mode 100644 index aa4ac1315e..0000000000 --- a/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java +++ /dev/null @@ -1,596 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.process; - -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Properties; -import java.util.logging.Level; - -import javax.sql.RowSet; - -import org.compiere.db.CConnection; -import org.compiere.interfaces.Server; -import org.compiere.model.MReplication; -import org.compiere.model.MReplicationLog; -import org.compiere.model.MReplicationRun; -import org.compiere.model.MSystem; -import org.compiere.util.CCachedRowSet; -import org.compiere.util.CLogger; -import org.compiere.util.DB; - -/** - * Local (Central) Data Replication. - * Note: requires migration technology - * - * @author Jorg Janke - * @version $Id: ReplicationLocal.java,v 1.2 2006/07/30 00:51:01 jjanke Exp $ - */ -public class ReplicationLocal extends SvrProcess -{ - /** System Record */ - private MSystem m_system = null; - /** Replication Info */ - private MReplication m_replication = null; - /** Replication Run */ - private MReplicationRun m_replicationRun = null; - /** Test Flag */ - private Boolean m_test = Boolean.FALSE; - /** Replication Flag */ - private boolean m_replicated = true; - /** Remote Server */ - private Server m_serverRemote = null; - private long m_start = System.currentTimeMillis(); - /** Date Run on Remote */ - private Timestamp m_replicationStart = new Timestamp (m_start); - - /** Logger */ - private static final CLogger s_log = CLogger.getCLogger(ReplicationLocal.class); - - /** Remote class */ - private static String REMOTE = "org.compiere.process.ReplicationRemote"; - protected static String START = "com.adempiere.client.StartReplication"; - - /** - * Prepare - e.g., get Parameters. - */ - public void prepare() - { - ProcessInfoParameter[] para = getParameter(); - for (int i = 0; i < para.length; i++) - { - String name = para[i].getParameterName(); - if (para[i].getParameter() == null) - ; - else if (name.equals("IsTest")) - m_test = Boolean.valueOf("Y".equals (para[i].getParameter())); - else - log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name); - } - m_system = MSystem.get (getCtx()); - } // prepare - - /** - * Perform process. - * @return Message - * @throws Exception if not successful - */ - public String doIt() throws Exception - { - if (m_system == null || !m_system.isValid()) - return ("SystemNotSetupForReplication"); - // - if (log.isLoggable(Level.INFO)) log.info("doIt - Record_ID=" + getRecord_ID() + ", test=" + m_test); - connectRemote(); - // - setupRemote(); - mergeData(); - sendUpdates(); - - // Save Info - if (log.isLoggable(Level.INFO)) log.info("doIt - Replicated=" + m_replicated + " - " + m_replicationStart); - m_replicationRun.setIsReplicated(m_replicated); - double sec = (System.currentTimeMillis() - m_start); - sec /= 1000; - m_replicationRun.setDescription(sec + " s"); - m_replicationRun.saveEx(); - if (m_replicated) - { - m_replication.setDateLastRun (m_replicationStart); - m_replication.saveEx(); - } - // - exit(); - return m_replicated ? "Replicated" : "Replication Error"; - } // doIt - - - /** - * Connect to Remote Server - * @throws java.lang.Exception - */ - private void connectRemote() throws Exception - { - // Replication Info - m_replication = new MReplication (getCtx(), getRecord_ID(), get_TrxName()); - // - String AppsHost = m_replication.getHostAddress(); - int AppsPort = m_replication.getHostPort(); - - CConnection connection = new CConnection(AppsHost); - if (log.isLoggable(Level.INFO)) log.info (AppsHost + ":" + AppsPort); - try - { - Server server = connection.getServer(); - // log.fine("- ServerHome: " + serverHome); - if (server == null) - throw new Exception ("NoServer"); - m_serverRemote = server; - // log.fine("- Server: " + m_serverRemote); - // log.fine("- Remote Status = " + m_serverRemote.getStatus()); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "connectRemote", ex); - throw new Exception (ex); - } - } // connectRemote - - - /** - * Setup Remote AD_System/AD_Table/AD_Sequence for Remote Management. - * @throws Exception - */ - private void setupRemote() throws Exception - { - log.info("setupRemote"); - // - String sql = "SELECT rt.AD_Table_ID, rt.ReplicationType, t.TableName " - + "FROM AD_ReplicationTable rt" - + " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID) " - + "WHERE rt.IsActive='Y' AND t.IsActive='Y'" - + " AND AD_ReplicationStrategy_ID=? " // #1 - + "ORDER BY t.LoadSeq"; - RowSet rowset = getRowSet(sql, new Object[]{Integer.valueOf(m_replication.getAD_ReplicationStrategy_ID())}); - if (rowset == null) - throw new Exception("setupRemote - No RowSet Data"); - - // Data Info - RemoteSetupVO data = new RemoteSetupVO(); - data.Test = m_test; - data.ReplicationTable = rowset; // RowSet - data.IDRangeStart = m_replication.getIDRangeStart(); - data.IDRangeEnd = m_replication.getIDRangeEnd(); - data.AD_Client_ID = m_replication.getRemote_Client_ID(); - data.AD_Org_ID = m_replication.getRemote_Org_ID(); - data.Prefix = m_replication.getPrefix(); - data.Suffix = m_replication.getSuffix(); - // Process Info - ProcessInfo pi = new ProcessInfo(data.toString(), 0); - pi.setClassName (REMOTE); - pi.setSerializableObject(data); - Object result = doIt(START, "init", new Object[]{m_system}); - if (result == null || !Boolean.TRUE.equals(result)) - throw new Exception("setupRemote - Init Error - " + result); - // send it - pi = m_serverRemote.process (new Properties (), pi); - ProcessInfoLog[] logs = pi.getLogs(); - Timestamp dateRun = null; - if (logs != null && logs.length > 0) - dateRun = logs[0].getP_Date(); // User Remote Timestamp! - // - if (log.isLoggable(Level.INFO)) log.info ("setupRemote - " + pi + " - Remote Timestamp = " + dateRun); - if (dateRun != null) - m_replicationStart = dateRun; - m_replicationRun = new MReplicationRun (getCtx(), m_replication.getAD_Replication_ID(), m_replicationStart, get_TrxName()); - m_replicationRun.saveEx(); - } // setupRemote - - /*************************************************************************/ - - /** - * Receive new Data from Remote. - * @throws Exception - */ - private void mergeData() throws Exception - { - log.info("mergeData"); - // - String sql = "SELECT rt.AD_Table_ID, rt.ReplicationType, t.TableName, rt.AD_ReplicationTable_ID " - + "FROM AD_ReplicationTable rt" - + " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID) " - + "WHERE rt.IsActive='Y' AND t.IsActive='Y'" - + " AND AD_ReplicationStrategy_ID=?" // #1 - + " AND rt.ReplicationType='M' " // Merge - + "ORDER BY t.LoadSeq"; - RowSet rowset = getRowSet(sql, new Object[]{Integer.valueOf(m_replication.getAD_ReplicationStrategy_ID())}); - try - { - while (rowset.next()) - mergeDataTable (rowset.getInt(1), rowset.getString(3), rowset.getInt(4)); - } - catch (SQLException ex) - { - log.log(Level.SEVERE, "mergeData", ex); - m_replicated = false; - } - finally - { - DB.close(rowset); - rowset = null; - } - } // mergeData - - /** - * Receive New Data from Remote (and send local updates) - * @param AD_Table_ID table id - * @param TableName table name - * @param AD_ReplicationTable_ID id - * @return true if success - * @throws java.lang.Exception - */ - private boolean mergeDataTable (int AD_Table_ID, String TableName, int AD_ReplicationTable_ID) throws Exception - { - RemoteMergeDataVO data = new RemoteMergeDataVO(); - data.Test = m_test; - data.TableName = TableName; - // Create SQL - StringBuilder sql = new StringBuilder("SELECT * FROM ") - .append(TableName) - .append(" WHERE AD_Client_ID=").append(m_replication.getRemote_Client_ID()); - if (m_replication.getRemote_Org_ID() != 0) - sql.append(" AND AD_Org_ID IN (0,").append(m_replication.getRemote_Org_ID()).append(")"); - if (m_replication.getDateLastRun() != null) - sql.append(" AND Updated >= ").append(DB.TO_DATE(m_replication.getDateLastRun(), false)); - sql.append(" ORDER BY "); - data.KeyColumns = getKeyColumns(AD_Table_ID); - if (data.KeyColumns == null || data.KeyColumns.length == 0) - { - log.log(Level.SEVERE, "mergeDataTable - No KeyColumns for " + TableName); - m_replicated = false; - return false; - } - for (int i = 0; i < data.KeyColumns.length; i++) - { - if (i > 0) - sql.append(","); - sql.append(data.KeyColumns[i]); - } - data.Sql = sql.toString(); - // New Central Data - data.CentralData = getRowSet(data.Sql, null); - if (data.CentralData == null) - { - if (log.isLoggable(Level.FINE)) log.fine("mergeDataTable - CentralData is Null - " + TableName); - m_replicated = false; - return false; - } - - // Process Info - ProcessInfo pi = new ProcessInfo("MergeData", 0); - pi.setClassName (REMOTE); - pi.setSerializableObject(data); - // send it - pi = m_serverRemote.process (new Properties (), pi); - ProcessInfoLog[] logs = pi.getLogs(); - StringBuilder msg = new StringBuilder("< "); - if (logs != null && logs.length > 0) - msg.append(logs[0].getP_Msg()); // Remote Message - if (log.isLoggable(Level.INFO)) log.info("mergeDataTable - " + pi); - // - MReplicationLog rLog = new MReplicationLog (getCtx(), m_replicationRun.getAD_Replication_Run_ID(), AD_ReplicationTable_ID, msg.toString(), get_TrxName()); - if (pi.isError()) - { - log.severe ("mergeDataTable Error - " + pi); - m_replicated = false; - rLog.setIsReplicated(false); - } - else // import data fom remote - { - RowSet sourceRS = (RowSet)pi.getSerializableObject(); - RowSet targetRS = getRowSet(data.Sql, null); - Object result = doIt (START, "sync", new Object[] // Merge - {data.TableName, data.KeyColumns, sourceRS, targetRS, m_test, Boolean.TRUE}); - boolean replicated = isReplicated(result); - if (replicated) { - if (log.isLoggable(Level.FINE)) log.fine("mergeDataTable -> " + TableName + " - " + result); - } else { - m_replicated = false; - log.severe ("mergeDataTable -> " + TableName + " - " + result); - } - rLog.setIsReplicated(replicated); - if (result != null) - rLog.setP_Msg("< " + result.toString()); - DB.close(sourceRS); - sourceRS = null; - DB.close(targetRS); - targetRS = null; - } - rLog.saveEx(); - return !pi.isError(); - } // mergeDataTable - - /** - * Get Key Columns (PK or FK) of Table - * @param AD_Table_ID id - * @return Key Columns - */ - public String[] getKeyColumns (int AD_Table_ID) - { - ArrayList list = new ArrayList(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - // Get Keys - String sql = "SELECT ColumnName FROM AD_Column " - + "WHERE AD_Table_ID=?" - + " AND IsKey='Y'"; - pstmt = DB.prepareStatement(sql, get_TrxName()); - pstmt.setInt(1, AD_Table_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - list.add(rs.getString(1)); - // no keys - search for parents - if (list.size() == 0) - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - sql = "SELECT ColumnName FROM AD_Column " - + "WHERE AD_Table_ID=?" - + " AND IsParent='Y'"; - pstmt = DB.prepareStatement(sql, get_TrxName()); - pstmt.setInt(1, AD_Table_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - list.add(rs.getString(1)); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, "getKeyColumns", e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - // Convert to Array - String[] retValue = new String[list.size()]; - list.toArray(retValue); - return retValue; - } // getKeyColumns - - /*************************************************************************/ - - /** - * Send Updates to Remote (i.e. r/o on remote) - * @throws Exception - */ - private void sendUpdates() throws Exception - { - log.info("sendUpdates"); - // - String sql = "SELECT rt.AD_Table_ID, rt.ReplicationType, t.TableName, rt.AD_ReplicationTable_ID " - + "FROM AD_ReplicationTable rt" - + " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID) " - + "WHERE rt.IsActive='Y' AND t.IsActive='Y'" - + " AND AD_ReplicationStrategy_ID=?" // #1 - + " AND rt.ReplicationType='R' " // Reference - + "ORDER BY t.LoadSeq"; - RowSet rowset = getRowSet(sql, new Object[]{Integer.valueOf(m_replication.getAD_ReplicationStrategy_ID())}); - try - { - while (rowset.next()) - sendUpdatesTable (rowset.getInt(1), rowset.getString(3), rowset.getInt(4)); - } - catch (SQLException ex) - { - log.log(Level.SEVERE, "sendUpdates", ex); - m_replicated = false; - } - finally - { - DB.close(rowset); - rowset = null; - } - } // sendUpdates - - /** - * Send UPdates to Remote - * @param AD_Table_ID table id - * @param TableName table - * @param AD_ReplicationTable_ID id - * @return true if success - * @throws Exception - */ - private boolean sendUpdatesTable (int AD_Table_ID, String TableName, int AD_ReplicationTable_ID) throws Exception - { - RemoteUpdateVO data = new RemoteUpdateVO(); - data.Test = m_test; - data.TableName = TableName; - // Create SQL - StringBuilder sql = new StringBuilder ("SELECT * FROM ") - .append(TableName) - .append(" WHERE AD_Client_ID=").append(m_replication.getRemote_Client_ID()); - if (m_replication.getRemote_Org_ID() != 0) - sql.append(" AND AD_Org_ID IN (0,").append(m_replication.getRemote_Org_ID()).append(")"); - if (m_replication.getDateLastRun() != null) - sql.append(" AND Updated >= ").append(DB.TO_DATE(m_replication.getDateLastRun(), false)); - sql.append(" ORDER BY "); - data.KeyColumns = getKeyColumns(AD_Table_ID); - if (data.KeyColumns == null || data.KeyColumns.length == 0) - { - log.log(Level.SEVERE, "sendUpdatesTable - No KeyColumns for " + TableName); - m_replicated = false; - return false; - } - for (int i = 0; i < data.KeyColumns.length; i++) - { - if (i > 0) - sql.append(","); - sql.append(data.KeyColumns[i]); - } - data.Sql = sql.toString(); - // New Data - data.CentralData = getRowSet(data.Sql, null); - if (data.CentralData == null) - { - if (log.isLoggable(Level.FINE)) log.fine("sendUpdatesTable - Null - " + TableName); - m_replicated = false; - return false; - } - int rows = 0; - try - { - if (data.CentralData.last()) - rows = data.CentralData.getRow(); - data.CentralData.beforeFirst(); // rewind - } - catch (SQLException ex) - { - if (log.isLoggable(Level.FINE)) log.fine("RowCheck " + ex); - m_replicated = false; - return false; - } - if (rows == 0) - { - if (log.isLoggable(Level.FINE)) log.fine("No Rows - " + TableName); - return true; - } - else - if (log.isLoggable(Level.FINE)) log.fine(TableName + " #" + rows); - - // Process Info - ProcessInfo pi = new ProcessInfo("SendUpdates", 0); - pi.setClassName (REMOTE); - pi.setSerializableObject(data); - // send it - pi = m_serverRemote.process (new Properties (), pi); - if (log.isLoggable(Level.INFO)) log.info("sendUpdatesTable - " + pi); - ProcessInfoLog[] logs = pi.getLogs(); - StringBuilder msg = new StringBuilder("> "); - if (logs != null && logs.length > 0) - msg.append(logs[0].getP_Msg()); // Remote Message - // - MReplicationLog rLog = new MReplicationLog (getCtx(), m_replicationRun.getAD_Replication_Run_ID(), AD_ReplicationTable_ID, msg.toString(), get_TrxName()); - if (pi.isError()) - m_replicated = false; - rLog.setIsReplicated(!pi.isError()); - rLog.saveEx(); - return !pi.isError(); - } // sendUpdatesTable - - /** - * Clean up resources (connections) - */ - private void exit() - { - log.info ("exit"); - @SuppressWarnings("unused") - Object result = doIt(START, "exit", null); - ProcessInfo pi = new ProcessInfo("Exit", 0); - pi.setClassName (REMOTE); - pi.setSerializableObject(m_replicationStart); - // send it - try - { - m_serverRemote.process (new Properties (), pi); - } - catch (Exception ex) - { - } - } // exit - - - /************************************************************************** - * Get RowSet of Local Connection - * @param sql sql - * @param args optional argument array - supported: Integer, Timestamp, BigDecimal - rest is concerted to String - * @return row set - */ - public static RowSet getRowSet (String sql, Object[] args) - { - // shared connection - Connection conn = DB.getConnectionRO(); - PreparedStatement pstmt = null; - RowSet rowSet = null; - ResultSet rs = null; - // - try - { - sql = DB.getDatabase().convertStatement(sql); - pstmt = conn.prepareStatement(sql, - ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); - // Set Parameters - if (args != null) - { - for (int i = 0; i < args.length; i++) - { - if (args[i] == null) - s_log.log(Level.SEVERE, "NULL Argument " + i); - else if (args[i] instanceof Integer) - pstmt.setInt(i+1, ((Integer)args[i]).intValue()); - else if (args[i] instanceof Timestamp) - pstmt.setTimestamp(i+1, (Timestamp)args[i]); - else if (args[i] instanceof BigDecimal) - pstmt.setBigDecimal(i+1, (BigDecimal)args[i]); - else - pstmt.setString(i+1, args[i].toString()); - } - } - // - rs = pstmt.executeQuery(); - rowSet = CCachedRowSet.getRowSet(rs); - } - catch (Exception ex) - { - s_log.log(Level.SEVERE, sql, ex); - throw new RuntimeException (ex); - } - // Close Cursor - finally - { - DB.close(rs,pstmt); - rs = null;pstmt = null; - } - - return rowSet; - } // getRowSet - - /** - * Is data successful replicated - * @param result sync return value - * @return true if replicated - */ - public static boolean isReplicated (Object result) - { - boolean replicated = result != null && !Boolean.FALSE.equals(result); - if (replicated) - replicated = result.toString().endsWith("Errors=0"); - return replicated; - } // isReplicated - -} // ReplicationLocal diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplicationRemote.java b/org.adempiere.base.process/src/org/compiere/process/ReplicationRemote.java deleted file mode 100644 index 42eb69af55..0000000000 --- a/org.adempiere.base.process/src/org/compiere/process/ReplicationRemote.java +++ /dev/null @@ -1,316 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.process; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.logging.Level; - -import javax.sql.RowSet; - -import org.compiere.model.MSystem; -import org.compiere.util.DB; - -/** - * Remote Data Replication. - * Note: requires migration technology - * - * @author Jorg Janke - * @version $Id: ReplicationRemote.java,v 1.2 2006/07/30 00:51:01 jjanke Exp $ - */ -public class ReplicationRemote extends SvrProcess -{ - /** System Record */ - private MSystem m_system = null; - /** Local Timestamp */ - private Timestamp m_startDate = new Timestamp(System.currentTimeMillis()); - - /** - * Prepare - e.g., get Parameters. - */ - public void prepare() - { - ProcessInfoParameter[] para = getParameter(); - for (int i = 0; i < para.length; i++) - { - String name = para[i].getParameterName(); - if (para[i].getParameter() == null) - ; - else - log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name); - } - m_system = MSystem.get (getCtx()); - } // prepare - - /** - * Perform process. - * @return Message - * @throws Exception if not successful - */ - public String doIt() throws Exception - { - ProcessInfo pi = getProcessInfo(); - if (log.isLoggable(Level.INFO)) log.info("doIt - " + pi.getTitle()); - if (pi.getSerializableObject() instanceof RemoteSetupVO) - return setupRemote(); - else if (pi.getSerializableObject() instanceof RemoteMergeDataVO) - return mergeDataWithCentral(); - else if (pi.getSerializableObject() instanceof RemoteUpdateVO) - return receiveUpdateFromCentral(); - else if (pi.getSerializableObject() instanceof Timestamp) - return exit(); - else - throw new Exception ("ReplicationRemote - unknown VO - " + pi.getSerializableObject()); - } // doIt - - /************************************************************************* - - /** - * Setup Remote AD_System/AD_Table/AD_Sequence for Remote Management. - * @return "" or error message - * @throws Exception - */ - private String setupRemote() throws Exception - { - ProcessInfo pi = getProcessInfo(); - RemoteSetupVO data = (RemoteSetupVO)pi.getSerializableObject(); - if (log.isLoggable(Level.INFO)) log.info("setupRemote Start (" + pi + ") " + data); - - RowSet rs = data.ReplicationTable; - try - { - // Update AD_System **** - if (data.IDRangeStart == null || data.IDRangeEnd == null) - throw new Exception ("setupRemote - IDRange cannot be null"); - if (!data.Test.booleanValue()) - { - setupRemoteAD_System (data.IDRangeStart, data.IDRangeEnd); - // Update AD_Sequence **** - setupRemoteAD_Sequence (data.IDRangeStart); - // Update DocNo Prefix/Suffix **** - setupRemoteC_DocType (data.AD_Client_ID, data.Prefix, data.Suffix); - } - // Update Tables **** - while (rs.next ()) - { - //int AD_Table_ID = rs.getInt(1); - String ReplicationType = rs.getString(2); - String TableName = rs.getString(3); - if (log.isLoggable(Level.FINE)) log.fine("setupRemote - " + TableName + " - " + ReplicationType); - if (!data.Test.booleanValue()) - setupRemoteAD_Table(TableName, ReplicationType); - } - pi.setSummary("OK - Test=" + data.Test, false); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "setupRemote", ex); - pi.setSummary(ex.toString(), true); - } - Object result = doIt(ReplicationLocal.START, "init", new Object[]{m_system}); - if (result == null || !Boolean.TRUE.equals(result)) - throw new Exception("setupRemote - Init Error - " + result); - pi.setSerializableObject(null); - pi.addLog(0,0, m_startDate, null, null); - if (log.isLoggable(Level.INFO)) log.info("setupRemote End (" + pi + ") " + data); - return "Remote SetupRemote OK"; - } // setupRemote - - /** - * Update Replication Type and ID Range of AD_System - * @param IDRangeStart start - * @param IDRangeEnd end - * @throws Exception if sql error - */ - private void setupRemoteAD_System (BigDecimal IDRangeStart, BigDecimal IDRangeEnd) throws Exception - { - m_system.setIDRangeStart(IDRangeStart); - m_system.setIDRangeEnd(IDRangeEnd); - m_system.setReplicationType(MSystem.REPLICATIONTYPE_Merge); - m_system.saveEx(); - } // setupRemoteAD_System - - /** - * Update StartNo/CurrentNext/CurrentNextSys in AD_Sequence - * @param IDRangeStart start - * @throws Exception if sql error - */ - private void setupRemoteAD_Sequence (BigDecimal IDRangeStart) throws Exception - { - StringBuilder sql = new StringBuilder("UPDATE AD_Sequence SET StartNo = ").append(IDRangeStart) - .append(" WHERE IsTableID='Y' AND StartNo < ").append(IDRangeStart); - int no = DB.executeUpdate(sql.toString(), get_TrxName()); - if (no == -1) - throw new Exception("setupRemoteAD_Sequence_Start"); - // - sql = new StringBuilder("UPDATE AD_Sequence SET CurrentNext = ").append(IDRangeStart) - .append(" WHERE IsTableID='Y' AND CurrentNext < ").append(IDRangeStart); - no = DB.executeUpdate(sql.toString(), get_TrxName()); - if (no == -1) - throw new Exception("setupRemoteAD_Sequence_Next"); - // - sql = new StringBuilder("UPDATE AD_Sequence SET CurrentNextSys = -1") - .append(" WHERE IsTableID='Y' AND CurrentNextSys <> -1"); - no = DB.executeUpdate(sql.toString(), get_TrxName()); - if (no == -1) - throw new Exception("setupRemoteAD_Sequence_Sys"); - } // setupRemoteAD_Sequence - - /** - * Update Document Prefix/Suffix - * @param AD_Client_ID client - * @param Prefix prefix - * @param Suffix suffix - * @throws Exception if sql error - */ - private void setupRemoteC_DocType (int AD_Client_ID, String Prefix, String Suffix) throws Exception - { - if (Prefix == null) - Prefix = ""; - if (Suffix == null) - Suffix = ""; - // DocNoSequence_ID - StringBuilder sql = new StringBuilder("UPDATE AD_Sequence SET Prefix=").append(DB.TO_STRING(Prefix)).append(", Suffix=").append(DB.TO_STRING(Suffix)) - .append(" WHERE AD_Sequence_ID IN (SELECT DocNoSequence_ID FROM C_DocType") - .append(" WHERE AD_Client_ID=").append(AD_Client_ID).append(" AND DocNoSequence_ID IS NOT NULL)"); - int no = DB.executeUpdate(sql.toString(), get_TrxName()); - if (no == -1) - throw new Exception("setupRemoteC_DocType_DocNo"); - // BatchNoSequence_ID - sql = new StringBuilder("UPDATE AD_Sequence SET Prefix=").append(DB.TO_STRING(Prefix)).append(", Suffix=").append(DB.TO_STRING(Suffix)) - .append(" WHERE AD_Sequence_ID IN (SELECT BatchNoSequence_ID FROM C_DocType") - .append(" WHERE AD_Client_ID=").append(AD_Client_ID).append(" AND BatchNoSequence_ID IS NOT NULL)"); - no = DB.executeUpdate(sql.toString(), get_TrxName()); - if (no == -1) - throw new Exception("setupRemoteC_DocType_Batch"); - } // setupRemoteC_DocType - - /** - * Set ReplicationType of AD_Table - * @param TableName table name - * @param ReplicationType replication type - * @throws Exception if sql error - */ - private void setupRemoteAD_Table(String TableName, String ReplicationType) throws Exception - { - StringBuilder sql = new StringBuilder("UPDATE AD_Table SET ReplicationType = '").append(ReplicationType) - .append("' WHERE TableName='").append(TableName).append("' AND ReplicationType <> '").append(ReplicationType).append("'"); - int no = DB.executeUpdate(sql.toString(), get_TrxName()); - if (no == -1) - throw new Exception("setupRemoteAD_Table"); - } // setupRemoteAD_Table - - /************************************************************************* - - /** - * Send new Data from Remote. - * Transcation Data changed - * @return info - * @throws Exception - */ - private String mergeDataWithCentral() throws Exception - { - ProcessInfo pi = getProcessInfo(); - RemoteMergeDataVO data = (RemoteMergeDataVO)pi.getSerializableObject(); - if (log.isLoggable(Level.INFO)) log.info("mergeDataWithCentral Start (" + pi + ") " + data); - // Merge Data from Central - RowSet sourceRS = data.CentralData; - if (sourceRS == null) - log.log(Level.SEVERE, "mergeDataWithCentral - No Data - " + data); - else if (!data.Test.booleanValue()) - { - RowSet targetRS = ReplicationLocal.getRowSet(data.Sql, null); - Object result = doIt (ReplicationLocal.START, "sync", new Object[] // Merge - {data.TableName, data.KeyColumns, sourceRS, targetRS, data.Test, Boolean.TRUE}); - if (log.isLoggable(Level.FINE)) log.fine("receiveUpdateFromCentral - " + data.TableName + " - " + result); - pi.setSerializableObject(null); - boolean replicated = ReplicationLocal.isReplicated(result); - if (!replicated) - pi.setError(true); - if (result != null) - pi.addLog(0,null,null, result.toString()); - if (Boolean.FALSE.equals(result)) - throw new Exception ("receiveUpdateFromCentral - " + data.TableName + " - " + result); - } - - // Local Remote Data - RowSet rowset = ReplicationLocal.getRowSet(data.Sql, null); - // Result - pi.setSerializableObject((Serializable)rowset); - if (log.isLoggable(Level.INFO)) log.info("mergeDataWithCentral End (" + pi + ") " + data); - return "Remote MergeDataWithCentral - " + data.TableName; - } // sendNewDataToCentral - - /************************************************************************* - - /** - * Receive Update from Central - * @return info - * @throws Exception - */ - private String receiveUpdateFromCentral() throws Exception - { - ProcessInfo pi = getProcessInfo(); - RemoteUpdateVO data = (RemoteUpdateVO)pi.getSerializableObject(); - if (log.isLoggable(Level.INFO)) log.info("receiveUpdateFromCentral Start (" + pi + ") - " + data); - // - RowSet sourceRS = data.CentralData; - if (sourceRS == null) - { - log.log(Level.SEVERE, "receiveUpdateFromCentral - No Data - " + data); - pi.setSummary("NoData", true); - } - else if (!data.Test.booleanValue()) - { - RowSet targetRS = ReplicationLocal.getRowSet(data.Sql, null); - Object result = doIt (ReplicationLocal.START, "sync", new Object[] // Sync - {data.TableName, data.KeyColumns, sourceRS, targetRS, data.Test, Boolean.FALSE}); - if (log.isLoggable(Level.FINE)) log.fine("receiveUpdateFromCentral - " + data.TableName + " - " + result); - pi.setSerializableObject(null); - boolean replicated = ReplicationLocal.isReplicated(result); - if (!replicated) - pi.setError(true); - if (result != null) - pi.addLog(0,null,null, result.toString()); - if (Boolean.FALSE.equals(result)) - throw new Exception ("receiveUpdateFromCentral - " + data.TableName + " - " + result); - } - // - pi.setSerializableObject(null); - if (log.isLoggable(Level.INFO)) log.info("receiveUpdateFromCentral End (" + pi + ") - " + data); - return "Remote Receive Update from Central OK"; - } // receiveUpdateFromCentral - - /*************************************************************************/ - - /** - * Clean up resources (connections) - * @return exit - * @throws Exception - */ - private String exit() throws Exception - { - log.info ("exit"); - @SuppressWarnings("unused") - ProcessInfo pi = getProcessInfo(); - @SuppressWarnings("unused") - Object result = doIt(ReplicationLocal.START, "exit", null); - return "exit"; - } // exit - -} // ReplicationRemote diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF index f65feb319f..df0a54406d 100644 --- a/org.adempiere.base/META-INF/MANIFEST.MF +++ b/org.adempiere.base/META-INF/MANIFEST.MF @@ -36,8 +36,6 @@ Export-Package: bsh, org.compiere.dbPort, org.compiere.impexp, org.compiere.install, - org.compiere.interfaces, - org.compiere.interfaces.impl, org.compiere.model, org.compiere.print, org.compiere.print.layout, diff --git a/org.adempiere.base/OSGI-INF/serverbean.xml b/org.adempiere.base/OSGI-INF/serverbean.xml deleted file mode 100644 index 75ba3fcc4e..0000000000 --- a/org.adempiere.base/OSGI-INF/serverbean.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.base/OSGI-INF/statusbean.xml b/org.adempiere.base/OSGI-INF/statusbean.xml deleted file mode 100644 index 1e63f707f1..0000000000 --- a/org.adempiere.base/OSGI-INF/statusbean.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.base/build.properties b/org.adempiere.base/build.properties index 8cf631453b..7d3bd4bcce 100644 --- a/org.adempiere.base/build.properties +++ b/org.adempiere.base/build.properties @@ -1,8 +1,6 @@ bin.includes = plugin.xml,\ OSGI-INF/,\ OSGI-INF/dslocator.xml,\ - OSGI-INF/serverbean.xml,\ - OSGI-INF/statusbean.xml,\ OSGI-INF/defaultmodelfactory.xml,\ OSGI-INF/defaultdocfactory.xml,\ OSGI-INF/defaultcolumncalloutfactory.xml,\ diff --git a/org.adempiere.base/src/org/compiere/db/CConnection.java b/org.adempiere.base/src/org/compiere/db/CConnection.java index 5b7f674c45..7681ca7ad1 100644 --- a/org.adempiere.base/src/org/compiere/db/CConnection.java +++ b/org.adempiere.base/src/org/compiere/db/CConnection.java @@ -26,8 +26,6 @@ import javax.naming.InitialContext; import javax.sql.DataSource; import javax.swing.JOptionPane; -import org.adempiere.base.Service; -import org.compiere.interfaces.Server; import org.compiere.util.CLogger; import org.compiere.util.Ini; @@ -304,16 +302,6 @@ public class CConnection implements Serializable, Cloneable } } - /** - * Get Server - * @return Server - */ - public Server getServer() - { - return Service.locator().locate(Server.class).getService(); - } // getServer - - /** * Get Apps Server Version * @return db host name diff --git a/org.adempiere.base/src/org/compiere/db/TestEJB.java b/org.adempiere.base/src/org/compiere/db/TestEJB.java deleted file mode 100644 index c022399ba2..0000000000 --- a/org.adempiere.base/src/org/compiere/db/TestEJB.java +++ /dev/null @@ -1,89 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.db; - -import javax.naming.CommunicationException; -import javax.naming.InitialContext; -import javax.naming.NameClassPair; -import javax.naming.NamingEnumeration; - -import org.compiere.interfaces.Status; - -/** - * Test EJB - * - * @author Jorg Janke - * @version $Id: TestEJB.java,v 1.3 2006/07/30 00:55:13 jjanke Exp $ - */ -public class TestEJB -{ - /** - * TestEJB - */ - public TestEJB () - { - CConnection cc = CConnection.get(); - cc.setAppsHost("dev1"); - InitialContext ic = cc.getInitialContext(false); - /**/ - try - { - System.out.println(ic.getEnvironment()); - System.out.println("----------------"); - NamingEnumeration ne = ic.list(""); - while (ne.hasMore()) - { - System.out.println(ne.next()); - } - } - catch (Exception e) - { - System.err.println(".."); - e.printStackTrace(); - System.exit(1); - } - /**/ - - // - try - { - @SuppressWarnings("unused") - Status status = (Status)ic.lookup ("Status"); - // - } - catch (CommunicationException ce) // not a "real" error - { - System.err.println("=ce="); - ce.printStackTrace(); - } - catch (Exception e) - { - System.err.println("=e="); - e.printStackTrace(); - } - } - - /** - * main - * @param args - */ - public static void main (String[] args) - { - new TestEJB(); - } // main - -} // TestEJB diff --git a/org.adempiere.base/src/org/compiere/interfaces/Server.java b/org.adempiere.base/src/org/compiere/interfaces/Server.java deleted file mode 100644 index b1aa61cf77..0000000000 --- a/org.adempiere.base/src/org/compiere/interfaces/Server.java +++ /dev/null @@ -1,69 +0,0 @@ - -package org.compiere.interfaces; - -import java.util.Properties; - -import org.compiere.process.ProcessInfo; -import org.compiere.util.EMail; - -/** - * Interface for adempiere/Server. - */ -public interface Server -{ - /** - * Post Immediate - * @param ctx Client Context - * @param AD_Client_ID Client ID of Document - * @param AD_Table_ID Table ID of Document - * @param Record_ID Record ID of this document - * @param force force posting - * @return null, if success or error message */ - public String postImmediate( Properties ctx, int AD_Client_ID, int AD_Table_ID, - int Record_ID, boolean force); - - /** - * Process Remote - * @param ctx Context - * @param pi Process Info - * @return resulting Process Info */ - public ProcessInfo process( Properties ctx, ProcessInfo pi ); - - /** - * Run Workflow (and wait) on Server - * @param ctx Context - * @param pi Process Info - * @param AD_Workflow_ID id - * @return process info */ - public ProcessInfo workflow( Properties ctx, ProcessInfo pi, int AD_Workflow_ID ); - - /** - * Send EMail from Server - * @param ctx Context - * @param email - * @return message return from email server */ - public String sendEMail( Properties ctx, EMail email); - - /** - * Execute task on server - * @param ctx Context - * @param AD_Task_ID task - * @return execution trace */ - public String executeTask( Properties ctx, int AD_Task_ID ); - - /** - * Cash Reset - * @param ctx Context - * @param tableName table name - * @param Record_ID record or 0 for all - * @return number of records reset */ - public int cacheReset( Properties ctx, String tableName,int Record_ID ); - - /** - * Execute db proces on server - * @param ctx Context - * @param processInfo - * @param procedureName - * @return ProcessInfo */ - public ProcessInfo dbProcess( Properties ctx, ProcessInfo processInfo, String procedureName ); -} diff --git a/org.adempiere.base/src/org/compiere/interfaces/Status.java b/org.adempiere.base/src/org/compiere/interfaces/Status.java deleted file mode 100644 index 489624df55..0000000000 --- a/org.adempiere.base/src/org/compiere/interfaces/Status.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.compiere.interfaces; - -/** - * Interface for adempiere/Status. - */ -public interface Status -{ - /** - * Get Version (Date) - * @return version e.g. 2002-09-02 */ - public String getDateVersion( ); - - /** - * Get Main Version - * @return main version - e.g. Version 2.4.3b */ - public String getMainVersion( ); - - /** - * Get Database Type - * @return Database Type */ - public String getDbType( ); - - /** - * Get Database Host - * @return Database Host Name */ - public String getDbHost( ); - - /** - * Get Database Port - * @return Database Port */ - public int getDbPort( ); - - /** - * Get Database SID - * @return Database SID */ - public String getDbName( ); - - /** - * Get Database URL - * @return Database URL */ - public String getConnectionURL( ); - - /** - * Get Database UID - * @return Database User Name */ - public String getDbUid( ); - - /** - * Get Database PWD - * @return Database User Password */ - public String getDbPwd( ); - - /** - * Get Connection Manager Host - * @return Connection Manager Host */ - public String getFwHost( ); - - /** - * Get Connection Manager Port - * @return Connection Manager Port */ - public int getFwPort( ); -} diff --git a/org.adempiere.base/src/org/compiere/interfaces/impl/ServerBean.java b/org.adempiere.base/src/org/compiere/interfaces/impl/ServerBean.java deleted file mode 100644 index 42970a8b37..0000000000 --- a/org.adempiere.base/src/org/compiere/interfaces/impl/ServerBean.java +++ /dev/null @@ -1,141 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.interfaces.impl; - -import java.util.Properties; -import java.util.logging.Level; - -import org.adempiere.util.ProcessUtil; -import org.compiere.acct.Doc; -import org.compiere.interfaces.Server; -import org.compiere.model.MAcctSchema; -import org.compiere.model.MTask; -import org.compiere.process.ProcessInfo; -import org.compiere.util.CLogger; -import org.compiere.util.CacheMgt; -import org.compiere.util.EMail; -import org.compiere.util.Env; - -/** - * Adempiere Server Bean. - * - * @author Jorg Janke - * @version $Id: ServerBean.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $ - * @author Low Heng Sin - * - Added remote transaction management - * - Added support to run db process remotely on server - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - BF [ 1757523 ] - */ -public class ServerBean implements Server -{ - /** Logger */ - private static final CLogger log = CLogger.getCLogger(ServerBean.class); - // - /** - * Post Immediate - * - * @param ctx Client Context - * @param AD_Client_ID Client ID of Document - * @param AD_Table_ID Table ID of Document - * @param Record_ID Record ID of this document - * @param force force posting - * @return null, if success or error message - */ - public String postImmediate (Properties ctx, - int AD_Client_ID, int AD_Table_ID, int Record_ID, boolean force) - { - if (log.isLoggable(Level.INFO)) log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID); - - MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID); - return Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, null); - } // postImmediate - - /************************************************************************* - * Process Remote - * - * @param ctx Context - * @param pi Process Info - * @return resulting Process Info - */ - public ProcessInfo process (Properties ctx, ProcessInfo pi) - { - // Start Process - ProcessUtil.startJavaProcess(ctx, pi, null); - return pi; - } // process - - - /************************************************************************* - * Run Workflow (and wait) on Server - * - * @param ctx Context - * @param pi Process Info - * @param AD_Workflow_ID id - * @return process info - */ - public ProcessInfo workflow (Properties ctx, ProcessInfo pi, int AD_Workflow_ID) - { - if (log.isLoggable(Level.INFO)) log.info ("AD_Workflow_ID=" + AD_Workflow_ID); - ProcessUtil.startWorkFlow(ctx, pi, AD_Workflow_ID); - return pi; - } // workflow - - /** - * Execute task on server - * @param ctx Context - * @param AD_Task_ID task - * @return execution trace - */ - public String executeTask (Properties ctx, int AD_Task_ID) - { - MTask task = new MTask (Env.getCtx(), AD_Task_ID, null); // Server Context - return task.execute(); - } // executeTask - - - /** - * Cash Reset - * @param ctx Context - * @param tableName table name - * @param Record_ID record or 0 for all - * @return number of records reset - */ - public int cacheReset (Properties ctx, String tableName, int Record_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config(tableName + " - " + Record_ID); - return CacheMgt.get().reset(tableName, Record_ID); - } // cacheReset - - /** - * Execute db proces on server - * @param ctx Context - * @param processInfo - * @param procedureName - * @return ProcessInfo - */ - public ProcessInfo dbProcess(Properties ctx, ProcessInfo processInfo, String procedureName) - { - ProcessUtil.startDatabaseProcedure(processInfo, procedureName, null); - return processInfo; - } - - @Override - public String sendEMail(Properties ctx, EMail email) { - return email.send(); - } -} // ServerBean diff --git a/org.adempiere.base/src/org/compiere/interfaces/impl/StatusBean.java b/org.adempiere.base/src/org/compiere/interfaces/impl/StatusBean.java deleted file mode 100644 index d818bba72e..0000000000 --- a/org.adempiere.base/src/org/compiere/interfaces/impl/StatusBean.java +++ /dev/null @@ -1,142 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.interfaces.impl; - -import org.compiere.Adempiere; -import org.compiere.db.CConnection; -import org.compiere.interfaces.Status; -import org.compiere.util.CLogger; - - -/** - * Adempiere Status Bean - * - * @author Jorg Janke - * @version $Id: StatusBean.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $ - */ -public class StatusBean implements Status -{ - private static final String ALLOW_CLIENT_QUERY_DB_PWD = "adempiere.client.getDBPwd"; - - /** Logging */ - @SuppressWarnings("unused") - private static final CLogger log = CLogger.getCLogger(StatusBean.class); - - /** - * Get Version (Date) - * @return version e.g. 2002-09-02 - */ - public String getDateVersion() - { - return Adempiere.DATE_VERSION; - } // getDateVersion - - /** - * Get Main Version - * @return main version - e.g. Version 2.4.3b - */ - public String getMainVersion() - { - return Adempiere.MAIN_VERSION; - } // getMainVersion - - /** - * Get Database Type - * @return Database Type - */ - public String getDbType() - { - return CConnection.get().getType(); - } // getDbType - - /** - * Get Database Host - * @return Database Host Name - */ - public String getDbHost() - { - return CConnection.get().getDbHost(); - } // getDbHost - - /** - * Get Database Port - * @return Database Port - */ - public int getDbPort() - { - return CConnection.get().getDbPort(); - } // getDbPort - - /** - * Get Database SID - * @return Database SID - */ - public String getDbName() - { - return CConnection.get().getDbName(); - } // getDbSID - - /** - * Get Database URL - * @return Database URL - */ - public String getConnectionURL() - { - return CConnection.get().getConnectionURL(); - } // getConnectionURL - - /** - * Get Database UID - * @return Database User Name - */ - public String getDbUid() - { - return CConnection.get().getDbUid(); - } // getDbUID - - /** - * Get Database PWD - * @return Database User Password - */ - public String getDbPwd() - { - String f = System.getProperty(ALLOW_CLIENT_QUERY_DB_PWD); - if ("false".equalsIgnoreCase(f)) - return ""; - - return CConnection.get().getDbPwd(); - } // getDbPWD - - /** - * Get Connection Manager Host - * @return Connection Manager Host - */ - public String getFwHost() - { - return CConnection.get().getFwHost(); - } // getCMHost - - /** - * Get Connection Manager Port - * @return Connection Manager Port - */ - public int getFwPort() - { - return CConnection.get().getFwPort(); - } // getCMPort - -} // StatusBean diff --git a/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java b/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java index 8b5f6399e3..b37911f0af 100644 --- a/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java +++ b/org.adempiere.base/src/org/compiere/process/ServerProcessCtl.java @@ -1,13 +1,9 @@ package org.compiere.process; -import java.io.InvalidClassException; -import java.lang.reflect.UndeclaredThrowableException; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.logging.Level; import org.adempiere.util.ProcessUtil; -import org.compiere.db.CConnection; -import org.compiere.interfaces.Server; import org.compiere.model.MPInstance; import org.compiere.model.MRule; import org.compiere.print.ServerReportCtl; @@ -27,7 +23,6 @@ public class ServerProcessCtl implements Runnable { /** Process Info */ ProcessInfo m_pi; private Trx m_trx; - private boolean m_IsServerProcess = false; /************************************************************************** * Constructor @@ -140,7 +135,7 @@ public class ServerProcessCtl implements Runnable { String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," // 9 - + " p.IsServerProcess, p.JasperReport, p.AD_Process_UU " // 10..12 + + " p.JasperReport, p.AD_Process_UU " // 10..11 + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + "WHERE p.IsActive='Y'" @@ -149,7 +144,7 @@ public class ServerProcessCtl implements Runnable { sql = "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," // 9 - + " p.IsServerProcess, p.JasperReport, p.AD_Process_UU " // 10..12 + + " p.JasperReport, p.AD_Process_UU " // 10..11 + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + " INNER JOIN AD_Process_Trl t ON (p.AD_Process_ID=t.AD_Process_ID" @@ -171,7 +166,7 @@ public class ServerProcessCtl implements Runnable { ProcedureName = rs.getString(2); m_pi.setClassName (rs.getString(3)); m_pi.setAD_Process_ID (rs.getInt(4)); - m_pi.setAD_Process_UU (rs.getString(12)); + m_pi.setAD_Process_UU (rs.getString(11)); // Report if ("Y".equals(rs.getString(5))) { @@ -185,8 +180,7 @@ public class ServerProcessCtl implements Runnable { { m_pi.setEstSeconds (estimate + 1); // admin overhead } - m_IsServerProcess = "Y".equals(rs.getString(10)); - JasperReport = rs.getString(11); + JasperReport = rs.getString(10); } else log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID()); @@ -308,32 +302,10 @@ public class ServerProcessCtl implements Runnable { { if (log.isLoggable(Level.FINE)) log.fine(AD_Workflow_ID + " - " + m_pi); boolean started = false; - if (m_IsServerProcess) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - m_pi = server.workflow (Env.getRemoteCallCtx(Env.getCtx()), m_pi, AD_Workflow_ID); - if (log.isLoggable(Level.FINEST)) log.finest("server => " + m_pi); - started = true; - } - } - catch (Exception ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - started = false; - } - } - // Run locally - if (!started && !m_IsServerProcess) - { - if (m_trx != null) - m_pi.setTransactionName(m_trx.getTrxName()); - MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), m_pi, AD_Workflow_ID); - started = wfProcess != null; - } + if (m_trx != null) + m_pi.setTransactionName(m_trx.getTrxName()); + MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), m_pi, AD_Workflow_ID); + started = wfProcess != null; return started; } // startWorkflow @@ -349,67 +321,11 @@ public class ServerProcessCtl implements Runnable { protected boolean startProcess () { if (log.isLoggable(Level.FINE)) log.fine(m_pi.toString()); - boolean started = false; - - //hengsin, bug [ 1633995 ] - boolean clientOnly = false; - if (! m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { - try { - Class processClass = Class.forName(m_pi.getClassName()); - if (ClientProcess.class.isAssignableFrom(processClass)) - clientOnly = true; - } catch (Exception e) {} + if (m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { + return ProcessUtil.startScriptProcess(Env.getCtx(), m_pi, m_trx); + } else { + return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx); } - - if (m_IsServerProcess && !clientOnly) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { - // See ServerBean - m_pi = server.process (Env.getRemoteCallCtx(Env.getCtx()), m_pi); - if (log.isLoggable(Level.FINEST)) log.finest("server => " + m_pi); - started = true; - } - } - catch (UndeclaredThrowableException ex) - { - Throwable cause = ex.getCause(); - if (cause != null) - { - if (cause instanceof InvalidClassException) - log.log(Level.SEVERE, "Version Server <> Client: " - + cause.toString() + " - " + m_pi, ex); - else - log.log(Level.SEVERE, "AppsServer error(1b): " - + cause.toString() + " - " + m_pi, ex); - } - else - log.log(Level.SEVERE, " AppsServer error(1) - " - + m_pi, ex); - started = false; - } - catch (Exception ex) - { - Throwable cause = ex.getCause(); - if (cause == null) - cause = ex; - log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause); - started = false; - } - } - // Run locally - if (!started && (!m_IsServerProcess || clientOnly )) - { - if (m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { - return ProcessUtil.startScriptProcess(Env.getCtx(), m_pi, m_trx); - } else { - return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx); - } - } - return !m_pi.isError(); } // startProcess @@ -422,59 +338,7 @@ public class ServerProcessCtl implements Runnable { { // execute on this thread/connection if (log.isLoggable(Level.FINE)) log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")"); - boolean started = false; - if (m_IsServerProcess) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - m_pi = server.dbProcess(Env.getRemoteCallCtx(Env.getCtx()), m_pi, ProcedureName); - if (log.isLoggable(Level.FINEST)) log.finest("server => " + m_pi); - started = true; - } - } - catch (UndeclaredThrowableException ex) - { - Throwable cause = ex.getCause(); - if (cause != null) - { - if (cause instanceof InvalidClassException) - log.log(Level.SEVERE, "Version Server <> Client: " - + cause.toString() + " - " + m_pi, ex); - else - log.log(Level.SEVERE, "AppsServer error(1b): " - + cause.toString() + " - " + m_pi, ex); - } - else - { - log.log(Level.SEVERE, " AppsServer error(1) - " - + m_pi, ex); - cause = ex; - } - m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage()); - m_pi.setError (true); - return false; - } - catch (Exception ex) - { - Throwable cause = ex.getCause(); - if (cause == null) - cause = ex; - log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause); - m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage()); - m_pi.setError (true); - return false; - } - } - - //try locally - if (!started) - { - return ProcessUtil.startDatabaseProcedure(m_pi, ProcedureName, m_trx); - } - return true; + return ProcessUtil.startDatabaseProcedure(m_pi, ProcedureName, m_trx); } // startDBProcess } diff --git a/org.adempiere.plugin.utils/META-INF/MANIFEST.MF b/org.adempiere.plugin.utils/META-INF/MANIFEST.MF index c8cc17c894..218448b61d 100644 --- a/org.adempiere.plugin.utils/META-INF/MANIFEST.MF +++ b/org.adempiere.plugin.utils/META-INF/MANIFEST.MF @@ -40,14 +40,10 @@ Import-Package: org.adempiere.base, org.apache.xerces.xs;version="2.9.0", org.apache.xerces.xs.datatypes;version="2.9.0", org.apache.xml.serialize;version="2.9.0", - org.compiere, - org.compiere.db, - org.compiere.model, - org.compiere.process, - org.compiere.util, org.osgi.framework;version="1.5.0", org.osgi.util.tracker;version="1.5.0" Export-Package: org.adempiere.plugin.utils Bundle-ClassPath: . Automatic-Module-Name: org.adempiere.plugin.utils Bundle-Vendor: iDempiere Community +Require-Bundle: org.adempiere.base;bundle-version="0.0.0" diff --git a/org.adempiere.ui/src/org/compiere/apps/AbstractProcessCtl.java b/org.adempiere.ui/src/org/compiere/apps/AbstractProcessCtl.java index 9ba960834d..b97f9c1e82 100644 --- a/org.adempiere.ui/src/org/compiere/apps/AbstractProcessCtl.java +++ b/org.adempiere.ui/src/org/compiere/apps/AbstractProcessCtl.java @@ -16,20 +16,15 @@ *****************************************************************************/ package org.compiere.apps; -import java.io.InvalidClassException; -import java.lang.reflect.UndeclaredThrowableException; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.logging.Level; import org.adempiere.util.IProcessUI; import org.adempiere.util.ProcessUtil; -import org.compiere.db.CConnection; -import org.compiere.interfaces.Server; import org.compiere.model.MPInstance; import org.compiere.model.MRule; import org.compiere.print.ReportCtl; -import org.compiere.process.ClientProcess; import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoUtil; import org.compiere.util.CLogger; @@ -79,7 +74,6 @@ public abstract class AbstractProcessCtl implements Runnable /** Process Info */ private ProcessInfo m_pi; private Trx m_trx; - private boolean m_IsServerProcess = false; /** Static Logger */ private static final CLogger log = CLogger.getCLogger (AbstractProcessCtl.class); @@ -128,7 +122,7 @@ public abstract class AbstractProcessCtl implements Runnable String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," // 9 - + " p.IsServerProcess, p.JasperReport, p.AD_Process_UU " // 10..12 + + " p.JasperReport, p.AD_Process_UU " // 10..11 + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + "WHERE p.IsActive='Y'" @@ -137,7 +131,7 @@ public abstract class AbstractProcessCtl implements Runnable sql = "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," // 9 - + " p.IsServerProcess, p.JasperReport, p.AD_Process_UU " // 10..12 + + " p.JasperReport, p.AD_Process_UU " // 10..11 + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + " INNER JOIN AD_Process_Trl t ON (p.AD_Process_ID=t.AD_Process_ID" @@ -160,7 +154,7 @@ public abstract class AbstractProcessCtl implements Runnable ProcedureName = rs.getString(2); m_pi.setClassName (rs.getString(3)); m_pi.setAD_Process_ID (rs.getInt(4)); - m_pi.setAD_Process_UU(rs.getString(12)); + m_pi.setAD_Process_UU(rs.getString(11)); // Report if ("Y".equals(rs.getString(5))) { @@ -178,8 +172,7 @@ public abstract class AbstractProcessCtl implements Runnable m_pi.setEstSeconds (estimate + 1); // admin overhead updateProgressWindowTimerEstimate(m_pi.getEstSeconds()); } - m_IsServerProcess = "Y".equals(rs.getString(10)); - JasperReport = rs.getString(11); + JasperReport = rs.getString(10); } else log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID()); @@ -358,9 +351,10 @@ public abstract class AbstractProcessCtl implements Runnable return getProcessMonitor(); } + @Deprecated protected boolean isServerProcess() { - return m_IsServerProcess; + return false; } /************************************************************************** @@ -373,32 +367,10 @@ public abstract class AbstractProcessCtl implements Runnable { if (log.isLoggable(Level.FINE)) log.fine(AD_Workflow_ID + " - " + m_pi); boolean started = false; - if (m_IsServerProcess) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - m_pi = server.workflow (Env.getRemoteCallCtx(Env.getCtx()), m_pi, AD_Workflow_ID); - if (log.isLoggable(Level.FINEST)) log.finest("server => " + m_pi); - started = true; - } - } - catch (Exception ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - started = false; - } - } - // Run locally - if (!started && !m_IsServerProcess) - { - if (m_trx != null) - m_pi.setTransactionName(m_trx.getTrxName()); - MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), m_pi, AD_Workflow_ID); - started = wfProcess != null; - } + if (m_trx != null) + m_pi.setTransactionName(m_trx.getTrxName()); + MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), m_pi, AD_Workflow_ID); + started = wfProcess != null; return started; } // startWorkflow @@ -414,68 +386,12 @@ public abstract class AbstractProcessCtl implements Runnable private boolean startProcess () { if (log.isLoggable(Level.FINE)) log.fine(m_pi.toString()); - boolean started = false; - - //hengsin, bug [ 1633995 ] - boolean clientOnly = false; - if (! m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { - try { - Class processClass = Class.forName(m_pi.getClassName()); - if (ClientProcess.class.isAssignableFrom(processClass)) - clientOnly = true; - } catch (Exception e) {} + if (m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { + m_pi.setProcessUI(m_processUI); + return ProcessUtil.startScriptProcess(Env.getCtx(), m_pi, m_trx); + } else { + return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx, true, m_processUI); } - - if (m_IsServerProcess && !clientOnly) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { - // See ServerBean - m_pi = server.process (Env.getRemoteCallCtx(Env.getCtx()), m_pi); - if (log.isLoggable(Level.FINEST)) log.finest("server => " + m_pi); - started = true; - } - } - catch (UndeclaredThrowableException ex) - { - Throwable cause = ex.getCause(); - if (cause != null) - { - if (cause instanceof InvalidClassException) - log.log(Level.SEVERE, "Version Server <> Client: " - + cause.toString() + " - " + m_pi, ex); - else - log.log(Level.SEVERE, "AppsServer error(1b): " - + cause.toString() + " - " + m_pi, ex); - } - else - log.log(Level.SEVERE, " AppsServer error(1) - " - + m_pi, ex); - started = false; - } - catch (Exception ex) - { - Throwable cause = ex.getCause(); - if (cause == null) - cause = ex; - log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause); - started = false; - } - } - // Run locally - if (!started && (!m_IsServerProcess || clientOnly )) - { - if (m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { - m_pi.setProcessUI(m_processUI); - return ProcessUtil.startScriptProcess(Env.getCtx(), m_pi, m_trx); - } else { - return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx, true, m_processUI); - } - } - return !m_pi.isError(); } // startProcess @@ -488,60 +404,7 @@ public abstract class AbstractProcessCtl implements Runnable { // execute on this thread/connection if (log.isLoggable(Level.FINE)) log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")"); - boolean started = false; - if (m_IsServerProcess) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - m_pi = server.dbProcess(Env.getRemoteCallCtx(Env.getCtx()), m_pi, ProcedureName); - if (log.isLoggable(Level.FINEST)) log.finest("server => " + m_pi); - started = true; - } - } - catch (UndeclaredThrowableException ex) - { - Throwable cause = ex.getCause(); - if (cause != null) - { - if (cause instanceof InvalidClassException) - log.log(Level.SEVERE, "Version Server <> Client: " - + cause.toString() + " - " + m_pi, ex); - else - log.log(Level.SEVERE, "AppsServer error(1b): " - + cause.toString() + " - " + m_pi, ex); - } - else - { - log.log(Level.SEVERE, " AppsServer error(1) - " - + m_pi, ex); - cause = ex; - } - m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage()); - m_pi.setError (true); - return false; - } - catch (Exception ex) - { - Throwable cause = ex.getCause(); - if (cause == null) - cause = ex; - log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause); - m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage()); - m_pi.setError (true); - return false; - } - } - - //try locally - if (!started) - { - return ProcessUtil.startDatabaseProcedure(m_pi, ProcedureName, m_trx); - } - // if (log.isLoggable(Level.FINE)) log.fine(Log.l4_Data, "ProcessCtl.startProcess - done"); - return true; + return ProcessUtil.startDatabaseProcedure(m_pi, ProcedureName, m_trx); } // startDBProcess