Search in sources :

Example 1 with X_CM_TemplateTable

use of org.compiere.model.X_CM_TemplateTable in project adempiere by adempiere.

the class Generator method generateExternalTables.

private void generateExternalTables(Properties ctx, HttpServletRequest httpRequest) {
    HttpSession thisSession = httpRequest.getSession(false);
    WebInfo wi = null;
    if (thisSession != null)
        if (thisSession.getAttribute(WebInfo.NAME) != null)
            wi = (WebInfo) thisSession.getAttribute(WebInfo.NAME);
    int[] tableKeys = X_CM_TemplateTable.getAllIDs("CM_TemplateTable", "CM_Template_ID=" + thisRequest.getCM_Container().getCM_Template_ID(), "WebCM");
    if (tableKeys.length > 0) {
        xmlCode.append("<externalTables>\n");
        for (int i = 0; i < tableKeys.length; i++) {
            X_CM_TemplateTable thisTemplateTable = new X_CM_TemplateTable(ctx, tableKeys[i], "WebCM");
            try {
                StringBuffer tempXML = new StringBuffer();
                tempXML.append("<" + thisTemplateTable.getName() + ">\n");
                MTable table = MTable.get(ctx, thisTemplateTable.getAD_Table_ID());
                String trxName = null;
                int[] ids = PO.getAllIDs(table.getTableName(), replaceSessionElements(wi, thisTemplateTable.getWhereClause()), trxName);
                if (ids != null && ids.length > 0) {
                    for (int j = 0; j < ids.length; j++) {
                        PO po = null;
                        po = table.getPO(ids[j], null);
                        if (po != null) {
                            tempXML = po.get_xmlString(tempXML);
                        }
                    }
                }
                tempXML.append("\n</" + thisTemplateTable.getName() + ">\n");
                xmlCode.append(tempXML);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        xmlCode.append("\n</externalTables>\n");
    }
}
Also used : MTable(org.compiere.model.MTable) HttpSession(javax.servlet.http.HttpSession) WebInfo(org.compiere.util.WebInfo) SQLException(java.sql.SQLException) X_CM_TemplateTable(org.compiere.model.X_CM_TemplateTable) PO(org.compiere.model.PO)

Aggregations

SQLException (java.sql.SQLException)1 HttpSession (javax.servlet.http.HttpSession)1 MTable (org.compiere.model.MTable)1 PO (org.compiere.model.PO)1 X_CM_TemplateTable (org.compiere.model.X_CM_TemplateTable)1 WebInfo (org.compiere.util.WebInfo)1