[ 1754519 ] Refactoring of PackInHandler

- Further stabilization and refactoring after testing with the Fixed Asset package.
[ 1759822 ] 2Pack - few bugs fixed, including NASTY one
- many thanks for Igor's contributed fixed.

* Other
- Added display of AdempiereProperties in Preference window's info tab.
- Added data conversion from string to integer in PO.setValue
- Added msequence existence check in Mtable.afterSave
- Fixed ddl generation issue for column with display type button
This commit is contained in:
Heng Sin Low 2007-07-25 14:04:39 +00:00
parent 888d3a0362
commit 4b2f7a14ac
34 changed files with 758 additions and 417 deletions

View File

@ -22,6 +22,7 @@ import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
@ -92,26 +93,26 @@ public abstract class AbstractElementHandler implements ElementHandler {
id = MSequence.getNextID (Env.getAD_Client_ID(ctx), "AD_Package_Imp_Detail", getTrxName(ctx)); id = MSequence.getNextID (Env.getAD_Client_ID(ctx), "AD_Package_Imp_Detail", getTrxName(ctx));
StringBuffer sqlB = new StringBuffer ("Insert INTO AD_Package_Imp_Detail" StringBuffer sqlB = new StringBuffer ("Insert INTO AD_Package_Imp_Detail")
+ "(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, " .append( "(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, " )
+ "AD_PACKAGE_IMP_DETAIL_ID, AD_PACKAGE_IMP_ID, TYPE, NAME," .append( "AD_PACKAGE_IMP_DETAIL_ID, AD_PACKAGE_IMP_ID, TYPE, NAME," )
+ " ACTION, SUCCESS, AD_ORIGINAL_ID, AD_BACKUP_ID, TABLENAME, AD_TABLE_ID)" .append( " ACTION, SUCCESS, AD_ORIGINAL_ID, AD_BACKUP_ID, TABLENAME, AD_TABLE_ID)" )
+ "VALUES(" .append( "VALUES(" )
+ " "+ Env.getAD_Client_ID(ctx) .append( " "+ Env.getAD_Client_ID(ctx) )
+ ", "+ Env.getAD_Org_ID(ctx) .append( ", "+ Env.getAD_Org_ID(ctx) )
+ ", "+ Env.getAD_User_ID(ctx) .append( ", "+ Env.getAD_User_ID(ctx) )
+ ", "+ Env.getAD_User_ID(ctx) .append( ", "+ Env.getAD_User_ID(ctx) )
+ ", " + id .append( ", " + id )
+ ", " + getPackageImpId(ctx) .append( ", " + getPackageImpId(ctx) )
+ ", '" + objectType .append( ", '" + objectType )
+ "', '" + objectName .append( "', '" + objectName )
+ "', '" + objectStatus .append( "', '" + objectStatus )
+ "', 'Success'" .append( "', 'Success'" )
+ ", "+objectID .append( ", "+objectID )
+ ", "+objectIDBackup .append( ", "+objectIDBackup )
+ ", '"+tableName .append( ", '"+tableName )
+ "', "+AD_Table_ID .append( "', "+AD_Table_ID )
+")"); .append(")");
int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx)); int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx));
if (no == -1) if (no == -1)
log.info("Insert to import detail failed"); log.info("Insert to import detail failed");
@ -131,26 +132,26 @@ public abstract class AbstractElementHandler implements ElementHandler {
id = MSequence.getNextID (Env.getAD_Client_ID(ctx), "AD_Package_Imp_Detail", getTrxName(ctx)); id = MSequence.getNextID (Env.getAD_Client_ID(ctx), "AD_Package_Imp_Detail", getTrxName(ctx));
StringBuffer sqlB = new StringBuffer ("Insert INTO AD_Package_Imp_Detail" StringBuffer sqlB = new StringBuffer ("Insert INTO AD_Package_Imp_Detail")
+ "(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, " .append( "(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, " )
+ "AD_PACKAGE_IMP_DETAIL_ID, AD_PACKAGE_IMP_ID, TYPE, NAME," .append( "AD_PACKAGE_IMP_DETAIL_ID, AD_PACKAGE_IMP_ID, TYPE, NAME," )
+ " ACTION, SUCCESS, AD_ORIGINAL_ID, AD_BACKUP_ID, TABLENAME, AD_TABLE_ID)" .append( " ACTION, SUCCESS, AD_ORIGINAL_ID, AD_BACKUP_ID, TABLENAME, AD_TABLE_ID)" )
+ "VALUES(" .append( "VALUES(" )
+ " "+ Env.getAD_Client_ID(ctx) .append( " "+ Env.getAD_Client_ID(ctx) )
+ ", "+ Env.getAD_Org_ID(ctx) .append( ", "+ Env.getAD_Org_ID(ctx) )
+ ", "+ Env.getAD_User_ID(ctx) .append( ", "+ Env.getAD_User_ID(ctx) )
+ ", "+ Env.getAD_User_ID(ctx) .append( ", "+ Env.getAD_User_ID(ctx) )
+ ", " + id .append( ", " + id )
+ ", " + getPackageImpId(ctx) .append( ", " + getPackageImpId(ctx) )
+ ", '" + objectType .append( ", '" + objectType )
+ "', '" + objectName .append( "', '" + objectName )
+ "', '" + objectStatus .append( "', '" + objectStatus )
+ "', 'Failure'" .append( "', 'Failure'" )
+ ", "+objectID .append( ", "+objectID )
+ ", "+objectIDBackup .append( ", "+objectIDBackup )
+ ", '"+tableName .append( ", '"+tableName )
+ "', "+AD_Table_ID .append( "', "+AD_Table_ID )
+")"); .append( ")");
int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx)); int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx));
if (no == -1) if (no == -1)
log.info("Insert to import detail failed"); log.info("Insert to import detail failed");
@ -245,23 +246,23 @@ public abstract class AbstractElementHandler implements ElementHandler {
else else
;//Ignore ;//Ignore
StringBuffer sqlB = new StringBuffer ("Insert INTO AD_Package_Imp_Backup" StringBuffer sqlB = new StringBuffer ("Insert INTO AD_Package_Imp_Backup")
+ "(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, " .append( "(AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, " )
+ "AD_PACKAGE_IMP_BACKUP_ID, AD_PACKAGE_IMP_DETAIL_ID, AD_PACKAGE_IMP_ID," .append( "AD_PACKAGE_IMP_BACKUP_ID, AD_PACKAGE_IMP_DETAIL_ID, AD_PACKAGE_IMP_ID," )
+ " AD_TABLE_ID, AD_COLUMN_ID, AD_REFERENCE_ID, COLVALUE)" .append( " AD_TABLE_ID, AD_COLUMN_ID, AD_REFERENCE_ID, COLVALUE)" )
+ "VALUES(" .append( "VALUES(" )
+ " "+ Env.getAD_Client_ID(ctx) .append( " "+ Env.getAD_Client_ID(ctx) )
+ ", "+ Env.getAD_Org_ID(ctx) .append( ", "+ Env.getAD_Org_ID(ctx) )
+ ", "+ Env.getAD_User_ID(ctx) .append( ", "+ Env.getAD_User_ID(ctx) )
+ ", "+ Env.getAD_User_ID(ctx) .append( ", "+ Env.getAD_User_ID(ctx) )
+ ", " + idBackup .append( ", " + idBackup )
+ ", " + idDetail .append( ", " + idDetail )
+ ", " + getPackageImpId(ctx) .append( ", " + getPackageImpId(ctx) )
+ ", " + tableID .append( ", " + tableID )
+ ", " + columnID .append( ", " + columnID )
+ ", " + referenceID .append( ", " + referenceID )
+ ", '" + (colValue != null ? colValue : from.get_Value(i)) .append( ", '" + (colValue != null ? colValue : from.get_Value(i)) )
+"')"); .append( "')");
int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx)); int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx));
if (no == -1) if (no == -1)
@ -333,13 +334,11 @@ public abstract class AbstractElementHandler implements ElementHandler {
} }
source.close(); source.close();
target.close(); target.close();
//System.out.println("Successfully copied " + byteCount + " bytes.");
System.out.println("Successfully copied " + byteCount + " bytes.");
} }
catch (Exception e) { catch (Exception e) {
System.out.println("Error occurred while copying. "+ byteCount + " bytes copied."); System.out.println("Error occurred while copying. "+ byteCount + " bytes copied.");
System.out.println(e.toString()); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
success = -1; success = -1;
} }
@ -372,5 +371,5 @@ public abstract class AbstractElementHandler implements ElementHandler {
protected String getPackageDirectory(Properties ctx) { protected String getPackageDirectory(Properties ctx) {
return Env.getContext(ctx, "PackageDirectory"); return Env.getContext(ctx, "PackageDirectory");
} }
} }

View File

