List of usage examples for org.dom4j Element getData
Object getData();
From source file:edu.ku.brc.dbsupport.ImportExportDB.java
License:Open Source License
protected Object findTypeRecordSet(Element compareMe, String dbTable, @SuppressWarnings("unused") long parentId, String parentName) { try { // get the fieldinfo String lowerdbTable = dbTable.toLowerCase(); DBTableInfo info = DBTableIdMgr.getInstance().getInfoByTableName(lowerdbTable); // find element with compareme.getName() DBFieldInfo fieldInfo = info.getFieldByName(compareMe.getName()); // if the element is an id, ignore it // TODO: shouldl check for primary key if (!compareMe.getName().equals(lowerFirstChar(dbTable) + "Id")) //$NON-NLS-1$ {/* w ww . j a v a 2s . c om*/ // if it is a normal field if (fieldInfo != null) { String type = fieldInfo.getType(); // check the type if (type.equals("java.lang.String") || type.equals("text")) //$NON-NLS-1$ //$NON-NLS-2$ { return compareMe.getStringValue(); } else if (type.equals("java.util.Date")) //$NON-NLS-1$ { Date dtTmp = new SimpleDateFormat("yy-MM-dd H:mm:ss").parse(compareMe //$NON-NLS-1$ .getStringValue()); return dtTmp; } else if (type.equals("java.sql.Timestamp")) //$NON-NLS-1$ { Timestamp tmstmp = Timestamp.valueOf(compareMe.getStringValue()); return tmstmp; } else if (type.equals("java.lang.Integer")) //$NON-NLS-1$ { int num = new Integer(compareMe.getStringValue()).intValue(); return num; } else if (type.equals("java.lang.Boolean")) //$NON-NLS-1$ { Boolean bool = Boolean.valueOf(compareMe.getStringValue()); return bool; } else if (type.equals("java.math.BigDecimal")) //$NON-NLS-1$ { BigDecimal num = UIHelper.parseDoubleToBigDecimal(compareMe.getStringValue()); return num; } else if (type.equals("java.lang.Double")) //$NON-NLS-1$ { double num = new Double(compareMe.getStringValue()).doubleValue(); return num; } else if (type.equals("java.lang.Float")) //$NON-NLS-1$ { float num = new Float(compareMe.getStringValue()).floatValue(); return num; } else if (type.equals("java.lang.Long")) //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); return num; } else if (type.equals("java.lang.Short")) //$NON-NLS-1$ { short num = new Short(compareMe.getStringValue()).shortValue(); return num; } else if (type.equals("java.lang.Byte")) //$NON-NLS-1$ { byte num = new Byte(compareMe.getStringValue()).byteValue(); return num; } else if (type.equals("java.util.Calendar")) //$NON-NLS-1$ { Calendar date = dateString2Calendar(compareMe.getStringValue()); return date; } } else // check if it is a many-to-one { DBRelationshipInfo tablerel = info.getRelationshipByName(compareMe.getName()); // check for many to one, and make sure it has a value if (tablerel != null && tablerel.getType().name() == "ManyToOne" //$NON-NLS-1$ && !compareMe.getStringValue().equals("")) //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); String className = tablerel.getClassName().substring(29);// strip working // set // TODO: remove this condition for agent if (className.equals("Agent")) //$NON-NLS-1$ { className = className.toLowerCase(); Object tableObject = genericDBObject2(className, num); return tableObject; } Object tableObject = getParentDBObject(className, num); return tableObject; // check if its a collection (one-to-many) } else if ((tablerel != null && tablerel.getType().name() == "OneToMany") //$NON-NLS-1$ || (tablerel != null && tablerel.getType().name() == "ManyToMany")) //$NON-NLS-1$ { // if many-to-many if (compareMe.getName().equals(parentName + "s")) { //$NON-NLS-0$ return "ManyToMany"; //$NON-NLS-1$ } // else one-to-many return "OneToMany"; //$NON-NLS-1$ } else { log.debug("could not import element: " + compareMe.getName() //$NON-NLS-1$ + ", with data:" + compareMe.getData()); //$NON-NLS-1$ } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex); if (ex.toString().startsWith("java.lang.NumberFormatException")) { //$NON-NLS-0$ return null; } // else ex.printStackTrace(); } return null; }
From source file:edu.ku.brc.dbsupport.ImportExportDB.java
License:Open Source License
protected Object findTypeDataBase(Element compareMe, String dbTable, @SuppressWarnings("unused") long parentId, String parentName) { try { // get the fieldinfo String lowerdbTable = dbTable.toLowerCase(); DBTableInfo info = DBTableIdMgr.getInstance().getInfoByTableName(lowerdbTable); // find element with compareme.getName() DBFieldInfo fieldInfo = info.getFieldByName(compareMe.getName()); // if the element is an id, ignore it // TODO: shouldl check for primary key if (!compareMe.getName().equals(lowerFirstChar(dbTable) + "Id")) //$NON-NLS-1$ {//from ww w . java2 s .co m // if it is a normal field if (fieldInfo != null) { String type = fieldInfo.getType(); // check the type if (type.equals("java.lang.String") || type.equals("text")) //$NON-NLS-1$ //$NON-NLS-2$ { return compareMe.getStringValue(); } else if (type.equals("java.util.Date")) //$NON-NLS-1$ { Date dtTmp = new SimpleDateFormat("yy-MM-dd H:mm:ss").parse(compareMe //$NON-NLS-1$ .getStringValue()); return dtTmp; } else if (type.equals("java.sql.Timestamp")) //$NON-NLS-1$ { Timestamp tmstmp = Timestamp.valueOf(compareMe.getStringValue()); return tmstmp; } else if (type.equals("java.lang.Integer")) //$NON-NLS-1$ { int num = new Integer(compareMe.getStringValue()).intValue(); return num; } else if (type.equals("java.lang.Boolean")) //$NON-NLS-1$ { Boolean bool = Boolean.valueOf(compareMe.getStringValue()); return bool; } else if (type.equals("java.math.BigDecimal")) //$NON-NLS-1$ { BigDecimal num = UIHelper.parseDoubleToBigDecimal(compareMe.getStringValue()); return num; } else if (type.equals("java.lang.Double")) //$NON-NLS-1$ { double num = new Double(compareMe.getStringValue()).doubleValue(); return num; } else if (type.equals("java.lang.Float")) //$NON-NLS-1$ { float num = new Float(compareMe.getStringValue()).floatValue(); return num; } else if (type.equals("java.lang.Long")) //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); return num; } else if (type.equals("java.lang.Short")) //$NON-NLS-1$ { short num = new Short(compareMe.getStringValue()).shortValue(); return num; } else if (type.equals("java.lang.Byte")) //$NON-NLS-1$ { byte num = new Byte(compareMe.getStringValue()).byteValue(); return num; } else if (type.equals("java.util.Calendar")) //$NON-NLS-1$ { Calendar date = dateString2Calendar(compareMe.getStringValue()); return date; } } else // check if it is a many-to-one { DBRelationshipInfo tablerel = info.getRelationshipByName(compareMe.getName()); // check for many to one, and make sure it has a value if (tablerel != null && tablerel.getType().name() == "ManyToOne" //$NON-NLS-1$ && !compareMe.getStringValue().equals("")) //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); String className = tablerel.getClassName().substring(29);// strip working // set // TODO: remove this condition for agent if (className.equals("Agent")) //$NON-NLS-1$ { className = className.toLowerCase(); Object tableObject = genericDBObject2(className, num); return tableObject; } else { Object tableObject = loadOrCreateParentDataBaseObject(className, num); return tableObject; } // check if its a collection (one-to-many) } else if ((tablerel != null && tablerel.getType().name() == "OneToMany") //$NON-NLS-1$ || (tablerel != null && tablerel.getType().name() == "ManyToMany")) //$NON-NLS-1$ { // if many-to-many if (compareMe.getName().equals(parentName + "s")) { //$NON-NLS-0$ return "ManyToMany"; //$NON-NLS-1$ } // else one-to-many return "OneToMany"; //$NON-NLS-1$ } else { log.debug("could not import element: " + compareMe.getName() //$NON-NLS-1$ + ", with data:" + compareMe.getData()); //$NON-NLS-1$ } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex); if (ex.toString().startsWith("java.lang.NumberFormatException")) { //$NON-NLS-0$ return null; } // else ex.printStackTrace(); } return null; }
From source file:edu.ku.brc.dbsupport.ImportExportDB.java
License:Open Source License
protected Object findTypeDataBaseParent(Element compareMe, String dbTable, @SuppressWarnings("unused") long parentId, String parentName) { try { // get the fieldinfo String lowerdbTable = dbTable.toLowerCase(); DBTableInfo info = DBTableIdMgr.getInstance().getInfoByTableName(lowerdbTable); String primaryKey = info.getPrimaryKeyName(); // find element with compareme.getName() DBFieldInfo fieldInfo = info.getFieldByName(compareMe.getName()); // if the element is an id, ignore it // if( !compareMe.getName().equals( lowerFirstChar(dbTable) + "Id") ) // { // if(!primaryKey.equals(compareMe.getName())) // { // if it is a normal field if (fieldInfo != null || primaryKey.equals(compareMe.getName())) // if(fieldInfo != null ) {// w w w .ja v a2s.com String type = new String(); if (fieldInfo == null) {// it is an id type = "java.lang.Integer"; //$NON-NLS-1$ System.out.println(compareMe.getStringValue()); } else { type = fieldInfo.getType(); } // check the type if (type.equals("java.lang.String") || type.equals("text")) //$NON-NLS-1$ //$NON-NLS-2$ { return compareMe.getStringValue(); } else if (type.equals("java.util.Date")) //$NON-NLS-1$ { Date dtTmp = new SimpleDateFormat("yy-MM-dd H:mm:ss").parse(compareMe //$NON-NLS-1$ .getStringValue()); return dtTmp; } else if (type.equals("java.sql.Timestamp")) //$NON-NLS-1$ { Timestamp tmstmp = Timestamp.valueOf(compareMe.getStringValue()); return tmstmp; } else if (type.equals("java.lang.Integer")) //$NON-NLS-1$ { int num = new Integer(compareMe.getStringValue()).intValue(); return num; } else if (type.equals("java.lang.Boolean")) //$NON-NLS-1$ { Boolean bool = Boolean.valueOf(compareMe.getStringValue()); return bool; } else if (type.equals("java.math.BigDecimal")) //$NON-NLS-1$ { BigDecimal num = UIHelper.parseDoubleToBigDecimal(compareMe.getStringValue()); return num; } else if (type.equals("java.lang.Double")) //$NON-NLS-1$ { double num = new Double(compareMe.getStringValue()).doubleValue(); return num; } else if (type.equals("java.lang.Float")) //$NON-NLS-1$ { float num = new Float(compareMe.getStringValue()).floatValue(); return num; } else if (type.equals("java.lang.Long")) //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); return num; } else if (type.equals("java.lang.Short")) //$NON-NLS-1$ { short num = new Short(compareMe.getStringValue()).shortValue(); return num; } else if (type.equals("java.lang.Byte")) //$NON-NLS-1$ { byte num = new Byte(compareMe.getStringValue()).byteValue(); return num; } else if (type.equals("java.util.Calendar")) //$NON-NLS-1$ { Calendar date = dateString2Calendar(compareMe.getStringValue()); return date; } } else // check if it is a many-to-one { DBRelationshipInfo tablerel = info.getRelationshipByName(compareMe.getName()); // check for many to one, and make sure it has a value if (tablerel != null && tablerel.getType().name() == "ManyToOne" //$NON-NLS-1$ && !compareMe.getStringValue().equals("")) //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); String className = tablerel.getClassName().substring(29);// strip working set // TODO: remove this condition for agent if (className.equals("Agent")) //$NON-NLS-1$ { className = className.toLowerCase(); Object tableObject = genericDBObject2(className, num); return tableObject; } else { Object tableObject = loadOrCreateParentDataBaseObject(className, num); return tableObject; } // check if its a collection (one-to-many) } else if ((tablerel != null && tablerel.getType().name() == "OneToMany") //$NON-NLS-1$ || (tablerel != null && tablerel.getType().name() == "ManyToMany")) //$NON-NLS-1$ { // if many-to-many if (compareMe.getName().equals(parentName + "s")) { //$NON-NLS-0$ return "ManyToMany"; //$NON-NLS-1$ } // else one-to-many return "OneToMany"; //$NON-NLS-1$ } else { log.debug("could not import element: " + compareMe.getName() //$NON-NLS-1$ + ", with data:" + compareMe.getData()); //$NON-NLS-1$ } } // } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex); if (ex.toString().startsWith("java.lang.NumberFormatException")) { //$NON-NLS-0$ return null; } // else ex.printStackTrace(); } return null; }
From source file:net.techest.railgun.action.FilterActionNode.java
License:Apache License
@Override public Shell execute(Element node, Shell shell) throws Exception { // ?//w w w.j av a 2 s . co m if (node.getData() == null) { throw new ActionException("Filter???filters"); } String[] classP = node.getTextTrim().split("/"); String className = classP[0]; String methodName = "process"; if (classP.length == 2) { methodName = classP[1]; } new FiltersInvoker().invoke(shell, className, methodName); return shell; }
From source file:net.techest.railgun.action.ShellActionNode.java
License:Apache License
@Override public Shell execute(Element node, Shell shell) throws Exception { // name/*from ww w.j a v a 2 s . c o m*/ if (node.element("name") == null) { throw new ActionException("railgunName"); } Element nameNode = node.element("name"); shell.setName(nameNode.getData().toString()); nameNode.detach(); // description? if (node.element("description") != null) { Element despNode = node.element("description"); shell.setDescription(despNode.getData().toString()); despNode.detach(); } // reloadtime? if (node.element("reloadtime") != null) { Element reloadNode = node.element("reloadtime"); shell.setReloadTime(Long.parseLong(reloadNode.getData().toString())); reloadNode.detach(); } // baseurl? if (node.element("baseurl") != null) { Element baseurlNode = node.element("baseurl"); shell.setBaseUrl(baseurlNode.getData().toString()); baseurlNode.detach(); } // ? httpclient Client hc = new HttpClient(); if (node.element("client") == null) { // Log4j.getInstance().info("Your Shell Has No Gun To Lauther"); } shell.setClient(hc); LinkedList<Resource> res = new LinkedList(); res.add(new Resource()); shell.setResources(res); return shell; }
From source file:org.dom4j.samples.bean.BeanDemo.java
License:Open Source License
protected void process(Document document) throws Exception { // find all of the windows List windows = document.selectNodes("//window"); for (Iterator iter = windows.iterator(); iter.hasNext();) { Element element = (Element) iter.next(); Object window = element.getData(); if (window instanceof Component) { Component component = (Component) window; component.setVisible(true);/*from ww w . j a va2 s . c o m*/ } println("found element: " + element); println("found window: " + window); } println(""); println("Now lets find all the fonts..."); List fonts = document.selectNodes("//@font"); for (Iterator iter = fonts.iterator(); iter.hasNext();) { Attribute font = (Attribute) iter.next(); println("found font: " + font.getData()); } }
From source file:org.fseek.simon.imageuploader.hoster.imgur.ImgurUploader.java
License:Open Source License
private void addToEngine(Element n, ImgurImage img) throws Exception { String nodeName = n.getName(); Object nodeData = n.getData(); Class<? extends ImgurImage> aClass = img.getClass(); Field[] declaredFields = aClass.getDeclaredFields(); for (int i = 0; i < declaredFields.length; i++) { Field f = declaredFields[i]; f.setAccessible(true);/* www . j a v a 2 s. com*/ if (nodeName.equals(f.getName())) { try { Class<?> type = f.getType(); if (type.toString().equals("boolean")) { f.setBoolean(img, Boolean.parseBoolean(nodeData.toString())); } else if (type.toString().equals("int")) { f.setInt(img, Integer.parseInt(nodeData.toString())); } else if (type.toString().equals("long")) { f.setLong(img, Long.parseLong(nodeData.toString())); } else { f.set(img, nodeData); } } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:org.nuxeo.cm.core.service.caseimporter.DefaultXMLCaseReader.java
License:Open Source License
@Override public String getCaseItemPathFile(Element caseItemElement) { return (String) caseItemElement.getData(); }
From source file:org.nuxeo.cm.core.service.caseimporter.DefaultXMLCaseReader.java
License:Open Source License
@Override public DistributionInfo getDistributionInfo(Element caseElement) { List<String> actionMailboxes = new ArrayList<String>(); List<String> informationMailboxes = new ArrayList<String>(); CMFDistributionInfo distributionInfo = new CMFDistributionInfo(); Element allRecipients = caseElement.element(CASE_RECIPIENTS_TAG); // TODO : better error handling if (allRecipients != null) { List<Element> actionMailboxesElements = allRecipients.element(CASE_RECIPIENTS_ACTION) .elements(CASE_RECIPIENTS_MAILBOX_TAG); for (Element element : actionMailboxesElements) { actionMailboxes.add((String) element.getData()); }/*from w w w. j av a2 s.c om*/ List<Element> informationMailboxesElements = caseElement.element(CASE_RECIPIENTS_TAG) .element(CASE_RECIPIENTS_INFORMATION).elements(CASE_RECIPIENTS_MAILBOX_TAG); for (Element element : informationMailboxesElements) { informationMailboxes.add((String) element.getData()); } } distributionInfo.setForActionMailboxes(actionMailboxes); distributionInfo.setForInformationMailboxes(informationMailboxes); return distributionInfo; }
From source file:org.onecmdb.core.utils.xml.XmlParser.java
License:Open Source License
public void dumpElement(Element el, int level) { System.out.println(tab(level) + el.getName() + ":" + el.getData() + " {"); List attributes = el.attributes(); for (int i = 0; i < attributes.size(); i++) { Attribute a = (Attribute) attributes.get(i); System.out.println(tab(level) + " " + a.getName() + "=" + a.getData()); }//ww w. j a va 2 s . co m List els = el.elements(); for (int i = 0; i < els.size(); i++) { dumpElement((Element) els.get(i), level + 1); } System.out.println(tab(level) + "}"); }