diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java
index 7e08c57cd3..572cdcd177 100644
--- a/org.adempiere.base/src/org/compiere/model/PO.java
+++ b/org.adempiere.base/src/org/compiere/model/PO.java
@@ -863,7 +863,7 @@ public abstract class PO
* @param value value
* @return true if value set
*/
- protected final boolean set_ValueNoCheck (String ColumnName, Object value)
+ public final boolean set_ValueNoCheck (String ColumnName, Object value)
{
int index = get_ColumnIndex(ColumnName);
if (index < 0)
diff --git a/org.adempiere.pipo.handlers/plugin.xml b/org.adempiere.pipo.handlers/plugin.xml
index 0286b73627..dfe05878c0 100644
--- a/org.adempiere.pipo.handlers/plugin.xml
+++ b/org.adempiere.pipo.handlers/plugin.xml
@@ -164,6 +164,10 @@
class="org.adempiere.pipo2.handler.ReferenceTableElementHandler"
id="AD_Ref_Table">
+
+
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java
index 612ae824a0..3b77579416 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AdElementHandler.java
@@ -19,11 +19,11 @@ package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
@@ -44,19 +44,19 @@ public class AdElementHandler extends AbstractElementHandler {
private final String AD_ELEMENT = "AD_Element";
- public void startElement(Properties ctx, Element element)
+ public void startElement(PIPOContext ctx, Element element)
throws SAXException {
String action = null;
String entitytype = getStringValue(element, "EntityType");
String ColumnName = getStringValue(element, "ColumnName");
- if (isProcessElement(ctx, entitytype)) {
-
+ if (isProcessElement(ctx.ctx, entitytype)) {
+
M_Element mElement = findPO(ctx, element);
if (mElement == null) {
- int id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName);
- mElement = new M_Element(ctx, id, getTrxName(ctx));
+ int id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName, /*ignorecase=*/true);
+ mElement = new M_Element(ctx.ctx, id, getTrxName(ctx));
}
List excludes = defaultExcludeList(X_AD_Element.Table_Name);
if (mElement.getAD_Element_ID() == 0 && isOfficialId(element, "AD_Element_ID"))
@@ -71,6 +71,7 @@ public class AdElementHandler extends AbstractElementHandler {
List notfounds = pf.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
@@ -94,7 +95,7 @@ public class AdElementHandler extends AbstractElementHandler {
} else {
logImportDetail(ctx, impDetail, 0, mElement.getName(),
mElement.get_ID(), action);
- throw new POSaveFailedException("Reference");
+ throw new POSaveFailedException("Failed to save Element " + mElement.getName());
}
}
} else {
@@ -102,14 +103,14 @@ public class AdElementHandler extends AbstractElementHandler {
}
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- protected void create(Properties ctx, TransformerHandler document)
+ protected void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int adElement_id = Env.getContextAsInt(ctx,
+ int adElement_id = Env.getContextAsInt(ctx.ctx,
X_AD_Element.COLUMNNAME_AD_Element_ID);
if (processedElements.contains(adElement_id))
@@ -117,18 +118,22 @@ public class AdElementHandler extends AbstractElementHandler {
processedElements.add(adElement_id);
- X_AD_Element m_AdElement = new X_AD_Element(ctx, adElement_id, null);
+ X_AD_Element mAdElement = new X_AD_Element(ctx.ctx, adElement_id, null);
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (mAdElement.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
AttributesImpl atts = new AttributesImpl();
addTypeName(atts, "table");
document.startElement("", "", "AD_Element", atts);
- createAdElementBinding(ctx, document, m_AdElement);
-
- PackOut packOut = (PackOut)ctx.get("PackOutProcess");
-
+ createAdElementBinding(ctx, document, mAdElement);
+ PackOut packOut = ctx.packOut;
try{
- new CommonTranslationHandler().packOut(packOut,document,null,m_AdElement.get_ID());
+ new CommonTranslationHandler().packOut(packOut,document,null,mAdElement.get_ID());
}
catch(Exception e)
{
@@ -139,7 +144,7 @@ public class AdElementHandler extends AbstractElementHandler {
}
- private void createAdElementBinding(Properties ctx, TransformerHandler document,
+ private void createAdElementBinding(PIPOContext ctx, TransformerHandler document,
X_AD_Element m_AdElement) {
PoExporter filler = new PoExporter(ctx, document, m_AdElement);
@@ -152,8 +157,8 @@ public class AdElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
{
- Env.setContext(packout.getCtx(), X_AD_Element.COLUMNNAME_AD_Element_ID, recordId);
+ Env.setContext(packout.getCtx().ctx, X_AD_Element.COLUMNNAME_AD_Element_ID, recordId);
this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Element.COLUMNNAME_AD_Element_ID);
+ packout.getCtx().ctx.remove(X_AD_Element.COLUMNNAME_AD_Element_ID);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java
new file mode 100644
index 0000000000..0246aceb10
--- /dev/null
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/AttachmentElementHandler.java
@@ -0,0 +1,178 @@
+/******************************************************************************
+ * 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 *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *
+ * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
+ * Contributor(s): Low Heng Sin hengsin@avantz.com
+ *****************************************************************************/
+package org.adempiere.pipo2.handler;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.transform.sax.TransformerHandler;
+
+import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.Element;
+import org.adempiere.pipo2.ElementHandler;
+import org.adempiere.pipo2.PIPOContext;
+import org.adempiere.pipo2.PackOut;
+import org.adempiere.pipo2.PoExporter;
+import org.adempiere.pipo2.PoFiller;
+import org.adempiere.pipo2.ReferenceUtils;
+import org.adempiere.pipo2.exception.POSaveFailedException;
+import org.compiere.model.MAttachment;
+import org.compiere.model.PO;
+import org.compiere.model.X_AD_Attachment;
+import org.compiere.model.X_AD_AttachmentNote;
+import org.compiere.model.X_AD_Package_Imp_Detail;
+import org.compiere.util.DB;
+import org.compiere.util.Env;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+public class AttachmentElementHandler extends AbstractElementHandler {
+
+ private List attachments = new ArrayList();
+
+ public void startElement(PIPOContext ctx, Element element)
+ throws SAXException {
+ String action = null;
+
+ MAttachment mAttachment = findPO(ctx, element);
+ if (mAttachment == null) {
+ int AD_Table_ID = ReferenceUtils.resolveReference(ctx.ctx, element.properties.get("AD_Table_ID"), getTrxName(ctx));
+ if (AD_Table_ID <= 0) {
+ element.defer = true;
+ element.unresolved = "AD_Table_ID";
+ return;
+ }
+ Element recordElement = element.properties.get("Record_ID");
+ int Record_ID = ReferenceUtils.resolveReference(ctx.ctx, recordElement, getTrxName(ctx));
+ if (Record_ID <= 0) {
+ element.defer = true;
+ element.unresolved = "Record_ID";
+ return;
+ }
+
+ int id = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Attachment_ID FROM AD_Attachment WHERE Record_ID="+Record_ID+" AND AD_Table_ID="+AD_Table_ID);
+ mAttachment = new MAttachment(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
+ if (mAttachment.is_new()) {
+ mAttachment.setAD_Table_ID(AD_Table_ID);
+ mAttachment.setRecord_ID(Record_ID);
+ }
+ }
+ List excludes = defaultExcludeList(X_AD_Attachment.Table_Name);
+ excludes.add("AD_Table_ID");
+ excludes.add("Record_ID");
+ if (mAttachment.getAD_Attachment_ID() == 0 && isOfficialId(element, "AD_Attachment_ID"))
+ mAttachment.setAD_Attachment_ID(getIntValue(element, "AD_Attachment_ID"));
+
+ if (attachments.contains(mAttachment.getAD_Attachment_ID())) {
+ element.skip = true;
+ return;
+ }
+
+ PoFiller pf = new PoFiller(ctx, mAttachment, element, this);
+ List notfounds = pf.autoFill(excludes);
+ if (notfounds.size() > 0) {
+ element.defer = true;
+ element.unresolved = notfounds.toString();
+ return;
+ }
+
+ mAttachment.getEntries();
+ if (mAttachment.is_new() || mAttachment.is_Changed()) {
+ X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Attachment.Table_Name, X_AD_Attachment.Table_ID);
+ if (!mAttachment.is_new()) {
+ backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_Attachment.Table_Name, mAttachment);
+ action = "Update";
+ } else {
+ action = "New";
+ }
+
+ if (mAttachment.save(getTrxName(ctx)) == true) {
+ logImportDetail(ctx, impDetail, 1, mAttachment.toString(),
+ mAttachment.get_ID(), action);
+
+ element.recordId = mAttachment.getAD_Attachment_ID();
+
+ attachments.add(mAttachment.getAD_Attachment_ID());
+
+ } else {
+ logImportDetail(ctx, impDetail, 0, mAttachment.toString(),
+ mAttachment.get_ID(), action);
+ throw new POSaveFailedException("Failed to save Attachment " + mAttachment.toString());
+ }
+ }
+ }
+
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
+ }
+
+ protected void create(PIPOContext ctx, TransformerHandler document)
+ throws SAXException {
+
+
+ int AD_Attachment_ID = Env.getContextAsInt(ctx.ctx, "AD_Attachment_ID");
+
+ if (attachments.contains(AD_Attachment_ID))
+ return;
+
+ attachments.add(AD_Attachment_ID);
+
+ MAttachment mAttachment = new MAttachment(ctx.ctx, AD_Attachment_ID, getTrxName(ctx));
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (mAttachment.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
+
+ AttributesImpl atts = new AttributesImpl();
+ addTypeName(atts, "table");
+ document.startElement("", "", "AD_Attachment", atts);
+ createAttachmentBinding(ctx, document, mAttachment);
+
+ int[] ids = PO.getAllIDs(X_AD_AttachmentNote.Table_Name, "AD_Attachment_ID="+AD_Attachment_ID, getTrxName(ctx));
+ if (ids != null && ids.length > 0) {
+ ElementHandler handler = ctx.packOut.getHandler(X_AD_AttachmentNote.Table_Name);
+ for (int AD_AttachmentNote_ID : ids ) {
+ try {
+ handler.packOut(ctx.packOut, document, null, AD_AttachmentNote_ID);
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+ }
+ }
+ document.endElement("", "", "AD_Attachment");
+ }
+
+
+ private void createAttachmentBinding(PIPOContext ctx, TransformerHandler document,
+ MAttachment mAttachment) {
+
+ PoExporter filler = new PoExporter(ctx, document, mAttachment);
+ if (mAttachment.getAD_Attachment_ID() <= PackOut.MAX_OFFICIAL_ID)
+ filler.add("AD_Attachment_ID", new AttributesImpl());
+
+ List excludes = defaultExcludeList(X_AD_Attachment.Table_Name);
+ filler.export(excludes);
+ }
+
+ public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
+ {
+ packout.getCtx().ctx.put("AD_Attachment_ID", recordId);
+ this.create(packout.getCtx(), packoutHandler);
+ packout.getCtx().ctx.remove("AD_Attachment_ID");
+ }
+}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java
index 182cb72e5e..dd6cbc1697 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java
@@ -28,7 +28,6 @@ import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
@@ -44,12 +43,13 @@ import org.xml.sax.helpers.AttributesImpl;
import org.adempiere.pipo2.AbstractElementHandler;
import org.adempiere.pipo2.CodeSnippetElementParameters;
import org.adempiere.pipo2.Element;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PackOut;
import org.adempiere.pipo2.PackoutItem;
public class CodeSnippetElementHandler extends AbstractElementHandler {
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
String action = null;
action = "Update";
String releaseNumber = getStringValue(element, "ReleaseNo");
@@ -68,7 +68,7 @@ public class CodeSnippetElementHandler extends AbstractElementHandler {
//get adempiere-all directory
try {
- packagePath = getPackageDirectory(ctx);
+ packagePath = getPackageDirectory(ctx.ctx);
File parentDirectory = new File(packagePath);
while (!parentDirectory.getName().equals("packages")){
parentDirectory = parentDirectory.getParentFile();
@@ -144,9 +144,9 @@ public class CodeSnippetElementHandler extends AbstractElementHandler {
}
//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));
+ X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx.ctx, 0, getTrxName(ctx));
+ backup.setAD_Org_ID(Env.getAD_Org_ID(ctx.ctx));
+ backup.setAD_Package_Imp_ID(getPackageImpId(ctx.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();
@@ -189,18 +189,18 @@ public class CodeSnippetElementHandler extends AbstractElementHandler {
}
- public void endElement(Properties ctx, Element element)
+ public void endElement(PIPOContext ctx, Element element)
throws SAXException {
}
- public void create(Properties ctx, TransformerHandler document)
+ public void create(PIPOContext pipoContext, TransformerHandler document)
throws SAXException {
- String FileDir = Env.getContext(ctx, CodeSnippetElementParameters.DESTINATION_DIRECTORY);
- String FileName = Env.getContext(ctx, CodeSnippetElementParameters.DESTINATION_FILE_NAME);
- String OldCode = Env.getContext(ctx, CodeSnippetElementParameters.AD_Package_Code_Old);
- String NewCode = Env.getContext(ctx, CodeSnippetElementParameters.AD_Package_Code_New);
- String ReleaseNo = Env.getContext(ctx, CodeSnippetElementParameters.RELEASE_NO);
+ String FileDir = Env.getContext(pipoContext.ctx, CodeSnippetElementParameters.DESTINATION_DIRECTORY);
+ String FileName = Env.getContext(pipoContext.ctx, CodeSnippetElementParameters.DESTINATION_FILE_NAME);
+ String OldCode = Env.getContext(pipoContext.ctx, CodeSnippetElementParameters.AD_Package_Code_Old);
+ String NewCode = Env.getContext(pipoContext.ctx, CodeSnippetElementParameters.AD_Package_Code_New);
+ String ReleaseNo = Env.getContext(pipoContext.ctx, CodeSnippetElementParameters.RELEASE_NO);
AttributesImpl atts = new AttributesImpl();
addTypeName(atts, "custom");
createSnipitBinding(atts, FileDir, FileName, OldCode, NewCode, ReleaseNo);
@@ -232,16 +232,16 @@ public class CodeSnippetElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
{
PackoutItem detail = packout.getCurrentPackoutItem();
- Env.setContext(packout.getCtx(), CodeSnippetElementParameters.DESTINATION_DIRECTORY, (String)detail.getProperty(CodeSnippetElementParameters.DESTINATION_DIRECTORY));
- Env.setContext(packout.getCtx(), CodeSnippetElementParameters.DESTINATION_FILE_NAME, (String)detail.getProperty(CodeSnippetElementParameters.DESTINATION_FILE_NAME));
- Env.setContext(packout.getCtx(), CodeSnippetElementParameters.AD_Package_Code_Old, (String)detail.getProperty(CodeSnippetElementParameters.AD_Package_Code_Old));
- Env.setContext(packout.getCtx(), CodeSnippetElementParameters.AD_Package_Code_New, (String)detail.getProperty(CodeSnippetElementParameters.AD_Package_Code_New));
- Env.setContext(packout.getCtx(), CodeSnippetElementParameters.RELEASE_NO, (String)detail.getProperty(CodeSnippetElementParameters.RELEASE_NO));
+ Env.setContext(packout.getCtx().ctx, CodeSnippetElementParameters.DESTINATION_DIRECTORY, (String)detail.getProperty(CodeSnippetElementParameters.DESTINATION_DIRECTORY));
+ Env.setContext(packout.getCtx().ctx, CodeSnippetElementParameters.DESTINATION_FILE_NAME, (String)detail.getProperty(CodeSnippetElementParameters.DESTINATION_FILE_NAME));
+ Env.setContext(packout.getCtx().ctx, CodeSnippetElementParameters.AD_Package_Code_Old, (String)detail.getProperty(CodeSnippetElementParameters.AD_Package_Code_Old));
+ Env.setContext(packout.getCtx().ctx, CodeSnippetElementParameters.AD_Package_Code_New, (String)detail.getProperty(CodeSnippetElementParameters.AD_Package_Code_New));
+ Env.setContext(packout.getCtx().ctx, CodeSnippetElementParameters.RELEASE_NO, (String)detail.getProperty(CodeSnippetElementParameters.RELEASE_NO));
this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(CodeSnippetElementParameters.DESTINATION_DIRECTORY);
- packout.getCtx().remove(CodeSnippetElementParameters.DESTINATION_FILE_NAME);
- packout.getCtx().remove(CodeSnippetElementParameters.AD_Package_Code_Old);
- packout.getCtx().remove(CodeSnippetElementParameters.AD_Package_Code_New);
- packout.getCtx().remove(CodeSnippetElementParameters.RELEASE_NO);
+ packout.getCtx().ctx.remove(CodeSnippetElementParameters.DESTINATION_DIRECTORY);
+ packout.getCtx().ctx.remove(CodeSnippetElementParameters.DESTINATION_FILE_NAME);
+ packout.getCtx().ctx.remove(CodeSnippetElementParameters.AD_Package_Code_Old);
+ packout.getCtx().ctx.remove(CodeSnippetElementParameters.AD_Package_Code_New);
+ packout.getCtx().ctx.remove(CodeSnippetElementParameters.RELEASE_NO);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java
index 5b52b0dfeb..f0d5a530b3 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/ColumnElementHandler.java
@@ -21,12 +21,12 @@ import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-import java.util.Properties;
import java.util.logging.Level;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
@@ -49,11 +49,11 @@ import org.xml.sax.helpers.AttributesImpl;
public class ColumnElementHandler extends AbstractElementHandler {
- public void startElement(Properties ctx, Element element)
+ public void startElement(PIPOContext ctx, Element element)
throws SAXException {
int success = 0;
String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
+ if (isProcessElement(ctx.ctx, entitytype)) {
if (isParentDefer(element, I_AD_Table.Table_Name)) {
element.defer = true;
return;
@@ -68,13 +68,13 @@ public class ColumnElementHandler extends AbstractElementHandler {
if (getParentId(element, I_AD_Table.Table_Name) > 0) {
tableid = getParentId(element, I_AD_Table.Table_Name);
} else {
- mColumn = new MColumn(ctx, 0, getTrxName(ctx));
+ mColumn = new MColumn(ctx.ctx, 0, getTrxName(ctx));
PoFiller filler = new PoFiller(ctx, mColumn, element, this);
filler.setTableReference("AD_Table_ID");
tableid = mColumn.getAD_Table_ID();
}
- int AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid);
- mColumn = new MColumn(ctx, AD_Column_ID > 0 ? AD_Column_ID : 0, getTrxName(ctx));
+ int AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid, /*ignorecase=*/true);
+ mColumn = new MColumn(ctx.ctx, AD_Column_ID > 0 ? AD_Column_ID : 0, getTrxName(ctx));
if (mColumn.getAD_Column_ID() == 0 && isOfficialId(element, "AD_Column_ID")) {
mColumn.setAD_Column_ID(getIntValue(element, "AD_Column_ID"));
}
@@ -87,6 +87,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
List notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
@@ -104,7 +105,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
// Setup Element.
if (mColumn.getAD_Element_ID() == 0) {
- X_AD_Element adElement = new X_AD_Element(ctx, 0, getTrxName(ctx));
+ X_AD_Element adElement = new X_AD_Element(ctx.ctx, 0, getTrxName(ctx));
adElement.setColumnName(mColumn.getColumnName());
adElement.setEntityType(mColumn.getEntityType());
adElement.setPrintName(mColumn.getColumnName());
@@ -164,11 +165,11 @@ public class ColumnElementHandler extends AbstractElementHandler {
} else {
logImportDetail(ctx, impDetail, 0, mColumn.getName(), mColumn
.get_ID(), action);
- throw new POSaveFailedException("Failed to import column.");
+ throw new POSaveFailedException("Failed to save column " + mColumn.getName());
}
if (recreateColumn || syncDatabase) {
- MTable table = new MTable(ctx, mColumn.getAD_Table_ID(), getTrxName(ctx));
+ MTable table = new MTable(ctx.ctx, mColumn.getAD_Table_ID(), getTrxName(ctx));
if (!table.isView() && !mColumn.isVirtualColumn()) {
success = createColumn(ctx, table, mColumn, recreateColumn);
@@ -199,7 +200,7 @@ public class ColumnElementHandler extends AbstractElementHandler {
* @param v_IsMandatory
*
*/
- private int createColumn(Properties ctx, MTable table, MColumn column, boolean doAlter) {
+ private int createColumn(PIPOContext ctx, MTable table, MColumn column, boolean doAlter) {
int no = 0;
@@ -297,23 +298,30 @@ public class ColumnElementHandler extends AbstractElementHandler {
return 1;
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- public void create(Properties ctx, TransformerHandler document)
+ public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int AD_Column_ID = Env.getContextAsInt(ctx,
+ int AD_Column_ID = Env.getContextAsInt(ctx.ctx,
X_AD_Column.COLUMNNAME_AD_Column_ID);
AttributesImpl atts = new AttributesImpl();
- X_AD_Column m_Column = new X_AD_Column(ctx, AD_Column_ID,
+ X_AD_Column m_Column = new X_AD_Column(ctx.ctx, AD_Column_ID,
getTrxName(ctx));
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (m_Column.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
+
addTypeName(atts, "table");
document.startElement("", "", I_AD_Column.Table_Name, atts);
createColumnBinding(ctx, document, m_Column);
document.endElement("", "", I_AD_Column.Table_Name);
}
- private void createColumnBinding(Properties ctx, TransformerHandler document,
+ private void createColumnBinding(PIPOContext ctx, TransformerHandler document,
X_AD_Column m_Column) {
PoExporter filler = new PoExporter(ctx, document, m_Column);
@@ -337,8 +345,8 @@ public class ColumnElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler,
TransformerHandler docHandler,
int recordId) throws Exception {
- Env.setContext(packout.getCtx(), I_AD_Column.COLUMNNAME_AD_Column_ID, recordId);
+ Env.setContext(packout.getCtx().ctx, I_AD_Column.COLUMNNAME_AD_Column_ID, recordId);
create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(I_AD_Column.COLUMNNAME_AD_Column_ID);
+ packout.getCtx().ctx.remove(I_AD_Column.COLUMNNAME_AD_Column_ID);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java
index 427b883ced..f7517799f2 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java
@@ -5,12 +5,12 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.exceptions.DBException;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.ElementHandler;
@@ -30,9 +30,9 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
private HashMap> cacheColumns = new HashMap>();//Key: table name. Value: set of PIPO columns
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
- if(! isHandleTranslations(ctx)){
+ if(! isHandleTranslations(ctx.ctx)){
return;//translation import option is disabled
}
@@ -64,7 +64,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
private boolean isRecordExists(String tableName, int parentID,
- String language, Properties ctx) {
+ String language, PIPOContext ctx) {
String sql =
"SELECT AD_Client_ID FROM " + tableName +" WHERE " +
@@ -79,7 +79,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
private void insertTranslation(String tableName, int parentID,
- Properties ctx, Element element) throws SAXException{
+ PIPOContext ctx, Element element) throws SAXException{
String parentTable = tableName.substring(0, tableName.length()-4);
ArrayList columns = getTranslatedColumns(parentTable);
@@ -133,7 +133,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
private void updateTranslation(String tableName, int parentID,
- Properties ctx, Element element) throws SAXException{
+ PIPOContext ctx, Element element) throws SAXException{
String parentTable = tableName.substring(0, tableName.length()-4);
ArrayList columns = getTranslatedColumns(parentTable);
StringBuffer buffer = new StringBuffer("UPDATE "+tableName+" SET ");
@@ -173,22 +173,22 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- public void create(Properties ctx, TransformerHandler document) throws SAXException {
+ public void create(PIPOContext ctx, TransformerHandler document) throws SAXException {
- String parenTableName = Env.getContext(ctx, CONTEXT_KEY_PARENT_TABLE);
+ String parenTableName = Env.getContext(ctx.ctx, CONTEXT_KEY_PARENT_TABLE);
- int parentRecordID = Env.getContextAsInt(ctx, CONTEXT_KEY_PARENT_RECORD_ID);
+ int parentRecordID = Env.getContextAsInt(ctx.ctx, CONTEXT_KEY_PARENT_RECORD_ID);
createTranslationTags(ctx, parenTableName, parentRecordID, document);
}
- private void createTranslationTags(Properties ctx, String parentTable,
+ private void createTranslationTags(PIPOContext ctx, String parentTable,
int parentRecordID, TransformerHandler document) throws SAXException {
ArrayList translatedColumns = getTranslatedColumns(parentTable);
@@ -221,7 +221,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
}
}
- private void exportRow(Properties ctx, TransformerHandler document, ArrayList columns,
+ private void exportRow(PIPOContext ctx, TransformerHandler document, ArrayList columns,
ResultSet rs) throws Exception {
PoExporter af = new PoExporter(ctx, document, null);
@@ -289,12 +289,12 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,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);
+ if("true".equals(packout.getCtx().ctx.getProperty("isHandleTranslations"))){
+ Env.setContext(packout.getCtx().ctx, CommonTranslationHandler.CONTEXT_KEY_PARENT_TABLE,X_AD_Element.Table_Name);
+ Env.setContext(packout.getCtx().ctx, CommonTranslationHandler.CONTEXT_KEY_PARENT_RECORD_ID,recordId);
this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(CommonTranslationHandler.CONTEXT_KEY_PARENT_TABLE);
- packout.getCtx().remove(CommonTranslationHandler.CONTEXT_KEY_PARENT_RECORD_ID);
+ packout.getCtx().ctx.remove(CommonTranslationHandler.CONTEXT_KEY_PARENT_TABLE);
+ packout.getCtx().ctx.remove(CommonTranslationHandler.CONTEXT_KEY_PARENT_RECORD_ID);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DistFileElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DistFileElementHandler.java
index 72c6110b8d..f3ea3b23b9 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DistFileElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DistFileElementHandler.java
@@ -22,12 +22,12 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
import org.adempiere.pipo2.Element;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PackOut;
import org.adempiere.pipo2.PackoutItem;
import org.compiere.Adempiere;
@@ -53,7 +53,7 @@ public class DistFileElementHandler extends AbstractElementHandler {
this.fileDest=fileDest;
}
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
String action = null;
String releaseNumber = getStringValue(element,"ReleaseNo");
@@ -72,7 +72,7 @@ public class DistFileElementHandler extends AbstractElementHandler {
//get adempiere-all directory
try {
- packagePath = getPackageDirectory(ctx);
+ packagePath = getPackageDirectory(ctx.ctx);
File parentDirectory = new File(packagePath);
while (!parentDirectory.getName().equals("packages")){
parentDirectory = parentDirectory.getParentFile();
@@ -165,25 +165,25 @@ public class DistFileElementHandler extends AbstractElementHandler {
}
}
//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));
+ X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx.ctx, 0, getTrxName(ctx));
+ backup.setAD_Org_ID(Env.getAD_Org_ID(ctx.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.setAD_Package_Imp_ID(getPackageImpId(ctx.ctx));
backup.saveEx();
}
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- public void create(Properties ctx, TransformerHandler document)
+ public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- String FileName = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
- String Source_Directory = Env.getContext(ctx, "Source_Directory");
- String Target_Directory = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
- String ReleaseNo = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
+ String FileName = Env.getContext(ctx.ctx, X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
+ String Source_Directory = Env.getContext(ctx.ctx, "Source_Directory");
+ String Target_Directory = Env.getContext(ctx.ctx, X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
+ String ReleaseNo = Env.getContext(ctx.ctx, X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
AttributesImpl atts = new AttributesImpl();
addTypeName(atts, "custom");
document.startElement("","","Dist_File",atts);
@@ -197,22 +197,20 @@ public class DistFileElementHandler extends AbstractElementHandler {
public void doPackout(PackOut packout, MPackageExp header, PackoutItem detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,AttributesImpl atts,int recordId) throws Exception
{
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, (String)detail.getProperty("FileName"));
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo, (String)detail.getProperty("ReleaseNo"));
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory, (String)detail.getProperty("TargetDirectory"));
- Env.setContext(packout.getCtx(), "Source_Directory", fileDest);
+ Env.setContext(packout.getCtx().ctx, X_AD_Package_Exp_Detail.COLUMNNAME_FileName, (String)detail.getProperty("FileName"));
+ Env.setContext(packout.getCtx().ctx, X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo, (String)detail.getProperty("ReleaseNo"));
+ Env.setContext(packout.getCtx().ctx, X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory, (String)detail.getProperty("TargetDirectory"));
+ Env.setContext(packout.getCtx().ctx, "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");
+ packout.getCtx().ctx.remove(X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
+ packout.getCtx().ctx.remove(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
+ packout.getCtx().ctx.remove(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
+ packout.getCtx().ctx.remove("Source_Directory");
}
@Override
public void packOut(PackOut packout, TransformerHandler packoutHandler,
TransformerHandler docHandler,
int recordId) throws Exception {
- // TODO Auto-generated method stub
-
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java
index 1e640e73a6..e87476484b 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java
@@ -18,11 +18,11 @@ package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
@@ -40,16 +40,16 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
private List rules = new ArrayList();
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
+ if (isProcessElement(ctx.ctx, entitytype)) {
String name = getStringValue(element, "Name");
X_AD_Val_Rule mValRule = findPO(ctx, element);
if (mValRule == null)
{
int id = findIdByColumn(ctx, "AD_Val_Rule", "Name", name);
- mValRule = new X_AD_Val_Rule(ctx, id > 0 ? id : 0, getTrxName(ctx));
+ mValRule = new X_AD_Val_Rule(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
}
if (mValRule.getAD_Val_Rule_ID() == 0 && isOfficialId(element, "AD_Val_Rule_ID"))
mValRule.setAD_Val_Rule_ID(getIntValue(element, "AD_Val_Rule_ID"));
@@ -60,6 +60,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
List notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
@@ -80,7 +81,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
}
else{
logImportDetail (ctx, impDetail, 0, mValRule.getName(), mValRule.get_ID(),action);
- throw new POSaveFailedException("Failed to save dynamic validation rule.");
+ throw new POSaveFailedException("Failed to save dynamic validation rule " + mValRule.getName());
}
}
} else {
@@ -89,16 +90,23 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- protected void create(Properties ctx, TransformerHandler document)
+ protected void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int AD_Val_Rule_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
+ int AD_Val_Rule_ID = Env.getContextAsInt(ctx.ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
if (rules.contains(AD_Val_Rule_ID))
return;
rules.add(AD_Val_Rule_ID);
- X_AD_Val_Rule m_ValRule = new X_AD_Val_Rule (ctx, AD_Val_Rule_ID, null);
+ X_AD_Val_Rule m_ValRule = new X_AD_Val_Rule (ctx.ctx, AD_Val_Rule_ID, null);
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (m_ValRule.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
+
AttributesImpl atts = new AttributesImpl();
addTypeName(atts, "table");
document.startElement("","",I_AD_Val_Rule.Table_Name, atts);
@@ -107,7 +115,7 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
}
- private void createDynamicValidationRuleBinding(Properties ctx, TransformerHandler document, X_AD_Val_Rule m_ValRule)
+ private void createDynamicValidationRuleBinding(PIPOContext ctx, TransformerHandler document, X_AD_Val_Rule m_ValRule)
{
PoExporter filler = new PoExporter(ctx, document, m_ValRule);
Listexcludes = defaultExcludeList(X_AD_Val_Rule.Table_Name);
@@ -122,9 +130,9 @@ public class DynValRuleElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
{
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID, recordId);
+ Env.setContext(packout.getCtx().ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID, recordId);
this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
+ packout.getCtx().ctx.remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java
index 6aa853c930..c4b29f82ba 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldElementHandler.java
@@ -17,12 +17,12 @@
package org.adempiere.pipo2.handler;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
import org.adempiere.pipo2.ElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
@@ -33,7 +33,6 @@ import org.compiere.model.I_AD_Field;
import org.compiere.model.I_AD_FieldGroup;
import org.compiere.model.I_AD_Reference;
import org.compiere.model.I_AD_Tab;
-import org.compiere.model.I_AD_Val_Rule;
import org.compiere.model.MField;
import org.compiere.model.X_AD_Field;
import org.compiere.model.X_AD_Package_Imp_Detail;
@@ -44,32 +43,47 @@ import org.xml.sax.helpers.AttributesImpl;
public class FieldElementHandler extends AbstractElementHandler {
- public void startElement(Properties ctx, Element element)
+ public void startElement(PIPOContext ctx, Element element)
throws SAXException {
String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
+ if (isProcessElement(ctx.ctx, entitytype)) {
if (isParentDefer(element, I_AD_Tab.Table_Name)) {
element.defer = true;
return;
}
Listexcludes = defaultExcludeList(X_AD_Field.Table_Name);
+ excludes.add("AD_Window_ID");
+ excludes.add("AD_Tab_ID");
int tabid = getParentId(element, I_AD_Tab.Table_Name) ;
+ if (tabid <= 0) {
+ Element tabElement = element.properties.get("AD_Tab_ID");
+ if (ReferenceUtils.isIDLookup(tabElement) || ReferenceUtils.isUUIDLookup(tabElement)) {
+ tabid = ReferenceUtils.resolveReference(ctx.ctx, tabElement, getTrxName(ctx));
+ } else {
+ String tabName = getStringValue(element, "AD_Tab_ID");
+ int AD_Window_ID = ReferenceUtils.resolveReference(ctx.ctx, element.properties.get("AD_Window_ID"), getTrxName(ctx));
+ if (AD_Window_ID > 0) {
+ tabid = findIdByNameAndParentId(ctx, "AD_Tab", tabName, "AD_Window", AD_Window_ID);
+ }
+ }
+ }
if (tabid <= 0) {
element.defer = true;
+ element.unresolved = "AD_Tab_ID";
return;
}
- MField mField = findPO(ctx, element);
- if (mField == null)
- {
- int AD_Table_ID = ReferenceUtils.resolveReference(ctx, element.parent.properties.get("AD_Table_ID"), getTrxName(ctx));
+ excludes.add("AD_Table_ID");
+ excludes.add("AD_Column_ID");
+
+ int AD_Table_ID = ReferenceUtils.resolveReference(ctx.ctx, element.properties.get("AD_Table_ID"), getTrxName(ctx));
Element columnElement = element.properties.get("AD_Column_ID");
int AD_Column_ID = 0;
if (ReferenceUtils.isIDLookup(columnElement) || ReferenceUtils.isUUIDLookup(columnElement))
{
- AD_Column_ID = ReferenceUtils.resolveReference(ctx, columnElement, getTrxName(ctx));
+ AD_Column_ID = ReferenceUtils.resolveReference(ctx.ctx, columnElement, getTrxName(ctx));
}
else
{
@@ -79,20 +93,32 @@ public class FieldElementHandler extends AbstractElementHandler {
if (AD_Column_ID == 0) {
element.defer = true;
+ element.unresolved = "AD_Column_ID";
return;
}
+ MField mField = findPO(ctx, element);
+ if (mField == null)
+ {
StringBuffer sqlB = new StringBuffer(
"select AD_Field_ID from AD_Field where AD_Column_ID = ")
.append(AD_Column_ID)
.append(" and AD_Tab_ID = ?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid);
- mField = new MField(ctx, id > 0 ? id : 0, getTrxName(ctx));
+ mField = new MField(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
if (mField.is_new()) {
mField.setAD_Column_ID(AD_Column_ID);
mField.setAD_Tab_ID(tabid);
}
+ } else {
+ if (mField.getAD_Tab_ID() != tabid) {
+ mField.setAD_Tab_ID(tabid);
}
+ if (mField.getAD_Column_ID() != AD_Column_ID) {
+ mField.setAD_Column_ID(AD_Column_ID);
+ }
+ }
+
PoFiller filler = new PoFiller(ctx, mField, element, this);
if (mField.getAD_Field_ID() == 0 && isOfficialId(element, "AD_Field_ID"))
{
@@ -102,6 +128,7 @@ public class FieldElementHandler extends AbstractElementHandler {
List notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
@@ -124,7 +151,7 @@ public class FieldElementHandler extends AbstractElementHandler {
} else {
logImportDetail(ctx, impDetail, 0, mField.getName(), mField
.get_ID(), action);
- throw new POSaveFailedException("Failed to save field definition.");
+ throw new POSaveFailedException("Failed to save field definition " + mField.getName());
}
}
} else {
@@ -132,20 +159,16 @@ public class FieldElementHandler extends AbstractElementHandler {
}
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- public void create(Properties ctx, TransformerHandler document)
+ public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int AD_Field_ID = Env.getContextAsInt(ctx,
+ int AD_Field_ID = Env.getContextAsInt(ctx.ctx,
X_AD_Field.COLUMNNAME_AD_Field_ID);
- X_AD_Field m_Field = new X_AD_Field(ctx, AD_Field_ID, null);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("", "", I_AD_Field.Table_Name, atts);
- createFieldBinding(ctx, document, m_Field);
+ X_AD_Field m_Field = new X_AD_Field(ctx.ctx, AD_Field_ID, null);
- PackOut packOut = (PackOut)ctx.get("PackOutProcess");
+ PackOut packOut = ctx.packOut;
try
{
@@ -160,28 +183,26 @@ public class FieldElementHandler extends AbstractElementHandler {
ElementHandler handler = packOut.getHandler(I_AD_Reference.Table_Name);
handler.packOut(packOut,document,null,m_Field.getAD_Reference_ID());
}
-
- if (m_Field.getAD_Reference_Value_ID()>0)
- {
- ElementHandler handler = packOut.getHandler(I_AD_Reference.Table_Name);
- handler.packOut(packOut,document,null,m_Field.getAD_Reference_Value_ID());
- }
-
- if (m_Field.getAD_Val_Rule_ID()>0)
- {
- ElementHandler handler = packOut.getHandler(I_AD_Val_Rule.Table_Name);
- handler.packOut(packOut,document,null,m_Field.getAD_Val_Rule_ID());
- }
}
catch(Exception e)
- {
- log.info(e.toString());
+ {
+ throw new SAXException(e);
+ }
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (m_Field.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
}
- document.endElement("", "", I_AD_Field.Table_Name);
+ AttributesImpl atts = new AttributesImpl();
+ addTypeName(atts, "table");
+ document.startElement("", "", X_AD_Field.Table_Name, atts);
+ createFieldBinding(ctx, document, m_Field);
+ document.endElement("", "", X_AD_Field.Table_Name);
}
- private void createFieldBinding(Properties ctx, TransformerHandler document,
+ private void createFieldBinding(PIPOContext ctx, TransformerHandler document,
X_AD_Field m_Field) {
List excludes = defaultExcludeList(X_AD_Field.Table_Name);
@@ -190,6 +211,20 @@ public class FieldElementHandler extends AbstractElementHandler {
filler.add("AD_Field_ID", new AttributesImpl());
}
+ int AD_Table_ID = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Table_ID FROM AD_Column WHERE AD_Column_ID=?", m_Field.getAD_Column_ID());
+ if (AD_Table_ID > 0) {
+ AttributesImpl atts = new AttributesImpl();
+ filler.addTableReference("AD_Table_ID", "AD_Table", "TableName", AD_Table_ID, atts);
+ }
+
+ excludes.add("AD_Tab_ID");
+ AttributesImpl atts = new AttributesImpl();
+ filler.addTableReference("AD_Tab_ID", "AD_Tab", "Name", m_Field.getAD_Tab_ID(), atts);
+ if (atts.getValue("reference").equals("table")) {
+ int AD_Window_ID = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Window_ID FROM AD_Tab WHERE AD_Tab_ID=?", m_Field.getAD_Tab_ID());
+ filler.addTableReference("AD_Window_ID", "AD_Window", "Name", AD_Window_ID, new AttributesImpl());
+ }
+
filler.export(excludes);
}
@@ -197,8 +232,8 @@ public class FieldElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler,
TransformerHandler docHandler,
int recordId) throws Exception {
- Env.setContext(packout.getCtx(), I_AD_Field.COLUMNNAME_AD_Field_ID, recordId);
+ Env.setContext(packout.getCtx().ctx, I_AD_Field.COLUMNNAME_AD_Field_ID, recordId);
create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(I_AD_Field.COLUMNNAME_AD_Field_ID);
+ packout.getCtx().ctx.remove(I_AD_Field.COLUMNNAME_AD_Field_ID);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java
index b4080fb3a1..b05aa06bab 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java
@@ -19,11 +19,11 @@ package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
@@ -42,7 +42,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
private List processedFieldGroups = new ArrayList();
- public void startElement(Properties ctx, Element element)
+ public void startElement(PIPOContext ctx, Element element)
throws SAXException {
String elementValue = element.getElementValue();
String action = null;
@@ -52,13 +52,13 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
String entitytype = getStringValue(element, "EntityType");
String name = getStringValue(element, "Name");
- if (isProcessElement(ctx, entitytype)) {
+ if (isProcessElement(ctx.ctx, entitytype)) {
X_AD_FieldGroup fieldGroup = findPO(ctx, element);
if (fieldGroup == null)
{
int id = findIdByColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name);
- fieldGroup = new X_AD_FieldGroup(ctx, id > 0 ? id : 0, getTrxName(ctx));
+ fieldGroup = new X_AD_FieldGroup(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
}
PoFiller pf = new PoFiller(ctx, fieldGroup, element, this);
List excludes = defaultExcludeList(X_AD_FieldGroup.Table_Name);
@@ -75,6 +75,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
List notfounds = pf.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
@@ -99,7 +100,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
} else {
logImportDetail(ctx, impDetail, 0, fieldGroup.getName(),
fieldGroup.get_ID(), action);
- throw new POSaveFailedException("Reference");
+ throw new POSaveFailedException("Failed to save Field Group " + fieldGroup.getName());
}
}
} else {
@@ -107,14 +108,14 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
}
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- protected void create(Properties ctx, TransformerHandler document)
+ protected void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int fieldGroup_id = Env.getContextAsInt(ctx,
+ int fieldGroup_id = Env.getContextAsInt(ctx.ctx,
X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
if (processedFieldGroups.contains(fieldGroup_id))
@@ -122,7 +123,13 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
processedFieldGroups.add(fieldGroup_id);
- X_AD_FieldGroup fieldGroup = new X_AD_FieldGroup(ctx, fieldGroup_id, null);
+ X_AD_FieldGroup fieldGroup = new X_AD_FieldGroup(ctx.ctx, fieldGroup_id, null);
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (fieldGroup.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
AttributesImpl atts = new AttributesImpl();
addTypeName(atts, "table");
@@ -130,7 +137,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
createAdElementBinding(ctx, document, fieldGroup);
- PackOut packOut = (PackOut)ctx.get("PackOutProcess");
+ PackOut packOut = ctx.packOut;
try{
new CommonTranslationHandler().packOut(packOut,document,null,fieldGroup.get_ID());
@@ -143,7 +150,7 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
}
- private void createAdElementBinding(Properties ctx, TransformerHandler document,
+ private void createAdElementBinding(PIPOContext ctx, TransformerHandler document,
X_AD_FieldGroup fieldGroup) {
PoExporter filler = new PoExporter(ctx, document, fieldGroup);
@@ -157,9 +164,9 @@ public class FieldGroupElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
{
- Env.setContext(packout.getCtx(), X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID, recordId);
+ Env.setContext(packout.getCtx().ctx, X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID, recordId);
this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
+ packout.getCtx().ctx.remove(X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
}
}
\ No newline at end of file
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FileElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FileElementHandler.java
index 1a88609c43..0da89781b0 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FileElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FileElementHandler.java
@@ -1,7 +1,6 @@
package org.adempiere.pipo2.handler;
import java.io.File;
-import java.util.Properties;
import java.util.logging.Level;
import javax.xml.transform.sax.TransformerHandler;
@@ -10,6 +9,7 @@ import org.adempiere.exceptions.AdempiereException;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.ElementHandler;
import org.adempiere.pipo2.FileElementParameters;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PackOut;
import org.adempiere.pipo2.PackoutDocument;
import org.adempiere.pipo2.PackoutItem;
@@ -88,11 +88,11 @@ public class FileElementHandler implements ElementHandler {
}
@Override
- public void startElement(Properties ctx, Element element)
+ public void startElement(PIPOContext ctx, Element element)
throws SAXException {
}
@Override
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java
index 0a3f424eee..25f2a78be3 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java
@@ -17,11 +17,11 @@
package org.adempiere.pipo2.handler;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PackOut;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
@@ -40,7 +40,7 @@ import org.xml.sax.helpers.AttributesImpl;
public class FormAccessElementHandler extends AbstractElementHandler {
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
List excludes = defaultExcludeList(X_AD_Form_Access.Table_Name);
MFormAccess po = findPO(ctx, element);
@@ -49,28 +49,30 @@ public class FormAccessElementHandler extends AbstractElementHandler {
if (getParentId(element, I_AD_Role.Table_Name) > 0) {
AD_Role_ID = getParentId(element, I_AD_Role.Table_Name);
} else {
- AD_Role_ID = ReferenceUtils.resolveReference(ctx, element.properties.get("AD_Role_ID"), getTrxName(ctx));
+ AD_Role_ID = ReferenceUtils.resolveReference(ctx.ctx, element.properties.get("AD_Role_ID"), getTrxName(ctx));
}
if (AD_Role_ID <= 0)
{
element.defer = true;
+ element.unresolved = "AD_Role_ID";
return;
}
- int AD_Form_ID = ReferenceUtils.resolveReference(ctx, element.properties.get("AD_Form_ID"), getTrxName(ctx));
+ int AD_Form_ID = ReferenceUtils.resolveReference(ctx.ctx, element.properties.get("AD_Form_ID"), getTrxName(ctx));
if (AD_Form_ID <= 0)
{
element.defer = true;
+ element.unresolved = "AD_Form_ID";
return;
}
- Query query = new Query(ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
+ Query query = new Query(ctx.ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID})
.setClient_ID()
.first();
if (po == null)
{
- po = new MFormAccess(ctx, 0, null);
+ po = new MFormAccess(ctx.ctx, 0, getTrxName(ctx));
po.setAD_Form_ID(AD_Form_ID);
po.setAD_Role_ID(AD_Role_ID);
}
@@ -83,43 +85,51 @@ public class FormAccessElementHandler extends AbstractElementHandler {
List notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
po.saveEx();
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- public void create(Properties ctx, TransformerHandler document)
+ public void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int AD_Form_ID = Env.getContextAsInt(ctx, X_AD_Form.COLUMNNAME_AD_Form_ID);
- int AD_Role_ID = Env.getContextAsInt(ctx, X_AD_Role.COLUMNNAME_AD_Role_ID);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("", "", I_AD_Form_Access.Table_Name, atts);
- createFormAccessBinding(ctx, document, AD_Form_ID, AD_Role_ID);
- document.endElement("", "", I_AD_Form_Access.Table_Name);
+ int AD_Form_ID = Env.getContextAsInt(ctx.ctx, X_AD_Form.COLUMNNAME_AD_Form_ID);
+ int AD_Role_ID = Env.getContextAsInt(ctx.ctx, X_AD_Role.COLUMNNAME_AD_Role_ID);
+
+ MFormAccess po = null;
+ Query query = new Query(ctx.ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
+ po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID}).first();
+
+ if (po != null) {
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (po.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
+
+ AttributesImpl atts = new AttributesImpl();
+ addTypeName(atts, "table");
+ document.startElement("", "", I_AD_Form_Access.Table_Name, atts);
+ createFormAccessBinding(ctx, document, po);
+ document.endElement("", "", I_AD_Form_Access.Table_Name);
+ }
}
- private void createFormAccessBinding(Properties ctx, TransformerHandler document,
- int formId, int roleId) {
- MFormAccess po = null;
- Query query = new Query(ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
- po = query.setParameters(new Object[]{formId, roleId}).first();
- if (po != null) {
- PoExporter filler = new PoExporter(ctx, document, po);
- List excludes = defaultExcludeList(X_AD_Form_Access.Table_Name);
- filler.export(excludes);
- }
+ private void createFormAccessBinding(PIPOContext ctx, TransformerHandler document,
+ MFormAccess po) {
+ PoExporter filler = new PoExporter(ctx, document, po);
+ List excludes = defaultExcludeList(X_AD_Form_Access.Table_Name);
+ filler.export(excludes);
}
@Override
public void packOut(PackOut packout, TransformerHandler packoutHandler,
TransformerHandler docHandler,
int recordId) throws Exception {
- // TODO Auto-generated method stub
-
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java
index f838389294..a037691d60 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/FormElementHandler.java
@@ -19,11 +19,11 @@ package org.adempiere.pipo2.handler;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
import org.adempiere.pipo2.AbstractElementHandler;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
@@ -42,16 +42,16 @@ public class FormElementHandler extends AbstractElementHandler {
private List forms = new ArrayList();
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
List excludes = defaultExcludeList(X_AD_Form.Table_Name);
String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
+ if (isProcessElement(ctx.ctx, entitytype)) {
MForm mForm = findPO(ctx, element);
if (mForm == null) {
String name = getStringValue(element, "Name");
int id = findIdByName(ctx, "AD_Form", name);
- mForm = new MForm(ctx, id > 0 ? id : 0, getTrxName(ctx));
+ mForm = new MForm(ctx.ctx, id > 0 ? id : 0, getTrxName(ctx));
}
PoFiller filler = new PoFiller(ctx, mForm, element, this);
@@ -63,6 +63,7 @@ public class FormElementHandler extends AbstractElementHandler {
List notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
+ element.unresolved = notfounds.toString();
return;
}
@@ -83,7 +84,7 @@ public class FormElementHandler extends AbstractElementHandler {
}
else{
logImportDetail (ctx, impDetail, 0, mForm.getName(), mForm.get_ID(), action);
- throw new POSaveFailedException("Failed to save form definition");
+ throw new POSaveFailedException("Failed to save form definition " + mForm.getName());
}
}
} else {
@@ -91,16 +92,23 @@ public class FormElementHandler extends AbstractElementHandler {
}
}
- public void endElement(Properties ctx, Element element) throws SAXException {
+ public void endElement(PIPOContext ctx, Element element) throws SAXException {
}
- protected void create(Properties ctx, TransformerHandler document)
+ protected void create(PIPOContext ctx, TransformerHandler document)
throws SAXException {
- int AD_Form_ID = Env.getContextAsInt(ctx, "AD_Form_ID");
+ int AD_Form_ID = Env.getContextAsInt(ctx.ctx, "AD_Form_ID");
if (forms.contains(AD_Form_ID)) return;
forms.add(AD_Form_ID);
- X_AD_Form m_Form = new X_AD_Form (ctx, AD_Form_ID, null);
+ X_AD_Form m_Form = new X_AD_Form (ctx.ctx, AD_Form_ID, null);
+
+ if (ctx.packOut.getFromDate() != null) {
+ if (m_Form.getUpdated().compareTo(ctx.packOut.getFromDate()) < 0) {
+ return;
+ }
+ }
+
AttributesImpl atts = new AttributesImpl();
addTypeName(atts, "table");
document.startElement("","",I_AD_Form.Table_Name,atts);
@@ -108,7 +116,7 @@ public class FormElementHandler extends AbstractElementHandler {
document.endElement("","",I_AD_Form.Table_Name);
}
- private void createFormBinding(Properties ctx, TransformerHandler document, X_AD_Form m_Form)
+ private void createFormBinding(PIPOContext ctx, TransformerHandler document, X_AD_Form m_Form)
{
PoExporter filler = new PoExporter(ctx, document, m_Form);
List excludes = defaultExcludeList(X_AD_Form.Table_Name);
@@ -121,8 +129,8 @@ public class FormElementHandler extends AbstractElementHandler {
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
{
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID, recordId);
+ Env.setContext(packout.getCtx().ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID, recordId);
this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID);
+ packout.getCtx().ctx.remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID);
}
}
diff --git a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java
index 38db379171..1254469bf7 100644
--- a/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java
+++ b/org.adempiere.pipo.handlers/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java
@@ -21,7 +21,6 @@ import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import javax.xml.transform.sax.TransformerHandler;
@@ -29,11 +28,13 @@ import org.adempiere.exceptions.AdempiereException;
import org.adempiere.model.GenericPO;
import org.adempiere.pipo2.AbstractElementHandler;
import org.adempiere.pipo2.DataElementParameters;
+import org.adempiere.pipo2.PIPOContext;
import org.adempiere.pipo2.PackoutItem;
import org.adempiere.pipo2.PoExporter;
import org.adempiere.pipo2.Element;
import org.adempiere.pipo2.PackOut;
import org.adempiere.pipo2.PoFiller;
+import org.adempiere.pipo2.ReferenceUtils;
import org.compiere.model.MColumn;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
@@ -54,56 +55,112 @@ import org.xml.sax.helpers.AttributesImpl;
*/
public class GenericPOElementHandler extends AbstractElementHandler {
- public GenericPOElementHandler() {
+ private String tableName;
+
+ public GenericPOElementHandler(String tableName) {
+ this.tableName = tableName;
}
- public void startElement(Properties ctx, Element element) throws SAXException {
+ public void startElement(PIPOContext ctx, Element element) throws SAXException {
String tableName = element.getElementValue();
PO po = findPO(ctx, element);
if (po == null) {
- MTable table = MTable.get(ctx, tableName);
- POInfo info = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
- MColumn columns[] = table.getColumns(false);
- StringBuffer whereClause = new StringBuffer();
- List