diff --git a/.classpath b/.classpath index 345de5c026..bdac6b7b27 100644 --- a/.classpath +++ b/.classpath @@ -1,57 +1,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/base/src/org/compiere/model/MCash.java b/base/src/org/compiere/model/MCash.java index 9522829642..5d7b7de659 100644 --- a/base/src/org/compiere/model/MCash.java +++ b/base/src/org/compiere/model/MCash.java @@ -46,13 +46,25 @@ public class MCash extends X_C_Cash implements DocAction { MCash retValue = null; // Existing Journal - String sql = "SELECT * FROM C_Cash c " + String sql; + if(DB.isFyracle()){ + sql = "SELECT * FROM C_Cash c " + + "WHERE c.AD_Org_ID=?" // #1 + //FYRACLE PATCH + + " AND cast(c.StatementDate as date)=?" // #2 + + " AND c.Processed='N'" + + " AND EXISTS (SELECT * FROM C_CashBook cb " + + "WHERE c.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=c.AD_Org_ID" + + " AND cb.C_Currency_ID=?)"; // #3 + }else{ + sql = "SELECT * FROM C_Cash c " + "WHERE c.AD_Org_ID=?" // #1 + " AND TRUNC(c.StatementDate)=?" // #2 + " AND c.Processed='N'" + " AND EXISTS (SELECT * FROM C_CashBook cb " + "WHERE c.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=c.AD_Org_ID" + " AND cb.C_Currency_ID=?)"; // #3 + } PreparedStatement pstmt = null; try { diff --git a/base/src/org/compiere/model/MCashLine.java b/base/src/org/compiere/model/MCashLine.java index 76675f6306..edaa3f10b9 100644 --- a/base/src/org/compiere/model/MCashLine.java +++ b/base/src/org/compiere/model/MCashLine.java @@ -366,7 +366,8 @@ public class MCashLine extends X_C_CashLine { String sql = "UPDATE C_Cash c" + " SET StatementDifference=" - + "(SELECT COALESCE(SUM(currencyConvert(cl.Amount, cl.C_Currency_ID, cb.C_Currency_ID, c.DateAcct, null, c.AD_Client_ID, c.AD_Org_ID)),0) " + //FYRACLE replace null with 0 there is no difference with this + + "(SELECT COALESCE(SUM(currencyConvert(cl.Amount, cl.C_Currency_ID, cb.C_Currency_ID, c.DateAcct, 0, c.AD_Client_ID, c.AD_Org_ID)),0) " + "FROM C_CashLine cl, C_CashBook cb " + "WHERE cb.C_CashBook_ID=c.C_CashBook_ID" + " AND cl.C_Cash_ID=c.C_Cash_ID) " diff --git a/base/src/org/compiere/report/FinBalance.java b/base/src/org/compiere/report/FinBalance.java index ecbdac7c43..fdbaa13e08 100644 --- a/base/src/org/compiere/report/FinBalance.java +++ b/base/src/org/compiere/report/FinBalance.java @@ -141,7 +141,7 @@ public class FinBalance extends SvrProcess + " C_Project_ID, AD_OrgTrx_ID, C_SalesRegion_ID, C_Activity_ID," + " C_Campaign_ID, C_LocTo_ID, C_LocFrom_ID, User1_ID, User2_ID, GL_Budget_ID) " + "WHERE C_AcctSchema_ID=" + C_AcctSchema_ID - + " AND EXISTS (SELECT * FROM Fact_Acct a " + + " AND EXISTS (SELECT 1 FROM Fact_Acct a " + "WHERE a.AD_Client_ID=ab.AD_Client_ID AND a.AD_Org_ID=ab.AD_Org_ID" + " AND a.C_AcctSchema_ID=ab.C_AcctSchema_ID AND TRUNC(a.DateAcct)=TRUNC(ab.DateAcct)" + " AND a.Account_ID=ab.Account_ID AND a.PostingType=ab.PostingType" @@ -165,7 +165,7 @@ public class FinBalance extends SvrProcess } /** Insert **/ - sql = "INSERT INTO Fact_Acct_Balance ab " + sql = "INSERT INTO Fact_Acct_Balance " + "(AD_Client_ID, AD_Org_ID, C_AcctSchema_ID, DateAcct," + " Account_ID, PostingType, M_Product_ID, C_BPartner_ID," + " C_Project_ID, AD_OrgTrx_ID, C_SalesRegion_ID,C_Activity_ID," @@ -180,7 +180,7 @@ public class FinBalance extends SvrProcess + "FROM Fact_Acct a " + "WHERE C_AcctSchema_ID=" + C_AcctSchema_ID; if (!deleteFirst) - sql += " AND NOT EXISTS (SELECT * " + sql += " AND NOT EXISTS (SELECT 1 " + "FROM Fact_Acct_Balance x " + "WHERE a.AD_Client_ID=x.AD_Client_ID AND a.AD_Org_ID=x.AD_Org_ID" + " AND a.C_AcctSchema_ID=x.C_AcctSchema_ID AND TRUNC(a.DateAcct)=TRUNC(x.DateAcct)" diff --git a/client/src/org/compiere/acct/AcctViewerData.java b/client/src/org/compiere/acct/AcctViewerData.java index 1ecc0a7010..a910fae6d9 100644 --- a/client/src/org/compiere/acct/AcctViewerData.java +++ b/client/src/org/compiere/acct/AcctViewerData.java @@ -438,7 +438,7 @@ class AcctViewerData rm.addColumn(new RColumn(ctx, "Description", DisplayType.String)); } if (PostingType == null || PostingType.length() == 0) - rm.addColumn(new RColumn(ctx, "PostingType", DisplayType.List, + rm.addColumn(new RColumn(ctx, RModel.TABLE_ALIAS+".PostingType", DisplayType.List, MFactAcct.POSTINGTYPE_AD_Reference_ID)); return rm; } // createRModel diff --git a/client/src/org/compiere/install/Translation.java b/client/src/org/compiere/install/Translation.java index 5fefd7a009..e6897c443b 100644 --- a/client/src/org/compiere/install/Translation.java +++ b/client/src/org/compiere/install/Translation.java @@ -50,7 +50,8 @@ public class Translation /** DTD */ public static final String DTD = ""; /** XML Element Tag */ - public static final String XML_TAG = "compiereTrl"; + public static final String XML_TAG = "adempiereTrl"; + public static final String XML_TAG2 = "compiereTrl"; /** XML Attribute Table */ public static final String XML_ATTRIBUTE_TABLE = "table"; /** XML Attribute Language */ diff --git a/client/src/org/compiere/install/TranslationHandler.java b/client/src/org/compiere/install/TranslationHandler.java index 340e3cb001..b1b17c88ee 100644 --- a/client/src/org/compiere/install/TranslationHandler.java +++ b/client/src/org/compiere/install/TranslationHandler.java @@ -78,7 +78,7 @@ public class TranslationHandler extends DefaultHandler throws org.xml.sax.SAXException { // log.fine( "TranslationHandler.startElement", qName); // + " - " + uri + " - " + localName); - if (qName.equals(Translation.XML_TAG)) + if (qName.equals(Translation.XML_TAG)||qName.equals(Translation.XML_TAG2)) { m_AD_Language = attributes.getValue(Translation.XML_ATTRIBUTE_LANGUAGE); m_isBaseLanguage = Language.isBaseLanguage(m_AD_Language); @@ -132,7 +132,7 @@ public class TranslationHandler extends DefaultHandler throws SAXException { // Log.trace(Log.l6_Database+1, "TranslationHandler.endElement", qName); - if (qName.equals(Translation.XML_TAG)) + if (qName.equals(Translation.XML_TAG)||qName.equals(Translation.XML_TAG2)) { } else if (qName.equals(Translation.XML_ROW_TAG)) diff --git a/dbPort/build.xml b/dbPort/build.xml index 94d9954118..e0ef368cc3 100644 --- a/dbPort/build.xml +++ b/dbPort/build.xml @@ -15,10 +15,10 @@ - - - - + + + + @@ -28,11 +28,12 @@ + - + @@ -42,61 +43,61 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + deprecation="on" debug="on" encoding="${env.ENCODING}"> + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/dbPort/src/org/compiere/db/CConnection.java b/dbPort/src/org/compiere/db/CConnection.java index 5ab8cb36da..732815ec2b 100644 --- a/dbPort/src/org/compiere/db/CConnection.java +++ b/dbPort/src/org/compiere/db/CConnection.java @@ -822,6 +822,11 @@ public class CConnection implements Serializable setDbPort (DB_PostgreSQL.DEFAULT_PORT); } //end vpj-cd e-evolution 09 ene 2006 + if (isFyracle()) + { + if (getDbPort () != DB_Fyracle.DEFAULT_PORT) + setDbPort (DB_Fyracle.DEFAULT_PORT); + } } // setType /** @@ -888,7 +893,15 @@ public class CConnection implements Serializable return Database.DB_POSTGRESQL.equals (m_type); } // isPostgreSQL //end - + /** + * Is PostgreSQL DB + * @return true if PostgreSQL + */ + public boolean isFyracle () + { + return Database.DB_FYRACLE.equals (m_type); + } // isPostgreSQL + //end /** * Is Database Connection OK * @return true if database connection is OK diff --git a/dbPort/src/org/compiere/db/DB_Fyracle.java b/dbPort/src/org/compiere/db/DB_Fyracle.java new file mode 100644 index 0000000000..829e54181b --- /dev/null +++ b/dbPort/src/org/compiere/db/DB_Fyracle.java @@ -0,0 +1,522 @@ +/****************************************************************************** + * The contents of this file are subject to the Compiere License Version 1.1 + * ("License"); You may not use this file except in compliance with the License + * You may obtain a copy of the License at http://www.compiere.org/license.html + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * The Original Code is Compiere ERP & CRM Business Solution + * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc. + * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts + * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved. + * Contributor(s): ______________________________________. + *****************************************************************************/ +package org.compiere.db; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.logging.Level; + +import javax.sql.DataSource; + +import org.compiere.dbPort.Convert; +import org.compiere.dbPort.Convert_Oracle; +import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; +import org.compiere.util.Language; +import org.firebirdsql.pool.FBWrappingDataSource; + +/** + * Firebird Database Port + * + * @author Paul Ruizendaal + * @author Marek Mosiewicz http://www.jotel.com.pl (port to Compiere 2.5.1g) + * @version $Id: DB_Firebird.java,v 1.13 2003/08/16 19:09:21 pnr Exp $ + */ +public class DB_Fyracle implements AdempiereDatabase { + /** Statement Cache */ + private static final int MAX_STATEMENTS = 20; + + /** + * Firebird Database + */ + public DB_Fyracle() { + } // DB_Firebird + + /** Driver */ + private org.firebirdsql.jdbc.FBDriver s_driver = null; + + /** Default Port */ + public static final int DEFAULT_PORT = 3050; + + + /** Connection String */ + private String m_connection; + + private FBWrappingDataSource m_ds; + + private static CLogger log = CLogger.getCLogger (DB_Fyracle.class); + private Convert m_convert = new Convert_Oracle(); + + private String m_userName; + + private String m_connectionURL; + + + /** + * Get Database Name + * + * @return database short name + */ + public String getName() { + return Database.DB_FYRACLE; + } // getName + + /** + * Get Database Description + * + * @return database long name and version + */ + public String getDescription() { + return s_driver.toString(); + } // getDescription + + /** + * Get Standard JDBC Port + * + * @return standard port + */ + public int getStandardPort() { + return DEFAULT_PORT; + } // getStandardPort + + /** + * Get Database Driver + * + * @return Driver + */ + public java.sql.Driver getDriver() { + if (s_driver == null) + s_driver = new org.firebirdsql.jdbc.FBDriver(); + return s_driver; + } // getDriver + + /** + * Get Database Connection String. Requirements: - createdb -E UNICODE + * compiere + * + * @param connection + * Connection Descriptor + * @return connection String + */ + public String getConnectionURL(CConnection connection) { + StringBuffer sb = new StringBuffer("jdbc:firebirdsql:oracle:"); + sb.append(connection.getDbHost()).append("/").append( + connection.getDbPort()).append(":").append( + connection.getDbName()); + m_connection = sb.toString(); + m_userName = connection.getDbUid(); + return m_connection; + } // getConnectionString + /** + * Get Connection URL. + * http://download-east.oracle.com/docs/cd/B14117_01/java.101/b10979/urls.htm#BEIDBFDF + * @param dbHost db Host + * @param dbPort db Port + * @param dbName db Name + * @param userName user name + * @return connection + */ + public String getConnectionURL (String dbHost, int dbPort, String dbName, + String userName) + { + StringBuffer sb = new StringBuffer("jdbc:firebirdsql:oracle:"); + sb.append(dbHost).append("/").append( + dbPort).append(":").append( + dbName); + m_connection = sb.toString(); + m_userName = userName; + return m_connection; + } // getConnectionURL + + /** + * Supports BLOB + * + * @return true if BLOB is supported + */ + public boolean supportsBLOB() { + return true; + } // supportsBLOB + + /** + * String Representation + * + * @return info + */ + public String toString() { + StringBuffer sb = new StringBuffer("DB_Firebird["); + sb.append(m_connection).append("]"); + return sb.toString(); + } // toString + + /** ********************************************************************** */ + + /** + * Convert an individual Oracle Style statements to target database + * statement syntax + * + * @param oraStatement + * @return converted Statement + * @throws Exception + */ + public String convertStatement(String oraStatement) { + return oraStatement; + } // convertStatement + + /** ********************************************************************** */ + + /** + * Set the RowID + * + * @param pstmt + * @param pos + * @param rowID + * @throws SQLException + */ + public void setRowID(PreparedStatement pstmt, int pos, Object rowID) + throws SQLException { + pstmt.setString(pos, (String) rowID); + } // setRowID + + /** + * Get the RowID + * + * @param rs + * @param pos + * @return rowID + * @throws SQLException + */ + public Object getRowID(java.sql.ResultSet rs, int pos) throws SQLException { + return rs.getString(pos); + } // getRowID + + + /* + * (non-Javadoc) + * + * @see org.compiere.db.CompiereDatabase#getCachedConnection(org.compiere.db.CConnection, + * boolean, int) + */ + public Connection getCachedConnection(CConnection connection, + boolean autoCommit, int transactionIsolation) throws Exception { + if (m_ds == null) + getDataSource(connection); + Connection conn = null; + conn = m_ds.getConnection(); + if (conn != null) { + if (conn.getTransactionIsolation() != transactionIsolation) + conn.setTransactionIsolation(transactionIsolation); + if (conn.getAutoCommit() != autoCommit) + conn.setAutoCommit(autoCommit); + } else { + throw new RuntimeException("Cann't connect to database"); + } + return conn; + } + /** + * Get JDBC Schema + * @return user name + */ + public String getSchema() + { + if (m_userName != null) + return m_userName.toUpperCase(); + log.severe("User Name not set (yet) - call getConnectionURL first"); + return null; + } // getSchema + /** + * Get Driver Connection + * @param dbUrl URL + * @param dbUid user + * @param dbPwd password + * @return connection + * @throws SQLException + */ + public Connection getDriverConnection (String dbUrl, String dbUid, String dbPwd) + throws SQLException + { + getDriver(); + return DriverManager.getConnection (dbUrl, dbUid, dbPwd); + } // getDriverConnection + /** + * Get Connection from Driver + * @param connection info + * @return connection or null + */ + public Connection getDriverConnection (CConnection connection) throws SQLException + { + getDriver(); + return DriverManager.getConnection (getConnectionURL (connection), + connection.getDbUid(), connection.getDbPwd()); + } // getDriverConnection + + /* + * (non-Javadoc) + * + * @see org.compiere.db.CompiereDatabase#getDataSource(org.compiere.db.CConnection) + */ + public DataSource getDataSource(CConnection connection) { + if (m_ds != null) + return m_ds; + try { + m_ds = new FBWrappingDataSource(); + StringBuffer db = new StringBuffer().append(connection.getDbHost()).append("/").append( + connection.getDbPort()).append(":").append( + connection.getDbName()); + + m_ds.setDatabase(db.toString()); + m_ds.setUserName(connection.getDbUid()); + m_ds.setPassword(connection.getDbPwd()); + m_ds.setDescription("Compiere DS"); + + m_ds.setType("ORACLE_MODE"); + + m_ds.setLoginTimeout(10); + m_ds.setMaxStatements(MAX_STATEMENTS); + + + return m_ds; + + } catch (Exception e) { + log.log(Level.SEVERE, toString(), e); + //throw new RuntimeException(e); + } + return null; + + } + + /* + * (non-Javadoc) + * + * @see org.compiere.db.CompiereDatabase#getStatus() + */ + public String getStatus() { + // TODO Auto-generated method stub + return null; + } + + /* + * (non-Javadoc) + * + * @see org.compiere.db.CompiereDatabase#close() + */ + public void close() { + m_ds=null; + } + + public static void main(String[] a) { + try { + FBWrappingDataSource m_ds = new FBWrappingDataSource(); + m_ds + .setDatabase("localhost/3050:c:/devspace/apps/fyracle/data/compiere.fdb"); + + m_ds.setUserName("sysdba"); + m_ds.setPassword("masterkey"); + m_ds.setDescription("Compiere DS"); + + m_ds.setLoginTimeout(10); + // + m_ds.setMaxStatements(MAX_STATEMENTS); + // + m_ds.setType("ORACLE_MODE"); + Connection c = null; + c = m_ds.getConnection(); + c.createStatement().executeQuery("SELECT * FROM ad_CLIENT WHERE created>TO_DATE('2001-01-01')"); + + new DB_Fyracle().getDriver(); + c = DriverManager.getConnection ("jdbc:firebirdsql:oracle:localhost/3050:c:/devspace/apps/fyracle/data/compiere.fdb", "SYSDBA", "masterkey"); + + + c.createStatement().executeQuery("SELECT * FROM ad_CLIENT WHERE created>TO_DATE('2001-01-01')"); + } catch (SQLException e) { + throw new RuntimeException(e); + } + + } + /** + * Get JDBC Catalog + * @return null - not used + */ + public String getCatalog() + { + return null; + } // getCatalog + /** + * Get SQL Commands. + * The following variables are resolved: + * @SystemPassword@, @CompiereUser@, @CompierePassword@ + * @SystemPassword@, @DatabaseName@, @DatabaseDevice@ + * @param cmdType CMD_* + * @return array of commands to be executed + */ + public String[] getCommands (int cmdType) + { + if (CMD_CREATE_USER == cmdType) + return new String[] + { + + }; + // + if (CMD_CREATE_DATABASE == cmdType) + return new String[] + { + + }; + // + if (CMD_DROP_DATABASE == cmdType) + return new String[] + { + + }; + // + return null; + } // getCommands + /** + * Create SQL TO Date String from Timestamp + * + * @param time Date to be converted + * @param dayOnly true if time set to 00:00:00 + * + * @return TO_DATE('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS') + * or TO_DATE('2001-01-30',''YYYY-MM-DD') + */ + public String TO_DATE (Timestamp time, boolean dayOnly) + { + if (time == null) + { + if (dayOnly) + return "TRUNC(SysDate)"; + return "SysDate"; + } + + StringBuffer dateString = new StringBuffer("TO_DATE('"); + // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format + String myDate = time.toString(); + if (dayOnly) + { + dateString.append(myDate.substring(0,10)); + dateString.append("','YYYY-MM-DD')"); + } + else + { + dateString.append(myDate.substring(0, myDate.indexOf("."))); // cut off miliseconds + dateString.append("','YYYY-MM-DD HH24:MI:SS')"); + } + return dateString.toString(); + } // TO_DATE + + /** + * Create SQL for formatted Date, Number + * + * @param columnName the column name in the SQL + * @param displayType Display Type + * @param AD_Language 6 character language setting (from Env.LANG_*) + * + * @return TRIM(TO_CHAR(columnName,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.''')) + * or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language + * @see org.compiere.util.DisplayType + * @see org.compiere.util.Env + * + * */ + public String TO_CHAR (String columnName, int displayType, String AD_Language) + { + StringBuffer retValue = new StringBuffer("TRIM(TO_CHAR("); + retValue.append(columnName); + + // Numbers + if (DisplayType.isNumeric(displayType)) + { + if (displayType == DisplayType.Amount) + retValue.append(",'9G999G990D00'"); + else + retValue.append(",'TM9'"); + // TO_CHAR(GrandTotal,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.''') + if (!Language.isDecimalPoint(AD_Language)) // reversed + retValue.append(",'NLS_NUMERIC_CHARACTERS='',.'''"); + } + else if (DisplayType.isDate(displayType)) + { + retValue.append(",'") + .append(Language.getLanguage(AD_Language).getDBdatePattern()) + .append("'"); + } + retValue.append("))"); + // + return retValue.toString(); + } // TO_CHAR + + /** + * Return number as string for INSERT statements with correct precision + * @param number number + * @param displayType display Type + * @return number as string + */ + public String TO_NUMBER (BigDecimal number, int displayType) + { + if (number == null) + return "NULL"; + return number.toString(); + } // TO_NUMBER + + /** + * Get Name of System User + * @return system + */ + public String getSystemUser() + { + return "sysdba"; + } // getSystemUser + + /** + * Get Name of System Database + * @param databaseName database Name + * @return e.g. master or database Name + */ + public String getSystemDatabase(String databaseName) + { + return databaseName; + } // getSystemDatabase + + public String getAlternativeSQL(int reExNo, String msg, String sql) { + return null; + } + + public String getConnectionURL(String connectionURL, String userName) { + m_userName = userName; + m_connectionURL = connectionURL; + return m_connectionURL; + } + + public String getConstraintType(Connection conn, String tableName, String IXName) { + if (IXName == null || IXName.length()==0) + return "0"; + if (IXName.endsWith("_KEY")) + return "1"+IXName; + else + return "0"; + } + + public Convert getConvert() { + return m_convert; + } + + public boolean isSupported(String sql) { + return true; + } + + +} // DB_Firebird diff --git a/dbPort/src/org/compiere/db/Database.java b/dbPort/src/org/compiere/db/Database.java index 11a98947d8..5cf15eb7ca 100644 --- a/dbPort/src/org/compiere/db/Database.java +++ b/dbPort/src/org/compiere/db/Database.java @@ -42,6 +42,9 @@ public class Database /** Enterprise DB */ //public static String DB_EDB = "EnterpriseDB"; + public static String DB_FYRACLE = "Fyracle(beta)"; + + /** Supported Databases */ public static String[] DB_NAMES = new String[] { DB_ORACLE @@ -49,6 +52,7 @@ public class Database // ,DB_DERBY // ,DB_MSSQLServer ,DB_POSTGRESQL + ,DB_FYRACLE // ,DB_EDB }; @@ -59,6 +63,7 @@ public class Database // ,DB_Derby.class // ,DB_MSSQLServer.class ,DB_PostgreSQL.class + ,DB_Fyracle.class // ,DB_EDB.class }; @@ -105,7 +110,9 @@ public class Database if (url.indexOf("db2") != -1) return new DB_DB2(); if (url.indexOf("postgresql") != -1) - return new DB_DB2(); + return new DB_PostgreSQL(); + if (url.indexOf("firebirdsql") != -1) + return new DB_Fyracle(); log.severe("No Database for " + url); return null; diff --git a/dbPort/src/org/compiere/model/MSequence.java b/dbPort/src/org/compiere/model/MSequence.java index ba70f5b5b5..acde88bca4 100644 --- a/dbPort/src/org/compiere/model/MSequence.java +++ b/dbPort/src/org/compiere/model/MSequence.java @@ -110,7 +110,22 @@ public class MSequence extends X_AD_Sequence { int AD_Sequence_ID = rs.getInt(4); // - if (USE_PROCEDURE) + if (DB.isFyracle()) { + PreparedStatement updateSQL; + int incrementNo = rs.getInt(3); + if (adempiereSys) { + updateSQL = conn + .prepareStatement("UPDATE AD_Sequence SET CurrentNextSys = CurrentNextSys + ? WHERE AD_Sequence_ID = ?"); + retValue = rs.getInt(2); + } else { + updateSQL = conn + .prepareStatement("UPDATE AD_Sequence SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID = ?"); + retValue = rs.getInt(1); + } + updateSQL.setInt(1, incrementNo); + updateSQL.setInt(2, AD_Sequence_ID); + updateSQL.executeUpdate(); + } else if (USE_PROCEDURE) { retValue = nextID(conn, AD_Sequence_ID, adempiereSys); } @@ -303,7 +318,21 @@ public class MSequence extends X_AD_Sequence prefix = rs.getString(4); suffix = rs.getString(5); incrementNo = rs.getInt(3); - + if (DB.isFyracle()) { + PreparedStatement updateSQL; + if (adempiereSys) { + updateSQL = conn + .prepareStatement("UPDATE AD_Sequence SET CurrentNextSys = CurrentNextSys + ? WHERE AD_Sequence_ID = ?"); + next = rs.getInt(2); + } else { + updateSQL = conn + .prepareStatement("UPDATE AD_Sequence SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID = ?"); + next = rs.getInt(1); + } + updateSQL.setInt(1, incrementNo); + updateSQL.setInt(2, AD_Sequence_ID); + updateSQL.executeUpdate(); + } else if (USE_PROCEDURE) { next = nextID(conn, AD_Sequence_ID, adempiereSys); @@ -462,7 +491,21 @@ public class MSequence extends X_AD_Sequence adempiereSys = false; AD_Sequence_ID = rs.getInt(7); - if (USE_PROCEDURE) + if (DB.isFyracle()) { + PreparedStatement updateSQL; + if (adempiereSys) { + updateSQL = conn + .prepareStatement("UPDATE AD_Sequence SET CurrentNextSys = CurrentNextSys + ? WHERE AD_Sequence_ID = ?"); + next = rs.getInt(2); + } else { + updateSQL = conn + .prepareStatement("UPDATE AD_Sequence SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID = ?"); + next = rs.getInt(1); + } + updateSQL.setInt(1, incrementNo); + updateSQL.setInt(2, AD_Sequence_ID); + updateSQL.executeUpdate(); + }else if (USE_PROCEDURE) { next = nextID(conn, AD_Sequence_ID, adempiereSys); } diff --git a/dbPort/src/org/compiere/model/MSystem.java b/dbPort/src/org/compiere/model/MSystem.java index a74a3069de..5bb9ccbe32 100644 --- a/dbPort/src/org/compiere/model/MSystem.java +++ b/dbPort/src/org/compiere/model/MSystem.java @@ -176,12 +176,12 @@ public class MSystem extends X_AD_System if (s == null || recalc) { //jz to avoid data conversion String sql = "SELECT 'C'||(SELECT COUNT(*) FROM AD_Client)" - String sql = "SELECT 'C'||getChars((SELECT COUNT(*) FROM AD_Client))" - + "||'U'||getChars((SELECT COUNT(*) FROM AD_User))" - + "||'B'||getChars((SELECT COUNT(*) FROM C_BPartner))" - + "||'P'||getChars((SELECT COUNT(*) FROM M_Product))" - + "||'I'||getChars((SELECT COUNT(*) FROM C_Invoice))" - + "||'M'||getChars((SELECT COUNT(*) FROM M_Transaction))" + String sql = "SELECT 'C'||(SELECT COUNT(*) FROM AD_Client)" + + "||'U'||(SELECT COUNT(*) FROM AD_User)" + + "||'B'||(SELECT COUNT(*) FROM C_BPartner)" + + "||'P'||(SELECT COUNT(*) FROM M_Product)" + + "||'I'||(SELECT COUNT(*) FROM C_Invoice)" + + "||'M'||(SELECT COUNT(*) FROM M_Transaction)" + " FROM AD_System"; PreparedStatement pstmt = null; try diff --git a/dbPort/src/org/compiere/model/PO.java b/dbPort/src/org/compiere/model/PO.java index e103ef0ebb..8a5796123a 100644 --- a/dbPort/src/org/compiere/model/PO.java +++ b/dbPort/src/org/compiere/model/PO.java @@ -3148,7 +3148,7 @@ public abstract class PO // Object retValue = null; //begin vpj-cd e-Evolution 03/11/2005 PostgreSQL - if(DB.isPostgreSQL()) + if(DB.isPostgreSQL()||DB.isFyracle()) { byte buf[] = (byte[])value; retValue = buf; diff --git a/dbPort/src/org/compiere/util/DB.java b/dbPort/src/org/compiere/util/DB.java index 8cbd647710..2b1b3f7250 100644 --- a/dbPort/src/org/compiere/util/DB.java +++ b/dbPort/src/org/compiere/util/DB.java @@ -558,7 +558,14 @@ public final class DB log.severe("No Database"); return false; } - + public static boolean isFyracle() + { + if (s_cc != null) + return s_cc.isFyracle(); + log.severe("No Database"); + return false; + } // isFyracle + /** * Do we have a Postgre DB ? * @return true if connected to PostgreSQL diff --git a/install/Adempiere/RUN_setup.bat b/install/Adempiere/RUN_setup.bat index 0c9c911e73..1d0a457a95 100644 --- a/install/Adempiere/RUN_setup.bat +++ b/install/Adempiere/RUN_setup.bat @@ -20,7 +20,7 @@ goto START @Echo ======================================= @Echo Starting Setup Dialog ... @Echo ======================================= -@SET CP=lib\CInstall.jar;lib\Adempiere.jar;lib\CCTools.jar;lib\oracle.jar;lib\derby.jar;lib\jboss.jar;lib\postgresql.jar; +@SET CP=lib\CInstall.jar;lib\Adempiere.jar;lib\CCTools.jar;lib\oracle.jar;lib\fyracle.jar;lib\derby.jar;lib\jboss.jar;lib\postgresql.jar; @Rem Trace Level Parameter, e.g. SET ARGS=ALL @SET ARGS=CONFIG diff --git a/install/Adempiere/RUN_setup.sh b/install/Adempiere/RUN_setup.sh index 6ecaee2b15..8044217150 100644 --- a/install/Adempiere/RUN_setup.sh +++ b/install/Adempiere/RUN_setup.sh @@ -18,7 +18,7 @@ fi echo =================================== echo Setup Dialog echo =================================== -CP=lib/CInstall.jar:lib/Adempiere.jar:lib/CCTools.jar:lib/oracle.jar:lib/derby.jar:lib/jboss.jar:lib/postgresql.jar: +CP=lib/CInstall.jar:lib/Adempiere.jar:lib/CCTools.jar:lib/oracle.jar:lib/derby.jar:lib/fyracle.jar:lib/jboss.jar:lib/postgresql.jar: # Trace Level Parameter, e.g. ARGS=ALL ARGS=CONFIG diff --git a/install/Adempiere/build.xml b/install/Adempiere/build.xml index a811bfbd69..b465afefed 100644 --- a/install/Adempiere/build.xml +++ b/install/Adempiere/build.xml @@ -154,7 +154,9 @@ - + + + @@ -205,6 +207,8 @@ + + diff --git a/install/Adempiere/install-fyracle.html b/install/Adempiere/install-fyracle.html new file mode 100644 index 0000000000..50c841792c --- /dev/null +++ b/install/Adempiere/install-fyracle.html @@ -0,0 +1,103 @@ + + + + + + + Adempiere Fyracle installation + + +

Adempiere Fyracle installation

+Welcome to adempiere for Fyracle databse project.
+
+This file contains basic information necessery to install adempiere with +Fyracle database.
+
+To install Adempiere Fyracle following packages are necessery:
+
    +
  1. Sun Java SDK 1.5.0 from http://java.sun.com/j2se/1.5.0/downloads/index.html
  2. +
  3. Fyracle databse from http://www.janus-software.com/runtime_dl.html
  4. +
  5. Adempiere installation
  6. +
+
+Please download version of Java SDK and Fyracle appropriate to your +operating system.
+
+Install Java SDK and Fyracle according to their own manuals. Follwoing +instruction
+will assume that You installed Java in c:\adempiere\jdk folder and +Fyracle in c:\adempiere\fyracle
+folder.
+
+Next uninstall Adempiere.zip into to c:\adempiere\Adempiere directory
+and adempiereData.zip into c:\adempiere\data directory.
+
+Please run c:\adempiere\Adempiere\RUN_setup.bat to setup adempiere server.
+Please fill them with following values:
+
    +
  • Java folder is place where You Java has been installed +(c:\adempiere\jdk)
  • +
  • Adempiere folder is folder of adempiere installation +(c:\adempiere\Adempiere)
  • +
  • Server is name of computer used for application server (can not +be localhost). This name of computer must be available for all clients +of adempiere
  • +
  • Web port and SSL port are ports on which web version of adempiere +will be available (must be not used)
  • +
  • JNP port is application server port and probably should not be +changed
  • +
  • Keystore password is password for adempiere keystore
  • +
  • Choose Fyracle database from combobox.
  • +
  • Database host should be name of computer n which You install +server (not localhost)
  • +
  • Database name is name of data file location. In our exaple it is +c:\adempiere\data\adempiere.fdb
    +
  • +
  • Database port should be set 3050
  • +
  • Database user should be set to SYSDBA
  • +
  • Database password is 'masterkey'
  • +
  • Remainig fields are to setup adempiere email account
  • +
+Press Save button to save changes to configuration.
+
+It is adviced to restart Windows computer in next step as Windows can +not set environment variable
+without it.
+
+You shuold be able to startup adempiere server with +c:\adempiere\Adempiere\utils\RUN_Server2.bat
+Next run client with c:\adempiere\Adempiere\RUN_Adempiere.bat command.
+
+Click connection field. In dialog window set  server name to +computer on which adempiere server is running.
+If server is working information on database connection shuold be +filled with necessery inforation.
+It is necessery to mark checkbox "override" and change database type to +"Fyracle".
+
+Close connection dialog.
+Set adempiere user name to GardenAdmin and password to 'GardenAdmin'.
+Click OK and in second window OK again.
+Now adempiere client should be working.
+
+
+
+If You have any suggestion to this +document please contact us: marek(dot)mosiewicz(at)jotel(dot)com(dot)pl
+
+
For +more information about adempiere +itself see http://www.adempiere.org
+adempiere Fyracle version is maintained and supprted by Jotel sp.j. (see http://www.jotel.com.pl/adempiere)
+
To get inforamtion Fyracle +see http://www.fyracle.org
+
+
+ + diff --git a/install/build.xml b/install/build.xml index 1937b76041..7f72a6be8e 100644 --- a/install/build.xml +++ b/install/build.xml @@ -1,4 +1,4 @@ - + @@ -32,6 +32,10 @@ + + + + diff --git a/install/src/org/compiere/install/ConfigFyracle.java b/install/src/org/compiere/install/ConfigFyracle.java new file mode 100644 index 0000000000..a23eefb920 --- /dev/null +++ b/install/src/org/compiere/install/ConfigFyracle.java @@ -0,0 +1,196 @@ +/****************************************************************************** + * The contents of this file are subject to the Compiere License Version 1.1 + * ("License"); You may not use this file except in compliance with the License + * You may obtain a copy of the License at http://www.compiere.org/license.html + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial + * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke + * are Copyright (C) 1999-2005 Jorg Janke. + * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. + * Contributor(s): ______________________________________. + *****************************************************************************/ +package org.compiere.install; + +import java.net.*; +import java.sql.*; +import org.compiere.db.*; + +/** + * Firebird Fyracle Configuration + * + * @author Marek Mosiewicz + * @version $Id: ConfigSybase.java,v 1.4 2005/03/11 20:30:23 jjanke Exp $ + */ +public class ConfigFyracle extends Config +{ + + /** + * ConfigSybase + * @param data + */ + public ConfigFyracle (ConfigurationData data) + { + super (data); + } // ConfigFirebird + + /** Discoverd TNS */ + private String[] p_discovered = null; + /** Fyracle DB Info */ + private DB_Fyracle p_db = new DB_Fyracle(); + + /** + * Init + */ + public void init() + { + p_data.setDatabasePort(String.valueOf(DB_Fyracle.DEFAULT_PORT)); + } // init + + /** + * Discover Databases. + * To be overwritten by database configs + * @param selected selected database + * @return array of databases + */ + public String[] discoverDatabases(String selected) + { + if (p_discovered != null) + return p_discovered; + p_discovered = new String[]{}; + return p_discovered; + } // discoveredDatabases + + + /************************************************************************** + * Test + * @return error message or null if OK + */ + public String test() + { + // Database Server + String server = p_data.getDatabaseServer(); + boolean pass = server != null && server.length() > 0 + && server.toLowerCase().indexOf("localhost") == -1 + && !server.equals("127.0.0.1"); + String error = "Not correct: DB Server = " + server; + InetAddress databaseServer = null; + try + { + if (pass) + databaseServer = InetAddress.getByName(server); + } + catch (Exception e) + { + error += " - " + e.getMessage(); + pass = false; + } + signalOK(getPanel().okDatabaseServer, "ErrorDatabaseServer", + pass, true, error); + log.info("OK: Database Server = " + databaseServer); + setProperty(ConfigurationData.ADEMPIERE_DB_SERVER, databaseServer.getHostName()); + setProperty(ConfigurationData.ADEMPIERE_DB_TYPE, p_data.getDatabaseType()); + + // Database Port + int databasePort = p_data.getDatabasePort(); + pass = p_data.testPort (databaseServer, databasePort, true); + error = "DB Server Port = " + databasePort; + signalOK(getPanel().okDatabaseServer, "ErrorDatabasePort", + pass, true, error); + if (!pass) + return error; + log.info("OK: Database Port = " + databasePort); + setProperty(ConfigurationData.ADEMPIERE_DB_PORT, String.valueOf(databasePort)); + + + // JDBC Database Info + String databaseName = p_data.getDatabaseName(); // Service Name + String systemPassword = p_data.getDatabaseSystemPassword(); + + String urlSystem = p_db.getConnectionURL(databaseServer.getHostName(), databasePort, + p_db.getSystemDatabase(databaseName), p_db.getSystemUser()); + pass = testJDBC(urlSystem, p_db.getSystemUser(), systemPassword); + error = "Error connecting: " + urlSystem + + " - " + p_db.getSystemUser() + "/" + systemPassword; + signalOK(getPanel().okDatabaseSystem, "ErrorJDBC", + pass, true, error); + if (!pass) + return error; + log.info("OK: System Connection = " + urlSystem); + setProperty(ConfigurationData.ADEMPIERE_DB_SYSTEM, systemPassword); + + + // Database User Info + String databaseUser = p_data.getDatabaseUser(); // UID + String databasePassword = p_data.getDatabasePassword(); // PWD + pass = databasePassword != null && databasePassword.length() > 0; + error = "No Database User Password entered"; + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, true, error); + if (!pass) + return error; + // + String url= p_db.getConnectionURL(databaseServer.getHostName(), databasePort, + databaseName, databaseUser); + // Ignore result as it might not be imported + pass = testJDBC(url, databaseUser, databasePassword); + error = "Database imported? Cannot connect to User: " + databaseUser + "/" + databasePassword; + signalOK(getPanel().okDatabaseUser, "ErrorJDBC", + pass, false, error); + if (pass) + log.info("OK: Database User = " + databaseUser); + else + log.warning(error); + setProperty(ConfigurationData.ADEMPIERE_DB_URL, url); + setProperty(ConfigurationData.ADEMPIERE_DB_NAME, databaseName); + setProperty(ConfigurationData.ADEMPIERE_DB_USER, databaseUser); + setProperty(ConfigurationData.ADEMPIERE_DB_PASSWORD, databasePassword); + + /** + // TNS Name Info + String sqlplus = "sqlplus system/" + systemPassword + "@" + databaseName + + " @utils/oracle/Test.sql"; + log.config(sqlplus); + pass = testSQL(sqlplus); + error = "Error connecting via: " + sqlplus; + signalOK(getPanel().okDatabaseSQL, "ErrorTNS", + pass, true, error); + if (pass) + log.info("OK: Database SQL Connection"); + + // OCI Test + url = "jdbc:oracle:oci8:@" + databaseName; + pass = testJDBC(url, "system", systemPassword); + if (pass) + log.info("OK: Connection = " + url); + else + log.warning("Cannot connect via Net8: " + url); + setProperty(ConfigurationData.COMPIERE_DB_TNS, databaseName); + + **/ + return null; + } // test + + /** + * Test JDBC Connection to Server + * @param url connection string + * @param uid user id + * @param pwd password + * @return true if OK + */ + private boolean testJDBC (String url, String uid, String pwd) + { + try + { + Connection conn = p_db.getDriverConnection(url, uid, pwd); + } + catch (Exception e) + { + log.severe(e.toString()); + return false; + } + return true; + } // testJDBC + +} // ConfigFirebird diff --git a/install/src/org/compiere/install/ConfigurationData.java b/install/src/org/compiere/install/ConfigurationData.java index 4824560053..5751b16bd9 100644 --- a/install/src/org/compiere/install/ConfigurationData.java +++ b/install/src/org/compiere/install/ConfigurationData.java @@ -740,6 +740,8 @@ public class ConfigurationData //begin vpj-cd e-evolution 03/17/2005 PostgreSQL else if (getDatabaseType().equals(DBTYPE_POSTGRESQL)) ccType = Database.DB_POSTGRESQL; + else if (getDatabaseType().equals(DBTYPE_FYRACLE)) + ccType = Database.DB_FYRACLE; //end vpj-cd e-evolution 03/17/2005 PostgreSQL CConnection cc = null; @@ -1138,6 +1140,8 @@ public class ConfigurationData /** PostgreSQL */ private static String DBTYPE_POSTGRESQL = "postgresql"; private static String DBTYPE_EDB = "enterprisedb"; + private static String DBTYPE_FYRACLE = "fyracle"; + // end e-evolution vpj-cd 02/07/2005 PostgreSQL /** Database Types */ @@ -1146,8 +1150,10 @@ public class ConfigurationData DBTYPE_ORACLE, //DBTYPE_DB2, //DBTYPE_MS, + DBTYPE_FYRACLE, //begin e-evolution vpj-cd 02/07/2005 PostgreSQL DBTYPE_POSTGRESQL + }; //end e-evolution vpj-cd 02/07/2005 PostgreSQL @@ -1160,6 +1166,7 @@ public class ConfigurationData //begin e-evolution vpj-cd 02/07/2005 PostgreSQL //null //null, + new ConfigFyracle(this), new ConfigPostgreSQL(this) // new ConfigEDB(this) // end e-evolution vpj-cd 02/07/2005 PostgreSQL diff --git a/serverRoot/src/main/server/org/compiere/acct/Doc_InOut.java b/serverRoot/src/main/server/org/compiere/acct/Doc_InOut.java index 4ca4a7b57a..b30a2870dc 100644 --- a/serverRoot/src/main/server/org/compiere/acct/Doc_InOut.java +++ b/serverRoot/src/main/server/org/compiere/acct/Doc_InOut.java @@ -264,10 +264,11 @@ public class Doc_InOut extends Doc log.fine("M_InOut_ID=" + get_ID()); // Old Model StringBuffer sql = new StringBuffer( + //FYRACLE add pc. everywhere "UPDATE M_Product_Costing pc " + "SET (CostAverageCumQty, CostAverageCumAmt)=" - + "(SELECT CostAverageCumQty - SUM(il.MovementQty)," - + " CostAverageCumAmt - SUM(il.MovementQty*CurrentCostPrice) " + + "(SELECT pc.CostAverageCumQty - SUM(il.MovementQty)," + + " pc.CostAverageCumAmt - SUM(il.MovementQty*pc.CurrentCostPrice) " + "FROM M_InOutLine il " + "WHERE pc.M_Product_ID=il.M_Product_ID" + " AND il.M_InOut_ID=").append(get_ID()).append(") ") diff --git a/serverRoot/src/main/server/org/compiere/acct/Doc_Order.java b/serverRoot/src/main/server/org/compiere/acct/Doc_Order.java index 05f5ec643e..13e728a7a0 100644 --- a/serverRoot/src/main/server/org/compiere/acct/Doc_Order.java +++ b/serverRoot/src/main/server/org/compiere/acct/Doc_Order.java @@ -608,7 +608,8 @@ public class Doc_Order extends Doc + "FROM C_Order o, C_OrderLine ol, C_AcctSchema a " + "WHERE o.C_Order_ID=ol.C_Order_ID" + " AND pc.M_Product_ID=ol.M_Product_ID AND pc.C_AcctSchema_ID=a.C_AcctSchema_ID" - + " AND ROWNUM=1" + //TODO FYRACLE many lines for same product + + (DB.isFyracle()?"":" AND ROWNUM=1") + " AND pc.C_AcctSchema_ID=").append(C_AcctSchema_ID).append(" AND o.C_Order_ID=") .append(get_ID()).append(") ") .append("WHERE EXISTS (SELECT * "