Search in sources :

Example 56 with AttributesImpl

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

the class WindowAccessElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Window_ID = Env.getContextAsInt(ctx, X_AD_Window.COLUMNNAME_AD_Window_ID);
    int AD_Role_ID = Env.getContextAsInt(ctx, X_AD_Role.COLUMNNAME_AD_Role_ID);
    AttributesImpl atts = new AttributesImpl();
    createWindowAccessBinding(atts, AD_Window_ID, AD_Role_ID);
    document.startElement("", "", "windowaccess", atts);
    document.endElement("", "", "windowaccess");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 57 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl 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 58 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl 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 59 with AttributesImpl

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

the class TaskAccessElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Task_ID = Env.getContextAsInt(ctx, X_AD_Task.COLUMNNAME_AD_Task_ID);
    int AD_Role_ID = Env.getContextAsInt(ctx, X_AD_Role.COLUMNNAME_AD_Role_ID);
    AttributesImpl atts = new AttributesImpl();
    createTaskAccessBinding(atts, AD_Task_ID, AD_Role_ID);
    document.startElement("", "", "taskaccess", atts);
    document.endElement("", "", "taskaccess");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 60 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project jackrabbit by apache.

the class JsonDiffHandler method importNode.

private static Node importNode(Node parent, String nodeName, String ntName, String uuid) throws RepositoryException {
    String uri = "http://www.jcp.org/jcr/sv/1.0";
    String prefix = "sv:";
    ContentHandler ch = createContentHandler(parent);
    try {
        ch.startDocument();
        String nN = "node";
        AttributesImpl attrs = new AttributesImpl();
        attrs.addAttribute(uri, "name", prefix + "name", "CDATA", nodeName);
        ch.startElement(uri, nN, prefix + nN, attrs);
        // primary node type
        String pN = "property";
        attrs = new AttributesImpl();
        attrs.addAttribute(uri, "name", prefix + "name", "CDATA", JcrConstants.JCR_PRIMARYTYPE);
        attrs.addAttribute(uri, "type", prefix + "type", "CDATA", PropertyType.nameFromValue(PropertyType.NAME));
        ch.startElement(uri, pN, prefix + pN, attrs);
        ch.startElement(uri, "value", prefix + "value", new AttributesImpl());
        char[] val = ntName.toCharArray();
        ch.characters(val, 0, val.length);
        ch.endElement(uri, "value", prefix + "value");
        ch.endElement(uri, pN, prefix + pN);
        // uuid
        attrs = new AttributesImpl();
        attrs.addAttribute(uri, "name", prefix + "name", "CDATA", JcrConstants.JCR_UUID);
        attrs.addAttribute(uri, "type", prefix + "type", "CDATA", PropertyType.nameFromValue(PropertyType.STRING));
        ch.startElement(uri, pN, prefix + pN, attrs);
        ch.startElement(uri, "value", prefix + "value", new AttributesImpl());
        val = uuid.toCharArray();
        ch.characters(val, 0, val.length);
        ch.endElement(uri, "value", prefix + "value");
        ch.endElement(uri, pN, prefix + pN);
        ch.endElement(uri, nN, prefix + nN);
        ch.endDocument();
    } catch (SAXException e) {
        throw new RepositoryException(e);
    }
    Node n = null;
    NodeIterator it = parent.getNodes(nodeName);
    while (it.hasNext()) {
        n = it.nextNode();
    }
    if (n == null) {
        throw new RepositoryException("Internal error: No child node added.");
    }
    return n;
}
Also used : NodeIterator(javax.jcr.NodeIterator) AttributesImpl(org.xml.sax.helpers.AttributesImpl) Node(javax.jcr.Node) RepositoryException(javax.jcr.RepositoryException) ContentHandler(org.xml.sax.ContentHandler) 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