@ -32,6 +32,10 @@ public class Element {
public Attributes attributes; public Attributes attributes;
//defer for later reprocessing //defer for later reprocessing
public boolean defer = false; public boolean defer = false;
//parent element
public Element parent;
//resolved db recordid, store for reference by child element
public int recordId = 0;
/** /**
* @param uri * @param uri

View File

@ -44,7 +44,11 @@ public class IDFinder {
*/ */
public static int get_ID (String tableName, String name, int AD_Client_ID, String trxName) { public static int get_ID (String tableName, String name, int AD_Client_ID, String trxName) {
int id = 0; int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where name=?"); StringBuffer sqlB = new StringBuffer ("select ")
.append(tableName)
.append("_ID from ")
.append(tableName)
.append(" where name=?");
if (!tableName.startsWith("AD_")) if (!tableName.startsWith("AD_"))
sqlB = sqlB.append(" and AD_Client_ID=?"); sqlB = sqlB.append(" and AD_Client_ID=?");
@ -77,17 +81,25 @@ public class IDFinder {
*/ */
public static int get_IDWithColumn (String tableName, String columnName, Object value, int AD_Client_ID, String trxName) { public static int get_IDWithColumn (String tableName, String columnName, Object value, int AD_Client_ID, String trxName) {
int id = 0; int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where UPPER("+columnName+")=?"); StringBuffer sqlB = new StringBuffer ("select ")
.append(tableName)
.append("_ID from ")
.append(tableName)
.append(" where ")
.append(columnName)
.append(" = ?");
//StringBuffer sqlC = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where "+columnName+"="+value.toString()); //StringBuffer sqlC = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where "+columnName+"="+value.toString());
if (!tableName.startsWith("AD_")) if (!tableName.startsWith("AD_"))
sqlB = sqlB.append(" and AD_Client_ID=?"); sqlB = sqlB.append(" and AD_Client_ID=?");
//here! //here!
sqlB = sqlB.append(" Order By "+tableName+"_ID"); sqlB = sqlB.append(" Order By ")
.append(tableName)
.append("_ID");
try { try {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName); PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
if (value instanceof String) if (value instanceof String)
pstmt.setString(1, ((String)value).toUpperCase()); pstmt.setString(1, (String)value);
else if (value instanceof Integer) else if (value instanceof Integer)
pstmt.setInt(1, ((Integer)value).intValue()); pstmt.setInt(1, ((Integer)value).intValue());
if (!tableName.startsWith("AD_")) if (!tableName.startsWith("AD_"))
@ -117,13 +129,22 @@ public class IDFinder {
*/ */
public static int get_IDWithMaster (String tableName, String name, String tableNameMaster, String nameMaster, String trxName) { public static int get_IDWithMaster (String tableName, String name, String tableNameMaster, String nameMaster, String trxName) {
int id = 0; int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where UPPER(name)=? and " StringBuffer sqlB = new StringBuffer ("select ")
+ tableNameMaster+"_ID = (select "+tableNameMaster+"_ID from "+tableNameMaster+" where UPPER(name)=?)"); .append(tableName)
.append("_ID from ")
.append(tableName)
.append(" where name = ? and ")
.append(tableNameMaster)
.append("_ID = (select ")
.append(tableNameMaster)
.append("_ID from ")
.append(tableNameMaster)
.append(" where name = ?)");
try { try {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName); PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
pstmt.setString(1, name.toUpperCase()); pstmt.setString(1, name);
pstmt.setString(2, nameMaster.toUpperCase()); pstmt.setString(2, nameMaster);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
id = rs.getInt(1); id = rs.getInt(1);
@ -149,8 +170,14 @@ public class IDFinder {
public static int get_IDWithMasterAndColumn (String tableName, String columnName, String name, String tableNameMaster, int masterID, String trxName) { public static int get_IDWithMasterAndColumn (String tableName, String columnName, String name, String tableNameMaster, int masterID, String trxName) {
int id = 0; int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where UPPER("+columnName+")=? and " StringBuffer sqlB = new StringBuffer ("select ")
+ tableNameMaster+"_ID =?"); .append(tableName)
.append("_ID from ")
.append(tableName)
.append(" where ")
.append(columnName)
.append(" = ? and ")
.append(tableNameMaster+"_ID =?");
//StringBuffer sqlC = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where "+columnName+"="+name+" and " //StringBuffer sqlC = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where "+columnName+"="+name+" and "
// + tableNameMaster+"_ID ="+masterID); // + tableNameMaster+"_ID ="+masterID);
log.info(sqlB.toString()); log.info(sqlB.toString());
@ -158,7 +185,7 @@ public class IDFinder {
try { try {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName); PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
pstmt.setString(1, name.toUpperCase()); pstmt.setString(1, name);
pstmt.setInt(2, masterID); pstmt.setInt(2, masterID);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
@ -184,8 +211,13 @@ public class IDFinder {
*/ */
public static int get_IDWithMaster (String tableName, String name, String tableNameMaster, int masterID, String trxName) { public static int get_IDWithMaster (String tableName, String name, String tableNameMaster, int masterID, String trxName) {
int id = 0; int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where name=? and " StringBuffer sqlB = new StringBuffer ("select ")
+ tableNameMaster+"_ID=?"); .append(tableName)
.append("_ID from ")
.append(tableName)
.append(" where name=? and ")
.append(tableNameMaster)
.append("_ID=?");
try { try {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName); PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
@ -215,13 +247,17 @@ public class IDFinder {
*/ */
public static int getIDbyName (String tableName, String name, int AD_Client_ID, String trxName) { public static int getIDbyName (String tableName, String name, int AD_Client_ID, String trxName) {
int id = 0; int id = 0;
String sql = "SELECT "+tableName+"_ID " StringBuffer sql = new StringBuffer("SELECT ")
+ "FROM "+tableName+" " .append(tableName)
+ "WHERE name=?"; .append("_ID ")
.append("FROM ")
.append(tableName)
.append(" ")
.append("WHERE name=?");
if (!tableName.startsWith("AD_")) if (!tableName.startsWith("AD_"))
sql = sql + " AND AD_Client_ID=?"; sql.append(" AND AD_Client_ID=?");
try { try {
PreparedStatement pstmt = DB.prepareStatement(sql, trxName); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), trxName);
pstmt.setString(1, name); pstmt.setString(1, name);
if (!tableName.startsWith("AD_")) if (!tableName.startsWith("AD_"))
pstmt.setInt(2, AD_Client_ID); pstmt.setInt(2, AD_Client_ID);

View File

@ -20,6 +20,8 @@ package org.adempiere.pipo;
import java.io.File; import java.io.File;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import org.compiere.Adempiere;
import org.compiere.process.ProcessInfoParameter; import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess; import org.compiere.process.SvrProcess;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -29,7 +31,10 @@ import org.compiere.util.CLogMgt;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Trx;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.logging.*; import java.util.logging.*;
@ -42,10 +47,59 @@ public class PackIn extends SvrProcess {
/** Logger */ /** Logger */
private CLogger log = CLogger.getCLogger("PackIn"); private CLogger log = CLogger.getCLogger("PackIn");
public static String m_UpdateMode = "false"; //update system maintain dictionary, default to true
public static String m_UpdateMode = "true";
public static String m_Database = "Oracle"; public static String m_Database = "Oracle";
public static String m_Package_Dir = null; public static String m_Package_Dir = null;
public int p_PackIn_ID = 0; public int p_PackIn_ID = 0;
private Map<String,Integer> tableCache = new HashMap<String,Integer>();
private Map<String,Integer> columnCache = new HashMap<String,Integer>();
/**
* add to table id cache
* @param tableName
* @param tableId
*/
public void addTable(String tableName, int tableId) {
tableCache.put(tableName, tableId);
}
/**
* Find table id from cache
* @param tableName
* @return tableId
*/
public int getTableId(String tableName) {
if (tableCache.containsKey(tableName))
return tableCache.get(tableName).intValue();
else
return 0;
}
/**
* add to column id cache
* @param tableName
* @param columnName
* @param columnId
*/
public void addColumn(String tableName, String columnName, int columnId) {
columnCache.put(tableName+"."+columnName, columnId);
}
/**
* find column id from cache
* @param tableName
* @param columnName
* @return column id
*/
public int getColumnId(String tableName, String columnName) {
String key = tableName+"."+columnName;
if (columnCache.containsKey(key))
return columnCache.get(key).intValue();
else
return 0;
}
protected void prepare() { protected void prepare() {
p_PackIn_ID = getRecord_ID(); p_PackIn_ID = getRecord_ID();
@ -61,7 +115,7 @@ public class PackIn extends SvrProcess {
* xml file to read * xml file to read
* @return status message * @return status message
*/ */
public String importXML(String fileName, Properties ctx, String trxName) { public String importXML(String fileName, Properties ctx, String trxName) throws Exception {
log.info("importXML:" + fileName); log.info("importXML:" + fileName);
File in = new File(fileName); File in = new File(fileName);
if (!in.exists()) { if (!in.exists()) {
@ -87,7 +141,7 @@ public class PackIn extends SvrProcess {
return "OK."; return "OK.";
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "importXML:", e); log.log(Level.SEVERE, "importXML:", e);
return e.toString(); throw e;
} }
} }
@ -97,21 +151,22 @@ public class PackIn extends SvrProcess {
* @return "" * @return ""
* *
*/ */
protected String doIt() { protected String doIt() throws Exception {
X_AD_Package_Imp_Proc adPackageImp = new X_AD_Package_Imp_Proc(getCtx(), X_AD_Package_Imp_Proc adPackageImp = new X_AD_Package_Imp_Proc(getCtx(),
p_PackIn_ID, null); p_PackIn_ID, null);
// Create Target directory if required // Create Target directory if required
String fileSeparator = null; String packageDirectory = adPackageImp.getAD_Package_Dir();
File tempfile = new File(""); if (packageDirectory == null || packageDirectory.trim().length() == 0) {
fileSeparator = tempfile.separator; packageDirectory = Adempiere.getAdempiereHome();
File targetDir = new File(adPackageImp.getAD_Package_Dir() + fileSeparator }
File targetDir = new File( packageDirectory + File.separator
+ "packages"); + "packages");
if (!targetDir.exists()) { if (!targetDir.exists()) {
boolean success = (new File(adPackageImp.getAD_Package_Dir() boolean success = (new File(packageDirectory
+ fileSeparator + "packages")).mkdirs(); + File.separator + "packages")).mkdirs();
if (!success) { if (!success) {
log.info("Target directory creation failed"); log.info("Target directory creation failed");
} }
@ -123,26 +178,26 @@ public class PackIn extends SvrProcess {
String PackageName = CreateZipFile.getParentDir(zipFilepath); String PackageName = CreateZipFile.getParentDir(zipFilepath);
CreateZipFile.unpackFile(zipFilepath, targetDir); CreateZipFile.unpackFile(zipFilepath, targetDir);
String dict_file = adPackageImp.getAD_Package_Dir() + fileSeparator String dict_file = packageDirectory + File.separator
+ "packages" + fileSeparator + PackageName + fileSeparator + "packages" + File.separator + PackageName + File.separator
+ "dict" + fileSeparator + "PackOut.xml"; + "dict" + File.separator + "PackOut.xml";
log.info("dict file->" + dict_file); log.info("dict file->" + dict_file);
PackIn impXML = new PackIn(); PackIn packIn = new PackIn();
if (adPackageImp.isAD_Override_Dict() == true) if (adPackageImp.isAD_Override_Dict() == true)
impXML.m_UpdateMode = "true"; packIn.m_UpdateMode = "true";
else else
impXML.m_UpdateMode = "false"; packIn.m_UpdateMode = "false";
impXML.m_Package_Dir = adPackageImp.getAD_Package_Dir() + fileSeparator packIn.m_Package_Dir = packageDirectory + File.separator
+ "packages" + fileSeparator + PackageName + fileSeparator; + "packages" + File.separator + PackageName + File.separator;
if (DB.isOracle()) if (DB.isOracle())
impXML.m_Database = "Oracle"; packIn.m_Database = "Oracle";
else if (DB.isPostgreSQL()) else if (DB.isPostgreSQL())
impXML.m_Database = "PostgreSQL"; packIn.m_Database = "PostgreSQL";
// call XML Handler // call XML Handler
impXML.importXML(dict_file, getCtx(), get_TrxName()); String msg = packIn.importXML(dict_file, getCtx(), get_TrxName());
// Generate Model Classes // Generate Model Classes
// globalqss - don't call Generate Model must be done manual // globalqss - don't call Generate Model must be done manual
@ -151,7 +206,7 @@ public class PackIn extends SvrProcess {
// "org.compiere.model","'U'"}; // "org.compiere.model","'U'"};
// org.compiere.util.GenerateModel.main(args) ; // org.compiere.util.GenerateModel.main(args) ;
return "Finish Process"; return msg;
} // doIt } // doIt
/*************************************************************************** /***************************************************************************
@ -176,7 +231,7 @@ public class PackIn extends SvrProcess {
Ini.setProperty(Ini.P_ADEMPIERESYS, true); Ini.setProperty(Ini.P_ADEMPIERESYS, true);
} }
PackIn impXML = new PackIn(); PackIn packIn = new PackIn();
// org.compiere.Compiere.startupEnvironment(true); // org.compiere.Compiere.startupEnvironment(true);
// Force connection if there are enough parameters. Else we work with // Force connection if there are enough parameters. Else we work with
// Compiere.properties // Compiere.properties
@ -185,7 +240,7 @@ public class PackIn extends SvrProcess {
// Integer.valueOf(args[2]).intValue(), args[5], args[3], args[4]); // Integer.valueOf(args[2]).intValue(), args[5], args[3], args[4]);
CConnection cc = CConnection.get(); CConnection cc = CConnection.get();
// System.out.println("DB Connect String1:"+cc.getDbName()); // System.out.println("DB Connect String1:"+cc.getDbName());
impXML.m_Database = cc.getType(); packIn.m_Database = cc.getType();
DB.setDBTarget(cc); DB.setDBTarget(cc);
} }
@ -226,10 +281,21 @@ public class PackIn extends SvrProcess {
CLogMgt.setLevel(logLevel); CLogMgt.setLevel(logLevel);
CLogMgt.setLoggerLevel(logLevel, null); CLogMgt.setLoggerLevel(logLevel, null);
// impXML.setUpdateMode(args[7]); if (args.length >= 8)
impXML.m_UpdateMode = args[7]; packIn.m_UpdateMode = args[7];
impXML.importXML(file, Env.getCtx(), null); String trxName = Trx.createTrxName("PackIn");
try {
packIn.importXML(file, Env.getCtx(), trxName);
Trx trx = Trx.get(trxName, false);
if (trx != null)
trx.commit(true);
} catch (Exception e) {
System.out.println("Import Failed: " + e.getLocalizedMessage());
Trx trx = Trx.get(trxName, false);
if (trx != null)
trx.rollback();
}
System.exit(0); System.exit(0);
} // main } // main

View File

@ -326,7 +326,7 @@ public class PackInHandler extends DefaultHandler {
.append( ", '" + atts.getValue("CompVer") ) .append( ", '" + atts.getValue("CompVer") )
.append( "', '" + atts.getValue("Version") ) .append( "', '" + atts.getValue("Version") )
.append( "', '" + atts.getValue("DataBase") ) .append( "', '" + atts.getValue("DataBase") )
.append( "', '" + atts.getValue("Description").replaceAll("'","''").replaceAll(",","") ) .append( "', '" + atts.getValue("Description").replaceAll("'","''"))
.append( "', '" + atts.getValue("Name") ) .append( "', '" + atts.getValue("Name") )
.append( "', '" + atts.getValue("creator") ) .append( "', '" + atts.getValue("creator") )
.append( "', '" + atts.getValue("creatorcontact") ) .append( "', '" + atts.getValue("creatorcontact") )
@ -357,7 +357,7 @@ public class PackInHandler extends DefaultHandler {
.append( ", '" + atts.getValue("CompVer") ) .append( ", '" + atts.getValue("CompVer") )
.append( "', '" + atts.getValue("Version") ) .append( "', '" + atts.getValue("Version") )
.append( "', '" + atts.getValue("DataBase") ) .append( "', '" + atts.getValue("DataBase") )
.append( "', '" + atts.getValue("Description").replaceAll("'","''").replaceAll(",","") ) .append( "', '" + atts.getValue("Description").replaceAll("'","''"))
.append( "', '" + atts.getValue("Name") ) .append( "', '" + atts.getValue("Name") )
.append( "', '" + atts.getValue("creator") ) .append( "', '" + atts.getValue("creator") )
.append( "', '" + atts.getValue("creatorcontact") ) .append( "', '" + atts.getValue("creatorcontact") )
@ -387,20 +387,27 @@ public class PackInHandler extends DefaultHandler {
Env.setContext(m_ctx, "PackageDirectory", packageDirectory); Env.setContext(m_ctx, "PackageDirectory", packageDirectory);
m_ctx.put("Document", hd_document); m_ctx.put("Document", hd_document);
m_ctx.put("DocumentAttributes", attsOut); m_ctx.put("DocumentAttributes", attsOut);
m_ctx.put("PackInProcess", packIn);
} }
else if (elementValue.equals("menu")) { else if (elementValue.equals("menu")) {
//defer //defer
Element e = new Element(uri, localName, qName, atts); Element e = new Element(uri, localName, qName, new AttributesImpl(atts));
if (stack.size() > 0)
e.parent = stack.peek();
stack.push(e);
menus.add(e); menus.add(e);
} }
else { else {
Element e = new Element(uri, localName, qName, atts); Element e = new Element(uri, localName, qName, new AttributesImpl(atts));
if (stack.size() > 0)
e.parent = stack.peek();
stack.push(e); stack.push(e);
ElementHandler handler = handlers.get(elementValue); ElementHandler handler = handlers.get(elementValue);
if (handler != null) if (handler != null)
handler.startElement(m_ctx, e); handler.startElement(m_ctx, e);
if (e.defer) if (e.defer) {
defer.add(new DeferEntry(e, true)); defer.add(new DeferEntry(e, true));
}
} }
} // startElement } // startElement
@ -642,6 +649,8 @@ public class PackInHandler extends DefaultHandler {
handler.endElement(m_ctx, e); handler.endElement(m_ctx, e);
if (e.defer) if (e.defer)
defer.add(new DeferEntry(e, false)); defer.add(new DeferEntry(e, false));
else
log.info("Processed: " + e.getElementValue() + " - " + e.attributes.getValue(0));
} }
} // endElement } // endElement
@ -677,6 +686,11 @@ public class PackInHandler extends DefaultHandler {
int endSize = defer.size(); int endSize = defer.size();
if (startSize == endSize) break; if (startSize == endSize) break;
} while (defer.size() > 0); } while (defer.size() > 0);
if (defer.size() > 0) {
//TODO
throw new RuntimeException("Failed to resolve dependency for " + defer.size() + " elements.");
}
} }
// globalqss - add support for trx in 3.1.2 // globalqss - add support for trx in 3.1.2

View File

@ -67,20 +67,18 @@ public class CodeSnipitElementHandler extends AbstractElementHandler {
String packagePath=null; String packagePath=null;
String sourcePath=null; String sourcePath=null;
//get compiere-all directory //get adempiere-all directory
try { try {
packagePath = currentDirectory.getCanonicalPath(); packagePath = getPackageDirectory(ctx);
File parentDirectory = new File(packagePath); File parentDirectory = new File(packagePath);
while (!parentDirectory.getName().equals("packages")){ while (!parentDirectory.getName().equals("packages")){
parentDirectory = parentDirectory.getParentFile(); parentDirectory = parentDirectory.getParentFile();
} }
parentDirectory = parentDirectory.getParentFile(); parentDirectory = parentDirectory.getParentFile();
sourcePath = parentDirectory.getCanonicalPath(); sourcePath = parentDirectory.getCanonicalPath();
} catch (IOException e1) { } catch (IOException e1) {
System.out.println("Can't find compiere-all directory."); System.out.println("Can't find adempiere-all directory.");
} }
// Create backup directory if required // Create backup directory if required
File backupDir = new File(packagePath+File.separator+"backup"+File.separator); File backupDir = new File(packagePath+File.separator+"backup"+File.separator);

View File

@ -27,6 +27,7 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element; import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackIn;
import org.adempiere.pipo.exception.DatabaseAccessException; import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException; import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
@ -43,19 +44,40 @@ public class ColumnElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element) public void startElement(Properties ctx, Element element)
throws SAXException { throws SAXException {
PackIn packIn = (PackIn)ctx.get("PackInProcess");
String elementValue = element.getElementValue(); String elementValue = element.getElementValue();
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ColumnName")); log.info(elementValue + " " + atts.getValue("ColumnName"));
int success = 0; int success = 0;
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) { if (element.parent != null && element.parent.getElementValue().equals("table") &&
element.parent.defer) {
element.defer = true;
return;
}
String columnName = atts.getValue("ColumnName"); String columnName = atts.getValue("ColumnName");
String tableName = atts.getValue("ADTableNameID");
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts int tableid = 0;
.getValue("ADTableNameID")); if (element.parent != null && element.parent.getElementValue().equals("table") &&
int id = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", element.parent.recordId > 0) {
tableid = element.parent.recordId;
} else {
tableid = packIn.getTableId(tableName);
}
if (tableid <= 0) {
tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
if (tableid > 0)
packIn.addTable(tableName, tableid);
}
int id = packIn.getColumnId(tableName, columnName);
if (id <= 0) {
id = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName",
columnName, "AD_Table", tableid); columnName, "AD_Table", tableid);
if (id > 0) {
packIn.addColumn(tableName, columnName, id);
}
}
MColumn m_Column = new MColumn(ctx, id, getTrxName(ctx)); MColumn m_Column = new MColumn(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
String Object_Status = null; String Object_Status = null;
@ -193,19 +215,22 @@ public class ColumnElementHandler extends AbstractElementHandler {
} }
// Don't create database column for virtual columns // Don't create database column for virtual columns
// Don't create columns by default, just if getIsSyncDatabase='Y' boolean syncDatabase = "Y".equalsIgnoreCase(atts.getValue("getIsSyncDatabase"));
if (recreateColumn) { if (recreateColumn) {
String sync = atts.getValue("getIsSyncDatabase"); if (m_Column.isVirtualColumn() || !syncDatabase)
if (m_Column.isVirtualColumn() || sync == null
|| (!sync.equals("Y")))
recreateColumn = false; recreateColumn = false;
} }
if (tableName.equals("A_Depreciation") && columnName.equals("Processed")) {
System.out.println("A_Depreciation.Processed: " + recreateColumn);
}
if (m_Column.save(getTrxName(ctx)) == true) { if (m_Column.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Column.getName(), "Column", m_Column record_log(ctx, 1, m_Column.getName(), "Column", m_Column
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column", .get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
get_IDWithColumn(ctx, "AD_Table", "TableName", get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Column")); "AD_Column"));
element.recordId = m_Column.getAD_Column_ID();
} else { } else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column", .get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
@ -214,8 +239,8 @@ public class ColumnElementHandler extends AbstractElementHandler {
throw new POSaveFailedException("Column"); throw new POSaveFailedException("Column");
} }
if (recreateColumn) { if (recreateColumn || syncDatabase) {
success = createcolumn(ctx, m_Column); success = createColumn(ctx, m_Column, recreateColumn);
if (success == 1) { if (success == 1) {
record_log(ctx, 1, m_Column.getColumnName(), "dbColumn", record_log(ctx, 1, m_Column.getColumnName(), "dbColumn",
@ -246,7 +271,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
* @param v_IsMandatory * @param v_IsMandatory
* *
*/ */
private int createcolumn(Properties ctx, MColumn column) { private int createColumn(Properties ctx, MColumn column, boolean doAlter) {
MTable table = new MTable(ctx, column.getAD_Table_ID(), getTrxName(ctx)); MTable table = new MTable(ctx, column.getAD_Table_ID(), getTrxName(ctx));
if (table.isView()) if (table.isView())
return 0; return 0;
@ -280,11 +305,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
// //
rsc = md.getColumns(catalog, schema, tableName, columnName); rsc = md.getColumns(catalog, schema, tableName, columnName);
if (rsc.next()) { if (rsc.next()) {
// update existing column if (doAlter) {
boolean notNull = DatabaseMetaData.columnNoNulls == rsc // update existing column
.getInt("NULLABLE"); boolean notNull = DatabaseMetaData.columnNoNulls == rsc
sql = column.getSQLModify(table, .getInt("NULLABLE");
column.isMandatory() != notNull); sql = column.getSQLModify(table,
column.isMandatory() != notNull);
}
} else { } else {
// No existing column // No existing column
sql = column.getSQLAdd(table); sql = column.getSQLAdd(table);
@ -295,19 +322,21 @@ public class ColumnElementHandler extends AbstractElementHandler {
rst.close(); rst.close();
rst = null; rst = null;
log.info(sql); //execute modify or add if needed
if (sql != null && sql.trim().length() > 0) {
if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) { log.info(sql);
no = DB.executeUpdate(sql, false, getTrxName(ctx));
} else { if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) {
String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR); no = DB.executeUpdate(sql, false, getTrxName(ctx));
for (int i = 0; i < statements.length; i++) { } else {
int count = DB.executeUpdate(statements[i], false, String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR);
getTrxName(ctx)); for (int i = 0; i < statements.length; i++) {
no += count; int count = DB.executeUpdate(statements[i], false,
getTrxName(ctx));
no += count;
}
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
if (rsc != null) { if (rsc != null) {
@ -443,9 +472,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
.isUpdateable() == true ? "true" : "false")); .isUpdateable() == true ? "true" : "false"));
atts.addAttribute("", "", "Name", "CDATA", atts.addAttribute("", "", "Name", "CDATA",
(m_Column.getName() != null ? m_Column.getName() : "")); (m_Column.getName() != null ? m_Column.getName() : ""));
atts.addAttribute("", "", "getIsSyncDatabase", "CDATA", (m_Column atts.addAttribute("", "", "getIsSyncDatabase", "CDATA", "Y");
.getIsSyncDatabase() != null ? m_Column.getIsSyncDatabase()
: ""));
atts atts
.addAttribute("", "", "ReadOnlyLogic", "CDATA", (m_Column .addAttribute("", "", "ReadOnlyLogic", "CDATA", (m_Column
.getReadOnlyLogic() != null ? m_Column .getReadOnlyLogic() != null ? m_Column

View File

@ -34,6 +34,7 @@ import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element; import org.adempiere.pipo.Element;
import org.adempiere.pipo.GenericPO; import org.adempiere.pipo.GenericPO;
import org.adempiere.pipo.IDFinder; import org.adempiere.pipo.IDFinder;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.POInfo; import org.compiere.model.POInfo;
import org.compiere.model.X_AD_Package_Exp_Detail; import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -46,7 +47,7 @@ public class DataElementHandler extends AbstractElementHandler {
private GenericPO genericPO = null; private GenericPO genericPO = null;
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
String Object_Status = null; String objectStatus = null;
String d_tablename = null; String d_tablename = null;
private DataRowElementHandler rowHandler = new DataRowElementHandler(); private DataRowElementHandler rowHandler = new DataRowElementHandler();
@ -101,10 +102,10 @@ public class DataElementHandler extends AbstractElementHandler {
genericPO = new GenericPO(ctx, id, getTrxName(ctx)); genericPO = new GenericPO(ctx, id, getTrxName(ctx));
if (id > 0){ if (id > 0){
AD_Backup_ID = copyRecord(ctx,d_tablename,genericPO); AD_Backup_ID = copyRecord(ctx,d_tablename,genericPO);
Object_Status = "Update"; objectStatus = "Update";
} }
else{ else{
Object_Status = "New"; objectStatus = "New";
AD_Backup_ID =0; AD_Backup_ID =0;
} }
} }
@ -131,7 +132,7 @@ public class DataElementHandler extends AbstractElementHandler {
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
Object_Status = "Update"; objectStatus = "Update";
genericPO = new GenericPO(ctx, rs, getTrxName(ctx)); genericPO = new GenericPO(ctx, rs, getTrxName(ctx));
rs.close(); rs.close();
pstmt.close(); pstmt.close();
@ -142,7 +143,7 @@ public class DataElementHandler extends AbstractElementHandler {
rs.close(); rs.close();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
Object_Status = "New"; objectStatus = "New";
// set keyXname. // set keyXname.
CURRENT_KEY = "key1name"; CURRENT_KEY = "key1name";
if (!atts.getValue(CURRENT_KEY).equals("")) { if (!atts.getValue(CURRENT_KEY).equals("")) {
@ -202,9 +203,11 @@ public class DataElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException { public void endElement(Properties ctx, Element element) throws SAXException {
if (genericPO != null) { if (genericPO != null) {
if (genericPO.save(getTrxName(ctx))== true) if (genericPO.save(getTrxName(ctx))== true)
record_log (ctx, 1, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, Object_Status,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename)); record_log (ctx, 1, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
else else {
record_log (ctx, 0, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, Object_Status,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename)); record_log (ctx, 0, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
throw new POSaveFailedException("GenericPO");
}
genericPO = null; genericPO = null;
} }
@ -229,9 +232,9 @@ public class DataElementHandler extends AbstractElementHandler {
String isUpdateable = DB.getSQLValueString(getTrxName(ctx), sql.toString(),id); String isUpdateable = DB.getSQLValueString(getTrxName(ctx), sql.toString(),id);
sql = new StringBuffer ("SELECT IsKey FROM AD_column WHERE AD_Column_ID = ?"); sql = new StringBuffer ("SELECT IsKey FROM AD_column WHERE AD_Column_ID = ?");
String isKey = DB.getSQLValueString(getTrxName(ctx), sql.toString(),id); String isKey = DB.getSQLValueString(getTrxName(ctx), sql.toString(),id);
if (isKey.equals("N") && if (("New".equals(objectStatus)) || (isKey.equals("N") &&
isUpdateable.equals("Y") && isUpdateable.equals("Y") &&
(!atts.getValue("name").equals("CreatedBy")||!atts.getValue("name").equals("UpdatedBy"))) { (!atts.getValue("name").equals("CreatedBy")||!atts.getValue("name").equals("UpdatedBy")))) {
if (atts.getValue("value") != null && !atts.getValue("value").equals("null")) { if (atts.getValue("value") != null && !atts.getValue("value").equals("null")) {
if (atts.getValue("class").equals("String") || atts.getValue("class").equals("Text") if (atts.getValue("class").equals("String") || atts.getValue("class").equals("Text")
|| atts.getValue("class").equals("List")|| atts.getValue("class").equals("Yes-No") || atts.getValue("class").equals("List")|| atts.getValue("class").equals("Yes-No")

View File

@ -63,7 +63,7 @@ public class DistFileElementHandler extends AbstractElementHandler {
String packagePath=null; String packagePath=null;
String sourcePath=null; String sourcePath=null;
//get compiere-all directory //get adempiere-all directory
try { try {
packagePath = getPackageDirectory(ctx); packagePath = getPackageDirectory(ctx);
File parentDirectory = new File(packagePath); File parentDirectory = new File(packagePath);
@ -73,7 +73,7 @@ public class DistFileElementHandler extends AbstractElementHandler {
parentDirectory = parentDirectory.getParentFile(); parentDirectory = parentDirectory.getParentFile();
sourcePath = parentDirectory.getCanonicalPath(); sourcePath = parentDirectory.getCanonicalPath();
} catch (IOException e1) { } catch (IOException e1) {
System.out.println("Can't find compiere-all directory."); System.out.println("Can't find adempiere-all directory.");
} }

View File

@ -40,7 +40,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("Name")); log.info(elementValue+" "+atts.getValue("Name"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.equals("U") || entitytype.equals("D") && getUpdateMode(ctx).equals("true")) { if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
String name = atts.getValue("Name"); String name = atts.getValue("Name");
int id = get_IDWithColumn(ctx, "AD_Val_Rule", "name", name); int id = get_IDWithColumn(ctx, "AD_Val_Rule", "name", name);
@ -55,7 +55,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
Object_Status = "New"; Object_Status = "New";
AD_Backup_ID =0; AD_Backup_ID =0;
} }
m_ValRule.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); m_ValRule.setDescription(atts.getValue("Description").replaceAll("'","''"));
m_ValRule.setEntityType(atts.getValue("EntityType")); m_ValRule.setEntityType(atts.getValue("EntityType"));
m_ValRule.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_ValRule.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_ValRule.setName(name); m_ValRule.setName(name);

View File

@ -23,6 +23,7 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element; import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackIn;
import org.compiere.model.MField; import org.compiere.model.MField;
import org.compiere.model.X_AD_Field; import org.compiere.model.X_AD_Field;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -33,76 +34,133 @@ import org.xml.sax.helpers.AttributesImpl;
public class FieldElementHandler extends AbstractElementHandler { public class FieldElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element) throws SAXException { public void startElement(Properties ctx, Element element)
throws SAXException {
PackIn packIn = (PackIn)ctx.get("PackInProcess");
String elementValue = element.getElementValue(); String elementValue = element.getElementValue();
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("Name")); log.info(elementValue + " " + atts.getValue("Name"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 && getUpdateMode(ctx).compareTo("true") == 0) { if (entitytype.equals("U")
|| (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
if (element.parent != null && element.parent.getElementValue().equals("tab") &&
element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("Name"); String name = atts.getValue("Name");
String tabname = atts.getValue("ADTabNameID"); String tabname = atts.getValue("ADTabNameID");
String colname = atts.getValue("ADColumnNameID"); String colname = atts.getValue("ADColumnNameID");
// log.info("Column Name ->"+colname); String tableName = atts.getValue("ADTableNameID");
// log.info("Database Name ->"+m_DatabaseType); int tableid = packIn.getTableId(tableName);
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID")); if (tableid <= 0) {
int windowid = get_ID(ctx, "AD_Window", atts.getValue("ADWindowNameID")); tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
//log.info("Column Name ->"+colname); if (tableid > 0)
int columnid = get_IDWithMasterAndColumn (ctx, "AD_Column","ColumnName", colname, "AD_Table", tableid); packIn.addTable(tableName, tableid);
//log.info("ColumnID->"+columnid); }
StringBuffer sqlB = new StringBuffer ("select AD_Tab_ID from AD_Tab where AD_Window_ID = " + windowid) if (tableid <= 0) {
.append( " and Name = '"+tabname +"'" ) element.defer = true;
.append( " and AD_Table_ID = ?"); return;
int tabid = DB.getSQLValue(getTrxName(ctx), sqlB.toString (), tableid); }
int windowid = get_ID(ctx, "AD_Window", atts
if (tabid > 0 ) .getValue("ADWindowNameID"));
{ if (windowid <= 0) {
element.defer = true;
sqlB = new StringBuffer ("select AD_Field_ID from AD_Field where AD_Column_ID = "+columnid return;
+ " and AD_Tab_ID = ?"); }
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString (), tabid); int columnid = packIn.getColumnId(tableName, colname);
if (columnid <= 0) {
columnid = get_IDWithMasterAndColumn(ctx, "AD_Column",
"ColumnName", colname, "AD_Table", tableid);
if (columnid > 0)
packIn.addColumn(tableName, colname, columnid);
}
if (columnid <= 0) {
element.defer = true;
return;
}
int tabid = 0;
if (element.parent != null && element.parent.getElementValue().equals("tab") &&
element.parent.recordId > 0) {
tabid = element.parent.recordId;
} else {
StringBuffer sqlB = new StringBuffer(
"select AD_Tab_ID from AD_Tab where AD_Window_ID = "
+ windowid).append(" and Name = '" + tabname + "'")
.append(" and AD_Table_ID = ?");
tabid = DB.getSQLValue(getTrxName(ctx), sqlB.toString(),
tableid);
if (element.parent != null && element.parent.getElementValue().equals("tab") && tabid > 0) {
element.parent.recordId = tabid;
}
}
if (tabid > 0) {
StringBuffer sqlB = new StringBuffer(
"select AD_Field_ID from AD_Field where AD_Column_ID = ")
.append(columnid)
.append(" and AD_Tab_ID = ?");
int id = DB
.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid);
MField m_Field = new MField(ctx, id, getTrxName(ctx)); MField m_Field = new MField(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
String Object_Status = null; String Object_Status = null;
if (id > 0){ if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Field",m_Field); AD_Backup_ID = copyRecord(ctx, "AD_Field", m_Field);
Object_Status = "Update"; Object_Status = "Update";
} } else {
else{
Object_Status = "New"; Object_Status = "New";
AD_Backup_ID =0; AD_Backup_ID = 0;
} }
m_Field.setName(atts.getValue("Name")); m_Field.setName(atts.getValue("Name"));
m_Field.setAD_Column_ID(columnid); m_Field.setAD_Column_ID(columnid);
name = atts.getValue("ADFieldGroupNameID"); name = atts.getValue("ADFieldGroupNameID");
id = get_IDWithColumn(ctx, "AD_FieldGroup", "Name", name); id = get_IDWithColumn(ctx, "AD_FieldGroup", "Name", name);
m_Field.setAD_FieldGroup_ID(id); m_Field.setAD_FieldGroup_ID(id);
m_Field.setAD_Tab_ID(tabid); m_Field.setAD_Tab_ID(tabid);
m_Field.setEntityType (atts.getValue("EntityType")); m_Field.setEntityType(atts.getValue("EntityType"));
m_Field.setIsSameLine(Boolean.valueOf(atts.getValue("SameLine")).booleanValue()); m_Field.setIsSameLine(Boolean
m_Field.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("isCentrallyMaintained")).booleanValue()); .valueOf(atts.getValue("SameLine")).booleanValue());
m_Field.setIsDisplayed(Boolean.valueOf(atts.getValue("Displayed")).booleanValue()); m_Field.setIsCentrallyMaintained(Boolean.valueOf(
//m_Field.setIsEncrypted(Boolean.valueOf(atts.getValue("isEncrypted")).booleanValue()); atts.getValue("isCentrallyMaintained")).booleanValue());
m_Field.setIsFieldOnly(Boolean.valueOf(atts.getValue("isFieldOnly")).booleanValue()); m_Field.setIsDisplayed(Boolean.valueOf(
m_Field.setIsHeading(Boolean.valueOf(atts.getValue("isHeading")).booleanValue()); atts.getValue("Displayed")).booleanValue());
m_Field.setIsReadOnly(Boolean.valueOf(atts.getValue("isReadOnly")).booleanValue()); // m_Field.setIsEncrypted(Boolean.valueOf(atts.getValue("isEncrypted")).booleanValue());
m_Field.setIsFieldOnly(Boolean.valueOf(
atts.getValue("isFieldOnly")).booleanValue());
m_Field.setIsHeading(Boolean
.valueOf(atts.getValue("isHeading")).booleanValue());
m_Field.setIsReadOnly(Boolean.valueOf(
atts.getValue("isReadOnly")).booleanValue());
m_Field.setSeqNo(Integer.parseInt(atts.getValue("SeqNo"))); m_Field.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
m_Field.setDisplayLength(Integer.parseInt(atts.getValue("DisplayLength"))); m_Field.setDisplayLength(Integer.parseInt(atts
m_Field.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); .getValue("DisplayLength")));
m_Field.setHelp(atts.getValue("Help").replaceAll("'","''").replaceAll(",","")); m_Field.setDescription(atts.getValue("Description").replaceAll(
m_Field.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); "'", "''").replaceAll(",", ""));
m_Field.setHelp(atts.getValue("Help").replaceAll("'", "''")
.replaceAll(",", ""));
m_Field.setIsActive(atts.getValue("isActive") != null ? Boolean
.valueOf(atts.getValue("isActive")).booleanValue()
: true);
m_Field.setSortNo(new BigDecimal(atts.getValue("SortNo"))); m_Field.setSortNo(new BigDecimal(atts.getValue("SortNo")));
m_Field.setDisplayLogic(atts.getValue("DisplayLogic")); m_Field.setDisplayLogic(atts.getValue("DisplayLogic"));
if (m_Field.save(getTrxName(ctx)) == true){ if (m_Field.save(getTrxName(ctx)) == true) {
record_log (ctx, 1, m_Field.getName(),"Field", m_Field.get_ID(),AD_Backup_ID, Object_Status,"AD_Field",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Field")); record_log(ctx, 1, m_Field.getName(), "Field", m_Field
.get_ID(), AD_Backup_ID, Object_Status, "AD_Field",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Field"));
element.recordId = m_Field.getAD_Field_ID();
} else {
record_log(ctx, 0, m_Field.getName(), "Field", m_Field
.get_ID(), AD_Backup_ID, Object_Status, "AD_Field",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Field"));
} }
else{ } else {
record_log (ctx, 0, m_Field.getName(),"Field", m_Field.get_ID(),AD_Backup_ID, Object_Status,"AD_Field",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Field")); element.defer = true;
} return;
} }
else
log.severe("Tab do not exist to field Name: "+ name); }
}
} }
public void endElement(Properties ctx, Element element) throws SAXException { public void endElement(Properties ctx, Element element) throws SAXException {
@ -110,82 +168,97 @@ public class FieldElementHandler extends AbstractElementHandler {
public void create(Properties ctx, TransformerHandler document) public void create(Properties ctx, TransformerHandler document)
throws SAXException { throws SAXException {
int AD_Field_ID = Env.getContextAsInt(ctx, X_AD_Field.COLUMNNAME_AD_Field_ID); int AD_Field_ID = Env.getContextAsInt(ctx,
X_AD_Field m_Field = new X_AD_Field (ctx, AD_Field_ID, null); X_AD_Field.COLUMNNAME_AD_Field_ID);
X_AD_Field m_Field = new X_AD_Field(ctx, AD_Field_ID, null);
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
createFieldBinding(atts,m_Field); createFieldBinding(atts, m_Field);
document.startElement("","","field",atts); document.startElement("", "", "field", atts);
document.endElement("","","field"); document.endElement("", "", "field");
} }
private AttributesImpl createFieldBinding( AttributesImpl atts, X_AD_Field m_Field) private AttributesImpl createFieldBinding(AttributesImpl atts,
{ X_AD_Field m_Field) {
String sql = null; String sql = null;
String name = null; String name = null;
atts.clear(); atts.clear();
if (m_Field.getAD_Column_ID()> 0 ){ if (m_Field.getAD_Column_ID() > 0) {
sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?"; sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_Column_ID()); name = DB.getSQLValueString(null, sql, m_Field.getAD_Column_ID());
atts.addAttribute("","","ADColumnNameID","CDATA",name); atts.addAttribute("", "", "ADColumnNameID", "CDATA", name);
} } else
else atts.addAttribute("", "", "ADColumnNameID", "CDATA", "");
atts.addAttribute("","","ADColumnNameID","CDATA","");
if (m_Field.getAD_Column_ID() > 0) {
if (m_Field.getAD_Column_ID()> 0 ){
sql = "SELECT AD_Table_ID FROM AD_Column WHERE AD_Column_ID=?"; sql = "SELECT AD_Table_ID FROM AD_Column WHERE AD_Column_ID=?";
int idTable = DB.getSQLValue(null, sql,m_Field.getAD_Column_ID()); int idTable = DB.getSQLValue(null, sql, m_Field.getAD_Column_ID());
sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?"; sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
name = DB.getSQLValueString(null,sql,idTable); name = DB.getSQLValueString(null, sql, idTable);
atts.addAttribute("","","ADTableNameID","CDATA",name); atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
} } else
else atts.addAttribute("", "", "ADTableNameID", "CDATA", "");
atts.addAttribute("","","ADTableNameID","CDATA",""); if (m_Field.getAD_FieldGroup_ID() > 0) {
if (m_Field.getAD_FieldGroup_ID()> 0 ){
sql = "SELECT Name FROM AD_FieldGroup WHERE AD_FieldGroup_ID=?"; sql = "SELECT Name FROM AD_FieldGroup WHERE AD_FieldGroup_ID=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_FieldGroup_ID()); name = DB.getSQLValueString(null, sql, m_Field
atts.addAttribute("","","ADFieldGroupNameID","CDATA",name); .getAD_FieldGroup_ID());
} atts.addAttribute("", "", "ADFieldGroupNameID", "CDATA", name);
else } else
atts.addAttribute("","","ADFieldGroupNameID","CDATA",""); atts.addAttribute("", "", "ADFieldGroupNameID", "CDATA", "");
if (m_Field.getAD_Field_ID()> 0 ){ if (m_Field.getAD_Field_ID() > 0) {
sql = "SELECT Name FROM AD_Field WHERE AD_Field_ID=?"; sql = "SELECT Name FROM AD_Field WHERE AD_Field_ID=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_Field_ID()); name = DB.getSQLValueString(null, sql, m_Field.getAD_Field_ID());
atts.addAttribute("","","ADFieldNameID","CDATA",name); atts.addAttribute("", "", "ADFieldNameID", "CDATA", name);
} } else
else atts.addAttribute("", "", "ADFieldNameID", "CDATA", "");
atts.addAttribute("","","ADFieldNameID","CDATA","");
if (m_Field.getAD_Tab_ID() > 0) {
if (m_Field.getAD_Tab_ID()> 0 ){ sql = "SELECT Name FROM AD_Tab WHERE AD_Tab_ID=?";
sql = "SELECT Name FROM AD_Tab WHERE AD_Tab_ID=?"; name = DB.getSQLValueString(null, sql, m_Field.getAD_Tab_ID());
name = DB.getSQLValueString(null,sql,m_Field.getAD_Tab_ID()); atts.addAttribute("", "", "ADTabNameID", "CDATA", name);
atts.addAttribute("","","ADTabNameID","CDATA",name); sql = "SELECT AD_Window_ID FROM AD_Tab WHERE AD_Tab_ID=?";
sql = "SELECT AD_Window_ID FROM AD_Tab WHERE AD_Tab_ID=?"; int windowid = DB.getSQLValue(null, sql, m_Field.getAD_Tab_ID());
int windowid = DB.getSQLValue(null,sql,m_Field.getAD_Tab_ID());
sql = "SELECT Name FROM AD_Window WHERE AD_Window_ID=?"; sql = "SELECT Name FROM AD_Window WHERE AD_Window_ID=?";
name = DB.getSQLValueString(null,sql,windowid); name = DB.getSQLValueString(null, sql, windowid);
atts.addAttribute("","","ADWindowNameID","CDATA",name); atts.addAttribute("", "", "ADWindowNameID", "CDATA", name);
} } else
else atts.addAttribute("", "", "ADTabNameID", "CDATA", "");
atts.addAttribute("","","ADTabNameID","CDATA","");
atts.addAttribute("", "", "EntityType", "CDATA", (m_Field
atts.addAttribute("","","EntityType","CDATA",(m_Field.getEntityType () != null ? m_Field.getEntityType ():"")); .getEntityType() != null ? m_Field.getEntityType() : ""));
atts.addAttribute("","","Name","CDATA",(m_Field.getName () != null ? m_Field.getName ():"")); atts.addAttribute("", "", "Name", "CDATA",
atts.addAttribute("","","SameLine","CDATA", (m_Field.isSameLine() == true ? "true":"false")); (m_Field.getName() != null ? m_Field.getName() : ""));
atts.addAttribute("","","isCentrallyMaintained","CDATA",(m_Field.isCentrallyMaintained()== true ? "true":"false")); atts.addAttribute("", "", "SameLine", "CDATA",
atts.addAttribute("","","Displayed","CDATA",(m_Field.isDisplayed()== true ? "true":"false")); (m_Field.isSameLine() == true ? "true" : "false"));
atts.addAttribute("","","isActive","CDATA",(m_Field.isActive()== true ? "true":"false")); atts.addAttribute("", "", "isCentrallyMaintained", "CDATA", (m_Field
atts.addAttribute("","","isEncrypted","CDATA",(m_Field.isEncrypted()== true ? "true":"false")); .isCentrallyMaintained() == true ? "true" : "false"));
atts.addAttribute("","","isFieldOnly","CDATA",(m_Field.isFieldOnly()== true ? "true":"false")); atts.addAttribute("", "", "Displayed", "CDATA",
atts.addAttribute("","","isHeading","CDATA",(m_Field.isHeading()== true ? "true":"false")); (m_Field.isDisplayed() == true ? "true" : "false"));
atts.addAttribute("","","isReadOnly","CDATA",(m_Field.isReadOnly()== true ? "true":"false")); atts.addAttribute("", "", "isActive", "CDATA",
atts.addAttribute("","","SeqNo","CDATA", "" + (m_Field.getSeqNo())); (m_Field.isActive() == true ? "true" : "false"));
atts.addAttribute("","","DisplayLength","CDATA",(m_Field.getDisplayLength () > 0 ? "" + m_Field.getDisplayLength():"0")); atts.addAttribute("", "", "isEncrypted", "CDATA", (m_Field
atts.addAttribute("","","Description","CDATA",(m_Field.getDescription () != null ? m_Field.getDescription():"")); .isEncrypted() == true ? "true" : "false"));
atts.addAttribute("","","Help","CDATA",(m_Field.getHelp () != null ? m_Field.getHelp():"")); atts.addAttribute("", "", "isFieldOnly", "CDATA", (m_Field
atts.addAttribute("","","SortNo","CDATA",(m_Field.getSortNo () != null ? m_Field.getSortNo().toString():"")); .isFieldOnly() == true ? "true" : "false"));
atts.addAttribute("","","DisplayLogic","CDATA",(m_Field.getDisplayLogic () != null ? m_Field.getDisplayLogic():"")); atts.addAttribute("", "", "isHeading", "CDATA",
atts.addAttribute("","","ObscureType","CDATA",(m_Field.getObscureType () != null ? m_Field.getObscureType():"")); (m_Field.isHeading() == true ? "true" : "false"));
atts.addAttribute("", "", "isReadOnly", "CDATA",
(m_Field.isReadOnly() == true ? "true" : "false"));
atts.addAttribute("", "", "SeqNo", "CDATA", "" + (m_Field.getSeqNo()));
atts.addAttribute("", "", "DisplayLength", "CDATA",
(m_Field.getDisplayLength() > 0 ? ""
+ m_Field.getDisplayLength() : "0"));
atts.addAttribute("", "", "Description", "CDATA", (m_Field
.getDescription() != null ? m_Field.getDescription() : ""));
atts.addAttribute("", "", "Help", "CDATA",
(m_Field.getHelp() != null ? m_Field.getHelp() : ""));
atts.addAttribute("", "", "SortNo", "CDATA",
(m_Field.getSortNo() != null ? m_Field.getSortNo().toString()
: ""));
atts.addAttribute("", "", "DisplayLogic", "CDATA", (m_Field
.getDisplayLogic() != null ? m_Field.getDisplayLogic() : ""));
atts.addAttribute("", "", "ObscureType", "CDATA", (m_Field
.getObscureType() != null ? m_Field.getObscureType() : ""));
return atts; return atts;
} }
} }

View File

@ -38,7 +38,7 @@ public class FormElementHandler extends AbstractElementHandler {
log.info(elementValue+" "+atts.getValue("ADFormNameID")); log.info(elementValue+" "+atts.getValue("ADFormNameID"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 && getUpdateMode(ctx).compareTo("true") == 0 ) { if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
String name = atts.getValue("ADFormNameID"); String name = atts.getValue("ADFormNameID");
int id = get_ID(ctx, "AD_Form", name); int id = get_ID(ctx, "AD_Form", name);
MForm m_Form = new MForm(ctx, id, getTrxName(ctx)); MForm m_Form = new MForm(ctx, id, getTrxName(ctx));
@ -55,9 +55,9 @@ public class FormElementHandler extends AbstractElementHandler {
m_Form.setClassname (atts.getValue("Classname")); m_Form.setClassname (atts.getValue("Classname"));
m_Form.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue()); m_Form.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
m_Form.setAccessLevel(atts.getValue("AccessLevel")); m_Form.setAccessLevel(atts.getValue("AccessLevel"));
m_Form.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); m_Form.setDescription(atts.getValue("Description").replaceAll("'","''"));
m_Form.setEntityType(atts.getValue("EntityType")); m_Form.setEntityType(atts.getValue("EntityType"));
m_Form.setHelp(atts.getValue("Help").replaceAll(",","")); m_Form.setHelp(atts.getValue("Help"));
m_Form.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Form.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_Form.setName(atts.getValue("Name")); m_Form.setName(atts.getValue("Name"));

View File

@ -41,7 +41,7 @@ public class MessageElementHandler extends AbstractElementHandler {
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("Value")); log.info(elementValue+" "+atts.getValue("Value"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.equals("U") || entitytype.equals("D") && getUpdateMode(ctx).equals("true")) { if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
String value = atts.getValue("Value"); String value = atts.getValue("Value");
int id = get_IDWithColumn(ctx, "AD_Message", "value", value); int id = get_IDWithColumn(ctx, "AD_Message", "value", value);
@ -56,8 +56,8 @@ public class MessageElementHandler extends AbstractElementHandler {
Object_Status = "New"; Object_Status = "New";
AD_Backup_ID =0; AD_Backup_ID =0;
} }
m_Message.setMsgText(atts.getValue("MsgText").replaceAll("'","''").replaceAll(",","")); m_Message.setMsgText(atts.getValue("MsgText").replaceAll("'","''"));
m_Message.setMsgTip(atts.getValue("MsgTip").replaceAll("'","''").replaceAll(",","")); m_Message.setMsgTip(atts.getValue("MsgTip").replaceAll("'","''"));
m_Message.setEntityType(atts.getValue("EntityType")); m_Message.setEntityType(atts.getValue("EntityType"));
m_Message.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Message.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_Message.setValue(value); m_Message.setValue(value);

View File

@ -161,6 +161,7 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status, m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status,
"AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table", "AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormat")); "TableName", "AD_PrintFormat"));
element.recordId = m_PrintFormat.getAD_PrintFormat_ID();
} else { } else {
record_log(ctx, 0, m_PrintFormat.getName(), "PrintFormat", record_log(ctx, 0, m_PrintFormat.getName(), "PrintFormat",
m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status, m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status,

View File

@ -39,6 +39,11 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
String Object_Status = null; String Object_Status = null;
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name")); log.info(elementValue + " " + atts.getValue("Name"));
if (element.parent != null && element.parent.getElementValue().equals("printformat") &&
element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("Name"); String name = atts.getValue("Name");
int id = get_IDWithMaster(ctx, "AD_PrintFormatItem", name, int id = get_IDWithMaster(ctx, "AD_PrintFormatItem", name,
@ -56,7 +61,16 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
} }
m_PrintFormatItem.setName(name); m_PrintFormatItem.setName(name);
name = atts.getValue("ADPrintFormatNameID"); name = atts.getValue("ADPrintFormatNameID");
id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name); if (element.parent != null && element.parent.getElementValue().equals("printformat") &&
element.parent.recordId != 0) {
id = element.parent.recordId;
} else {
id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
if (element.parent != null && element.parent.getElementValue().equals("printformat") &&
id > 0) {
element.parent.recordId = id;
}
}
if (id <= 0) { if (id <= 0) {
element.defer = true; element.defer = true;
return; return;
@ -76,31 +90,40 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
name = atts.getValue("ADPrintGraphID"); name = atts.getValue("ADPrintGraphID");
if (name != null && name.trim().length() > 0) { if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintGraph", "Name", name); id = get_IDWithColumn(ctx, "AD_PrintGraph", "Name", name);
//TODO: export and import of ad_printgraph
/*
if (id <= 0) { if (id <= 0) {
element.defer = true; element.defer = true;
return; return;
} }*/
m_PrintFormatItem.setAD_PrintGraph_ID(id); if (id > 0)
m_PrintFormatItem.setAD_PrintGraph_ID(id);
} }
name = atts.getValue("ADPrintColorID"); name = atts.getValue("ADPrintColorID");
if (name != null && name.trim().length() > 0) { if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintColor", "Name", name); id = get_IDWithColumn(ctx, "AD_PrintColor", "Name", name);
//TODO: export and import of ad_printcolor
/*
if (id <= 0) { if (id <= 0) {
element.defer = true; element.defer = true;
return; return;
} }*/
m_PrintFormatItem.setAD_PrintColor_ID(id); if (id > 0)
m_PrintFormatItem.setAD_PrintColor_ID(id);
} }
name = atts.getValue("ADPrintFontID"); name = atts.getValue("ADPrintFontID");
if (name != null && name.trim().length() > 0) { if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintFont", "Name", name); id = get_IDWithColumn(ctx, "AD_PrintFont", "Name", name);
//TODO: export and import of print font
/*
if (id <= 0) { if (id <= 0) {
element.defer = true; element.defer = true;
return; return;
} }*/
m_PrintFormatItem.setAD_PrintFont_ID(id); if (id > 0)
m_PrintFormatItem.setAD_PrintFont_ID(id);
} }
m_PrintFormatItem.setPrintName(atts.getValue("PrintName")); m_PrintFormatItem.setPrintName(atts.getValue("PrintName"));

View File

@ -29,7 +29,6 @@ import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut; import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException; import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException; import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MProcess;
import org.compiere.model.MSequence; import org.compiere.model.MSequence;
import org.compiere.model.X_AD_Process; import org.compiere.model.X_AD_Process;
import org.compiere.model.X_AD_Process_Para; import org.compiere.model.X_AD_Process_Para;
@ -50,22 +49,21 @@ public class ProcessElementHandler extends AbstractElementHandler {
log.info(elementValue + " " + atts.getValue("Name")); log.info(elementValue + " " + atts.getValue("Name"));
int id = 0; int id = 0;
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) {
String name = atts.getValue("Name"); String name = atts.getValue("Name");
// Get New process. // Get New process.
id = get_ID(ctx, "AD_Process", name); id = get_ID(ctx, "AD_Process", name);
MProcess m_Process = null; X_AD_Process m_Process = null;
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
String Object_Status = null; String Object_Status = null;
if (id > 0) { if (id > 0) {
m_Process = new MProcess(ctx, id, getTrxName(ctx)); m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process); AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process);
Object_Status = "Update"; Object_Status = "Update";
} else { } else {
m_Process = new MProcess(ctx, id, getTrxName(ctx)); m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
id = MSequence.getNextID(Env.getAD_Client_ID(ctx), id = MSequence.getNextID(Env.getAD_Client_ID(ctx),
"AD_Process", getTrxName(ctx)); "AD_Process", getTrxName(ctx));
m_Process.setAD_Process_ID(id); m_Process.setAD_Process_ID(id);

View File

@ -39,8 +39,7 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
log.info(elementValue + " " + atts.getValue("Name")); log.info(elementValue + " " + atts.getValue("Name"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) {
String name = atts.getValue("Name"); String name = atts.getValue("Name");
int id = get_IDWithMaster(ctx, "AD_Process_Para", name, int id = get_IDWithMaster(ctx, "AD_Process_Para", name,

View File

@ -19,6 +19,8 @@ package org.adempiere.pipo.handler;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -41,6 +43,8 @@ public class ReferenceElementHandler extends AbstractElementHandler {
private ReferenceListElementHandler listHandler = new ReferenceListElementHandler(); private ReferenceListElementHandler listHandler = new ReferenceListElementHandler();
private ReferenceTableElementHandler tableHandler = new ReferenceTableElementHandler(); private ReferenceTableElementHandler tableHandler = new ReferenceTableElementHandler();
private List<Integer> references = new ArrayList<Integer>();
public void startElement(Properties ctx, Element element) public void startElement(Properties ctx, Element element)
throws SAXException { throws SAXException {
@ -63,6 +67,9 @@ public class ReferenceElementHandler extends AbstractElementHandler {
if (id > 0) { if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reference", m_Reference); AD_Backup_ID = copyRecord(ctx, "AD_Reference", m_Reference);
Object_Status = "Update"; Object_Status = "Update";
if (references.contains(id)) {
return;
}
} else { } else {
Object_Status = "New"; Object_Status = "New";
AD_Backup_ID = 0; AD_Backup_ID = 0;
@ -84,6 +91,7 @@ public class ReferenceElementHandler extends AbstractElementHandler {
m_Reference.get_ID(), AD_Backup_ID, Object_Status, m_Reference.get_ID(), AD_Backup_ID, Object_Status,
"AD_Reference", get_IDWithColumn(ctx, "AD_Table", "AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference")); "TableName", "AD_Reference"));
references.add(m_Reference.getAD_Reference_ID());
} else { } else {
record_log(ctx, 0, m_Reference.getName(), "Reference", record_log(ctx, 0, m_Reference.getName(), "Reference",
m_Reference.get_ID(), AD_Backup_ID, Object_Status, m_Reference.get_ID(), AD_Backup_ID, Object_Status,

View File

@ -41,32 +41,30 @@ public class ReferenceListElementHandler extends AbstractElementHandler {
log.info(elementValue + " " + atts.getValue("Name")); log.info(elementValue + " " + atts.getValue("Name"));
// TODO: Solve for date issues with valuefrom valueto // TODO: Solve for date issues with valuefrom valueto
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) {
String name = atts.getValue("Name"); String name = atts.getValue("Name");
int Referenceid = get_IDWithColumn(ctx, "AD_Reference", "Name", String value = atts.getValue("Value");
int AD_Reference_ID = get_IDWithColumn(ctx, "AD_Reference", "Name",
atts.getValue("ADRefenceNameID")); atts.getValue("ADRefenceNameID"));
int id = get_IDWithMaster(ctx, "AD_Ref_List", name, "AD_Reference", int AD_Ref_List_ID = get_IDWithMasterAndColumn(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
Referenceid); X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, AD_Ref_List_ID,
X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, id,
getTrxName(ctx)); getTrxName(ctx));
if (id > 0) { if (AD_Ref_List_ID > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Ref_List", m_Ref_List); AD_Backup_ID = copyRecord(ctx, "AD_Ref_List", m_Ref_List);
Object_Status = "Update"; Object_Status = "Update";
} else { } else {
Object_Status = "New"; Object_Status = "New";
AD_Backup_ID = 0; AD_Backup_ID = 0;
} }
name = atts.getValue("ADRefenceNameID");
id = get_IDWithColumn(ctx, "AD_Reference", "Name", name); m_Ref_List.setAD_Reference_ID(AD_Reference_ID);
m_Ref_List.setAD_Reference_ID(id); m_Ref_List.setDescription(atts.getValue("Description").replaceAll("'", "''"));
m_Ref_List.setDescription(atts.getValue("Description").replaceAll(
"'", "''").replaceAll(",", ""));
m_Ref_List.setEntityType(atts.getValue("EntityType")); m_Ref_List.setEntityType(atts.getValue("EntityType"));
m_Ref_List.setName(atts.getValue("Name")); m_Ref_List.setName(atts.getValue("Name"));
m_Ref_List.setValue(value);
m_Ref_List.setIsActive(atts.getValue("isActive") != null ? Boolean m_Ref_List.setIsActive(atts.getValue("isActive") != null ? Boolean
.valueOf(atts.getValue("isActive")).booleanValue() : true); .valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Ref_List.setValue(atts.getValue("Value"));
if (m_Ref_List.save(getTrxName(ctx)) == true) { if (m_Ref_List.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Ref_List.getName(), "Reference List", record_log(ctx, 1, m_Ref_List.getName(), "Reference List",
m_Ref_List.get_ID(), AD_Backup_ID, Object_Status, m_Ref_List.get_ID(), AD_Backup_ID, Object_Status,

View File

@ -48,8 +48,7 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
Attributes atts = element.attributes; Attributes atts = element.attributes;
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
String name = atts.getValue("ADRefenceNameID"); String name = atts.getValue("ADRefenceNameID");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) {
StringBuffer sqlB = new StringBuffer( StringBuffer sqlB = new StringBuffer(
"SELECT AD_Reference_ID FROM AD_Reference WHERE Name= ?"); "SELECT AD_Reference_ID FROM AD_Reference WHERE Name= ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), name); int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), name);
@ -126,10 +125,8 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
name, "AD_Table", tableId); name, "AD_Table", tableId);
String entityType = atts.getValue("EntityType"); String entityType = atts.getValue("EntityType");
String isValueDisplayed = atts.getValue("IsValueDisplayed"); String isValueDisplayed = atts.getValue("IsValueDisplayed");
String OrderByClause = atts.getValue("OrderByClause").replaceAll( String OrderByClause = atts.getValue("OrderByClause").replaceAll("'", "''");
"'", "''").replaceAll(",", ""); String WhereClause = atts.getValue("WhereClause").replaceAll("'","''");
String WhereClause = atts.getValue("WhereClause").replaceAll("'",
"''").replaceAll(",", "");
if (count > 0) { if (count > 0) {
sqlB = new StringBuffer("UPDATE AD_Ref_Table ").append( sqlB = new StringBuffer("UPDATE AD_Ref_Table ").append(
"SET AD_Table_ID = " + tableId).append( "SET AD_Table_ID = " + tableId).append(

View File

@ -44,8 +44,7 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
String name = atts.getValue("ADReportViewColID"); String name = atts.getValue("ADReportViewColID");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) {
int id = get_ID(ctx, "AD_Reportview_Col", name); int id = get_ID(ctx, "AD_Reportview_Col", name);
X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx, X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx,
id, getTrxName(ctx)); id, getTrxName(ctx));

View File

@ -27,6 +27,7 @@ import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element; import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut; import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException; import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTab; import org.compiere.model.MTab;
import org.compiere.model.X_AD_Field; import org.compiere.model.X_AD_Field;
import org.compiere.model.X_AD_Tab; import org.compiere.model.X_AD_Tab;
@ -45,11 +46,33 @@ public class TabElementHandler extends AbstractElementHandler {
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("ADTabNameID")); log.info(elementValue+" "+atts.getValue("ADTabNameID"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 && getUpdateMode(ctx).compareTo("true") == 0) { if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
if (element.parent != null && element.parent.getElementValue().equals("window")
&& element.parent.defer) {
element.defer = true;
return;
}
String name = atts.getValue("ADTabNameID"); String name = atts.getValue("ADTabNameID");
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID")); int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID"));
int windowid = get_ID(ctx, "AD_Window", atts.getValue("ADWindowNameID")); if (tableid <= 0) {
element.defer = true;
return;
}
int windowid = 0;
if (element.parent != null && element.parent.getElementValue().equals("window")
&& element.parent.recordId > 0) {
windowid = element.parent.recordId;
} else {
windowid = get_ID(ctx, "AD_Window", atts.getValue("ADWindowNameID"));
if (element.parent != null && element.parent.getElementValue().equals("window")
&& windowid > 0) {
element.parent.recordId = windowid;
}
}
if (windowid <= 0) {
element.defer = true;
return;
}
StringBuffer sqlB = new StringBuffer ("select AD_Tab_ID from AD_Tab where AD_Window_ID = " + windowid StringBuffer sqlB = new StringBuffer ("select AD_Tab_ID from AD_Tab where AD_Window_ID = " + windowid
+ " and Name = '"+name +"'" + " and Name = '"+name +"'"
+ " and AD_Table_ID = ?"); + " and AD_Table_ID = ?");
@ -110,10 +133,10 @@ public class TabElementHandler extends AbstractElementHandler {
m_Tab.setIncluded_Tab_ID(id); m_Tab.setIncluded_Tab_ID(id);
} }
m_Tab.setCommitWarning(atts.getValue("CommitWarning")); m_Tab.setCommitWarning(atts.getValue("CommitWarning"));
m_Tab.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); m_Tab.setDescription(atts.getValue("Description").replaceAll("'","''"));
m_Tab.setEntityType (atts.getValue("EntityType")); m_Tab.setEntityType (atts.getValue("EntityType"));
m_Tab.setHasTree(Boolean.valueOf(atts.getValue("isHasTree")).booleanValue()); m_Tab.setHasTree(Boolean.valueOf(atts.getValue("isHasTree")).booleanValue());
m_Tab.setHelp (atts.getValue("Help").replaceAll("'","''").replaceAll(",","")); m_Tab.setHelp (atts.getValue("Help").replaceAll("'","''"));
m_Tab.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Tab.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_Tab.setImportFields (atts.getValue("ImportFields")); m_Tab.setImportFields (atts.getValue("ImportFields"));
m_Tab.setIsInfoTab (Boolean.valueOf(atts.getValue("isInfoTab")).booleanValue()); m_Tab.setIsInfoTab (Boolean.valueOf(atts.getValue("isInfoTab")).booleanValue());
@ -140,9 +163,11 @@ public class TabElementHandler extends AbstractElementHandler {
m_Tab.setIsAdvancedTab(Boolean.valueOf(atts.getValue("isAdvancedTab")).booleanValue()); m_Tab.setIsAdvancedTab(Boolean.valueOf(atts.getValue("isAdvancedTab")).booleanValue());
} }
if (m_Tab.save(getTrxName(ctx)) == true){ if (m_Tab.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_Tab.getName(),"Tab", m_Tab.get_ID(),AD_Backup_ID, Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab")); record_log (ctx, 1, m_Tab.getName(),"Tab", m_Tab.get_ID(),AD_Backup_ID, Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
element.recordId = m_Tab.getAD_Tab_ID();
} else { } else {
record_log (ctx, 0, m_Tab.getName(),"Tab", m_Tab.get_ID(),AD_Backup_ID, Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab")); record_log (ctx, 0, m_Tab.getName(),"Tab", m_Tab.get_ID(),AD_Backup_ID, Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
throw new POSaveFailedException("Tab");
} }
} }

View File

@ -27,7 +27,9 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element; import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackIn;
import org.adempiere.pipo.PackOut; import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.X_AD_Column; import org.compiere.model.X_AD_Column;
import org.compiere.model.X_AD_Package_Exp_Detail; import org.compiere.model.X_AD_Package_Exp_Detail;
@ -41,7 +43,10 @@ import org.xml.sax.helpers.AttributesImpl;
public class TableElementHandler extends AbstractElementHandler { public class TableElementHandler extends AbstractElementHandler {
private ColumnElementHandler columnHandler = new ColumnElementHandler(); private ColumnElementHandler columnHandler = new ColumnElementHandler();
private List<Integer>tables = new ArrayList<Integer>();
public void startElement(Properties ctx, Element element) throws SAXException { public void startElement(Properties ctx, Element element) throws SAXException {
PackIn packIn = (PackIn)ctx.get("PackInProcess");
String elementValue = element.getElementValue(); String elementValue = element.getElementValue();
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("ADTableNameID")); log.info(elementValue+" "+atts.getValue("ADTableNameID"));
@ -50,8 +55,16 @@ public class TableElementHandler extends AbstractElementHandler {
if (entitytype.equals("U") || entitytype.equals("D") && getUpdateMode(ctx).equals("true")) { if (entitytype.equals("U") || entitytype.equals("D") && getUpdateMode(ctx).equals("true")) {
String tableName = atts.getValue("ADTableNameID"); String tableName = atts.getValue("ADTableNameID");
int id = packIn.getTableId(tableName);
int id = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName); if (id <= 0) {
id = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
if (id > 0)
packIn.addTable(tableName, id);
}
if (id > 0 && isTableProcess(ctx, id)) {
System.out.println("skip table, already process");
return;
}
MTable m_Table = new MTable(ctx, id, getTrxName(ctx)); MTable m_Table = new MTable(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
@ -79,9 +92,9 @@ public class TableElementHandler extends AbstractElementHandler {
m_Table.setAD_Val_Rule_ID(id); m_Table.setAD_Val_Rule_ID(id);
m_Table.setAccessLevel (atts.getValue("AccessLevel")); m_Table.setAccessLevel (atts.getValue("AccessLevel"));
m_Table.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); m_Table.setDescription(atts.getValue("Description").replaceAll("'","''"));
m_Table.setEntityType(atts.getValue("EntityType")); m_Table.setEntityType(atts.getValue("EntityType"));
m_Table.setHelp(atts.getValue("Help").replaceAll("'","''").replaceAll(",","")); m_Table.setHelp(atts.getValue("Help").replaceAll("'","''"));
m_Table.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Table.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_Table.setImportTable(atts.getValue("ImportTable")); m_Table.setImportTable(atts.getValue("ImportTable"));
m_Table.setIsChangeLog(Boolean.valueOf(atts.getValue("isChangeLog")).booleanValue()); m_Table.setIsChangeLog(Boolean.valueOf(atts.getValue("isChangeLog")).booleanValue());
@ -96,10 +109,14 @@ public class TableElementHandler extends AbstractElementHandler {
// log.info("in3"); // log.info("in3");
getDocumentAttributes(ctx).clear(); getDocumentAttributes(ctx).clear();
if (m_Table.save(getTrxName(ctx)) == true){ if (m_Table.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table")); record_log (ctx, 1, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
tables.add(m_Table.getAD_Table_ID());
packIn.addTable(tableName, m_Table.getAD_Table_ID());
element.recordId = m_Table.getAD_Table_ID();
} }
else{ else{
record_log (ctx, 0, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table")); record_log (ctx, 0, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
throw new POSaveFailedException("Table");
} }
} }
} }
@ -112,7 +129,7 @@ public class TableElementHandler extends AbstractElementHandler {
int AD_Table_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID); int AD_Table_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
PackOut packOut = (PackOut)ctx.get("PackOutProcess"); PackOut packOut = (PackOut)ctx.get("PackOutProcess");
boolean exported = isTableExported(ctx, AD_Table_ID); boolean exported = isTableProcess(ctx, AD_Table_ID);
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
//Export table if not already done so //Export table if not already done so
if (!exported){ if (!exported){
@ -202,19 +219,12 @@ public class TableElementHandler extends AbstractElementHandler {
ctx.remove(X_AD_Column.COLUMNNAME_AD_Column_ID); ctx.remove(X_AD_Column.COLUMNNAME_AD_Column_ID);
} }
private boolean isTableExported(Properties ctx, int AD_Table_ID) { private boolean isTableProcess(Properties ctx, int AD_Table_ID) {
List<Integer>tables = (List<Integer>)ctx.get("ExportedTables"); if (tables.contains(AD_Table_ID))
if (tables == null) { return true;
tables = new ArrayList<Integer>(); else {
tables.add(AD_Table_ID); tables.add(AD_Table_ID);
return false; return false;
} else {
if (tables.contains(AD_Table_ID))
return true;
else {
tables.add(AD_Table_ID);
return false;
}
} }
} }

View File

@ -22,6 +22,7 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler; import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element; import org.adempiere.pipo.Element;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTask; import org.compiere.model.MTask;
import org.compiere.model.X_AD_Task; import org.compiere.model.X_AD_Task;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -32,37 +33,47 @@ import org.xml.sax.helpers.AttributesImpl;
public class TaskElementHandler extends AbstractElementHandler { public class TaskElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element) throws SAXException { public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue(); String elementValue = element.getElementValue();
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("ADTaskNameID")); log.info(elementValue + " " + atts.getValue("ADTaskNameID"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 && getUpdateMode(ctx).compareTo("true") == 0 ) { if (entitytype.equals("U")
|| (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
String name = atts.getValue("ADTaskNameID"); String name = atts.getValue("ADTaskNameID");
int id = get_ID(ctx, "AD_Task", name); int id = get_ID(ctx, "AD_Task", name);
MTask m_Task = new MTask(ctx, id, getTrxName(ctx)); MTask m_Task = new MTask(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1; int AD_Backup_ID = -1;
String Object_Status = null; String Object_Status = null;
if (id > 0){ if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Task",m_Task); AD_Backup_ID = copyRecord(ctx, "AD_Task", m_Task);
Object_Status = "Update"; Object_Status = "Update";
} } else {
else{
Object_Status = "New"; Object_Status = "New";
AD_Backup_ID =0; AD_Backup_ID = 0;
}
m_Task.setAccessLevel(atts.getValue("AccessLevel"));
m_Task.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",",""));
m_Task.setEntityType(atts.getValue("EntityType"));
m_Task.setHelp(atts.getValue("Help").replaceAll("'","''").replaceAll(",",""));
m_Task.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_Task.setName(name);
m_Task.setOS_Command(atts.getValue("OS_Command"));
if (m_Task.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_Task.getName(),"Task", m_Task.get_ID(),AD_Backup_ID, Object_Status,"AD_Task",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Task"));
} }
else{ m_Task.setAccessLevel(atts.getValue("AccessLevel"));
record_log (ctx, 0, m_Task.getName(),"Task", m_Task.get_ID(),AD_Backup_ID, Object_Status,"AD_Task",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Task")); m_Task.setDescription(atts.getValue("Description").replaceAll("'",
"''").replaceAll(",", ""));
m_Task.setEntityType(atts.getValue("EntityType"));
m_Task.setHelp(atts.getValue("Help").replaceAll("'", "''")
.replaceAll(",", ""));
m_Task.setIsActive(atts.getValue("isActive") != null ? Boolean
.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Task.setName(name);
m_Task.setOS_Command(atts.getValue("OS_Command"));
if (m_Task.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Task.getName(), "Task", m_Task.get_ID(),
AD_Backup_ID, Object_Status, "AD_Task",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Task"));
} else {
record_log(ctx, 0, m_Task.getName(), "Task", m_Task.get_ID(),
AD_Backup_ID, Object_Status, "AD_Task",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Task"));
throw new POSaveFailedException("Task");
} }
} }
} }
@ -73,35 +84,42 @@ public class TaskElementHandler extends AbstractElementHandler {
public void create(Properties ctx, TransformerHandler document) public void create(Properties ctx, TransformerHandler document)
throws SAXException { throws SAXException {
int AD_Task_ID = Env.getContextAsInt(ctx, "AD_Task_ID"); int AD_Task_ID = Env.getContextAsInt(ctx, "AD_Task_ID");
X_AD_Task m_Task = new X_AD_Task (ctx, AD_Task_ID, null); X_AD_Task m_Task = new X_AD_Task(ctx, AD_Task_ID, null);
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
createTaskBinding(atts,m_Task); createTaskBinding(atts, m_Task);
document.startElement("","","task",atts); document.startElement("", "", "task", atts);
document.endElement("","","task"); document.endElement("", "", "task");
} }
private static AttributesImpl createTaskBinding( AttributesImpl atts, X_AD_Task m_Task) private static AttributesImpl createTaskBinding(AttributesImpl atts,
{ X_AD_Task m_Task) {
String sql = null; String sql = null;
String name = null; String name = null;
atts.clear(); atts.clear();
if (m_Task.getAD_Task_ID()> 0 ){ if (m_Task.getAD_Task_ID() > 0) {
sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?"; sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?";
name = DB.getSQLValueString(null,sql,m_Task.getAD_Task_ID()); name = DB.getSQLValueString(null, sql, m_Task.getAD_Task_ID());
} }
if (name != null ) if (name != null)
atts.addAttribute("","","ADTaskNameID","CDATA",name); atts.addAttribute("", "", "ADTaskNameID", "CDATA", name);
else else
atts.addAttribute("","","ADTaskNameID","CDATA",""); atts.addAttribute("", "", "ADTaskNameID", "CDATA", "");
atts.addAttribute("","","AccessLevel","CDATA",(m_Task.getAccessLevel () != null ? m_Task.getAccessLevel ():"")); atts.addAttribute("", "", "AccessLevel", "CDATA", (m_Task
atts.addAttribute("","","Description","CDATA",(m_Task.getDescription () != null ? m_Task.getDescription ():"")); .getAccessLevel() != null ? m_Task.getAccessLevel() : ""));
atts.addAttribute("","","EntityType","CDATA",(m_Task.getEntityType () != null ? m_Task.getEntityType ():"")); atts.addAttribute("", "", "Description", "CDATA", (m_Task
atts.addAttribute("","","Help","CDATA",(m_Task.getHelp () != null ? m_Task.getHelp ():"")); .getDescription() != null ? m_Task.getDescription() : ""));
atts.addAttribute("","","isActive","CDATA",(m_Task.isActive()== true ? "true":"false")); atts.addAttribute("", "", "EntityType", "CDATA", (m_Task
atts.addAttribute("","","Name","CDATA",(m_Task.getName () != null ? m_Task.getName ():"")); .getEntityType() != null ? m_Task.getEntityType() : ""));
atts.addAttribute("","","OS_Command","CDATA",(m_Task.getOS_Command () != null ? m_Task.getOS_Command ():"")); atts.addAttribute("", "", "Help", "CDATA",
return atts; (m_Task.getHelp() != null ? m_Task.getHelp() : ""));
atts.addAttribute("", "", "isActive", "CDATA",
(m_Task.isActive() == true ? "true" : "false"));
atts.addAttribute("", "", "Name", "CDATA",
(m_Task.getName() != null ? m_Task.getName() : ""));
atts.addAttribute("", "", "OS_Command", "CDATA", (m_Task
.getOS_Command() != null ? m_Task.getOS_Command() : ""));
return atts;
} }
} }

View File

@ -59,7 +59,7 @@ public class UserRoleElementHandler extends AbstractElementHandler {
orgid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); orgid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name);
} }
sqlB = new StringBuffer ("SELECT count(*) FROM AD_User_Roles WHERE AD_User_ID = ? and AD_Role_ID = ? and AD_Org_ID = "+orgid); sqlB = new StringBuffer ("SELECT count(*) FROM AD_User_Roles WHERE AD_User_ID = ? and AD_Role_ID = ?");
int count = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),userid,roleid); int count = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),userid,roleid);
int AD_Backup_ID = -1; int AD_Backup_ID = -1;

View File

@ -43,12 +43,20 @@ public class WindowAccessElementHandler extends AbstractElementHandler {
String name = atts.getValue("rolename"); String name = atts.getValue("rolename");
sqlB = new StringBuffer ("SELECT AD_Role_ID FROM AD_Role WHERE Name= ?"); sqlB = new StringBuffer ("SELECT AD_Role_ID FROM AD_Role WHERE Name= ?");
roleid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); roleid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name);
if (roleid <= 0) {
element.defer = true;
return;
}
} }
if (atts.getValue("windowname")!=null){ if (atts.getValue("windowname")!=null){
String name = atts.getValue("windowname"); String name = atts.getValue("windowname");
sqlB = new StringBuffer ("SELECT AD_Window_ID FROM AD_Window WHERE Name= ?"); sqlB = new StringBuffer ("SELECT AD_Window_ID FROM AD_Window WHERE Name= ?");
windowid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name); windowid = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),name);
if (windowid <= 0) {
element.defer = true;
return;
}
} }
sqlB = new StringBuffer ("SELECT count(*) FROM AD_Window_Access WHERE AD_Role_ID=? and AD_Window_ID=?"); sqlB = new StringBuffer ("SELECT count(*) FROM AD_Window_Access WHERE AD_Role_ID=? and AD_Window_ID=?");

View File

@ -51,8 +51,7 @@ public class WindowElementHandler extends AbstractElementHandler {
Attributes atts = element.attributes; Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name")); log.info(elementValue + " " + atts.getValue("Name"));
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
if (entitytype.compareTo("U") == 0 || entitytype.compareTo("D") == 0 if (entitytype.equals("U") || (entitytype.equals("D") && getUpdateMode(ctx).equals("true"))) {
&& getUpdateMode(ctx).compareTo("true") == 0) {
String name = atts.getValue("Name"); String name = atts.getValue("Name");
int id = get_ID(ctx, "AD_Window", name); int id = get_ID(ctx, "AD_Window", name);
MWindow m_Window = new MWindow(ctx, id, getTrxName(ctx)); MWindow m_Window = new MWindow(ctx, id, getTrxName(ctx));
@ -70,21 +69,27 @@ public class WindowElementHandler extends AbstractElementHandler {
name = atts.getValue("ADImageNameID"); name = atts.getValue("ADImageNameID");
if (name != null && name.trim().length() > 0) { if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Image", "Name", name); id = get_IDWithColumn(ctx, "AD_Image", "Name", name);
//TODO: export and import of ad_image
/*
if (id <= 0) { if (id <= 0) {
element.defer = true; element.defer = true;
return; return;
} }*/
m_Window.setAD_Image_ID(id); if (id > 0)
m_Window.setAD_Image_ID(id);
} }
name = atts.getValue("ADColorNameID"); name = atts.getValue("ADColorNameID");
if (name != null && name.trim().length() > 0) { if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Color", "Name", name); id = get_IDWithColumn(ctx, "AD_Color", "Name", name);
//TODO: export and import of ad_color
/*
if (id <= 0) { if (id <= 0) {
element.defer = true; element.defer = true;
return; return;
} }*/
m_Window.setAD_Color_ID(id); if (id > 0)
m_Window.setAD_Color_ID(id);
} }
m_Window.setDescription(atts.getValue("Description").replaceAll( m_Window.setDescription(atts.getValue("Description").replaceAll(
@ -111,6 +116,7 @@ public class WindowElementHandler extends AbstractElementHandler {
.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", .get_ID(), AD_Backup_ID, Object_Status, "AD_Window",
get_IDWithColumn(ctx, "AD_Table", "TableName", get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Window")); "AD_Window"));
element.recordId = m_Window.getAD_Window_ID();
} else { } else {
record_log(ctx, 0, m_Window.getName(), "Window", m_Window record_log(ctx, 0, m_Window.getName(), "Window", m_Window
.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", .get_ID(), AD_Backup_ID, Object_Status, "AD_Window",
@ -170,6 +176,8 @@ public class WindowElementHandler extends AbstractElementHandler {
} }
pstmt = null; pstmt = null;
} }
//TODO: export of ad_image and ad_color use
// Loop tags. // Loop tags.
document.endElement("", "", "window"); document.endElement("", "", "window");
@ -232,19 +240,26 @@ public class WindowElementHandler extends AbstractElementHandler {
if (m_Window.getAD_Image_ID() > 0) { if (m_Window.getAD_Image_ID() > 0) {
sql = "SELECT Name FROM AD_Image WHERE AD_Image_ID=?"; sql = "SELECT Name FROM AD_Image WHERE AD_Image_ID=?";
name = DB.getSQLValueString(null, sql, m_Window.getAD_Image_ID()); name = DB.getSQLValueString(null, sql, m_Window.getAD_Image_ID());
if (name != null)
atts.addAttribute("", "", "ADImageNameID", "CDATA", name);
else
atts.addAttribute("", "", "ADImageNameID", "CDATA", "");
} }
if (name != null) else {
atts.addAttribute("", "", "ADImageNameID", "CDATA", name);
else
atts.addAttribute("", "", "ADImageNameID", "CDATA", ""); atts.addAttribute("", "", "ADImageNameID", "CDATA", "");
}
if (m_Window.getAD_Color_ID() > 0) { if (m_Window.getAD_Color_ID() > 0) {
sql = "SELECT Name FROM AD_Color WHERE AD_Color_ID=?"; sql = "SELECT Name FROM AD_Color WHERE AD_Color_ID=?";
name = DB.getSQLValueString(null, sql, m_Window.getAD_Color_ID()); name = DB.getSQLValueString(null, sql, m_Window.getAD_Color_ID());
} if (name != null)
if (name != null) atts.addAttribute("", "", "ADColorNameID", "CDATA", name);
atts.addAttribute("", "", "ADColorNameID", "CDATA", name); else
else atts.addAttribute("", "", "ADColorNameID", "CDATA", "");
} else {
atts.addAttribute("", "", "ADColorNameID", "CDATA", ""); atts.addAttribute("", "", "ADColorNameID", "CDATA", "");
}
atts.addAttribute("", "", "Description", "CDATA", (m_Window atts.addAttribute("", "", "Description", "CDATA", (m_Window
.getDescription() != null ? m_Window.getDescription() : "")); .getDescription() != null ? m_Window.getDescription() : ""));
atts.addAttribute("", "", "EntityType", "CDATA", (m_Window atts.addAttribute("", "", "EntityType", "CDATA", (m_Window

View File

@ -59,9 +59,9 @@ public class WorkbenchElementHandler extends AbstractElementHandler {
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID")); int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID"));
int columnid = get_IDWithMasterAndColumn (ctx, "AD_Column","ColumnName", atts.getValue("ADColumnNameID"), "AD_Table", tableid); int columnid = get_IDWithMasterAndColumn (ctx, "AD_Column","ColumnName", atts.getValue("ADColumnNameID"), "AD_Table", tableid);
m_Workbench.setAD_Column_ID(columnid); m_Workbench.setAD_Column_ID(columnid);
m_Workbench.setDescription(atts.getValue("Description").replaceAll("'","''").replaceAll(",","")); m_Workbench.setDescription(atts.getValue("Description").replaceAll("'","''"));
m_Workbench.setEntityType(atts.getValue("EntityType")); m_Workbench.setEntityType(atts.getValue("EntityType"));
m_Workbench.setHelp(atts.getValue("Help").replaceAll("'","''").replaceAll(",","")); m_Workbench.setHelp(atts.getValue("Help").replaceAll("'","''"));
m_Workbench.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true); m_Workbench.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
m_Workbench.setName(atts.getValue("Name")); m_Workbench.setName(atts.getValue("Name"));
//m_Workbench.setPA_Goal_ID(Integer.parseInt(atts.getValue("PAGoalID"))); //m_Workbench.setPA_Goal_ID(Integer.parseInt(atts.getValue("PAGoalID")));

View File

@ -54,8 +54,8 @@ public class WorkflowElementHandler extends AbstractElementHandler {
String entitytype = atts.getValue("EntityType"); String entitytype = atts.getValue("EntityType");
log.info("entitytype " + atts.getValue("EntityType")); log.info("entitytype " + atts.getValue("EntityType"));
if (entitytype.equals("U") || entitytype.equals("D") if (entitytype.equals("U") || (entitytype.equals("D")
&& getUpdateMode(ctx).equals("true")) { && getUpdateMode(ctx).equals("true"))) {
log.info("entitytype is a U or D"); log.info("entitytype is a U or D");
String workflowName = atts.getValue("Name"); String workflowName = atts.getValue("Name");

View File

@ -309,7 +309,9 @@ public class MColumn extends X_AD_Column
{ {
if (DisplayType.isText(getAD_Reference_ID()) if (DisplayType.isText(getAD_Reference_ID())
|| getAD_Reference_ID() == DisplayType.List || getAD_Reference_ID() == DisplayType.List
|| getAD_Reference_ID() == DisplayType.YesNo) || getAD_Reference_ID() == DisplayType.YesNo
|| (getAD_Reference_ID() == DisplayType.Button &&
!(getColumnName().endsWith("_ID"))))
{ {
if (!defaultValue.startsWith("'") && !defaultValue.endsWith("'")) if (!defaultValue.startsWith("'") && !defaultValue.endsWith("'"))
defaultValue = DB.TO_STRING(defaultValue); defaultValue = DB.TO_STRING(defaultValue);
@ -354,7 +356,8 @@ public class MColumn extends X_AD_Column
if (DisplayType.isText(getAD_Reference_ID()) if (DisplayType.isText(getAD_Reference_ID())
|| getAD_Reference_ID() == DisplayType.List || getAD_Reference_ID() == DisplayType.List
|| getAD_Reference_ID() == DisplayType.YesNo || getAD_Reference_ID() == DisplayType.YesNo
|| getAD_Reference_ID() == DisplayType.Table) || (getAD_Reference_ID() == DisplayType.Button &&
!(getColumnName().endsWith("_ID"))))
{ {
if (!defaultValue.startsWith("'") && !defaultValue.endsWith("'")) if (!defaultValue.startsWith("'") && !defaultValue.endsWith("'"))
defaultValue = DB.TO_STRING(defaultValue); defaultValue = DB.TO_STRING(defaultValue);

View File

@ -734,7 +734,7 @@ public final class MLookup extends Lookup implements Serializable
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, m_info.KeyColumn + ": Loader - " + sql, e); log.log(Level.SEVERE, m_info.KeyColumn + ", " + m_info.Column_ID + " : Loader - " + sql, e);
} }
int size = m_lookup.size(); int size = m_lookup.size();
log.finer(m_info.KeyColumn log.finer(m_info.KeyColumn

View File

@ -614,11 +614,13 @@ public class MTable extends X_AD_Table
// Sync Table ID // Sync Table ID
if (newRecord) if (newRecord)
{ {
MSequence.createTableSequence(getCtx(), getTableName(), get_TrxName()); MSequence seq = MSequence.get(getCtx(), getTableName(), get_TrxName());
if (seq == null || seq.get_ID() == 0)
MSequence.createTableSequence(getCtx(), getTableName(), get_TrxName());
} }
else else
{ {
MSequence seq = MSequence.get(getCtx(), getTableName()); MSequence seq = MSequence.get(getCtx(), getTableName(), get_TrxName());
if (seq == null || seq.get_ID() == 0) if (seq == null || seq.get_ID() == 0)
MSequence.createTableSequence(getCtx(), getTableName(), get_TrxName()); MSequence.createTableSequence(getCtx(), getTableName(), get_TrxName());
else if (!seq.getName().equals(getTableName())) else if (!seq.getName().equals(getTableName()))

View File

@ -754,6 +754,22 @@ public abstract class PO
else if (p_info.getColumnClass(index) == Boolean.class else if (p_info.getColumnClass(index) == Boolean.class
&& ("Y".equals(value) || "N".equals(value)) ) && ("Y".equals(value) || "N".equals(value)) )
m_newValues[index] = new Boolean("Y".equals(value)); m_newValues[index] = new Boolean("Y".equals(value));
else if (p_info.getColumnClass(index) == Integer.class
&& value.getClass() == String.class)
{
try
{
int intValue = Integer.parseInt((String)value);
m_newValues[index] = Integer.valueOf(intValue);
}
catch (Exception e)
{
log.warning (ColumnName
+ " - Class invalid: " + value.getClass().toString()
+ ", Should be " + p_info.getColumnClass(index).toString() + ": " + value);
m_newValues[index] = null;
}
}
else else
{ {
log.warning (ColumnName log.warning (ColumnName

View File

@ -499,6 +499,7 @@ public class CLogMgt
sb.append(getMsg("ImplementationVersion")).append(eq).append(org.compiere.Adempiere.getImplementationVersion()).append(NL); sb.append(getMsg("ImplementationVersion")).append(eq).append(org.compiere.Adempiere.getImplementationVersion()).append(NL);
// //
sb.append("AdempiereHome = ").append(Adempiere.getAdempiereHome()).append(NL); sb.append("AdempiereHome = ").append(Adempiere.getAdempiereHome()).append(NL);
sb.append("AdempiereProperties = ").append(Ini.getPropertyFileName()).append(NL);
sb.append(Env.getLanguage(Env.getCtx())).append(NL); sb.append(Env.getLanguage(Env.getCtx())).append(NL);
MClient client = MClient.get(Env.getCtx()); MClient client = MClient.get(Env.getCtx());
sb.append(client).append(NL); sb.append(client).append(NL);