Search in sources :

Example 56 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParser method parseInfoToGetUUID.

public HashMap<String, String> parseInfoToGetUUID(String output, String queryURL, SAXBuilder builder) {
    HashMap<String, String> uidToUrlMap = new HashMap<>();
    try {
        Document document = builder.build(new StringReader(output));
        Element root = document.getRootElement();
        List<Element> entries = root.getChildren("entry");
        for (Element entry : entries) {
            uidToUrlMap.put(queryURL, entry.getChild("repository").getChild("uuid").getValue());
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return uidToUrlMap;
}
Also used : Element(org.jdom2.Element) StringReader(java.io.StringReader) Document(org.jdom2.Document) ParseException(java.text.ParseException)

Example 57 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project opentheso by miledrousset.

the class importxml method ouvreFichier.

/*  
        for (Table user : DataTable) {
            for (LineOfData lineOfData : user.getLineOfDatas()) {
                writeLine(lineOfData.getColomne(), lineOfData.getValue());
            }
     */
/*
    public void choisirfichier (HikariDataSource ds){
        JFileChooser fileChooser = new JFileChooser();
        int seleccion = fileChooser.showOpenDialog(null);
        fichero = fileChooser.getSelectedFile();
               //Acciones que se quieran realizar
        ouvreFichier();
       
    }*/
/**
 * cette funtion permet de ouvrir un fichier pour comencée a faire une
 * injection de données.
 * C'est seulement pour la creation de un nouvelle BDD.
 * la funtion generique est plus ba
 * @param con
 * @param archive
 * @throws ClassNotFoundException
 * @throws SQLException
 */
public void ouvreFichier(Connection con, File archive) throws ClassNotFoundException, SQLException {
    LanguageBean langueBean = new LanguageBean();
    SAXBuilder builder = new SAXBuilder();
    ArrayList<Table> toutTables = new ArrayList<>();
    ArrayList<LineOfData> lineOfDatas = new ArrayList<>();
    try {
        // on crée le document a partir du fichier que on a selectioné
        Document document = (Document) builder.build(archive);
        // Se obtiene la raiz 'tables'
        Element rootNode = document.getRootElement();
        // ici on a toutes les tables (les enfants de la racine)
        List list = rootNode.getChildren("table");
        // ici on fait le tour pour les enfants de 'tables'
        for (int i = 0; i < list.size(); i++) {
            // ici on a la première table
            Element tabla = (Element) list.get(i);
            // ici on a le nom de la table
            String nombreTabla = tabla.getAttributeValue("nom");
            // ici c'est la liste des lignes de la table
            List lista_campos = tabla.getChildren();
            // ici on découpe la liste des lignes
            for (int j = 0; j < lista_campos.size(); j++) {
                // ici on a une ligne de la table
                Element campo = (Element) lista_campos.get(j);
                for (Element colonne : campo.getChildren()) {
                    LineOfData lineOfData = new LineOfData();
                    // le nom de la colone
                    lineOfData.setColomne(colonne.getName());
                    // le value que le correspond
                    lineOfData.setValue(colonne.getText());
                    lineOfDatas.add(lineOfData);
                }
                insertLine(con, lineOfDatas, nombreTabla);
                lineOfDatas.clear();
            }
        // / mettre à jour la table dans la BDD
        }
    } catch (IOException | JDOMException io) {
        System.out.println("error");
    }
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("impBDD.info1")));
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Table(mom.trd.opentheso.core.exports.privatesdatas.tables.Table) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException) LineOfData(mom.trd.opentheso.core.exports.privatesdatas.LineOfData) ArrayList(java.util.ArrayList) List(java.util.List) LanguageBean(mom.trd.opentheso.SelectedBeans.LanguageBean)

Example 58 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project opentheso by miledrousset.

the class GpsQuery method getlisteAlign.

private ArrayList<NodeAlignment> getlisteAlign(String xmlrecord) {
    ArrayList<NodeAlignment> listeAlign1 = new ArrayList<>();
    // Se crea un SAXBuilder para poder parsear el archivo
    SAXBuilder builder = new SAXBuilder();
    File xmlFile = new File(xmlrecord);
    try {
        // Se crea el documento a traves del archivo
        Document document = (Document) builder.build(xmlFile);
        // Se obtiene la raiz 'tables'
        Element rootNode = document.getRootElement();
        // Se obtiene la lista de hijos de la raiz 'tables'
        List list = rootNode.getChildren("geoname");
        // Se recorre la lista de hijos de 'tables'
        for (int i = 0; i < list.size(); i++) {
            // Se obtiene el elemento 'tabla'
            Element tabla = (Element) list.get(i);
            // Se obtiene la lista de hijos del tag 'tabla'
            List lista_campos = tabla.getChildren();
            // Se recorre la lista de campos
            for (int j = 0; j < lista_campos.size(); j++) {
                // Se obtiene el elemento 'campo'
                Element campo = (Element) lista_campos.get(j);
                // Se obtienen los valores que estan entre los tags '&lt;campo&gt;&lt;/campo&gt;'
                // Se obtiene el valor que esta entre los tags '&lt;nombre&gt;&lt;/nombre&gt;'
                String nombre = campo.getChildTextTrim("name");
                // Se obtiene el valor que esta entre los tags '&lt;tipo&gt;&lt;/tipo&gt;'
                String tname = campo.getChildTextTrim("toponymName");
                // Se obtiene el valor que esta entre los tags '&lt;valor&gt;&lt;/valor&gt;'
                String lat = campo.getChildTextTrim("lat");
                String lng = campo.getChildTextTrim("lng");
                System.out.println("\t" + nombre + "\t\t" + tname + "\t\t" + lat + "\t\t" + lng);
            }
        }
    } catch (IOException io) {
        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        System.out.println(jdomex.getMessage());
    }
    return listeAlign1;
}
Also used : NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException) File(java.io.File)

Example 59 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project jPOS by jpos.

the class QThreadPoolExecutorTest method getDocument.

protected Document getDocument(InputStream is) {
    SAXBuilder builder = new SAXBuilder();
    builder.setValidation(false);
    Document doc = null;
    try {
        doc = builder.build(is);
        return doc;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Document(org.jdom2.Document) ConfigurationException(org.jpos.core.ConfigurationException) NotFoundException(org.jpos.util.NameRegistrar.NotFoundException) DataConversionException(org.jdom2.DataConversionException)

Example 60 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project scylla by bptlab.

the class SimulationConfigurationPane method open.

@Override
protected void open() throws JDOMException, IOException {
    buttonClosefile.setEnabled(true);
    try {
        creator = SimulationConfigurationCreator.createFromFile(getFile().getPath());
    } catch (NotAValidFileException e1) {
        setFile(null);
        e1.printStackTrace();
        return;
    }
    if (gcc != null)
        creator.setGCC(gcc);
    Element modelRoot = null;
    if (bpmnPath != null && !bpmnPath.isEmpty())
        try {
            Document doc;
            SAXBuilder builder = new SAXBuilder();
            doc = builder.build(bpmnPath);
            modelRoot = doc.getRootElement();
            creator.setModel(modelRoot, false);
        } catch (JDOMException | IOException e) {
            e.printStackTrace();
        } catch (NoProcessSpecifiedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NotAuthorizedToOverrideException e) {
            int override = showModelOverrideConfirmationDialog(e);
            if (override == 0)
                try {
                    creator.setModel(modelRoot, true);
                } catch (NoProcessSpecifiedException | NotAuthorizedToOverrideException e1) {
                    e1.printStackTrace();
                }
            else
                clearBpmnPath();
            e.printStackTrace();
        }
    setChangeFlag(true);
    textfieldId.loadSavedValue();
    if (creator.getRandomSeed() != null) {
        textfieldSeed.setValue(creator.getRandomSeed());
    }
    if (creator.getProcessInstances() != null)
        spinnerNOI.setValue(Integer.parseInt(creator.getProcessInstances()));
    String startDt = creator.getStartDateTime();
    if (startDt != null) {
        startDateTime = ZonedDateTime.parse(startDt);
        textfieldStartTime.setValue(startDateTime.toLocalTime());
        textfieldStartDate.setValue(startDateTime.toLocalDate());
    }
    String endDt = creator.getEndDateTime();
    if (endDt != null) {
        checkboxUnlimited.setSelected(false);
        endDateTime = ZonedDateTime.parse(endDt);
        textfieldEndTime.setValue(endDateTime.toLocalTime());
        textfieldEndDate.setValue(endDateTime.toLocalDate());
    } else {
        checkboxUnlimited.setSelected(true);
        textfieldEndDate.getComponent().setEnabled(false);
        textfieldEndTime.getComponent().setEnabled(false);
    }
    importCreatorElements();
    setChangeFlag(false);
    setEnabled(true);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) NotAuthorizedToOverrideException(de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NotAuthorizedToOverrideException) Element(org.jdom2.Element) Document(org.jdom2.Document) NoProcessSpecifiedException(de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NoProcessSpecifiedException) NotAValidFileException(de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NotAValidFileException)

Aggregations

SAXBuilder (org.jdom2.input.SAXBuilder)60 Document (org.jdom2.Document)35 Element (org.jdom2.Element)21 Test (org.junit.Test)20 IOException (java.io.IOException)14 File (java.io.File)12 JDOMException (org.jdom2.JDOMException)10 Modification (com.thoughtworks.go.domain.materials.Modification)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 BufferedInputStream (java.io.BufferedInputStream)5 ParseException (java.text.ParseException)5 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 StringReader (java.io.StringReader)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)3 NoProcessSpecifiedException (de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NoProcessSpecifiedException)3 NotAuthorizedToOverrideException (de.hpi.bpt.scylla.creation.SimulationConfiguration.SimulationConfigurationCreator.NotAuthorizedToOverrideException)3 FileNotFoundException (java.io.FileNotFoundException)3