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");
}
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;
}
}
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");
}
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");
}
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;
}
Aggregations