Example usage for org.dom4j.io XMLWriter close

List of usage examples for org.dom4j.io XMLWriter close

Introduction

In this page you can find the example usage for org.dom4j.io XMLWriter close.

Prototype

public void close() throws IOException 

Source Link

Document

Closes the underlying Writer

Usage

From source file:skoa.views.ModificarNombreVivienda.java

License:Open Source License

public static void main() {
    llamado = 1;/*from  w  w w .ja v a 2s  . com*/

    MOSTRAR_CONFIGURACION.setViewportView(Arbol.generarArbol());

    FRAME_MODIFICAR_VIVIENDA.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    FRAME_MODIFICAR_VIVIENDA.setTitle(resourceMap.getString("FRAME_MODIFICAR_VIVIENDA.title"));
    FRAME_MODIFICAR_VIVIENDA.setResizable(true);
    FRAME_MODIFICAR_VIVIENDA.setSize(900, 600);
    FRAME_MODIFICAR_VIVIENDA.setLocation(120, 20);
    FRAME_MODIFICAR_VIVIENDA.addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            FRAME_MODIFICAR_VIVIENDA.setVisible(false);
            try {
                if (ConfiguracionProyecto.llamado == 0) {
                    ConfiguracionProyecto.main();
                } else {
                    ConfiguracionProyecto.FRAME_CONFIGURACION.setVisible(true);
                    //Arbol.generarArbol();
                    //ConfiguracionProyecto.ARBOL_CONFIGURACION = Arbol.MOSTRAR_CONFIGURACION;
                }

            } catch (DocumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    //Solicitar email
    JLabel etiquetaModificarVivienda = new JLabel();
    etiquetaModificarVivienda.setText(resourceMap.getString("etiquetaModificarVivienda.text"));

    //Recoger email
    ModificarNombreVivienda.nombre_vivienda.setColumns(15);
    ModificarNombreVivienda.nombre_vivienda.setCaretPosition(0);
    ModificarNombreVivienda.nombre_vivienda.setText("");
    ModificarNombreVivienda.nombre_vivienda.setSelectionEnd(-1);
    ModificarNombreVivienda.nombre_vivienda.setSelectionStart(-1);

    nombre_vivienda.setText("");
    nombre_vivienda.setSize(250, 20);

    nombre_vivienda.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {

            String aux = ((JTextField) e.getSource()).getText(); //lee texto escrito
            ModificarNombreVivienda.nombre = aux;

        }//end focuslost

        public void focusGained(FocusEvent e) {
            // No hacemos nada
        }
    });

    JButton botonModidicarVivienda = new JButton(resourceMap.getString("botonModidicarVivienda.text"));
    botonModidicarVivienda.setSize(40, 20);
    botonModidicarVivienda.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                File f = new File(NuevoProyecto.archivo);

                if (!f.exists()) {
                    if (!ModificarNombreVivienda.nombre.equals("")) {
                        if (!ModificarNombreVivienda.imagen_viv.equals("")) {
                            Document documento = DocumentHelper.createDocument();
                            org.dom4j.Element root = documento.addElement("vivienda");
                            root.addAttribute("name", ModificarNombreVivienda.nombre);
                            root.addAttribute("logo", ModificarNombreVivienda.imagen_viv);
                            root.addAttribute("contador", "1");

                            FileWriter archivo = new FileWriter(NuevoProyecto.archivo, true);
                            OutputFormat format = OutputFormat.createPrettyPrint();

                            //format.setEncoding("UTF-8");
                            format.setEncoding("iso-8859-1");

                            XMLWriter writer = new XMLWriter(archivo, format);

                            writer.write(documento);
                            writer.close();
                            String mostrar = "Se ha modificado el nombre e imagen de la vivienda";
                            mostrar += "\n";
                            mostrar += "en el fichero de configuracin";
                            JOptionPane.showMessageDialog(null, mostrar, "Informacin", 1);

                            try {

                                File aFile = new File(NuevoProyecto.archivo);
                                SAXReader xmlReader = new SAXReader();
                                //xmlReader.setEncoding("UTF-8");
                                xmlReader.setEncoding("iso-8859-1");
                                Document doc = xmlReader.read(aFile);
                                Element node = (Element) doc.selectSingleNode("//vivienda/email");

                                ModificarNombreVivienda.nombreviv.setText("Nombre Actual de la vivienda:       "
                                        + ModificarNombreVivienda.nombre);

                                MOSTRAR_CONFIGURACION.setViewportView(Arbol.generarArbol());

                                ModificarNombreVivienda.nombre_vivienda.setColumns(0);
                                ModificarNombreVivienda.nombre_vivienda.setCaretPosition(0);
                                ModificarNombreVivienda.nombre_vivienda.setText("");
                                ModificarNombreVivienda.nombre_vivienda.setSelectionEnd(-1);
                                ModificarNombreVivienda.nombre_vivienda.setSelectionStart(-1);

                            } catch (DocumentException e1) {
                                e1.printStackTrace();
                            }

                        } else {
                            String mostrar = "Se esta creando el fichero.";
                            mostrar += "\n";
                            mostrar += "Debe selecciona una imagen para la vivienda";
                            JOptionPane.showMessageDialog(null, mostrar, "Alerta", 1);
                        }
                    } else {
                        String mostrar = "Debe introducir un nombre para la vivienda";
                        JOptionPane.showMessageDialog(null, mostrar, "Alerta", 1);
                    }
                } else {
                    navegar();

                } //end else

            } catch (IOException e2) {
                e2.printStackTrace();
            }

        }
    });

    JSeparator jSeparatorV = new javax.swing.JSeparator();
    jSeparatorV.setOrientation(javax.swing.SwingConstants.VERTICAL);

    JSeparator jSeparatorH = new javax.swing.JSeparator();

    Label etiquetaArbol = new java.awt.Label();
    etiquetaArbol.setText(resourceMap.getString("etiquetaArbol.text"));

    JMenuBar jMenuBar1 = new javax.swing.JMenuBar();

    JMenu jMenuUsando = new javax.swing.JMenu();
    jMenuUsando.setText(resourceMap.getString("jMenuUsando.text") + NuevoProyecto.nombre_archivo);
    jMenuUsando.setEnabled(false);
    jMenuBar1.add(jMenuUsando);

    jMenuBar1.add(jMenuUsando);
    FRAME_MODIFICAR_VIVIENDA.setJMenuBar(jMenuBar1);

    try {

        File aFile = new File(NuevoProyecto.archivo);
        SAXReader xmlReader = new SAXReader();
        //xmlReader.setEncoding("UTF-8");
        xmlReader.setEncoding("iso-8859-1");
        Document doc = xmlReader.read(aFile);
        Element node = (Element) doc.selectSingleNode("//vivienda");

        nombreviv.setText(resourceMap.getString("etiquetaViviendaActual.text") + node.valueOf("@name"));
        nombreviv.setSize(150, 30);
    } catch (DocumentException e) {
        e.printStackTrace();
    }

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
            ModificarNombreVivienda.FRAME_MODIFICAR_VIVIENDA.getContentPane());
    ModificarNombreVivienda.FRAME_MODIFICAR_VIVIENDA.getContentPane().setLayout(layout);

    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(MOSTRAR_CONFIGURACION, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(2, 2, 2)) // .addComponent(scrollbar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jSeparatorH, javax.swing.GroupLayout.PREFERRED_SIZE, 135,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(5, 5, 5).addComponent(etiquetaArbol, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(10, 10, 10)
                    .addComponent(jSeparatorV, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addGap(50, 50, 50)
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup() //                                      .addComponent(mensaje2)
                                                    .addGap(400, 400, 400).addComponent(botonModidicarVivienda))
                                            .addGroup(layout.createSequentialGroup()
                                                    .addComponent(etiquetaModificarVivienda).addGap(18, 18, 18)
                                                    .addComponent(nombre_vivienda,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(layout.createSequentialGroup().addGap(50, 50, 50)
                                                    .addComponent(nombreviv,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)) //                                .addGroup(layout.createSequentialGroup()
            )))).addGroup(layout.createSequentialGroup().addContainerGap(145, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparatorV, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, 8, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() //                  .addContainerGap()
                    .addGap(55, 55, 55)
                    .addComponent(etiquetaArbol, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jSeparatorH, javax.swing.GroupLayout.DEFAULT_SIZE, 7,
                            javax.swing.GroupLayout.DEFAULT_SIZE)
                    .addComponent(MOSTRAR_CONFIGURACION, javax.swing.GroupLayout.DEFAULT_SIZE, 450,
                            javax.swing.GroupLayout.DEFAULT_SIZE)
                    .addGap(175, 175, 175).addContainerGap())
            .addGroup(layout.createSequentialGroup().addGap(100, 100, 100)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nombreviv, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(55, 55, 55))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(etiquetaModificarVivienda)
                            .addComponent(nombre_vivienda, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botonModidicarVivienda))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) //                        .addComponent(imagen_vivienda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    ).addContainerGap().addGap(50, 50, 50).addContainerGap()));

    FRAME_MODIFICAR_VIVIENDA.setVisible(true);

}

