Adempiere 3.1.2

This commit is contained in:
vpj-cd 2006-12-07 03:21:41 +00:00
parent 6c5fa90281
commit ee46d9e792
24 changed files with 9257 additions and 8777 deletions

View File

@ -42,7 +42,7 @@ public final class Adempiere
/** Timestamp */ /** Timestamp */
static public final String ID = "$Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $"; static public final String ID = "$Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $";
/** Main Version String */ /** Main Version String */
static public final String MAIN_VERSION = "Release 3.1.1"; static public final String MAIN_VERSION = "Release 3.1.2";
/** Detail Version as date Used for Client/Server */ /** Detail Version as date Used for Client/Server */
static public final String DATE_VERSION = "2006-11-02"; static public final String DATE_VERSION = "2006-11-02";
/** Database Version as date Compared with AD_System */ /** Database Version as date Compared with AD_System */
@ -72,7 +72,7 @@ public final class Adempiere
static private String s_supportEmail = ""; static private String s_supportEmail = "";
/** Subtitle */ /** Subtitle */
static public final String SUB_TITLE = "The Open Source Profesional ERP,CRM and SCM "; static public final String SUB_TITLE = "Smart Suite ERP,CRM and SCM ";
/** Adempiere is a wordwide registered Trademark /** Adempiere is a wordwide registered Trademark
* - Don't modify this - Program will someday fail unexpectedly */ * - Don't modify this - Program will someday fail unexpectedly */
static public final String ADEMPIERE_R = "Adempiere\u00AE"; static public final String ADEMPIERE_R = "Adempiere\u00AE";

View File

