2pack refactoring

- make adding packin/packout support for new table easier
- use po instead of direct sql where possible
- more to come later
This commit is contained in:
Heng Sin Low 2009-08-03 10:13:43 +00:00
parent fecd8269ad
commit 69d3b96908
36 changed files with 714 additions and 451 deletions

View File

@ -16,6 +16,7 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -29,12 +30,15 @@ import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.PoFiller;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.X_AD_Element;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class AdElementHandler extends AbstractElementHandler {
import java.sql.ResultSet;
public class AdElementHandler extends AbstractElementHandler implements IPackOutHandler {
private List<Integer> processedElements = new ArrayList<Integer>();
@ -44,7 +48,6 @@ public class AdElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
@ -62,7 +65,7 @@ public class AdElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_Element_ID") != null && Integer.parseInt(atts.getValue("AD_Element_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_AdElement.setAD_Element_ID(Integer.parseInt(atts.getValue("AD_Element_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, AD_ELEMENT, m_AdElement);
backupRecord(ctx, AD_ELEMENT, m_AdElement);
Object_Status = "Update";
if (processedElements.contains(id)) {
element.skip = true;
@ -70,7 +73,6 @@ public class AdElementHandler extends AbstractElementHandler {
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
PoFiller pf = new PoFiller(m_AdElement, atts);
@ -92,7 +94,7 @@ public class AdElementHandler extends AbstractElementHandler {
if (m_AdElement.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_AdElement.getName(), "Element",
m_AdElement.get_ID(), AD_Backup_ID, Object_Status,
m_AdElement.get_ID(), Object_Status,
AD_ELEMENT, get_IDWithColumn(ctx, "AD_Table",
"TableName", AD_ELEMENT));
@ -102,7 +104,7 @@ public class AdElementHandler extends AbstractElementHandler {
} else {
record_log(ctx, 0, m_AdElement.getName(), "Element",
m_AdElement.get_ID(), AD_Backup_ID, Object_Status,
m_AdElement.get_ID(), Object_Status,
AD_ELEMENT, get_IDWithColumn(ctx, "AD_Table",
"TableName", AD_ELEMENT));
throw new POSaveFailedException("Reference");
@ -115,7 +117,7 @@ public class AdElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException {
}
public void create(Properties ctx, TransformerHandler document)
protected void create(Properties ctx, TransformerHandler document)
throws SAXException {
@ -136,8 +138,14 @@ public class AdElementHandler extends AbstractElementHandler {
PackOut packOut = (PackOut)ctx.get("PackOutProcess");
packOut.createTranslations(X_AD_Element.Table_Name,
m_AdElement.get_ID(), document);
try{
new CommonTranslationHandler().packOut(packOut,null,null,document,null,m_AdElement.get_ID());
}
catch(Exception e)
{
log.info(e.toString());
}
document.endElement("", "", "element");
}
@ -166,4 +174,15 @@ public class AdElementHandler extends AbstractElementHandler {
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0 )
recordId = detail.getInt(X_AD_Element.COLUMNNAME_AD_Element_ID);
Env.setContext(packout.getCtx(), X_AD_Element.COLUMNNAME_AD_Element_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Element.COLUMNNAME_AD_Element_ID);
}
}

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
@ -33,19 +34,23 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.compiere.Adempiere;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.DB;
import org.compiere.model.X_AD_Package_Imp_Backup;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class CodeSnipitElementHandler extends AbstractElementHandler {
import java.sql.ResultSet;
import org.adempiere.pipo.PackOut;
public class CodeSnipitElementHandler extends AbstractElementHandler implements IPackOutHandler {
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
log.info(elementValue);
Object_Status = "Update";
@ -58,10 +63,8 @@ public class CodeSnipitElementHandler extends AbstractElementHandler {
String oldCode = atts.getValue("oldcode");
String newCode = atts.getValue("newcode");
int idDetail=0;
InputStream source; // Stream for reading from the source file.
OutputStream copy; // Stream for writing the copy.
File currentDirectory = new File(".");
String packagePath=null;
String sourcePath=null;
@ -126,41 +129,28 @@ public class CodeSnipitElementHandler extends AbstractElementHandler {
int success = readReplace(targetDirectoryModified+sourceName, oldCode, newCode);
// Record in log
int idBackup = DB.getNextID (getClientId(ctx), "AD_Package_Imp_Backup", getTrxName(ctx));
if (success != -1){
try {
idDetail = record_log (ctx, 1, sourceName,"codesnipit", 0,0, Object_Status,sourceName,0);
record_log (ctx, 1, sourceName,"codesnipit", 0, Object_Status,sourceName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
else{
try {
idDetail = record_log (ctx, 0, sourceName,"codesnipit", 0,0, Object_Status,sourceName,0);
record_log (ctx, 0, sourceName,"codesnipit", 0, Object_Status,sourceName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
//Record in transaction file
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_PACKAGE_IMP_ORG_DIR, AD_PACKAGE_IMP_BCK_DIR)" )
.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( ", '" + targetDirectoryModified+sourceName )
.append( "', '" + packagePath+File.separator+"backup"+File.separator+fileDate+"_"+sourceName )
.append( "')");
int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx));
if (no == -1)
log.info("Insert to import backup failed");
//Record in transaction file
X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx, 0, getTrxName(ctx));
backup.setAD_Org_ID(Env.getAD_Org_ID(ctx));
backup.setAD_Package_Imp_ID(getPackageImpId(ctx));
backup.setAD_Package_Imp_Org_Dir(targetDirectoryModified+sourceName );
backup.setAD_Package_Imp_Bck_Dir(packagePath+File.separator+"backup"+File.separator+fileDate+"_"+sourceName);
backup.saveEx();
}
}
@ -238,4 +228,19 @@ public class CodeSnipitElementHandler extends AbstractElementHandler {
atts.addAttribute("","","ReleaseNo","CDATA",ReleaseNo);
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_Destination_Directory, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Destination_Directory));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Destination_FileName));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo,detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo));
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_File_Directory);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
}
}

View File

@ -85,14 +85,12 @@ public class ColumnElementHandler extends AbstractElementHandler {
MColumn m_Column = new MColumn(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Column_ID") != null && Integer.parseInt(atts.getValue("AD_Column_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Column.setAD_Column_ID(Integer.parseInt(atts.getValue("AD_Column_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Column", m_Column);
backupRecord(ctx, "AD_Column", m_Column);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Column.setColumnName(columnName);
@ -177,12 +175,12 @@ public class ColumnElementHandler extends AbstractElementHandler {
adElement.setName(m_Column.getColumnName());
if (adElement.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Column.getName(), "Element", adElement
.getAD_Element_ID(), AD_Backup_ID, "New",
.getAD_Element_ID(), "New",
"AD_Element", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Element"));
} else {
record_log(ctx, 0, m_Column.getName(), "Element", adElement
.getAD_Element_ID(), AD_Backup_ID, "New",
.getAD_Element_ID(), "New",
"AD_Element", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Element"));
}
@ -233,13 +231,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
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_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",
.get_ID(), Object_Status, "AD_Column",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Column"));
throw new POSaveFailedException("Failed to import column.");
@ -252,13 +250,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
if (success == 1) {
record_log(ctx, 1, m_Column.getColumnName(), "dbColumn",
m_Column.get_ID(), 0, Object_Status, atts.getValue(
m_Column.get_ID(), Object_Status, atts.getValue(
"ADTableNameID").toUpperCase(),
get_IDWithColumn(ctx, "AD_Table", "TableName", atts
.getValue("ADTableNameID").toUpperCase()));
} else {
record_log(ctx, 0, m_Column.getColumnName(), "dbColumn",
m_Column.get_ID(), 0, Object_Status, atts.getValue(
m_Column.get_ID(), Object_Status, atts.getValue(
"ADTableNameID").toUpperCase(),
get_IDWithColumn(ctx, "AD_Table", "TableName", atts
.getValue("ADTableNameID").toUpperCase()));
@ -390,12 +388,12 @@ public class ColumnElementHandler extends AbstractElementHandler {
AttributesImpl atts = new AttributesImpl();
X_AD_Column m_Column = new X_AD_Column(ctx, AD_Column_ID,
getTrxName(ctx));
createColumnBinding(atts, m_Column);
createColumnBinding(ctx, atts, m_Column);
document.startElement("", "", "column", atts);
document.endElement("", "", "column");
}
private AttributesImpl createColumnBinding(AttributesImpl atts,
private AttributesImpl createColumnBinding(Properties ctx, AttributesImpl atts,
X_AD_Column m_Column) {
String sql = null;
String name = null;
@ -435,8 +433,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
} else
atts.addAttribute("", "", "ADReferenceNameValueID", "CDATA", "");
if (m_Column.getAD_Table_ID() > 0) {
sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
name = DB.getSQLValueString(null, sql, m_Column.getAD_Table_ID());
name = MTable.getTableName(ctx, m_Column.getAD_Table_ID());
atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADTableNameID", "CDATA", "");

View File

@ -13,17 +13,19 @@ import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.AttributeFiller;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.ElementHandler;
import org.adempiere.pipo.PackOut;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class CommonTranslationHandler extends AbstractElementHandler implements ElementHandler{
import org.compiere.model.X_AD_Element;
public class CommonTranslationHandler extends AbstractElementHandler implements ElementHandler,IPackOutHandler{
public static final String CONTEXT_KEY__PARENT_TABLE = "currentParentTableForTranslation";
public static final String CONTEXT_KEY__PARENT_RECORD_ID = "currentParentTableRecordID_ForTranslation";
public static final String SPECIAL_ATRRIBUTE__TABLE_NAME = "ParentTable";
@ -313,4 +315,16 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
return arg.toString().substring(1, arg.toString().length()-1);
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if("true".equals(packout.getCtx().getProperty("isHandleTranslations"))){
Env.setContext(packout.getCtx(), CommonTranslationHandler.CONTEXT_KEY__PARENT_TABLE,X_AD_Element.Table_Name);
Env.setContext(packout.getCtx(), CommonTranslationHandler.CONTEXT_KEY__PARENT_RECORD_ID,recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(CommonTranslationHandler.CONTEXT_KEY__PARENT_TABLE);
packout.getCtx().remove(CommonTranslationHandler.CONTEXT_KEY__PARENT_RECORD_ID);
}
}
}

View File

@ -33,6 +33,7 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.IDFinder;
import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTable;
import org.compiere.model.PO;
@ -50,10 +51,9 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Low Heng Sin
*
*/
public class DataElementHandler extends AbstractElementHandler {
public class DataElementHandler extends AbstractElementHandler implements IPackOutHandler {
private PO genericPO = null;
int AD_Backup_ID = -1;
String objectStatus = null;
String d_tablename = null;
@ -112,12 +112,11 @@ public class DataElementHandler extends AbstractElementHandler {
if (id > 0){
if (genericPO == null || genericPO.get_ID() != id)
throw new SAXException("id not found");
AD_Backup_ID = copyRecord(ctx,d_tablename,genericPO);
backupRecord(ctx,d_tablename,genericPO);
objectStatus = "Update";
}
else{
objectStatus = "New";
AD_Backup_ID =0;
}
}
// keyXname and lookupkeyXname.
@ -220,9 +219,9 @@ 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, objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
record_log (ctx, 1, genericPO.get_TableName(),"Data", genericPO.get_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));
record_log (ctx, 0, genericPO.get_TableName(),"Data", genericPO.get_ID(),objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
throw new POSaveFailedException("GenericPO");
}
@ -407,4 +406,12 @@ public class DataElementHandler extends AbstractElementHandler {
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID, detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement));
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement);
}
}

View File

@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
@ -28,9 +29,10 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.compiere.Adempiere;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.DB;
import org.compiere.model.X_AD_Package_Imp_Backup;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -38,9 +40,20 @@ import org.xml.sax.helpers.AttributesImpl;
public class DistFileElementHandler extends AbstractElementHandler {
String fileDest;
public DistFileElementHandler()
{
}
public DistFileElementHandler(String fileDest)
{
this.fileDest=fileDest;
}
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue+" "+atts.getValue("name"));
@ -55,7 +68,6 @@ public class DistFileElementHandler extends AbstractElementHandler {
String targetDirectory = atts.getValue("targetDirectory");
Object_Status = "New";
int idDetail=0;
InputStream inputStream; // Stream for reading from the source file.
OutputStream outputStream; // Stream for writing the copy.
@ -138,41 +150,27 @@ public class DistFileElementHandler extends AbstractElementHandler {
//Copy File
int success = copyFile (inputStream,outputStream);
//Record in log
int idBackup = DB.getNextID (getClientId(ctx), "AD_Package_Imp_Backup", getTrxName(ctx));
if (success != -1){
try {
idDetail = record_log (ctx, 1, fileName,"file", 0,0, Object_Status,fileName,0);
record_log (ctx, 1, fileName,"file", 0, Object_Status,fileName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
else{
try {
idDetail = record_log (ctx, 0, fileName,"file", 0,0, Object_Status,fileName,0);
record_log (ctx, 0, fileName,"file", 0, Object_Status,fileName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
//Record in transaction file
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_PACKAGE_IMP_ORG_DIR, AD_PACKAGE_IMP_BCK_DIR)" )
.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( ", '" + fullTargetPath+fileName )
.append( "', '" + packagePath+File.separator+"backup"+File.separator+fileDate+"_"+fileName )
.append( "')");
int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx));
if (no == -1)
log.info("Insert to import backup failed");
X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx, 0, getTrxName(ctx));
backup.setAD_Org_ID(Env.getAD_Org_ID(ctx));
backup.setAD_Package_Imp_Org_Dir(fullTargetPath+fileName);
backup.setAD_Package_Imp_Bck_Dir(packagePath+File.separator+"backup"+File.separator+fileDate+"_"+fileName);
backup.setAD_Package_Imp_ID(getPackageImpId(ctx));
backup.saveEx();
}
}
@ -195,4 +193,16 @@ public class DistFileElementHandler extends AbstractElementHandler {
document.endElement("","","distfile");
}
public void doPackout(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,AttributesImpl atts,int recordId) throws Exception
{
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory));
Env.setContext(packout.getCtx(), "Source_Directory", fileDest);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
packout.getCtx().remove("Source_Directory");
}
}

View File

@ -37,7 +37,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class DynValRuleElementHandler extends AbstractElementHandler {
public class DynValRuleElementHandler extends AbstractElementHandler implements IPackOutHandler {
private List<Integer> rules = new ArrayList<Integer>();
@ -53,15 +53,13 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
X_AD_Val_Rule m_ValRule = new X_AD_Val_Rule(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Val_Rule_ID") != null && Integer.parseInt(atts.getValue("AD_Val_Rule_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_ValRule.setAD_Val_Rule_ID(Integer.parseInt(atts.getValue("AD_Val_Rule_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Val_Rule",m_ValRule);
backupRecord(ctx, "AD_Val_Rule",m_ValRule);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
m_ValRule.setDescription(getStringValue(atts, "Description"));
m_ValRule.setEntityType(atts.getValue("EntityType"));
@ -70,10 +68,10 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
m_ValRule.setType(atts.getValue("Type"));
m_ValRule.setCode(atts.getValue("Code"));
if (m_ValRule.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_ValRule.getName(),"ValRule", m_ValRule.get_ID(),AD_Backup_ID, Object_Status,"AD_Val_Rule",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Val_Rule"));
record_log (ctx, 1, m_ValRule.getName(),"ValRule", m_ValRule.get_ID(),Object_Status,"AD_Val_Rule",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Val_Rule"));
}
else{
record_log (ctx, 0, m_ValRule.getName(),"ValRule", m_ValRule.get_ID(),AD_Backup_ID, Object_Status,"AD_Val_Rule",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Val_Rule"));
record_log (ctx, 0, m_ValRule.getName(),"ValRule", m_ValRule.get_ID(),Object_Status,"AD_Val_Rule",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Val_Rule"));
throw new POSaveFailedException("Failed to save dynamic validation rule.");
}
} else {
@ -85,7 +83,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException {
}
public void create(Properties ctx, TransformerHandler document)
protected void create(Properties ctx, TransformerHandler document)
throws SAXException {
int AD_Val_Rule_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
if (rules.contains(AD_Val_Rule_ID))
@ -136,4 +134,17 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
atts.addAttribute("","","isActive","CDATA",(m_ValRule.isActive()== true ? "true":"false"));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0 )
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
}
}

View File

@ -105,14 +105,12 @@ public class FieldElementHandler extends AbstractElementHandler {
MField m_Field = new MField(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Field_ID") != null && Integer.parseInt(atts.getValue("AD_Field_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Field.setAD_Field_ID(Integer.parseInt(atts.getValue("AD_Field_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Field", m_Field);
backupRecord(ctx, "AD_Field", m_Field);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Field.setName(atts.getValue("Name"));
m_Field.setAD_Column_ID(columnid);
@ -161,13 +159,13 @@ public class FieldElementHandler extends AbstractElementHandler {
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_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_ID(), Object_Status, "AD_Field",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Field"));
throw new POSaveFailedException("Failed to save field definition.");
@ -194,20 +192,35 @@ public class FieldElementHandler extends AbstractElementHandler {
PackOut packOut = (PackOut)ctx.get("PackOutProcess");
if(m_Field.getAD_FieldGroup_ID() > 0){
packOut.createFieldGroupElement(m_Field.getAD_FieldGroup_ID(), document);
try
{
if(m_Field.getAD_FieldGroup_ID() > 0)
{
IPackOutHandler handler = packOut.getHandler("FG");
handler.packOut(packOut,null,null,document,null,m_Field.getAD_FieldGroup_ID());
}
if(m_Field.getAD_Reference_ID() > 0) {
packOut.createReference(m_Field.getAD_Reference_ID(), document);
if (m_Field.getAD_Reference_ID()>0)
{
IPackOutHandler handler = packOut.getHandler("REF");
handler.packOut(packOut,null,null,document,null,m_Field.getAD_Reference_ID());
}
if (m_Field.getAD_Reference_Value_ID() > 0) {
packOut.createReference(m_Field.getAD_Reference_Value_ID(), document);
if (m_Field.getAD_Reference_Value_ID()>0)
{
IPackOutHandler handler = packOut.getHandler("REF");
handler.packOut(packOut,null,null,document,null,m_Field.getAD_Reference_Value_ID());
}
if (m_Field.getAD_Val_Rule_ID() > 0) {
packOut.createDynamicRuleValidation(m_Field.getAD_Val_Rule_ID(), document);
if (m_Field.getAD_Val_Rule_ID()>0)
{
IPackOutHandler handler = packOut.getHandler("V");
handler.packOut(packOut,null,null,document,null,m_Field.getAD_Val_Rule_ID());
}
}
catch(Exception e)
{
log.info(e.toString());
}
document.startElement("", "", "field", atts);

View File

@ -16,6 +16,7 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -34,7 +35,10 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class FieldGroupElementHandler extends AbstractElementHandler {
import java.sql.ResultSet;
public class FieldGroupElementHandler extends AbstractElementHandler implements IPackOutHandler{
private List<Integer> processedFieldGroups = new ArrayList<Integer>();
@ -42,7 +46,6 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
@ -60,7 +63,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_FieldGroup_ID") != null && Integer.parseInt(atts.getValue("AD_FieldGroup_ID")) <= PackOut.MAX_OFFICIAL_ID)
fieldGroup.setAD_FieldGroup_ID(Integer.parseInt(atts.getValue("AD_FieldGroup_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, X_AD_FieldGroup.Table_Name, fieldGroup);
backupRecord(ctx, X_AD_FieldGroup.Table_Name, fieldGroup);
Object_Status = "Update";
if (processedFieldGroups.contains(id)) {
element.skip = true;
@ -68,7 +71,6 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
PoFiller pf = new PoFiller(fieldGroup, atts);
@ -81,7 +83,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
if (fieldGroup.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, fieldGroup.getName(), "FieldGroup",
fieldGroup.get_ID(), AD_Backup_ID, Object_Status,
fieldGroup.get_ID(), Object_Status,
X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table",
"TableName", X_AD_FieldGroup.Table_Name));
@ -91,7 +93,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
} else {
record_log(ctx, 0, fieldGroup.getName(), "FieldGroup",
fieldGroup.get_ID(), AD_Backup_ID, Object_Status,
fieldGroup.get_ID(), Object_Status,
X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table",
"TableName", X_AD_FieldGroup.Table_Name));
throw new POSaveFailedException("Reference");
@ -104,7 +106,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException {
}
public void create(Properties ctx, TransformerHandler document)
protected void create(Properties ctx, TransformerHandler document)
throws SAXException {
@ -125,9 +127,13 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
PackOut packOut = (PackOut)ctx.get("PackOutProcess");
packOut.createTranslations(X_AD_FieldGroup.Table_Name,
fieldGroup.get_ID(), document);
try{
new CommonTranslationHandler().packOut(packOut,null,null,document,null,fieldGroup.get_ID());
}
catch(Exception e)
{
log.info(e.toString());
}
document.endElement("", "", "fieldgroup");
}
@ -146,4 +152,15 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if (recordId <= 0)
recordId = detail.getInt(X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
Env.setContext(packout.getCtx(), X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
}
}

View File

@ -0,0 +1,94 @@
package org.adempiere.pipo.handler;
import java.io.File;
import java.sql.ResultSet;
import java.util.logging.Level;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.PackOut;
import org.compiere.model.X_AD_Package_Exp;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.CLogger;
import org.xml.sax.helpers.AttributesImpl;
public class FileElementHandler implements IPackOutHandler{
private CLogger log = CLogger.getCLogger(FileElementHandler.class);
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
log.log(Level.INFO,"In PackOut.java handling Code or Other 2pack module creation");
String fullDirectory = header.getString(X_AD_Package_Exp.COLUMNNAME_File_Directory) + header.getString(X_AD_Package_Exp.COLUMNNAME_Name)+header.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
log.log(Level.INFO,"fullDirectory" + fullDirectory);
String targetDirectoryModified=null;
char fileseperator1 = '/';
char fileseperator2 = '\\';
//Correct package for proper file seperator
if (File.separator.equals("/")){
targetDirectoryModified = fullDirectory.replace(fileseperator2,fileseperator1);
}
else
targetDirectoryModified = fullDirectory.replace(fileseperator1,fileseperator2);
String target_File = (targetDirectoryModified);
fullDirectory = detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_File_Directory);
targetDirectoryModified=null;
//Correct package for proper file seperator
if (File.separator.equals("/")){
targetDirectoryModified = fullDirectory.replace(fileseperator2,fileseperator1);
}
else
targetDirectoryModified = fullDirectory.replace(fileseperator2,fileseperator1);
packout.copyCode(
targetDirectoryModified + detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName),
target_File + detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName)
);
AttributesImpl atts = new AttributesImpl();
if(detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Destination_Directory) != null){
fullDirectory = detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Destination_Directory);
String destinationDirectoryModified=null;
//Correct package for proper file seperator
if (File.separator.equals("/")){
destinationDirectoryModified = fullDirectory.replace(fileseperator2,fileseperator1);
}
else
destinationDirectoryModified = fullDirectory.replace(fileseperator2,fileseperator1);
try{
new DistFileElementHandler(destinationDirectoryModified).doPackout(packout,null,detail,packOutDocument,null,null,0);
}
catch(Exception e)
{
System.err.println(e.toString());
}
}
if(detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName) != null){
packageDocument.startElement("","","file",atts);
packageDocument.characters(("File: "+detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName)).toCharArray(),0,("File: "+detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_FileName)).length());
packageDocument.endElement("","","file");
}
packageDocument.startElement("","","filedirectory",atts);
packageDocument.characters(
("Directory: " + detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory)).toCharArray(),
0,
("Directory: " + detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory)).length());
packageDocument.endElement("","","filedirectory");
packageDocument.startElement("","","filenotes",atts);
packageDocument.characters(
("Notes: " + detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Description)).toCharArray(),
0,
(("Notes: " + detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Description)).length()));
packageDocument.endElement("","","filenotes");
}
}

View File

@ -16,6 +16,7 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -28,13 +29,15 @@ import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MForm;
import org.compiere.model.X_AD_Form;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import java.sql.ResultSet;
public class FormElementHandler extends AbstractElementHandler {
public class FormElementHandler extends AbstractElementHandler implements IPackOutHandler {
private List<Integer> forms = new ArrayList<Integer>();
@ -48,17 +51,15 @@ public class FormElementHandler extends AbstractElementHandler {
String name = atts.getValue("ADFormNameID");
int id = get_ID(ctx, "AD_Form", name);
MForm m_Form = new MForm(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Form_ID") != null && Integer.parseInt(atts.getValue("AD_Form_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Form.setAD_Form_ID(Integer.parseInt(atts.getValue("AD_Form_ID")));
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Form",m_Form);
backupRecord(ctx, "AD_Form",m_Form);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
m_Form.setClassname (atts.getValue("Classname"));
m_Form.setIsBetaFunctionality (Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
@ -70,10 +71,10 @@ public class FormElementHandler extends AbstractElementHandler {
m_Form.setName(atts.getValue("Name"));
if (m_Form.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_Form.getName(),"Form", m_Form.get_ID(),AD_Backup_ID, Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
record_log (ctx, 1, m_Form.getName(),"Form", m_Form.get_ID(), Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
}
else{
record_log (ctx, 0, m_Form.getName(),"Form", m_Form.get_ID(),AD_Backup_ID, Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
record_log (ctx, 0, m_Form.getName(),"Form", m_Form.get_ID(), Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
throw new POSaveFailedException("Failed to save form definition");
}
} else {
@ -84,7 +85,7 @@ public class FormElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException {
}
public void create(Properties ctx, TransformerHandler document)
protected void create(Properties ctx, TransformerHandler document)
throws SAXException {
int AD_Form_ID = Env.getContextAsInt(ctx, "AD_Form_ID");
if (forms.contains(AD_Form_ID)) return;
@ -126,4 +127,15 @@ public class FormElementHandler extends AbstractElementHandler {
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID);
}
}

View File

@ -0,0 +1,13 @@
package org.adempiere.pipo.handler;
import java.sql.ResultSet;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.PackOut;
public interface IPackOutHandler {
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception;
}

View File

@ -39,7 +39,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ImpFormatElementHandler extends AbstractElementHandler {
public class ImpFormatElementHandler extends AbstractElementHandler implements IPackOutHandler {
private ImpFormatRowElementHandler rowHandler = new ImpFormatRowElementHandler();
@ -48,7 +48,6 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
@ -59,11 +58,10 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_ImpFormat_ID") != null && Integer.parseInt(atts.getValue("AD_ImpFormat_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_ImpFormat.setAD_ImpFormat_ID(Integer.parseInt(atts.getValue("AD_ImpFormat_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_ImpFormat", m_ImpFormat);
backupRecord(ctx, "AD_ImpFormat", m_ImpFormat);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_ImpFormat.setName(atts.getValue("Name"));
String name = atts.getValue("ADTableNameID");
@ -87,12 +85,12 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
m_ImpFormat.setFormatType(atts.getValue("FormatType"));
if (m_ImpFormat.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_ImpFormat.getName(), "ImpFormat", m_ImpFormat
.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat",
.get_ID(), Object_Status, "AD_ImpFormat",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_ImpFormat"));
} else {
record_log(ctx, 0, m_ImpFormat.getName(), "ImpFormat", m_ImpFormat
.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat",
.get_ID(), Object_Status, "AD_ImpFormat",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_ImpFormat"));
throw new POSaveFailedException("Failed to save Import Format.");
@ -102,7 +100,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
public void endElement(Properties ctx, Element element) throws SAXException {
}
public void create(Properties ctx, TransformerHandler document)
protected void create(Properties ctx, TransformerHandler document)
throws SAXException {
int import_id = Env.getContextAsInt(ctx,
X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID);
@ -179,4 +177,14 @@ public class ImpFormatElementHandler extends AbstractElementHandler {
.getFormatType() != null ? m_ImpFormat.getFormatType() : ""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID);
}
}

View File

@ -73,12 +73,11 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_ImpFormat_Row_ID") != null && Integer.parseInt(atts.getValue("AD_ImpFormat_Row_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_ImpFormat_row.setAD_ImpFormat_Row_ID(Integer.parseInt(atts.getValue("AD_ImpFormat_Row_ID")));
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_ImpFormat",m_ImpFormat_row);
backupRecord(ctx, "AD_ImpFormat",m_ImpFormat_row);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
m_ImpFormat_row.setName(atts.getValue("Name"));
m_ImpFormat_row.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue():true);
@ -96,10 +95,10 @@ public class ImpFormatRowElementHandler extends AbstractElementHandler {
m_ImpFormat_row.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
m_ImpFormat_row.setStartNo(Integer.parseInt(atts.getValue("StartNo")));
if (m_ImpFormat_row.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_ImpFormat_row.getName(),"ImpFormatRow", m_ImpFormat_row.get_ID(),AD_Backup_ID, Object_Status,"AD_ImpFormat",get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row"));
record_log (ctx, 1, m_ImpFormat_row.getName(),"ImpFormatRow", m_ImpFormat_row.get_ID(),Object_Status,"AD_ImpFormat",get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row"));
}
else{
record_log (ctx, 0, m_ImpFormat_row.getName(),"ImpFormatRow", m_ImpFormat_row.get_ID(),AD_Backup_ID, Object_Status,"AD_ImpFormat",get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row"));
record_log (ctx, 0, m_ImpFormat_row.getName(),"ImpFormatRow", m_ImpFormat_row.get_ID(),Object_Status,"AD_ImpFormat",get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row"));
throw new POSaveFailedException("Failed to import Import Format Row.");
}
}

View File

@ -28,18 +28,19 @@ import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.compiere.model.X_AD_Menu;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.model.X_AD_Task;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class MenuElementHandler extends AbstractElementHandler {
public class MenuElementHandler extends AbstractElementHandler implements IPackOutHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ADMenuNameID"));
@ -57,13 +58,13 @@ public class MenuElementHandler extends AbstractElementHandler {
if (menuid <= 0 && atts.getValue("AD_Menu_ID") != null && Integer.parseInt(atts.getValue("AD_Menu_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Menu.setAD_Menu_ID(Integer.parseInt(atts.getValue("AD_Menu_ID")));
if (menuid > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Menu", m_Menu);
backupRecord(ctx, "AD_Menu", m_Menu);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Menu.setName(name);
name = atts.getValue("ADWindowNameID");
if (name != null && name.trim().length() > 0) {
@ -142,7 +143,7 @@ public class MenuElementHandler extends AbstractElementHandler {
if (m_Menu.save(getTrxName(ctx)) == true) {
try {
idDetail = record_log(ctx, 1, m_Menu.getName(), "Menu", m_Menu
.get_ID(), AD_Backup_ID, Object_Status, "AD_Menu",
.get_ID(), Object_Status, "AD_Menu",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Menu"));
} catch (SAXException e) {
@ -151,7 +152,7 @@ public class MenuElementHandler extends AbstractElementHandler {
} else {
try {
idDetail = record_log(ctx, 0, m_Menu.getName(), "Menu", m_Menu
.get_ID(), AD_Backup_ID, Object_Status, "AD_Menu",
.get_ID(), Object_Status, "AD_Menu",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Menu"));
} catch (SAXException e) {
@ -387,25 +388,29 @@ public class MenuElementHandler extends AbstractElementHandler {
|| rs.getInt("AD_FORM_ID") > 0
|| rs.getInt("AD_WORKBENCH_ID") > 0) {
// Call CreateWindow.
if (rs.getInt("AD_WINDOW_ID") > 0) {
packOut.createWindow(rs.getInt("AD_WINDOW_ID"), document);
if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("W");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateProcess.
else if (rs.getInt("AD_PROCESS_ID") > 0) {
packOut.createProcess(rs.getInt("AD_PROCESS_ID"), document);
else if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("P");
handler.packOut(packOut,null,rs,document,null,0);
} else if (rs.getInt(X_AD_Task.COLUMNNAME_AD_Task_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("K");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateTask.
else if (rs.getInt("AD_TASK_ID") > 0) {
packOut.createTask(rs.getInt("AD_TASK_ID"), document);
else if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID) > 0)
{
IPackOutHandler handler = packOut.getHandler("X");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateForm.
else if (rs.getInt("AD_FORM_ID") > 0) {
packOut.createForm(rs.getInt("AD_FORM_ID"), document);
}
// Call CreateWorkflow
else if (rs.getInt("AD_Workflow_ID") > 0) {
packOut.createWorkflow(rs.getInt("AD_Workflow_ID"),
document);
else if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID) > 0)
{
IPackOutHandler handler = packOut.getHandler("F");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateModule because entry is a summary menu
} else {
@ -440,9 +445,10 @@ public class MenuElementHandler extends AbstractElementHandler {
AttributesImpl atts = new AttributesImpl();
PreparedStatement pstmt = null;
ResultSet rs = null;
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
try {
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next()) {
// Menu tag Start.
X_AD_Menu m_Menu = new X_AD_Menu(ctx, rs.getInt("AD_Menu_ID"),
@ -456,26 +462,30 @@ public class MenuElementHandler extends AbstractElementHandler {
|| rs.getInt("AD_FORM_ID") > 0
|| rs.getInt("AD_WORKBENCH_ID") > 0) {
// Call CreateWindow.
if (rs.getInt("AD_WINDOW_ID") > 0) {
packOut.createWindow(rs.getInt("AD_WINDOW_ID"), document);
if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("W");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateProcess.
else if (rs.getInt("AD_PROCESS_ID") > 0) {
packOut.createProcess(rs.getInt("AD_PROCESS_ID"),
document);
else if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("P");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateTask.
else if (rs.getInt("AD_TASK_ID") > 0) {
packOut.createTask(rs.getInt("AD_TASK_ID"), document);
else if (rs.getInt(X_AD_Task.COLUMNNAME_AD_Task_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("K");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateForm.
else if (rs.getInt("AD_FORM_ID") > 0) {
packOut.createForm(rs.getInt("AD_FORM_ID"), document);
else if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID) > 0)
{
IPackOutHandler handler = packOut.getHandler("X");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateWorkflow
else if (rs.getInt("AD_Workflow_ID") > 0) {
packOut.createWorkflow(rs.getInt("AD_Workflow_ID"),
document);
else if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID) > 0)
{
IPackOutHandler handler = packOut.getHandler("F");
handler.packOut(packOut,null,rs,document,null,0);
}
// Call CreateModule because entry is a summary menu
} else {
@ -483,18 +493,29 @@ public class MenuElementHandler extends AbstractElementHandler {
}
document.endElement("", "", "menu");
}
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, "getWindows", e);
} finally {
try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}
pstmt = null;
DB.close(rs, pstmt);
}
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Menu_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Menu_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Menu_ID);
}
}

View File

@ -38,7 +38,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class MessageElementHandler extends AbstractElementHandler {
public class MessageElementHandler extends AbstractElementHandler implements IPackOutHandler{
private List<Integer> messages = new ArrayList<Integer>();
@ -52,17 +52,15 @@ public class MessageElementHandler extends AbstractElementHandler {
int id = get_IDWithColumn(ctx, "AD_Message", "value", value);
MMessage m_Message = new MMessage(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Message_ID") != null && Integer.parseInt(atts.getValue("AD_Message_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Message.setAD_Message_ID(Integer.parseInt(atts.getValue("AD_Message_ID")));
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Message",m_Message);
backupRecord(ctx, "AD_Message",m_Message);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
m_Message.setMsgText(getStringValue(atts, "MsgText"));
m_Message.setMsgTip(getStringValue(atts, "MsgTip"));
@ -71,10 +69,10 @@ public class MessageElementHandler extends AbstractElementHandler {
m_Message.setValue(value);
m_Message.setMsgType(atts.getValue("MsgType"));
if (m_Message.save(getTrxName(ctx)) == true){
record_log (ctx, 1, m_Message.getValue(),"Message", m_Message.get_ID(),AD_Backup_ID, Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
record_log (ctx, 1, m_Message.getValue(),"Message", m_Message.get_ID(),Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
}
else{
record_log (ctx, 0, m_Message.getValue(),"Message", m_Message.get_ID(),AD_Backup_ID, Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
record_log (ctx, 0, m_Message.getValue(),"Message", m_Message.get_ID(),Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
throw new POSaveFailedException("Failed to save message.");
}
} else {
@ -136,4 +134,15 @@ public class MessageElementHandler extends AbstractElementHandler {
atts.addAttribute("","","isActive","CDATA",(m_Message.isActive()== true ? "true":"false"));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID);
}
}

View File

@ -53,16 +53,14 @@ public class PreferenceElementHandler extends AbstractElementHandler {
" and AD_Window_ID = ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), windowid);
MPreference m_Preference = new MPreference(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Preference_ID") != null && Integer.parseInt(atts.getValue("AD_Preference_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Preference.setAD_Preference_ID(Integer.parseInt(atts.getValue("AD_Preference_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Preference", m_Preference);
backupRecord(ctx, "AD_Preference", m_Preference);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
sqlB = null;
m_Preference.setAD_Window_ID(windowid);
@ -70,12 +68,12 @@ public class PreferenceElementHandler extends AbstractElementHandler {
m_Preference.setValue(atts.getValue("Value"));
if (m_Preference.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Preference.getAttribute(), "Preference",
m_Preference.get_ID(), AD_Backup_ID, Object_Status,
m_Preference.get_ID(), Object_Status,
"AD_Preference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Preference"));
} else {
record_log(ctx, 0, m_Preference.getAttribute(), "Preference",
m_Preference.get_ID(), AD_Backup_ID, Object_Status,
m_Preference.get_ID(), Object_Status,
"AD_Preference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Preference"));
throw new POSaveFailedException("Failed to save Preference");

View File

@ -42,7 +42,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class PrintFormatElementHandler extends AbstractElementHandler {
public class PrintFormatElementHandler extends AbstractElementHandler implements IPackOutHandler {
private PrintFormatItemElementHandler itemHandler = new PrintFormatItemElementHandler();
@ -51,7 +51,6 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
@ -63,11 +62,10 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_PrintFormat_ID") != null && Integer.parseInt(atts.getValue("AD_PrintFormat_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_PrintFormat.setAD_PrintFormat_ID(Integer.parseInt(atts.getValue("AD_PrintFormat_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_PrintFormat", m_PrintFormat);
backupRecord(ctx, "AD_PrintFormat", m_PrintFormat);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
name = atts.getValue("ADReportviewnameID");
@ -89,12 +87,12 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
m_Table.setTableName(name);
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table",
m_Table.get_ID(), 0, "New", "AD_Table",
m_Table.get_ID(), "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table",
m_Table.get_ID(), 0, "New", "AD_Table",
m_Table.get_ID(), "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
}
@ -165,13 +163,13 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
.booleanValue());
if (m_PrintFormat.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_PrintFormat.getName(), "PrintFormat",
m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status,
m_PrintFormat.get_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,
m_PrintFormat.get_ID(), Object_Status,
"AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormat"));
throw new POSaveFailedException("Failed to save Print Format");
@ -349,4 +347,16 @@ public class PrintFormatElementHandler extends AbstractElementHandler {
.isDefault() == true ? "true" : "false"));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID);
}
}

View File

@ -37,7 +37,6 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
@ -56,12 +55,11 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_PrintFormatItem_ID") != null && Integer.parseInt(atts.getValue("AD_PrintFormatItem_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_PrintFormatItem.setAD_PrintFormatItem_ID(Integer.parseInt(atts.getValue("AD_PrintFormatItem_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_PrintFormatItem",
backupRecord(ctx, "AD_PrintFormatItem",
m_PrintFormatItem);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_PrintFormatItem.setName(name);
name = atts.getValue("ADPrintFormatNameID");
@ -232,12 +230,12 @@ public class PrintFormatItemElementHandler extends AbstractElementHandler {
if (m_PrintFormatItem.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_PrintFormatItem.getName(), "PrintFormatItem",
m_PrintFormatItem.get_ID(), AD_Backup_ID, Object_Status,
m_PrintFormatItem.get_ID(), Object_Status,
"AD_PrintFormatItem", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormatItem"));
} else {
record_log(ctx, 0, m_PrintFormatItem.getName(), "PrintFormatItem",
m_PrintFormatItem.get_ID(), AD_Backup_ID, Object_Status,
m_PrintFormatItem.get_ID(), Object_Status,
"AD_PrintFormatItem", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormatItem"));
throw new POSaveFailedException("PrintFormatItem");

View File

@ -31,6 +31,7 @@ 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.X_AD_Package_Exp_Detail;
import org.compiere.model.X_AD_Process;
import org.compiere.model.X_AD_Process_Para;
import org.compiere.util.DB;
@ -39,7 +40,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ProcessElementHandler extends AbstractElementHandler {
public class ProcessElementHandler extends AbstractElementHandler implements IPackOutHandler{
private ProcessParaElementHandler paraHandler = new ProcessParaElementHandler();
@ -59,11 +60,10 @@ public class ProcessElementHandler extends AbstractElementHandler {
id = get_IDWithColumn(ctx, "AD_Process", "Value", value);
X_AD_Process m_Process = null;
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0) {
m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process);
backupRecord(ctx, "AD_Process", m_Process);
Object_Status = "Update";
} else {
m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
@ -71,7 +71,6 @@ public class ProcessElementHandler extends AbstractElementHandler {
"AD_Process", getTrxName(ctx));
m_Process.setAD_Process_ID(id);
Object_Status = "New";
AD_Backup_ID = 0;
}
if (id <= 0 && atts.getValue("AD_Process_ID") != null && Integer.parseInt(atts.getValue("AD_Process_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Process.setAD_Process_ID(Integer.parseInt(atts.getValue("AD_Process_ID")));
@ -146,13 +145,13 @@ public class ProcessElementHandler extends AbstractElementHandler {
m_Process.setJasperReport(getStringValue(atts, "JasperReport"));
if (m_Process.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Process.getName(), "Process", m_Process
.get_ID(), AD_Backup_ID, Object_Status, "AD_Process",
.get_ID(), Object_Status, "AD_Process",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Process"));
element.recordId = m_Process.getAD_Process_ID();
} else {
record_log(ctx, 0, m_Process.getName(), "Process", m_Process
.get_ID(), AD_Backup_ID, Object_Status, "AD_Process",
.get_ID(), Object_Status, "AD_Process",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Process"));
throw new POSaveFailedException("Process");
@ -186,19 +185,20 @@ public class ProcessElementHandler extends AbstractElementHandler {
log.log(Level.INFO, "AD_ReportView_ID: "
+ m_Process.getAD_Process_ID());
if (m_Process.isReport() && m_Process.getAD_ReportView_ID() > 0) {
packOut.createReportview(m_Process.getAD_ReportView_ID(),
document);
}
if (m_Process.isReport() && m_Process.getAD_PrintFormat_ID() > 0) {
if (m_Process.isReport() && m_Process.getAD_ReportView_ID() > 0)
{
IPackOutHandler handler = packOut.getHandler("R");
handler.packOut(packOut,null,null,document,null,m_Process.getAD_ReportView_ID());
packOut.createPrintFormat(m_Process.getAD_PrintFormat_ID(),
document);
}
if (m_Process.isReport() && m_Process.getAD_PrintFormat_ID() > 0)
{
IPackOutHandler handler = packOut.getHandler("PFT");
handler.packOut(packOut,null,null,document,null,m_Process.getAD_PrintFormat_ID());
}
if (m_Process.getAD_Workflow_ID() > 0) {
packOut.createWorkflow(m_Process.getAD_Workflow_ID(),
document);
IPackOutHandler handler = packOut.getHandler("F");
handler.packOut(packOut,null,null,document,null,m_Process.getAD_Workflow_ID());
}
createProcessBinding(atts, m_Process);
document.startElement("", "", "process", atts);
@ -210,15 +210,24 @@ public class ProcessElementHandler extends AbstractElementHandler {
try {
ResultSet rsP = pstmtP.executeQuery();
while (rsP.next()) {
if (rsP.getInt("AD_Reference_ID") > 0)
packOut.createReference(rsP
.getInt("AD_Reference_ID"), document);
if (rsP.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("REF");
handler.packOut(packOut,null,rsP,document,null,0);
}
if (rsP.getInt("AD_Reference_Value_ID")>0)
packOut.createReference(rsP
.getInt("AD_Reference_Value_ID"),
document);
if (rsP.getInt("AD_Val_Rule_ID") > 0)
packOut.createDynamicRuleValidation (rsP.getInt("AD_Val_Rule_ID"), document);
{
IPackOutHandler handler = packOut.getHandler("REF");
handler.packOut(packOut,null,null,document,null,rsP.getInt("AD_Reference_Value_ID"));
}
if (rsP.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID)>0)
{
IPackOutHandler handler = packOut.getHandler("V");
handler.packOut(packOut,null,rsP,document,null,0);
}
createProcessPara(ctx, document, rsP
.getInt("AD_Process_Para_ID"));
@ -344,4 +353,15 @@ public class ProcessElementHandler extends AbstractElementHandler {
(m_Process.getJasperReport() != null ? m_Process.getJasperReport() : ""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID);
}
}

View File

@ -76,17 +76,15 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
X_AD_Process_Para m_Process_para = new X_AD_Process_Para(ctx, id,
getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Process_Para_ID") != null && Integer.parseInt(atts.getValue("AD_Process_Para_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Process_para.setAD_Process_Para_ID(Integer.parseInt(atts.getValue("AD_Process_Para_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Process_Para",
backupRecord(ctx, "AD_Process_Para",
m_Process_para);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Process_para.setName(atts.getValue("Name"));
@ -114,12 +112,12 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
adElement.setName(m_Process_para.getName());
if (adElement.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Process_para.getName(), "Element", adElement
.getAD_Element_ID(), AD_Backup_ID, "New",
.getAD_Element_ID(), "New",
"AD_Element", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Element"));
} else {
record_log(ctx, 0, m_Process_para.getName(), "Element", adElement
.getAD_Element_ID(), AD_Backup_ID, "New",
.getAD_Element_ID(), "New",
"AD_Element", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Element"));
}
@ -185,12 +183,12 @@ public class ProcessParaElementHandler extends AbstractElementHandler {
.booleanValue());
if (m_Process_para.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Process_para.getName(), "Process_para",
m_Process_para.get_ID(), AD_Backup_ID, Object_Status,
m_Process_para.get_ID(), Object_Status,
"AD_Process_para", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Process_para"));
} else {
record_log(ctx, 0, m_Process_para.getName(), "Process_para",
m_Process_para.get_ID(), AD_Backup_ID, Object_Status,
m_Process_para.get_ID(), Object_Status,
"AD_Process_para", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Process_para"));
throw new POSaveFailedException("ProcessPara");

View File

@ -31,6 +31,7 @@ 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.X_AD_Package_Exp_Detail;
import org.compiere.model.X_AD_Ref_List;
import org.compiere.model.X_AD_Ref_Table;
import org.compiere.model.X_AD_Reference;
@ -40,7 +41,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ReferenceElementHandler extends AbstractElementHandler {
public class ReferenceElementHandler extends AbstractElementHandler implements IPackOutHandler{
private ReferenceListElementHandler listHandler = new ReferenceListElementHandler();
private ReferenceTableElementHandler tableHandler = new ReferenceTableElementHandler();
@ -50,7 +51,6 @@ public class ReferenceElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
@ -67,7 +67,7 @@ public class ReferenceElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_Reference_ID") != null && Integer.parseInt(atts.getValue("AD_Reference_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Reference.setAD_Reference_ID(Integer.parseInt(atts.getValue("AD_Reference_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reference", m_Reference);
backupRecord(ctx, "AD_Reference", m_Reference);
Object_Status = "Update";
if (references.contains(id)) {
element.skip = true;
@ -75,7 +75,6 @@ public class ReferenceElementHandler extends AbstractElementHandler {
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Reference.setDescription(getStringValue(atts,"Description"));
@ -89,14 +88,14 @@ public class ReferenceElementHandler extends AbstractElementHandler {
m_Reference.setValidationType(atts.getValue("ValidationType"));
if (m_Reference.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Reference.getName(), "Reference",
m_Reference.get_ID(), AD_Backup_ID, Object_Status,
m_Reference.get_ID(), Object_Status,
"AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference"));
references.add(m_Reference.getAD_Reference_ID());
element.recordId = m_Reference.getAD_Reference_ID();
} else {
record_log(ctx, 0, m_Reference.getName(), "Reference",
m_Reference.get_ID(), AD_Backup_ID, Object_Status,
m_Reference.get_ID(), Object_Status,
"AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference"));
throw new POSaveFailedException("Reference");
@ -276,4 +275,14 @@ public class ReferenceElementHandler extends AbstractElementHandler {
: ""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID);
}
}

View File

@ -36,7 +36,6 @@ public class ReferenceListElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("Name"));
@ -64,11 +63,10 @@ public class ReferenceListElementHandler extends AbstractElementHandler {
if (AD_Ref_List_ID <= 0 && atts.getValue("AD_Ref_List_ID") != null && Integer.parseInt(atts.getValue("AD_Ref_List_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Ref_List.setAD_Ref_List_ID(Integer.parseInt(atts.getValue("AD_Ref_List_ID")));
if (AD_Ref_List_ID > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Ref_List", m_Ref_List);
backupRecord(ctx, "AD_Ref_List", m_Ref_List);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Ref_List.setAD_Reference_ID(AD_Reference_ID);
@ -81,12 +79,12 @@ public class ReferenceListElementHandler extends AbstractElementHandler {
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,
m_Ref_List.get_ID(), Object_Status,
"AD_Ref_List", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Ref_List"));
} else {
record_log(ctx, 0, m_Ref_List.getName(), "Reference List",
m_Ref_List.get_ID(), AD_Backup_ID, Object_Status,
m_Ref_List.get_ID(), Object_Status,
"AD_Ref_List", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Ref_List"));
throw new POSaveFailedException("ReferenceList");

View File

@ -42,8 +42,6 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
log.info(elementValue);
Attributes atts = element.attributes;
@ -79,11 +77,11 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
m_Table.setTableName(atts.getValue("ADTableNameID"));
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table", m_Table
.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(
.get_ID(), "New", "AD_Table", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table", m_Table
.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(
.get_ID(), "New", "AD_Table", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Table"));
}
tableId = get_IDWithColumn(ctx, "AD_Table", "TableName", atts
@ -102,11 +100,11 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
m_Column.setAD_Reference_ID(30);
if (m_Column.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Column.getName(), "Column", m_Column
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
.get_ID(), "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
} else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
.get_ID(), "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
}
}
@ -123,11 +121,11 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
m_Column.setAD_Reference_ID(30);
if (m_Column.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Column.getName(), "Column", m_Column
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
.get_ID(), "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
} else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
.get_ID(), "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
}
}
@ -156,12 +154,12 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
int no = DB.executeUpdate(sqlB.toString(), getTrxName(ctx));
if (no > 0) {
record_log(ctx, 1, atts.getValue("ADRefenceNameID"),
"Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, "Update", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
} else {
record_log(ctx, 0, atts.getValue("ADRefenceNameID"),
"Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, "Update", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
throw new POSaveFailedException("ReferenceTable");
@ -185,12 +183,12 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
int no = DB.executeUpdate(sqlB.toString(), getTrxName(ctx));
if (no > 0) {
record_log(ctx, 1, atts.getValue("ADRefenceNameID"),
"Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, "New", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
} else {
record_log(ctx, 0, atts.getValue("ADRefenceNameID"),
"Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, "New", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
throw new POSaveFailedException("ReferenceTable");

View File

@ -36,7 +36,6 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
@ -84,12 +83,11 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_ReportView_Col_ID") != null && Integer.parseInt(atts.getValue("AD_ReportView_Col_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Reportview_Col.setAD_ReportView_Col_ID(Integer.parseInt(atts.getValue("AD_ReportView_Col_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reportview_Col",
backupRecord(ctx, "AD_Reportview_Col",
m_Reportview_Col);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
boolean isGroupFunction = Boolean.valueOf(
@ -110,13 +108,13 @@ public class ReportViewColElementHandler extends AbstractElementHandler {
if (m_Reportview_Col.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, "" + m_Reportview_Col.getAD_ReportView_ID(),
"Reportview_Col", m_Reportview_Col.get_ID(),
AD_Backup_ID, Object_Status, "AD_Reportview_Col",
Object_Status, "AD_Reportview_Col",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Reportview_Col"));
} else {
record_log(ctx, 0, "" + m_Reportview_Col.getAD_ReportView_ID(),
"Reportview_Col", m_Reportview_Col.get_ID(),
AD_Backup_ID, Object_Status, "AD_Reportview_Col",
Object_Status, "AD_Reportview_Col",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Reportview_Col"));
throw new POSaveFailedException("ReportViewCol");

View File

@ -32,6 +32,7 @@ import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MTable;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.model.X_AD_ReportView;
import org.compiere.model.X_AD_ReportView_Col;
import org.compiere.util.DB;
@ -40,7 +41,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ReportViewElementHandler extends AbstractElementHandler {
public class ReportViewElementHandler extends AbstractElementHandler implements IPackOutHandler{
private ReportViewColElementHandler columnHandler = new ReportViewColElementHandler();
@ -49,11 +50,9 @@ public class ReportViewElementHandler extends AbstractElementHandler {
public void startElement(Properties ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
Attributes atts = element.attributes;
log.info(elementValue + " " + atts.getValue("ADReportviewnameID"));
String entitytype = atts.getValue("EntityType");
String name = atts.getValue("ADReportviewnameID");
int id = get_ID(ctx, "AD_ReportView", name);
@ -62,11 +61,10 @@ public class ReportViewElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_ReportView_ID") != null && Integer.parseInt(atts.getValue("AD_ReportView_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Reportview.setAD_ReportView_ID(Integer.parseInt(atts.getValue("AD_ReportView_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Reportview", m_Reportview);
backupRecord(ctx, "AD_Reportview", m_Reportview);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
String Name = atts.getValue("ADTableNameID");
id = get_IDWithColumn(ctx, "AD_Table", "TableName", Name);
@ -78,12 +76,12 @@ public class ReportViewElementHandler extends AbstractElementHandler {
m_Table.setTableName(Name);
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table",
m_Table.get_ID(), 0, "New", "AD_Table",
m_Table.get_ID(), "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table",
m_Table.get_ID(), 0, "New", "AD_Table",
m_Table.get_ID(), "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
}
@ -100,13 +98,13 @@ public class ReportViewElementHandler extends AbstractElementHandler {
m_Reportview.setWhereClause(getStringValue(atts,"WhereClause"));
if (m_Reportview.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Reportview.getName(), "Reportview",
m_Reportview.get_ID(), AD_Backup_ID, Object_Status,
m_Reportview.get_ID(), Object_Status,
"AD_Reportview", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reportview"));
element.recordId = m_Reportview.getAD_ReportView_ID();
} else {
record_log(ctx, 0, m_Reportview.getName(), "Reportview",
m_Reportview.get_ID(), AD_Backup_ID, Object_Status,
m_Reportview.get_ID(), Object_Status,
"AD_Reportview", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reportview"));
throw new POSaveFailedException("ReportView");
@ -146,10 +144,11 @@ public class ReportViewElementHandler extends AbstractElementHandler {
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()) {
// Export Table if neccessary
packOut.createTable(rs1.getInt("AD_Table_ID"),
document);
packOut.createPrintFormat(rs1
.getInt("AD_Printformat_ID"), document);
IPackOutHandler tableHandler = packOut.getHandler("T");
tableHandler.packOut(packOut,null,rs1,document,null,0);
IPackOutHandler pftHandler = packOut.getHandler("PFT");
pftHandler.packOut(packOut,null,rs1,document,null,0);
}
rs1.close();
pstmt1.close();
@ -264,4 +263,15 @@ public class ReportViewElementHandler extends AbstractElementHandler {
.getWhereClause() : ""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ReportView_ID);
}
}

View File

@ -46,7 +46,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class RoleElementHandler extends AbstractElementHandler {
public class RoleElementHandler extends AbstractElementHandler implements IPackOutHandler{
private List<Integer> roles = new ArrayList<Integer>();
@ -69,16 +69,13 @@ public class RoleElementHandler extends AbstractElementHandler {
int id = get_ID(ctx, "AD_Role", name);
MRole m_Role = new MRole(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Role_ID") != null && Integer.parseInt(atts.getValue("AD_Role_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Role.setAD_Role_ID(Integer.parseInt(atts.getValue("AD_Role_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Role", m_Role);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Role.setName(name);
@ -188,12 +185,12 @@ public class RoleElementHandler extends AbstractElementHandler {
if (m_Role.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Role.getName(), "Role", m_Role.get_ID(),
AD_Backup_ID, Object_Status, "AD_Role", get_IDWithColumn(
Object_Status, "AD_Role", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Role"));
} else {
record_log(ctx, 0, m_Role.getName(), "Role", m_Role.get_ID(),
AD_Backup_ID, Object_Status, "AD_Role", get_IDWithColumn(
Object_Status, "AD_Role", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Role"));
throw new POSaveFailedException("Role");
}
@ -517,4 +514,15 @@ public class RoleElementHandler extends AbstractElementHandler {
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID);
}
}

View File

@ -18,6 +18,7 @@ package org.adempiere.pipo.handler;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
import java.util.logging.Level;
@ -26,6 +27,7 @@ import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.util.DB;
import org.compiere.util.Env;
@ -33,12 +35,10 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class SQLStatementElementHandler extends AbstractElementHandler {
public class SQLStatementElementHandler extends AbstractElementHandler implements IPackOutHandler{
public void startElement(Properties ctx, Element element) throws SAXException {
String elementValue = element.getElementValue();
int AD_Backup_ID = -1;
String Object_Status = null;
log.info(elementValue);
Attributes atts = element.attributes;
@ -50,7 +50,7 @@ public class SQLStatementElementHandler extends AbstractElementHandler {
try {
if(DBType.equals("ALL")) {
int n = pstmt.executeUpdate();
log.info("Executed SQL Statement: "+ atts.getValue("statement"));
log.info("Executed SQL Statement: "+ atts.getValue("statement") + " ReturnValue="+n);
}
else if(DB.isOracle() == true && DBType.equals("Oracle")) {
pstmt.executeUpdate();
@ -70,7 +70,7 @@ public class SQLStatementElementHandler extends AbstractElementHandler {
try {
Statement stmt = m_con.createStatement();
int n = stmt.executeUpdate (atts.getValue("statement"));
log.info("Executed SQL Statement for PostgreSQL: "+ atts.getValue("statement"));
log.info("Executed SQL Statement for PostgreSQL: "+ atts.getValue("statement") + " ReturnValue="+n);
// Postgres needs to commit DDL statements
if (m_con != null && !m_con.getAutoCommit())
m_con.commit();
@ -106,4 +106,13 @@ public class SQLStatementElementHandler extends AbstractElementHandler {
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int field) throws Exception
{
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement));
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_DBType, detail.getString(X_AD_Package_Exp_Detail.COLUMNNAME_DBType));
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_DBType);
}
}

View File

@ -81,15 +81,13 @@ public class TabElementHandler extends AbstractElementHandler {
MTab m_Tab = new MTab(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Tab_ID") != null && Integer.parseInt(atts.getValue("AD_Tab_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Tab.setAD_Tab_ID(Integer.parseInt(atts.getValue("AD_Tab_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Tab",m_Tab);
backupRecord(ctx, "AD_Tab",m_Tab);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
sqlB = null;
m_Tab.setName(name);
@ -170,10 +168,10 @@ 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(),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"));
record_log (ctx, 0, m_Tab.getName(),"Tab", m_Tab.get_ID(),Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
throw new POSaveFailedException("Tab");
}
} else {
@ -228,7 +226,15 @@ public class TabElementHandler extends AbstractElementHandler {
if(m_Tab.getAD_Process_ID() > 0 )
{
packOut.createProcess(m_Tab.getAD_Process_ID(), document);
try
{
IPackOutHandler handler = packOut.getHandler("P");
handler.packOut(packOut,null,null,document,null,m_Tab.getAD_Process_ID());
}
catch(Exception e)
{
log.info(e.toString());
}
}
}
@ -327,5 +333,4 @@ public class TabElementHandler extends AbstractElementHandler {
atts.addAttribute("","","Syncfields","CDATA","false");
return atts;
}
}

View File

@ -40,7 +40,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class TableElementHandler extends AbstractElementHandler {
public class TableElementHandler extends AbstractElementHandler implements IPackOutHandler{
private ColumnElementHandler columnHandler = new ColumnElementHandler();
private List<Integer>tables = new ArrayList<Integer>();
@ -68,15 +68,13 @@ public class TableElementHandler extends AbstractElementHandler {
MTable m_Table = new MTable(ctx, id, getTrxName(ctx));
if (id <= 0 && atts.getValue("AD_Table_ID") != null && Integer.parseInt(atts.getValue("AD_Table_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Table.setAD_Table_ID(Integer.parseInt(atts.getValue("AD_Table_ID")));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_Table",m_Table);
backupRecord(ctx, "AD_Table",m_Table);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
m_Table.setTableName(tableName);
String Name = atts.getValue("ADWindowNameID");
@ -109,13 +107,13 @@ public class TableElementHandler extends AbstractElementHandler {
m_Table.setReplicationType(getStringValue(atts,"ReplicationType"));
m_Table.setTableName(atts.getValue("TableName"));
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(),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"));
record_log (ctx, 0, m_Table.getName(),"Table", m_Table.get_ID(),Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
throw new POSaveFailedException("Table");
}
} else {
@ -162,20 +160,32 @@ public class TableElementHandler extends AbstractElementHandler {
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()){
IPackOutHandler handler = packOut.getHandler("ELE");
handler.packOut(packOut,null,rs1,document,null,0);
packOut.createAdElement(rs1.getInt("AD_Element_ID"), document);
if (rs1.getInt("AD_Reference_ID")>0)
packOut.createReference (rs1.getInt("AD_Reference_ID"), document);
if (rs1.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID)>0)
{
handler = packOut.getHandler("REF");
handler.packOut(packOut,null,rs1,document,null,0);
}
if (rs1.getInt("AD_Reference_Value_ID")>0)
packOut.createReference (rs1.getInt("AD_Reference_Value_ID"), document);
{
handler = packOut.getHandler("REF");
handler.packOut(packOut,null,null,document,null,rs1.getInt("AD_Reference_Value_ID"));
}
if (rs1.getInt("AD_Process_ID")>0)
packOut.createProcess (rs1.getInt("AD_Process_ID"), document);
if (rs1.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID)>0)
{
handler = packOut.getHandler("P");
handler.packOut(packOut,null,rs1,document,null,0);
}
if (rs1.getInt("AD_Val_Rule_ID")>0)
packOut.createDynamicRuleValidation (rs1.getInt("AD_Val_Rule_ID"), document);
if (rs1.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID)>0)
{
handler = packOut.getHandler("V");
handler.packOut(packOut,rs,rs1,document,null,0);
}
createColumn(ctx, document, rs1.getInt("AD_Column_ID"));
}
@ -284,4 +294,15 @@ public class TableElementHandler extends AbstractElementHandler {
atts.addAttribute("","","TableName","CDATA",(m_Table.getTableName () != null ? m_Table.getTableName ():""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
}
}

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
. * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
@ -16,6 +16,7 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -34,7 +35,9 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class TaskElementHandler extends AbstractElementHandler {
import java.sql.ResultSet;
public class TaskElementHandler extends AbstractElementHandler implements IPackOutHandler{
private List<Integer> tasks = new ArrayList<Integer>();
@ -48,16 +51,14 @@ public class TaskElementHandler extends AbstractElementHandler {
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 && atts.getValue("AD_Task_ID") != null && Integer.parseInt(atts.getValue("AD_Task_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Task.setAD_Task_ID(Integer.parseInt(atts.getValue("AD_Task_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Task", m_Task);
backupRecord(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(getStringValue(atts,"Description"));
@ -69,12 +70,12 @@ public class TaskElementHandler extends AbstractElementHandler {
m_Task.setOS_Command(getStringValue(atts,"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",
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",
Object_Status, "AD_Task",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Task"));
throw new POSaveFailedException("Task");
@ -136,4 +137,14 @@ public class TaskElementHandler extends AbstractElementHandler {
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Task.COLUMNNAME_AD_Task_ID);
Env.setContext(packout.getCtx(), X_AD_Task.COLUMNNAME_AD_Task_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Task.COLUMNNAME_AD_Task_ID);
}
}

View File

@ -32,6 +32,7 @@ import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.MWindow;
import org.compiere.model.X_AD_Package_Exp_Detail;
import org.compiere.model.X_AD_Preference;
import org.compiere.model.X_AD_Tab;
import org.compiere.model.X_AD_Window;
@ -41,7 +42,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class WindowElementHandler extends AbstractElementHandler {
public class WindowElementHandler extends AbstractElementHandler implements IPackOutHandler{
private TabElementHandler tabHandler = new TabElementHandler();
private PreferenceElementHandler preferenceHandler = new PreferenceElementHandler();
@ -65,13 +66,11 @@ public class WindowElementHandler extends AbstractElementHandler {
if (id <= 0 && atts.getValue("AD_Window_ID") != null && Integer.parseInt(atts.getValue("AD_Window_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Window.setAD_Window_ID(Integer.parseInt(atts.getValue("AD_Window_ID")));
String Object_Status = null;
int AD_Backup_ID = -1;
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Window", m_Window);
backupRecord(ctx, "AD_Window", m_Window);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Window.setName(name);
@ -120,14 +119,14 @@ public class WindowElementHandler extends AbstractElementHandler {
m_Window.setWindowType(atts.getValue("WindowType"));
if (m_Window.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Window.getName(), "Window", m_Window
.get_ID(), AD_Backup_ID, Object_Status, "AD_Window",
.get_ID(), Object_Status, "AD_Window",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Window"));
element.recordId = m_Window.getAD_Window_ID();
windows.add(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",
.get_ID(), Object_Status, "AD_Window",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Window"));
throw new POSaveFailedException("Window");
@ -157,12 +156,9 @@ public class WindowElementHandler extends AbstractElementHandler {
try {
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
String tableSql = "SELECT Name FROM AD_Table WHERE AD_Table_ID=?";
int table_id = rs.getInt("AD_TABLE_ID");
String name = rs.getString("NAME");
String tablename = DB.getSQLValueString(null, tableSql,
table_id);
packOut.createTable(rs.getInt("AD_Table_ID"), document);
IPackOutHandler handler = packOut.getHandler("T");
handler.packOut(packOut,null,rs,document,null,0);
createTab(ctx, document, rs.getInt("AD_Tab_ID"));
}
rs.close();
@ -299,4 +295,15 @@ public class WindowElementHandler extends AbstractElementHandler {
.getWindowType() != null ? m_Window.getWindowType() : ""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Window_ID);
}
}

View File

@ -44,7 +44,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class WorkflowElementHandler extends AbstractElementHandler {
public class WorkflowElementHandler extends AbstractElementHandler implements IPackOutHandler{
private WorkflowNodeElementHandler nodeHandler = new WorkflowNodeElementHandler();
private WorkflowNodeNextElementHandler nodeNextHandler = new WorkflowNodeNextElementHandler();
@ -71,16 +71,14 @@ public class WorkflowElementHandler extends AbstractElementHandler {
}
MWorkflow m_Workflow = new MWorkflow(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_Workflow_ID") != null && Integer.parseInt(atts.getValue("AD_Workflow_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_Workflow.setAD_Workflow_ID(Integer.parseInt(atts.getValue("AD_Workflow_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_Workflow", m_Workflow);
backupRecord(ctx, "AD_Workflow", m_Workflow);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
String name = atts.getValue("ADWorkflowResponsibleNameID");
@ -152,7 +150,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
if (m_Workflow.save(getTrxName(ctx)) == true) {
log.info("m_Workflow save success");
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
.get_ID(), Object_Status, "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
workflows.add(m_Workflow.getAD_Workflow_ID());
@ -160,7 +158,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
} else {
log.info("m_Workflow save failure");
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
.get_ID(), Object_Status, "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
throw new POSaveFailedException("MWorkflow");
@ -191,7 +189,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
if (m_Workflow.save(getTrxName(ctx)) == true) {
log.info("m_Workflow update success");
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), 0, "Update", "AD_Workflow",
.get_ID(), "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
workflows.add(m_Workflow.getAD_Workflow_ID());
@ -199,7 +197,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
} else {
log.info("m_Workflow update fail");
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), 0, "Update", "AD_Workflow",
.get_ID(), "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
throw new POSaveFailedException("MWorkflow");
@ -222,7 +220,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
if (m_Workflow.save(getTrxName(ctx)) == true) {
log.info("m_Workflow update success");
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), 0, "Update", "AD_Workflow",
.get_ID(), "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
workflows.add(m_Workflow.getAD_Workflow_ID());
@ -230,7 +228,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
} else {
log.info("m_Workflow update fail");
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), 0, "Update", "AD_Workflow",
.get_ID(), "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
throw new POSaveFailedException("MWorkflow");
@ -465,4 +463,16 @@ public class WorkflowElementHandler extends AbstractElementHandler {
// != null ? ""+m_Workflow.getSetupTime():""));
return atts;
}
public void packOut(PackOut packout, ResultSet header, ResultSet detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,int recordId) throws Exception
{
if(recordId <= 0)
recordId = detail.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID);
Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID, recordId);
this.create(packout.getCtx(), packOutDocument);
packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID);
}
}

View File

@ -81,16 +81,14 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler {
workflowId, workflowNodeName);
X_AD_WF_Node m_WFNode = new X_AD_WF_Node(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_WF_Node_ID") != null && Integer.parseInt(atts.getValue("AD_WF_Node_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_WFNode.setAD_WF_Node_ID(Integer.parseInt(atts.getValue("AD_WF_Node_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_WF_Node", m_WFNode);
backupRecord(ctx, "AD_WF_Node", m_WFNode);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_WFNode.setValue(atts.getValue("Value"));
m_WFNode.setName(workflowNodeName);
@ -230,13 +228,13 @@ public class WorkflowNodeElementHandler extends AbstractElementHandler {
if (m_WFNode.save(getTrxName(ctx)) == true) {
log.info("m_WFNode save success");
record_log(ctx, 1, m_WFNode.getName(), "WFNode", m_WFNode
.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_Node",
.get_ID(), Object_Status, "AD_WF_Node",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_WF_Node"));
} else {
log.info("m_WFNode save failure");
record_log(ctx, 0, m_WFNode.getName(), "WFNode", m_WFNode
.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_Node",
.get_ID(), Object_Status, "AD_WF_Node",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_WF_Node"));
throw new POSaveFailedException("WorkflowNode");

View File

@ -92,17 +92,15 @@ public class WorkflowNodeNextConditionElementHandler extends
MWFNextCondition m_WFNodeNextCondition = new MWFNextCondition(ctx,
id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_WF_NextCondition_ID") != null && Integer.parseInt(atts.getValue("AD_WF_NextCondition_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_WFNodeNextCondition.setAD_WF_NextCondition_ID(Integer.parseInt(atts.getValue("AD_WF_NextCondition_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_WF_NextCondition",
backupRecord(ctx, "AD_WF_NextCondition",
m_WFNodeNextCondition);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
sqlB = new StringBuffer(
@ -139,7 +137,6 @@ public class WorkflowNodeNextConditionElementHandler extends
String.valueOf(m_WFNodeNextCondition.get_ID()),
"WFNextCondition",
m_WFNodeNextCondition.get_ID(),
AD_Backup_ID,
Object_Status,
"AD_WF_NextCondition",
get_IDWithColumn(ctx, "AD_Table",
@ -152,7 +149,6 @@ public class WorkflowNodeNextConditionElementHandler extends
String.valueOf(m_WFNodeNextCondition.get_ID()),
"WFNextCondition",
m_WFNodeNextCondition.get_ID(),
AD_Backup_ID,
Object_Status,
"AD_WF_NextCondition",
get_IDWithColumn(ctx, "AD_Table",

View File

@ -24,7 +24,6 @@ import org.adempiere.pipo.AbstractElementHandler;
import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.X_AD_WF_NextCondition;
import org.compiere.model.X_AD_WF_NodeNext;
import org.compiere.util.DB;
import org.compiere.util.Env;
@ -78,17 +77,15 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
int id = DB.getSQLValue(getTrxName(ctx),sqlB.toString(),wfNodeId,wfNodeNextId);
MWFNodeNext m_WFNodeNext = new MWFNodeNext(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_WF_NodeNext_ID") != null && Integer.parseInt(atts.getValue("AD_WF_NodeNext_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_WFNodeNext.setAD_WF_NodeNext_ID(Integer.parseInt(atts.getValue("AD_WF_NodeNext_ID")));
if (id > 0){
AD_Backup_ID = copyRecord(ctx, "AD_WF_NodeNext",m_WFNodeNext);
backupRecord(ctx, "AD_WF_NodeNext",m_WFNodeNext);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
m_WFNodeNext.setAD_WF_Node_ID(wfNodeId);
m_WFNodeNext.setAD_WF_Next_ID(wfNodeNextId);
@ -99,12 +96,12 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
log.info("about to execute m_WFNodeNext.save");
if (m_WFNodeNext.save(getTrxName(ctx)) == true){
log.info("m_WFNodeNext save success");
record_log (ctx, 1, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NodeNext",
record_log (ctx, 1, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(), Object_Status,"AD_WF_NodeNext",
get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NodeNext"));
}
else{
log.info("m_WFNodeNext save failure");
record_log (ctx, 0, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NodeNext",
record_log (ctx, 0, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(), Object_Status,"AD_WF_NodeNext",
get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NodeNext"));
throw new POSaveFailedException("WorkflowNodeNext");
}
@ -186,89 +183,4 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
return atts;
}
private AttributesImpl createWorkflowNodeNextConditionBinding(
AttributesImpl atts, X_AD_WF_NextCondition m_WF_NodeNextCondition) {
String sql = null;
String name = null;
atts.clear();
if (m_WF_NodeNextCondition.getAD_WF_NodeNext_ID() > 0) {
// FIXME: it appears nodes point back to themselves
// so a group by is necessary
sql = "SELECT AD_Workflow.Name FROM AD_Workflow, AD_WF_Node, AD_WF_NodeNext WHERE AD_Workflow.AD_Workflow_ID = AD_WF_Node.AD_Workflow_ID and AD_WF_Node.AD_WF_Node_ID = AD_WF_NodeNext.AD_WF_Node_ID and AD_WF_NodeNext.AD_WF_NodeNext_ID = ? group by AD_Workflow.Name";
name = DB.getSQLValueString(null, sql, m_WF_NodeNextCondition
.getAD_WF_NodeNext_ID());
atts.addAttribute("", "", "ADWorkflowNameID", "CDATA", name);
// FIXME: it appears nodes point back to themselves
// so a group by is necessary
sql = "SELECT AD_WF_Node.Name FROM AD_WF_Node, AD_WF_NodeNext WHERE AD_WF_Node.AD_WF_Node_ID = AD_WF_NodeNext.AD_WF_Node_ID and AD_WF_NodeNext.AD_WF_NodeNext_ID = ? group by AD_WF_Node.Name";
name = DB.getSQLValueString(null, sql, m_WF_NodeNextCondition
.getAD_WF_NodeNext_ID());
atts.addAttribute("", "", "ADWorkflowNodeNameID", "CDATA", name);
// FIXME: it appears nodes point back to themselves
// so a group by is necessary
sql = "SELECT AD_WF_Node.Name FROM AD_WF_Node, AD_WF_NodeNext, AD_WF_NextCondition WHERE AD_WF_Node.AD_WF_Node_ID = AD_WF_NodeNext.AD_WF_Next_ID and AD_WF_NodeNext.AD_WF_NodeNext_ID = ? group by AD_WF_Node.Name";
name = DB.getSQLValueString(null, sql, m_WF_NodeNextCondition
.getAD_WF_NodeNext_ID());
// log.log(Level.INFO,"node next name: ", name);
atts
.addAttribute("", "", "ADWorkflowNodeNextNameID", "CDATA",
name);
}
if (m_WF_NodeNextCondition.getAD_Column_ID() > 0) {
sql = "SELECT AD_Table.TableName FROM AD_Table, AD_Column, AD_WF_NextCondition WHERE AD_Column.AD_Table_ID=AD_Table.AD_Table_ID and AD_Column.AD_Column_ID = ?";
name = DB.getSQLValueString(null, sql, m_WF_NodeNextCondition
.getAD_Column_ID());
atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?";
name = DB.getSQLValueString(null, sql, m_WF_NodeNextCondition
.getAD_Column_ID());
atts.addAttribute("", "", "ADColumnNameID", "CDATA", name);
} else {
atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
atts.addAttribute("", "", "ADColumnNameID", "CDATA", "");
}
// FIXME: don't know if I need org_id or not
// sql = "SELECT Name FROM AD_Org WHERE AD_Org_ID=?";
// name = DB.getSQLValueString(null,sql,org_id);
// atts.addAttribute("","","orgname","CDATA",name);
atts.addAttribute("", "", "isActive", "CDATA", (m_WF_NodeNextCondition
.isActive() == true ? "true" : "false"));
atts
.addAttribute(
"",
"",
"EntityType",
"CDATA",
(m_WF_NodeNextCondition.getEntityType() != null ? m_WF_NodeNextCondition
.getEntityType()
: ""));
atts.addAttribute("", "", "AndOr", "CDATA", (m_WF_NodeNextCondition
.getAndOr() != null ? m_WF_NodeNextCondition.getAndOr() : ""));
atts.addAttribute("", "", "Operation", "CDATA", (m_WF_NodeNextCondition
.getOperation() != null ? m_WF_NodeNextCondition.getOperation()
: ""));
atts.addAttribute("", "", "Value", "CDATA", (m_WF_NodeNextCondition
.getValue() != null ? m_WF_NodeNextCondition.getValue() : ""));
atts
.addAttribute(
"",
"",
"Value2",
"CDATA",
(m_WF_NodeNextCondition.getValue2() != null ? m_WF_NodeNextCondition
.getValue2()
: ""));
atts.addAttribute("", "", "SeqNo", "CDATA", (String
.valueOf(m_WF_NodeNextCondition.getSeqNo()) != null ? String
.valueOf(m_WF_NodeNextCondition.getSeqNo()) : ""));
return atts;
}
}