From source file:skoa.views.ModificarNombreVivienda.java

License:Open Source License

private static void navegar() {

    try {//ww w  .j a v a  2 s  .co  m

        File aFile = new File(NuevoProyecto.archivo);
        SAXReader xmlReader = new SAXReader();
        //xmlReader.setEncoding("UTF-8");
        xmlReader.setEncoding("iso-8859-1");
        Document doc = xmlReader.read(aFile);

        if (!ModificarNombreVivienda.nombre.equals("")) {
            Element node = (Element) doc.selectSingleNode("//vivienda");//[@nombre]" );
            Attribute atributo = node.attribute("name");
            atributo.setText(ModificarNombreVivienda.nombre);

            if (!ModificarNombreVivienda.imagen_viv.equals("")) {
                Attribute atributo2 = node.attribute("logo");
                atributo2.setText(ModificarNombreVivienda.imagen_viv);

                String mostrar = "Se ha modificado el nombre e imagen de la vivienda";
                mostrar += "\n";
                mostrar += "en el fichero de configuracin";
                JOptionPane.showMessageDialog(null, mostrar, "Informacin", 1);
                Arbol.generarArbol();
            } else {
                String mostrar = "Se ha modificado el nombre de la vivienda";
                mostrar += "\n";
                mostrar += "en el fichero de configuracin";
                JOptionPane.showMessageDialog(null, mostrar, "Informacin", 1);
                Arbol.generarArbol();
            }

            try {

                File aFile1 = new File(NuevoProyecto.archivo);
                SAXReader xmlReader1 = new SAXReader();
                //xmlReader1.setEncoding("UTF-8");
                xmlReader1.setEncoding("iso-8859-1");
                Document doc1 = xmlReader1.read(aFile1);
                Element node1 = (Element) doc1.selectSingleNode("//vivienda/email");

                ModificarNombreVivienda.nombreviv.setText(
                        resourceMap.getString("etiquetaViviendaActual.text") + ModificarNombreVivienda.nombre);

            } catch (DocumentException e1) {
                e1.printStackTrace();
            }

        } else {
            String mostrar = "Ha de introducir un nombre para la vivienda";
            JOptionPane.showMessageDialog(null, mostrar, "Alerta", 1);
        }

        String aux = doc.asXML();
        FileWriter archivo;

        archivo = new FileWriter(NuevoProyecto.archivo);
        OutputFormat format = OutputFormat.createPrettyPrint();

        //format.setEncoding("UTF-8");
        format.setEncoding("iso-8859-1");

        XMLWriter writer = new XMLWriter(new FileWriter(NuevoProyecto.archivo));
        writer.write(doc);
        writer.close();

    } catch (IOException e) {
        e.printStackTrace();

    } catch (DocumentException e) {
        e.printStackTrace();
    }

}

From source file:skoa.views.NuevoProyecto.java

License:Open Source License

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

    nombre_archivo = nombreFichero.getText() + ".xml";
    //archivo = archivo + "\\" + nombre_archivo;
    if (ruta.getText().equals("")) {
        archivo = "." + File.separator + nombre_archivo;
    } else {/*from   w ww  .ja  va2s.c om*/
        archivo = ruta.getText() + File.separator + nombre_archivo;
    }

    nombre_vivienda_fichero = nombre_viv.getText();
    email_fichero = email.getText();

    String auxiliar;
    if (eshotel == false) {
        auxiliar = "Viv. ";
    } else {
        auxiliar = "Hotel ";
    }

    auxiliar = auxiliar + nombre_vivienda_fichero;

    try {
        Document documento = DocumentHelper.createDocument();
        org.dom4j.Element root = documento.addElement("vivienda");
        root.addAttribute("name", nombre_vivienda_fichero);
        root.addAttribute("logo", auxiliar);
        root.addAttribute("contador", "1");

        Element node = (Element) documento.selectSingleNode("//vivienda");//[@nombre]" );
        org.dom4j.Element anadir = node.addElement("email");//( "plantas" );

        node = (Element) documento.selectSingleNode("//vivienda/email");
        anadir = node.addAttribute("direccion", email_fichero);

        FileWriter archivoFW = new FileWriter(archivo, true);
        OutputFormat format = OutputFormat.createPrettyPrint();

        //format.setEncoding("UTF-8");
        format.setEncoding("iso-8859-1");

        XMLWriter writer = new XMLWriter(archivoFW, format);

        writer.write(documento);
        writer.close();

        String mostrar = "Se ha creado el nuevo fichero de";
        mostrar += "\n";
        mostrar += "configuracin: " + nombre_archivo;
        JOptionPane.showMessageDialog(null, mostrar, "Informacin", 1);

        cargarArchivo.setCaretPosition(0);
        cargarArchivo.setText("");

        email.setCaretPosition(0);
        email.setText("");

        nombre_viv.setCaretPosition(0);
        nombre_viv.setText("");

        nombreFichero.setCaretPosition(0);
        nombreFichero.setText("");

        ruta.setCaretPosition(0);
        ruta.setText("");
        ruta.setEnabled(false);

        this.dispose();
        ConfiguracionProyecto.main();

    } catch (IOException e2) {
        e2.printStackTrace();
    } catch (DocumentException e1) {

        e1.printStackTrace();
    }
}

From source file:skoa.views.PlantaNueva.java

License:Open Source License

private static void navegar() {
    try {//from   w ww  . j  a v a2  s .c o  m
        File aFile = new File(NuevoProyecto.archivo);
        SAXReader xmlReader = new SAXReader();

        xmlReader.setEncoding("UTF-8");
        //xmlReader.setEncoding("iso-8859-1");

        Document doc = xmlReader.read(aFile);

        Element node = (Element) doc.selectSingleNode("//vivienda/planta");

        if (node == null) {
            node = (Element) doc.selectSingleNode("//vivienda");//[@nombre]" );
            org.dom4j.Element anadir = node.addElement("planta");//( "plantas" );

            node = (Element) doc.selectSingleNode("//vivienda/planta");
            anadir = node.addAttribute("alias", PlantaNueva.nueva);// planta_nueva.nueva );
        } //end if
        else {
            node = (Element) doc.selectSingleNode("//vivienda");
            org.dom4j.Element anadir2 = node.addElement("planta").addAttribute("alias", PlantaNueva.nueva);

        } //end else

        OutputFormat format = OutputFormat.createPrettyPrint();
        format.setEncoding("iso-8859-1");

        XMLWriter writer = new XMLWriter(new FileWriter(NuevoProyecto.archivo), format);
        writer.write(doc);
        writer.close();

    } catch (IOException | DocumentException e) {
        e.printStackTrace();
    }

}

