Search in sources :

Example 1 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class WindowElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Window_ID = Env.getContextAsInt(ctx, "AD_Window_ID");
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    X_AD_Window m_Window = new X_AD_Window(ctx, AD_Window_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createWindowBinding(atts, m_Window);
    document.startElement("", "", "window", atts);
    // Tab Tag
    String sql = "SELECT * FROM AD_TAB WHERE AD_WINDOW_ID = " + AD_Window_ID + " ORDER BY " + X_AD_Tab.COLUMNNAME_SeqNo + "," + X_AD_Tab.COLUMNNAME_AD_Tab_ID;
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            packOut.createTable(rs.getInt("AD_Table_ID"), document);
            createTab(ctx, document, rs.getInt("AD_Tab_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } 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 window.", e);
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException("Failed to export window.", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
    //TODO: export of ad_image and ad_color use
    // Loop tags.
    document.endElement("", "", "window");
    // Preference Tag
    sql = "SELECT * FROM AD_PREFERENCE WHERE AD_WINDOW_ID = " + AD_Window_ID + " ORDER BY " + X_AD_Preference.COLUMNNAME_AD_Preference_ID;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createPreference(ctx, document, rs.getInt("AD_Preference_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } 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 window preference.", e);
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException("Failed to export window preference.", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) SQLException(java.sql.SQLException) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) X_AD_Window(org.compiere.model.X_AD_Window) PreparedStatement(java.sql.PreparedStatement) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SQLException(java.sql.SQLException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException)

Example 2 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class ViewDefinitionElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    int AD_View_Definition_ID = Env.getContextAsInt(ctx, X_AD_View_Definition.COLUMNNAME_AD_View_Definition_ID);
    MViewDefinition m_View_Definition = new MViewDefinition(ctx, AD_View_Definition_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createViewDefinitionBinding(atts, m_View_Definition);
    document.startElement("", "", "viewdefinition", atts);
    // View Columns tags.
    StringBuilder whereClause = new StringBuilder(I_AD_View_Definition.COLUMNNAME_AD_View_Definition_ID).append("=?");
    List<MViewColumn> viewColumns = new Query(ctx, I_AD_View_Column.Table_Name, whereClause.toString(), getTrxName(ctx)).setParameters(m_View_Definition.get_ID()).list();
    for (MViewColumn vc : viewColumns) {
        createViewColumn(ctx, document, vc.getAD_View_Column_ID());
    }
    document.endElement("", "", "viewdefinition");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) Query(org.compiere.model.Query) PackOut(org.adempiere.pipo.PackOut) MViewDefinition(org.adempiere.model.MViewDefinition) MViewColumn(org.adempiere.model.MViewColumn)

Example 3 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class BrowseFieldElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Browse_Field_ID = Env.getContextAsInt(ctx, X_AD_Browse_Field.COLUMNNAME_AD_Browse_Field_ID);
    MBrowseField m_BrowseField = new MBrowseField(ctx, AD_Browse_Field_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createBrowseFieldBinding(atts, m_BrowseField);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    if (m_BrowseField.getAD_Reference_ID() > 0) {
        packOut.createReference(m_BrowseField.getAD_Reference_ID(), document);
    }
    if (m_BrowseField.getAD_Reference_Value_ID() > 0) {
        packOut.createReference(m_BrowseField.getAD_Reference_Value_ID(), document);
    }
    if (m_BrowseField.getAD_Val_Rule_ID() > 0) {
        packOut.createDynamicRuleValidation(m_BrowseField.getAD_Val_Rule_ID(), document);
    }
    document.startElement("", "", "browsefield", atts);
    document.endElement("", "", "browsefield");
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) AttributesImpl(org.xml.sax.helpers.AttributesImpl) PackOut(org.adempiere.pipo.PackOut)

Example 4 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class MenuElementHandler method createModule.

public void createModule(Properties ctx, TransformerHandler document, int menu_id) throws SAXException {
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    String sql = null;
    sql = "SELECT A.Node_ID, B.AD_Menu_ID, B.Name, B.AD_WINDOW_ID, B.AD_WORKFLOW_ID, B.AD_TASK_ID, " + "B.AD_PROCESS_ID, B.AD_FORM_ID, B.AD_BROWSE_ID, B.AD_WORKBENCH_ID " + "FROM AD_TreeNoDemm A, AD_Menu B " + "WHERE A.Parent_ID = " + menu_id + " AND A.Node_ID = B.AD_Menu_ID";
    AttributesImpl atts = new AttributesImpl();
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            // Menu tag Start.
            X_AD_Menu m_Menu = new X_AD_Menu(ctx, rs.getInt("AD_Menu_ID"), null);
            atts = createMenuBinding(atts, m_Menu);
            document.startElement("", "", "menu", atts);
            if (rs.getInt("AD_WINDOW_ID") > 0 || rs.getInt("AD_WORKFLOW_ID") > 0 || rs.getInt("AD_TASK_ID") > 0 || rs.getInt("AD_PROCESS_ID") > 0 || rs.getInt("AD_FORM_ID") > 0 || rs.getInt("AD_BROWSE_ID") > 0 || rs.getInt("AD_WORKBENCH_ID") > 0) {
                // Call CreateWindow.
                if (rs.getInt("AD_WINDOW_ID") > 0) {
                    packOut.createWindow(rs.getInt("AD_WINDOW_ID"), document);
                } else // Call CreateProcess.
                if (rs.getInt("AD_PROCESS_ID") > 0) {
                    packOut.createProcess(rs.getInt("AD_PROCESS_ID"), document);
                } else // Call CreateTask.
                if (rs.getInt("AD_TASK_ID") > 0) {
                    packOut.createTask(rs.getInt("AD_TASK_ID"), document);
                } else // Call CreateForm.
                if (rs.getInt("AD_FORM_ID") > 0) {
                    packOut.createForm(rs.getInt("AD_FORM_ID"), document);
                } else // Call Browse.
                if (rs.getInt("AD_Browse_ID") > 0) {
                    packOut.createBrowse(rs.getInt("AD_Browse_ID"), document);
                } else // Call CreateWorkflow
                if (rs.getInt("AD_Workflow_ID") > 0) {
                    packOut.createWorkflow(rs.getInt("AD_Workflow_ID"), document);
                }
            // Call CreateModule because entry is a summary menu
            } else {
                createModule(ctx, document, rs.getInt("Node_ID"));
            }
            document.endElement("", "", "menu");
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "getWindows", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_Menu(org.compiere.model.X_AD_Menu) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SAXException(org.xml.sax.SAXException)

Example 5 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class FieldGroupElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int fieldGroup_id = Env.getContextAsInt(ctx, X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
    if (processedFieldGroups.contains(fieldGroup_id))
        return;
    processedFieldGroups.add(fieldGroup_id);
    X_AD_FieldGroup fieldGroup = new X_AD_FieldGroup(ctx, fieldGroup_id, null);
    AttributesImpl atts = new AttributesImpl();
    createFieldGroupBinding(atts, fieldGroup);
    document.startElement("", "", "fieldgroup", atts);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    packOut.createTranslations(X_AD_FieldGroup.Table_Name, fieldGroup.get_ID(), document);
    document.endElement("", "", "fieldgroup");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_FieldGroup(org.compiere.model.X_AD_FieldGroup) PackOut(org.adempiere.pipo.PackOut)

Aggregations

PackOut (org.adempiere.pipo.PackOut)17 AttributesImpl (org.xml.sax.helpers.AttributesImpl)16 PreparedStatement (java.sql.PreparedStatement)8 ResultSet (java.sql.ResultSet)8 SAXException (org.xml.sax.SAXException)8 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)6 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)5 SQLException (java.sql.SQLException)4 Query (org.compiere.model.Query)3 MBrowseField (org.adempiere.model.MBrowseField)2 MViewColumn (org.adempiere.model.MViewColumn)2 MViewDefinition (org.adempiere.model.MViewDefinition)2 X_AD_Menu (org.compiere.model.X_AD_Menu)2 MBrowse (org.adempiere.model.MBrowse)1 X_AD_View (org.adempiere.model.X_AD_View)1 PackInHandler (org.adempiere.pipo.PackInHandler)1 MPackageExp (org.compiere.model.MPackageExp)1 X_AD_Element (org.compiere.model.X_AD_Element)1 X_AD_Field (org.compiere.model.X_AD_Field)1 X_AD_FieldGroup (org.compiere.model.X_AD_FieldGroup)1