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
|
|
@ -46,6 +46,17 @@ public class IntGenericPO extends PO {
|
|||
{
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
@ -62,7 +64,7 @@ public class IntPackIn extends SvrProcess
|
|||
* @param fileName xml file to read
|
||||
* @return status message
|
||||
*/
|
||||
public String importXML (String fileName) {
|
||||
public String importXML (String fileName, Properties ctx, String trxName) {
|
||||
log.info("importXML:" + fileName);
|
||||
File in = new File (fileName);
|
||||
if (!in.exists()) {
|
||||
|
|
@ -75,7 +77,8 @@ public class IntPackIn extends SvrProcess
|
|||
System.setProperty("javax.xml.parsers.SAXParserFactory",
|
||||
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
|
||||
IntPackInHandler handler = new IntPackInHandler();
|
||||
handler.set_TrxName(get_TrxName());
|
||||
handler.set_TrxName(trxName);
|
||||
handler.setCtx(ctx);
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
SAXParser parser = factory.newSAXParser();
|
||||
String msg = "Start Parser";
|
||||
|
|
@ -89,7 +92,6 @@ public class IntPackIn extends SvrProcess
|
|||
log.log(Level.SEVERE,"importXML:", e);
|
||||
return e.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,14 +107,14 @@ public class IntPackIn extends SvrProcess
|
|||
getCtx(),p_IntPackIn_ID, null);
|
||||
|
||||
// Create Target directory if required
|
||||
String fileSeperator=null;
|
||||
String fileSeparator=null;
|
||||
File tempfile = new File("");
|
||||
fileSeperator = tempfile.separator;
|
||||
fileSeparator = tempfile.separator;
|
||||
File targetDir = new
|
||||
File(IntPackIn.getAD_Package_Dir()+fileSeperator+"packages");
|
||||
File(IntPackIn.getAD_Package_Dir()+fileSeparator+"packages");
|
||||
|
||||
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) {
|
||||
log.info("Target directory creation failed");
|
||||
}
|
||||
|
|
@ -120,12 +122,12 @@ public class IntPackIn extends SvrProcess
|
|||
|
||||
//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()+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);
|
||||
IntPackIn impXML = new IntPackIn();
|
||||
|
||||
|
|
@ -134,26 +136,21 @@ public class IntPackIn extends SvrProcess
|
|||
else
|
||||
impXML.m_UpdateMode = "false";
|
||||
|
||||
impXML.m_Package_Dir=IntPackIn.getAD_Package_Dir()+fileSeperator+"packages"+fileSeperator+PackageName
|
||||
+fileSeperator;
|
||||
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);
|
||||
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 "";
|
||||
return "Finish Process";
|
||||
} // doIt
|
||||
|
||||
} // IntPackIn
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -136,6 +136,8 @@ public class PackOut extends SvrProcess
|
|||
*/
|
||||
protected String doIt() throws java.lang.Exception
|
||||
{
|
||||
OutputStream fw_document = null;
|
||||
OutputStream fw_menu = null;
|
||||
log.info("doIt - AD_PACKAGE_EXP_ID=" + p_PackOut_ID);
|
||||
if (p_PackOut_ID == 0)
|
||||
throw new IllegalArgumentException("No Record");
|
||||
|
|
@ -154,7 +156,7 @@ public class PackOut extends SvrProcess
|
|||
includesdir = rs1.getString("Name") + fileSeperator+"**";
|
||||
boolean success = (new File(rs1.getString("File_Directory") + rs1.getString("Name")+fileSeperator+"doc"+fileSeperator )).mkdirs();
|
||||
String file_document = rs1.getString("File_Directory") + rs1.getString("Name") +fileSeperator+ "doc"+fileSeperator+rs1.getString("Name")+"Doc.xml";
|
||||
OutputStream fw_document = new FileOutputStream (file_document, false);
|
||||
fw_document = new FileOutputStream (file_document, false);
|
||||
StreamResult streamResult_document = new StreamResult(fw_document);
|
||||
SAXTransformerFactory tf_document = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
|
||||
TransformerHandler hd_documemt = tf_document.newTransformerHandler();
|
||||
|
|
@ -165,8 +167,8 @@ public class PackOut extends SvrProcess
|
|||
hd_documemt.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.clear();
|
||||
hd_documemt.processingInstruction("xml-stylesheet","type=\"text/css\" href=\"compiereDocument.css\"");
|
||||
hd_documemt.startElement("","","compiereDocument",atts);
|
||||
hd_documemt.processingInstruction("xml-stylesheet","type=\"text/css\" href=\"adempiereDocument.css\"");
|
||||
hd_documemt.startElement("","","adempiereDocument",atts);
|
||||
hd_documemt.startElement("","","header",atts);
|
||||
hd_documemt.characters((rs1.getString("Name")+" Package Description").toCharArray(),0,(rs1.getString("Name")+" Package Description").length());
|
||||
hd_documemt.endElement("","","header");
|
||||
|
|
@ -226,7 +228,7 @@ public class PackOut extends SvrProcess
|
|||
hd_documemt.endElement("","","filenotes");
|
||||
success = (new File(rs1.getString("File_Directory") + rs1.getString("Name")+fileSeperator+ "dict"+fileSeperator)).mkdirs();
|
||||
String file_menu = rs1.getString("File_Directory") + rs1.getString("Name") +fileSeperator+ "dict"+fileSeperator+"PackOut.xml";
|
||||
OutputStream fw_menu = new FileOutputStream (file_menu, false);
|
||||
fw_menu = new FileOutputStream (file_menu, false);
|
||||
StreamResult streamResult_menu = new StreamResult(fw_menu);
|
||||
SAXTransformerFactory tf_menu = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
|
||||
TransformerHandler hd_menu = tf_menu.newTransformerHandler();
|
||||
|
|
@ -378,7 +380,7 @@ public class PackOut extends SvrProcess
|
|||
hd_menu.startElement("","","menuset",atts);
|
||||
hd_menu.endElement("","","menuset");
|
||||
hd_menu.endElement("","","adempiereAD");
|
||||
hd_menu.endDocument();hd_documemt.endElement("","","compiereDocument");
|
||||
hd_menu.endDocument();hd_documemt.endElement("","","adempiereDocument");
|
||||
hd_documemt.endDocument();
|
||||
//m_Exp.setProcessed(true);
|
||||
//m_Exp.save();
|
||||
|
|
@ -397,6 +399,8 @@ public class PackOut extends SvrProcess
|
|||
{
|
||||
if (pstmt1 != null)
|
||||
pstmt1.close ();
|
||||
fw_document.close();
|
||||
fw_menu.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
|
|
@ -581,6 +585,7 @@ public class PackOut extends SvrProcess
|
|||
pstmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyCode (String sourceName, String copyName)
|
||||
{
|
||||
CopyFile (sourceName, copyName );
|
||||
|
|
@ -629,6 +634,7 @@ public class PackOut extends SvrProcess
|
|||
}
|
||||
hd_menu.endElement("","","workbench");
|
||||
}
|
||||
|
||||
public void DistributeFile (String FileName, String Source_Directory, String ReleaseNo,String Target_Directory, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
atts.addAttribute("","","name","CDATA",FileName);
|
||||
|
|
@ -638,6 +644,7 @@ public class PackOut extends SvrProcess
|
|||
hd_menu.startElement("","","distfile",atts);
|
||||
hd_menu.endElement("","","distfile");
|
||||
}
|
||||
|
||||
public void CreateForm (int AD_Form_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
m_Form = new X_AD_Form (getCtx(), AD_Form_ID, null);
|
||||
|
|
@ -645,6 +652,7 @@ public class PackOut extends SvrProcess
|
|||
hd_menu.startElement("","","form",atts);
|
||||
hd_menu.endElement("","","form");
|
||||
}
|
||||
|
||||
public void CreateTask (int AD_Task_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
m_Task = new X_AD_Task (getCtx(), AD_Task_ID, null);
|
||||
|
|
@ -652,6 +660,7 @@ public class PackOut extends SvrProcess
|
|||
hd_menu.startElement("","","task",atts);
|
||||
hd_menu.endElement("","","task");
|
||||
}
|
||||
|
||||
public void CreateProcess (int AD_Process_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
String sqlW = "SELECT * FROM AD_PROCESS WHERE AD_PROCESS_ID = " + AD_Process_ID;
|
||||
|
|
@ -724,6 +733,7 @@ public class PackOut extends SvrProcess
|
|||
pstmt1 = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateWindow (int AD_Window_ID, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
// Window Tag
|
||||
|
|
@ -838,6 +848,7 @@ public class PackOut extends SvrProcess
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public void CreateData (int table_id, String sql, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
Statement stmt = DB.createStatement();
|
||||
|
|
@ -944,6 +955,7 @@ public class PackOut extends SvrProcess
|
|||
|
||||
hd_menu.endElement("","","data");
|
||||
}
|
||||
|
||||
public void CreateReportview (int Reportview_id, AttributesImpl atts, TransformerHandler hd_menu)
|
||||
{
|
||||
String sql = "SELECT * FROM AD_ReportView WHERE AD_ReportView_ID= " + Reportview_id;
|
||||
|
|
@ -1090,18 +1102,21 @@ public class PackOut extends SvrProcess
|
|||
pstmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateSQL (String SQLStatement, String DBType,AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
atts = createSQLStatmentBinding(atts, SQLStatement, DBType);
|
||||
hd_menu.startElement("","","SQLStatement",atts);
|
||||
hd_menu.endElement("","","SQLStatement");
|
||||
}
|
||||
|
||||
public void CreateSnipit (String FileDir, String FileName, String OldCode, String NewCode, String ReleaseNo, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
atts = createSnipitBinding(atts, FileDir, FileName, OldCode, NewCode, ReleaseNo);
|
||||
hd_menu.startElement("","","codesnipit",atts);
|
||||
hd_menu.endElement("","","codesnipit");
|
||||
}
|
||||
|
||||
public void CreateRoles (int Role_id, AttributesImpl atts, TransformerHandler hd_menu) throws SAXException
|
||||
{
|
||||
|
||||
|
|
@ -1276,10 +1291,9 @@ public class PackOut extends SvrProcess
|
|||
}
|
||||
hd_menu.endElement("","","role");
|
||||
}
|
||||
|
||||
public void CreateReference (int Reference_id, AttributesImpl atts, TransformerHandler hd_menu)
|
||||
{
|
||||
|
||||
|
||||
String sql = "SELECT * FROM AD_Reference WHERE AD_Reference_ID= " + Reference_id;
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
|
|
@ -1301,7 +1315,6 @@ public class PackOut extends SvrProcess
|
|||
{
|
||||
String sql1 = "SELECT * FROM AD_Ref_List WHERE AD_Reference_ID= " + Reference_id;
|
||||
|
||||
|
||||
PreparedStatement pstmt1 = null;
|
||||
pstmt1 = DB.prepareStatement (sql1, get_TrxName());
|
||||
|
||||
|
|
@ -1446,6 +1459,7 @@ public class PackOut extends SvrProcess
|
|||
hd_menu.endElement("","","impformat");
|
||||
|
||||
}
|
||||
|
||||
public void CreateTable (int table_id, AttributesImpl atts, TransformerHandler hd_menu)
|
||||
{
|
||||
int New_Table = 2;
|
||||
|
|
@ -1551,6 +1565,7 @@ public class PackOut extends SvrProcess
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AttributesImpl createfieldBinding( AttributesImpl atts, X_AD_Field m_Field)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -1621,6 +1636,7 @@ public class PackOut extends SvrProcess
|
|||
atts.addAttribute("","","ObscureType","CDATA",(m_Field.getObscureType () != null ? m_Field.getObscureType():""));
|
||||
return atts;
|
||||
}
|
||||
|
||||
public static AttributesImpl createpreferenceBinding( AttributesImpl atts, X_AD_Preference m_Preference)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2000,6 +2016,7 @@ public class PackOut extends SvrProcess
|
|||
atts.addAttribute("","","TableName","CDATA",(m_Table.getTableName () != null ? m_Table.getTableName ():""));
|
||||
return atts;
|
||||
}
|
||||
|
||||
public static AttributesImpl createcolumnBinding( AttributesImpl atts, X_AD_Column m_Column)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2055,6 +2072,7 @@ public class PackOut extends SvrProcess
|
|||
else
|
||||
atts.addAttribute("","","ADValRuleNameID","CDATA","");
|
||||
atts.addAttribute("","","Callout","CDATA",(m_Column.getCallout () != null ? m_Column.getCallout ():""));
|
||||
atts.addAttribute("","","ColumnSQL","CDATA",(m_Column.getColumnSQL () != null ? m_Column.getColumnSQL ():""));
|
||||
atts.addAttribute("","","ColumnName","CDATA",(m_Column.getColumnName () != null ? m_Column.getColumnName ():""));
|
||||
atts.addAttribute("","","DefaultValue","CDATA",(m_Column.getDefaultValue () != null ? m_Column.getDefaultValue ():""));
|
||||
atts.addAttribute("","","Description","CDATA",(m_Column.getDescription () != null ? m_Column.getDescription ():""));
|
||||
|
|
@ -2081,6 +2099,7 @@ public class PackOut extends SvrProcess
|
|||
atts.addAttribute("","","Value","CDATA",(m_Column.getVersion()!= null ? "" + m_Column.getVersion ():"0.0"));
|
||||
return atts;
|
||||
}
|
||||
|
||||
public static AttributesImpl createtaskBinding( AttributesImpl atts, X_AD_Task m_Task)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2127,6 +2146,7 @@ public class PackOut extends SvrProcess
|
|||
atts.addAttribute("","","Name","CDATA",(m_Form.getName() != null ? m_Form.getName():""));
|
||||
return atts;
|
||||
}
|
||||
|
||||
public static AttributesImpl createworkbenchBinding( AttributesImpl atts, X_AD_Workbench m_Workbench)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2157,7 +2177,6 @@ public class PackOut extends SvrProcess
|
|||
return atts;
|
||||
}
|
||||
|
||||
|
||||
public static AttributesImpl createworkbenchwindowBinding( AttributesImpl atts, X_AD_WorkbenchWindow m_Workbenchwindow)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2230,6 +2249,7 @@ public class PackOut extends SvrProcess
|
|||
atts.addAttribute("","","ValidationType","CDATA",(m_Reference.getValidationType () != null ? m_Reference.getValidationType ():""));
|
||||
return atts;
|
||||
}
|
||||
|
||||
public static AttributesImpl createimpBinding( AttributesImpl atts, X_AD_ImpFormat m_ImpFormat)
|
||||
{
|
||||
atts.clear();
|
||||
|
|
@ -2384,6 +2404,7 @@ public class PackOut extends SvrProcess
|
|||
return atts;
|
||||
|
||||
}
|
||||
|
||||
public static AttributesImpl createorgaccessBinding( AttributesImpl atts, int org_id, int role_id)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2408,6 +2429,7 @@ public class PackOut extends SvrProcess
|
|||
|
||||
return atts;
|
||||
}
|
||||
|
||||
//TODO
|
||||
public static AttributesImpl createusrassignBinding( AttributesImpl atts, int user_id, int role_id, int org_id)
|
||||
{
|
||||
|
|
@ -2829,7 +2851,6 @@ public static AttributesImpl createPrintformatItemBinding( AttributesImpl atts,
|
|||
return atts;
|
||||
}
|
||||
|
||||
|
||||
public static AttributesImpl createreportviewBinding( AttributesImpl atts, X_AD_ReportView m_Reportview)
|
||||
{
|
||||
String sql = null;
|
||||
|
|
@ -2938,4 +2959,5 @@ public static AttributesImpl createPrintformatItemBinding( AttributesImpl atts,
|
|||
System.out.println(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
} // PackOut
|
||||
|
|
|
|||
Loading…
Reference in New Issue