From source file:tw.edu.sju.ee.eea.module.iepe.project.IepeProjectProperties.java

License:Open Source License

public void write() {
    try {/*from w w  w .  j a v a 2 s.co m*/
        XMLWriter writer = new XMLWriter(new FileWriter(confFile));
        writer.write(doc);
        writer.close();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:us.mn.state.health.lims.audittrail.daoimpl.AuditTrailDAOImpl.java

License:Mozilla Public License

/**
 * Convert to xml format by reading the table bases on it's id (dom4j)
 * @param table the table name//  ww  w .  ja v a  2s . com
 * @param id the primary id
 * @return xml string
 */
public String getXML(String table, String id) throws LIMSRuntimeException {
    org.hibernate.Session session = HibernateUtil.getSession();
    org.hibernate.Session dom4jSession = session.getSession(org.hibernate.EntityMode.DOM4J);

    Element elem = (Element) dom4jSession.createQuery("from " + table + " where id=" + id).uniqueResult();
    java.io.StringWriter sw = new java.io.StringWriter();
    if (elem != null) {
        try {
            Document doc = DocumentHelper.createDocument();
            doc.add(elem);
            OutputFormat format = OutputFormat.createPrettyPrint();
            XMLWriter writer = new XMLWriter(sw, format);
            writer.write(doc);
            writer.flush();
            writer.close();

            return sw.toString();
        } catch (Exception e) {
            //buzilla 2154
            LogEvent.logError("AuditTrailDAOImpl", "getXML()", e.toString());
            throw new LIMSRuntimeException("Error in AuditTrail getXML()", e);
        }
    }
    return null;
}

From source file:us.wthr.jdem846.project.XmlProjectFileWriter.java

License:Apache License

/** A simple output implementation
 * //from  w w  w.ja v  a2s.c o m
 * @param projectModel
 * @param path
 */
public static void writeProject(ProjectModel projectModel, String path) throws IOException {
    log.info("Writing project file to " + path);

    Document doc = XmlProjectFileWriter.createDocument(projectModel);

    // lets write to a file
    OutputFormat format = OutputFormat.createPrettyPrint();

    XMLWriter writer = new XMLWriter(new FileWriter(path), format);
    writer.write(doc);
    writer.close();

}

From source file:utils.ComponentCreator.java

License:Open Source License

public ComponentCreator() {
    super("FREVO Component Creator");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.setSize(300, 300);
    this.setLocationRelativeTo(null);
    this.setResizable(false);

    typebox.setMaximumSize(new Dimension(250, 20));
    typebox.setSelectedIndex(-1);// select nothing
    typebox.addActionListener(new ActionListener() {

        @Override//from  w  w  w .  j  a  va 2  s.co  m
        public void actionPerformed(ActionEvent e) {
            istyped = true;
            check();
        }
    });

    namefield.setMinimumSize(new Dimension(250, 23));
    namefield.setMaximumSize(new Dimension(250, 23));
    DocumentListener myListener = new CheckListener(2);

    namefield.getDocument().addDocumentListener(myListener);

    packagefield.setMinimumSize(new Dimension(250, 23));
    packagefield.setMaximumSize(new Dimension(250, 23));
    DocumentListener packageListener = new CheckListener(4);

    packagefield.getDocument().addDocumentListener(packageListener);

    descriptionArea.setMinimumSize(new Dimension(250, 100));
    descriptionArea.setMaximumSize(new Dimension(250, 100));
    descriptionArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    descriptionArea.setLineWrap(true);
    // descriptionArea.setText("Enter component description");
    DocumentListener descListener = new CheckListener(3);
    descriptionArea.getDocument().addDocumentListener(descListener);

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    // frame layout
    layout.setVerticalGroup(layout.createSequentialGroup().addComponent(typelabel).addComponent(typebox)
            .addComponent(namelabel).addComponent(namefield).addComponent(packagelabel)
            .addComponent(packagefield).addComponent(descriptionlabel).addComponent(descriptionArea)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(createbutton)));

    layout.setHorizontalGroup(layout.createParallelGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER).addComponent(typelabel)
                    .addComponent(typebox).addComponent(namelabel).addComponent(namefield)
                    .addComponent(packagelabel).addComponent(packagefield).addComponent(descriptionlabel)
                    .addComponent(descriptionArea))
            .addGroup(layout.createSequentialGroup().addComponent(createbutton)));

    createbutton.setEnabled(false);
    pack();

    createbutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // create files
            String compname = namefield.getText();
            String dirname, dir = "";
            String packagename = packagefield.getText();
            String packagenamedir = packagename.replace('.', '/');

            int type = typebox.getSelectedIndex();
            File xmlfile = null;
            File classfile = null;

            try {
                // create component directory
                switch (type) {
                case 0: {
                    dir = "Components/Problems";
                    dirname = "./" + dir + "/" + compname;
                    // create component dir
                    new File(dirname).mkdir();

                    // create component package dir
                    new File("./" + dir + "/" + compname + "/" + packagenamedir).mkdirs();

                    // copy xml file to component dir
                    xmlfile = new File("./" + dir + "/" + compname + ".xml");
                    copyFile(new File("./src/utils/problemxml.template"), xmlfile);

                    // copy class file to package dir
                    classfile = new File(
                            "./" + dir + "/" + compname + "/" + packagenamedir + "/" + compname + ".java");
                    copyFile(new File("./src/utils/singleproblemclass.template"), classfile);
                    break;
                }
                case 1: {
                    dir = "Components/Problems";
                    dirname = "./" + dir + "/" + compname;
                    // create component dir
                    new File(dirname).mkdir();
                    // create component package dir
                    new File("./" + dir + "/" + compname + "/" + packagenamedir).mkdirs();

                    // copy xml file to component dir
                    xmlfile = new File("./" + dir + "/" + compname + ".xml");
                    copyFile(new File("./src/utils/problemxml.template"), xmlfile);

                    // copy class file to package dir
                    classfile = new File(
                            "./" + dir + "/" + compname + "/" + packagenamedir + "/" + compname + ".java");
                    copyFile(new File("./src/utils/multiproblemclass.template"), classfile);
                    break;
                }
                case 2: {
                    dir = "Components/Methods";
                    dirname = "./" + dir + "/" + compname;
                    // create component dir
                    new File(dirname).mkdir();
                    // create component package dir
                    new File("./" + dir + "/" + compname + "/" + packagenamedir).mkdirs();

                    // copy xml file to component dir
                    xmlfile = new File("./" + dir + "/" + compname + ".xml");
                    copyFile(new File("./src/utils/methodxml.template"), xmlfile);

                    // copy class file to package dir
                    classfile = new File(
                            "./" + dir + "/" + compname + "/" + packagenamedir + "/" + compname + ".java");
                    copyFile(new File("./src/utils/methodclass.template"), classfile);
                    break;
                }
                case 3: {
                    dir = "Components/Representations";
                    dirname = "./" + dir + "/" + compname;
                    // create component dir
                    new File(dirname).mkdir();
                    // create component package dir
                    new File("./" + dir + "/" + compname + "/" + packagenamedir).mkdirs();

                    // copy xml file to component dir
                    xmlfile = new File("./" + dir + "/" + compname + ".xml");
                    copyFile(new File("./src/utils/representationxml.template"), xmlfile);

                    // copy class file to package dir
                    classfile = new File(
                            "./" + dir + "/" + compname + "/" + packagenamedir + "/" + compname + ".java");
                    copyFile(new File("./src/utils/representationclass.template"), classfile);
                    break;
                }
                case 4: {
                    dir = "Components/Rankings";
                    dirname = "./" + dir + "/" + compname;
                    // create component dir
                    new File(dirname).mkdir();
                    // create component package dir
                    new File("./" + dir + "/" + compname + "/" + packagenamedir).mkdirs();

                    // copy xml file to component dir
                    xmlfile = new File("./" + dir + "/" + compname + ".xml");
                    copyFile(new File("./src/utils/rankingxml.template"), xmlfile);

                    // copy class file to package dir
                    classfile = new File(
                            "./" + dir + "/" + compname + "/" + packagenamedir + "/" + compname + ".java");
                    copyFile(new File("./src/utils/rankingclass.template"), classfile);
                    break;
                }
                }
                // replace TEMP in xml
                BufferedReader reader = new BufferedReader(new FileReader(xmlfile));
                String line = "", oldtext = "";
                while ((line = reader.readLine()) != null) {
                    oldtext += line + "\r\n";
                }
                reader.close();

                String newtext = oldtext.replaceAll("TEMPCLASSDIR", compname + "/" + packagename);
                newtext = newtext.replaceAll("TEMP", compname);
                newtext = newtext.replaceAll("TDESC", descriptionArea.getText());
                newtext = newtext.replaceAll("PACKAGE", packagename);

                FileWriter writer = new FileWriter(xmlfile);
                writer.write(newtext);
                writer.close();

                // replace TEMP in class
                reader = new BufferedReader(new FileReader(classfile));
                line = "";
                oldtext = "";
                while ((line = reader.readLine()) != null) {
                    oldtext += line + "\r\n";
                }
                reader.close();

                newtext = oldtext.replaceAll("TEMP", compname);
                newtext = newtext.replaceAll("PACKAGENAME", packagename);

                writer = new FileWriter(classfile);
                writer.write(newtext);
                writer.close();

                // Update classpath xml
                File classpath = new File(FrevoMain.getInstallDirectory() + File.separator + ".classpath");

                if (classpath.exists()) {
                    SAXReader xmlReader = new SAXReader(false);
                    Document doc = xmlReader.read(classpath);

                    doc.getRootElement().addElement("classpathentry").addAttribute("kind", "src")
                            .addAttribute("output", dir + "/" + compname)
                            .addAttribute("path", dir + "/" + compname);

                    OutputFormat format = OutputFormat.createPrettyPrint();
                    format.setLineSeparator(System.getProperty("line.separator"));

                    FileWriter out = new FileWriter(classpath);
                    BufferedWriter bw = new BufferedWriter(out);
                    XMLWriter wr = new XMLWriter(bw, format);
                    wr.write(doc);
                    wr.close();
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }

            // TODO compile newly created classfile

            JOptionPane.showMessageDialog(ComponentCreator.this, "Component " + compname
                    + " has been created! Please refresh your project in Eclipse for the changes to take effect!",
                    "Done!", JOptionPane.DEFAULT_OPTION);
            // add to classpath
            ComponentCreator.this.dispose();
        }
    });

}

