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:
parent
53dcf85e0f
commit
ad2de61371
|
@ -38,14 +38,25 @@ public class IntGenericPO extends PO {
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public IntGenericPO (Properties ctx, int ID)
|
public IntGenericPO (Properties ctx, int ID)
|
||||||
{
|
{
|
||||||
super (ctx, ID,null,null);
|
super (ctx, ID,null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load Constructor */
|
/** Load Constructor */
|
||||||
public IntGenericPO (Properties ctx, ResultSet rs)
|
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;
|
private int Table_ID = 0;
|
||||||
|
|
||||||
/** Load Meta Data */
|
/** Load Meta Data */
|
||||||
|
|
|
@ -31,6 +31,8 @@ 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.Util;
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,13 +49,13 @@ public class IntPackIn extends SvrProcess
|
||||||
public static String m_Package_Dir = null;
|
public static String m_Package_Dir = null;
|
||||||
public int p_IntPackIn_ID = 0;
|
public int p_IntPackIn_ID = 0;
|
||||||
|
|
||||||
protected void prepare()
|
protected void prepare()
|
||||||
{
|
{
|
||||||
p_IntPackIn_ID = getRecord_ID();
|
p_IntPackIn_ID = getRecord_ID();
|
||||||
ProcessInfoParameter[] para = getParameter();
|
ProcessInfoParameter[] para = getParameter();
|
||||||
for (int i = 0; i < para.length; i++)
|
for (int i = 0; i < para.length; i++)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
} // prepare
|
} // prepare
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,34 +64,34 @@ public class IntPackIn extends SvrProcess
|
||||||
* @param fileName xml file to read
|
* @param fileName xml file to read
|
||||||
* @return status message
|
* @return status message
|
||||||
*/
|
*/
|
||||||
public String importXML (String fileName) {
|
public String importXML (String fileName, Properties ctx, String trxName) {
|
||||||
log.info("importXML:" + fileName);
|
log.info("importXML:" + fileName);
|
||||||
File in = new File (fileName);
|
File in = new File (fileName);
|
||||||
if (!in.exists()) {
|
if (!in.exists()) {
|
||||||
String msg = "File does not exist: " + fileName;
|
String msg = "File does not exist: " + fileName;
|
||||||
log.info("importXML:" + msg);
|
log.info("importXML:" + msg);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
log.info("starting");
|
log.info("starting");
|
||||||
System.setProperty("javax.xml.parsers.SAXParserFactory",
|
System.setProperty("javax.xml.parsers.SAXParserFactory",
|
||||||
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
|
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
|
||||||
IntPackInHandler handler = new IntPackInHandler();
|
IntPackInHandler handler = new IntPackInHandler();
|
||||||
handler.set_TrxName(get_TrxName());
|
handler.set_TrxName(trxName);
|
||||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
handler.setCtx(ctx);
|
||||||
SAXParser parser = factory.newSAXParser();
|
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
String msg = "Start Parser";
|
SAXParser parser = factory.newSAXParser();
|
||||||
log.info (msg);
|
String msg = "Start Parser";
|
||||||
parser.parse(in, handler);
|
log.info (msg);
|
||||||
msg = "End Parser";
|
parser.parse(in, handler);
|
||||||
log.info (msg);
|
msg = "End Parser";
|
||||||
return "OK.";
|
log.info (msg);
|
||||||
}
|
return "OK.";
|
||||||
catch (Exception e) {
|
}
|
||||||
log.log(Level.SEVERE,"importXML:", e);
|
catch (Exception e) {
|
||||||
return e.toString();
|
log.log(Level.SEVERE,"importXML:", e);
|
||||||
}
|
return e.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,59 +103,54 @@ public class IntPackIn extends SvrProcess
|
||||||
protected String doIt()
|
protected String doIt()
|
||||||
{
|
{
|
||||||
|
|
||||||
X_AD_Package_Imp_Proc IntPackIn = new X_AD_Package_Imp_Proc(
|
X_AD_Package_Imp_Proc IntPackIn = new X_AD_Package_Imp_Proc(
|
||||||
getCtx(),p_IntPackIn_ID, null);
|
getCtx(),p_IntPackIn_ID, null);
|
||||||
|
|
||||||
// Create Target directory if required
|
// Create Target directory if required
|
||||||
String fileSeperator=null;
|
String fileSeparator=null;
|
||||||
File tempfile = new File("");
|
File tempfile = new File("");
|
||||||
fileSeperator = tempfile.separator;
|
fileSeparator = tempfile.separator;
|
||||||
File targetDir = new
|
File targetDir = new
|
||||||
File(IntPackIn.getAD_Package_Dir()+fileSeperator+"packages");
|
File(IntPackIn.getAD_Package_Dir()+fileSeparator+"packages");
|
||||||
|
|
||||||
if (!targetDir.exists()){
|
if (!targetDir.exists()){
|
||||||
boolean success = (new File(IntPackIn.getAD_Package_Dir()+fileSeperator+"packages")).mkdirs();
|
boolean success = (new File(IntPackIn.getAD_Package_Dir()+fileSeparator+"packages")).mkdirs();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
log.info("Target directory creation failed");
|
log.info("Target directory creation failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unzip package
|
//Unzip package
|
||||||
File zipFilepath = new File(IntPackIn.getAD_Package_Source());
|
File zipFilepath = new File(IntPackIn.getAD_Package_Source());
|
||||||
String PackageName = CreateZipFile.getParentDir(zipFilepath);
|
log.info("zipFilepath->"+zipFilepath);
|
||||||
CreateZipFile.unpackFile(zipFilepath,targetDir);
|
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";
|
String dict_file = IntPackIn.getAD_Package_Dir()+fileSeparator+"packages"+fileSeparator+PackageName+fileSeparator+"dict"+fileSeparator+"PackOut.xml";
|
||||||
log.info("dict file->"+dict_file);
|
log.info("dict file->"+dict_file);
|
||||||
IntPackIn impXML = new IntPackIn();
|
IntPackIn impXML = new IntPackIn();
|
||||||
|
|
||||||
if(IntPackIn.isAD_Override_Dict()== true)
|
if(IntPackIn.isAD_Override_Dict()== true)
|
||||||
impXML.m_UpdateMode = "true";
|
impXML.m_UpdateMode = "true";
|
||||||
else
|
else
|
||||||
impXML.m_UpdateMode = "false";
|
impXML.m_UpdateMode = "false";
|
||||||
|
|
||||||
impXML.m_Package_Dir=IntPackIn.getAD_Package_Dir()+fileSeperator+"packages"+fileSeperator+PackageName
|
impXML.m_Package_Dir=IntPackIn.getAD_Package_Dir()+fileSeparator+"packages"+fileSeparator+PackageName+fileSeparator;
|
||||||
+fileSeperator;
|
if (DB.isOracle())
|
||||||
if (DB.isOracle())
|
impXML.m_Database = "Oracle";
|
||||||
impXML.m_Database = "Oracle";
|
else if (DB.isPostgreSQL())
|
||||||
else if (DB.isPostgreSQL())
|
impXML.m_Database = "PostgreSQL";
|
||||||
impXML.m_Database = "PostgreSQL";
|
|
||||||
|
//call XML Handler
|
||||||
//call XML Handler
|
impXML.importXML(dict_file, getCtx(), get_TrxName());
|
||||||
impXML.importXML(dict_file);
|
|
||||||
|
//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
|
// String args[] = {IntPackIn.getAD_Package_Dir()+"/dbPort/src/org/compiere/model/", "org.compiere.model","'U'"};
|
||||||
// String args[] = {IntPackIn.getAD_Package_Dir()+"/dbPort/src/org/compiere/model/", "org.compiere.model","'U'"};
|
// org.compiere.util.GenerateModel.main(args) ;
|
||||||
// org.compiere.util.GenerateModel.main(args) ;
|
|
||||||
|
return "Finish Process";
|
||||||
|
|
||||||
return "";
|
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
} // IntPackIn
|
} // IntPackIn
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue