List of usage examples for org.dom4j Element getData
Object getData();
From source file:com.taobao.sqlautoreview.HandleXMLConf.java
License:Open Source License
public int getDbConfigPort() { int port = -1; ///*from ww w. j a v a 2s.c om*/ for (Iterator<Element> r = root.elementIterator(); r.hasNext();) { Element tmp = r.next(); if (tmp.getName().equals("port")) { port = Integer.valueOf(tmp.getData().toString()); break; } } return port; }
From source file:com.taobao.sqlautoreview.HandleXMLConf.java
License:Open Source License
public String getDbConfigDbname() { String dbname = ""; ///* w ww . java 2s. c o m*/ for (Iterator<Element> r = root.elementIterator(); r.hasNext();) { Element tmp = r.next(); if (tmp.getName().equals("dbname")) { dbname = tmp.getData().toString(); break; } } return dbname; }
From source file:com.taobao.sqlautoreview.HandleXMLConf.java
License:Open Source License
public String getDbConfigUser() { String user = ""; ///* ww w . j a v a 2 s .c o m*/ for (Iterator<Element> r = root.elementIterator(); r.hasNext();) { Element tmp = r.next(); if (tmp.getName().equals("user")) { user = tmp.getData().toString(); break; } } return user; }
From source file:com.taobao.sqlautoreview.HandleXMLConf.java
License:Open Source License
public String getDbConfigPassword() { String password = ""; ///*from ww w . j a va2s .c o m*/ for (Iterator<Element> r = root.elementIterator(); r.hasNext();) { Element tmp = r.next(); if (tmp.getName().equals("password")) { password = tmp.getData().toString(); break; } } return password; }
From source file:com.taobao.sqlautoreview.HandleXMLConf.java
License:Open Source License
public int getSQLMapFileID() { int file_id = -1; ///*w w w. j a v a 2s . co m*/ for (Iterator<Element> r = root.elementIterator(); r.hasNext();) { Element tmp = r.next(); if (tmp.getName().equals("file_id")) { file_id = Integer.valueOf(tmp.getData().toString()); break; } } return file_id; }
From source file:com.taobao.sqlautoreview.HandleXMLConf.java
License:Open Source License
public String getSQLMapFileName() { String file_name = ""; ///* ww w . j a v a 2 s . c o m*/ for (Iterator<Element> r = root.elementIterator(); r.hasNext();) { Element tmp = r.next(); if (tmp.getName().equals("file_name")) { file_name = tmp.getData().toString(); break; } } return file_name; }
From source file:controllers.FXMLScicumulusController.java
public void importWorkflow() throws DocumentException { //Impota o workflow e cria o grafo System.out.println("Importando..."); SAXReader reader = new SAXReader(); Document docXml = reader.read("src/main/java/br/com/uft/scicumulus/files/SciCumulus.xml"); Element root = docXml.getRootElement(); for (Iterator i = root.elementIterator(); i.hasNext();) { Element element = (Element) i.next(); // tempList.addElement(element.attributeValue("id")); for (Iterator j = element.elementIterator(); j.hasNext();) { Element innerElement = (Element) j.next(); System.out.println(innerElement.getData().toString()); }/* w w w . j ava 2 s . c om*/ } }
From source file:de.fmaul.android.cmis.utils.FeedUtils.java
License:Apache License
public static Element getWorkspace(Document doc, String workspaceName) { List<Element> workspaces = doc.getRootElement().elements("workspace"); Element workspace = null;//from ww w .j av a 2s . c o m if (workspaces.size() > 0) { for (Element wSpace : workspaces) { Element repoInfo = wSpace.element(CMISRA_REPO_INFO); Element repoId = repoInfo.element(CMIS_REPO_NAME); if (workspaceName.equals(repoId.getData())) { return workspace = wSpace; } } } else { workspace = null; } return workspace; }
From source file:edu.ku.brc.dbsupport.ImportExportDB.java
License:Open Source License
/** * set the value of an element to the correct type * @param compareMe the element//from w w w . j a v a2 s . c o m * @param dbTable the class name of the table * @param parentObject the parent record * @param parentName the parentName * @return an object, "ManyToMany", "OneToMany", or null if it could not find the type */ protected Object findType(Element compareMe, String dbTable, Object parentObject, 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 if (!compareMe.getName().equals(lowerFirstChar(dbTable) + "Id")) //$NON-NLS-1$ { // 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()); if (tablerel != null && tablerel.getType().name() == "ManyToOne") //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); if (compareMe.getName().equals(parentName)) { return parentObject; } // else check if the xml fiel is there, // if so run it // otherwise make a generic thing // some things cant be generic // also check the order of how buildsampledb does it ^.^ // a generic map // get the classtype /* * if(compareMe.getName() == "deaccessionPreparation"){ String className = * tablerel.getClassName().substring(29).toLowerCase();//strip working * set Object tableObject2 = genericDBObject2(className, num); return * tableObject2; } */// else{ // if(compareMe.getName() == "referenceWork"){File path = new // File(importFolderPath+"ReferenceWork"+".xml"); try {// if a generic exsists File path = new File( importFolderPath + capFirstChar(compareMe.getName()) + "Generic.xml"); //$NON-NLS-1$ Element dbImport2 = XMLHelper.readFileToDOM4J(path); Object tableObject = dynamicXMLImportRecReturn(dbImport2, capFirstChar(compareMe.getName())); return tableObject; } catch (FileNotFoundException e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, e); // normal String className = tablerel.getClassName().substring(29).toLowerCase();// strip working set Object tableObject = genericDBObject2(className, num); return tableObject; } // }else{ /* * Element dbImport = XMLHelper.readFileToDOM4J(path); Object * tableObject = dynamicXMLImportRecReturn(dbImport, * capFirstChar(compareMe.getName())); 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); ex.printStackTrace(); } return null; }
From source file:edu.ku.brc.dbsupport.ImportExportDB.java
License:Open Source License
protected Object findTypeSequential(Element compareMe, String dbTable, long parentId, String parentName) { try { // get the fieldinfo String lowerdbTable = dbTable.toLowerCase(); DBTableInfo info = DBTableIdMgr.getInstance().getInfoByTableName(lowerdbTable); /*//from w ww . j a va2 s .c om * List<DBTableIdMgr.FieldInfo> list = info.getFields(); * //log.debug(compareMe.getName()); for( DBTableIdMgr.FieldInfo i: list){ * System.out.println(i.getName()); } */ // 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")) //$NON-NLS-1$ { // 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()); if (tablerel != null && tablerel.getType().name() == "ManyToOne") //$NON-NLS-1$ { long num = new Long(compareMe.getStringValue()).longValue(); if (compareMe.getName().equals(lowerFirstChar(parentName)))// if they // equal, load // the parent // from the // database { String className = tablerel.getClassName().substring(29).toLowerCase();// strip // working // set Object tableObject = genericDBObject2(className, parentId); return tableObject; } // else check if the xml file is there, // if so run it // otherwise make a generic thing // some things cant be generic // also check the order of how buildsampledb does it ^.^ // a generic map // get the classtype /* * if(compareMe.getName() == "deaccessionPreparation"){ String className = * tablerel.getClassName().substring(29).toLowerCase();//strip working * set Object tableObject2 = genericDBObject2(className, num); return * tableObject2; } */// else{ // if(compareMe.getName() == "referenceWork"){File path = new // File(importFolderPath+"ReferenceWork"+".xml"); try {// if a generic exsists File path = new File( importFolderPath + capFirstChar(compareMe.getName()) + "Generic.xml"); //$NON-NLS-1$ Element dbImport2 = XMLHelper.readFileToDOM4J(path); Object tableObject = dynamicXMLImportRecReturn(dbImport2, capFirstChar(compareMe.getName())); return tableObject; } catch (FileNotFoundException e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, e); // normal String className = tablerel.getClassName().substring(29).toLowerCase();// strip working set Object tableObject = genericDBObject2(className, num); return tableObject; } // }else{ /* * Element dbImport = XMLHelper.readFileToDOM4J(path); Object * tableObject = dynamicXMLImportRecReturn(dbImport, * capFirstChar(compareMe.getName())); 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); ex.printStackTrace(); } return null; }