Search in sources :

Example 66 with Document

use of com.google.cloud.language.v1beta2.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 67 with Document

use of com.google.cloud.language.v1beta2.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 68 with Document

use of com.google.cloud.language.v1beta2.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 69 with Document

use of com.google.cloud.language.v1beta2.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_exportsGlobalSettingsWhenRequested.

@Test
public void exportPreferences_exportsGlobalSettingsWhenRequested() throws Exception {
    Document document = exportPreferences(true, Collections.<String>emptySet());
    assertNotNull(document.getRootElement().getChild("global"));
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Example 70 with Document

use of com.google.cloud.language.v1beta2.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_producesXML.

@Test
public void exportPreferences_producesXML() throws Exception {
    Document document = exportPreferences(false, Collections.<String>emptySet());
    assertEquals("k9settings", document.getRootElement().getName());
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)109 Element (org.jdom2.Element)74 SAXBuilder (org.jdom2.input.SAXBuilder)34 File (java.io.File)32 Test (org.junit.Test)29 DocType (org.jdom2.DocType)23 IOException (java.io.IOException)22 XMLOutputter (org.jdom2.output.XMLOutputter)20 JDOMException (org.jdom2.JDOMException)14 ProcessingInstruction (org.jdom2.ProcessingInstruction)13 XmlFile (jmri.jmrit.XmlFile)11 Document (com.google.cloud.language.v1beta2.Document)10 ApiException (com.google.api.gax.grpc.ApiException)9 Document (com.google.cloud.language.v1.Document)9 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)9 StatusRuntimeException (io.grpc.StatusRuntimeException)9 FileOutputStream (java.io.FileOutputStream)9 EncodingType (com.google.cloud.language.v1beta2.EncodingType)8 ArrayList (java.util.ArrayList)7 EncodingType (com.google.cloud.language.v1.EncodingType)6