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

View File

@ -32,6 +32,10 @@ public class Element {
public Attributes attributes;
//defer for later reprocessing
public boolean defer = false;
//parent element
public Element parent;
//resolved db recordid, store for reference by child element
public int recordId = 0;
/**
* @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) {
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_"))
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) {
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());
if (!tableName.startsWith("AD_"))
sqlB = sqlB.append(" and AD_Client_ID=?");
//here!
sqlB = sqlB.append(" Order By "+tableName+"_ID");
sqlB = sqlB.append(" Order By ")
.append(tableName)
.append("_ID");
try {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
if (value instanceof String)
pstmt.setString(1, ((String)value).toUpperCase());
pstmt.setString(1, (String)value);
else if (value instanceof Integer)
pstmt.setInt(1, ((Integer)value).intValue());
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) {
int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where UPPER(name)=? and "
+ tableNameMaster+"_ID = (select "+tableNameMaster+"_ID from "+tableNameMaster+" where UPPER(name)=?)");
StringBuffer sqlB = new StringBuffer ("select ")
.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 {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
pstmt.setString(1, name.toUpperCase());
pstmt.setString(2, nameMaster.toUpperCase());
pstmt.setString(1, name);
pstmt.setString(2, nameMaster);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
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) {
int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where UPPER("+columnName+")=? and "
+ tableNameMaster+"_ID =?");
StringBuffer sqlB = new StringBuffer ("select ")
.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 "
// + tableNameMaster+"_ID ="+masterID);
log.info(sqlB.toString());
@ -158,7 +185,7 @@ public class IDFinder {
try {
PreparedStatement pstmt = DB.prepareStatement(sqlB.toString(), trxName);
pstmt.setString(1, name.toUpperCase());
pstmt.setString(1, name);
pstmt.setInt(2, masterID);
ResultSet rs = pstmt.executeQuery();
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) {
int id = 0;
StringBuffer sqlB = new StringBuffer ("select "+tableName+"_ID from "+tableName+" where name=? and "
+ tableNameMaster+"_ID=?");
StringBuffer sqlB = new StringBuffer ("select ")
.append(tableName)
.append("_ID from ")
.append(tableName)
.append(" where name=? and ")
.append(tableNameMaster)
.append("_ID=?");
try {
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) {
int id = 0;
String sql = "SELECT "+tableName+"_ID "
+ "FROM "+tableName+" "
+ "WHERE name=?";
StringBuffer sql = new StringBuffer("SELECT ")
.append(tableName)
.append("_ID ")
.append("FROM ")
.append(tableName)
.append(" ")
.append("WHERE name=?");
if (!tableName.startsWith("AD_"))
sql = sql + " AND AD_Client_ID=?";
sql.append(" AND AD_Client_ID=?");
try {
PreparedStatement pstmt = DB.prepareStatement(sql, trxName);
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), trxName);
pstmt.setString(1, name);
if (!tableName.startsWith("AD_"))
pstmt.setInt(2, AD_Client_ID);

View File

@ -20,6 +20,8 @@ package org.adempiere.pipo;
import java.io.File;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import org.compiere.Adempiere;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.CLogger;
@ -29,7 +31,10 @@ import org.compiere.util.CLogMgt;
import org.compiere.util.DB;
import org.compiere.util.Env;
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.logging.*;
@ -42,10 +47,59 @@ public class PackIn extends SvrProcess {
/** Logger */
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_Package_Dir = null;
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() {
p_PackIn_ID = getRecord_ID();
@ -61,7 +115,7 @@ public class PackIn extends SvrProcess {
* xml file to read
* @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);
File in = new File(fileName);
if (!in.exists()) {
@ -87,7 +141,7 @@ public class PackIn extends SvrProcess {
return "OK.";
} catch (Exception e) {
log.log(Level.SEVERE, "importXML:", e);
return e.toString();
throw e;
}
}
@ -97,21 +151,22 @@ public class PackIn extends SvrProcess {
* @return ""
*
*/
protected String doIt() {
protected String doIt() throws Exception {
X_AD_Package_Imp_Proc adPackageImp = new X_AD_Package_Imp_Proc(getCtx(),
p_PackIn_ID, null);
// Create Target directory if required
String fileSeparator = null;
File tempfile = new File("");
fileSeparator = tempfile.separator;
File targetDir = new File(adPackageImp.getAD_Package_Dir() + fileSeparator
String packageDirectory = adPackageImp.getAD_Package_Dir();
if (packageDirectory == null || packageDirectory.trim().length() == 0) {
packageDirectory = Adempiere.getAdempiereHome();
}
File targetDir = new File( packageDirectory + File.separator
+ "packages");
if (!targetDir.exists()) {
boolean success = (new File(adPackageImp.getAD_Package_Dir()
+ fileSeparator + "packages")).mkdirs();
boolean success = (new File(packageDirectory
+ File.separator + "packages")).mkdirs();
if (!success) {
log.info("Target directory creation failed");
}
@ -123,26 +178,26 @@ public class PackIn extends SvrProcess {
String PackageName = CreateZipFile.getParentDir(zipFilepath);
CreateZipFile.unpackFile(zipFilepath, targetDir);
String dict_file = adPackageImp.getAD_Package_Dir() + fileSeparator
+ "packages" + fileSeparator + PackageName + fileSeparator
+ "dict" + fileSeparator + "PackOut.xml";
String dict_file = packageDirectory + File.separator
+ "packages" + File.separator + PackageName + File.separator
+ "dict" + File.separator + "PackOut.xml";
log.info("dict file->" + dict_file);
PackIn impXML = new PackIn();
PackIn packIn = new PackIn();
if (adPackageImp.isAD_Override_Dict() == true)
impXML.m_UpdateMode = "true";
packIn.m_UpdateMode = "true";
else
impXML.m_UpdateMode = "false";
packIn.m_UpdateMode = "false";
impXML.m_Package_Dir = adPackageImp.getAD_Package_Dir() + fileSeparator
+ "packages" + fileSeparator + PackageName + fileSeparator;
packIn.m_Package_Dir = packageDirectory + File.separator
+ "packages" + File.separator + PackageName + File.separator;
if (DB.isOracle())
impXML.m_Database = "Oracle";
packIn.m_Database = "Oracle";
else if (DB.isPostgreSQL())
impXML.m_Database = "PostgreSQL";
packIn.m_Database = "PostgreSQL";
// call XML Handler
impXML.importXML(dict_file, getCtx(), get_TrxName());
String msg = packIn.importXML(dict_file, getCtx(), get_TrxName());
// Generate Model Classes
// 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.util.GenerateModel.main(args) ;
return "Finish Process";
return msg;
} // doIt
/***************************************************************************
@ -176,7 +231,7 @@ public class PackIn extends SvrProcess {
Ini.setProperty(Ini.P_ADEMPIERESYS, true);
}
PackIn impXML = new PackIn();
PackIn packIn = new PackIn();
// org.compiere.Compiere.startupEnvironment(true);
// Force connection if there are enough parameters. Else we work with
// Compiere.properties
@ -185,7 +240,7 @@ public class PackIn extends SvrProcess {
// Integer.valueOf(args[2]).intValue(), args[5], args[3], args[4]);
CConnection cc = CConnection.get();
// System.out.println("DB Connect String1:"+cc.getDbName());
impXML.m_Database = cc.getType();
packIn.m_Database = cc.getType();
DB.setDBTarget(cc);
}
@ -226,10 +281,21 @@ public class PackIn extends SvrProcess {
CLogMgt.setLevel(logLevel);
CLogMgt.setLoggerLevel(logLevel, null);
// impXML.setUpdateMode(args[7]);
impXML.m_UpdateMode = args[7];
if (args.length >= 8)
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);
} // main

View File

@ -326,7 +326,7 @@ public class PackInHandler extends DefaultHandler {
.append( ", '" + atts.getValue("CompVer") )
.append( "', '" + atts.getValue("Version") )
.append( "', '" + atts.getValue("DataBase") )
.append( "', '" + atts.getValue("Description").replaceAll("'","''").replaceAll(",","") )
.append( "', '" + atts.getValue("Description").replaceAll("'","''"))
.append( "', '" + atts.getValue("Name") )
.append( "', '" + atts.getValue("creator") )
.append( "', '" + atts.getValue("creatorcontact") )
@ -357,7 +357,7 @@ public class PackInHandler extends DefaultHandler {
.append( ", '" + atts.getValue("CompVer") )
.append( "', '" + atts.getValue("Version") )
.append( "', '" + atts.getValue("DataBase") )
.append( "', '" + atts.getValue("Description").replaceAll("'","''").replaceAll(",","") )
.append( "', '" + atts.getValue("Description").replaceAll("'","''"))
.append( "', '" + atts.getValue("Name") )
.append( "', '" + atts.getValue("creator") )
.append( "', '" + atts.getValue("creatorcontact") )
@ -387,20 +387,27 @@ public class PackInHandler extends DefaultHandler {
Env.setContext(m_ctx, "PackageDirectory", packageDirectory);
m_ctx.put("Document", hd_document);
m_ctx.put("DocumentAttributes", attsOut);
m_ctx.put("PackInProcess", packIn);
}
else if (elementValue.equals("menu")) {
//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);
}
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);
ElementHandler handler = handlers.get(elementValue);
if (handler != null)
handler.startElement(m_ctx, e);
if (e.defer)
if (e.defer) {
defer.add(new DeferEntry(e, true));
}
}
} // startElement
@ -642,6 +649,8 @@ public class PackInHandler extends DefaultHandler {
handler.endElement(m_ctx, e);
if (e.defer)
defer.add(new DeferEntry(e, false));
else
log.info("Processed: " + e.getElementValue() + " - " + e.attributes.getValue(0));
}
} // endElement
@ -677,6 +686,11 @@ public class PackInHandler extends DefaultHandler {
int endSize = defer.size();
if (startSize == endSize) break;
} 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

View File

@ -67,20 +67,18 @@ public class CodeSnipitElementHandler extends AbstractElementHandler {
String packagePath=null;
String sourcePath=null;
//get compiere-all directory
//get adempiere-all directory
try {
packagePath = currentDirectory.getCanonicalPath();
packagePath = getPackageDirectory(ctx);
File parentDirectory = new File(packagePath);
while (!parentDirectory.getName().equals("packages")){
parentDirectory = parentDirectory.getParentFile();
}
parentDirectory = parentDirectory.getParentFile();
sourcePath = parentDirectory.getCanonicalPath();
} 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
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.Element;
import org.adempiere.pipo.PackIn;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MColumn;
@ -43,19 +44,40 @@ public class ColumnElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
PackIn packIn = (PackIn)ctx.get("PackInProcess");
String elementValue = element.getElementValue();
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ColumnName"));
int success = 0;
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("table") &&
element.parent.defer) {
element.defer = true;
return;
}
String columnName = atts.getValue("ColumnName");
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts
.getValue("ADTableNameID"));
int id = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName",
String tableName = atts.getValue("ADTableNameID");
int tableid = 0;
if (element.parent != null && element.parent.getElementValue().equals("table") &&
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);
if (id > 0) {
packIn.addColumn(tableName, columnName, id);
}
}
MColumn m_Column = new MColumn(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
@ -193,19 +215,22 @@ public class ColumnElementHandler extends AbstractElementHandler {
}
// 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) {
String sync = atts.getValue("getIsSyncDatabase");
if (m_Column.isVirtualColumn() || sync == null
|| (!sync.equals("Y")))
if (m_Column.isVirtualColumn() || !syncDatabase)
recreateColumn = false;
}
if (tableName.equals("A_Depreciation") && columnName.equals("Processed")) {
System.out.println("A_Depreciation.Processed: " + recreateColumn);
}
if (m_Column.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Column.getName(), "Column", m_Column
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Column"));
element.recordId = m_Column.getAD_Column_ID();
} else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
@ -214,8 +239,8 @@ public class ColumnElementHandler extends AbstractElementHandler {
throw new POSaveFailedException("Column");
}
if (recreateColumn) {
success = createcolumn(ctx, m_Column);
if (recreateColumn || syncDatabase) {
success = createColumn(ctx, m_Column, recreateColumn);
if (success == 1) {
record_log(ctx, 1, m_Column.getColumnName(), "dbColumn",
@ -246,7 +271,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
* @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));
if (table.isView())
return 0;
@ -280,11 +305,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
//
rsc = md.getColumns(catalog, schema, tableName, columnName);
if (rsc.next()) {
// update existing column
boolean notNull = DatabaseMetaData.columnNoNulls == rsc
.getInt("NULLABLE");
sql = column.getSQLModify(table,
column.isMandatory() != notNull);
if (doAlter) {
// update existing column
boolean notNull = DatabaseMetaData.columnNoNulls == rsc
.getInt("NULLABLE");
sql = column.getSQLModify(table,
column.isMandatory() != notNull);
}
} else {
// No existing column
sql = column.getSQLAdd(table);
@ -295,19 +322,21 @@ public class ColumnElementHandler extends AbstractElementHandler {
rst.close();
rst = null;
log.info(sql);
if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) {
no = DB.executeUpdate(sql, false, getTrxName(ctx));
} else {
String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR);
for (int i = 0; i < statements.length; i++) {
int count = DB.executeUpdate(statements[i], false,
getTrxName(ctx));
no += count;
//execute modify or add if needed
if (sql != null && sql.trim().length() > 0) {
log.info(sql);
if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) {
no = DB.executeUpdate(sql, false, getTrxName(ctx));
} else {
String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR);
for (int i = 0; i < statements.length; i++) {
int count = DB.executeUpdate(statements[i], false,
getTrxName(ctx));
no += count;
}
}
}
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
if (rsc != null) {
@ -443,9 +472,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
.isUpdateable() == true ? "true" : "false"));
atts.addAttribute("", "", "Name", "CDATA",
(m_Column.getName() != null ? m_Column.getName() : ""));
atts.addAttribute("", "", "getIsSyncDatabase", "CDATA", (m_Column
.getIsSyncDatabase() != null ? m_Column.getIsSyncDatabase()
: ""));
atts.addAttribute("", "", "getIsSyncDatabase", "CDATA", "Y");
atts
.addAttribute("", "", "ReadOnlyLogic", "CDATA", (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.GenericPO;
import org.adempiere.pipo.IDFinder;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.POInfo;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.DB;
@ -46,7 +47,7 @@ public class DataElementHandler extends AbstractElementHandler {
private GenericPO genericPO = null;
int AD_Backup_ID = -1;
String Object_Status = null;
String objectStatus = null;
String d_tablename = null;
private DataRowElementHandler rowHandler = new DataRowElementHandler();
@ -101,10 +102,10 @@ public class DataElementHandler extends AbstractElementHandler {
genericPO = new GenericPO(ctx, id, getTrxName(ctx));
if (id > 0){
AD_Backup_ID = copyRecord(ctx,d_tablename,genericPO);
Object_Status = "Update";
objectStatus = "Update";
}
else{
Object_Status = "New";
objectStatus = "New";
AD_Backup_ID =0;
}
}
@ -131,7 +132,7 @@ public class DataElementHandler extends AbstractElementHandler {
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
Object_Status = "Update";
objectStatus = "Update";
genericPO = new GenericPO(ctx, rs, getTrxName(ctx));
rs.close();
pstmt.close();
@ -142,7 +143,7 @@ public class DataElementHandler extends AbstractElementHandler {
rs.close();
pstmt.close();
pstmt = null;
Object_Status = "New";
objectStatus = "New";
// set keyXname.
CURRENT_KEY = "key1name";
if (!atts.getValue(CURRENT_KEY).equals("")) {
@ -202,9 +203,11 @@ public class DataElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException {
if (genericPO != null) {
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));
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, 1, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
else {
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;
}
@ -229,9 +232,9 @@ public class DataElementHandler extends AbstractElementHandler {
String isUpdateable = DB.getSQLValueString(getTrxName(ctx), sql.toString(),id);
sql = new StringBuffer ("SELECT IsKey FROM AD_column WHERE AD_Column_ID = ?");
String isKey = DB.getSQLValueString(getTrxName(ctx), sql.toString(),id);
if (isKey.equals("N") &&
if (("New".equals(objectStatus)) || (isKey.equals("N") &&
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("class").equals("String") || atts.getValue("class").equals("Text")
|| 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 sourcePath=null;
//get compiere-all directory
//get adempiere-all directory
try {
packagePath = getPackageDirectory(ctx);
File parentDirectory = new File(packagePath);
@ -73,7 +73,7 @@ public class DistFileElementHandler extends AbstractElementHandler {
parentDirectory = parentDirectory.getParentFile();
sourcePath = parentDirectory.getCanonicalPath();
} 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;
log.info(elementValue+" "+atts.getValue("Name"));
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");
int id = get_IDWithColumn(ctx, "AD_Val_Rule", "name", name);
@ -55,7 +55,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
Object_Status = "New";
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.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
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.Element;
import org.adempiere.pipo.PackIn;
import org.compiere.model.MField;
import org.compiere.model.X_AD_Field;
import org.compiere.util.DB;
@ -33,76 +34,133 @@ import org.xml.sax.helpers.AttributesImpl;
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();
Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("Name"));
log.info(elementValue + " " + atts.getValue("Name"));
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 tabname = atts.getValue("ADTabNameID");
String colname = atts.getValue("ADColumnNameID");
// log.info("Column Name ->"+colname);
// log.info("Database Name ->"+m_DatabaseType);
int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID"));
int windowid = get_ID(ctx, "AD_Window", atts.getValue("ADWindowNameID"));
//log.info("Column Name ->"+colname);
int columnid = get_IDWithMasterAndColumn (ctx, "AD_Column","ColumnName", colname, "AD_Table", tableid);
//log.info("ColumnID->"+columnid);
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 = ?");
int tabid = DB.getSQLValue(getTrxName(ctx), sqlB.toString (), tableid);
if (tabid > 0 )
{
sqlB = new StringBuffer ("select AD_Field_ID from AD_Field where AD_Column_ID = "+columnid
+ " and AD_Tab_ID = ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString (), tabid);
String tableName = atts.getValue("ADTableNameID");
int tableid = packIn.getTableId(tableName);
if (tableid <= 0) {
tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
if (tableid > 0)
packIn.addTable(tableName, tableid);
}
if (tableid <= 0) {
element.defer = true;
return;
}
int windowid = get_ID(ctx, "AD_Window", atts
.getValue("ADWindowNameID"));
if (windowid <= 0) {
element.defer = true;
return;
}
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));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Field",m_Field);
Object_Status = "Update";
}
else{
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Field", m_Field);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID =0;
AD_Backup_ID = 0;
}
m_Field.setName(atts.getValue("Name"));
m_Field.setAD_Column_ID(columnid);
name = atts.getValue("ADFieldGroupNameID");
name = atts.getValue("ADFieldGroupNameID");
id = get_IDWithColumn(ctx, "AD_FieldGroup", "Name", name);
m_Field.setAD_FieldGroup_ID(id);
m_Field.setAD_Tab_ID(tabid);
m_Field.setEntityType (atts.getValue("EntityType"));
m_Field.setIsSameLine(Boolean.valueOf(atts.getValue("SameLine")).booleanValue());
m_Field.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("isCentrallyMaintained")).booleanValue());
m_Field.setIsDisplayed(Boolean.valueOf(atts.getValue("Displayed")).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.setAD_FieldGroup_ID(id);
m_Field.setAD_Tab_ID(tabid);
m_Field.setEntityType(atts.getValue("EntityType"));
m_Field.setIsSameLine(Boolean
.valueOf(atts.getValue("SameLine")).booleanValue());
m_Field.setIsCentrallyMaintained(Boolean.valueOf(
atts.getValue("isCentrallyMaintained")).booleanValue());
m_Field.setIsDisplayed(Boolean.valueOf(
atts.getValue("Displayed")).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.setDisplayLength(Integer.parseInt(atts.getValue("DisplayLength")));
m_Field.setDescription(atts.getValue("Description").replaceAll("'","''").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.setDisplayLength(Integer.parseInt(atts
.getValue("DisplayLength")));
m_Field.setDescription(atts.getValue("Description").replaceAll(
"'", "''").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.setDisplayLogic(atts.getValue("DisplayLogic"));
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"));
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"));
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{
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
log.severe("Tab do not exist to field Name: "+ name);
}
} else {
element.defer = true;
return;
}
}
}
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)
throws SAXException {
int AD_Field_ID = Env.getContextAsInt(ctx, X_AD_Field.COLUMNNAME_AD_Field_ID);
X_AD_Field m_Field = new X_AD_Field (ctx, AD_Field_ID, null);
int AD_Field_ID = Env.getContextAsInt(ctx,
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();
createFieldBinding(atts,m_Field);
document.startElement("","","field",atts);
document.endElement("","","field");
createFieldBinding(atts, m_Field);
document.startElement("", "", "field", atts);
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 name = null;
String name = null;
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=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_Column_ID());
atts.addAttribute("","","ADColumnNameID","CDATA",name);
}
else
atts.addAttribute("","","ADColumnNameID","CDATA","");
if (m_Field.getAD_Column_ID()> 0 ){
name = DB.getSQLValueString(null, sql, m_Field.getAD_Column_ID());
atts.addAttribute("", "", "ADColumnNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADColumnNameID", "CDATA", "");
if (m_Field.getAD_Column_ID() > 0) {
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=?";
name = DB.getSQLValueString(null,sql,idTable);
atts.addAttribute("","","ADTableNameID","CDATA",name);
}
else
atts.addAttribute("","","ADTableNameID","CDATA","");
if (m_Field.getAD_FieldGroup_ID()> 0 ){
name = DB.getSQLValueString(null, sql, idTable);
atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADTableNameID", "CDATA", "");
if (m_Field.getAD_FieldGroup_ID() > 0) {
sql = "SELECT Name FROM AD_FieldGroup WHERE AD_FieldGroup_ID=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_FieldGroup_ID());
atts.addAttribute("","","ADFieldGroupNameID","CDATA",name);
}
else
atts.addAttribute("","","ADFieldGroupNameID","CDATA","");
if (m_Field.getAD_Field_ID()> 0 ){
name = DB.getSQLValueString(null, sql, m_Field
.getAD_FieldGroup_ID());
atts.addAttribute("", "", "ADFieldGroupNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADFieldGroupNameID", "CDATA", "");
if (m_Field.getAD_Field_ID() > 0) {
sql = "SELECT Name FROM AD_Field WHERE AD_Field_ID=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_Field_ID());
atts.addAttribute("","","ADFieldNameID","CDATA",name);
}
else
atts.addAttribute("","","ADFieldNameID","CDATA","");
if (m_Field.getAD_Tab_ID()> 0 ){
sql = "SELECT Name FROM AD_Tab WHERE AD_Tab_ID=?";
name = DB.getSQLValueString(null,sql,m_Field.getAD_Tab_ID());
atts.addAttribute("","","ADTabNameID","CDATA",name);
sql = "SELECT AD_Window_ID FROM AD_Tab WHERE AD_Tab_ID=?";
int windowid = DB.getSQLValue(null,sql,m_Field.getAD_Tab_ID());
name = DB.getSQLValueString(null, sql, m_Field.getAD_Field_ID());
atts.addAttribute("", "", "ADFieldNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADFieldNameID", "CDATA", "");
if (m_Field.getAD_Tab_ID() > 0) {
sql = "SELECT Name FROM AD_Tab WHERE AD_Tab_ID=?";
name = DB.getSQLValueString(null, sql, m_Field.getAD_Tab_ID());
atts.addAttribute("", "", "ADTabNameID", "CDATA", name);
sql = "SELECT AD_Window_ID FROM AD_Tab WHERE AD_Tab_ID=?";
int windowid = DB.getSQLValue(null, sql, m_Field.getAD_Tab_ID());
sql = "SELECT Name FROM AD_Window WHERE AD_Window_ID=?";
name = DB.getSQLValueString(null,sql,windowid);
atts.addAttribute("","","ADWindowNameID","CDATA",name);
}
else
atts.addAttribute("","","ADTabNameID","CDATA","");
atts.addAttribute("","","EntityType","CDATA",(m_Field.getEntityType () != null ? m_Field.getEntityType ():""));
atts.addAttribute("","","Name","CDATA",(m_Field.getName () != null ? m_Field.getName ():""));
atts.addAttribute("","","SameLine","CDATA", (m_Field.isSameLine() == true ? "true":"false"));
atts.addAttribute("","","isCentrallyMaintained","CDATA",(m_Field.isCentrallyMaintained()== true ? "true":"false"));
atts.addAttribute("","","Displayed","CDATA",(m_Field.isDisplayed()== true ? "true":"false"));
atts.addAttribute("","","isActive","CDATA",(m_Field.isActive()== true ? "true":"false"));
atts.addAttribute("","","isEncrypted","CDATA",(m_Field.isEncrypted()== true ? "true":"false"));
atts.addAttribute("","","isFieldOnly","CDATA",(m_Field.isFieldOnly()== true ? "true":"false"));
atts.addAttribute("","","isHeading","CDATA",(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():""));
name = DB.getSQLValueString(null, sql, windowid);
atts.addAttribute("", "", "ADWindowNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADTabNameID", "CDATA", "");
atts.addAttribute("", "", "EntityType", "CDATA", (m_Field
.getEntityType() != null ? m_Field.getEntityType() : ""));
atts.addAttribute("", "", "Name", "CDATA",
(m_Field.getName() != null ? m_Field.getName() : ""));
atts.addAttribute("", "", "SameLine", "CDATA",
(m_Field.isSameLine() == true ? "true" : "false"));
atts.addAttribute("", "", "isCentrallyMaintained", "CDATA", (m_Field
.isCentrallyMaintained() == true ? "true" : "false"));
atts.addAttribute("", "", "Displayed", "CDATA",
(m_Field.isDisplayed() == true ? "true" : "false"));
atts.addAttribute("", "", "isActive", "CDATA",
(m_Field.isActive() == true ? "true" : "false"));
atts.addAttribute("", "", "isEncrypted", "CDATA", (m_Field
.isEncrypted() == true ? "true" : "false"));
atts.addAttribute("", "", "isFieldOnly", "CDATA", (m_Field
.isFieldOnly() == true ? "true" : "false"));
atts.addAttribute("", "", "isHeading", "CDATA",
(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;
}
}

View File

@ -38,7 +38,7 @@ public class FormElementHandler extends AbstractElementHandler {
log.info(elementValue+" "+atts.getValue("ADFormNameID"));
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");
int id = get_ID(ctx, "AD_Form", name);
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.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
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.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.setName(atts.getValue("Name"));

View File

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

View File

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

View File

@ -39,6 +39,11 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
String Object_Status = null;
Attributes atts = element.attributes;
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");
int id = get_IDWithMaster(ctx, "AD_PrintFormatItem", name,
@ -56,7 +61,16 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
}
m_PrintFormatItem.setName(name);
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) {
element.defer = true;
return;
@ -76,31 +90,40 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
name = atts.getValue("ADPrintGraphID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintGraph", "Name", name);
//TODO: export and import of ad_printgraph
/*
if (id <= 0) {
element.defer = true;
return;
}
m_PrintFormatItem.setAD_PrintGraph_ID(id);
}*/
if (id > 0)
m_PrintFormatItem.setAD_PrintGraph_ID(id);
}
name = atts.getValue("ADPrintColorID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintColor", "Name", name);
//TODO: export and import of ad_printcolor
/*
if (id <= 0) {
element.defer = true;
return;
}
m_PrintFormatItem.setAD_PrintColor_ID(id);
}*/
if (id > 0)
m_PrintFormatItem.setAD_PrintColor_ID(id);
}
name = atts.getValue("ADPrintFontID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_PrintFont", "Name", name);
//TODO: export and import of print font
/*
if (id <= 0) {
element.defer = true;
return;
}
m_PrintFormatItem.setAD_PrintFont_ID(id);
}*/
if (id > 0)
m_PrintFormatItem.setAD_PrintFont_ID(id);
}
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.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MProcess;
import org.compiere.model.MSequence;
import org.compiere.model.X_AD_Process;
import org.compiere.model.X_AD_Process_Para;
@ -50,22 +49,21 @@ public class ProcessElementHandler extends AbstractElementHandler {
log.info(elementValue + " " + atts.getValue("Name"));
int id = 0;
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("Name");
// Get New process.
id = get_ID(ctx, "AD_Process", name);
MProcess m_Process = null;
X_AD_Process m_Process = null;
int AD_Backup_ID = -1;
String Object_Status = null;
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);
Object_Status = "Update";
} 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),
"AD_Process", getTrxName(ctx));
m_Process.setAD_Process_ID(id);

View File

@ -39,8 +39,7 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
log.info(elementValue + " " + atts.getValue("Name"));
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("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.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -41,6 +43,8 @@ public class ReferenceElementHandler extends AbstractElementHandler {
private ReferenceListElementHandler listHandler = new ReferenceListElementHandler();
private ReferenceTableElementHandler tableHandler = new ReferenceTableElementHandler();
private List<Integer> references = new ArrayList<Integer>();
public void startElement(Properties ctx, Element element)
throws SAXException {
@ -63,6 +67,9 @@ public class ReferenceElementHandler extends AbstractElementHandler {
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reference", m_Reference);
Object_Status = "Update";
if (references.contains(id)) {
return;
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
@ -84,6 +91,7 @@ public class ReferenceElementHandler extends AbstractElementHandler {
m_Reference.get_ID(), AD_Backup_ID, Object_Status,
"AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference"));
references.add(m_Reference.getAD_Reference_ID());
} else {
record_log(ctx, 0, m_Reference.getName(), "Reference",
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"));
// TODO: Solve for date issues with valuefrom valueto
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("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"));
int id = get_IDWithMaster(ctx, "AD_Ref_List", name, "AD_Reference",
Referenceid);
X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, id,
int AD_Ref_List_ID = get_IDWithMasterAndColumn(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, AD_Ref_List_ID,
getTrxName(ctx));
if (id > 0) {
if (AD_Ref_List_ID > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Ref_List", m_Ref_List);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
name = atts.getValue("ADRefenceNameID");
id = get_IDWithColumn(ctx, "AD_Reference", "Name", name);
m_Ref_List.setAD_Reference_ID(id);
m_Ref_List.setDescription(atts.getValue("Description").replaceAll(
"'", "''").replaceAll(",", ""));
m_Ref_List.setAD_Reference_ID(AD_Reference_ID);
m_Ref_List.setDescription(atts.getValue("Description").replaceAll("'", "''"));
m_Ref_List.setEntityType(atts.getValue("EntityType"));
m_Ref_List.setName(atts.getValue("Name"));
m_Ref_List.setValue(value);
m_Ref_List.setIsActive(atts.getValue("isActive") != null ? Boolean
.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_Ref_List.setValue(atts.getValue("Value"));
if (m_Ref_List.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Ref_List.getName(), "Reference List",
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;
String entitytype = atts.getValue("EntityType");
String name = atts.getValue("ADRefenceNameID");
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"))) {
StringBuffer sqlB = new StringBuffer(
"SELECT AD_Reference_ID FROM AD_Reference WHERE Name= ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), name);
@ -126,10 +125,8 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
name, "AD_Table", tableId);
String entityType = atts.getValue("EntityType");
String isValueDisplayed = atts.getValue("IsValueDisplayed");
String OrderByClause = atts.getValue("OrderByClause").replaceAll(
"'", "''").replaceAll(",", "");
String WhereClause = atts.getValue("WhereClause").replaceAll("'",
"''").replaceAll(",", "");
String OrderByClause = atts.getValue("OrderByClause").replaceAll("'", "''");
String WhereClause = atts.getValue("WhereClause").replaceAll("'","''");
if (count > 0) {
sqlB = new StringBuffer("UPDATE AD_Ref_Table ").append(
"SET AD_Table_ID = " + tableId).append(

View File

@ -44,8 +44,7 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
String entitytype = atts.getValue("EntityType");
String name = atts.getValue("ADReportViewColID");
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"))) {
int id = get_ID(ctx, "AD_Reportview_Col", name);
X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx,
id, getTrxName(ctx));

View File

@ -27,6 +27,7 @@ import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTab;
import org.compiere.model.X_AD_Field;
import org.compiere.model.X_AD_Tab;
@ -45,11 +46,33 @@ public class TabElementHandler extends AbstractElementHandler {
Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("ADTabNameID"));
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");
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
+ " and Name = '"+name +"'"
+ " and AD_Table_ID = ?");
@ -110,10 +133,10 @@ public class TabElementHandler extends AbstractElementHandler {
m_Tab.setIncluded_Tab_ID(id);
}
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.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.setImportFields (atts.getValue("ImportFields"));
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());
}
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 {
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.Element;
import org.adempiere.pipo.PackIn;
import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTable;
import org.compiere.model.X_AD_Column;
import org.compiere.model.X_AD_Package_Exp_Detail;
@ -41,7 +43,10 @@ import org.xml.sax.helpers.AttributesImpl;
public class TableElementHandler extends AbstractElementHandler {
private ColumnElementHandler columnHandler = new ColumnElementHandler();
private List<Integer>tables = new ArrayList<Integer>();
public void startElement(Properties ctx, Element element) throws SAXException {
PackIn packIn = (PackIn)ctx.get("PackInProcess");
String elementValue = element.getElementValue();
Attributes atts = element.attributes;
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")) {
String tableName = atts.getValue("ADTableNameID");
int id = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
int id = packIn.getTableId(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));
int AD_Backup_ID = -1;
@ -79,9 +92,9 @@ public class TableElementHandler extends AbstractElementHandler {
m_Table.setAD_Val_Rule_ID(id);
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.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.setImportTable(atts.getValue("ImportTable"));
m_Table.setIsChangeLog(Boolean.valueOf(atts.getValue("isChangeLog")).booleanValue());
@ -96,10 +109,14 @@ public class TableElementHandler extends AbstractElementHandler {
// log.info("in3");
getDocumentAttributes(ctx).clear();
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{
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);
PackOut packOut = (PackOut)ctx.get("PackOutProcess");
boolean exported = isTableExported(ctx, AD_Table_ID);
boolean exported = isTableProcess(ctx, AD_Table_ID);
AttributesImpl atts = new AttributesImpl();
//Export table if not already done so
if (!exported){
@ -202,19 +219,12 @@ public class TableElementHandler extends AbstractElementHandler {
ctx.remove(X_AD_Column.COLUMNNAME_AD_Column_ID);
}
private boolean isTableExported(Properties ctx, int AD_Table_ID) {
List<Integer>tables = (List<Integer>)ctx.get("ExportedTables");
if (tables == null) {
tables = new ArrayList<Integer>();
private boolean isTableProcess(Properties ctx, int AD_Table_ID) {
if (tables.contains(AD_Table_ID))
return true;
else {
tables.add(AD_Table_ID);
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.Element;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTask;
import org.compiere.model.X_AD_Task;
import org.compiere.util.DB;
@ -32,37 +33,47 @@ import org.xml.sax.helpers.AttributesImpl;
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();
Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("ADTaskNameID"));
log.info(elementValue + " " + atts.getValue("ADTaskNameID"));
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");
int id = get_ID(ctx, "AD_Task", name);
MTask m_Task = new MTask(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Task",m_Task);
Object_Status = "Update";
}
else{
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Task", m_Task);
Object_Status = "Update";
} else {
Object_Status = "New";
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"));
AD_Backup_ID = 0;
}
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"));
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 {
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)
throws SAXException {
int AD_Task_ID = Env.getContextAsInt(ctx, "AD_Task_ID");
X_AD_Task m_Task = new X_AD_Task (ctx, AD_Task_ID, null);
AttributesImpl atts = new AttributesImpl();
createTaskBinding(atts,m_Task);
document.startElement("","","task",atts);
document.endElement("","","task");
X_AD_Task m_Task = new X_AD_Task(ctx, AD_Task_ID, null);
AttributesImpl atts = new AttributesImpl();
createTaskBinding(atts, m_Task);
document.startElement("", "", "task", atts);
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 name = null;
atts.clear();
if (m_Task.getAD_Task_ID()> 0 ){
sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?";
name = DB.getSQLValueString(null,sql,m_Task.getAD_Task_ID());
}
if (name != null )
atts.addAttribute("","","ADTaskNameID","CDATA",name);
else
atts.addAttribute("","","ADTaskNameID","CDATA","");
atts.addAttribute("","","AccessLevel","CDATA",(m_Task.getAccessLevel () != null ? m_Task.getAccessLevel ():""));
atts.addAttribute("","","Description","CDATA",(m_Task.getDescription () != null ? m_Task.getDescription ():""));
atts.addAttribute("","","EntityType","CDATA",(m_Task.getEntityType () != null ? m_Task.getEntityType ():""));
atts.addAttribute("","","Help","CDATA",(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;
String name = null;
atts.clear();
if (m_Task.getAD_Task_ID() > 0) {
sql = "SELECT Name FROM AD_Task WHERE AD_Task_ID=?";
name = DB.getSQLValueString(null, sql, m_Task.getAD_Task_ID());
}
if (name != null)
atts.addAttribute("", "", "ADTaskNameID", "CDATA", name);
else
atts.addAttribute("", "", "ADTaskNameID", "CDATA", "");
atts.addAttribute("", "", "AccessLevel", "CDATA", (m_Task
.getAccessLevel() != null ? m_Task.getAccessLevel() : ""));
atts.addAttribute("", "", "Description", "CDATA", (m_Task
.getDescription() != null ? m_Task.getDescription() : ""));
atts.addAttribute("", "", "EntityType", "CDATA", (m_Task
.getEntityType() != null ? m_Task.getEntityType() : ""));
atts.addAttribute("", "", "Help", "CDATA",
(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);
}
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 AD_Backup_ID = -1;

View File

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

View File

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

View File

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

View File

@ -734,7 +734,7 @@ public final class MLookup extends Lookup implements Serializable
}
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();
log.finer(m_info.KeyColumn

View File

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

View File

@ -754,6 +754,22 @@ public abstract class PO
else if (p_info.getColumnClass(index) == Boolean.class
&& ("Y".equals(value) || "N".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
{
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("AdempiereHome = ").append(Adempiere.getAdempiereHome()).append(NL);
sb.append("AdempiereProperties = ").append(Ini.getPropertyFileName()).append(NL);
sb.append(Env.getLanguage(Env.getCtx())).append(NL);
MClient client = MClient.get(Env.getCtx());
sb.append(client).append(NL);