Fix bugs on 2pack

[ 1662989 ] PackOut & PackIn are not closing file
[ 1663097 ] 2Pack doesn't export/import AD_Column.ColumnSQL
[ 1663098 ] 2pack creating table for views
[ 1663099 ] 2pack creating table with primary key even if is child table
* Also added complete trx management for processes
* Also added lots of log.info and beautify indentation
* Also dropped the create/alter routines to reuse the Adempiere routines
This commit is contained in:
Carlos Ruiz 2007-02-19 05:30:52 +00:00
parent 53dcf85e0f
commit ad2de61371
4 changed files with 4516 additions and 4679 deletions

View File

@ -38,14 +38,25 @@ public class IntGenericPO extends PO {
/** Standard Constructor */
public IntGenericPO (Properties ctx, int ID)
{
super (ctx, ID,null,null);
super (ctx, ID,null,null);
}
/** Load Constructor */
public IntGenericPO (Properties ctx, ResultSet rs)
{
super (ctx, 0, null, rs);
super (ctx, 0, null, rs);
}
public IntGenericPO (Properties ctx, int ID, String trxName)
{
super (ctx, ID, trxName, null);
}
public IntGenericPO (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, 0, trxName, rs);
}
private int Table_ID = 0;
/** Load Meta Data */

View File

@ -31,6 +31,8 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.Util;
import java.util.Properties;
import java.util.logging.*;
/**
@ -47,13 +49,13 @@ public class IntPackIn extends SvrProcess
public static String m_Package_Dir = null;
public int p_IntPackIn_ID = 0;
protected void prepare()
protected void prepare()
{
p_IntPackIn_ID = getRecord_ID();
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
}
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
}
} // prepare
@ -62,34 +64,34 @@ public class IntPackIn extends SvrProcess
* @param fileName xml file to read
* @return status message
*/
public String importXML (String fileName) {
log.info("importXML:" + fileName);
File in = new File (fileName);
if (!in.exists()) {
String msg = "File does not exist: " + fileName;
log.info("importXML:" + msg);
return msg;
}
try {
log.info("starting");
System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
IntPackInHandler handler = new IntPackInHandler();
handler.set_TrxName(get_TrxName());
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
String msg = "Start Parser";
log.info (msg);
parser.parse(in, handler);
msg = "End Parser";
log.info (msg);
return "OK.";
}
catch (Exception e) {
log.log(Level.SEVERE,"importXML:", e);
return e.toString();
}
public String importXML (String fileName, Properties ctx, String trxName) {
log.info("importXML:" + fileName);
File in = new File (fileName);
if (!in.exists()) {
String msg = "File does not exist: " + fileName;
log.info("importXML:" + msg);
return msg;
}
try {
log.info("starting");
System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
IntPackInHandler handler = new IntPackInHandler();
handler.set_TrxName(trxName);
handler.setCtx(ctx);
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
String msg = "Start Parser";
log.info (msg);
parser.parse(in, handler);
msg = "End Parser";
log.info (msg);
return "OK.";
}
catch (Exception e) {
log.log(Level.SEVERE,"importXML:", e);
return e.toString();
}
}
/**
@ -101,59 +103,54 @@ public class IntPackIn extends SvrProcess
protected String doIt()
{
X_AD_Package_Imp_Proc IntPackIn = new X_AD_Package_Imp_Proc(
getCtx(),p_IntPackIn_ID, null);
// Create Target directory if required
String fileSeperator=null;
File tempfile = new File("");
fileSeperator = tempfile.separator;
File targetDir = new
File(IntPackIn.getAD_Package_Dir()+fileSeperator+"packages");
if (!targetDir.exists()){
boolean success = (new File(IntPackIn.getAD_Package_Dir()+fileSeperator+"packages")).mkdirs();
if (!success) {
log.info("Target directory creation failed");
}
}
//Unzip package
File zipFilepath = new File(IntPackIn.getAD_Package_Source());
String PackageName = CreateZipFile.getParentDir(zipFilepath);
CreateZipFile.unpackFile(zipFilepath,targetDir);
String dict_file = IntPackIn.getAD_Package_Dir()+fileSeperator+"packages"+fileSeperator+PackageName
+fileSeperator+"dict"+fileSeperator+"PackOut.xml";
log.info("dict file->"+dict_file);
IntPackIn impXML = new IntPackIn();
if(IntPackIn.isAD_Override_Dict()== true)
impXML.m_UpdateMode = "true";
else
impXML.m_UpdateMode = "false";
impXML.m_Package_Dir=IntPackIn.getAD_Package_Dir()+fileSeperator+"packages"+fileSeperator+PackageName
+fileSeperator;
if (DB.isOracle())
impXML.m_Database = "Oracle";
else if (DB.isPostgreSQL())
impXML.m_Database = "PostgreSQL";
//call XML Handler
impXML.importXML(dict_file);
//Generate Model Classes
// globalqss - don't call Generate Model must be done manual
// String args[] = {IntPackIn.getAD_Package_Dir()+"/dbPort/src/org/compiere/model/", "org.compiere.model","'U'"};
// org.compiere.util.GenerateModel.main(args) ;
return "";
X_AD_Package_Imp_Proc IntPackIn = new X_AD_Package_Imp_Proc(
getCtx(),p_IntPackIn_ID, null);
// Create Target directory if required
String fileSeparator=null;
File tempfile = new File("");
fileSeparator = tempfile.separator;
File targetDir = new
File(IntPackIn.getAD_Package_Dir()+fileSeparator+"packages");
if (!targetDir.exists()){
boolean success = (new File(IntPackIn.getAD_Package_Dir()+fileSeparator+"packages")).mkdirs();
if (!success) {
log.info("Target directory creation failed");
}
}
//Unzip package
File zipFilepath = new File(IntPackIn.getAD_Package_Source());
log.info("zipFilepath->"+zipFilepath);
String PackageName = CreateZipFile.getParentDir(zipFilepath);
CreateZipFile.unpackFile(zipFilepath,targetDir);
String dict_file = IntPackIn.getAD_Package_Dir()+fileSeparator+"packages"+fileSeparator+PackageName+fileSeparator+"dict"+fileSeparator+"PackOut.xml";
log.info("dict file->"+dict_file);
IntPackIn impXML = new IntPackIn();
if(IntPackIn.isAD_Override_Dict()== true)
impXML.m_UpdateMode = "true";
else
impXML.m_UpdateMode = "false";
impXML.m_Package_Dir=IntPackIn.getAD_Package_Dir()+fileSeparator+"packages"+fileSeparator+PackageName+fileSeparator;
if (DB.isOracle())
impXML.m_Database = "Oracle";
else if (DB.isPostgreSQL())
impXML.m_Database = "PostgreSQL";
//call XML Handler
impXML.importXML(dict_file, getCtx(), get_TrxName());
//Generate Model Classes
// globalqss - don't call Generate Model must be done manual
// String args[] = {IntPackIn.getAD_Package_Dir()+"/dbPort/src/org/compiere/model/", "org.compiere.model","'U'"};
// org.compiere.util.GenerateModel.main(args) ;
return "Finish Process";
} // doIt
} // IntPackIn
} // IntPackIn

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff