Search in sources :

Example 76 with Document

use of com.google.firestore.v1.Document in project cxf by apache.

the class AbstractTypeTestClient2 method testDocument.

@Test
public void testDocument() throws Exception {
    if (!shouldRunTest("Document")) {
        return;
    }
    Document x = new Document();
    x.setValue("content-x");
    x.setID("Hello There");
    Document yOrig = new Document();
    yOrig.setID("Cheerio");
    yOrig.setValue("content-y");
    Holder<Document> y = new Holder<Document>(yOrig);
    Holder<Document> z = new Holder<Document>();
    Document ret;
    if (testDocLiteral) {
        ret = docClient.testDocument(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testDocument(x, y, z);
    } else {
        ret = rpcClient.testDocument(x, y, z);
    }
    if (!perfTestOnly) {
        equals("testDocument(): Incorrect value for inout param", x, y.value);
        equals("testDocument(): Incorrect value for out param", yOrig, z.value);
        equals("testDocument(): Incorrect return value", x, ret);
    }
    x = new Document();
    yOrig = new Document();
    x.setValue("content-x");
    yOrig.setValue("content-y");
    x.setID(null);
    yOrig.setID(null);
    y = new Holder<Document>(yOrig);
    z = new Holder<Document>();
    if (testDocLiteral) {
        ret = docClient.testDocument(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testDocument(x, y, z);
    } else {
        ret = rpcClient.testDocument(x, y, z);
    }
    if (!perfTestOnly) {
        equals("testDocument(): Incorrect value for inout param", x, y.value);
        equals("testDocument(): Incorrect value for out param", yOrig, z.value);
        equals("testDocument(): Incorrect return value", x, ret);
        assertNull(y.value.getID());
        assertNull(ret.getID());
    }
}
Also used : Holder(javax.xml.ws.Holder) Document(org.apache.type_test.types1.Document) Test(org.junit.Test)

Example 77 with Document

use of com.google.firestore.v1.Document in project opentheso by miledrousset.

the class importxml method ouvreFichier2.

/**
 * cette funtion permet de ouvrir un fichier pour comencée a faire une
 * injection de données.
 * Cette funtion c'est la generique
 * @param ds
 * @param archive
 * @throws ClassNotFoundException
 * @throws SQLException
 */
public void ouvreFichier2(HikariDataSource ds, 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();
                    lineOfData.setColomne(colonne.getName());
                    lineOfData.setValue(colonne.getText());
                    lineOfDatas.add(lineOfData);
                }
                insertLine2(ds, lineOfDatas, nombreTabla);
                lineOfDatas.clear();
            }
        // / mettre à jour la table dans la BDD
        }
    } catch (IOException | JDOMException io) {
        System.out.println(io.toString());
    }
// 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 78 with Document

use of com.google.firestore.v1.Document in project opentheso by miledrousset.

the class testimportxml method ouvreFichier.

// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
// 
@Test
public void ouvreFichier() {
    HikariDataSource conn = openConnexionPool();
    SAXBuilder builder = new SAXBuilder();
    ArrayList<Table> toutTables = new ArrayList<>();
    ArrayList<LineOfData> lineOfDatas = new ArrayList<>();
    File xmlFile = new File("C:/Users/antonio.perez/Desktop/testbon.xml");
    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'
        // ici on a toutes les tables (les enfants de la racine)
        List list = rootNode.getChildren("table");
        // Se recorre la lista de hijos de 'tables'
        for (int i = 0; i < list.size(); i++) {
            // Se obtiene el elemento 'tabla'
            // ici on a la première table
            Element tabla = (Element) list.get(i);
            // Se obtiene el atributo 'nombre' que esta en el tag 'tabla'
            // ici on a le nom de la table
            String nombreTabla = tabla.getAttributeValue("nom");
            System.out.println("Nom de la table : " + nombreTabla);
            // Se obtiene la lista de hijos del tag 'tabla'
            // 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++) {
                // Se obtiene el elemento 'campo'
                // ici on a une ligne de la table
                Element campo = (Element) lista_campos.get(j);
                // System.out.println("nouvelle ligne table "+ nombreTabla);
                for (Element colonne : campo.getChildren()) {
                    LineOfData lineOfData = new LineOfData();
                    // System.out.println("Nom de la colonne = " + colonne.getName());
                    // System.out.println("valeur de la colonne = " + colonne.getText());
                    lineOfData.setColomne(colonne.getName());
                    lineOfData.setValue(colonne.getText());
                    lineOfDatas.add(lineOfData);
                }
                insertLine(conn, lineOfDatas, nombreTabla);
                lineOfDatas.clear();
            }
        // / mettre à jour la table dans la BDD
        }
    } catch (IOException io) {
        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        System.out.println(jdomex.getMessage());
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) HikariDataSource(com.zaxxer.hikari.HikariDataSource) 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) File(java.io.File) Test(org.junit.Test)

Example 79 with Document

use of com.google.firestore.v1.Document in project ParadoxosModManager by ThibautSF.

the class MyXML method readFile.

// public MyXML(){}
/**
 * @param file
 * @throws IOException
 * @throws JDOMException
 * @throws Exception
 */
public void readFile(String file) throws JDOMException, IOException {
    SAXBuilder sxb = new SAXBuilder();
    File xml = new File(file);
    if (xml.exists()) {
        document = sxb.build(xml);
        root = document.getRootElement();
    } else {
        root = new Element(USER_LISTS);
        document = new Document(root);
    }
    // Init for export lists
    root_exported = new Element(EXPORTED_LIST);
    root_exported.setAttribute(GAME_ID, ModManager.STEAM_ID.toString());
    document_exported = new Document(root_exported);
    this.file = file;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File)

Example 80 with Document

use of com.google.firestore.v1.Document in project ParadoxosModManager by ThibautSF.

the class MyXML method readSettingFile.

/**
 * @param file
 * @throws Exception
 */
public void readSettingFile(String file) throws Exception {
    SAXBuilder sxb = new SAXBuilder();
    File xml = new File(file);
    if (xml.exists()) {
        document = sxb.build(xml);
        root = document.getRootElement();
    } else {
        root = new Element(APP_SETTINGS);
        document = new Document(root);
    }
    this.file = file;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File)

Aggregations

Document (org.jdom2.Document)396 Element (org.jdom2.Element)244 Test (org.junit.Test)116 SAXBuilder (org.jdom2.input.SAXBuilder)89 IOException (java.io.IOException)72 File (java.io.File)56 XMLOutputter (org.jdom2.output.XMLOutputter)56 JDOMException (org.jdom2.JDOMException)44 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)34 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)25 DocType (org.jdom2.DocType)24 ArrayList (java.util.ArrayList)23 MCRContent (org.mycore.common.content.MCRContent)22 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)22 Document (com.google.cloud.language.v1.Document)21 MCRException (org.mycore.common.MCRException)21 HashMap (java.util.HashMap)20 Attribute (org.jdom2.Attribute)19 MCRObject (org.mycore.datamodel.metadata.MCRObject)19 InputStream (java.io.InputStream)18