IDEMPIERE-4279 Error on packout from the toolbar on certain windows (Table & Column, Window, Tab & Field) (#141)
This commit is contained in:
parent
6e2cf15fa9
commit
e1c064b968
|
@ -2,7 +2,6 @@ package org.adempiere.pipo2.handler;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -16,6 +15,7 @@ import org.adempiere.pipo2.ElementHandler;
|
||||||
import org.adempiere.pipo2.PIPOContext;
|
import org.adempiere.pipo2.PIPOContext;
|
||||||
import org.adempiere.pipo2.PackOut;
|
import org.adempiere.pipo2.PackOut;
|
||||||
import org.adempiere.pipo2.PoExporter;
|
import org.adempiere.pipo2.PoExporter;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLanguage;
|
import org.compiere.model.MLanguage;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -87,7 +87,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
|
||||||
PIPOContext ctx, Element element) throws SAXException{
|
PIPOContext ctx, Element element) throws SAXException{
|
||||||
|
|
||||||
String parentTable = tableName.substring(0, tableName.length()-4);
|
String parentTable = tableName.substring(0, tableName.length()-4);
|
||||||
ArrayList<String> columns = getTranslatedColumns(parentTable);
|
ArrayList<String> columns = getTranslatedColumns(ctx, parentTable);
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("INSERT INTO ")
|
sql.append("INSERT INTO ")
|
||||||
.append(tableName)
|
.append(tableName)
|
||||||
|
@ -140,7 +140,7 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
|
||||||
private void updateTranslation(String tableName, int parentID,
|
private void updateTranslation(String tableName, int parentID,
|
||||||
PIPOContext ctx, Element element) throws SAXException{
|
PIPOContext ctx, Element element) throws SAXException{
|
||||||
String parentTable = tableName.substring(0, tableName.length()-4);
|
String parentTable = tableName.substring(0, tableName.length()-4);
|
||||||
ArrayList<String> columns = getTranslatedColumns(parentTable);
|
ArrayList<String> columns = getTranslatedColumns(ctx, parentTable);
|
||||||
StringBuilder buffer = new StringBuilder("UPDATE "+tableName+" SET ");
|
StringBuilder buffer = new StringBuilder("UPDATE "+tableName+" SET ");
|
||||||
for (String columnName : columns) {
|
for (String columnName : columns) {
|
||||||
buffer.append(columnName).append("=?,");
|
buffer.append(columnName).append("=?,");
|
||||||
|
@ -196,17 +196,18 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
|
||||||
private void createTranslationTags(PIPOContext ctx, String parentTable,
|
private void createTranslationTags(PIPOContext ctx, String parentTable,
|
||||||
int parentRecordID, TransformerHandler document) throws SAXException {
|
int parentRecordID, TransformerHandler document) throws SAXException {
|
||||||
|
|
||||||
ArrayList<String> translatedColumns = getTranslatedColumns(parentTable);
|
ArrayList<String> translatedColumns = getTranslatedColumns(ctx, parentTable);
|
||||||
|
|
||||||
String sql =
|
String sql =
|
||||||
"select "+cast(translatedColumns)+" from "+parentTable+"_trl where "+
|
"SELECT "+cast(translatedColumns)+" FROM "+parentTable+"_Trl WHERE "+
|
||||||
parentTable+"_ID="+parentRecordID;
|
parentTable+"_ID=?";
|
||||||
|
|
||||||
PreparedStatement pstm = null;
|
PreparedStatement pstm = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
pstm = DB.prepareStatement(sql, null);
|
pstm = DB.prepareStatement(sql, getTrxName(ctx));
|
||||||
|
pstm.setInt(1, parentRecordID);
|
||||||
rs = pstm.executeQuery();
|
rs = pstm.executeQuery();
|
||||||
|
|
||||||
String elementName = parentTable + "_Trl";
|
String elementName = parentTable + "_Trl";
|
||||||
|
@ -243,11 +244,12 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
* @param ctx
|
||||||
* @param parentTable
|
* @param parentTable
|
||||||
* @return
|
* @return
|
||||||
* @throws SAXException
|
* @throws SAXException
|
||||||
*/
|
*/
|
||||||
private ArrayList<String> getTranslatedColumns(String parentTable) throws SAXException {
|
private ArrayList<String> getTranslatedColumns(PIPOContext ctx, String parentTable) throws SAXException {
|
||||||
|
|
||||||
|
|
||||||
ArrayList<String> pipolColumns = cacheColumns.get(parentTable);
|
ArrayList<String> pipolColumns = cacheColumns.get(parentTable);
|
||||||
|
@ -256,25 +258,12 @@ public class CommonTranslationHandler extends AbstractElementHandler implements
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> columns = new ArrayList<String>();
|
ArrayList<String> columns = new ArrayList<String>();
|
||||||
String sql = "select * from ad_column where ad_table_id = " +
|
MTable table = MTable.get(ctx.ctx, parentTable);
|
||||||
"(select ad_table_id from ad_table where tableName = ?)" +
|
MColumn[] cols = table.getColumns(false);
|
||||||
"and isTranslated='Y'";
|
for (MColumn col : cols) {
|
||||||
|
if (col.isTranslated()) {
|
||||||
PreparedStatement pstm = null;
|
columns.add(col.getColumnName());
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
|
||||||
pstm = DB.prepareStatement(sql, null);
|
|
||||||
pstm.setString(1, parentTable);
|
|
||||||
|
|
||||||
rs = pstm.executeQuery();
|
|
||||||
while(rs.next()){
|
|
||||||
columns.add(rs.getString("columnName"));
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new SAXException();
|
|
||||||
} finally {
|
|
||||||
DB.close(rs, pstm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
columns.add("AD_Language");
|
columns.add("AD_Language");
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.pipo2.handler;
|
package org.adempiere.pipo2.handler;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -31,7 +28,6 @@ import org.adempiere.pipo2.PIPOContext;
|
||||||
import org.adempiere.pipo2.PackOut;
|
import org.adempiere.pipo2.PackOut;
|
||||||
import org.adempiere.pipo2.PoExporter;
|
import org.adempiere.pipo2.PoExporter;
|
||||||
import org.adempiere.pipo2.PoFiller;
|
import org.adempiere.pipo2.PoFiller;
|
||||||
import org.adempiere.pipo2.exception.DatabaseAccessException;
|
|
||||||
import org.adempiere.pipo2.exception.POSaveFailedException;
|
import org.adempiere.pipo2.exception.POSaveFailedException;
|
||||||
import org.compiere.model.I_AD_Reference;
|
import org.compiere.model.I_AD_Reference;
|
||||||
import org.compiere.model.MReference;
|
import org.compiere.model.MReference;
|
||||||
|
@ -112,7 +108,7 @@ public class ReferenceElementHandler extends AbstractElementHandler {
|
||||||
|
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
|
||||||
MReference m_Reference = new MReference(ctx.ctx, Reference_id, getTrxName(ctx));
|
MReference m_Reference = MReference.get(ctx.ctx, Reference_id);
|
||||||
|
|
||||||
boolean createElement = isPackOutElement(ctx, m_Reference);
|
boolean createElement = isPackOutElement(ctx, m_Reference);
|
||||||
|
|
||||||
|
@ -130,36 +126,13 @@ public class ReferenceElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Reference.getValidationType().compareTo("L") == 0) {
|
if (MReference.VALIDATIONTYPE_ListValidation.equals(m_Reference.getValidationType())) {
|
||||||
String sql1 = "SELECT AD_REF_LIST_ID FROM AD_Ref_List WHERE AD_Reference_ID= "
|
int[] rls = DB.getIDsEx(getTrxName(ctx), "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=?", Reference_id);
|
||||||
+ Reference_id;
|
for (int rl : rls) {
|
||||||
|
createReferenceList(ctx, document, rl);
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
pstmt = DB.prepareStatement(sql1, getTrxName(ctx));
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
createReferenceList(ctx, document, rs.getInt("AD_REF_LIST_ID"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
|
||||||
if (e instanceof SAXException)
|
|
||||||
throw (SAXException) e;
|
|
||||||
else if (e instanceof SQLException)
|
|
||||||
throw new DatabaseAccessException("Failed to export Reference.", e);
|
|
||||||
else if (e instanceof RuntimeException)
|
|
||||||
throw (RuntimeException) e;
|
|
||||||
else
|
|
||||||
throw new RuntimeException("Failed to export Reference.", e);
|
|
||||||
} finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (m_Reference.getValidationType().compareTo("T") == 0) {
|
} else if (MReference.VALIDATIONTYPE_TableValidation.equals(m_Reference.getValidationType())) {
|
||||||
createReferenceTable(ctx, document, Reference_id);
|
createReferenceTable(ctx, document, Reference_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.pipo2.handler;
|
package org.adempiere.pipo2.handler;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -32,10 +30,10 @@ import org.adempiere.pipo2.PoFiller;
|
||||||
import org.adempiere.pipo2.ReferenceUtils;
|
import org.adempiere.pipo2.ReferenceUtils;
|
||||||
import org.adempiere.pipo2.exception.DatabaseAccessException;
|
import org.adempiere.pipo2.exception.DatabaseAccessException;
|
||||||
import org.compiere.model.I_AD_Ref_Table;
|
import org.compiere.model.I_AD_Ref_Table;
|
||||||
|
import org.compiere.model.MRefTable;
|
||||||
import org.compiere.model.MReference;
|
import org.compiere.model.MReference;
|
||||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||||
import org.compiere.model.X_AD_Ref_Table;
|
import org.compiere.model.X_AD_Ref_Table;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
@ -102,16 +100,8 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
|
||||||
private void createReferenceTableBinding(PIPOContext ctx,
|
private void createReferenceTableBinding(PIPOContext ctx,
|
||||||
TransformerHandler document, int reference_ID) {
|
TransformerHandler document, int reference_ID) {
|
||||||
|
|
||||||
String sql = "SELECT * FROM AD_Ref_Table WHERE AD_Reference_ID= "
|
|
||||||
+ reference_ID;
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
MRefTable refTable = MRefTable.get(ctx.ctx, reference_ID);
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
if (rs.next()) {
|
|
||||||
X_AD_Ref_Table refTable = new X_AD_Ref_Table(ctx.ctx, rs, getTrxName(ctx));
|
|
||||||
if (!isPackOutElement(ctx, refTable))
|
if (!isPackOutElement(ctx, refTable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -136,13 +126,11 @@ public class ReferenceTableElementHandler extends AbstractElementHandler {
|
||||||
filler.addTableReference("AD_Key", "AD_Column", new AttributesImpl());
|
filler.addTableReference("AD_Key", "AD_Column", new AttributesImpl());
|
||||||
|
|
||||||
document.endElement("", "", X_AD_Ref_Table.Table_Name);
|
document.endElement("", "", X_AD_Ref_Table.Table_Name);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||||
throw new DatabaseAccessException("Failed to export Reference Table", e);
|
throw new DatabaseAccessException("Failed to export Reference Table", e);
|
||||||
} finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.pipo2.handler;
|
package org.adempiere.pipo2.handler;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -36,16 +34,17 @@ import org.adempiere.pipo2.PoFiller;
|
||||||
import org.adempiere.pipo2.exception.DatabaseAccessException;
|
import org.adempiere.pipo2.exception.DatabaseAccessException;
|
||||||
import org.adempiere.pipo2.exception.POSaveFailedException;
|
import org.adempiere.pipo2.exception.POSaveFailedException;
|
||||||
import org.compiere.model.I_AD_Table;
|
import org.compiere.model.I_AD_Table;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MSysConfig;
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.MTableIndex;
|
import org.compiere.model.MTableIndex;
|
||||||
import org.compiere.model.MViewComponent;
|
import org.compiere.model.MViewComponent;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.model.X_AD_Column;
|
import org.compiere.model.X_AD_Column;
|
||||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||||
import org.compiere.model.X_AD_Table;
|
import org.compiere.model.X_AD_Table;
|
||||||
import org.compiere.process.DatabaseViewValidate;
|
import org.compiere.process.DatabaseViewValidate;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Trx;
|
import org.compiere.util.Trx;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -165,85 +164,67 @@ public class TableElementHandler extends AbstractElementHandler {
|
||||||
createTableBinding(ctx,document,m_Table);
|
createTableBinding(ctx,document,m_Table);
|
||||||
}
|
}
|
||||||
|
|
||||||
String sql = "SELECT * FROM AD_Column WHERE AD_Table_ID = ? "
|
|
||||||
+ " ORDER BY IsKey DESC, AD_Column_ID"; // Export key column as the first one
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement (sql, getTrxName(ctx));
|
List<MColumn> cols = new Query(ctx.ctx, MColumn.Table_Name, "AD_Table_ID=?", getTrxName(ctx))
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
.setParameters(AD_Table_ID)
|
||||||
rs = pstmt.executeQuery();
|
.setOrderBy("IsKey DESC, AD_Column_ID") // Export key column as the first one
|
||||||
|
.list();
|
||||||
while (rs.next()){
|
for (MColumn col : cols) {
|
||||||
ElementHandler handler = packOut.getHandler("AD_Element");
|
ElementHandler handler = packOut.getHandler("AD_Element");
|
||||||
handler.packOut(packOut,document,null,rs.getInt(X_AD_Column.COLUMNNAME_AD_Element_ID));
|
handler.packOut(packOut,document,null,col.getAD_Element_ID());
|
||||||
|
|
||||||
if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID)>0)
|
if (col.getAD_Reference_ID()>0)
|
||||||
{
|
{
|
||||||
handler = packOut.getHandler("AD_Reference");
|
handler = packOut.getHandler("AD_Reference");
|
||||||
handler.packOut(packOut,document,null,rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Reference_ID));
|
handler.packOut(packOut,document,null,col.getAD_Reference_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs.getInt("AD_Reference_Value_ID")>0)
|
if (col.getAD_Reference_Value_ID()>0)
|
||||||
{
|
{
|
||||||
handler = packOut.getHandler("AD_Reference");
|
handler = packOut.getHandler("AD_Reference");
|
||||||
handler.packOut(packOut,document,null,rs.getInt("AD_Reference_Value_ID"));
|
handler.packOut(packOut,document,null,col.getAD_Reference_Value_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID)>0)
|
if (col.getAD_Process_ID()>0)
|
||||||
{
|
{
|
||||||
handler = packOut.getHandler("AD_Process");
|
handler = packOut.getHandler("AD_Process");
|
||||||
handler.packOut(packOut,document,null,rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Process_ID));
|
handler.packOut(packOut,document,null,col.getAD_Process_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID)>0)
|
if (col.getAD_Val_Rule_ID()>0)
|
||||||
{
|
{
|
||||||
handler = packOut.getHandler("AD_Val_Rule");
|
handler = packOut.getHandler("AD_Val_Rule");
|
||||||
handler.packOut(packOut,document,null,rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID));
|
handler.packOut(packOut,document,null,col.getAD_Val_Rule_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
createColumn(ctx, document, rs.getInt("AD_Column_ID"));
|
createColumn(ctx, document, col.getAD_Column_ID());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AdempiereException(e);
|
throw new AdempiereException(e);
|
||||||
} finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "SELECT * FROM AD_TableIndex WHERE AD_Table_ID = ? ORDER BY AD_TableIndex_ID";
|
|
||||||
pstmt = null;
|
|
||||||
rs = null;
|
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement (sql, getTrxName(ctx));
|
List<MTableIndex> tis = new Query(ctx.ctx, MTableIndex.Table_Name, "AD_Table_ID=?", getTrxName(ctx))
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
.setParameters(AD_Table_ID)
|
||||||
rs = pstmt.executeQuery();
|
.setOrderBy("AD_TableIndex_ID")
|
||||||
|
.list();
|
||||||
while (rs.next()) {
|
for (MTableIndex ti : tis) {
|
||||||
createTableIndex(ctx, document, rs.getInt(MTableIndex.COLUMNNAME_AD_TableIndex_ID));
|
createTableIndex(ctx, document, ti.getAD_TableIndex_ID());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AdempiereException(e);
|
throw new AdempiereException(e);
|
||||||
} finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "SELECT * FROM AD_ViewComponent WHERE AD_Table_ID = ? ORDER BY SeqNo, AD_ViewComponent_ID";
|
|
||||||
pstmt = null;
|
|
||||||
rs = null;
|
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement (sql, getTrxName(ctx));
|
List<MViewComponent> vcs = new Query(ctx.ctx, MViewComponent.Table_Name, "AD_Table_ID=?", getTrxName(ctx))
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
.setParameters(AD_Table_ID)
|
||||||
rs = pstmt.executeQuery();
|
.setOrderBy("SeqNo, AD_ViewComponent_ID")
|
||||||
|
.list();
|
||||||
while (rs.next()) {
|
for (MViewComponent vc : vcs) {
|
||||||
createViewComponent(ctx, document, rs.getInt(MViewComponent.COLUMNNAME_AD_ViewComponent_ID));
|
createViewComponent(ctx, document, vc.getAD_ViewComponent_ID());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AdempiereException(e);
|
throw new AdempiereException(e);
|
||||||
} finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createElement) {
|
if (createElement) {
|
||||||
|
|
|
@ -16,31 +16,32 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.pipo2.handler;
|
package org.adempiere.pipo2.handler;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.xml.transform.sax.TransformerHandler;
|
import javax.xml.transform.sax.TransformerHandler;
|
||||||
|
|
||||||
import org.adempiere.exceptions.DBException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.pipo2.AbstractElementHandler;
|
import org.adempiere.pipo2.AbstractElementHandler;
|
||||||
import org.adempiere.pipo2.PIPOContext;
|
|
||||||
import org.adempiere.pipo2.PoExporter;
|
|
||||||
import org.adempiere.pipo2.Element;
|
import org.adempiere.pipo2.Element;
|
||||||
|
import org.adempiere.pipo2.PIPOContext;
|
||||||
import org.adempiere.pipo2.PackOut;
|
import org.adempiere.pipo2.PackOut;
|
||||||
|
import org.adempiere.pipo2.PoExporter;
|
||||||
import org.adempiere.pipo2.PoFiller;
|
import org.adempiere.pipo2.PoFiller;
|
||||||
import org.adempiere.pipo2.exception.POSaveFailedException;
|
import org.adempiere.pipo2.exception.POSaveFailedException;
|
||||||
import org.compiere.model.I_AD_Workflow;
|
import org.compiere.model.I_AD_Workflow;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||||
import org.compiere.model.X_AD_WF_NextCondition;
|
import org.compiere.model.X_AD_WF_NextCondition;
|
||||||
import org.compiere.model.X_AD_WF_Node;
|
import org.compiere.model.X_AD_WF_Node;
|
||||||
import org.compiere.model.X_AD_WF_NodeNext;
|
import org.compiere.model.X_AD_WF_NodeNext;
|
||||||
import org.compiere.model.X_AD_Workflow;
|
import org.compiere.model.X_AD_Workflow;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.wf.MWFNextCondition;
|
||||||
|
import org.compiere.wf.MWFNode;
|
||||||
|
import org.compiere.wf.MWFNodeNext;
|
||||||
import org.compiere.wf.MWorkflow;
|
import org.compiere.wf.MWorkflow;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
@ -150,17 +151,14 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
||||||
if (ctx.packOut.isExported(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID+"|"+AD_Workflow_ID))
|
if (ctx.packOut.isExported(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID+"|"+AD_Workflow_ID))
|
||||||
return;
|
return;
|
||||||
PackOut packOut = ctx.packOut;
|
PackOut packOut = ctx.packOut;
|
||||||
int ad_wf_nodenext_id = 0;
|
|
||||||
int ad_wf_nodenextcondition_id = 0;
|
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
|
||||||
MWorkflow m_Workflow = new MWorkflow(ctx.ctx,
|
MWorkflow m_Workflow = MWorkflow.get(ctx.ctx, AD_Workflow_ID);
|
||||||
AD_Workflow_ID, null);
|
|
||||||
boolean createElement = isPackOutElement(ctx, m_Workflow);
|
boolean createElement = isPackOutElement(ctx, m_Workflow);
|
||||||
if (createElement) {
|
if (createElement) {
|
||||||
atts.addAttribute("", "", "type", "CDATA", "object");
|
atts.addAttribute("", "", "type", "CDATA", "object");
|
||||||
atts.addAttribute("", "", "type-name", "CDATA", "ad.workflow");
|
atts.addAttribute("", "", "type-name", "CDATA", "ad.workflow");
|
||||||
document.startElement("", "", I_AD_Workflow.Table_Name, atts);
|
document.startElement("", "", MWorkflow.Table_Name, atts);
|
||||||
createWorkflowBinding(ctx, document, m_Workflow);
|
createWorkflowBinding(ctx, document, m_Workflow);
|
||||||
|
|
||||||
packOut.getCtx().ctx.put("Table_Name",I_AD_Workflow.Table_Name);
|
packOut.getCtx().ctx.put("Table_Name",I_AD_Workflow.Table_Name);
|
||||||
|
@ -171,54 +169,40 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String sql = "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID=? AND AD_Client_ID=?";
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
PreparedStatement psNodeNext = null;
|
|
||||||
PreparedStatement psNCondition = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
ResultSet nodeNextrs = null;
|
|
||||||
ResultSet nodeNConditionrs = null;
|
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sql, getTrxName(ctx));
|
List<MWFNode> wns = new Query(ctx.ctx, MWFNode.Table_Name, "AD_Workflow_ID=? AND AD_Client_ID=?", getTrxName(ctx))
|
||||||
pstmt.setInt(1, AD_Workflow_ID);
|
.setParameters(AD_Workflow_ID, Env.getAD_Client_ID(ctx.ctx))
|
||||||
pstmt.setInt(2, Env.getAD_Client_ID(ctx.ctx));
|
.list();
|
||||||
// Generated workflowNodeNext(s) and
|
for (MWFNode wn : wns) {
|
||||||
// workflowNodeNextCondition(s)
|
int nodeId = wn.getAD_WF_Node_ID();
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
while (rs.next()) {
|
|
||||||
int nodeId = rs.getInt("AD_WF_Node_ID");
|
|
||||||
createNode(ctx, document, nodeId);
|
createNode(ctx, document, nodeId);
|
||||||
sql = "SELECT ad_wf_nodenext_id from ad_wf_nodenext WHERE ad_wf_node_id=? AND AD_Client_ID=?";
|
|
||||||
psNodeNext = DB.prepareStatement(sql, getTrxName(ctx));
|
List<MWFNodeNext> wnns = new Query(ctx.ctx, MWFNodeNext.Table_Name, "AD_WF_Node_ID=? AND AD_Client_ID=?", getTrxName(ctx))
|
||||||
psNodeNext.setInt(1, nodeId);
|
.setParameters(nodeId, Env.getAD_Client_ID(ctx.ctx))
|
||||||
psNodeNext.setInt(2, Env.getAD_Client_ID(ctx.ctx));
|
.list();
|
||||||
nodeNextrs = psNodeNext.executeQuery();
|
for (MWFNodeNext wnn : wnns) {
|
||||||
while (nodeNextrs.next()){
|
int ad_wf_nodenext_id = wnn.getAD_WF_NodeNext_ID();
|
||||||
ad_wf_nodenext_id = nodeNextrs.getInt("AD_WF_NodeNext_ID");
|
|
||||||
createNodeNext(ctx, document, ad_wf_nodenext_id);
|
createNodeNext(ctx, document, ad_wf_nodenext_id);
|
||||||
sql = "SELECT ad_wf_nextcondition_id from ad_wf_nextcondition WHERE ad_wf_nodenext_id=? AND AD_Client_ID=?";
|
|
||||||
psNCondition = DB.prepareStatement(sql, getTrxName(ctx));
|
List<MWFNextCondition> wncs = new Query(ctx.ctx, MWFNextCondition.Table_Name, "AD_WF_NodeNext_ID=? AND AD_Client_ID=?", getTrxName(ctx))
|
||||||
psNCondition.setInt(1, ad_wf_nodenext_id);
|
.setParameters(ad_wf_nodenext_id, Env.getAD_Client_ID(ctx.ctx))
|
||||||
psNCondition.setInt(2, Env.getAD_Client_ID(ctx.ctx));
|
.list();
|
||||||
nodeNConditionrs = psNCondition.executeQuery();
|
for (MWFNextCondition wnc : wncs) {
|
||||||
while (nodeNConditionrs.next()) {
|
int ad_wf_nodenextcondition_id = wnc.getAD_WF_NextCondition_ID();
|
||||||
ad_wf_nodenextcondition_id= nodeNConditionrs.getInt("AD_WF_NextCondition_ID");
|
|
||||||
if (log.isLoggable(Level.INFO)) log.info("ad_wf_nodenextcondition_id: "+ String.valueOf(ad_wf_nodenextcondition_id));
|
if (log.isLoggable(Level.INFO)) log.info("ad_wf_nodenextcondition_id: "+ String.valueOf(ad_wf_nodenextcondition_id));
|
||||||
createNodeNextCondition(ctx, document, ad_wf_nodenextcondition_id);
|
createNodeNextCondition(ctx, document, ad_wf_nodenextcondition_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DBException(e);
|
throw new AdempiereException(e);
|
||||||
} finally {
|
}
|
||||||
DB.close(rs, pstmt);
|
|
||||||
DB.close(nodeNextrs, psNodeNext);
|
|
||||||
DB.close(nodeNConditionrs,psNCondition);
|
|
||||||
if (createElement) {
|
if (createElement) {
|
||||||
document.endElement("", "", MWorkflow.Table_Name);
|
document.endElement("", "", MWorkflow.Table_Name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNodeNextCondition(PIPOContext ctx,
|
private void createNodeNextCondition(PIPOContext ctx,
|
||||||
|
|
Loading…
Reference in New Issue