From source file:zuora.ots_login_0_1.OTS_Login.java

License:Apache License

public void tFixedFlowInput_1Process(final java.util.Map<String, Object> globalMap) throws TalendException {
    globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 0);

    final boolean execStat = this.execStat;

    String iterateId = "";

    String currentComponent = "";
    java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>();

    try {/*www .  j  a  v a 2 s  .  c  o m*/

        String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName();
        boolean resumeIt = currentMethodName.equals(resumeEntryMethodName);
        if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start
            // the
            // resume
            globalResumeTicket = true;

            credentialsStruct credentials = new credentialsStruct();
            row1Struct row1 = new row1Struct();

            /**
             * [tFileOutputXML_1 begin ] start
             */

            ok_Hash.put("tFileOutputXML_1", false);
            start_Hash.put("tFileOutputXML_1", System.currentTimeMillis());

            currentComponent = "tFileOutputXML_1";

            int tos_count_tFileOutputXML_1 = 0;

            String originalFileName_tFileOutputXML_1 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/login.xml";
            java.io.File originalFile_tFileOutputXML_1 = new java.io.File(originalFileName_tFileOutputXML_1);

            String fileName_tFileOutputXML_1 = originalFileName_tFileOutputXML_1;
            java.io.File file_tFileOutputXML_1 = new java.io.File(fileName_tFileOutputXML_1);
            if (!file_tFileOutputXML_1.isAbsolute()) {
                file_tFileOutputXML_1 = file_tFileOutputXML_1.getCanonicalFile();
            }

            // create directory only if not exists

            file_tFileOutputXML_1.getParentFile().mkdirs();

            int nb_line_tFileOutputXML_1 = 0;
            org.dom4j.io.OutputFormat format_tFileOutputXML_1 = org.dom4j.io.OutputFormat.createPrettyPrint();
            format_tFileOutputXML_1.setEncoding("ISO-8859-15");
            format_tFileOutputXML_1.setNewLineAfterDeclaration(false);
            format_tFileOutputXML_1.setTrimText(false);
            org.dom4j.io.XMLWriter writer_tFileOutputXML_1 = new org.dom4j.io.XMLWriter(
                    new java.io.OutputStreamWriter(new java.io.FileOutputStream(file_tFileOutputXML_1),
                            "ISO-8859-15"),
                    format_tFileOutputXML_1);

            /**
             * [tFileOutputXML_1 begin ] stop
             */

            /**
             * [tSOAP_1 begin ] start
             */

            ok_Hash.put("tSOAP_1", false);
            start_Hash.put("tSOAP_1", System.currentTimeMillis());

            currentComponent = "tSOAP_1";

            int tos_count_tSOAP_1 = 0;

            org.talend.soap.SOAPUtil soapUtil_tSOAP_1 = new org.talend.soap.SOAPUtil();

            final String decryptedPassword_tSOAP_1 = routines.system.PasswordEncryptUtil
                    .decryptPassword("a54bbfcc1190b7e1f4f7aba1746784ea");

            /**
             * [tSOAP_1 begin ] stop
             */

            /**
             * [tFixedFlowInput_1 begin ] start
             */

            ok_Hash.put("tFixedFlowInput_1", false);
            start_Hash.put("tFixedFlowInput_1", System.currentTimeMillis());

            currentComponent = "tFixedFlowInput_1";

            int tos_count_tFixedFlowInput_1 = 0;

            for (int i_tFixedFlowInput_1 = 0; i_tFixedFlowInput_1 < 1; i_tFixedFlowInput_1++) {

                credentials.username = (String) globalMap.get("user");

                credentials.password = (String) globalMap.get("psw");

                /**
                 * [tFixedFlowInput_1 begin ] stop
                 */

                /**
                 * [tFixedFlowInput_1 main ] start
                 */

                currentComponent = "tFixedFlowInput_1";

                tos_count_tFixedFlowInput_1++;

                /**
                 * [tFixedFlowInput_1 main ] stop
                 */

                /**
                 * [tSOAP_1 main ] start
                 */

                currentComponent = "tSOAP_1";

                String document_tSOAP_1 = soapUtil_tSOAP_1.extractContentAsDocument(
                        org.talend.soap.SOAPUtil.SOAP11, "https://apisandbox.zuora.com/apps/services/a/75.0",
                        "http://api.zuora.com/login",
                        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:api=\"http://api.zuora.com/\">     <soapenv:Header/>     <soapenv:Body>        <api:login>           <api:username>"
                                + credentials.username + "</api:username>           <api:password>"
                                + credentials.password
                                + "</api:password>        </api:login>     </soapenv:Body>  </soapenv:Envelope>");

                // for output

                row1 = new row1Struct();

                row1.Soap = ParserUtils.parseTo_Document(document_tSOAP_1);

                tos_count_tSOAP_1++;

                /**
                 * [tSOAP_1 main ] stop
                 */

                /**
                 * [tFileOutputXML_1 main ] start
                 */

                currentComponent = "tFileOutputXML_1";

                nb_line_tFileOutputXML_1++;
                writer_tFileOutputXML_1.write(row1.Soap.getDocument());

                tos_count_tFileOutputXML_1++;

                /**
                 * [tFileOutputXML_1 main ] stop
                 */

                /**
                 * [tFixedFlowInput_1 end ] start
                 */

                currentComponent = "tFixedFlowInput_1";

            }
            globalMap.put("tFixedFlowInput_1_NB_LINE", 1);

            ok_Hash.put("tFixedFlowInput_1", true);
            end_Hash.put("tFixedFlowInput_1", System.currentTimeMillis());

            /**
             * [tFixedFlowInput_1 end ] stop
             */

            /**
             * [tSOAP_1 end ] start
             */

            currentComponent = "tSOAP_1";

            soapUtil_tSOAP_1.close();

            ok_Hash.put("tSOAP_1", true);
            end_Hash.put("tSOAP_1", System.currentTimeMillis());

            /**
             * [tSOAP_1 end ] stop
             */

            /**
             * [tFileOutputXML_1 end ] start
             */

            currentComponent = "tFileOutputXML_1";

            writer_tFileOutputXML_1.close();

            ok_Hash.put("tFileOutputXML_1", true);
            end_Hash.put("tFileOutputXML_1", System.currentTimeMillis());

            /**
             * [tFileOutputXML_1 end ] stop
             */

        } // end the resume

        if (resumeEntryMethodName == null || globalResumeTicket) {
            resumeUtil.addLog("CHECKPOINT", "CONNECTION:SUBJOB_OK:tFixedFlowInput_1:OnSubjobOk", "",
                    Thread.currentThread().getId() + "", "", "", "", "", "");
        }

        tFileInputXML_2Process(globalMap);

    } catch (java.lang.Exception e) {

        TalendException te = new TalendException(e, currentComponent, globalMap);

        throw te;
    } catch (java.lang.Error error) {

        throw error;
    } finally {

        try {

            /**
             * [tFixedFlowInput_1 finally ] start
             */

            currentComponent = "tFixedFlowInput_1";

            /**
             * [tFixedFlowInput_1 finally ] stop
             */

            /**
             * [tSOAP_1 finally ] start
             */

            currentComponent = "tSOAP_1";

            /**
             * [tSOAP_1 finally ] stop
             */

            /**
             * [tFileOutputXML_1 finally ] start
             */

            currentComponent = "tFileOutputXML_1";

            /**
             * [tFileOutputXML_1 finally ] stop
             */

        } catch (java.lang.Exception e) {
            // ignore
        } catch (java.lang.Error error) {
            // ignore
        }
        resourceMap = null;
    }

    globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 1);
}

