FR [ 2847727 ] 2pack export all messages for a entity type functionality
https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2847727&group_id=176962
This commit is contained in:
parent
9bbc11be55
commit
f2324316b1
|
@ -85,6 +85,9 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
* <li>BF [ 1819315 ] PackOut: fix xml indentation not working
|
||||
* <li>BF [ 1819319 ] PackOut: use just active AD_Package_Exp_Detail lines
|
||||
* <li>--
|
||||
* <li>FR [ 2847727 ] 2pack export all messages for a entity type functionality
|
||||
* https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2847727&group_id=176962
|
||||
*/
|
||||
|
||||
public class PackOut extends SvrProcess
|
||||
|
@ -263,15 +266,20 @@ public class PackOut extends SvrProcess
|
|||
|
||||
packOutDocument.startElement("","","adempiereAD",atts);
|
||||
atts.clear();
|
||||
String sql = "SELECT * FROM AD_Package_Exp_Detail WHERE AD_Package_Exp_ID = "+p_PackOut_ID+" AND IsActive='Y' ORDER BY Line ASC";
|
||||
|
||||
final String sql = "SELECT * FROM AD_Package_Exp_Detail WHERE AD_Package_Exp_ID = "+p_PackOut_ID+" AND IsActive='Y' ORDER BY Line ASC";
|
||||
PreparedStatement pstmt = null;
|
||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||
|
||||
try {
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()){
|
||||
String Type = rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Type);
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
final String Type = rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Type);
|
||||
final int AD_EntityType_ID = rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID);
|
||||
Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID, AD_EntityType_ID);
|
||||
//
|
||||
log.info(rs.getString(X_AD_Package_Exp_Detail.COLUMNNAME_Line));
|
||||
if (Type.compareTo("M") == 0){
|
||||
createMenu(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Menu_ID), packOutDocument );
|
||||
|
@ -315,7 +323,7 @@ public class PackOut extends SvrProcess
|
|||
else if (Type.compareTo(X_AD_Package_Exp_Detail.TYPE_ModelValidator) == 0)
|
||||
createModelValidator(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_ModelValidator_ID), packOutDocument);
|
||||
else if (Type.compareTo(X_AD_Package_Exp_Detail.TYPE_EntityType) == 0)
|
||||
createEntityType(rs.getInt(X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID), packOutDocument);
|
||||
createEntityType(AD_EntityType_ID, packOutDocument);
|
||||
else if (Type.compareTo("C") == 0){
|
||||
log.log(Level.INFO,"In PackOut.java handling Code or Other 2pack module creation");
|
||||
|
||||
|
@ -389,20 +397,13 @@ public class PackOut extends SvrProcess
|
|||
packageDocument.endElement("","","filenotes");
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
//
|
||||
getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
pstmt = null;
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
atts.clear();
|
||||
//no longer use
|
||||
|
@ -821,9 +822,9 @@ public class PackOut extends SvrProcess
|
|||
*/
|
||||
public void createEntityType (int AD_EntityType_ID, TransformerHandler packOutDocument) throws Exception
|
||||
{
|
||||
Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID, AD_EntityType_ID);
|
||||
//Env.setContext(getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID, AD_EntityType_ID);
|
||||
entitytypeHandler.create(getCtx(), packOutDocument);
|
||||
getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID);
|
||||
//getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,16 +12,14 @@
|
|||
* 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
|
||||
* Contributor(s): Low Heng Sin hengsin@avantz.com
|
||||
* Teo Sarca, teo.sarca@gmail.com
|
||||
*****************************************************************************/
|
||||
package org.adempiere.pipo.handler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
|
@ -30,9 +28,9 @@ import org.adempiere.pipo.Element;
|
|||
import org.adempiere.pipo.PackOut;
|
||||
import org.adempiere.pipo.exception.POSaveFailedException;
|
||||
import org.compiere.model.MMessage;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_AD_Message;
|
||||
import org.compiere.model.X_AD_Package_Exp_Detail;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -86,40 +84,49 @@ public class MessageElementHandler extends AbstractElementHandler {
|
|||
public void endElement(Properties ctx, Element element) throws SAXException {
|
||||
}
|
||||
|
||||
public void create(Properties ctx, TransformerHandler document)
|
||||
throws SAXException {
|
||||
int AD_Message_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID);
|
||||
if (messages.contains(AD_Message_ID))
|
||||
return;
|
||||
messages.add(AD_Message_ID);
|
||||
String sql = "SELECT value FROM AD_Message WHERE AD_Message_ID= " + AD_Message_ID;
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
pstmt = DB.prepareStatement (sql, getTrxName(ctx));
|
||||
|
||||
try {
|
||||
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
X_AD_Message m_Message = new X_AD_Message (ctx, AD_Message_ID, null);
|
||||
createMessageBinding(atts,m_Message);
|
||||
document.startElement("","","message",atts);
|
||||
document.endElement("","","message");
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception e){
|
||||
log.log(Level.SEVERE,"getProcess", e);
|
||||
}
|
||||
finally
|
||||
public void create(Properties ctx, TransformerHandler document) throws SAXException
|
||||
{
|
||||
for (X_AD_Message message : getMessages(ctx))
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
if (messages.contains(message.getAD_Message_ID()))
|
||||
continue;
|
||||
messages.add(message.getAD_Message_ID());
|
||||
//
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
createMessageBinding(atts, message);
|
||||
document.startElement("","","message",atts);
|
||||
document.endElement("","","message");
|
||||
}
|
||||
}
|
||||
|
||||
private List<X_AD_Message> getMessages(Properties ctx)
|
||||
{
|
||||
int AD_Message_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Message_ID);
|
||||
int AD_EntityType_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_EntityType_ID);
|
||||
String whereClause;
|
||||
Object[] params;
|
||||
if (AD_Message_ID > 0)
|
||||
{
|
||||
whereClause = X_AD_Message.COLUMNNAME_AD_Message_ID+"=?";
|
||||
params = new Object[]{AD_Message_ID};
|
||||
}
|
||||
else if (AD_EntityType_ID > 0)
|
||||
{
|
||||
whereClause = " EXISTS (SELECT 1 FROM AD_EntityType et"
|
||||
+" WHERE et.AD_EntityType_ID=? AND et.EntityType=AD_Message.EntityType)";
|
||||
params = new Object[]{AD_EntityType_ID};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("AD_Message_ID and AD_EntityType_ID not found");
|
||||
}
|
||||
|
||||
List<X_AD_Message> list = new Query(ctx, X_AD_Message.Table_Name, whereClause, null)
|
||||
.setParameters(params)
|
||||
.setOrderBy(X_AD_Message.COLUMNNAME_AD_Message_ID)
|
||||
.list();
|
||||
return list;
|
||||
}
|
||||
|
||||
private AttributesImpl createMessageBinding( AttributesImpl atts, X_AD_Message m_Message)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue