Search in sources :

Example 51 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class ModelValidatorElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    final int AD_ModelValidator_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_ModelValidator_ID);
    if (validators.contains(AD_ModelValidator_ID))
        return;
    validators.add(AD_ModelValidator_ID);
    final X_AD_ModelValidator validator = new X_AD_ModelValidator(ctx, AD_ModelValidator_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createMessageBinding(atts, validator);
    document.startElement("", "", TAG_Name, atts);
    document.endElement("", "", TAG_Name);
}
Also used : X_AD_ModelValidator(org.compiere.model.X_AD_ModelValidator) AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 52 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class PreferenceElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Preference_ID = Env.getContextAsInt(ctx, X_AD_Preference.COLUMNNAME_AD_Preference_ID);
    X_AD_Preference m_Preference = new X_AD_Preference(ctx, AD_Preference_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createPreferenceBinding(atts, m_Preference);
    document.startElement("", "", "preference", atts);
    document.endElement("", "", "preference");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_Preference(org.compiere.model.X_AD_Preference)

Example 53 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class RoleElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int Role_id = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Role_ID);
    if (roles.contains(Role_id))
        return;
    roles.add(Role_id);
    X_AD_Role m_Role = new X_AD_Role(ctx, Role_id, null);
    AttributesImpl atts = new AttributesImpl();
    createRoleBinding(atts, m_Role);
    document.startElement("", "", "role", atts);
    // Process org access
    String sql = "SELECT * FROM AD_Role_OrgAccess WHERE AD_Role_ID= " + Role_id;
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createOrgAccess(ctx, document, rs.getInt("AD_Org_ID"), rs.getInt("AD_Role_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_Role_OrgAccess", e);
        throw new DatabaseAccessException("Failed to export organization role access.");
    }
    // Process user assignment access
    sql = "SELECT * FROM AD_User_Roles WHERE AD_Role_ID= " + Role_id;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createUserRole(ctx, document, rs.getInt("AD_User_ID"), rs.getInt("AD_Role_ID"), rs.getInt("AD_Org_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_User_Roles", e);
        throw new DatabaseAccessException("Failed to export user role assignment.");
    }
    // Process AD_Window_Access Values
    sql = "SELECT * FROM AD_Window_Access WHERE AD_Role_ID= " + Role_id;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createWindowAccess(ctx, document, rs.getInt("AD_Window_ID"), rs.getInt("AD_Role_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_Window_Access", e);
        throw new DatabaseAccessException("Failed to export window access.");
    }
    // Process AD_Process_Access Values
    sql = "SELECT * FROM AD_Process_Access WHERE AD_Role_ID= " + Role_id;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createProcessAccess(ctx, document, rs.getInt("AD_Process_ID"), rs.getInt("AD_Role_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_Process_Access", e);
        throw new DatabaseAccessException("Failed to export process access.");
    }
    // Process AD_Form_Access Values
    sql = "SELECT * FROM AD_Form_Access WHERE AD_Role_ID= " + Role_id;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createFormAccess(ctx, document, rs.getInt("AD_Form_ID"), rs.getInt("AD_Role_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_Form_Access", e);
        throw new DatabaseAccessException("Failed to export form access.");
    }
    // Process AD_Browse_Access
    String whereClause = I_AD_Browse_Access.COLUMNNAME_AD_Role_ID + "=?";
    List<X_AD_Browse_Access> browseaccess = new Query(ctx, I_AD_Browse_Access.Table_Name, whereClause, getTrxName(ctx)).setParameters(Role_id).list();
    for (X_AD_Browse_Access ba : browseaccess) {
        createBrowseAccess(ctx, document, ba.getAD_Browse_ID(), ba.getAD_Role_ID());
    }
    // Process AD_Workflow_Access Values
    sql = "SELECT * FROM AD_Workflow_Access WHERE AD_Role_ID= " + Role_id;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createWorkflowAccess(ctx, document, rs.getInt("AD_Workflow_ID"), rs.getInt("AD_Role_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_Workflow_Access", e);
        throw new DatabaseAccessException("Failed to export workflow access.");
    }
    // Process AD_Task_Access Values
    sql = "SELECT * FROM AD_Task_Access WHERE AD_Role_ID= " + Role_id;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createTaskAccess(ctx, document, rs.getInt("AD_Task_ID"), rs.getInt("AD_Role_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "AD_Task_Access", e);
        throw new DatabaseAccessException("Failed to export task access.");
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
    document.endElement("", "", "role");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) Query(org.compiere.model.Query) X_AD_Browse_Access(org.adempiere.model.X_AD_Browse_Access) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) X_AD_Role(org.compiere.model.X_AD_Role) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException)

Example 54 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class WorkflowNodeNextElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int ad_wf_nodenext_id = Env.getContextAsInt(ctx, X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID);
    X_AD_WF_NodeNext m_WF_NodeNext = new X_AD_WF_NodeNext(ctx, ad_wf_nodenext_id, null);
    AttributesImpl atts = new AttributesImpl();
    createWorkflowNodeNextBinding(atts, m_WF_NodeNext);
    document.startElement("", "", "workflowNodeNext", atts);
    document.endElement("", "", "workflowNodeNext");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_WF_NodeNext(org.compiere.model.X_AD_WF_NodeNext)

Example 55 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class WorkflowElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Workflow_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Workflow_ID);
    if (workflows.contains(AD_Workflow_ID))
        return;
    workflows.add(AD_Workflow_ID);
    String sql = "SELECT Name FROM AD_Workflow WHERE  AD_Workflow_ID= " + AD_Workflow_ID;
    int ad_wf_nodenext_id = 0;
    int ad_wf_nodenextcondition_id = 0;
    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_Workflow m_Workflow = new X_AD_Workflow(ctx, AD_Workflow_ID, null);
            createWorkflowBinding(atts, m_Workflow);
            document.startElement("", "", "workflow", atts);
            String sql1 = "SELECT AD_WF_Node_ID FROM AD_WF_Node WHERE AD_Workflow_ID = " + AD_Workflow_ID + " ORDER BY " + X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID;
            PreparedStatement pstmt1 = null;
            ResultSet rs1 = null;
            try {
                pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
                // Generated workflowNodeNext(s) and
                // workflowNodeNextCondition(s)
                rs1 = pstmt1.executeQuery();
                while (rs1.next()) {
                    int nodeId = rs1.getInt("AD_WF_Node_ID");
                    createNode(ctx, document, nodeId);
                    ad_wf_nodenext_id = 0;
                    String sqlnn = "SELECT AD_WF_NodeNext_ID FROM AD_WF_NodeNext WHERE AD_WF_Node_ID = ?" + " ORDER BY " + X_AD_WF_NodeNext.COLUMNNAME_AD_WF_NodeNext_ID;
                    PreparedStatement pstmtnn = null;
                    ResultSet rsnn = null;
                    try {
                        pstmtnn = DB.prepareStatement(sqlnn, getTrxName(ctx));
                        pstmtnn.setInt(1, nodeId);
                        rsnn = pstmtnn.executeQuery();
                        while (rsnn.next()) {
                            ad_wf_nodenext_id = rsnn.getInt("AD_WF_NodeNext_ID");
                            if (ad_wf_nodenext_id > 0) {
                                createNodeNext(ctx, document, ad_wf_nodenext_id);
                                ad_wf_nodenextcondition_id = 0;
                                String sqlnnc = "SELECT AD_WF_NextCondition_ID FROM AD_WF_NextCondition WHERE AD_WF_NodeNext_ID = ?" + " ORDER BY " + X_AD_WF_NextCondition.COLUMNNAME_AD_WF_NextCondition_ID;
                                PreparedStatement pstmtnnc = null;
                                ResultSet rsnnc = null;
                                try {
                                    pstmtnnc = DB.prepareStatement(sqlnnc, getTrxName(ctx));
                                    pstmtnnc.setInt(1, ad_wf_nodenext_id);
                                    rsnnc = pstmtnnc.executeQuery();
                                    while (rsnnc.next()) {
                                        ad_wf_nodenextcondition_id = rsnnc.getInt("AD_WF_NextCondition_ID");
                                        log.info("ad_wf_nodenextcondition_id: " + String.valueOf(ad_wf_nodenextcondition_id));
                                        if (ad_wf_nodenextcondition_id > 0) {
                                            createNodeNextCondition(ctx, document, ad_wf_nodenextcondition_id);
                                        }
                                    }
                                } finally {
                                    DB.close(rsnnc, pstmtnnc);
                                    rsnnc = null;
                                    pstmtnnc = null;
                                }
                            }
                        }
                    } finally {
                        DB.close(rsnn, pstmtnn);
                        rsnn = null;
                        pstmtnn = null;
                    }
                }
            } finally {
                DB.close(rs1, pstmt1);
                rs1 = null;
                pstmt1 = null;
                document.endElement("", "", "workflow");
            }
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "Workflow", e);
        if (e instanceof SAXException)
            throw (SAXException) e;
        else if (e instanceof SQLException)
            throw new DatabaseAccessException("Failed to export workflow.", e);
        else
            throw new RuntimeException("Failed to export workflow.", e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
}
Also used : X_AD_Workflow(org.compiere.model.X_AD_Workflow) AttributesImpl(org.xml.sax.helpers.AttributesImpl) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException)

Aggregations

AttributesImpl (org.xml.sax.helpers.AttributesImpl)310 SAXException (org.xml.sax.SAXException)53 Test (org.junit.Test)34 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)23 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)23 ContentHandler (org.xml.sax.ContentHandler)21 Attributes (org.xml.sax.Attributes)17 PreparedStatement (java.sql.PreparedStatement)16 ResultSet (java.sql.ResultSet)16 Map (java.util.Map)16 PackOut (org.adempiere.pipo.PackOut)16 IOException (java.io.IOException)15 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)12 Iterator (java.util.Iterator)11 TransformerHandler (javax.xml.transform.sax.TransformerHandler)11 StreamResult (javax.xml.transform.stream.StreamResult)11 Metadata (org.apache.tika.metadata.Metadata)11 File (java.io.File)9 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)9 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)9