From source file:zuora.ots_login_0_1.OTS_Login.java

License:Apache License

public void tFileInputXML_1Process(final java.util.Map<String, Object> globalMap) throws TalendException {
    globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 0);

    final boolean execStat = this.execStat;
    String currentVirtualComponent = null;

    String iterateId = "";

    String currentComponent = "";
    java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>();

    try {//from ww w.j ava2s. co m

        String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName();
        boolean resumeIt = currentMethodName.equals(resumeEntryMethodName);
        if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start
            // the
            // resume
            globalResumeTicket = true;

            row5Struct row5 = new row5Struct();

            /**
             * [tWriteJSONField_2_Out begin ] start
             */

            ok_Hash.put("tWriteJSONField_2_Out", false);
            start_Hash.put("tWriteJSONField_2_Out", System.currentTimeMillis());

            currentVirtualComponent = "tWriteJSONField_2";

            currentComponent = "tWriteJSONField_2_Out";

            int tos_count_tWriteJSONField_2_Out = 0;

            // tWriteXMLFieldOut_begin
            int nb_line_tWriteJSONField_2_Out = 0;
            boolean needRoot_tWriteJSONField_2_Out = true;

            String strCompCache_tWriteJSONField_2_Out = null;

            java.util.Queue<row3Struct> listGroupby_tWriteJSONField_2_Out = new java.util.concurrent.ConcurrentLinkedQueue<row3Struct>();

            class ThreadXMLField_tWriteJSONField_2_Out extends Thread {

                java.util.Queue<row3Struct> queue;

                java.util.List<java.util.Map<String, String>> flows;
                java.lang.Exception lastException;
                String currentComponent;

                ThreadXMLField_tWriteJSONField_2_Out(java.util.Queue q) {
                    this.queue = q;
                    globalMap.put("queue_tWriteJSONField_2_In", queue);
                    lastException = null;
                }

                ThreadXMLField_tWriteJSONField_2_Out(java.util.Queue q,
                        java.util.List<java.util.Map<String, String>> l) {
                    this.queue = q;
                    this.flows = l;
                    lastException = null;
                    globalMap.put("queue_tWriteJSONField_2_In", queue);
                    globalMap.put("flows_tWriteJSONField_2_In", flows);
                }

                public java.lang.Exception getLastException() {
                    return this.lastException;
                }

                public String getCurrentComponent() {
                    return this.currentComponent;
                }

                @Override
                public void run() {
                    try {
                        tWriteJSONField_2_InProcess(globalMap);
                    } catch (TalendException te) {
                        this.lastException = te.getException();
                        this.currentComponent = te.getCurrentComponent();
                    }
                }
            }

            ThreadXMLField_tWriteJSONField_2_Out txf_tWriteJSONField_2_Out = new ThreadXMLField_tWriteJSONField_2_Out(
                    listGroupby_tWriteJSONField_2_Out);

            txf_tWriteJSONField_2_Out.start();

            java.util.List<java.util.List<String>> groupbyList_tWriteJSONField_2_Out = new java.util.ArrayList<java.util.List<String>>();
            java.util.Map<String, String> valueMap_tWriteJSONField_2_Out = new java.util.HashMap<String, String>();

            class NestXMLTool_tWriteJSONField_2_Out {
                public void parseAndAdd(org.dom4j.Element nestRoot, String value) {
                    try {
                        org.dom4j.Document doc4Str = org.dom4j.DocumentHelper
                                .parseText("<root>" + value + "</root>");
                        nestRoot.setContent(doc4Str.getRootElement().content());
                    } catch (java.lang.Exception e) {
                        e.printStackTrace();
                        nestRoot.setText(value);
                    }
                }

                public void setText(org.dom4j.Element element, String value) {
                    if (value.startsWith("<![CDATA[") && value.endsWith("]]>")) {
                        String text = value.substring(9, value.length() - 3);
                        element.addCDATA(text);
                    } else {
                        element.setText(value);
                    }
                }

                public void replaceDefaultNameSpace(org.dom4j.Element nestRoot) {
                    if (nestRoot != null) {
                        for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) nestRoot.elements()) {
                            if (("").equals(tmp.getQName().getNamespace().getURI())
                                    && ("").equals(tmp.getQName().getNamespace().getPrefix())) {
                                tmp.setQName(org.dom4j.DocumentHelper.createQName(tmp.getName(),
                                        nestRoot.getQName().getNamespace()));
                            }
                            replaceDefaultNameSpace(tmp);
                        }
                    }
                }

                public void removeEmptyElement(org.dom4j.Element root) {
                    if (root != null) {
                        for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) root.elements()) {
                            removeEmptyElement(tmp);
                        }
                        if (root.content().size() == 0 && root.attributes().size() == 0
                                && root.declaredNamespaces().size() == 0) {
                            if (root.getParent() != null) {
                                root.getParent().remove(root);
                            }
                        }
                    }
                }
            }
            NestXMLTool_tWriteJSONField_2_Out nestXMLTool_tWriteJSONField_2_Out = new NestXMLTool_tWriteJSONField_2_Out();

            row5Struct rowStructOutput_tWriteJSONField_2_Out = null;
            // sort group root element for judgement of group
            java.util.List<org.dom4j.Element> groupElementList_tWriteJSONField_2_Out = new java.util.ArrayList<org.dom4j.Element>();
            org.dom4j.Element root4Group_tWriteJSONField_2_Out = null;
            org.dom4j.Document doc_tWriteJSONField_2_Out = org.dom4j.DocumentHelper.createDocument();
            org.dom4j.io.OutputFormat format_tWriteJSONField_2_Out = org.dom4j.io.OutputFormat
                    .createCompactFormat();
            format_tWriteJSONField_2_Out.setNewLineAfterDeclaration(false);
            format_tWriteJSONField_2_Out.setTrimText(false);
            format_tWriteJSONField_2_Out.setEncoding("ISO-8859-15");
            int[] orders_tWriteJSONField_2_Out = new int[1];

            /**
             * [tWriteJSONField_2_Out begin ] stop
             */

            /**
             * [tFileInputXML_1 begin ] start
             */

            ok_Hash.put("tFileInputXML_1", false);
            start_Hash.put("tFileInputXML_1", System.currentTimeMillis());

            currentComponent = "tFileInputXML_1";

            int tos_count_tFileInputXML_1 = 0;

            int nb_line_tFileInputXML_1 = 0;

            String os_tFileInputXML_1 = System.getProperty("os.name").toLowerCase();
            boolean isWindows_tFileInputXML_1 = false;
            if (os_tFileInputXML_1.indexOf("windows") > -1 || os_tFileInputXML_1.indexOf("nt") > -1) {
                isWindows_tFileInputXML_1 = true;
            }
            class NameSpaceTool_tFileInputXML_1 {

                public java.util.HashMap<String, String> xmlNameSpaceMap = new java.util.HashMap<String, String>();

                private java.util.List<String> defualtNSPath = new java.util.ArrayList<String>();

                public void countNSMap(org.dom4j.Element el) {
                    for (org.dom4j.Namespace ns : (java.util.List<org.dom4j.Namespace>) el
                            .declaredNamespaces()) {
                        if (ns.getPrefix().trim().length() == 0) {
                            xmlNameSpaceMap.put("pre" + defualtNSPath.size(), ns.getURI());
                            String path = "";
                            org.dom4j.Element elTmp = el;
                            while (elTmp != null) {
                                if (elTmp.getNamespacePrefix() != null
                                        && elTmp.getNamespacePrefix().length() > 0) {
                                    path = "/" + elTmp.getNamespacePrefix() + ":" + elTmp.getName() + path;
                                } else {
                                    path = "/" + elTmp.getName() + path;
                                }
                                elTmp = elTmp.getParent();
                            }
                            defualtNSPath.add(path);
                        } else {
                            xmlNameSpaceMap.put(ns.getPrefix(), ns.getURI());
                        }

                    }
                    for (org.dom4j.Element e : (java.util.List<org.dom4j.Element>) el.elements()) {
                        countNSMap(e);
                    }
                }

                private final org.talend.xpath.XPathUtil util = new org.talend.xpath.XPathUtil();

                {
                    util.setDefaultNSPath(defualtNSPath);
                }

                public String addDefaultNSPrefix(String path) {
                    return util.addDefaultNSPrefix(path);
                }

                public String addDefaultNSPrefix(String relativeXpression, String basePath) {
                    return util.addDefaultNSPrefix(relativeXpression, basePath);
                }

            }

            class XML_API_tFileInputXML_1 {
                public boolean isDefNull(org.dom4j.Node node) throws javax.xml.transform.TransformerException {
                    if (node != null && node instanceof org.dom4j.Element) {
                        org.dom4j.Attribute attri = ((org.dom4j.Element) node).attribute("nil");
                        if (attri != null && ("true").equals(attri.getText())) {
                            return true;
                        }
                    }
                    return false;
                }

                public boolean isMissing(org.dom4j.Node node) throws javax.xml.transform.TransformerException {
                    return node == null ? true : false;
                }

                public boolean isEmpty(org.dom4j.Node node) throws javax.xml.transform.TransformerException {
                    if (node != null) {
                        return node.getText().length() == 0;
                    }
                    return false;
                }
            }

            org.dom4j.io.SAXReader reader_tFileInputXML_1 = new org.dom4j.io.SAXReader();
            Object filename_tFileInputXML_1 = null;
            try {
                filename_tFileInputXML_1 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/login.xml";
            } catch (java.lang.Exception e) {

                System.err.println(e.getMessage());

            }
            if (filename_tFileInputXML_1 != null && filename_tFileInputXML_1 instanceof String
                    && filename_tFileInputXML_1.toString().startsWith("//")) {
                if (!isWindows_tFileInputXML_1) {
                    filename_tFileInputXML_1 = filename_tFileInputXML_1.toString().replaceFirst("//", "/");
                }
            }

            boolean isValidFile_tFileInputXML_1 = true;
            org.dom4j.Document doc_tFileInputXML_1 = null;
            java.io.Closeable toClose_tFileInputXML_1 = null;
            try {
                if (filename_tFileInputXML_1 instanceof java.io.InputStream) {
                    java.io.InputStream inputStream_tFileInputXML_1 = (java.io.InputStream) filename_tFileInputXML_1;
                    toClose_tFileInputXML_1 = inputStream_tFileInputXML_1;
                    doc_tFileInputXML_1 = reader_tFileInputXML_1.read(inputStream_tFileInputXML_1);
                } else {
                    java.io.Reader unicodeReader_tFileInputXML_1 = new UnicodeReader(
                            new java.io.FileInputStream(String.valueOf(filename_tFileInputXML_1)),
                            "ISO-8859-15");
                    toClose_tFileInputXML_1 = unicodeReader_tFileInputXML_1;
                    org.xml.sax.InputSource in_tFileInputXML_1 = new org.xml.sax.InputSource(
                            unicodeReader_tFileInputXML_1);
                    doc_tFileInputXML_1 = reader_tFileInputXML_1.read(in_tFileInputXML_1);
                }
            } catch (java.lang.Exception e) {

                System.err.println(e.getMessage());
                isValidFile_tFileInputXML_1 = false;
            } finally {
                if (toClose_tFileInputXML_1 != null) {
                    toClose_tFileInputXML_1.close();
                }
            }
            if (isValidFile_tFileInputXML_1) {
                NameSpaceTool_tFileInputXML_1 nsTool_tFileInputXML_1 = new NameSpaceTool_tFileInputXML_1();
                nsTool_tFileInputXML_1.countNSMap(doc_tFileInputXML_1.getRootElement());
                java.util.HashMap<String, String> xmlNameSpaceMap_tFileInputXML_1 = nsTool_tFileInputXML_1.xmlNameSpaceMap;

                org.dom4j.XPath x_tFileInputXML_1 = doc_tFileInputXML_1.createXPath(nsTool_tFileInputXML_1
                        .addDefaultNSPrefix("/soapenv:Envelope/soapenv:Body/soapenv:Fault"));
                x_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1);

                java.util.List<org.dom4j.tree.AbstractNode> nodeList_tFileInputXML_1 = (java.util.List<org.dom4j.tree.AbstractNode>) x_tFileInputXML_1
                        .selectNodes(doc_tFileInputXML_1);
                XML_API_tFileInputXML_1 xml_api_tFileInputXML_1 = new XML_API_tFileInputXML_1();
                String str_tFileInputXML_1 = "";
                org.dom4j.Node node_tFileInputXML_1 = null;

                // init all mapping xpaths
                for (org.dom4j.tree.AbstractNode temp_tFileInputXML_1 : nodeList_tFileInputXML_1) {
                    nb_line_tFileInputXML_1++;
                    row5 = null;
                    boolean whetherReject_tFileInputXML_1 = false;
                    row5 = new row5Struct();
                    try {
                        org.dom4j.XPath xTmp0_tFileInputXML_1 = org.dom4j.DocumentHelper
                                .createXPath(nsTool_tFileInputXML_1.addDefaultNSPrefix("faultcode",
                                        "/soapenv:Envelope/soapenv:Body/soapenv:Fault"));
                        xTmp0_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1);
                        Object obj0_tFileInputXML_1 = xTmp0_tFileInputXML_1.evaluate(temp_tFileInputXML_1);
                        if (obj0_tFileInputXML_1 == null) {
                            node_tFileInputXML_1 = null;
                            str_tFileInputXML_1 = "";

                        } else if (obj0_tFileInputXML_1 instanceof org.dom4j.Node) {
                            node_tFileInputXML_1 = (org.dom4j.Node) obj0_tFileInputXML_1;
                            str_tFileInputXML_1 = org.jaxen.function.StringFunction.evaluate(
                                    node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance());
                        } else if (obj0_tFileInputXML_1 instanceof String
                                || obj0_tFileInputXML_1 instanceof Number) {
                            node_tFileInputXML_1 = temp_tFileInputXML_1;
                            str_tFileInputXML_1 = String.valueOf(obj0_tFileInputXML_1);
                        } else if (obj0_tFileInputXML_1 instanceof java.util.List) {
                            java.util.List<org.dom4j.Node> nodes_tFileInputXML_1 = (java.util.List<org.dom4j.Node>) obj0_tFileInputXML_1;
                            node_tFileInputXML_1 = nodes_tFileInputXML_1.size() > 0
                                    ? nodes_tFileInputXML_1.get(0)
                                    : null;
                            str_tFileInputXML_1 = node_tFileInputXML_1 == null ? ""
                                    : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_1,
                                            org.jaxen.dom4j.DocumentNavigator.getInstance());
                        }
                        if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) {
                            row5.faultcode = null;
                        } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) {
                            row5.faultcode = "";
                        } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) {
                            row5.faultcode = null;
                        } else {
                            row5.faultcode = str_tFileInputXML_1;
                        }
                        org.dom4j.XPath xTmp1_tFileInputXML_1 = org.dom4j.DocumentHelper
                                .createXPath(nsTool_tFileInputXML_1.addDefaultNSPrefix("faultstring",
                                        "/soapenv:Envelope/soapenv:Body/soapenv:Fault"));
                        xTmp1_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1);
                        Object obj1_tFileInputXML_1 = xTmp1_tFileInputXML_1.evaluate(temp_tFileInputXML_1);
                        if (obj1_tFileInputXML_1 == null) {
                            node_tFileInputXML_1 = null;
                            str_tFileInputXML_1 = "";

                        } else if (obj1_tFileInputXML_1 instanceof org.dom4j.Node) {
                            node_tFileInputXML_1 = (org.dom4j.Node) obj1_tFileInputXML_1;
                            str_tFileInputXML_1 = org.jaxen.function.StringFunction.evaluate(
                                    node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance());
                        } else if (obj1_tFileInputXML_1 instanceof String
                                || obj1_tFileInputXML_1 instanceof Number) {
                            node_tFileInputXML_1 = temp_tFileInputXML_1;
                            str_tFileInputXML_1 = String.valueOf(obj1_tFileInputXML_1);
                        } else if (obj1_tFileInputXML_1 instanceof java.util.List) {
                            java.util.List<org.dom4j.Node> nodes_tFileInputXML_1 = (java.util.List<org.dom4j.Node>) obj1_tFileInputXML_1;
                            node_tFileInputXML_1 = nodes_tFileInputXML_1.size() > 0
                                    ? nodes_tFileInputXML_1.get(0)
                                    : null;
                            str_tFileInputXML_1 = node_tFileInputXML_1 == null ? ""
                                    : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_1,
                                            org.jaxen.dom4j.DocumentNavigator.getInstance());
                        }
                        if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) {
                            row5.faultstring = null;
                        } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) {
                            row5.faultstring = "";
                        } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) {
                            row5.faultstring = null;
                        } else {
                            row5.faultstring = str_tFileInputXML_1;
                        }

                    } catch (java.lang.Exception e) {
                        whetherReject_tFileInputXML_1 = true;
                        System.err.println(e.getMessage());
                        row5 = null;
                    }

                    if (nb_line_tFileInputXML_1 > 50) {

                        break;
                    }

                    /**
                     * [tFileInputXML_1 begin ] stop
                     */

                    /**
                     * [tFileInputXML_1 main ] start
                     */

                    currentComponent = "tFileInputXML_1";

                    tos_count_tFileInputXML_1++;

                    /**
                     * [tFileInputXML_1 main ] stop
                     */
                    // Start of branch "row5"
                    if (row5 != null) {

                        /**
                         * [tWriteJSONField_2_Out main ] start
                         */

                        currentVirtualComponent = "tWriteJSONField_2";

                        currentComponent = "tWriteJSONField_2_Out";

                        if (txf_tWriteJSONField_2_Out.getLastException() != null) {
                            currentComponent = txf_tWriteJSONField_2_Out.getCurrentComponent();
                            throw txf_tWriteJSONField_2_Out.getLastException();
                        }
                        nb_line_tWriteJSONField_2_Out++;
                        valueMap_tWriteJSONField_2_Out.clear();
                        valueMap_tWriteJSONField_2_Out.put("faultcode",
                                (row5.faultcode != null ? row5.faultcode.toString() : null));
                        valueMap_tWriteJSONField_2_Out.put("faultstring",
                                (row5.faultstring != null ? row5.faultstring.toString() : null));
                        String strTemp_tWriteJSONField_2_Out = "";
                        strTemp_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out
                                + valueMap_tWriteJSONField_2_Out.get("faultcode")
                                + valueMap_tWriteJSONField_2_Out.get("faultcode").length();
                        strTemp_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out
                                + valueMap_tWriteJSONField_2_Out.get("faultstring")
                                + valueMap_tWriteJSONField_2_Out.get("faultstring").length();
                        if (strCompCache_tWriteJSONField_2_Out == null) {
                            strCompCache_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out;

                            rowStructOutput_tWriteJSONField_2_Out = row5;

                        } else {
                            // the data read is different from the data read
                            // last time.
                            if (strCompCache_tWriteJSONField_2_Out
                                    .equals(strTemp_tWriteJSONField_2_Out) == false) {
                                nestXMLTool_tWriteJSONField_2_Out
                                        .replaceDefaultNameSpace(doc_tWriteJSONField_2_Out.getRootElement());
                                java.io.StringWriter strWriter_tWriteJSONField_2_Out = new java.io.StringWriter();
                                org.dom4j.io.XMLWriter output_tWriteJSONField_2_Out = new org.dom4j.io.XMLWriter(
                                        strWriter_tWriteJSONField_2_Out, format_tWriteJSONField_2_Out);
                                output_tWriteJSONField_2_Out.write(doc_tWriteJSONField_2_Out);
                                output_tWriteJSONField_2_Out.close();

                                row3Struct row_tWriteJSONField_2_Out = new row3Struct();

                                row_tWriteJSONField_2_Out.result = strWriter_tWriteJSONField_2_Out.toString();
                                listGroupby_tWriteJSONField_2_Out.add(row_tWriteJSONField_2_Out);

                                doc_tWriteJSONField_2_Out.clearContent();
                                needRoot_tWriteJSONField_2_Out = true;
                                for (int i_tWriteJSONField_2_Out = 0; i_tWriteJSONField_2_Out < orders_tWriteJSONField_2_Out.length; i_tWriteJSONField_2_Out++) {
                                    orders_tWriteJSONField_2_Out[i_tWriteJSONField_2_Out] = 0;
                                }

                                if (groupbyList_tWriteJSONField_2_Out != null
                                        && groupbyList_tWriteJSONField_2_Out.size() >= 0) {
                                    groupbyList_tWriteJSONField_2_Out.clear();
                                }
                                strCompCache_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out;
                                rowStructOutput_tWriteJSONField_2_Out = row5;

                            }
                        }

                        org.dom4j.Element subTreeRootParent_tWriteJSONField_2_Out = null;

                        // build root xml tree
                        if (needRoot_tWriteJSONField_2_Out) {
                            needRoot_tWriteJSONField_2_Out = false;
                            org.dom4j.Element root_tWriteJSONField_2_Out = doc_tWriteJSONField_2_Out
                                    .addElement("result");
                            subTreeRootParent_tWriteJSONField_2_Out = root_tWriteJSONField_2_Out;
                            org.dom4j.Element root_0_tWriteJSONField_2_Out = root_tWriteJSONField_2_Out
                                    .addElement("faultstring");
                            if (valueMap_tWriteJSONField_2_Out.get("faultstring") != null) {
                                nestXMLTool_tWriteJSONField_2_Out.setText(root_0_tWriteJSONField_2_Out,
                                        valueMap_tWriteJSONField_2_Out.get("faultstring"));
                            }
                            root4Group_tWriteJSONField_2_Out = subTreeRootParent_tWriteJSONField_2_Out;
                        } else {
                            subTreeRootParent_tWriteJSONField_2_Out = root4Group_tWriteJSONField_2_Out;
                        }
                        // build group xml tree
                        // build loop xml tree
                        org.dom4j.Element loop_tWriteJSONField_2_Out = org.dom4j.DocumentHelper
                                .createElement("faultcode");
                        if (orders_tWriteJSONField_2_Out[0] == 0) {
                            orders_tWriteJSONField_2_Out[0] = 0;
                        }
                        if (1 < orders_tWriteJSONField_2_Out.length) {
                            orders_tWriteJSONField_2_Out[1] = 0;
                        }
                        subTreeRootParent_tWriteJSONField_2_Out.elements()
                                .add(orders_tWriteJSONField_2_Out[0]++, loop_tWriteJSONField_2_Out);
                        if (valueMap_tWriteJSONField_2_Out.get("faultcode") != null) {
                            nestXMLTool_tWriteJSONField_2_Out.setText(loop_tWriteJSONField_2_Out,
                                    valueMap_tWriteJSONField_2_Out.get("faultcode"));
                        }

                        tos_count_tWriteJSONField_2_Out++;

                        /**
                         * [tWriteJSONField_2_Out main ] stop
                         */

                    } // End of branch "row5"

                    /**
                     * [tFileInputXML_1 end ] start
                     */

                    currentComponent = "tFileInputXML_1";

                }
            }
            globalMap.put("tFileInputXML_1_NB_LINE", nb_line_tFileInputXML_1);

            ok_Hash.put("tFileInputXML_1", true);
            end_Hash.put("tFileInputXML_1", System.currentTimeMillis());

            /**
             * [tFileInputXML_1 end ] stop
             */

            /**
             * [tWriteJSONField_2_Out end ] start
             */

            currentVirtualComponent = "tWriteJSONField_2";

            currentComponent = "tWriteJSONField_2_Out";

            if (nb_line_tWriteJSONField_2_Out > 0) {
                nestXMLTool_tWriteJSONField_2_Out
                        .replaceDefaultNameSpace(doc_tWriteJSONField_2_Out.getRootElement());
                java.io.StringWriter strWriter_tWriteJSONField_2_Out = new java.io.StringWriter();
                org.dom4j.io.XMLWriter output_tWriteJSONField_2_Out = new org.dom4j.io.XMLWriter(
                        strWriter_tWriteJSONField_2_Out, format_tWriteJSONField_2_Out);
                output_tWriteJSONField_2_Out.write(doc_tWriteJSONField_2_Out);
                output_tWriteJSONField_2_Out.close();
                row3Struct row_tWriteJSONField_2_Out = new row3Struct();

                row_tWriteJSONField_2_Out.result = strWriter_tWriteJSONField_2_Out.toString();
                listGroupby_tWriteJSONField_2_Out.add(row_tWriteJSONField_2_Out);

            }
            globalMap.put("tWriteJSONField_2_Out_NB_LINE", nb_line_tWriteJSONField_2_Out);
            globalMap.put("tWriteJSONField_2_In_FINISH" + (listGroupby_tWriteJSONField_2_Out == null ? ""
                    : listGroupby_tWriteJSONField_2_Out.hashCode()), "true");

            txf_tWriteJSONField_2_Out.join();
            if (txf_tWriteJSONField_2_Out.getLastException() != null) {
                currentComponent = txf_tWriteJSONField_2_Out.getCurrentComponent();
                throw txf_tWriteJSONField_2_Out.getLastException();
            }

            resourceMap.put("finish_tWriteJSONField_2_Out", true);

            ok_Hash.put("tWriteJSONField_2_Out", true);
            end_Hash.put("tWriteJSONField_2_Out", System.currentTimeMillis());

            /**
             * [tWriteJSONField_2_Out end ] stop
             */

        } // end the resume

    } catch (java.lang.Exception e) {

        TalendException te = new TalendException(e, currentComponent, globalMap);

        te.setVirtualComponentName(currentVirtualComponent);

        throw te;
    } catch (java.lang.Error error) {

        throw error;
    } finally {

        try {

            /**
             * [tFileInputXML_1 finally ] start
             */

            currentComponent = "tFileInputXML_1";

            /**
             * [tFileInputXML_1 finally ] stop
             */

            /**
             * [tWriteJSONField_2_Out finally ] start
             */

            currentVirtualComponent = "tWriteJSONField_2";

            currentComponent = "tWriteJSONField_2_Out";

            java.util.Queue listGroupby_tWriteJSONField_2_Out = (java.util.Queue) globalMap
                    .get("queue_tWriteJSONField_2_In");
            if (resourceMap.get("finish_tWriteJSONField_2_Out") == null) {
                globalMap.put("tWriteJSONField_2_In_FINISH_WITH_EXCEPTION"
                        + (listGroupby_tWriteJSONField_2_Out == null ? ""
                                : listGroupby_tWriteJSONField_2_Out.hashCode()),
                        "true");
            }

            if (listGroupby_tWriteJSONField_2_Out != null) {
                globalMap.put("tWriteJSONField_2_In_FINISH" + (listGroupby_tWriteJSONField_2_Out == null ? ""
                        : listGroupby_tWriteJSONField_2_Out.hashCode()), "true");
            }

            /**
             * [tWriteJSONField_2_Out finally ] stop
             */

        } catch (java.lang.Exception e) {
            // ignore
        } catch (java.lang.Error error) {
            // ignore
        }
        resourceMap = null;
    }

    globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 1);
}