revert 9811

This commit is contained in:
Heng Sin Low 2009-08-03 14:22:52 +00:00
parent 69d3b96908
commit 76678eab36
36 changed files with 453 additions and 716 deletions

View File

@ -16,7 +16,6 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -30,15 +29,12 @@ 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;
import java.sql.ResultSet;
public class AdElementHandler extends AbstractElementHandler implements IPackOutHandler {
public class AdElementHandler extends AbstractElementHandler {
private List<Integer> processedElements = new ArrayList<Integer>();
@ -48,6 +44,7 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
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;
@ -65,7 +62,7 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
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) {
backupRecord(ctx, AD_ELEMENT, m_AdElement);
AD_Backup_ID = copyRecord(ctx, AD_ELEMENT, m_AdElement);
Object_Status = "Update";
if (processedElements.contains(id)) {
element.skip = true;
@ -73,6 +70,7 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
PoFiller pf = new PoFiller(m_AdElement, atts);
@ -94,7 +92,7 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
if (m_AdElement.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_AdElement.getName(), "Element",
m_AdElement.get_ID(), Object_Status,
m_AdElement.get_ID(), AD_Backup_ID, Object_Status,
AD_ELEMENT, get_IDWithColumn(ctx, "AD_Table",
"TableName", AD_ELEMENT));
@ -104,7 +102,7 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
} else {
record_log(ctx, 0, m_AdElement.getName(), "Element",
m_AdElement.get_ID(), Object_Status,
m_AdElement.get_ID(), AD_Backup_ID, Object_Status,
AD_ELEMENT, get_IDWithColumn(ctx, "AD_Table",
"TableName", AD_ELEMENT));
throw new POSaveFailedException("Reference");
@ -117,7 +115,7 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
public void endElement(Properties ctx, Element element) throws SAXException {
}
protected void create(Properties ctx, TransformerHandler document)
public void create(Properties ctx, TransformerHandler document)
throws SAXException {
@ -138,14 +136,8 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
PackOut packOut = (PackOut)ctx.get("PackOutProcess");
try{
new CommonTranslationHandler().packOut(packOut,null,null,document,null,m_AdElement.get_ID());
}
catch(Exception e)
{
log.info(e.toString());
}
packOut.createTranslations(X_AD_Element.Table_Name,
m_AdElement.get_ID(), document);
document.endElement("", "", "element");
}
@ -174,15 +166,4 @@ public class AdElementHandler extends AbstractElementHandler implements IPackOut
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,7 +25,6 @@ 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;
@ -34,23 +33,19 @@ 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.model.X_AD_Package_Imp_Backup;
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;
import org.adempiere.pipo.PackOut;
public class CodeSnipitElementHandler extends AbstractElementHandler implements IPackOutHandler {
public class CodeSnipitElementHandler 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);
Object_Status = "Update";
@ -63,8 +58,10 @@ public class CodeSnipitElementHandler extends AbstractElementHandler implements
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;
@ -128,29 +125,42 @@ public class CodeSnipitElementHandler extends AbstractElementHandler implements
int success = readReplace(targetDirectoryModified+sourceName, oldCode, newCode);
// Record in log
// Record in log
int idBackup = DB.getNextID (getClientId(ctx), "AD_Package_Imp_Backup", getTrxName(ctx));
if (success != -1){
try {
record_log (ctx, 1, sourceName,"codesnipit", 0, Object_Status,sourceName,0);
idDetail = record_log (ctx, 1, sourceName,"codesnipit", 0,0, Object_Status,sourceName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
else{
try {
record_log (ctx, 0, sourceName,"codesnipit", 0, Object_Status,sourceName,0);
idDetail = record_log (ctx, 0, sourceName,"codesnipit", 0,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( "')");
//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();
int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx));
if (no == -1)
log.info("Insert to import backup failed");
}
}
@ -228,19 +238,4 @@ public class CodeSnipitElementHandler extends AbstractElementHandler implements
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,12 +85,14 @@ 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) {
backupRecord(ctx, "AD_Column", m_Column);
AD_Backup_ID = copyRecord(ctx, "AD_Column", m_Column);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Column.setColumnName(columnName);
@ -175,12 +177,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(), "New",
.getAD_Element_ID(), AD_Backup_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(), "New",
.getAD_Element_ID(), AD_Backup_ID, "New",
"AD_Element", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Element"));
}
@ -231,13 +233,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(), Object_Status, "AD_Column",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Column"));
element.recordId = m_Column.getAD_Column_ID();
} else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), Object_Status, "AD_Column",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Column",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Column"));
throw new POSaveFailedException("Failed to import column.");
@ -250,13 +252,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
if (success == 1) {
record_log(ctx, 1, m_Column.getColumnName(), "dbColumn",
m_Column.get_ID(), Object_Status, atts.getValue(
m_Column.get_ID(), 0, 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(), Object_Status, atts.getValue(
m_Column.get_ID(), 0, Object_Status, atts.getValue(
"ADTableNameID").toUpperCase(),
get_IDWithColumn(ctx, "AD_Table", "TableName", atts
.getValue("ADTableNameID").toUpperCase()));
@ -388,12 +390,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(ctx, atts, m_Column);
createColumnBinding(atts, m_Column);
document.startElement("", "", "column", atts);
document.endElement("", "", "column");
}
private AttributesImpl createColumnBinding(Properties ctx, AttributesImpl atts,
private AttributesImpl createColumnBinding(AttributesImpl atts,
X_AD_Column m_Column) {
String sql = null;
String name = null;
@ -433,7 +435,8 @@ public class ColumnElementHandler extends AbstractElementHandler {
} else
atts.addAttribute("", "", "ADReferenceNameValueID", "CDATA", "");
if (m_Column.getAD_Table_ID() > 0) {
name = MTable.getTableName(ctx, m_Column.getAD_Table_ID());
sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
name = DB.getSQLValueString(null, sql, m_Column.getAD_Table_ID());
atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
} else
atts.addAttribute("", "", "ADTableNameID", "CDATA", "");

View File

@ -13,19 +13,17 @@ 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;
import org.compiere.model.X_AD_Element;
public class CommonTranslationHandler extends AbstractElementHandler implements ElementHandler,IPackOutHandler{
public class CommonTranslationHandler extends AbstractElementHandler implements ElementHandler{
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";
@ -314,17 +312,5 @@ 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,7 +33,6 @@ 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;
@ -51,9 +50,10 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Low Heng Sin
*
*/
public class DataElementHandler extends AbstractElementHandler implements IPackOutHandler {
public class DataElementHandler extends AbstractElementHandler {
private PO genericPO = null;
int AD_Backup_ID = -1;
String objectStatus = null;
String d_tablename = null;
@ -112,11 +112,12 @@ public class DataElementHandler extends AbstractElementHandler implements IPackO
if (id > 0){
if (genericPO == null || genericPO.get_ID() != id)
throw new SAXException("id not found");
backupRecord(ctx,d_tablename,genericPO);
AD_Backup_ID = copyRecord(ctx,d_tablename,genericPO);
objectStatus = "Update";
}
else{
objectStatus = "New";
AD_Backup_ID =0;
}
}
// keyXname and lookupkeyXname.
@ -219,9 +220,9 @@ public class DataElementHandler extends AbstractElementHandler implements IPackO
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(),objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
record_log (ctx, 1, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
else {
record_log (ctx, 0, genericPO.get_TableName(),"Data", genericPO.get_ID(),objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
record_log (ctx, 0, genericPO.get_TableName(),"Data", genericPO.get_ID(),AD_Backup_ID, objectStatus,d_tablename,get_IDWithColumn(ctx, "AD_Table", "TableName", d_tablename));
throw new POSaveFailedException("GenericPO");
}
@ -405,13 +406,5 @@ public class DataElementHandler extends AbstractElementHandler implements IPackO
document.endElement("","","data");
}
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,7 +20,6 @@ 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;
@ -29,10 +28,9 @@ 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.model.X_AD_Package_Imp_Backup;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -40,20 +38,9 @@ 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"));
@ -68,6 +55,7 @@ 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.
@ -150,27 +138,41 @@ 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 {
record_log (ctx, 1, fileName,"file", 0, Object_Status,fileName,0);
idDetail = record_log (ctx, 1, fileName,"file", 0,0, Object_Status,fileName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
else{
try {
record_log (ctx, 0, fileName,"file", 0, Object_Status,fileName,0);
idDetail = record_log (ctx, 0, fileName,"file", 0,0, Object_Status,fileName,0);
} catch (SAXException e) {
log.info ("setfile:"+e);
}
}
//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_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();
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");
}
}
@ -192,17 +194,5 @@ public class DistFileElementHandler extends AbstractElementHandler {
document.startElement("","","distfile",atts);
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 implements IPackOutHandler {
public class DynValRuleElementHandler extends AbstractElementHandler {
private List<Integer> rules = new ArrayList<Integer>();
@ -53,13 +53,15 @@ public class DynValRuleElementHandler extends AbstractElementHandler implements
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){
backupRecord(ctx, "AD_Val_Rule",m_ValRule);
AD_Backup_ID = copyRecord(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"));
@ -68,10 +70,10 @@ public class DynValRuleElementHandler extends AbstractElementHandler implements
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(),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(),AD_Backup_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(),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(),AD_Backup_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 {
@ -83,7 +85,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler implements
public void endElement(Properties ctx, Element element) throws SAXException {
}
protected void create(Properties ctx, TransformerHandler document)
public 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))
@ -134,17 +136,4 @@ public class DynValRuleElementHandler extends AbstractElementHandler implements
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,12 +105,14 @@ 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) {
backupRecord(ctx, "AD_Field", m_Field);
AD_Backup_ID = copyRecord(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);
@ -159,13 +161,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(), Object_Status, "AD_Field",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Field",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Field"));
element.recordId = m_Field.getAD_Field_ID();
} else {
record_log(ctx, 0, m_Field.getName(), "Field", m_Field
.get_ID(), Object_Status, "AD_Field",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Field",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Field"));
throw new POSaveFailedException("Failed to save field definition.");
@ -191,36 +193,21 @@ public class FieldElementHandler extends AbstractElementHandler {
createFieldBinding(atts, m_Field);
PackOut packOut = (PackOut)ctx.get("PackOutProcess");
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)
{
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)
{
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)
{
IPackOutHandler handler = packOut.getHandler("V");
handler.packOut(packOut,null,null,document,null,m_Field.getAD_Val_Rule_ID());
}
if(m_Field.getAD_FieldGroup_ID() > 0){
packOut.createFieldGroupElement(m_Field.getAD_FieldGroup_ID(), document);
}
catch(Exception e)
{
log.info(e.toString());
if(m_Field.getAD_Reference_ID() > 0) {
packOut.createReference(m_Field.getAD_Reference_ID(), document);
}
if (m_Field.getAD_Reference_Value_ID() > 0) {
packOut.createReference(m_Field.getAD_Reference_Value_ID(), document);
}
if (m_Field.getAD_Val_Rule_ID() > 0) {
packOut.createDynamicRuleValidation(m_Field.getAD_Val_Rule_ID(), document);
}
document.startElement("", "", "field", atts);

View File

@ -16,7 +16,6 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -35,17 +34,15 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import java.sql.ResultSet;
public class FieldGroupElementHandler extends AbstractElementHandler {
public class FieldGroupElementHandler extends AbstractElementHandler implements IPackOutHandler{
private List<Integer> processedFieldGroups = new ArrayList<Integer>();
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;
@ -63,7 +60,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
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) {
backupRecord(ctx, X_AD_FieldGroup.Table_Name, fieldGroup);
AD_Backup_ID = copyRecord(ctx, X_AD_FieldGroup.Table_Name, fieldGroup);
Object_Status = "Update";
if (processedFieldGroups.contains(id)) {
element.skip = true;
@ -71,6 +68,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
PoFiller pf = new PoFiller(fieldGroup, atts);
@ -83,7 +81,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
if (fieldGroup.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, fieldGroup.getName(), "FieldGroup",
fieldGroup.get_ID(), Object_Status,
fieldGroup.get_ID(), AD_Backup_ID, Object_Status,
X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table",
"TableName", X_AD_FieldGroup.Table_Name));
@ -93,7 +91,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
} else {
record_log(ctx, 0, fieldGroup.getName(), "FieldGroup",
fieldGroup.get_ID(), Object_Status,
fieldGroup.get_ID(), AD_Backup_ID, Object_Status,
X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table",
"TableName", X_AD_FieldGroup.Table_Name));
throw new POSaveFailedException("Reference");
@ -106,7 +104,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
public void endElement(Properties ctx, Element element) throws SAXException {
}
protected void create(Properties ctx, TransformerHandler document)
public void create(Properties ctx, TransformerHandler document)
throws SAXException {
@ -126,14 +124,10 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
document.startElement("", "", "fieldgroup", atts);
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");
}
@ -152,15 +146,4 @@ public class FieldGroupElementHandler extends AbstractElementHandler implements
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

@ -1,94 +0,0 @@
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,7 +16,6 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -29,15 +28,13 @@ 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 implements IPackOutHandler {
public class FormElementHandler extends AbstractElementHandler {
private List<Integer> forms = new ArrayList<Integer>();
@ -51,15 +48,17 @@ public class FormElementHandler extends AbstractElementHandler implements IPackO
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){
backupRecord(ctx, "AD_Form",m_Form);
AD_Backup_ID = copyRecord(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());
@ -71,10 +70,10 @@ public class FormElementHandler extends AbstractElementHandler implements IPackO
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(), Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
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"));
}
else{
record_log (ctx, 0, m_Form.getName(),"Form", m_Form.get_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(),AD_Backup_ID, Object_Status,"AD_Form",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
throw new POSaveFailedException("Failed to save form definition");
}
} else {
@ -85,7 +84,7 @@ public class FormElementHandler extends AbstractElementHandler implements IPackO
public void endElement(Properties ctx, Element element) throws SAXException {
}
protected void create(Properties ctx, TransformerHandler document)
public 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;
@ -127,15 +126,4 @@ public class FormElementHandler extends AbstractElementHandler implements IPackO
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

@ -1,13 +0,0 @@
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 implements IPackOutHandler {
public class ImpFormatElementHandler extends AbstractElementHandler {
private ImpFormatRowElementHandler rowHandler = new ImpFormatRowElementHandler();
@ -48,6 +48,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler implements
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"));
@ -58,10 +59,11 @@ public class ImpFormatElementHandler extends AbstractElementHandler implements
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) {
backupRecord(ctx, "AD_ImpFormat", m_ImpFormat);
AD_Backup_ID = copyRecord(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");
@ -85,12 +87,12 @@ public class ImpFormatElementHandler extends AbstractElementHandler implements
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(), Object_Status, "AD_ImpFormat",
.get_ID(), AD_Backup_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(), Object_Status, "AD_ImpFormat",
.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_ImpFormat"));
throw new POSaveFailedException("Failed to save Import Format.");
@ -100,7 +102,7 @@ public class ImpFormatElementHandler extends AbstractElementHandler implements
public void endElement(Properties ctx, Element element) throws SAXException {
}
protected void create(Properties ctx, TransformerHandler document)
public void create(Properties ctx, TransformerHandler document)
throws SAXException {
int import_id = Env.getContextAsInt(ctx,
X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID);
@ -177,14 +179,4 @@ public class ImpFormatElementHandler extends AbstractElementHandler implements
.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,11 +73,12 @@ 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){
backupRecord(ctx, "AD_ImpFormat",m_ImpFormat_row);
AD_Backup_ID = copyRecord(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);
@ -95,10 +96,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(),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(),AD_Backup_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(),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(),AD_Backup_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,19 +28,18 @@ 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 implements IPackOutHandler {
public class MenuElementHandler 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("ADMenuNameID"));
@ -58,13 +57,13 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
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) {
backupRecord(ctx, "AD_Menu", m_Menu);
AD_Backup_ID = copyRecord(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) {
@ -143,7 +142,7 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
if (m_Menu.save(getTrxName(ctx)) == true) {
try {
idDetail = record_log(ctx, 1, m_Menu.getName(), "Menu", m_Menu
.get_ID(), Object_Status, "AD_Menu",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Menu",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Menu"));
} catch (SAXException e) {
@ -152,7 +151,7 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
} else {
try {
idDetail = record_log(ctx, 0, m_Menu.getName(), "Menu", m_Menu
.get_ID(), Object_Status, "AD_Menu",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Menu",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Menu"));
} catch (SAXException e) {
@ -388,29 +387,25 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
|| rs.getInt("AD_FORM_ID") > 0
|| rs.getInt("AD_WORKBENCH_ID") > 0) {
// Call CreateWindow.
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);
if (rs.getInt("AD_WINDOW_ID") > 0) {
packOut.createWindow(rs.getInt("AD_WINDOW_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 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_Form_ID) > 0)
{
IPackOutHandler handler = packOut.getHandler("X");
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_Workflow_ID) > 0)
{
IPackOutHandler handler = packOut.getHandler("F");
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);
}
// Call CreateModule because entry is a summary menu
} else {
@ -445,10 +440,9 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
AttributesImpl atts = new AttributesImpl();
PreparedStatement pstmt = null;
ResultSet rs = null;
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
try {
rs = pstmt.executeQuery();
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
// Menu tag Start.
X_AD_Menu m_Menu = new X_AD_Menu(ctx, rs.getInt("AD_Menu_ID"),
@ -462,30 +456,26 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
|| rs.getInt("AD_FORM_ID") > 0
|| rs.getInt("AD_WORKBENCH_ID") > 0) {
// Call CreateWindow.
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);
if (rs.getInt("AD_WINDOW_ID") > 0) {
packOut.createWindow(rs.getInt("AD_WINDOW_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 CreateProcess.
else if (rs.getInt("AD_PROCESS_ID") > 0) {
packOut.createProcess(rs.getInt("AD_PROCESS_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 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);
}
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 CreateWorkflow
else if (rs.getInt("AD_Workflow_ID") > 0) {
packOut.createWorkflow(rs.getInt("AD_Workflow_ID"),
document);
}
// Call CreateModule because entry is a summary menu
} else {
@ -493,29 +483,18 @@ public class MenuElementHandler extends AbstractElementHandler implements IPackO
}
document.endElement("", "", "menu");
}
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, "getWindows", e);
} finally {
DB.close(rs, pstmt);
try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}
pstmt = null;
}
}
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 implements IPackOutHandler{
public class MessageElementHandler extends AbstractElementHandler {
private List<Integer> messages = new ArrayList<Integer>();
@ -52,15 +52,17 @@ public class MessageElementHandler extends AbstractElementHandler implements IPa
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){
backupRecord(ctx, "AD_Message",m_Message);
AD_Backup_ID = copyRecord(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"));
@ -69,10 +71,10 @@ public class MessageElementHandler extends AbstractElementHandler implements IPa
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(),Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
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"));
}
else{
record_log (ctx, 0, m_Message.getValue(),"Message", m_Message.get_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(),AD_Backup_ID, Object_Status,"AD_Message",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
throw new POSaveFailedException("Failed to save message.");
}
} else {
@ -134,15 +136,4 @@ public class MessageElementHandler extends AbstractElementHandler implements IPa
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,14 +53,16 @@ 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) {
backupRecord(ctx, "AD_Preference", m_Preference);
AD_Backup_ID = copyRecord(ctx, "AD_Preference", m_Preference);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
sqlB = null;
m_Preference.setAD_Window_ID(windowid);
@ -68,12 +70,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(), Object_Status,
m_Preference.get_ID(), AD_Backup_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(), Object_Status,
m_Preference.get_ID(), AD_Backup_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 implements IPackOutHandler {
public class PrintFormatElementHandler extends AbstractElementHandler {
private PrintFormatItemElementHandler itemHandler = new PrintFormatItemElementHandler();
@ -51,6 +51,7 @@ public class PrintFormatElementHandler extends AbstractElementHandler implements
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"));
@ -62,10 +63,11 @@ public class PrintFormatElementHandler extends AbstractElementHandler implements
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) {
backupRecord(ctx, "AD_PrintFormat", m_PrintFormat);
AD_Backup_ID = copyRecord(ctx, "AD_PrintFormat", m_PrintFormat);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
name = atts.getValue("ADReportviewnameID");
@ -87,12 +89,12 @@ public class PrintFormatElementHandler extends AbstractElementHandler implements
m_Table.setTableName(name);
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table",
m_Table.get_ID(), "New", "AD_Table",
m_Table.get_ID(), 0, "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table",
m_Table.get_ID(), "New", "AD_Table",
m_Table.get_ID(), 0, "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
}
@ -163,13 +165,13 @@ public class PrintFormatElementHandler extends AbstractElementHandler implements
.booleanValue());
if (m_PrintFormat.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_PrintFormat.getName(), "PrintFormat",
m_PrintFormat.get_ID(), Object_Status,
m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status,
"AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormat"));
element.recordId = m_PrintFormat.getAD_PrintFormat_ID();
} else {
record_log(ctx, 0, m_PrintFormat.getName(), "PrintFormat",
m_PrintFormat.get_ID(), Object_Status,
m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status,
"AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormat"));
throw new POSaveFailedException("Failed to save Print Format");
@ -347,16 +349,4 @@ public class PrintFormatElementHandler extends AbstractElementHandler implements
.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,6 +37,7 @@ 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"));
@ -55,11 +56,12 @@ 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) {
backupRecord(ctx, "AD_PrintFormatItem",
AD_Backup_ID = copyRecord(ctx, "AD_PrintFormatItem",
m_PrintFormatItem);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_PrintFormatItem.setName(name);
name = atts.getValue("ADPrintFormatNameID");
@ -230,12 +232,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(), Object_Status,
m_PrintFormatItem.get_ID(), AD_Backup_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(), Object_Status,
m_PrintFormatItem.get_ID(), AD_Backup_ID, Object_Status,
"AD_PrintFormatItem", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_PrintFormatItem"));
throw new POSaveFailedException("PrintFormatItem");

View File

@ -31,7 +31,6 @@ import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.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;
@ -40,7 +39,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ProcessElementHandler extends AbstractElementHandler implements IPackOutHandler{
public class ProcessElementHandler extends AbstractElementHandler {
private ProcessParaElementHandler paraHandler = new ProcessParaElementHandler();
@ -60,10 +59,11 @@ public class ProcessElementHandler extends AbstractElementHandler implements IPa
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));
backupRecord(ctx, "AD_Process", m_Process);
AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process);
Object_Status = "Update";
} else {
m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
@ -71,6 +71,7 @@ public class ProcessElementHandler extends AbstractElementHandler implements IPa
"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")));
@ -145,13 +146,13 @@ public class ProcessElementHandler extends AbstractElementHandler implements IPa
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(), Object_Status, "AD_Process",
.get_ID(), AD_Backup_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(), Object_Status, "AD_Process",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Process",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Process"));
throw new POSaveFailedException("Process");
@ -185,20 +186,19 @@ public class ProcessElementHandler extends AbstractElementHandler implements IPa
log.log(Level.INFO, "AD_ReportView_ID: "
+ m_Process.getAD_Process_ID());
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());
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)
{
IPackOutHandler handler = packOut.getHandler("PFT");
handler.packOut(packOut,null,null,document,null,m_Process.getAD_PrintFormat_ID());
if (m_Process.isReport() && m_Process.getAD_PrintFormat_ID() > 0) {
packOut.createPrintFormat(m_Process.getAD_PrintFormat_ID(),
document);
}
if (m_Process.getAD_Workflow_ID() > 0) {
IPackOutHandler handler = packOut.getHandler("F");
handler.packOut(packOut,null,null,document,null,m_Process.getAD_Workflow_ID());
packOut.createWorkflow(m_Process.getAD_Workflow_ID(),
document);
}
createProcessBinding(atts, m_Process);
document.startElement("", "", "process", atts);
@ -210,24 +210,15 @@ public class ProcessElementHandler extends AbstractElementHandler implements IPa
try {
ResultSet rsP = pstmtP.executeQuery();
while (rsP.next()) {
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)
{
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);
}
if (rsP.getInt("AD_Reference_ID") > 0)
packOut.createReference(rsP
.getInt("AD_Reference_ID"), document);
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);
createProcessPara(ctx, document, rsP
.getInt("AD_Process_Para_ID"));
@ -353,15 +344,4 @@ public class ProcessElementHandler extends AbstractElementHandler implements IPa
(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,15 +76,17 @@ 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) {
backupRecord(ctx, "AD_Process_Para",
AD_Backup_ID = copyRecord(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"));
@ -112,12 +114,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(), "New",
.getAD_Element_ID(), AD_Backup_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(), "New",
.getAD_Element_ID(), AD_Backup_ID, "New",
"AD_Element", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Element"));
}
@ -183,12 +185,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(), Object_Status,
m_Process_para.get_ID(), AD_Backup_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(), Object_Status,
m_Process_para.get_ID(), AD_Backup_ID, Object_Status,
"AD_Process_para", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Process_para"));
throw new POSaveFailedException("ProcessPara");

View File

@ -31,7 +31,6 @@ import org.adempiere.pipo.Element;
import org.adempiere.pipo.PackOut;
import org.adempiere.pipo.exception.DatabaseAccessException;
import org.adempiere.pipo.exception.POSaveFailedException;
import org.compiere.model.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;
@ -41,7 +40,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ReferenceElementHandler extends AbstractElementHandler implements IPackOutHandler{
public class ReferenceElementHandler extends AbstractElementHandler {
private ReferenceListElementHandler listHandler = new ReferenceListElementHandler();
private ReferenceTableElementHandler tableHandler = new ReferenceTableElementHandler();
@ -51,6 +50,7 @@ public class ReferenceElementHandler extends AbstractElementHandler implements I
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 implements I
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) {
backupRecord(ctx, "AD_Reference", m_Reference);
AD_Backup_ID = copyRecord(ctx, "AD_Reference", m_Reference);
Object_Status = "Update";
if (references.contains(id)) {
element.skip = true;
@ -75,6 +75,7 @@ public class ReferenceElementHandler extends AbstractElementHandler implements I
}
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Reference.setDescription(getStringValue(atts,"Description"));
@ -88,14 +89,14 @@ public class ReferenceElementHandler extends AbstractElementHandler implements I
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(), Object_Status,
m_Reference.get_ID(), AD_Backup_ID, Object_Status,
"AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference"));
references.add(m_Reference.getAD_Reference_ID());
element.recordId = m_Reference.getAD_Reference_ID();
} else {
record_log(ctx, 0, m_Reference.getName(), "Reference",
m_Reference.get_ID(), Object_Status,
m_Reference.get_ID(), AD_Backup_ID, Object_Status,
"AD_Reference", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reference"));
throw new POSaveFailedException("Reference");
@ -275,14 +276,4 @@ public class ReferenceElementHandler extends AbstractElementHandler implements I
: ""));
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,6 +36,7 @@ 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"));
@ -63,10 +64,11 @@ 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) {
backupRecord(ctx, "AD_Ref_List", m_Ref_List);
AD_Backup_ID = copyRecord(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);
@ -79,12 +81,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(), Object_Status,
m_Ref_List.get_ID(), AD_Backup_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(), Object_Status,
m_Ref_List.get_ID(), AD_Backup_ID, Object_Status,
"AD_Ref_List", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Ref_List"));
throw new POSaveFailedException("ReferenceList");

View File

@ -42,6 +42,8 @@ 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;
@ -77,11 +79,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(), "New", "AD_Table", get_IDWithColumn(
.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table", m_Table
.get_ID(), "New", "AD_Table", get_IDWithColumn(
.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Table"));
}
tableId = get_IDWithColumn(ctx, "AD_Table", "TableName", atts
@ -100,11 +102,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(), "New", "AD_Column", get_IDWithColumn(
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
} else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), "New", "AD_Column", get_IDWithColumn(
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
}
}
@ -121,11 +123,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(), "New", "AD_Column", get_IDWithColumn(
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
} else {
record_log(ctx, 0, m_Column.getName(), "Column", m_Column
.get_ID(), "New", "AD_Column", get_IDWithColumn(
.get_ID(), 0, "New", "AD_Column", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Column"));
}
}
@ -154,12 +156,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, "Update", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "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, "Update", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
throw new POSaveFailedException("ReferenceTable");
@ -183,12 +185,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, "New", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "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, "New", "AD_Ref_Table",
"Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Ref_Table"));
throw new POSaveFailedException("ReferenceTable");

View File

@ -36,6 +36,7 @@ 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;
@ -83,11 +84,12 @@ 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) {
backupRecord(ctx, "AD_Reportview_Col",
AD_Backup_ID = copyRecord(ctx, "AD_Reportview_Col",
m_Reportview_Col);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
boolean isGroupFunction = Boolean.valueOf(
@ -108,13 +110,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(),
Object_Status, "AD_Reportview_Col",
AD_Backup_ID, 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(),
Object_Status, "AD_Reportview_Col",
AD_Backup_ID, Object_Status, "AD_Reportview_Col",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Reportview_Col"));
throw new POSaveFailedException("ReportViewCol");

View File

@ -32,7 +32,6 @@ 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;
@ -41,7 +40,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class ReportViewElementHandler extends AbstractElementHandler implements IPackOutHandler{
public class ReportViewElementHandler extends AbstractElementHandler {
private ReportViewColElementHandler columnHandler = new ReportViewColElementHandler();
@ -50,9 +49,11 @@ public class ReportViewElementHandler extends AbstractElementHandler implements
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);
@ -61,10 +62,11 @@ public class ReportViewElementHandler extends AbstractElementHandler implements
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) {
backupRecord(ctx, "AD_Reportview", m_Reportview);
AD_Backup_ID = copyRecord(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);
@ -76,12 +78,12 @@ public class ReportViewElementHandler extends AbstractElementHandler implements
m_Table.setTableName(Name);
if (m_Table.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Table.getName(), "Table",
m_Table.get_ID(), "New", "AD_Table",
m_Table.get_ID(), 0, "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
} else {
record_log(ctx, 0, m_Table.getName(), "Table",
m_Table.get_ID(), "New", "AD_Table",
m_Table.get_ID(), 0, "New", "AD_Table",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Table"));
}
@ -98,13 +100,13 @@ public class ReportViewElementHandler extends AbstractElementHandler implements
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(), Object_Status,
m_Reportview.get_ID(), AD_Backup_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(), Object_Status,
m_Reportview.get_ID(), AD_Backup_ID, Object_Status,
"AD_Reportview", get_IDWithColumn(ctx, "AD_Table",
"TableName", "AD_Reportview"));
throw new POSaveFailedException("ReportView");
@ -144,11 +146,10 @@ public class ReportViewElementHandler extends AbstractElementHandler implements
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()) {
// Export Table if neccessary
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);
packOut.createTable(rs1.getInt("AD_Table_ID"),
document);
packOut.createPrintFormat(rs1
.getInt("AD_Printformat_ID"), document);
}
rs1.close();
pstmt1.close();
@ -263,15 +264,4 @@ public class ReportViewElementHandler extends AbstractElementHandler implements
.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 implements IPackOutHandler{
public class RoleElementHandler extends AbstractElementHandler {
private List<Integer> roles = new ArrayList<Integer>();
@ -69,13 +69,16 @@ public class RoleElementHandler extends AbstractElementHandler implements IPackO
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);
@ -185,12 +188,12 @@ public class RoleElementHandler extends AbstractElementHandler implements IPackO
if (m_Role.save(getTrxName(ctx)) == true) {
record_log(ctx, 1, m_Role.getName(), "Role", m_Role.get_ID(),
Object_Status, "AD_Role", get_IDWithColumn(
AD_Backup_ID, 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(),
Object_Status, "AD_Role", get_IDWithColumn(
AD_Backup_ID, Object_Status, "AD_Role", get_IDWithColumn(
ctx, "AD_Table", "TableName", "AD_Role"));
throw new POSaveFailedException("Role");
}
@ -514,15 +517,4 @@ public class RoleElementHandler extends AbstractElementHandler implements IPackO
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,7 +18,6 @@ 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;
@ -27,7 +26,6 @@ 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;
@ -35,11 +33,13 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class SQLStatementElementHandler extends AbstractElementHandler implements IPackOutHandler{
public class SQLStatementElementHandler 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;
String DBType = atts.getValue("DBType");
@ -50,7 +50,7 @@ public class SQLStatementElementHandler extends AbstractElementHandler implement
try {
if(DBType.equals("ALL")) {
int n = pstmt.executeUpdate();
log.info("Executed SQL Statement: "+ atts.getValue("statement") + " ReturnValue="+n);
log.info("Executed SQL Statement: "+ atts.getValue("statement"));
}
else if(DB.isOracle() == true && DBType.equals("Oracle")) {
pstmt.executeUpdate();
@ -70,7 +70,7 @@ public class SQLStatementElementHandler extends AbstractElementHandler implement
try {
Statement stmt = m_con.createStatement();
int n = stmt.executeUpdate (atts.getValue("statement"));
log.info("Executed SQL Statement for PostgreSQL: "+ atts.getValue("statement") + " ReturnValue="+n);
log.info("Executed SQL Statement for PostgreSQL: "+ atts.getValue("statement"));
// Postgres needs to commit DDL statements
if (m_con != null && !m_con.getAutoCommit())
m_con.commit();
@ -106,13 +106,4 @@ public class SQLStatementElementHandler extends AbstractElementHandler implement
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,13 +81,15 @@ 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){
backupRecord(ctx, "AD_Tab",m_Tab);
AD_Backup_ID = copyRecord(ctx, "AD_Tab",m_Tab);
Object_Status = "Update";
}
else{
Object_Status = "New";
AD_Backup_ID =0;
}
sqlB = null;
m_Tab.setName(name);
@ -168,10 +170,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(),Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
record_log (ctx, 1, m_Tab.getName(),"Tab", m_Tab.get_ID(),AD_Backup_ID, Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
element.recordId = m_Tab.getAD_Tab_ID();
} else {
record_log (ctx, 0, m_Tab.getName(),"Tab", m_Tab.get_ID(),Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
record_log (ctx, 0, m_Tab.getName(),"Tab", m_Tab.get_ID(),AD_Backup_ID, Object_Status,"AD_Tab",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Tab"));
throw new POSaveFailedException("Tab");
}
} else {
@ -226,15 +228,7 @@ public class TabElementHandler extends AbstractElementHandler {
if(m_Tab.getAD_Process_ID() > 0 )
{
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());
}
packOut.createProcess(m_Tab.getAD_Process_ID(), document);
}
}
@ -333,4 +327,5 @@ 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 implements IPackOutHandler{
public class TableElementHandler extends AbstractElementHandler {
private ColumnElementHandler columnHandler = new ColumnElementHandler();
private List<Integer>tables = new ArrayList<Integer>();
@ -68,13 +68,15 @@ public class TableElementHandler extends AbstractElementHandler implements IPack
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){
backupRecord(ctx, "AD_Table",m_Table);
AD_Backup_ID = copyRecord(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");
@ -107,13 +109,13 @@ public class TableElementHandler extends AbstractElementHandler implements IPack
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(),Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
record_log (ctx, 1, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
tables.add(m_Table.getAD_Table_ID());
packIn.addTable(tableName, m_Table.getAD_Table_ID());
element.recordId = m_Table.getAD_Table_ID();
}
else{
record_log (ctx, 0, m_Table.getName(),"Table", m_Table.get_ID(),Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
record_log (ctx, 0, m_Table.getName(),"Table", m_Table.get_ID(),AD_Backup_ID, Object_Status,"AD_Table",get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
throw new POSaveFailedException("Table");
}
} else {
@ -160,33 +162,21 @@ public class TableElementHandler extends AbstractElementHandler implements IPack
ResultSet rs1 = pstmt1.executeQuery();
while (rs1.next()){
IPackOutHandler handler = packOut.getHandler("ELE");
handler.packOut(packOut,null,rs1,document,null,0);
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);
}
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("AD_Reference_Value_ID")>0)
{
handler = packOut.getHandler("REF");
handler.packOut(packOut,null,null,document,null,rs1.getInt("AD_Reference_Value_ID"));
}
packOut.createReference (rs1.getInt("AD_Reference_Value_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(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID)>0)
{
handler = packOut.getHandler("V");
handler.packOut(packOut,rs,rs1,document,null,0);
}
if (rs1.getInt("AD_Process_ID")>0)
packOut.createProcess (rs1.getInt("AD_Process_ID"), document);
if (rs1.getInt("AD_Val_Rule_ID")>0)
packOut.createDynamicRuleValidation (rs1.getInt("AD_Val_Rule_ID"), document);
createColumn(ctx, document, rs1.getInt("AD_Column_ID"));
}
@ -294,15 +284,4 @@ public class TableElementHandler extends AbstractElementHandler implements IPack
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,7 +16,6 @@
*****************************************************************************/
package org.adempiere.pipo.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -35,9 +34,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import java.sql.ResultSet;
public class TaskElementHandler extends AbstractElementHandler implements IPackOutHandler{
public class TaskElementHandler extends AbstractElementHandler {
private List<Integer> tasks = new ArrayList<Integer>();
@ -51,14 +48,16 @@ public class TaskElementHandler extends AbstractElementHandler implements IPackO
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) {
backupRecord(ctx, "AD_Task", m_Task);
AD_Backup_ID = copyRecord(ctx, "AD_Task", m_Task);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Task.setAccessLevel(atts.getValue("AccessLevel"));
m_Task.setDescription(getStringValue(atts,"Description"));
@ -70,12 +69,12 @@ public class TaskElementHandler extends AbstractElementHandler implements IPackO
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(),
Object_Status, "AD_Task",
AD_Backup_ID, Object_Status, "AD_Task",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Task"));
} else {
record_log(ctx, 0, m_Task.getName(), "Task", m_Task.get_ID(),
Object_Status, "AD_Task",
AD_Backup_ID, Object_Status, "AD_Task",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Task"));
throw new POSaveFailedException("Task");
@ -136,15 +135,5 @@ public class TaskElementHandler extends AbstractElementHandler implements IPackO
.getOS_Command() != null ? m_Task.getOS_Command() : ""));
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,7 +32,6 @@ 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;
@ -42,7 +41,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
public class WindowElementHandler extends AbstractElementHandler implements IPackOutHandler{
public class WindowElementHandler extends AbstractElementHandler {
private TabElementHandler tabHandler = new TabElementHandler();
private PreferenceElementHandler preferenceHandler = new PreferenceElementHandler();
@ -66,11 +65,13 @@ public class WindowElementHandler extends AbstractElementHandler implements IPac
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) {
backupRecord(ctx, "AD_Window", m_Window);
AD_Backup_ID = copyRecord(ctx, "AD_Window", m_Window);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_Window.setName(name);
@ -119,14 +120,14 @@ public class WindowElementHandler extends AbstractElementHandler implements IPac
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(), Object_Status, "AD_Window",
.get_ID(), AD_Backup_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(), Object_Status, "AD_Window",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Window",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Window"));
throw new POSaveFailedException("Window");
@ -156,9 +157,12 @@ public class WindowElementHandler extends AbstractElementHandler implements IPac
try {
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
IPackOutHandler handler = packOut.getHandler("T");
handler.packOut(packOut,null,rs,document,null,0);
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);
createTab(ctx, document, rs.getInt("AD_Tab_ID"));
}
rs.close();
@ -295,15 +299,4 @@ public class WindowElementHandler extends AbstractElementHandler implements IPac
.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 implements IPackOutHandler{
public class WorkflowElementHandler extends AbstractElementHandler {
private WorkflowNodeElementHandler nodeHandler = new WorkflowNodeElementHandler();
private WorkflowNodeNextElementHandler nodeNextHandler = new WorkflowNodeNextElementHandler();
@ -71,14 +71,16 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
}
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) {
backupRecord(ctx, "AD_Workflow", m_Workflow);
AD_Backup_ID = copyRecord(ctx, "AD_Workflow", m_Workflow);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
String name = atts.getValue("ADWorkflowResponsibleNameID");
@ -150,7 +152,7 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
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(), Object_Status, "AD_Workflow",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
workflows.add(m_Workflow.getAD_Workflow_ID());
@ -158,7 +160,7 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
} else {
log.info("m_Workflow save failure");
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), Object_Status, "AD_Workflow",
.get_ID(), AD_Backup_ID, Object_Status, "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
throw new POSaveFailedException("MWorkflow");
@ -189,7 +191,7 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
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(), "Update", "AD_Workflow",
.get_ID(), 0, "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
workflows.add(m_Workflow.getAD_Workflow_ID());
@ -197,7 +199,7 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
} else {
log.info("m_Workflow update fail");
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), "Update", "AD_Workflow",
.get_ID(), 0, "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
throw new POSaveFailedException("MWorkflow");
@ -220,7 +222,7 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
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(), "Update", "AD_Workflow",
.get_ID(), 0, "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
workflows.add(m_Workflow.getAD_Workflow_ID());
@ -228,7 +230,7 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
} else {
log.info("m_Workflow update fail");
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
.get_ID(), "Update", "AD_Workflow",
.get_ID(), 0, "Update", "AD_Workflow",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_Workflow"));
throw new POSaveFailedException("MWorkflow");
@ -463,16 +465,4 @@ public class WorkflowElementHandler extends AbstractElementHandler implements IP
// != 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,14 +81,16 @@ 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) {
backupRecord(ctx, "AD_WF_Node", m_WFNode);
AD_Backup_ID = copyRecord(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);
@ -228,13 +230,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(), Object_Status, "AD_WF_Node",
.get_ID(), AD_Backup_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(), Object_Status, "AD_WF_Node",
.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_Node",
get_IDWithColumn(ctx, "AD_Table", "TableName",
"AD_WF_Node"));
throw new POSaveFailedException("WorkflowNode");

View File

@ -92,15 +92,17 @@ 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) {
backupRecord(ctx, "AD_WF_NextCondition",
AD_Backup_ID = copyRecord(ctx, "AD_WF_NextCondition",
m_WFNodeNextCondition);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
sqlB = new StringBuffer(
@ -137,6 +139,7 @@ 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",
@ -149,6 +152,7 @@ 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,6 +24,7 @@ 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;
@ -77,15 +78,17 @@ 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){
backupRecord(ctx, "AD_WF_NodeNext",m_WFNodeNext);
AD_Backup_ID = copyRecord(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);
@ -96,12 +99,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(), Object_Status,"AD_WF_NodeNext",
record_log (ctx, 1, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(),AD_Backup_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(), Object_Status,"AD_WF_NodeNext",
record_log (ctx, 0, String.valueOf(m_WFNodeNext.get_ID()),"WFNodeNext", m_WFNodeNext.get_ID(),AD_Backup_ID, Object_Status,"AD_WF_NodeNext",
get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NodeNext"));
throw new POSaveFailedException("WorkflowNodeNext");
}
@ -182,5 +185,90 @@ public class WorkflowNodeNextElementHandler extends AbstractElementHandler {
.valueOf(m_WF_NodeNext.isStdUserWorkflow()) : ""));
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;
}
}