diff --git a/org.adempiere.base/src/org/compiere/MigrateData.java b/org.adempiere.base/src/org/compiere/MigrateData.java deleted file mode 100644 index 8d0db1ecb8..0000000000 --- a/org.adempiere.base/src/org/compiere/MigrateData.java +++ /dev/null @@ -1,129 +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; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Properties; -import java.util.logging.Level; - -import org.compiere.model.MProductDownload; -import org.compiere.print.PrintFormatUtil; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; - -/** - * Migrate Data - * @author Jorg Janke - * @version $Id: MigrateData.java,v 1.3 2006/07/30 00:51:06 jjanke Exp $ - */ -public class MigrateData -{ - /** - * Migrate Data. - * Called from DB.afterMigration - */ - public MigrateData () - { - release252c(); - - // Update existing Print Format - PrintFormatUtil pfu = new PrintFormatUtil (Env.getCtx()); - pfu.addMissingColumns((String)null); - } // MigrateData - - /** Logger */ - private static final CLogger log = CLogger.getCLogger (MigrateData.class); - - /** - * Release 252c - */ - private void release252c() - { - String sql = "SELECT COUNT(*) FROM M_ProductDownload"; - int no = DB.getSQLValue(null, sql); - if (no > 0) - { - if (log.isLoggable(Level.FINER)) log.finer("No Need - Downloads #" + no); - return; - } - // - int count = 0; - sql = "SELECT AD_Client_ID, AD_Org_ID, M_Product_ID, Name, DownloadURL " - + "FROM M_Product " - + "WHERE DownloadURL IS NOT NULL"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - int AD_Client_ID = rs.getInt(1); - int AD_Org_ID = rs.getInt(2); - int M_Product_ID = rs.getInt(3); - String Name = rs.getString(4); - String DownloadURL = rs.getString(5); - // - Properties ctx = new Properties (Env.getCtx()); - Env.setContext(ctx, Env.AD_CLIENT_ID, AD_Client_ID); - Env.setContext(ctx, "AD_Client_ID", AD_Client_ID); - Env.setContext(ctx, Env.AD_ORG_ID, AD_Org_ID); - Env.setContext(ctx, "AD_Org_ID", AD_Org_ID); - MProductDownload pdl = new MProductDownload(ctx, 0, null); - pdl.setM_Product_ID(M_Product_ID); - pdl.setName(Name); - pdl.setDownloadURL(DownloadURL); - if (pdl.save()) - { - count++; - String sqlUpdate = "UPDATE M_Product SET DownloadURL = NULL WHERE M_Product_ID=" + M_Product_ID; - int updated = DB.executeUpdate(sqlUpdate, null); - if (updated != 1) - log.warning("Product not updated"); - } - else - log.warning("Product Download not created M_Product_ID=" + M_Product_ID); - } - } - catch (Exception e) - { - log.log (Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - if (log.isLoggable(Level.INFO)) log.info("#" + count); - } // release252c - - - /** - * Migrate Data - * @param args ignored - */ - public static void main (String[] args) - { - Adempiere.startup(true); - new MigrateData(); - } // main - -} // MigrateData diff --git a/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java b/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java deleted file mode 100644 index 0aa7480f00..0000000000 --- a/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java +++ /dev/null @@ -1,838 +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 java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Properties; -import java.util.logging.Level; - -import org.adempiere.exceptions.DBException; -import org.compiere.Adempiere; -import org.compiere.model.MColumn; -import org.compiere.model.MTable; -import org.compiere.model.M_Element; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Util; - -/** - * Class to Create a new Adempiere Database from a reference DB. - *
- * - Create User - * - Create DDL (table, procedures, functions, etc.) - *- * - * @author Jorg Janke - * @version $Id: CreateAdempiere.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $ - */ -public class CreateAdempiere -{ - /** - * Constructor - * @param databaseType AdempiereDatabase.TYPE_ - * @param databaseHost database host - * @param databasePort database port 0 for default - * @param systemPassword system password - */ - public CreateAdempiere(String databaseType, String databaseHost, int databasePort, - String systemPassword) - { - initDatabase(databaseType); - m_databaseHost = databaseHost; - if (databasePort == 0) - m_databasePort = m_dbTarget.getStandardPort(); - else - m_databasePort = databasePort; - m_systemPassword = systemPassword; - if (log.isLoggable(Level.INFO)) log.info(m_dbTarget.getName() + " on " + databaseHost); - } // create - - /** Adempiere Target Database */ - private AdempiereDatabase m_dbTarget = null; - /** Adempiere Source Database */ - private AdempiereDatabase m_dbSource = null; - // - private String m_databaseHost = null; - private int m_databasePort = 0; - private String m_systemPassword = null; - private String m_adempiereUser = null; - private String m_adempierePassword = null; - private String m_databaseName = null; - private String m_databaseDevice = null; - // - private Properties m_ctx = new Properties (); - /** Cached connection */ - private Connection m_conn = null; - - /** Logger */ - private static final CLogger log = CLogger.getCLogger (CreateAdempiere.class); - - /** - * Create Adempiere Database - * @param databaseType Database.DB_ - */ - private void initDatabase(String databaseType) - { - try - { - m_dbTarget = Database.getDatabase(databaseType); - } - catch (Exception e) - { - log.severe(e.toString ()); - e.printStackTrace(); - } - if (m_dbTarget == null) - throw new IllegalStateException("No database: " + databaseType); - - // Source Database - m_dbSource = DB.getDatabase(); - } // createDatabase - - /** - * Clean Start - drop & re-create DB - */ - public void cleanStart() - { - Connection conn = getConnection(true, true); - if (conn == null) - throw new IllegalStateException("No Database"); - // - dropDatabase(conn); - createUser(conn); - createDatabase(conn); - // - try - { - if (conn != null) - conn.close(); - } - catch (SQLException e2) - { - log.log(Level.SEVERE, "close connection", e2); - } - conn = null; - } // cleanStart - - - /** - * Set Adempiere User - * @param adempiereUser adempiere id - * @param adempierePassword adempiere password - */ - public void setAdempiereUser (String adempiereUser, String adempierePassword) - { - m_adempiereUser = adempiereUser; - m_adempierePassword = adempierePassword; - } // setAdempiereUser - - /** - * Set Database Name - * @param databaseName db name - * @param databaseDevice device or table space - */ - public void setDatabaseName (String databaseName, String databaseDevice) - { - m_databaseName = databaseName; - m_databaseDevice = databaseDevice; - } // createDatabase - - - /** - * Test Connection - * @return connection - */ - public boolean testConnection() - { - String dbUrl = m_dbTarget.getConnectionURL (m_databaseHost, m_databasePort, - m_databaseName, m_dbTarget.getSystemUser()); // adempiere may not be defined yet - if (log.isLoggable(Level.INFO)) log.info(dbUrl + " - " + m_dbTarget.getSystemUser() + "/" + m_systemPassword); - try - { - Connection conn = m_dbTarget.getDriverConnection(dbUrl, m_dbTarget.getSystemUser(), m_systemPassword); - // - JDBCInfo info = new JDBCInfo(conn); - if (CLogMgt.isLevelFinest()) - { - info.listCatalogs(); - info.listSchemas(); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, "test", e); - return false; - } - - return true; - } // testConnection - - - /************************************************************************** - * Create User - * @param sysConn system connection - * @return true if success - */ - public boolean createUser (Connection sysConn) - { - if (log.isLoggable(Level.INFO)) log.info(m_adempiereUser + "/" + m_adempierePassword); - return executeCommands(m_dbTarget.getCommands(AdempiereDatabase.CMD_CREATE_USER), - sysConn, true, false); - } // createUser - - /** - * Create Database (User) - * @param sysConn system connection - * @return true if success - */ - public boolean createDatabase (Connection sysConn) - { - if (log.isLoggable(Level.INFO)) log.info(m_databaseName + "(" + m_databaseDevice + ")"); - return executeCommands(m_dbTarget.getCommands(AdempiereDatabase.CMD_CREATE_DATABASE), - sysConn, true, false); - } // createDatabase - - /** - * Drop Database (User) - * @param sysConn system connection - * @return true if success - */ - public boolean dropDatabase (Connection sysConn) - { - log.info(m_databaseName); - return executeCommands(m_dbTarget.getCommands(AdempiereDatabase.CMD_DROP_DATABASE), - sysConn, true, false); - } // dropDatabase - - - /** - * Create Tables and copy data - * @param whereClause optional where clause - * @param dropFirst drop first - * @return true if executed - */ - public boolean copy (String whereClause, boolean dropFirst) - { - log.info(whereClause); - if (getConnection(false, true) == null) - return false; - // - boolean success = true; - int count = 0; - ArrayList
MRoleTest
contains tests for the class MRole
- * - * @author Jorg Janke - * @version $Id: MRoleTest.java,v 1.2 2006/07/30 00:58:37 jjanke Exp $ - */ -public class MRoleTest extends TestCase -{ - /** - * Construct new test instance - * @param name the test name - */ - public MRoleTest(String name) - { - super(name); - } - - private MRole m_role = null; - - /** - * Perform pre-test initialization - * @throws Exception - * @see TestCase#setUp() - */ - protected void setUp() throws Exception, Exception - { - org.compiere.Adempiere.startupEnvironment(true); - m_role = MRole.getDefault(Env.getCtx(), false); - super.setUp(); - } - - /** - * Perform post-test clean up - * - * @throws Exception - * - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception - { - super.tearDown(); - } - - /** - * Run the String addAccessSQL(String, String, boolean, boolean) method - * test - */ - public void testAddAccessSQL() - { - // add test code here - String sql = m_role.addAccessSQL( - "SELECT r.a,r.b,r.c FROM AD_Role r WHERE EXISTS " - + "(SELECT AD_Column c WHERE c.a=c.b) ORDER BY r.a", - "r", - MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - System.out.println(sql); - assertEquals(sql, "SELECT r.a,r.b,r.c FROM AD_Role r WHERE EXISTS (SELECT AD_Column c WHERE c.a=c.b) AND r.AD_Client_ID=0 AND r.AD_Org_ID=0 ORDER BY r.a"); - } - - - /** - * Launch the test. - * @param args String[] - */ - public static void main(String[] args) - { - junit.textui.TestRunner.run(MRoleTest.class); - } - -} // MRoleTest diff --git a/org.adempiere.base/src/org/compiere/process/RemoteMergeDataVO.java b/org.adempiere.base/src/org/compiere/process/RemoteMergeDataVO.java deleted file mode 100644 index 9efc6370a2..0000000000 --- a/org.adempiere.base/src/org/compiere/process/RemoteMergeDataVO.java +++ /dev/null @@ -1,55 +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 javax.sql.RowSet; - -/** - * Merge New Data To/From Remote - * - * @author Jorg Janke - * @version $Id: RemoteMergeDataVO.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ - */ -public class RemoteMergeDataVO implements Serializable -{ - - /** - * - */ - private static final long serialVersionUID = 4466234572385621657L; - public Boolean Test = Boolean.FALSE; - public String TableName = null; - public String Sql = null; - public String[] KeyColumns = null; - public RowSet CentralData = null; - - /** - * String Representation - * @return info - */ - public String toString() - { - return "RemoteNewDataVO[test=" + Test - + "-" + TableName - // + "," + Sql - + "]"; - } // toString - - -} // RemoteNewDataVO diff --git a/org.adempiere.base/src/org/compiere/process/RemoteSetupVO.java b/org.adempiere.base/src/org/compiere/process/RemoteSetupVO.java deleted file mode 100644 index 0848fe6ddb..0000000000 --- a/org.adempiere.base/src/org/compiere/process/RemoteSetupVO.java +++ /dev/null @@ -1,59 +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 javax.sql.RowSet; - -/** - * Remote Setup VO - * - * @author Jorg Janke - * @version $Id: RemoteSetupVO.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ - */ -public class RemoteSetupVO implements Serializable -{ - - /** - * - */ - private static final long serialVersionUID = 2767440202354732666L; - public Boolean Test = Boolean.FALSE; - public RowSet ReplicationTable = null; - public BigDecimal IDRangeStart = null; - public BigDecimal IDRangeEnd = null; - public int AD_Client_ID = -1; - public int AD_Org_ID = -1; - public String Prefix = null; - public String Suffix = null; - - /** - * String Representation - * @return info - */ - public String toString() - { - return "RemoteSetupVO[test=" + Test - + ",IDRange=" + IDRangeStart + "-" + IDRangeEnd - + ",AD_Client_ID=" + AD_Client_ID + ",AD_Org_ID=" + AD_Org_ID - + ",Prefix=" + Prefix + ",Suffix=" + Suffix - + "]"; - } // toString - -} // RemoteSetupVO diff --git a/org.adempiere.base/src/org/compiere/process/RemoteUpdateVO.java b/org.adempiere.base/src/org/compiere/process/RemoteUpdateVO.java deleted file mode 100644 index 6b4ba3a35c..0000000000 --- a/org.adempiere.base/src/org/compiere/process/RemoteUpdateVO.java +++ /dev/null @@ -1,56 +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 javax.sql.RowSet; - -/** - * Send New Data To Remote for Update - * - * @author Jorg Janke - * @version $Id: RemoteUpdateVO.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ - */ -public class RemoteUpdateVO implements Serializable -{ - - /** - * - */ - private static final long serialVersionUID = -1609568403006050326L; - public Boolean Test = Boolean.FALSE; -// public Integer AD_Table_ID = null; - public String TableName = null; - public String Sql = null; - public String[] KeyColumns = null; - public RowSet CentralData = null; - - /** - * String Representation - * @return info - */ - public String toString() - { - return "RemoteUpdateVO[test=" + Test - + "-" + TableName - // + "," + Sql - + "]"; - } // toString - - -} // RemoteUpdateVO diff --git a/org.adempiere.base/src/org/compiere/tools/RMIUtil.java b/org.adempiere.base/src/org/compiere/tools/RMIUtil.java deleted file mode 100644 index 6958ea0b3b..0000000000 --- a/org.adempiere.base/src/org/compiere/tools/RMIUtil.java +++ /dev/null @@ -1,104 +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.tools; - -import java.rmi.Naming; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; - -/** - * Test/List RMI Registry - * - * @author Jorg Janke - * @version $Id: RMIUtil.java,v 1.3 2006/07/30 00:51:06 jjanke Exp $ - */ -public class RMIUtil -{ - /** - * RMIUtil - */ - public RMIUtil() - { - // testPort(); - try - { - System.out.println("Registry ------------------------------------"); - Registry registry = LocateRegistry.getRegistry(); - System.out.println("- " + registry); - String[] list = registry.list(); - System.out.println("- size=" + list.length); - for (int i = 0; i < list.length; i++) - { - System.out.println("-- " + list[i]); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - try - { - System.out.println("Server --------------------------------------"); - // System.out.println("- " + RemoteServer.getClientHost()); - String[] list = Naming.list ("rmi://localhost:1099"); - System.out.println("- size=" + list.length); - for (int i = 0; i < list.length; i++) - { - System.out.println("-- " + list[i]); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } // RMIUtil - - /*private void testPort() - { - try - { - System.out.println("Test Port -----------------------------------"); - Socket socket = new Socket ("localhost", 1099); - System.out.println("- Socket=" + socket); - // - InputStream in = socket.getInputStream(); - int i = 0; - while (i >= 0) - { - i = in.read(); - if (i >= 0) - System.out.println((char)i); - } - } - catch (IOException ex) - { - ex.printStackTrace(); - } - - }*/ - - /** - * Test - * @param args args - */ - public static void main (String[] args) - { - new RMIUtil(); - } // main - -} // RMIUtil