@ -27,7 +27,7 @@ import org.compiere.interfaces.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Adempiere Connection Descriptor * Compiere Connection Descriptor
* *
* @author Jorg Janke * @author Jorg Janke
* @author Marek Mosiewicz<marek.mosiewicz@jotel.com.pl> - support for RMI over HTTP * @author Marek Mosiewicz<marek.mosiewicz@jotel.com.pl> - support for RMI over HTTP
@ -138,7 +138,7 @@ public class CConnection implements Serializable
/************************************************************************** /**************************************************************************
* Adempiere Connection * Compiere Connection
* @param host optional application/db host * @param host optional application/db host
*/ */
private CConnection (String host) private CConnection (String host)
@ -182,9 +182,9 @@ public class CConnection implements Serializable
private int m_fw_port = 0; private int m_fw_port = 0;
/** DB User name */ /** DB User name */
private String m_db_uid = "adempiere"; private String m_db_uid = "compiere";
/** DB User password */ /** DB User password */
private String m_db_pwd = "adempiere"; private String m_db_pwd = "compiere";
/** Database */ /** Database */
private AdempiereDatabase m_db = null; private AdempiereDatabase m_db = null;
@ -209,9 +209,6 @@ public class CConnection implements Serializable
private Server m_server = null; private Server m_server = null;
/** DB Info */ /** DB Info */
private String m_dbInfo = null; private String m_dbInfo = null;
/** Had application server been query **/
private boolean m_queryAppsServer = false;
/************************************************************************* /*************************************************************************
@ -259,7 +256,6 @@ public class CConnection implements Serializable
m_apps_host = apps_host; m_apps_host = apps_host;
m_name = toString (); m_name = toString ();
m_okApps = false; m_okApps = false;
m_queryAppsServer = false;
} }
/** /**
@ -279,7 +275,6 @@ public class CConnection implements Serializable
{ {
m_apps_port = apps_port; m_apps_port = apps_port;
m_okApps = false; m_okApps = false;
m_queryAppsServer = false;
} }
/** /**
@ -308,11 +303,9 @@ public class CConnection implements Serializable
*/ */
public boolean isAppsServerOK (boolean tryContactAgain) public boolean isAppsServerOK (boolean tryContactAgain)
{ {
if (!tryContactAgain && m_queryAppsServer) if (!tryContactAgain)
return m_okApps; return m_okApps;
m_queryAppsServer = true;
// Get Context // Get Context
if (m_iContext == null) if (m_iContext == null)
{ {
@ -347,9 +340,8 @@ public class CConnection implements Serializable
*/ */
public Exception testAppsServer () public Exception testAppsServer ()
{ {
//if (queryAppsServerInfo ()) if (queryAppsServerInfo ())
// testDatabase (false); testDatabase (false);
queryAppsServerInfo ();
return getAppsServerException (); return getAppsServerException ();
} // testAppsServer } // testAppsServer
@ -809,24 +801,11 @@ public class CConnection implements Serializable
if (getDbPort () != DB_DB2.DEFAULT_PORT) if (getDbPort () != DB_DB2.DEFAULT_PORT)
setDbPort (DB_DB2.DEFAULT_PORT); setDbPort (DB_DB2.DEFAULT_PORT);
} }
else if (isDerby()) /*else if (isDerby())
{ {
// if (getDbPort () != DB_Derby.DEFAULT_PORT) if (getDbPort () != DB_Derby.DEFAULT_PORT)
// setDbPort (DB_Derby.DEFAULT_PORT); setDbPort (DB_Derby.DEFAULT_PORT);
} }*/
// begin vpj-cd e-evolution 09 ene 2006
// PostgreSQL
if (isPostgreSQL ())
{
if (getDbPort () != DB_PostgreSQL.DEFAULT_PORT)
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 } // setType
/** /**
@ -875,16 +854,7 @@ public class CConnection implements Serializable
return Database.DB_MSSQLServer.equals (m_type); return Database.DB_MSSQLServer.equals (m_type);
} // isMSSQLServer } // isMSSQLServer
//begin e-evolution vpj-cd 30 nov 2005 /**
/**
* Is PostgreSQL DB
* @return true if PostgreSQL
*/
// public boolean isEDB ()
// {
// return Database.DB_EDB.equals (m_type);
// } // isPostgreSQL
/**
* Is PostgreSQL DB * Is PostgreSQL DB
* @return true if PostgreSQL * @return true if PostgreSQL
*/ */
@ -902,6 +872,7 @@ public class CConnection implements Serializable
return Database.DB_FYRACLE.equals (m_type); return Database.DB_FYRACLE.equals (m_type);
} // isPostgreSQL } // isPostgreSQL
//end //end
/** /**
* Is Database Connection OK * Is Database Connection OK
* @return true if database connection is OK * @return true if database connection is OK
@ -987,9 +958,18 @@ public class CConnection implements Serializable
Connection.TRANSACTION_READ_COMMITTED); Connection.TRANSACTION_READ_COMMITTED);
if (conn != null) if (conn != null)
{ {
try try
{ {
readInfo(conn); DatabaseMetaData dbmd = conn.getMetaData ();
m_info[0] = "Database=" + dbmd.getDatabaseProductName ()
+ " - " + dbmd.getDatabaseProductVersion ();
m_info[0] = m_info[0].replace ('\n', ' ');
m_info[1] = "Driver =" + dbmd.getDriverName ()
+ " - " + dbmd.getDriverVersion ();
if (isDataSource())
m_info[1] += " - via DataSource";
m_info[1] = m_info[1].replace ('\n', ' ');
log.config(m_info[0] + " - " + m_info[1]);
conn.close (); conn.close ();
} }
catch (Exception e) catch (Exception e)
@ -1000,19 +980,20 @@ public class CConnection implements Serializable
} }
return m_dbException; // from opening return m_dbException; // from opening
} // testDatabase } // testDatabase
public void readInfo(Connection conn) throws SQLException { public void readInfo(Connection conn) throws SQLException {
DatabaseMetaData dbmd = conn.getMetaData (); DatabaseMetaData dbmd = conn.getMetaData ();
m_info[0] = "Database=" + dbmd.getDatabaseProductName () m_info[0] = "Database=" + dbmd.getDatabaseProductName ()
+ " - " + dbmd.getDatabaseProductVersion (); + " - " + dbmd.getDatabaseProductVersion ();
m_info[0] = m_info[0].replace ('\n', ' '); m_info[0] = m_info[0].replace ('\n', ' ');
m_info[1] = "Driver =" + dbmd.getDriverName () m_info[1] = "Driver =" + dbmd.getDriverName ()
+ " - " + dbmd.getDriverVersion (); + " - " + dbmd.getDriverVersion ();
if (isDataSource()) if (isDataSource())
m_info[1] += " - via DataSource"; m_info[1] += " - via DataSource";
m_info[1] = m_info[1].replace ('\n', ' '); m_info[1] = m_info[1].replace ('\n', ' ');
log.config(m_info[0] + " - " + m_info[1]); log.config(m_info[0] + " - " + m_info[1]);
} }
/************************************************************************* /*************************************************************************
* Short String representation * Short String representation
@ -1224,7 +1205,15 @@ public class CConnection implements Serializable
{ {
try try
{ {
m_db = Database.getDatabase(m_type); for (int i = 0; i < Database.DB_NAMES.length; i++)
{
if (Database.DB_NAMES[i].equals (m_type))
{
m_db = (AdempiereDatabase)Database.DB_CLASSES[i].
newInstance ();
break;
}
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -1507,19 +1496,12 @@ public class CConnection implements Serializable
log.finer(getAppsHost()); log.finer(getAppsHost());
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
m_okApps = false; m_okApps = false;
m_queryAppsServer = true;
m_appsException = null; m_appsException = null;
// //
getInitialContext (false); getInitialContext (false);
if (m_iContext == null) if (m_iContext == null)
return m_okApps; // false return m_okApps; // false
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
log.warning (getAppsHost() + " ignored");
return m_okApps; // false
}
// Prevent error trace // Prevent error trace
// CLogMgtLog4J.enable(false); // CLogMgtLog4J.enable(false);
try try
@ -1642,6 +1624,7 @@ public class CConnection implements Serializable
return "<?" + transactionIsolation + "?>"; return "<?" + transactionIsolation + "?>";
} // getTransactionIsolationInfo } // getTransactionIsolationInfo
/************************************************************************** /**************************************************************************
* Testing * Testing
@ -1664,7 +1647,7 @@ public class CConnection implements Serializable
Adempiere.startup(true); Adempiere.startup(true);
// //
System.out.println ("Connection = "); System.out.println ("Connection = ");
// CConnection[name=localhost{dev-dev1-adempiere},AppsHost=localhost,AppsPort=1099,type=Oracle,DBhost=dev,DBport=1521,DBname=dev1,BQ=false,FW=false,FWhost=,FWport=1630,UID=adempiere,PWD=adempiere] // CConnection[name=localhost{dev-dev1-compiere},AppsHost=localhost,AppsPort=1099,type=Oracle,DBhost=dev,DBport=1521,DBname=dev1,BQ=false,FW=false,FWhost=,FWport=1630,UID=compiere,PWD=compiere]
System.out.println (Ini.getProperty (Ini.P_CONNECTION)); System.out.println (Ini.getProperty (Ini.P_CONNECTION));
CConnection cc = CConnection.get (); CConnection cc = CConnection.get ();

View File

@ -3,21 +3,21 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. * * See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us * * 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 * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.db; package org.compiere.db;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import javax.swing.*; import javax.swing.*;
@ -26,23 +26,23 @@ import org.adempiere.plaf.AdempierePLAF;
import org.compiere.plaf.*; import org.compiere.plaf.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Connection Dialog. * Connection Dialog.
* *
* @author Jorg Janke * @author Jorg Janke
* @author Marek Mosiewicz<marek.mosiewicz@jotel.com.pl> - support for RMI over HTTP * @author Marek Mosiewicz<marek.mosiewicz@jotel.com.pl> - support for RMI over HTTP
* @version $Id: CConnectionDialog.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $ * @version $Id: CConnectionDialog.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
*/ */
public class CConnectionDialog extends CDialog implements ActionListener public class CConnectionDialog extends CDialog implements ActionListener
{ {
/** /**
* Connection Dialog using current Connection * Connection Dialog using current Connection
*/ */
public CConnectionDialog() public CConnectionDialog()
{ {
this (null); this (null);
} // CConnectionDialog } // CConnectionDialog
/** /**
* Connection Dialog * Connection Dialog
@ -50,13 +50,13 @@ public class CConnectionDialog extends CDialog implements ActionListener
*/ */
public CConnectionDialog(CConnection cc) public CConnectionDialog(CConnection cc)
{ {
super((Frame)null, true); super((Frame)null, true);
try try
{ {
jbInit(); jbInit();
setConnection (cc); setConnection (cc);
} }
catch(Exception e) catch(Exception e)
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
@ -64,33 +64,33 @@ public class CConnectionDialog extends CDialog implements ActionListener
} // CConnection } // CConnection
/** Resources */ /** Resources */
private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.db.DBRes"); private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.db.DBRes");
static static
{ {
/** Connection Profiles */ /** Connection Profiles */
CConnection.CONNECTIONProfiles = new ValueNamePair[]{ CConnection.CONNECTIONProfiles = new ValueNamePair[]{
new ValueNamePair("L", res.getString("LAN")), new ValueNamePair("L", res.getString("LAN")),
new ValueNamePair("T", res.getString("TerminalServer")), new ValueNamePair("T", res.getString("TerminalServer")),
new ValueNamePair("V", res.getString("VPN")), new ValueNamePair("V", res.getString("VPN")),
new ValueNamePair("W", res.getString("WAN")) new ValueNamePair("W", res.getString("WAN"))
}; };
} }
/** Default HTTP Port */ /** Default HTTP Port */
public static final String APPS_PORT_HTTP = "80"; public static final String APPS_PORT_HTTP = "80";
/** Default RMI Port */ /** Default RMI Port */
public static final String APPS_PORT_JNP = "1099"; public static final String APPS_PORT_JNP = "1099";
/** Connection */ /** Connection */
private CConnection m_cc = null; private CConnection m_cc = null;
private CConnection m_ccResult = null; private CConnection m_ccResult = null;
private boolean m_updating = false; private boolean m_updating = false;
private boolean m_saved = false; private boolean m_saved = false;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger (CConnectionDialog.class); private static CLogger log = CLogger.getCLogger (CConnectionDialog.class);
private CPanel mainPanel = new CPanel(); private CPanel mainPanel = new CPanel();
private BorderLayout mainLayout = new BorderLayout(); private BorderLayout mainLayout = new BorderLayout();
private CPanel centerPanel = new CPanel(); private CPanel centerPanel = new CPanel();
private CPanel southPanel = new CPanel(); private CPanel southPanel = new CPanel();
@ -99,156 +99,156 @@ public class CConnectionDialog extends CDialog implements ActionListener
private FlowLayout southLayout = new FlowLayout(); private FlowLayout southLayout = new FlowLayout();
private GridBagLayout centerLayout = new GridBagLayout(); private GridBagLayout centerLayout = new GridBagLayout();
private CLabel nameLabel = new CLabel(); private CLabel nameLabel = new CLabel();
private CTextField nameField = new CTextField(); private CTextField nameField = new CTextField();
private CLabel hostLabel = new CLabel(); private CLabel hostLabel = new CLabel();
private CTextField hostField = new CTextField(); private CTextField hostField = new CTextField();
private CLabel portLabel = new CLabel(); private CLabel portLabel = new CLabel();
private CTextField dbPortField = new CTextField(); private CTextField dbPortField = new CTextField();
private CLabel sidLabel = new CLabel(); private CLabel sidLabel = new CLabel();
private CTextField sidField = new CTextField(); private CTextField sidField = new CTextField();
private CCheckBox cbFirewall = new CCheckBox(); private CCheckBox cbFirewall = new CCheckBox();
private CLabel fwHostLabel = new CLabel(); private CLabel fwHostLabel = new CLabel();
private CTextField fwHostField = new CTextField(); private CTextField fwHostField = new CTextField();
private CLabel fwPortLabel = new CLabel(); private CLabel fwPortLabel = new CLabel();
private CTextField fwPortField = new CTextField(); private CTextField fwPortField = new CTextField();
private CButton bTestDB = new CButton(); private CButton bTestDB = new CButton();
private CLabel dbTypeLabel = new CLabel(); private CLabel dbTypeLabel = new CLabel();
private CComboBox dbTypeField = new CComboBox(Database.DB_NAMES); private CComboBox dbTypeField = new CComboBox(Database.DB_NAMES);
private CCheckBox cbBequeath = new CCheckBox(); private CCheckBox cbBequeath = new CCheckBox();
private CLabel appsHostLabel = new CLabel(); private CLabel appsHostLabel = new CLabel();
private CTextField appsHostField = new CTextField(); private CTextField appsHostField = new CTextField();
private CLabel appsPortLabel = new CLabel(); private CLabel appsPortLabel = new CLabel();
private CTextField appsPortField = new CTextField(); private CTextField appsPortField = new CTextField();
private CButton bTestApps = new CButton(); private CButton bTestApps = new CButton();
private CCheckBox cbOverwrite = new CCheckBox(); private CCheckBox cbOverwrite = new CCheckBox();
private CLabel dbUidLabel = new CLabel(); private CLabel dbUidLabel = new CLabel();
private CTextField dbUidField = new CTextField(); private CTextField dbUidField = new CTextField();
private JPasswordField dbPwdField = new JPasswordField(); private JPasswordField dbPwdField = new JPasswordField();
private CLabel connectionProfileLabel = new CLabel(); private CLabel connectionProfileLabel = new CLabel();
private CComboBox connectionProfileField = new CComboBox(CConnection.CONNECTIONProfiles); private CComboBox connectionProfileField = new CComboBox(CConnection.CONNECTIONProfiles);
/** /**
* Static Layout * Static Layout
* @throws Exception * @throws Exception
*/ */
private void jbInit() throws Exception private void jbInit() throws Exception
{ {
this.setTitle(res.getString("CConnectionDialog")); this.setTitle(res.getString("CConnectionDialog"));
mainPanel.setLayout(mainLayout); mainPanel.setLayout(mainLayout);
southPanel.setLayout(southLayout); southPanel.setLayout(southLayout);
southLayout.setAlignment(FlowLayout.RIGHT); southLayout.setAlignment(FlowLayout.RIGHT);
centerPanel.setLayout(centerLayout); centerPanel.setLayout(centerLayout);
nameLabel.setText(res.getString("Name")); nameLabel.setText(res.getString("Name"));
nameField.setColumns(30); nameField.setColumns(30);
nameField.setReadWrite(false); nameField.setReadWrite(false);
hostLabel.setText(res.getString("DBHost")); hostLabel.setText(res.getString("DBHost"));
hostField.setColumns(30); hostField.setColumns(30);
portLabel.setText(res.getString("DBPort")); portLabel.setText(res.getString("DBPort"));
dbPortField.setColumns(10); dbPortField.setColumns(10);
sidLabel.setText(res.getString("DBName")); sidLabel.setText(res.getString("DBName"));
cbFirewall.setToolTipText(""); cbFirewall.setToolTipText("");
cbFirewall.setText(res.getString("ViaFirewall")); cbFirewall.setText(res.getString("ViaFirewall"));
fwHostLabel.setText(res.getString("FWHost")); fwHostLabel.setText(res.getString("FWHost"));
fwHostField.setColumns(30); fwHostField.setColumns(30);
fwPortLabel.setText(res.getString("FWPort")); fwPortLabel.setText(res.getString("FWPort"));
bTestDB.setText(res.getString("TestConnection")); bTestDB.setText(res.getString("TestConnection"));
bTestDB.setHorizontalAlignment(JLabel.LEFT); bTestDB.setHorizontalAlignment(JLabel.LEFT);
dbTypeLabel.setText(res.getString("Type")); dbTypeLabel.setText(res.getString("Type"));
sidField.setColumns(30); sidField.setColumns(30);
fwPortField.setColumns(10); fwPortField.setColumns(10);
cbBequeath.setText(res.getString("BequeathConnection")); cbBequeath.setText(res.getString("BequeathConnection"));
appsHostLabel.setText(res.getString("AppsHost")); appsHostLabel.setText(res.getString("AppsHost"));
appsHostField.setColumns(30); appsHostField.setColumns(30);
appsPortLabel.setText(res.getString("AppsPort")); appsPortLabel.setText(res.getString("AppsPort"));
appsPortField.setColumns(10); appsPortField.setColumns(10);
bTestApps.setText(res.getString("TestApps")); bTestApps.setText(res.getString("TestApps"));
bTestApps.setHorizontalAlignment(JLabel.LEFT); bTestApps.setHorizontalAlignment(JLabel.LEFT);
cbOverwrite.setText(res.getString("Overwrite")); cbOverwrite.setText(res.getString("Overwrite"));
dbUidLabel.setText(res.getString("DBUidPwd")); dbUidLabel.setText(res.getString("DBUidPwd"));
dbUidField.setColumns(10); dbUidField.setColumns(10);
connectionProfileLabel.setText(res.getString("ConnectionProfile")); connectionProfileLabel.setText(res.getString("ConnectionProfile"));
connectionProfileField.addActionListener(this); connectionProfileField.addActionListener(this);
this.getContentPane().add(mainPanel, BorderLayout.CENTER); this.getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(centerPanel, BorderLayout.CENTER);
mainPanel.add(southPanel, BorderLayout.SOUTH); mainPanel.add(southPanel, BorderLayout.SOUTH);
southPanel.add(bCancel, null); southPanel.add(bCancel, null);
southPanel.add(bOK, null); southPanel.add(bOK, null);
// //
centerPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 centerPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0));
centerPanel.add(nameField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 centerPanel.add(nameField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0));
centerPanel.add(appsHostLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 centerPanel.add(appsHostLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(appsHostField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 centerPanel.add(appsHostField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0));
centerPanel.add(appsPortLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 centerPanel.add(appsPortLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(appsPortField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 centerPanel.add(appsPortField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
centerPanel.add(connectionProfileLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 centerPanel.add(connectionProfileLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(connectionProfileField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 centerPanel.add(connectionProfileField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));
// //
centerPanel.add(bTestApps, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 centerPanel.add(bTestApps, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0)); ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0));
centerPanel.add(cbOverwrite, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 centerPanel.add(cbOverwrite, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 0, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 0, 12), 0, 0));
// DB // DB
centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(dbTypeField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 centerPanel.add(dbTypeField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
centerPanel.add(cbBequeath, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0 centerPanel.add(cbBequeath, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 12), 0, 0));
centerPanel.add(hostLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 centerPanel.add(hostLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(hostField, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0 centerPanel.add(hostField, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0));
centerPanel.add(portLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 centerPanel.add(portLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(dbPortField, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0 centerPanel.add(dbPortField, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
centerPanel.add(sidLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 centerPanel.add(sidLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(sidField, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0 centerPanel.add(sidField, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
centerPanel.add(dbUidLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0 centerPanel.add(dbUidLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(dbUidField, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0 centerPanel.add(dbUidField, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
centerPanel.add(dbPwdField, new GridBagConstraints(2, 9, 1, 1, 1.0, 0.0 centerPanel.add(dbPwdField, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 12), 0, 0));
centerPanel.add(cbFirewall, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0 centerPanel.add(cbFirewall, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 12), 0, 0));
centerPanel.add(fwHostLabel, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0 centerPanel.add(fwHostLabel, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(fwHostField, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0 centerPanel.add(fwHostField, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
centerPanel.add(fwPortLabel, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0 centerPanel.add(fwPortLabel, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(fwPortField, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0 centerPanel.add(fwPortField, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
centerPanel.add(bTestDB, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0 centerPanel.add(bTestDB, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0)); ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0));
// //
nameField.addActionListener(this); nameField.addActionListener(this);
appsHostField.addActionListener(this); appsHostField.addActionListener(this);
appsPortField.addActionListener(this); appsPortField.addActionListener(this);
cbOverwrite.addActionListener(this); cbOverwrite.addActionListener(this);
bTestApps.addActionListener(this); bTestApps.addActionListener(this);
// //
dbTypeField.addActionListener(this); dbTypeField.addActionListener(this);
hostField.addActionListener(this); hostField.addActionListener(this);
dbPortField.addActionListener(this); dbPortField.addActionListener(this);
sidField.addActionListener(this); sidField.addActionListener(this);
cbBequeath.addActionListener(this); cbBequeath.addActionListener(this);
cbFirewall.addActionListener(this); cbFirewall.addActionListener(this);
fwHostField.addActionListener(this); fwHostField.addActionListener(this);
fwPortField.addActionListener(this); fwPortField.addActionListener(this);
bTestDB.addActionListener(this); bTestDB.addActionListener(this);
bOK.addActionListener(this); bOK.addActionListener(this);
bCancel.addActionListener(this); bCancel.addActionListener(this);
@ -256,260 +256,260 @@ public class CConnectionDialog extends CDialog implements ActionListener
// Server // Server
if (!Ini.isClient()) if (!Ini.isClient())
{ {
appsHostLabel.setVisible(false); appsHostLabel.setVisible(false);
appsHostField.setVisible(false); appsHostField.setVisible(false);
appsPortLabel.setVisible(false); appsPortLabel.setVisible(false);
appsPortField.setVisible(false); appsPortField.setVisible(false);
bTestApps.setVisible(false); bTestApps.setVisible(false);
connectionProfileLabel.setVisible(false); connectionProfileLabel.setVisible(false);
connectionProfileField.setVisible(false); connectionProfileField.setVisible(false);
} }
else // Client else // Client
cbBequeath.setVisible(false); cbBequeath.setVisible(false);
} // jbInit } // jbInit
/** /**
* Set Busy - lock UI * Set Busy - lock UI
* @param busy busy * @param busy busy
*/ */
private void setBusy (boolean busy) private void setBusy (boolean busy)
{ {
if (busy) if (busy)
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
else else
this.setCursor(Cursor.getDefaultCursor()); this.setCursor(Cursor.getDefaultCursor());
m_updating = busy; m_updating = busy;
} // setBusy } // setBusy
/** /**
* Set Connection * Set Connection
* @param cc - if null use current connection * @param cc - if null use current connection
*/ */
public void setConnection (CConnection cc) public void setConnection (CConnection cc)
{ {
m_cc = cc; m_cc = cc;
if (m_cc == null) if (m_cc == null)
{ {
m_cc = CConnection.get(); m_cc = CConnection.get();
m_cc.setName(); m_cc.setName();
} }
// Should copy values // Should copy values
m_ccResult = m_cc; m_ccResult = m_cc;
// //
String type = m_cc.getType(); String type = m_cc.getType();
if (type == null || type.length() == 0) if (type == null || type.length() == 0)
dbTypeField.setSelectedItem(null); dbTypeField.setSelectedItem(null);
else else
m_cc.setType(m_cc.getType()); // sets defaults m_cc.setType(m_cc.getType()); // sets defaults
updateInfo(); updateInfo();
} // setConnection } // setConnection
/** /**
* Get Connection * Get Connection
* @return CConnection * @return CConnection
*/ */
public CConnection getConnection() public CConnection getConnection()
{ {
return m_ccResult; return m_ccResult;
} // getConnection; } // getConnection;
/** /**
* ActionListener * ActionListener
* @param e event * @param e event
*/ */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
if (m_updating) if (m_updating)
return; return;
Object src = e.getSource(); Object src = e.getSource();
if (src == bOK) if (src == bOK)
{ {
m_cc.setName(); m_cc.setName();
m_ccResult = m_cc; m_ccResult = m_cc;
dispose(); dispose();
return; return;
} }
else if (src == bCancel) else if (src == bCancel)
{ {
m_cc.setName(); m_cc.setName();
dispose(); dispose();
return; return;
} }
else if (src == connectionProfileField) else if (src == connectionProfileField)
{ {
ValueNamePair pp = (ValueNamePair)connectionProfileField.getSelectedItem(); ValueNamePair pp = (ValueNamePair)connectionProfileField.getSelectedItem();
m_cc.setConnectionProfile(pp.getValue()); m_cc.setConnectionProfile(pp.getValue());
if (m_cc.isRMIoverHTTP()) if (m_cc.isRMIoverHTTP())
appsPortField.setText(APPS_PORT_HTTP); appsPortField.setText(APPS_PORT_HTTP);
else else
appsPortField.setText(APPS_PORT_JNP); appsPortField.setText(APPS_PORT_JNP);
return; return;
} }
else if (src == dbTypeField) else if (src == dbTypeField)
{ {
if (dbTypeField.getSelectedItem() == null) if (dbTypeField.getSelectedItem() == null)
return; return;
} }
if (Ini.isClient()) if (Ini.isClient())
{ {
m_cc.setAppsHost(appsHostField.getText()); m_cc.setAppsHost(appsHostField.getText());
m_cc.setAppsPort(appsPortField.getText()); m_cc.setAppsPort(appsPortField.getText());
} }
else else
m_cc.setAppsHost("localhost"); m_cc.setAppsHost("localhost");
// //
ValueNamePair pp = (ValueNamePair)connectionProfileField.getSelectedItem(); ValueNamePair pp = (ValueNamePair)connectionProfileField.getSelectedItem();
m_cc.setConnectionProfile(pp.getValue()); m_cc.setConnectionProfile(pp.getValue());
// //
m_cc.setType((String)dbTypeField.getSelectedItem()); m_cc.setType((String)dbTypeField.getSelectedItem());
m_cc.setDbHost(hostField.getText()); m_cc.setDbHost(hostField.getText());
m_cc.setDbPort(dbPortField.getText()); m_cc.setDbPort(dbPortField.getText());
m_cc.setDbName(sidField.getText()); m_cc.setDbName(sidField.getText());
m_cc.setDbUid(dbUidField.getText()); m_cc.setDbUid(dbUidField.getText());
m_cc.setDbPwd(String.valueOf(dbPwdField.getPassword())); m_cc.setDbPwd(String.valueOf(dbPwdField.getPassword()));
m_cc.setBequeath(cbBequeath.isSelected()); m_cc.setBequeath(cbBequeath.isSelected());
m_cc.setViaFirewall(cbFirewall.isSelected()); m_cc.setViaFirewall(cbFirewall.isSelected());
m_cc.setFwHost(fwHostField.getText()); m_cc.setFwHost(fwHostField.getText());
m_cc.setFwPort(fwPortField.getText()); m_cc.setFwPort(fwPortField.getText());
// //
if (src == bTestApps) if (src == bTestApps)
cmd_testApps(); cmd_testApps();
// Database Selection Changed // Database Selection Changed
else if (src == dbTypeField) else if (src == dbTypeField)
{ {
m_cc.setType((String)dbTypeField.getSelectedItem()); m_cc.setType((String)dbTypeField.getSelectedItem());
dbPortField.setText(String.valueOf(m_cc.getDbPort())); dbPortField.setText(String.valueOf(m_cc.getDbPort()));
cbBequeath.setSelected(m_cc.isBequeath()); cbBequeath.setSelected(m_cc.isBequeath());
fwPortField.setText(String.valueOf(m_cc.getFwPort())); fwPortField.setText(String.valueOf(m_cc.getFwPort()));
} }
// //
else if (src == bTestDB) else if (src == bTestDB)
cmd_testDB(); cmd_testDB();
// Name // Name
if (src == nameField) if (src == nameField)
m_cc.setName(nameField.getText()); m_cc.setName(nameField.getText());
updateInfo(); updateInfo();
} // actionPerformed } // actionPerformed
/** /**
* Update Fields from Connection * Update Fields from Connection
*/ */
private void updateInfo() private void updateInfo()
{ {
m_updating = true; m_updating = true;
nameField.setText(m_cc.getName()); nameField.setText(m_cc.getName());
appsHostField.setText(m_cc.getAppsHost()); appsHostField.setText(m_cc.getAppsHost());
appsPortField.setText(String.valueOf(m_cc.getAppsPort())); appsPortField.setText(String.valueOf(m_cc.getAppsPort()));
// //
String cp = m_cc.getConnectionProfile(); String cp = m_cc.getConnectionProfile();
ValueNamePair cpPP = null; ValueNamePair cpPP = null;
for (int i = 0; i < CConnection.CONNECTIONProfiles.length; i++) for (int i = 0; i < CConnection.CONNECTIONProfiles.length; i++)
{ {
if (cp.equals(CConnection.CONNECTIONProfiles[i].getValue())) if (cp.equals(CConnection.CONNECTIONProfiles[i].getValue()))
{ {
cpPP = CConnection.CONNECTIONProfiles[i]; cpPP = CConnection.CONNECTIONProfiles[i];
break; break;
} }
} }
if (cpPP == null) // LAN if (cpPP == null) // LAN
cpPP = CConnection.CONNECTIONProfiles[0]; cpPP = CConnection.CONNECTIONProfiles[0];
connectionProfileField.setSelectedItem(cpPP); connectionProfileField.setSelectedItem(cpPP);
bTestApps.setIcon(getStatusIcon(m_cc.isAppsServerOK(false))); bTestApps.setIcon(getStatusIcon(m_cc.isAppsServerOK(false)));
// bTestApps.setToolTipText(m_cc.getRmiUri()); // bTestApps.setToolTipText(m_cc.getRmiUri());
cbOverwrite.setVisible(m_cc.isAppsServerOK(false)); cbOverwrite.setVisible(m_cc.isAppsServerOK(false));
boolean rw = cbOverwrite.isSelected() || !m_cc.isAppsServerOK(false); boolean rw = cbOverwrite.isSelected() || !m_cc.isAppsServerOK(false);
// //
dbTypeLabel.setReadWrite(rw); dbTypeLabel.setReadWrite(rw);
dbTypeField.setReadWrite(rw); dbTypeField.setReadWrite(rw);
dbTypeField.setSelectedItem(m_cc.getType()); dbTypeField.setSelectedItem(m_cc.getType());
// //
hostLabel.setReadWrite(rw); hostLabel.setReadWrite(rw);
hostField.setReadWrite(rw); hostField.setReadWrite(rw);
hostField.setText(m_cc.getDbHost()); hostField.setText(m_cc.getDbHost());
portLabel.setReadWrite(rw); portLabel.setReadWrite(rw);
dbPortField.setReadWrite(rw); dbPortField.setReadWrite(rw);
dbPortField.setText(String.valueOf(m_cc.getDbPort())); dbPortField.setText(String.valueOf(m_cc.getDbPort()));
sidLabel.setReadWrite(rw); sidLabel.setReadWrite(rw);
sidField.setReadWrite(rw); sidField.setReadWrite(rw);
sidField.setText(m_cc.getDbName()); sidField.setText(m_cc.getDbName());
// //
dbUidLabel.setReadWrite(rw); dbUidLabel.setReadWrite(rw);
dbUidField.setReadWrite(rw); dbUidField.setReadWrite(rw);
dbUidField.setText(m_cc.getDbUid()); dbUidField.setText(m_cc.getDbUid());
dbPwdField.setEditable(rw); dbPwdField.setEditable(rw);
dbPwdField.setText(m_cc.getDbPwd()); dbPwdField.setText(m_cc.getDbPwd());
// //
cbBequeath.setReadWrite(rw); cbBequeath.setReadWrite(rw);
cbBequeath.setEnabled(m_cc.isOracle()); cbBequeath.setEnabled(m_cc.isOracle());
cbBequeath.setSelected(m_cc.isBequeath()); cbBequeath.setSelected(m_cc.isBequeath());
// //
boolean fwEnabled = rw && m_cc.isViaFirewall() && m_cc.isOracle(); boolean fwEnabled = rw && m_cc.isViaFirewall() && m_cc.isOracle();
cbFirewall.setReadWrite(rw && m_cc.isOracle()); cbFirewall.setReadWrite(rw && m_cc.isOracle());
cbFirewall.setSelected(m_cc.isViaFirewall()); cbFirewall.setSelected(m_cc.isViaFirewall());
fwHostLabel.setReadWrite(fwEnabled); fwHostLabel.setReadWrite(fwEnabled);
fwHostField.setReadWrite(fwEnabled); fwHostField.setReadWrite(fwEnabled);
fwHostField.setText(m_cc.getFwHost()); fwHostField.setText(m_cc.getFwHost());
fwPortLabel.setReadWrite(fwEnabled); fwPortLabel.setReadWrite(fwEnabled);
fwPortField.setReadWrite(fwEnabled); fwPortField.setReadWrite(fwEnabled);
fwPortField.setText(String.valueOf(m_cc.getFwPort())); fwPortField.setText(String.valueOf(m_cc.getFwPort()));
// //
bTestDB.setToolTipText(m_cc.getConnectionURL()); bTestDB.setToolTipText(m_cc.getConnectionURL());
bTestDB.setIcon(getStatusIcon(m_cc.isDatabaseOK())); bTestDB.setIcon(getStatusIcon(m_cc.isDatabaseOK()));
m_updating = false; m_updating = false;
} // updateInfo } // updateInfo
/** /**
* Get Status Icon - ok or not * Get Status Icon - ok or not
* @param ok ok * @param ok ok
* @return Icon * @return Icon
*/ */
private Icon getStatusIcon (boolean ok) private Icon getStatusIcon (boolean ok)
{ {
if (ok) if (ok)
return bOK.getIcon(); return bOK.getIcon();
else else
return bCancel.getIcon(); return bCancel.getIcon();
} // getStatusIcon } // getStatusIcon
/** /**
* Test Database connection * Test Database connection
*/ */
private void cmd_testDB() private void cmd_testDB()
{ {
setBusy (true); setBusy (true);
Exception e = m_cc.testDatabase(true); Exception e = m_cc.testDatabase(true);
if (e != null) if (e != null)
{ {
JOptionPane.showMessageDialog(this, JOptionPane.showMessageDialog(this,
e, // message e, // message
res.getString("ConnectionError") + ": " + m_cc.getConnectionURL(), res.getString("ConnectionError") + ": " + m_cc.getConnectionURL(),
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
setBusy (false); setBusy (false);
} // cmd_testDB } // cmd_testDB
/** /**
* Test Application connection * Test Application connection
*/ */
private void cmd_testApps() private void cmd_testApps()
{ {
setBusy (true); setBusy (true);
Exception e = m_cc.testAppsServer(); Exception e = m_cc.testAppsServer();
if (e != null) if (e != null)
{ {
JOptionPane.showMessageDialog(this, JOptionPane.showMessageDialog(this,
e.getLocalizedMessage(), e.getLocalizedMessage(),
res.getString("ServerNotActive") + " - " + m_cc.getAppsHost(), res.getString("ServerNotActive") + " - " + m_cc.getAppsHost(),
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
setBusy (false); setBusy (false);
} // cmd_testApps } // cmd_testApps
} // CConnectionDialog } // CConnectionDialog

View File

@ -624,4 +624,10 @@ class DataSourceImpl implements DataSource {
return impl.toString(); return impl.toString();
} }
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
{
return false;
}
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
} }

View File

@ -1,16 +1,17 @@
/****************************************************************************** /******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1 * Product: Adempiere ERP & CRM Smart Business Solution
* ("License"); You may not use this file except in compliance with the License * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
* You may obtain a copy of the License at http://www.compiere.org/license.html * This program is free software; you can redistribute it and/or modify it
* Software distributed under the License is distributed on an "AS IS" basis, * under the terms version 2 of the GNU General Public License as published
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * by the Free Software Foundation. This program is distributed in the hope
* the specific language governing rights and limitations under the License. * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke * See the GNU General Public License for more details.
* are Copyright (C) 1999-2005 Jorg Janke. * You should have received a copy of the GNU General Public License along
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. * with this program; if not, write to the Free Software Foundation, Inc.,
* Portions created by Victor Perez are Copyright (C) 1999-2005 e-Evolution,S.C * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* Contributor(s): Victor Perez * You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
*****************************************************************************/ *****************************************************************************/
package org.compiere.db; package org.compiere.db;

View File

@ -0,0 +1,426 @@
/******************************************************************************
* 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.
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
*****************************************************************************/
package org.compiere.db;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.apache.derby.drda.*;
import org.apache.derby.impl.drda.*;
import org.apache.derby.jdbc.*;
import org.compiere.util.*;
/**
* Derby DB Server
*
* @author Jorg Janke
* @version $Id: DerbyServer.java,v 1.5 2006/07/30 00:55:13 jjanke Exp $
*/
public class DerbyServer extends Thread
{
/**
* Get/Create Derby Server
* @return server
*/
public static synchronized DerbyServer get()
{
if (s_server == null)
{
InetAddress address = null;
int port = PORT;
try
{
address = InetAddress.getByAddress(new byte[] {0,0,0,0}); // all ports
s_server = new DerbyServer(address, port);
s_server.start();
}
catch (Exception e)
{
String msg = null;
if (address == null)
msg = "";
else
msg = address.toString();
msg += ":" + port;
log.log(Level.SEVERE, msg, e);
}
}
return s_server;
} // get
/**
* Start Server
* @return true if started
*/
public static boolean startServer()
{
if (get() == null)
return false;
return s_server.isServerStarted();
} // startServer
/**
* Stop Server
* @return true if stopped / not running
*/
public static boolean stopServer()
{
if (s_server == null)
return true;
try
{
s_server.shutdown();
s_server = null;
return true;
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getMessage(), e);
}
return false;
} // stopServer
/** Singleton */
private static DerbyServer s_server = null;
/** Default Port 1527 */
public static final int PORT = NetworkServerControl.DEFAULT_PORTNUMBER;
/** Logger */
private static CLogger log = CLogger.getCLogger (DerbyServer.class);
/**************************************************************************
* Derby Server
* @param address server address
* @param port port
* @throws Exception
*/
private DerbyServer (InetAddress address, int port) throws Exception
{
super("CompiereDerby");
if (s_impl != null)
throw new IllegalStateException("Derby Server already started");
//
String compiereHome = Ini.getAdempiereHome();
s_derbyHome = compiereHome + File.separator + "derby";
File dir = new File(s_derbyHome);
if (!dir.exists())
dir.mkdir();
//
System.setProperty("derby.system.home", s_derbyHome);
System.setProperty("derby.drda.traceDirectory", s_derbyHome);
//
String logIt = "false";
if (CLogMgt.isLevelFiner())
logIt = "true";
System.setProperty("derby.drda.logConnections", logIt);
System.setProperty("derby.drda.traceAll", logIt);
//
System.setProperty("derby.connection.requireAuthentication", "true");
System.setProperty("derby.authentication.provider", "BUILTIN");
addUser("compiere", "compiere");
//
s_address = address;
s_port = port;
s_impl = new NetworkServerControlImpl (s_address, s_port);
} // DerbyServer
/** Singleton */
private static NetworkServerControlImpl s_impl = null;
/** Derby Home */
private static String s_derbyHome = "";
/** Address */
private static InetAddress s_address = null;
/** Port */
private static int s_port = 0;
/**
* Run
*/
public void run()
{
log.info("starting ...");
PrintWriter consoleWriter = new PrintWriter(System.out, true); // flush
try
{
s_impl.blockingStart(consoleWriter);
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getMessage(), e);
s_impl = null;
}
log.info("done");
} // run
/**
* Interrupt - shutdown
*/
public void interrupt ()
{
super.interrupt ();
shutdown();
} // interrupt
/**
* Is Server Started
* @return server started
*/
public boolean isServerStarted()
{
if (s_impl == null)
return false;
try
{
s_impl.ping();
}
catch (Exception e)
{
return false;
}
return true;
} // isServerStarted
/**
* Shutdown
* @return true if shut down
*/
public boolean shutdown()
{
if (s_impl != null)
{
try
{
log.info("shutting down ...");
s_impl.shutdown();
log.info("shutdown");
return true;
}
catch (Exception e)
{
return false;
}
}
return true;
} // shutdown
/**
* String Representation
* @return info
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("DerbyServer[");
sb.append (s_derbyHome)
.append(";").append(s_address)
.append(":").append(s_port)
.append(";Alive=").append(isAlive())
.append(";Started=").append(isServerStarted());
sb.append ("]");
return sb.toString ();
} // toString
/**
* Get Derby Home
* @return home
*/
public String getDerbyHome()
{
return s_derbyHome;
} // getDerbyHome
/**
* Get Runtime Info
* @return info
*/
public String getRuntimeInfo()
{
try
{
if (s_impl != null)
return s_impl.runtimeInfo();
}
catch (Exception e)
{
return e.getMessage();
}
return "";
} // getRuntimeInfo
/**
* Get System Info
* @return info
*/
public String getSysInfo()
{
try
{
if (s_impl != null)
return s_impl.sysinfo();
}
catch (Exception e)
{
return e.getMessage();
}
return "";
} // getSysInfo
/**
* Get current Network server properties.
* @return Properties object containing Network server properties
* @exception Exception throws an exception if an error occurs
*/
public Properties getCurrentProperties() throws Exception
{
return s_impl.getCurrentProperties();
} // getCurrentProperties
/**
* Add User
* @param dbUid user id
* @param dbPwd user password
*/
public void addUser (String dbUid, String dbPwd)
{
System.setProperty("derby.user." + dbUid, dbPwd);
Properties dp = new Properties();
} // addUser
/**
* Create Database
* @param dbName database name
* @param dbUid user id
* @param dbPwd user password
* @return true if exists or created
*/
public boolean createDatabase (String dbName,
String dbUid, String dbPwd)
{
addUser (dbUid, dbPwd);
// Embedded Driver
try
{
EmbeddedDriver driver = new EmbeddedDriver();
DriverManager.registerDriver (driver);
}
catch (Exception e)
{
log.log(Level.SEVERE, "DriverIssue", e);
return false;
}
// Connection
String dbUrl = "jdbc:derby:" + dbName;
Connection conn = null;
try
{
String urlAttributes = ";create=true"
// + "dataEncryption=true;bootPassword=cLo4u922sc23aPe"
// + ";territory=en_US"
+ ";user=" + dbUid
+ ";password=" + dbPwd;
conn = DriverManager.getConnection(dbUrl + urlAttributes);
log.info("Created DB: " + dbName);
// new JDBCInfo(conn);
}
catch (Exception e)
{
log.severe(e.getMessage());
}
try
{
if (conn != null)
conn.close();
conn = null;
}
catch (Exception e)
{
}
// Connection test
try
{
conn = DriverManager.getConnection(dbUrl, dbUid, dbPwd);
log.info("Connected to DB: " + dbName);
// new JDBCInfo(conn);
}
catch (Exception e)
{
log.severe(e.getMessage());
conn = null;
return false;
}
// Connection test
Statement stmt = null;
try
{
stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE XX (XX VARCHAR(5))");
stmt.executeUpdate("INSERT INTO XX (XX) VALUES ('A')");
}
catch (Exception e)
{
log.info(e.getMessage());
}
try
{
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
conn = null;
}
catch (Exception e)
{
}
return true;
} // createDatabase
/**************************************************************************
* Start Derby Server
* @param args
*/
public static void main (String[] args)
{
CLogMgt.setLevel(Level.FINE);
DerbyServer server = DerbyServer.get();
startServer();
server.createDatabase("compiere", "compiere", "compiere");
// log.info(server.getRuntimeInfo());
// log.info(server.getSysInfo());
try
{
// log.info(server.getCurrentProperties().toString());
//
log.info("Sleeping " + get());
Thread.sleep(5000);
}
catch (Exception e)
{
}
// stopServer();
} // main
} // DerbyServer

View File

@ -1,200 +1,200 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* For the text or an alternative of this public license, you may reach us * * You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
* or via info@compiere.org or http://www.compiere.org/license.html * *****************************************************************************/
*****************************************************************************/ package org.compiere.db;
package org.compiere.db;
import java.util.*;
import java.util.*; import java.util.logging.*;
import java.util.logging.*;
import javax.naming.*;
import javax.naming.*; import javax.naming.ldap.*;
import javax.naming.ldap.*; import javax.naming.directory.*;
import javax.naming.directory.*;
import org.compiere.util.*;
import org.compiere.util.*;
/**
/** * LDAP Management Interface
* LDAP Management Interface *
* * @author Jorg Janke
* @author Jorg Janke * @version $Id: LDAP.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
* @version $Id: LDAP.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $ */
*/ public class LDAP
public class LDAP {
{ /**
/** * Validate User
* Validate User * @param ldapURL provider url - e.g. ldap://dc.compiere.org
* @param ldapURL provider url - e.g. ldap://dc.adempiere.org * @param domain domain name = e.g. compiere.org
* @param domain domain name = e.g. adempiere.org * @param userName user name - e.g. jjanke
* @param userName user name - e.g. jjanke * @param password password
* @param password password * @return true if validated with ldap
* @return true if validated with ldap */
*/ public static boolean validate (String ldapURL, String domain, String userName, String password)
public static boolean validate (String ldapURL, String domain, String userName, String password) {
{ Hashtable<String,String> env = new Hashtable<String,String>();
Hashtable<String,String> env = new Hashtable<String,String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // ldap://dc.compiere.org
// ldap://dc.adempiere.org env.put(Context.PROVIDER_URL, ldapURL);
env.put(Context.PROVIDER_URL, ldapURL); env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_AUTHENTICATION, "simple"); // jjanke@compiere.org
// jjanke@adempiere.org StringBuffer principal = new StringBuffer (userName)
StringBuffer principal = new StringBuffer (userName) .append("@").append(domain);
.append("@").append(domain); env.put(Context.SECURITY_PRINCIPAL, principal.toString());
env.put(Context.SECURITY_PRINCIPAL, principal.toString()); env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.SECURITY_CREDENTIALS, password); //
// try
try {
{ // Create the initial context
// Create the initial context InitialLdapContext ctx = new InitialLdapContext(env, null);
InitialLdapContext ctx = new InitialLdapContext(env, null); // DirContext ctx = new InitialDirContext(env);
// DirContext ctx = new InitialDirContext(env);
// Test - Get the attributes
// Test - Get the attributes Attributes answer = ctx.getAttributes("");
Attributes answer = ctx.getAttributes("");
// Print the answer
// Print the answer if (false)
// dump (answer); dump (answer);
} }
catch (AuthenticationException e) catch (AuthenticationException e)
{ {
log.info("Error: " + principal + " - " + e.getLocalizedMessage()); log.info("Error: " + principal + " - " + e.getLocalizedMessage());
return false; return false;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, ldapURL + " - " + principal, e); log.log (Level.SEVERE, ldapURL + " - " + principal, e);
return false; return false;
} }
log.info("OK: " + principal); log.info("OK: " + principal);
return true; return true;
} // validate } // validate
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger (LDAP.class); private static CLogger log = CLogger.getCLogger (LDAP.class);
/** /**
* Test NT * Test NT
* @throws LoginException * @throws LoginException
* *
private static void testNT () throws LoginException private static void testNT () throws LoginException
{ {
try try
{ {
System.out.println ("NT system ----------------------------"); System.out.println ("NT system ----------------------------");
NTSystem ntsystem = new NTSystem (); NTSystem ntsystem = new NTSystem ();
System.out.println (ntsystem); System.out.println (ntsystem);
System.out.println (ntsystem.getDomain ()); System.out.println (ntsystem.getDomain ());
System.out.println (ntsystem.getDomainSID ()); System.out.println (ntsystem.getDomainSID ());
System.out.println (ntsystem.getName ()); System.out.println (ntsystem.getName ());
System.out.println (ntsystem.getUserSID ()); System.out.println (ntsystem.getUserSID ());
System.out.println ("NT login ----------------------------"); System.out.println ("NT login ----------------------------");
NTLoginModule ntlogin = new NTLoginModule (); NTLoginModule ntlogin = new NTLoginModule ();
System.out.println (ntlogin); System.out.println (ntlogin);
Map<String,String> map = new HashMap<String,String>(); Map<String,String> map = new HashMap<String,String>();
map.put ("debug", "true"); map.put ("debug", "true");
ntlogin.initialize (null, null, null, map); ntlogin.initialize (null, null, null, map);
System.out.println (ntlogin.login ()); System.out.println (ntlogin.login ());
} }
catch (LoginException le) catch (LoginException le)
{ {
System.err.println ("Authentication attempt failed" + le); System.err.println ("Authentication attempt failed" + le);
} }
} // testNT } // testNT
/** /**
* testKerberos * testKerberos
* @throws LoginException * @throws LoginException
* *
private static void testKerberos () private static void testKerberos ()
throws LoginException throws LoginException
{ {
System.out.println ("Krb login ----------------------------"); System.out.println ("Krb login ----------------------------");
Map<String,String> map = new HashMap<String,String>(); Map<String,String> map = new HashMap<String,String>();
// map.put("debug", "true"); // map.put("debug", "true");
// map.put("debugNative", "true"); // map.put("debugNative", "true");
Krb5LoginModule klogin = new Krb5LoginModule (); Krb5LoginModule klogin = new Krb5LoginModule ();
System.out.println (klogin); System.out.println (klogin);
map.put ("principal", "username@adempiere.org"); map.put ("principal", "username@compiere.org");
map.put ("credential", "pass"); map.put ("credential", "pass");
klogin.initialize (null, null, null, map); klogin.initialize (null, null, null, map);
System.out.println (klogin.login ()); System.out.println (klogin.login ());
/*********************************************************************** /***********************************************************************
* ** No krb5.ini file found in entire system Debug is true storeKey * ** No krb5.ini file found in entire system Debug is true storeKey
* false useTicketCache false useKeyTab false doNotPrompt false * false useTicketCache false useKeyTab false doNotPrompt false
* ticketCache is null KeyTab is null refreshKrb5Config is false * ticketCache is null KeyTab is null refreshKrb5Config is false
* principal is jjanke tryFirstPass is false useFirstPass is false * principal is jjanke tryFirstPass is false useFirstPass is false
* storePass is false clearPass is false [Krb5LoginModule] * storePass is false clearPass is false [Krb5LoginModule]
* authentication failed Could not load configuration file * authentication failed Could not load configuration file
* c:\winnt\krb5.ini (The system cannot find the file specified) * c:\winnt\krb5.ini (The system cannot find the file specified)
* javax.security.auth.login.LoginException: Could not load * javax.security.auth.login.LoginException: Could not load
* configuration file c:\winnt\krb5.ini (The system cannot find the file * configuration file c:\winnt\krb5.ini (The system cannot find the file
* specified) * specified)
* *
} // testKerbos } // testKerbos
/**/ /**/
/** /**
* Print Attributes to System.out * Print Attributes to System.out
* @param attrs * @param attrs
*/ */
private static void dump (Attributes attrs) private static void dump (Attributes attrs)
{ {
if (attrs == null) if (attrs == null)
{ {
System.out.println ("No attributes"); System.out.println ("No attributes");
} }
else else
{ {
/* Print each attribute */ /* Print each attribute */
try try
{ {
for (NamingEnumeration ae = attrs.getAll (); ae.hasMore ();) for (NamingEnumeration ae = attrs.getAll (); ae.hasMore ();)
{ {
Attribute attr = (Attribute) ae.next (); Attribute attr = (Attribute) ae.next ();
System.out.println ("attribute: " + attr.getID ()); System.out.println ("attribute: " + attr.getID ());
/* print each value */ /* print each value */
for (NamingEnumeration e = attr.getAll(); for (NamingEnumeration e = attr.getAll();
e.hasMore (); e.hasMore ();
System.out.println (" value: " + e.next())) System.out.println (" value: " + e.next()))
; ;
} }
} }
catch (NamingException e) catch (NamingException e)
{ {
e.printStackTrace (); e.printStackTrace ();
} }
} }
} // dump } // dump
/** /**
* Test * Test
* @param args ignored * @param args ignored
*/ */
public static void main (String[] args) public static void main (String[] args)
{ {
try try
{ {
validate("ldap://dc.adempiere.org", "adempiere.org", "red1", "ikeepforgetting"); validate("ldap://dc.compiere.org", "compiere.org", "jjanke", "ikeepforgetting");
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} // main } // main
} // LDAP } // LDAP

View File

@ -1,15 +1,17 @@
/****************************************************************************** /******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1 * Product: Adempiere ERP & CRM Smart Business Solution
* ("License"); You may not use this file except in compliance with the License * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
* You may obtain a copy of the License at http://www.compiere.org/license.html * This program is free software; you can redistribute it and/or modify it
* Software distributed under the License is distributed on an "AS IS" basis, * under the terms version 2 of the GNU General Public License as published
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * by the Free Software Foundation. This program is distributed in the hope
* the specific language governing rights and limitations under the License. * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke * See the GNU General Public License for more details.
* are Copyright (C) 1999-2005 Jorg Janke. * You should have received a copy of the GNU General Public License along
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. * with this program; if not, write to the Free Software Foundation, Inc.,
* Contributor(s): ______________________________________. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
*****************************************************************************/ *****************************************************************************/
package org.compiere.dbPort; package org.compiere.dbPort;

View File

@ -1,15 +1,17 @@
/****************************************************************************** /******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1 * Product: Adempiere ERP & CRM Smart Business Solution
* ("License"); You may not use this file except in compliance with the License * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
* You may obtain a copy of the License at http://www.compiere.org/license.html * This program is free software; you can redistribute it and/or modify it
* Software distributed under the License is distributed on an "AS IS" basis, * under the terms version 2 of the GNU General Public License as published
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * by the Free Software Foundation. This program is distributed in the hope
* the specific language governing rights and limitations under the License. * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke * See the GNU General Public License for more details.
* are Copyright (C) 1999-2005 Jorg Janke. * You should have received a copy of the GNU General Public License along
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. * with this program; if not, write to the Free Software Foundation, Inc.,
* Contributor(s): ______________________________________. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
*****************************************************************************/ *****************************************************************************/
package org.compiere.dbPort; package org.compiere.dbPort;

View File

@ -3,58 +3,58 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. * * See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us * * 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 * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import junit.framework.*; import junit.framework.*;
import org.compiere.*; import org.compiere.*;
/** /**
* AccessSqlParserTest tests the class * AccessSqlParserTest tests the class
* AccessSqlParser * AccessSqlParser
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: AccessSqlParserTest.java,v 1.2 2006/07/30 00:58:04 jjanke Exp $ * @version $Id: AccessSqlParserTest.java,v 1.2 2006/07/30 00:58:04 jjanke Exp $
*/ */
public class AccessSqlParserTest extends TestCase public class AccessSqlParserTest extends TestCase
{ {
/** /**
* Construct new test instance * Construct new test instance
* *
* @param name the test name * @param name the test name
*/ */
public AccessSqlParserTest(String name) public AccessSqlParserTest(String name)
{ {
super(name); super(name);
} }
/** /**
* Launch the test. * Launch the test.
* *
* @param args String[] * @param args String[]
*/ */
public static void main(String[] args) public static void main(String[] args)
{ {
junit.swingui.TestRunner.run(AccessSqlParserTest.class); junit.swingui.TestRunner.run(AccessSqlParserTest.class);
} }
/** /**
* Perform pre-test initialization * Perform pre-test initialization
* *
* @throws Exception * @throws Exception
* *
* @see TestCase#setUp() * @see TestCase#setUp()
*/ */
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
super.setUp(); super.setUp();
@ -62,170 +62,170 @@ public class AccessSqlParserTest extends TestCase
} }
/** /**
* Run the oneTable test * Run the oneTable test
*/ */
public void testOneTable() public void testOneTable()
{ {
String sql = "SELECT AD_Table_ID, TableName FROM AD_Table WHERE IsActive='Y'"; String sql = "SELECT AD_Table_ID, TableName FROM AD_Table WHERE IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table|0]", fixture.toString());
} }
/** /**
* Run the oneTableSyn test * Run the oneTableSyn test
*/ */
public void testOneTableSyn() public void testOneTableSyn()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName FROM AD_Table t WHERE t.IsActive='Y'"; String sql = "SELECT t.AD_Table_ID, t.TableName FROM AD_Table t WHERE t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table=t|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table=t|0]", fixture.toString());
} }
/** /**
* Run the oneTableSyn test * Run the oneTableSyn test
*/ */
public void testOneTableSynAS() public void testOneTableSynAS()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName FROM AD_Table AS t WHERE t.IsActive='Y'"; String sql = "SELECT t.AD_Table_ID, t.TableName FROM AD_Table AS t WHERE t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table=t|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table=t|0]", fixture.toString());
} }
/** /**
* Run the twoTable test * Run the twoTable test
*/ */
public void testTwoTable() public void testTwoTable()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName FROM AD_Table t, AD_Column c WHERE t.AD_Table_ID=c.AD_Table_ID AND t.IsActive='Y'"; String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName FROM AD_Table t, AD_Column c WHERE t.AD_Table_ID=c.AD_Table_ID AND t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString());
} }
/** /**
* Run the twoTableSyn test * Run the twoTableSyn test
*/ */
public void testTwoTableSyn() public void testTwoTableSyn()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName FROM AD_Table as t, AD_Column AS c WHERE t.AD_Table_ID=c.AD_Table_ID AND t.IsActive='Y'"; String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName FROM AD_Table as t, AD_Column AS c WHERE t.AD_Table_ID=c.AD_Table_ID AND t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString());
} }
/** /**
* Run the joinInner test * Run the joinInner test
*/ */
public void testJoinInner() public void testJoinInner()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName " String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName "
+ "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) WHERE t.IsActive='Y'"; + "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) WHERE t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString());
} }
/** /**
* Run the joinOuter test * Run the joinOuter test
*/ */
public void testJoinOuter() public void testJoinOuter()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName " String sql = "SELECT t.AD_Table_ID, t.TableName, c.AD_Column_ID, c.ColumnName "
+ "FROM AD_Table t LEFT OUTER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) WHERE t.IsActive='Y'"; + "FROM AD_Table t LEFT OUTER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) WHERE t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString()); assertEquals("AccessSqlParser[AD_Table=t,AD_Column=c|0]", fixture.toString());
} }
/** /**
* Run the exists test * Run the exists test
*/ */
public void testExists() public void testExists()
{ {
String sql = "SELECT AD_Table.AD_Table_ID, AD_Table.TableName " String sql = "SELECT AD_Table.AD_Table_ID, AD_Table.TableName "
+ "FROM AD_Table " + "FROM AD_Table "
+ "WHERE EXISTS (SELECT * FROM AD_Column c WHERE AD_Table.AD_Table_ID=c.AD_Table_ID)"; + "WHERE EXISTS (SELECT * FROM AD_Column c WHERE AD_Table.AD_Table_ID=c.AD_Table_ID)";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Column=c|AD_Table|1]", fixture.toString()); assertEquals("AccessSqlParser[AD_Column=c|AD_Table|1]", fixture.toString());
} }
/** /**
* Run the exists test with syn * Run the exists test with syn
*/ */
public void testExistsSyn() public void testExistsSyn()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName " String sql = "SELECT t.AD_Table_ID, t.TableName "
+ "FROM AD_Table t " + "FROM AD_Table t "
+ "WHERE EXISTS (SELECT * FROM AD_Column c WHERE t.AD_Table_ID=c.AD_Table_ID)"; + "WHERE EXISTS (SELECT * FROM AD_Column c WHERE t.AD_Table_ID=c.AD_Table_ID)";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Column=c|AD_Table=t|1]", fixture.toString()); assertEquals("AccessSqlParser[AD_Column=c|AD_Table=t|1]", fixture.toString());
} }
/** /**
* Run the embeddedSelect test * Run the embeddedSelect test
*/ */
public void testEmbeddedSelect() public void testEmbeddedSelect()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName," String sql = "SELECT t.AD_Table_ID, t.TableName,"
+ "(SELECT COUNT(c.ColumnName) FROM AD_Column c WHERE t.AD_Table_ID=c.AD_Table_ID) " + "(SELECT COUNT(c.ColumnName) FROM AD_Column c WHERE t.AD_Table_ID=c.AD_Table_ID) "
+ "FROM AD_Table t WHERE t.IsActive='Y'"; + "FROM AD_Table t WHERE t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Column=c|AD_Table=t|1]", fixture.toString()); assertEquals("AccessSqlParser[AD_Column=c|AD_Table=t|1]", fixture.toString());
} }
/** /**
* Run the embeddedFrom test * Run the embeddedFrom test
*/ */
public void testEmbeddedFrom() public void testEmbeddedFrom()
{ {
String sql = "SELECT t.AD_Table_ID, t.TableName, cc.CCount " String sql = "SELECT t.AD_Table_ID, t.TableName, cc.CCount "
+ "FROM AD_Table t," + "FROM AD_Table t,"
+ "(SELECT COUNT(ColumnName) AS CCount FROM AD_Column) cc " + "(SELECT COUNT(ColumnName) AS CCount FROM AD_Column) cc "
+ "WHERE t.IsActive='Y'"; + "WHERE t.IsActive='Y'";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[AD_Column|AD_Table=t,(##)=cc|1]", fixture.toString()); assertEquals("AccessSqlParser[AD_Column|AD_Table=t,(##)=cc|1]", fixture.toString());
} }
/** /**
* Run the Product & Instance Attribute Query * Run the Product & Instance Attribute Query
*/ */
public void testProductInstanceAttributeQuery() public void testProductInstanceAttributeQuery()
{ {
String sql = "SELECT p.M_Product_ID, p.Discontinued, p.Value, p.Name, BOM_Qty_Available(p.M_Product_ID,?) AS QtyAvailable, bomQtyList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd, BOM_Qty_OnHand(p.M_Product_ID,?) AS QtyOnHand, BOM_Qty_Reserved(p.M_Product_ID,?) AS QtyReserved, BOM_Qty_Ordered(p.M_Product_ID,?) AS QtyOrdered, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin, bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit, pa.IsInstanceAttribute FROM M_Product p INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID) LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID) WHERE p.IsSummary='N' AND p.IsActive='Y' AND pr.IsActive='Y' AND pr.M_PriceList_Version_ID=? AND EXISTS (SELECT * FROM M_Storage s INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) WHERE s.M_Product_ID=p.M_Product_ID AND asi.SerNo LIKE '33' AND asi.Lot LIKE '33' AND asi.M_Lot_ID=101 AND TRUNC(asi.GuaranteeDate,'DD')<TO_DATE('2003-10-16','YYYY-MM-DD') AND asi.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=103 AND Value LIKE '33') AND (M_Attribute_ID=102 AND M_AttributeValue_ID=106))) AND p.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=101 AND M_AttributeValue_ID=105) AND (M_Attribute_ID=100 AND M_AttributeValue_ID=102)) AND p.AD_Client_ID IN(0,11) AND p.AD_Org_ID IN(0,11,12) ORDER BY QtyAvailable DESC, Margin DESC"; String sql = "SELECT p.M_Product_ID, p.Discontinued, p.Value, p.Name, BOM_Qty_Available(p.M_Product_ID,?) AS QtyAvailable, bomQtyList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd, BOM_Qty_OnHand(p.M_Product_ID,?) AS QtyOnHand, BOM_Qty_Reserved(p.M_Product_ID,?) AS QtyReserved, BOM_Qty_Ordered(p.M_Product_ID,?) AS QtyOrdered, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin, bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit, pa.IsInstanceAttribute FROM M_Product p INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID) LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID) WHERE p.IsSummary='N' AND p.IsActive='Y' AND pr.IsActive='Y' AND pr.M_PriceList_Version_ID=? AND EXISTS (SELECT * FROM M_Storage s INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) WHERE s.M_Product_ID=p.M_Product_ID AND asi.SerNo LIKE '33' AND asi.Lot LIKE '33' AND asi.M_Lot_ID=101 AND TRUNC(asi.GuaranteeDate)<TO_DATE('2003-10-16','YYYY-MM-DD') AND asi.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=103 AND Value LIKE '33') AND (M_Attribute_ID=102 AND M_AttributeValue_ID=106))) AND p.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=101 AND M_AttributeValue_ID=105) AND (M_Attribute_ID=100 AND M_AttributeValue_ID=102)) AND p.AD_Client_ID IN(0,11) AND p.AD_Org_ID IN(0,11,12) ORDER BY QtyAvailable DESC, Margin DESC";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[M_AttributeInstance|M_Storage=s,M_AttributeSetInstance=asi|M_AttributeInstance|M_Product=p,M_ProductPrice=pr,M_AttributeSet=pa|3]", fixture.toString()); assertEquals("AccessSqlParser[M_AttributeInstance|M_Storage=s,M_AttributeSetInstance=asi|M_AttributeInstance|M_Product=p,M_ProductPrice=pr,M_AttributeSet=pa|3]", fixture.toString());
} }
/** /**
* Run the Product Attribute Query * Run the Product Attribute Query
*/ */
public void testProductAttributeQuery() public void testProductAttributeQuery()
{ {
String sql = "SELECT p.M_Product_ID, p.Discontinued, p.Value, p.Name, BOM_Qty_Available(p.M_Product_ID,?) AS QtyAvailable, bomQtyList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd, BOM_Qty_OnHand(p.M_Product_ID,?) AS QtyOnHand, BOM_Qty_Reserved(p.M_Product_ID,?) AS QtyReserved, BOM_Qty_Ordered(p.M_Product_ID,?) AS QtyOrdered, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin, bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit, pa.IsInstanceAttribute FROM M_Product p INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID) LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID) WHERE p.IsSummary='N' AND p.IsActive='Y' AND pr.IsActive='Y' AND pr.M_PriceList_Version_ID=? AND p.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=100 AND M_AttributeValue_ID=101)) ORDER BY QtyAvailable DESC, Margin DESC"; String sql = "SELECT p.M_Product_ID, p.Discontinued, p.Value, p.Name, BOM_Qty_Available(p.M_Product_ID,?) AS QtyAvailable, bomQtyList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd, BOM_Qty_OnHand(p.M_Product_ID,?) AS QtyOnHand, BOM_Qty_Reserved(p.M_Product_ID,?) AS QtyReserved, BOM_Qty_Ordered(p.M_Product_ID,?) AS QtyOrdered, bomQtyStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin, bomQtyLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit, pa.IsInstanceAttribute FROM M_Product p INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID) LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID) WHERE p.IsSummary='N' AND p.IsActive='Y' AND pr.IsActive='Y' AND pr.M_PriceList_Version_ID=? AND p.M_AttributeSetInstance_ID IN (SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance WHERE (M_Attribute_ID=100 AND M_AttributeValue_ID=101)) ORDER BY QtyAvailable DESC, Margin DESC";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
assertEquals("AccessSqlParser[M_AttributeInstance|M_Product=p,M_ProductPrice=pr,M_AttributeSet=pa|1]", fixture.toString()); assertEquals("AccessSqlParser[M_AttributeInstance|M_Product=p,M_ProductPrice=pr,M_AttributeSet=pa|1]", fixture.toString());
} }
/** **/ /** **/
public void testHinttech() public void testHinttech()
{ {
String sql = "SELECT XX_HTC1_EMPLOYEE_V.C_BPartner_ID,NULL,XX_HTC1_EMPLOYEE_V.C_BPARTNER_NAME,XX_HTC1_EMPLOYEE_V.IsActive FROM XX_HTC1_EMPLOYEE_V WHERE XX_HTC1_EMPLOYEE_V.AD_User_ID IN (SELECT ur.AD_User_ID FROM AD_User_Roles ur INNER JOIN AD_Role r ON (ur.AD_Role_ID=r.AD_Role_ID) WHERE r.Name like '%Field Manager%')"; String sql = "SELECT XX_HTC1_EMPLOYEE_V.C_BPartner_ID,NULL,XX_HTC1_EMPLOYEE_V.C_BPARTNER_NAME,XX_HTC1_EMPLOYEE_V.IsActive FROM XX_HTC1_EMPLOYEE_V WHERE XX_HTC1_EMPLOYEE_V.AD_User_ID IN (SELECT ur.AD_User_ID FROM AD_User_Roles ur INNER JOIN AD_Role r ON (ur.AD_Role_ID=r.AD_Role_ID) WHERE r.Name like '%Field Manager%')";
AccessSqlParser fixture = new AccessSqlParser(sql); AccessSqlParser fixture = new AccessSqlParser(sql);
} }
} }
/*$CPS$ This comment was generated by CodePro. Do not edit it. /*$CPS$ This comment was generated by CodePro. Do not edit it.
* patternId = com.instantiations.assist.eclipse.pattern.testCasePattern * patternId = com.instantiations.assist.eclipse.pattern.testCasePattern
* strategyId = com.instantiations.assist.eclipse.pattern.testCasePattern.junitTestCase * strategyId = com.instantiations.assist.eclipse.pattern.testCasePattern.junitTestCase
* additionalTestNames = oneTable, oneTableSyn, twoTable, twoTableSyn, joinInner, joinOuter, embeddedSelect, embeddedFrom * additionalTestNames = oneTable, oneTableSyn, twoTable, twoTableSyn, joinInner, joinOuter, embeddedSelect, embeddedFrom
* assertTrue = false * assertTrue = false
* callTestMethod = true * callTestMethod = true
* createMain = true * createMain = true
* createSetUp = true * createSetUp = true
* createTearDown = false * createTearDown = false
* createTestFixture = false * createTestFixture = false
* createTestStubs = false * createTestStubs = false
* methods = getSql(),parse() * methods = getSql(),parse()
* package = org.compiere.model * package = org.compiere.model
* package.sourceFolder = dbPort/src * package.sourceFolder = dbPort/src
* superclassType = junit.framework.TestCase * superclassType = junit.framework.TestCase
* testCase = AccessSqlParserTest * testCase = AccessSqlParserTest
* testClassType = org.compiere.model.AccessSqlParser * testClassType = org.compiere.model.AccessSqlParser
*/ */

View File

@ -3,238 +3,238 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. * * See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us * * 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 * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Client Share Info * Client Share Info
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MClientShare.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $ * @version $Id: MClientShare.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $
*/ */
public class MClientShare extends X_AD_ClientShare public class MClientShare extends X_AD_ClientShare
{ {
/** /**
* Is Table Client Level Only * Is Table Client Level Only
* @param AD_Client_ID client * @param AD_Client_ID client
* @param AD_Table_ID table * @param AD_Table_ID table
* @return true if client level only (default false) * @return true if client level only (default false)
*/ */
public static boolean isClientLevelOnly (int AD_Client_ID, int AD_Table_ID) public static boolean isClientLevelOnly (int AD_Client_ID, int AD_Table_ID)
{ {
Boolean share = isShared(AD_Client_ID, AD_Table_ID); Boolean share = isShared(AD_Client_ID, AD_Table_ID);
if (share != null) if (share != null)
return share.booleanValue(); return share.booleanValue();
return false; return false;
} // isClientLevel } // isClientLevel
/** /**
* Is Table Org Level Only * Is Table Org Level Only
* @param AD_Client_ID client * @param AD_Client_ID client
* @param AD_Table_ID table * @param AD_Table_ID table
* @return true if Org level only (default false) * @return true if Org level only (default false)
*/ */
public static boolean isOrgLevelOnly (int AD_Client_ID, int AD_Table_ID) public static boolean isOrgLevelOnly (int AD_Client_ID, int AD_Table_ID)
{ {
Boolean share = isShared(AD_Client_ID, AD_Table_ID); Boolean share = isShared(AD_Client_ID, AD_Table_ID);
if (share != null) if (share != null)
return !share.booleanValue(); return !share.booleanValue();
return false; return false;
} // isOrgLevel } // isOrgLevel
/** /**
* Is Table Shared for Client * Is Table Shared for Client
* @param AD_Client_ID client * @param AD_Client_ID client
* @param AD_Table_ID table * @param AD_Table_ID table
* @return info or null * @return info or null
*/ */
private static Boolean isShared (int AD_Client_ID, int AD_Table_ID) private static Boolean isShared (int AD_Client_ID, int AD_Table_ID)
{ {
// Load // Load
if (s_shares.isEmpty()) if (s_shares.isEmpty())
{ {
String sql = "SELECT AD_Client_ID, AD_Table_ID, ShareType " String sql = "SELECT AD_Client_ID, AD_Table_ID, ShareType "
+ "FROM AD_ClientShare WHERE ShareType<>'x' AND IsActive='Y'"; + "FROM AD_ClientShare WHERE ShareType<>'x' AND IsActive='Y'";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
int Client_ID = rs.getInt(1); int Client_ID = rs.getInt(1);
int table_ID = rs.getInt(2); int table_ID = rs.getInt(2);
String key = Client_ID + "_" + table_ID; String key = Client_ID + "_" + table_ID;
String ShareType = rs.getString(3); String ShareType = rs.getString(3);
if (ShareType.equals(SHARETYPE_ClientAllShared)) if (ShareType.equals(SHARETYPE_ClientAllShared))
s_shares.put(key, Boolean.TRUE); s_shares.put(key, Boolean.TRUE);
else if (ShareType.equals(SHARETYPE_OrgNotShared)) else if (ShareType.equals(SHARETYPE_OrgNotShared))
s_shares.put(key, Boolean.FALSE); s_shares.put(key, Boolean.FALSE);
} }
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
if (s_shares.isEmpty()) // put in something if (s_shares.isEmpty()) // put in something
s_shares.put("0_0", Boolean.TRUE); s_shares.put("0_0", Boolean.TRUE);
} // load } // load
String key = AD_Client_ID + "_" + AD_Table_ID; String key = AD_Client_ID + "_" + AD_Table_ID;
return s_shares.get(key); return s_shares.get(key);
} // load } // load
/** Shared Info */ /** Shared Info */
private static CCache<String,Boolean> s_shares private static CCache<String,Boolean> s_shares
= new CCache<String,Boolean>("AD_ClientShare", 10, 120); // 2h = new CCache<String,Boolean>("AD_ClientShare", 10, 120); // 2h
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MClientShare.class); private static CLogger s_log = CLogger.getCLogger (MClientShare.class);
/************************************************************************** /**************************************************************************
* Default Constructor * Default Constructor
* @param ctx context * @param ctx context
* @param AD_ClientShare_ID id * @param AD_ClientShare_ID id
* @param trxName trx * @param trxName trx
*/ */
public MClientShare (Properties ctx, int AD_ClientShare_ID, String trxName) public MClientShare (Properties ctx, int AD_ClientShare_ID, String trxName)
{ {
super (ctx, AD_ClientShare_ID, trxName); super (ctx, AD_ClientShare_ID, trxName);
} // MClientShare } // MClientShare
/** /**
* Load Constructor * Load Constructor
* @param ctx context * @param ctx context
* @param rs result set * @param rs result set
* @param trxName trx * @param trxName trx
*/ */
public MClientShare (Properties ctx, ResultSet rs, String trxName) public MClientShare (Properties ctx, ResultSet rs, String trxName)
{ {
super (ctx, rs, trxName); super (ctx, rs, trxName);
} // MClientShare } // MClientShare
/** The Table */ /** The Table */
private MTable m_table = null; private MTable m_table = null;
/** /**
* Is Client Level Only * Is Client Level Only
* @return true if client level only (shared) * @return true if client level only (shared)
*/ */
public boolean isClientLevelOnly() public boolean isClientLevelOnly()
{ {
return getShareType().equals(SHARETYPE_ClientAllShared); return getShareType().equals(SHARETYPE_ClientAllShared);
} // isClientLevelOnly } // isClientLevelOnly
/** /**
* Is Org Level Only * Is Org Level Only
* @return true if org level only (not shared) * @return true if org level only (not shared)
*/ */
public boolean isOrgLevelOnly() public boolean isOrgLevelOnly()
{ {
return getShareType().equals(SHARETYPE_OrgNotShared); return getShareType().equals(SHARETYPE_OrgNotShared);
} // isOrgLevelOnly } // isOrgLevelOnly
/** /**
* Get Table model * Get Table model
* @return table * @return table
*/ */
public MTable getTable() public MTable getTable()
{ {
if (m_table == null) if (m_table == null)
m_table = MTable.get(getCtx(), getAD_Table_ID()); m_table = MTable.get(getCtx(), getAD_Table_ID());
return m_table; return m_table;
} // getTable } // getTable
/** /**
* Get Table Name * Get Table Name
* @return table name * @return table name
*/ */
public String getTableName() public String getTableName()
{ {
return getTable().getTableName(); return getTable().getTableName();
} // getTableName } // getTableName
/** /**
* After Save * After Save
* @param newRecord new * @param newRecord new
* @param success success * @param success success
* @return true * @return true
*/ */
protected boolean afterSave (boolean newRecord, boolean success) protected boolean afterSave (boolean newRecord, boolean success)
{ {
if (isActive()) if (isActive())
{ {
setDataToLevel(); setDataToLevel();
listChildRecords(); listChildRecords();
} }
return true; return true;
} // afterSave } // afterSave
/** /**
* Set Data To Level * Set Data To Level
* @return info * @return info
*/ */
public String setDataToLevel() public String setDataToLevel()
{ {
String info = "-"; String info = "-";
if (isClientLevelOnly()) if (isClientLevelOnly())
{ {
StringBuffer sql = new StringBuffer("UPDATE ") StringBuffer sql = new StringBuffer("UPDATE ")
.append(getTableName()) .append(getTableName())
.append(" SET AD_Org_ID=0 WHERE AD_Org_ID<>0 AND AD_Client_ID=?"); .append(" SET AD_Org_ID=0 WHERE AD_Org_ID<>0 AND AD_Client_ID=?");
int no = DB.executeUpdate(sql.toString(), getAD_Client_ID(), get_TrxName()); int no = DB.executeUpdate(sql.toString(), getAD_Client_ID(), get_TrxName());
info = getTableName() + " set to Shared #" + no; info = getTableName() + " set to Shared #" + no;
log.info(info); log.info(info);
} }
else if (isOrgLevelOnly()) else if (isOrgLevelOnly())
{ {
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM ") StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM ")
.append(getTableName()) .append(getTableName())
.append(" WHERE AD_Org_ID=0 WHERE AD_Client_ID=?"); .append(" WHERE AD_Org_ID=0 WHERE AD_Client_ID=?");
int no = DB.getSQLValue(get_TrxName(), sql.toString(), getAD_Client_ID()); int no = DB.getSQLValue(get_TrxName(), sql.toString(), getAD_Client_ID());
info = getTableName() + " Shared records #" + no; info = getTableName() + " Shared records #" + no;
log.info(info); log.info(info);
} }
return info; return info;
} // setDataToLevel } // setDataToLevel
/** /**
* List Child Tables * List Child Tables
* @return child tables * @return child tables
*/ */
public String listChildRecords() public String listChildRecords()
{ {
StringBuffer info = new StringBuffer(); StringBuffer info = new StringBuffer();
String sql = "SELECT AD_Table_ID, TableName " String sql = "SELECT AD_Table_ID, TableName "
+ "FROM AD_Table t " + "FROM AD_Table t "
+ "WHERE AccessLevel='3' AND IsView='N'" //jz put quote for typing + "WHERE AccessLevel=3 AND IsView='N'"
+ " AND EXISTS (SELECT * FROM AD_Column c " + " AND EXISTS (SELECT * FROM AD_Column c "
+ "WHERE t.AD_Table_ID=c.AD_Table_ID" + "WHERE t.AD_Table_ID=c.AD_Table_ID"
+ " AND c.IsParent='Y'" + " AND c.IsParent='Y'"
@ -242,50 +242,50 @@ public class MClientShare extends X_AD_ClientShare
+ "WHERE cc.IsKey='Y' AND cc.AD_Table_ID=?))"; + "WHERE cc.IsKey='Y' AND cc.AD_Table_ID=?))";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_Table_ID()); pstmt.setInt (1, getAD_Table_ID());
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
int AD_Table_ID = rs.getInt(1); int AD_Table_ID = rs.getInt(1);
String TableName = rs.getString(2); String TableName = rs.getString(2);
if (info.length() != 0) if (info.length() != 0)
info.append(", "); info.append(", ");
info.append(TableName); info.append(TableName);
} }
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
log.info(info.toString()); log.info(info.toString());
return info.toString(); return info.toString();
} // listChildRecords } // listChildRecords
/** /**
* Before Save * Before Save
* @param newRecord new * @param newRecord new
* @return true * @return true
*/ */
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
if (getAD_Org_ID() != 0) if (getAD_Org_ID() != 0)
setAD_Org_ID(0); setAD_Org_ID(0);
return true; return true;
} // beforeSave } // beforeSave
} // MClientShare } // MClientShare

View File

@ -3,52 +3,52 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. * * See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us * * 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 * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Cost Element Model * Cost Element Model
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MCostElement.java,v 1.2 2006/07/30 00:58:04 jjanke Exp $ * @version $Id: MCostElement.java,v 1.2 2006/07/30 00:58:04 jjanke Exp $
*/ */
public class MCostElement extends X_M_CostElement public class MCostElement extends X_M_CostElement
{ {
/** /**
* Get Material Cost Element or create it * Get Material Cost Element or create it
* @param po parent * @param po parent
* @param CostingMethod method * @param CostingMethod method
* @return cost element * @return cost element
*/ */
public static MCostElement getMaterialCostElement (PO po, String CostingMethod) public static MCostElement getMaterialCostElement (PO po, String CostingMethod)
{ {
if (CostingMethod == null || CostingMethod.length() == 0) if (CostingMethod == null || CostingMethod.length() == 0)
{ {
s_log.severe("No CostingMethod"); s_log.severe("No CostingMethod");
return null; return null;
} }
// //
MCostElement retValue = null; MCostElement retValue = null;
String sql = "SELECT * FROM M_CostElement WHERE AD_Client_ID=? AND CostingMethod=? ORDER BY AD_Org_ID"; String sql = "SELECT * FROM M_CostElement WHERE AD_Client_ID=? AND CostingMethod=? ORDER BY AD_Org_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, po.get_TrxName()); pstmt = DB.prepareStatement (sql, po.get_TrxName());
pstmt.setInt (1, po.getAD_Client_ID()); pstmt.setInt (1, po.getAD_Client_ID());
pstmt.setString(2, CostingMethod); pstmt.setString(2, CostingMethod);
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
@ -59,400 +59,400 @@ public class MCostElement extends X_M_CostElement
s_log.warning("More then one Material Cost Element for CostingMethod=" + CostingMethod); s_log.warning("More then one Material Cost Element for CostingMethod=" + CostingMethod);
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
if (retValue != null) if (retValue != null)
return retValue; return retValue;
// Create New // Create New
retValue = new MCostElement (po.getCtx(), 0, po.get_TrxName()); retValue = new MCostElement (po.getCtx(), 0, po.get_TrxName());
retValue.setClientOrg(po.getAD_Client_ID(), 0); retValue.setClientOrg(po.getAD_Client_ID(), 0);
String name = MRefList.getListName(po.getCtx(), COSTINGMETHOD_AD_Reference_ID, CostingMethod); String name = MRefList.getListName(po.getCtx(), COSTINGMETHOD_AD_Reference_ID, CostingMethod);
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
name = CostingMethod; name = CostingMethod;
retValue.setName(name); retValue.setName(name);
retValue.setCostElementType(COSTELEMENTTYPE_Material); retValue.setCostElementType(COSTELEMENTTYPE_Material);
retValue.setCostingMethod(CostingMethod); retValue.setCostingMethod(CostingMethod);
retValue.save(); retValue.save();
// //
return retValue; return retValue;
} // getMaterialCostElement } // getMaterialCostElement
/** /**
* Get first Material Cost Element * Get first Material Cost Element
* @param ctx context * @param ctx context
* @param CostingMethod costing method * @param CostingMethod costing method
* @return Cost Element or null * @return Cost Element or null
*/ */
public static MCostElement getMaterialCostElement(Properties ctx, String CostingMethod) public static MCostElement getMaterialCostElement(Properties ctx, String CostingMethod)
{ {
MCostElement retValue = null; MCostElement retValue = null;
String sql = "SELECT * FROM M_CostElement WHERE AD_Client_ID=? AND CostingMethod=? ORDER BY AD_Org_ID"; String sql = "SELECT * FROM M_CostElement WHERE AD_Client_ID=? AND CostingMethod=? ORDER BY AD_Org_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, Env.getAD_Client_ID(ctx)); pstmt.setInt (1, Env.getAD_Client_ID(ctx));
pstmt.setString(2, CostingMethod); pstmt.setString(2, CostingMethod);
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MCostElement (ctx, rs, null); retValue = new MCostElement (ctx, rs, null);
if (rs.next()) if (rs.next())
s_log.info("More then one Material Cost Element for CostingMethod=" + CostingMethod); s_log.info("More then one Material Cost Element for CostingMethod=" + CostingMethod);
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
return retValue; return retValue;
} // getMaterialCostElement } // getMaterialCostElement
/** /**
* Get active Material Cost Element for client * Get active Material Cost Element for client
* @param po parent * @param po parent
* @return cost element array * @return cost element array
*/ */
public static MCostElement[] getCostingMethods (PO po) public static MCostElement[] getCostingMethods (PO po)
{ {
ArrayList<MCostElement> list = new ArrayList<MCostElement>(); ArrayList<MCostElement> list = new ArrayList<MCostElement>();
String sql = "SELECT * FROM M_CostElement " String sql = "SELECT * FROM M_CostElement "
+ "WHERE AD_Client_ID=?" + "WHERE AD_Client_ID=?"
+ " AND IsActive='Y' AND CostElementType='M' AND CostingMethod IS NOT NULL"; + " AND IsActive='Y' AND CostElementType='M' AND CostingMethod IS NOT NULL";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, po.get_TrxName()); pstmt = DB.prepareStatement (sql, po.get_TrxName());
pstmt.setInt (1, po.getAD_Client_ID()); pstmt.setInt (1, po.getAD_Client_ID());
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add(new MCostElement (po.getCtx(), rs, po.get_TrxName())); list.add(new MCostElement (po.getCtx(), rs, po.get_TrxName()));
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
// //
MCostElement[] retValue = new MCostElement[list.size ()]; MCostElement[] retValue = new MCostElement[list.size ()];
list.toArray (retValue); list.toArray (retValue);
return retValue; return retValue;
} // getMaterialCostElement } // getMaterialCostElement
/** /**
* Get Cost Element from Cache * Get Cost Element from Cache
* @param ctx context * @param ctx context
* @param M_CostElement_ID id * @param M_CostElement_ID id
* @return Cost Element * @return Cost Element
*/ */
public static MCostElement get (Properties ctx, int M_CostElement_ID) public static MCostElement get (Properties ctx, int M_CostElement_ID)
{ {
Integer key = new Integer (M_CostElement_ID); Integer key = new Integer (M_CostElement_ID);
MCostElement retValue = (MCostElement) s_cache.get (key); MCostElement retValue = (MCostElement) s_cache.get (key);
if (retValue != null) if (retValue != null)
return retValue; return retValue;
retValue = new MCostElement (ctx, M_CostElement_ID, null); retValue = new MCostElement (ctx, M_CostElement_ID, null);
if (retValue.get_ID () != 0) if (retValue.get_ID () != 0)
s_cache.put (key, retValue); s_cache.put (key, retValue);
return retValue; return retValue;
} // get } // get
/** Cache */ /** Cache */
private static CCache<Integer,MCostElement> s_cache = new CCache<Integer,MCostElement>("M_CostElement", 20); private static CCache<Integer,MCostElement> s_cache = new CCache<Integer,MCostElement>("M_CostElement", 20);
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MCostElement.class); private static CLogger s_log = CLogger.getCLogger (MCostElement.class);
/************************************************************************** /**************************************************************************
* Standard Constructor * Standard Constructor
* @param ctx context * @param ctx context
* @param M_CostElement_ID id * @param M_CostElement_ID id
* @param trxName trx * @param trxName trx
*/ */
public MCostElement (Properties ctx, int M_CostElement_ID, String trxName) public MCostElement (Properties ctx, int M_CostElement_ID, String trxName)
{ {
super (ctx, M_CostElement_ID, trxName); super (ctx, M_CostElement_ID, trxName);
if (M_CostElement_ID == 0) if (M_CostElement_ID == 0)
{ {
// setName (null); // setName (null);
setCostElementType (COSTELEMENTTYPE_Material); setCostElementType (COSTELEMENTTYPE_Material);
setIsCalculated (false); setIsCalculated (false);
} }
} // MCostElement } // MCostElement
/** /**
* Load Constructor * Load Constructor
* @param ctx context * @param ctx context
* @param rs result set * @param rs result set
* @param trxName trx * @param trxName trx
*/ */
public MCostElement (Properties ctx, ResultSet rs, String trxName) public MCostElement (Properties ctx, ResultSet rs, String trxName)
{ {
super (ctx, rs, trxName); super (ctx, rs, trxName);
} // MCostElement } // MCostElement
/** /**
* Before Save * Before Save
* @param newRecord new * @param newRecord new
* @return true * @return true
*/ */
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
// Check Unique Costing Method // Check Unique Costing Method
if (COSTELEMENTTYPE_Material.equals(getCostElementType()) if (COSTELEMENTTYPE_Material.equals(getCostElementType())
&& (newRecord || is_ValueChanged("CostingMethod"))) && (newRecord || is_ValueChanged("CostingMethod")))
{ {
String sql = "SELECT MAX(COALESCE(M_CostElement_ID,0)) FROM M_CostElement " String sql = "SELECT COALESCE(MAX(M_CostElement_ID),0) FROM M_CostElement "
+ "WHERE AD_Client_ID=? AND CostingMethod=?"; + "WHERE AD_Client_ID=? AND CostingMethod=?";
int id = DB.getSQLValue(get_TrxName(), sql, getAD_Client_ID(), getCostingMethod()); int id = DB.getSQLValue(get_TrxName(), sql, getAD_Client_ID(), getCostingMethod());
if (id > 0 && id != get_ID()) if (id > 0 && id != get_ID())
{ {
log.saveError("AlreadyExists", Msg.getElement(getCtx(), "CostingMethod")); log.saveError("AlreadyExists", Msg.getElement(getCtx(), "CostingMethod"));
return false; return false;
} }
} }
// Maintain Calclated // Maintain Calclated
if (COSTELEMENTTYPE_Material.equals(getCostElementType())) if (COSTELEMENTTYPE_Material.equals(getCostElementType()))
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
if (cm == null || cm.length() == 0 if (cm == null || cm.length() == 0
|| COSTINGMETHOD_StandardCosting.equals(cm)) || COSTINGMETHOD_StandardCosting.equals(cm))
setIsCalculated(false); setIsCalculated(false);
else else
setIsCalculated(true); setIsCalculated(true);
} }
else else
{ {
if (isCalculated()) if (isCalculated())
setIsCalculated(false); setIsCalculated(false);
if (getCostingMethod() != null) if (getCostingMethod() != null)
setCostingMethod(null); setCostingMethod(null);
} }
if (getAD_Org_ID() != 0) if (getAD_Org_ID() != 0)
setAD_Org_ID(0); setAD_Org_ID(0);
return true; return true;
} // beforeSave } // beforeSave
/** /**
* Before Delete * Before Delete
* @return true if can be deleted * @return true if can be deleted
*/ */
protected boolean beforeDelete () protected boolean beforeDelete ()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
if (cm == null if (cm == null
|| !COSTELEMENTTYPE_Material.equals(getCostElementType())) || !COSTELEMENTTYPE_Material.equals(getCostElementType()))
return true; return true;
// Costing Methods on AS level // Costing Methods on AS level
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID()); MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID());
for (int i = 0; i < ass.length; i++) for (int i = 0; i < ass.length; i++)
{ {
if (ass[i].getCostingMethod().equals(getCostingMethod())) if (ass[i].getCostingMethod().equals(getCostingMethod()))
{ {
log.saveError("CannotDeleteUsed", Msg.getElement(getCtx(), "C_AcctSchema_ID") log.saveError("CannotDeleteUsed", Msg.getElement(getCtx(), "C_AcctSchema_ID")
+ " - " + ass[i].getName()); + " - " + ass[i].getName());
return false; return false;
} }
} }
// Costing Methods on PC level // Costing Methods on PC level
String sql = "SELECT M_Product_Category_ID FROM M_Product_Category_Acct WHERE AD_Client_ID=? AND CostingMethod=?"; String sql = "SELECT M_Product_Category_ID FROM M_Product_Category_Acct WHERE AD_Client_ID=? AND CostingMethod=?";
int M_Product_Category_ID = 0; int M_Product_Category_ID = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_Client_ID()); pstmt.setInt (1, getAD_Client_ID());
pstmt.setString (2, getCostingMethod()); pstmt.setString (2, getCostingMethod());
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
{ {
M_Product_Category_ID = rs.getInt(1); M_Product_Category_ID = rs.getInt(1);
} }
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
if (M_Product_Category_ID != 0) if (M_Product_Category_ID != 0)
{ {
log.saveError("CannotDeleteUsed", Msg.getElement(getCtx(), "M_Product_Category_ID") log.saveError("CannotDeleteUsed", Msg.getElement(getCtx(), "M_Product_Category_ID")
+ " (ID=" + M_Product_Category_ID + ")"); + " (ID=" + M_Product_Category_ID + ")");
return false; return false;
} }
return true; return true;
} // beforeDelete } // beforeDelete
/** /**
* Is this a Costing Method * Is this a Costing Method
* @return true if not Material cost or no costing method. * @return true if not Material cost or no costing method.
*/ */
public boolean isCostingMethod() public boolean isCostingMethod()
{ {
return COSTELEMENTTYPE_Material.equals(getCostElementType()) return COSTELEMENTTYPE_Material.equals(getCostElementType())
&& getCostingMethod() != null; && getCostingMethod() != null;
} // isCostingMethod } // isCostingMethod
/** /**
* Is Avg Invoice Costing Method * Is Avg Invoice Costing Method
* @return true if AverageInvoice * @return true if AverageInvoice
*/ */
public boolean isAverageInvoice() public boolean isAverageInvoice()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_AverageInvoice) && cm.equals(COSTINGMETHOD_AverageInvoice)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isAverageInvoice } // isAverageInvoice
/** /**
* Is Avg PO Costing Method * Is Avg PO Costing Method
* @return true if AveragePO * @return true if AveragePO
*/ */
public boolean isAveragePO() public boolean isAveragePO()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_AveragePO) && cm.equals(COSTINGMETHOD_AveragePO)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isAveragePO } // isAveragePO
/** /**
* Is FiFo Costing Method * Is FiFo Costing Method
* @return true if Fifo * @return true if Fifo
*/ */
public boolean isFifo() public boolean isFifo()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_Fifo) && cm.equals(COSTINGMETHOD_Fifo)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isFifo } // isFifo
/** /**
* Is Last Invoice Costing Method * Is Last Invoice Costing Method
* @return true if LastInvoice * @return true if LastInvoice
*/ */
public boolean isLastInvoice() public boolean isLastInvoice()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_LastInvoice) && cm.equals(COSTINGMETHOD_LastInvoice)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isLastInvoice } // isLastInvoice
/** /**
* Is Last PO Costing Method * Is Last PO Costing Method
* @return true if LastPOPrice * @return true if LastPOPrice
*/ */
public boolean isLastPOPrice() public boolean isLastPOPrice()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_LastPOPrice) && cm.equals(COSTINGMETHOD_LastPOPrice)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isLastPOPrice } // isLastPOPrice
/** /**
* Is LiFo Costing Method * Is LiFo Costing Method
* @return true if Lifo * @return true if Lifo
*/ */
public boolean isLifo() public boolean isLifo()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_Lifo) && cm.equals(COSTINGMETHOD_Lifo)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isLiFo } // isLiFo
/** /**
* Is Std Costing Method * Is Std Costing Method
* @return true if StandardCosting * @return true if StandardCosting
*/ */
public boolean isStandardCosting() public boolean isStandardCosting()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_StandardCosting) && cm.equals(COSTINGMETHOD_StandardCosting)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isStandardCosting } // isStandardCosting
/** /**
* Is User Costing Method * Is User Costing Method
* @return true if User Defined * @return true if User Defined
*/ */
public boolean isUserDefined() public boolean isUserDefined()
{ {
String cm = getCostingMethod(); String cm = getCostingMethod();
return cm != null return cm != null
&& cm.equals(COSTINGMETHOD_UserDefined) && cm.equals(COSTINGMETHOD_UserDefined)
&& COSTELEMENTTYPE_Material.equals(getCostElementType()); && COSTELEMENTTYPE_Material.equals(getCostElementType());
} // isAveragePO } // isAveragePO
/** /**
* String Representation * String Representation
* @return info * @return info
*/ */
public String toString () public String toString ()
{ {
StringBuffer sb = new StringBuffer ("MCostElement["); StringBuffer sb = new StringBuffer ("MCostElement[");
sb.append (get_ID ()) sb.append (get_ID ())
.append ("-").append (getName()) .append ("-").append (getName())
.append(",Type=").append(getCostElementType()) .append(",Type=").append(getCostElementType())
.append(",Method=").append(getCostingMethod()) .append(",Method=").append(getCostingMethod())
.append ("]"); .append ("]");
return sb.toString (); return sb.toString ();
} // toString } // toString
} // MCostElement } // MCostElement

File diff suppressed because it is too large Load Diff

View File

@ -3,224 +3,217 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. * * See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us * * 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 * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Organization Model * Organization Model
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MOrg.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $ * @version $Id: MOrg.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
*/ */
public class MOrg extends X_AD_Org public class MOrg extends X_AD_Org
{ {
/** /**
* Get Organizations Of Client * Get Organizations Of Client
* @param po persistent object * @param po persistent object
* @return array of orgs * @return array of orgs
*/ */
public static MOrg[] getOfClient (PO po) public static MOrg[] getOfClient (PO po)
{ {
ArrayList<MOrg> list = new ArrayList<MOrg>(); ArrayList<MOrg> list = new ArrayList<MOrg>();
String sql = "SELECT * FROM AD_Org WHERE AD_Client_ID=? ORDER BY Value"; String sql = "SELECT * FROM AD_Org WHERE AD_Client_ID=? ORDER BY Value";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, po.getAD_Client_ID()); pstmt.setInt (1, po.getAD_Client_ID());
ResultSet rs = pstmt.executeQuery (); ResultSet rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new MOrg (po.getCtx(), rs, null)); list.add (new MOrg (po.getCtx(), rs, null));
rs.close (); rs.close ();
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close (); pstmt.close ();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
MOrg[] retValue = new MOrg[list.size ()]; MOrg[] retValue = new MOrg[list.size ()];
list.toArray (retValue); list.toArray (retValue);
return retValue; return retValue;
} // getOfClient } // getOfClient
/** /**
* Get Org from Cache * Get Org from Cache
* @param ctx context * @param ctx context
* @param AD_Org_ID id * @param AD_Org_ID id
* @return MOrg * @return MOrg
*/ */
public static MOrg get (Properties ctx, int AD_Org_ID) public static MOrg get (Properties ctx, int AD_Org_ID)
{ {
Integer key = new Integer (AD_Org_ID); Integer key = new Integer (AD_Org_ID);
MOrg retValue = (MOrg) s_cache.get (key); MOrg retValue = (MOrg) s_cache.get (key);
if (retValue != null) if (retValue != null)
return retValue; return retValue;
retValue = new MOrg (ctx, AD_Org_ID, null); retValue = new MOrg (ctx, AD_Org_ID, null);
if (retValue.get_ID () != 0) if (retValue.get_ID () != 0)
s_cache.put (key, retValue); s_cache.put (key, retValue);
return retValue; return retValue;
} // get } // get
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MOrg.class); private static CLogger s_log = CLogger.getCLogger (MOrg.class);
/** Cache */ /** Cache */
private static CCache<Integer,MOrg> s_cache = new CCache<Integer,MOrg>("AD_Org", 20); private static CCache<Integer,MOrg> s_cache = new CCache<Integer,MOrg>("AD_Org", 20);
/************************************************************************** /**************************************************************************
* Standard Constructor * Standard Constructor
* @param ctx context * @param ctx context
* @param AD_Org_ID id * @param AD_Org_ID id
* @param trxName transaction * @param trxName transaction
*/ */
public MOrg (Properties ctx, int AD_Org_ID, String trxName) public MOrg (Properties ctx, int AD_Org_ID, String trxName)
{ {
super(ctx, AD_Org_ID, trxName); super(ctx, AD_Org_ID, trxName);
if (AD_Org_ID == 0) if (AD_Org_ID == 0)
{ {
// setValue (null); // setValue (null);
// setName (null); // setName (null);
setIsSummary (false); setIsSummary (false);
} }
} // MOrg } // MOrg
/** /**
* Load Constructor * Load Constructor
* @param ctx context * @param ctx context
* @param rs result set * @param rs result set
* @param trxName transaction * @param trxName transaction
*/ */
public MOrg (Properties ctx, ResultSet rs, String trxName) public MOrg (Properties ctx, ResultSet rs, String trxName)
{ {
super(ctx, rs, trxName); super(ctx, rs, trxName);
} // MOrg } // MOrg
/** /**
* Parent Constructor * Parent Constructor
* @param client client * @param client client
* @param name name * @param name name
*/ */
public MOrg (MClient client, String name) public MOrg (MClient client, String name)
{ {
this (client.getCtx(), 0, client.get_TrxName()); this (client.getCtx(), 0, client.get_TrxName());
setAD_Client_ID (client.getAD_Client_ID()); setAD_Client_ID (client.getAD_Client_ID());
setValue (name); setValue (name);
setName (name); setName (name);
} // MOrg } // MOrg
/** Org Info */ /** Org Info */
private MOrgInfo m_info = null; private MOrgInfo m_info = null;
/** Linked Business Partner */ /** Linked Business Partner */
private Integer m_linkedBPartner = null; private Integer m_linkedBPartner = null;
/** /**
* Get Org Info * Get Org Info
* @return Org Info * @return Org Info
*/ */
public MOrgInfo getInfo() public MOrgInfo getInfo()
{ {
if (m_info == null) if (m_info == null)
m_info = MOrgInfo.get (getCtx(), getAD_Org_ID()); m_info = MOrgInfo.get (getCtx(), getAD_Org_ID());
return m_info; return m_info;
} // getMOrgInfo } // getMOrgInfo
/** /**
* After Save * After Save
* @param newRecord new Record * @param newRecord new Record
* @param success save success * @param success save success
* @return success * @return success
*/ */
protected boolean afterSave (boolean newRecord, boolean success) protected boolean afterSave (boolean newRecord, boolean success)
{ {
if (!success) if (!success)
return success; return success;
if (newRecord) if (newRecord)
{ {
// Info // Info
m_info = new MOrgInfo (this); m_info = new MOrgInfo (this);
m_info.save(); m_info.save();
// Access // Access
MRoleOrgAccess.createForOrg (this); MRoleOrgAccess.createForOrg (this);
MRole.getDefault(getCtx(), true); // reload MRole.getDefault(getCtx(), true); // reload
// TreeNode // TreeNode
insert_Tree(MTree_Base.TREETYPE_Organization); insert_Tree(MTree_Base.TREETYPE_Organization);
} }
// Value/Name change // Value/Name change
if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name"))) if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name")))
{ {
MAccount.updateValueDescription(getCtx(), "AD_Org_ID=" + getAD_Org_ID(), get_TrxName()); MAccount.updateValueDescription(getCtx(), "AD_Org_ID=" + getAD_Org_ID(), get_TrxName());
if ("Y".equals(Env.getContext(getCtx(), "$Element_OT"))) if ("Y".equals(Env.getContext(getCtx(), "$Element_OT")))
MAccount.updateValueDescription(getCtx(), "AD_OrgTrx_ID=" + getAD_Org_ID(), get_TrxName()); MAccount.updateValueDescription(getCtx(), "AD_OrgTrx_ID=" + getAD_Org_ID(), get_TrxName());
} }
return true; return true;
} // afterSave } // afterSave
/** /**
* After Delete * After Delete
* @param success * @param success
* @return deleted * @return deleted
*/ */
protected boolean afterDelete (boolean success) protected boolean afterDelete (boolean success)
{ {
if (success) if (success)
delete_Tree(MTree_Base.TREETYPE_Organization); delete_Tree(MTree_Base.TREETYPE_Organization);
return success; return success;
} // afterDelete } // afterDelete
/** /**
* Get Linked BPartner * Get Linked BPartner
* @return C_BPartner_ID * @return C_BPartner_ID
*/ */
public int getLinkedC_BPartner_ID() public int getLinkedC_BPartner_ID()
{
return getLinkedC_BPartner_ID(null);
}
public int getLinkedC_BPartner_ID(String trxName)
{ {
if (m_linkedBPartner == null) if (m_linkedBPartner == null)
{ {
//jz int C_BPartner_ID = DB.getSQLValue(null, int C_BPartner_ID = DB.getSQLValue(null,
int C_BPartner_ID = DB.getSQLValue(trxName,
"SELECT C_BPartner_ID FROM C_BPartner WHERE AD_OrgBP_ID=?", "SELECT C_BPartner_ID FROM C_BPartner WHERE AD_OrgBP_ID=?",
getAD_Org_ID()); getAD_Org_ID());
if (C_BPartner_ID < 0) // not found = -1 if (C_BPartner_ID < 0) // not found = -1
C_BPartner_ID = 0; C_BPartner_ID = 0;
m_linkedBPartner = new Integer (C_BPartner_ID); m_linkedBPartner = new Integer (C_BPartner_ID);
} }
return m_linkedBPartner.intValue(); return m_linkedBPartner.intValue();
} // getLinkedC_BPartner_ID } // getLinkedC_BPartner_ID
} // MOrg } // MOrg

View File

@ -1,56 +1,55 @@
/****************************************************************************** /******************************************************************************
* Product: Compiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * * See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* For the text or an alternative of this public license, you may reach us * * You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
* or via info@compiere.org or http://www.compiere.org/license.html * *****************************************************************************/
*****************************************************************************/ package org.compiere.model;
package org.compiere.model;
import java.sql.*;
import java.sql.*; import java.util.*;
import java.util.*;
import java.util.logging.*;
import java.util.logging.*; import org.compiere.util.*;
import org.compiere.util.*;
/**
/** * Organization Info Model
* Organization Info Model *
* * @author Jorg Janke
* @author Jorg Janke * @version $Id: MOrgInfo.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $
* @version $Id: MOrgInfo.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $ */
*/ public class MOrgInfo extends X_AD_OrgInfo
public class MOrgInfo extends X_AD_OrgInfo {
{ /**
/** * Load Constructor
* Load Constructor * @param ctx context
* @param ctx context * @param AD_Org_ID id
* @param AD_Org_ID id * @return Org Info
* @return Org Info */
*/ public static MOrgInfo get (Properties ctx, int AD_Org_ID)
public static MOrgInfo get (Properties ctx, int AD_Org_ID) {
{ MOrgInfo retValue = null;
MOrgInfo retValue = null; String sql = "SELECT * FROM AD_OrgInfo WHERE AD_Org_ID=?";
String sql = "SELECT * FROM AD_OrgInfo WHERE AD_Org_ID=?"; PreparedStatement pstmt = null;
PreparedStatement pstmt = null; try
try {
{ pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, AD_Org_ID);
pstmt.setInt(1, AD_Org_ID); ResultSet rs = pstmt.executeQuery();
ResultSet rs = pstmt.executeQuery(); if (rs.next())
if (rs.next()) retValue = new MOrgInfo (ctx, rs, null);
retValue = new MOrgInfo (ctx, rs, null); rs.close();
rs.close(); pstmt.close();
pstmt.close(); pstmt = null;
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -58,42 +57,42 @@ public class MOrgInfo extends X_AD_OrgInfo
} }
try try
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
pstmt = null; pstmt = null;
} }
return retValue; return retValue;
} // get } // get
/** Static Logger */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MOrgInfo.class); private static CLogger s_log = CLogger.getCLogger (MOrgInfo.class);
/************************************************************************** /**************************************************************************
* Load Constructor * Load Constructor
* @param ctx context * @param ctx context
* @param rs result set * @param rs result set
* @param trxName transaction * @param trxName transaction
*/ */
public MOrgInfo (Properties ctx, ResultSet rs, String trxName) public MOrgInfo (Properties ctx, ResultSet rs, String trxName)
{ {
super(ctx, rs, trxName); super(ctx, rs, trxName);
} // MOrgInfo } // MOrgInfo
/** /**
* Organization constructor * Organization constructor
* @param org org * @param org org
*/ */
public MOrgInfo (MOrg org) public MOrgInfo (MOrg org)
{ {
super(org.getCtx(), 0, org.get_TrxName()); super(org.getCtx(), 0, org.get_TrxName());
setClientOrg(org); setClientOrg(org);
setDUNS ("?"); setDUNS ("?");
setTaxID ("?"); setTaxID ("?");
} // MOrgInfo } // MOrgInfo
} // MOrgInfo } // MOrgInfo

View File

@ -3,17 +3,18 @@
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * 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 * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. * * See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along * * 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., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us * * 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 * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.util; package org.compiere.util;
/** /**
@ -24,225 +25,240 @@ package org.compiere.util;
*/ */
public class AmtInWords_IN implements AmtInWords public class AmtInWords_IN implements AmtInWords
{ {
/** /**
* AmtInWords_IN * AmtInWords_IN
*/ */
public AmtInWords_IN () public AmtInWords_IN ()
{ {
super (); super ();
} // AmtInWords_IN } // AmtInWords_IN
private static final String[] basenumbers = new String[]{ private static final String[] basenumbers = new String[]{
"Nol", "Nol",
"Satu", "Satu",
"Dua", "Dua",
"Tiga", "Tiga",
"Empat", "Empat",
"Lima", "Lima",
"Enam", "Enam",
"Tujuh", "Tujuh",
"Delapan", "Delapan",
"Sembilan", "Sembilan",
"Sepuluh", "Sepuluh",
"Sebelas", "Sebelas",
}; };
private static final long POWER_THREE = 1000L; private static final long POWER_THREE = 1000L;
private static final long POWER_SIX = 1000000L; private static final long POWER_SIX = 1000000L;
private static final long POWER_NINE = 1000000000L; private static final long POWER_NINE = 1000000000L;
private static final long POWER_TWELVE = 1000000000000L; private static final long POWER_TWELVE = 1000000000000L;
private static final long POWER_FIFTEEN = 1000000000000000L; private static final long POWER_FIFTEEN = 1000000000000000L;
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (AmtInWords_IN.class);
//-------------------------- STATIC METHODS -------------------------- //-------------------------- STATIC METHODS --------------------------
/** /**
* Convenient method for {@link #sayNumber(StringBuffer, long)}. * Convenient method for {@link #sayNumber(StringBuffer, long)}.
* *
* @param number number to say * @param number number to say
* @return said number * @return said number
*/ */
public static String sayNumber(long number) { public static String sayNumber(double number) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
sayNumber(result, number); sayNumber(result, number);
result.append(" Rupiah");
return result.toString(); return result.toString();
} }
/** /**
* Say a number. This method will append the result to the given string buffer. * Say a number. This method will append the result to the given string buffer.
* *
* @param appendTo the string buffer * @param appendTo the string buffer
* @param number number to say * @param number number to say
* @return said number * @return said number
* @throws IllegalArgumentException if the number equals to {@link Long#MIN_VALUE} * @throws IllegalArgumentException if the number equals to {@link Long#MIN_VALUE}
*/ */
public static String sayNumber(StringBuffer appendTo, long number) public static String sayNumber(StringBuffer appendTo, double number)
throws IllegalArgumentException { throws IllegalArgumentException {
if (number == Long.MIN_VALUE) { if (number == Double.MIN_VALUE) {
throw new IllegalArgumentException("Out of range"); throw new IllegalArgumentException("Out of range");
} }
if (number < 0) { if (number < 0) {
appendTo.append("Minus "); appendTo.append("Minus ");
} }
long abs = Math.abs(number); double abs = Math.abs(number);
// s_log.warning("Debug=" + abs);
if (abs < POWER_THREE) { if (abs < POWER_THREE) {
saySimpleNumber(appendTo, (int) abs); saySimpleNumber(appendTo, (int) abs);
} else if (abs < 2000) {
int thousand = (int) (abs % POWER_THREE);
appendTo.append("Seribu ");
saySimpleNumber(appendTo, thousand);
} else if (abs < POWER_SIX) { } else if (abs < POWER_SIX) {
int thousand = (int) (abs % POWER_SIX / POWER_THREE); int thousand = (int) (abs % POWER_SIX / POWER_THREE);
saySimpleNumber(appendTo, thousand); saySimpleNumber(appendTo, thousand);
appendTo.append(" Ribu"); appendTo.append(" Ribu");
long remainder = abs - thousand * POWER_THREE; double remainder = abs - thousand * POWER_THREE;
if (remainder > 0) { if (remainder > 0) {
appendTo.append(' '); appendTo.append(' ');
sayNumber(appendTo, remainder); sayNumber(appendTo, remainder);
} }
} else if (abs < POWER_NINE) { } else if (abs < POWER_NINE) {
int million = (int) (abs % POWER_NINE / POWER_SIX); int million = (int) (abs % POWER_NINE / POWER_SIX);
saySimpleNumber(appendTo, million); saySimpleNumber(appendTo, million);
appendTo.append(" Juta"); appendTo.append(" Juta");
long remainder = abs - million * POWER_SIX; double remainder = abs - million * POWER_SIX;
if (remainder > 0) { if (remainder > 0) {
appendTo.append(' '); appendTo.append(' ');
sayNumber(appendTo, remainder); sayNumber(appendTo, remainder);
} }
} else if (abs < POWER_TWELVE) { } else if (abs < POWER_TWELVE) {
int billion = (int) (abs % POWER_TWELVE / POWER_NINE); int billion = (int) (abs % POWER_TWELVE / POWER_NINE);
saySimpleNumber(appendTo, billion); saySimpleNumber(appendTo, billion);
appendTo.append(" Milyar"); appendTo.append(" Milyar");
long remainder = abs - billion * POWER_NINE; double remainder = abs - billion * POWER_NINE;
if (remainder > 0) { if (remainder > 0) {
appendTo.append(' '); appendTo.append(' ');
sayNumber(appendTo, remainder); sayNumber(appendTo, remainder);
} }
} else if (abs < POWER_FIFTEEN) { } else if (abs < POWER_FIFTEEN) {
int trillion = (int) (abs % POWER_FIFTEEN / POWER_TWELVE); int trillion = (int) (abs % POWER_FIFTEEN / POWER_TWELVE);
saySimpleNumber(appendTo, trillion); saySimpleNumber(appendTo, trillion);
appendTo.append(" Trilyun"); appendTo.append(" Trilyun");
long remainder = abs - trillion * POWER_TWELVE; double remainder = abs - trillion * POWER_TWELVE;
if (remainder > 0) { if (remainder > 0) {
appendTo.append(' '); appendTo.append(' ');
sayNumber(appendTo, remainder); sayNumber(appendTo, remainder);
} }
} else { } else {
int log = (int) Math.floor(Math.log(abs) / Math.log(10)); appendTo.append("Lebih Dari Seribu Triliun");
// we want to break the number to several billions.
int logWhole = log - log % 12;
long powerWhole = (long) Math.pow(10, logWhole);
long part = abs / powerWhole;
sayNumber(appendTo, part);
appendTo.append(" Trilyun");
long remainder = abs - part * powerWhole;
if (remainder > 0) {
appendTo.append(' ');
sayNumber(appendTo, remainder);
}
} }
return appendTo.toString(); return appendTo.toString();
} }
static void saySimpleNumber(StringBuffer appendTo, int number) { static void saySimpleNumber(StringBuffer appendTo, int number) {
assert number < 1000 && number >= 0: "Must be between 0 and 1000"; assert number < 1000 && number >= 0: "Must be between 0 and 1000";
if (number < 12) { if (number < 12) {
assert number < 12 && number >= 0: "Must be between 0 and 11"; assert number < 12 && number >= 0: "Must be between 0 and 11";
appendTo.append(basenumbers[number]); appendTo.append(basenumbers[number]);
} else if (number < 20) { } else if (number < 20) {
assert number >= 12 && number <= 19: "Must be between 12 and 19"; assert number >= 12 && number <= 19: "Must be between 12 and 19";
int belasan = number % 10; int belasan = number % 10;
appendTo.append(basenumbers[belasan]); appendTo.append(basenumbers[belasan]);
appendTo.append(" Belas"); appendTo.append(" Belas");
} else if (number < 100) { } else if (number < 100) {
assert number >= 20 && number <= 99: "Must be between 20 and 99"; assert number >= 20 && number <= 99: "Must be between 20 and 99";
int puluhan = number / 10; int puluhan = number / 10;
appendTo.append(basenumbers[puluhan]); appendTo.append(basenumbers[puluhan]);
appendTo.append(" Puluh"); appendTo.append(" Puluh");
int remainder = number - puluhan * 10; int remainder = number - puluhan * 10;
if (remainder > 0) { if (remainder > 0) {
appendTo.append(' ');
saySimpleNumber(appendTo, remainder);
}
} else if (number < 200) {
assert number >= 100 && number <= 199: "Must be between 100 and 199";
appendTo.append("Seratus");
int remainder = number - 100;
if (remainder > 0) {
appendTo.append(' ');
saySimpleNumber(appendTo, remainder);
}
} else if (number != 0) {
assert number >= 200 && number <= 999: "Must be between 200 and 999";
int ratusan = number % 1000 / 100;
assert ratusan > 0 && ratusan < 10 :"1-9";
appendTo.append(basenumbers[ratusan]);
appendTo.append(" Ratus");
int remainder = number - ratusan * 100;
if (remainder > 0) {
appendTo.append(' '); appendTo.append(' ');
saySimpleNumber(appendTo, remainder); saySimpleNumber(appendTo, remainder);
} }
} else if (number < 200) { }
assert number >= 100 && number <= 199: "Must be between 100 and 199";
appendTo.append("Seratus");
int remainder = number - 100;
if (remainder > 0) {
appendTo.append(' ');
saySimpleNumber(appendTo, remainder);
}
} else if (number != 0) {
assert number >= 200 && number <= 999: "Must be between 200 and 999";
int ratusan = number % 1000 / 100;
assert ratusan > 0 && ratusan < 10 :"1-9";
appendTo.append(basenumbers[ratusan]);
appendTo.append(" Ratus");
int remainder = number - ratusan * 100;
if (remainder > 0) {
appendTo.append(' ');
saySimpleNumber(appendTo, remainder);
}
}
} }
/************************************************************************** /**************************************************************************
* Get Amount in Words * Get Amount in Words
* @param amount numeric amount (352.80) * @param amount numeric amount (352.80)
* @return amount in words (three*five*two 80/100) * @return amount in words (three*five*two 80/100)
* @throws Exception
*/ */
public String getAmtInWords (String amount) throws Exception public String getAmtInWords (String amount) throws Exception
{ {
if (amount == null) if (amount == null)
return amount; return amount;
// //
amount = amount.replaceAll (",", ""); StringBuffer result = new StringBuffer();
float numFloat = Float.parseFloat(amount);
long number = 0L; int pos = amount.lastIndexOf ('.');
number = (long)numFloat; String oldamt = amount;
return AmtInWords_IN.sayNumber(number); amount = amount.replaceAll (",", "");
String cents = pos > 0 ? oldamt.substring (pos + 1):null;
double numDouble = Double.parseDouble(amount);
sayNumber(result, numDouble);
if (cents != null)
{
result.append(" Koma ");
numDouble = Double.parseDouble(cents);
sayNumber(result, numDouble);
}
result.append(" Rupiah");
return result.toString();
} // getAmtInWords } // getAmtInWords
/** /**
* Test Print * Test Print
* @param amt amount * @param amt amount
*/ */
private void print (String amt) private void print (String amt)
{ {
try try
{ {
System.out.println(amt + " = " + getAmtInWords(amt)); System.out.println(amt + " = " + getAmtInWords(amt));
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} // print } // print
/** /**
* Test * Test
* @param args ignored * @param args ignored
*/ */
public static void main (String[] args) public static void main (String[] args)
{ {
AmtInWords_IN aiw = new AmtInWords_IN(); AmtInWords_IN aiw = new AmtInWords_IN();
// I doubt decimal support for rupiah is still needed ;) aiw.print ("0.00");
aiw.print (".23"); aiw.print ("0.23");
aiw.print ("948,776,477,778,778,778"); aiw.print ("1.23876787");
aiw.print ("1.79"); aiw.print ("11.45");
// aiw.print ("12.345"); aiw.print ("121.45");
// aiw.print ("123.45"); aiw.print ("1231.56");
// aiw.print ("1234.56"); aiw.print ("10341.78");
// aiw.print ("12345.78"); aiw.print ("12341.78");
// aiw.print ("123457.89"); aiw.print ("123451.89");
aiw.print ("1,234,578.90"); aiw.print ("12234571.90");
aiw.print ("123234571.90");
aiw.print ("1987234571.90");
aiw.print ("11123234571.90");
aiw.print ("123123234571.90");
aiw.print ("2123123234571.90");
aiw.print ("23,123,123,234,571.90");
aiw.print ("100,000,000,000,000.90");
aiw.print ("111,111,111");
aiw.print ("222,222,222,222,222");
aiw.print ("222,222,222,222,222,222,222");
} // main } // main
} // AmtInWords_IN } // AmtInWords_IN

View File

@ -170,6 +170,9 @@ public class CLogger extends Logger implements Serializable
public boolean saveWarning (String AD_Message, String message) public boolean saveWarning (String AD_Message, String message)
{ {
s_lastWarning = new ValueNamePair (AD_Message, message); s_lastWarning = new ValueNamePair (AD_Message, message);
// print it
if (true) // issueError
warning(AD_Message + " - " + message);
return true; return true;
} // saveWarning } // saveWarning

View File

@ -1066,6 +1066,113 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
throw new RuntimeException (ex); throw new RuntimeException (ex);
} }
} // remote_executeUpdate } // remote_executeUpdate
public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length)
throws SQLException
{
}
//vpj-cd add support java 6
public void setBinaryStream(int parameterIndex, java.io.InputStream x,
long length) throws SQLException
{
}
public void setCharacterStream(int parameterIndex,
java.io.Reader reader,
long length) throws SQLException
{
}
public void setAsciiStream(int parameterIndex, java.io.InputStream x)
throws SQLException
{
}
public void setBinaryStream(int parameterIndex, java.io.InputStream x)
throws SQLException
{
}
public void setCharacterStream(int parameterIndex,
java.io.Reader reader) throws SQLException
{
}
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
{
}
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
{
}
public void setClob(int parameterIndex, Reader reader)
throws SQLException
{
}
public void setClob(int parameterIndex, Reader reader, long length)
throws SQLException
{
}
public void setNClob(int parameterIndex, NClob value) throws SQLException
{
}
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException
{
}
public void setNClob(int parameterIndex, Reader reader)
throws SQLException
{
}
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException
{
}
public void setBlob(int parameterIndex, InputStream inputStream)
throws SQLException
{
}
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
{
}
public void setNString(int parameterIndex, String value) throws SQLException
{
}
public void setRowId(int parameterIndex, RowId x) throws SQLException{}
} // CPreparedStatement } // CPreparedStatement

View File

@ -905,5 +905,15 @@ public class CStatement implements Statement
} }
return rowSet; return rowSet;
} // remote_getRowSet } // remote_getRowSet
public boolean isPoolable() throws SQLException{ return false;}
public void setPoolable(boolean a) throws SQLException{};
public boolean isClosed() throws SQLException{ return false;}
public boolean isWrapperFor(java.lang.Class c) throws SQLException{ return false;}
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
} // CStatement } // CStatement

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff