// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:47:53
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   LeerConfiguracion.java

package project;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;
import traduccion.Traducir;

// Referenced classes of package project:
//            MensajeDeError, Application1, Crypto, AccederADatos

public class LeerConfiguracion
{

    public LeerConfiguracion(String idi, String modulo2, boolean demo)
    {
        scontinuo = "";
        num = 1;
        numero = 0;
        NModulo = "";
        ENModulo = "";
        NTema1 = "";
        ENTema1 = "";
        NTema2 = "";
        ENTema2 = "";
        NTema3 = "";
        ENTema3 = "";
        NTema4 = "";
        ENTema4 = "";
        NTema5 = "";
        ENTema5 = "";
        NTema6 = "";
        ENTema6 = "";
        NTema7 = "";
        ENTema7 = "";
        fichero = "";
        modulo = "";
        modulo = modulo2;
        fichero = "/project/modulo" + modulo + ".xml";
        System.out.println("fichero: " + fichero);
        stream = Application1.crypto.decrypt((java.lang.Object.class).getResourceAsStream(fichero));
        try
        {
            m_dbf = DocumentBuilderFactory.newInstance();
            db1 = m_dbf.newDocumentBuilder();
            doc = db1.parse(stream);
            listOfQuestions = doc.getElementsByTagName("idioma");
            boolean encontrado = false;
            System.out.println("listOfQuestions.getLength(): " + listOfQuestions.getLength());
            for(int a = 0; a < listOfQuestions.getLength(); a++)
            {
                nextQuestion = (Element)listOfQuestions.item(a);
                System.out.println("nextQuestion.getAttribute(\"id\"): " + nextQuestion.getAttribute("id"));
                System.out.println("idi: " + idi);
                if(nextQuestion.getAttribute("id").compareTo(idi) != 0)
                    continue;
                encontrado = true;
                NodeList listOfModulos = nextQuestion.getElementsByTagName("modulo");
                System.out.println("listOfModulos.getLength(): " + listOfModulos.getLength());
label0:
                for(int b = 0; b < listOfModulos.getLength(); b++)
                {
                    nextQuestion = (Element)listOfModulos.item(b);
                    System.out.println("nextQuestion.getAttribute(\"id\"): " + nextQuestion.getAttribute("id"));
                    System.out.println("modulo: " + modulo);
                    if(nextQuestion.getAttribute("id").compareTo(modulo) != 0)
                        continue;
                    if(!demo)
                        vDatosTemas.removeAllElements();
                    NModulo = nextQuestion.getAttribute("nombre");
                    ENModulo = nextQuestion.getAttribute("nombre");
                    vDatosTemas = new Vector();
                    vNombreTemas = new Vector();
                    NodeList listOfTemas = nextQuestion.getElementsByTagName("tema");
                    numero = listOfTemas.getLength();
                    int c = 0;
                    do
                    {
                        if(c >= listOfTemas.getLength())
                            continue label0;
                        Vector tema = new Vector();
                        nextQuestion = (Element)listOfTemas.item(c);
                        vNombreTemas.add(c, nextQuestion.getAttribute("nombre"));
                        NodeList listOfGrados = nextQuestion.getElementsByTagName("grado");
                        for(int d = 0; d < listOfGrados.getLength(); d++)
                        {
                            Vector grado = new Vector();
                            nextQuestion = (Element)listOfGrados.item(d);
                            if(!demo)
                                grado.add(0, nextQuestion.getAttribute("en_examen"));
                            else
                                grado.add(0, nextQuestion.getAttribute("en_demo"));
                            grado.add(1, nextQuestion.getAttribute("porcentaje1"));
                            grado.add(2, nextQuestion.getAttribute("porcentaje2"));
                            tema.add(d, grado);
                        }

                        vDatosTemas.add(c, tema);
                        c++;
                    } while(true);
                }

            }

            System.out.println("vDatosTemas: " + vDatosTemas.toString());
            ET1N1 = Integer.parseInt(sacarValorDelVector(0, 0, 0));
            ET1N2 = Integer.parseInt(sacarValorDelVector(0, 1, 0));
            ET1N3 = Integer.parseInt(sacarValorDelVector(0, 2, 0));
            System.out.println("ET1N1: " + ET1N1);
            System.out.println("ET1N2: " + ET1N2);
            System.out.println("ET1N2: " + ET1N2);
            ET2N1 = Integer.parseInt(sacarValorDelVector(1, 0, 0));
            ET2N2 = Integer.parseInt(sacarValorDelVector(1, 1, 0));
            ET2N3 = Integer.parseInt(sacarValorDelVector(1, 2, 0));
            System.out.println("ET2N1: " + ET2N1);
            System.out.println("ET2N2: " + ET2N2);
            System.out.println("ET2N2: " + ET2N2);
            ET3N1 = Integer.parseInt(sacarValorDelVector(2, 0, 0));
            ET3N2 = Integer.parseInt(sacarValorDelVector(2, 1, 0));
            ET3N3 = Integer.parseInt(sacarValorDelVector(2, 2, 0));
            System.out.println("ET3N1: " + ET3N1);
            System.out.println("ET3N2: " + ET3N2);
            System.out.println("ET3N2: " + ET3N2);
            ET4N1 = Integer.parseInt(sacarValorDelVector(3, 0, 0));
            ET4N2 = Integer.parseInt(sacarValorDelVector(3, 1, 0));
            ET4N3 = Integer.parseInt(sacarValorDelVector(3, 2, 0));
            System.out.println("ET4N1: " + ET4N1);
            System.out.println("ET4N2: " + ET4N2);
            System.out.println("ET4N2: " + ET4N2);
            ET5N1 = Integer.parseInt(sacarValorDelVector(4, 0, 0));
            ET5N2 = Integer.parseInt(sacarValorDelVector(4, 1, 0));
            ET5N3 = Integer.parseInt(sacarValorDelVector(4, 2, 0));
            System.out.println("ET5N1: " + ET5N1);
            System.out.println("ET5N2: " + ET5N2);
            System.out.println("ET5N2: " + ET5N2);
            ET6N1 = Integer.parseInt(sacarValorDelVector(5, 0, 0));
            ET6N2 = Integer.parseInt(sacarValorDelVector(5, 1, 0));
            ET6N3 = Integer.parseInt(sacarValorDelVector(5, 2, 0));
            System.out.println("ET6N1: " + ET6N1);
            System.out.println("ET6N2: " + ET6N2);
            System.out.println("ET6N2: " + ET6N2);
            ET7N1 = Integer.parseInt(sacarValorDelVector(6, 0, 0));
            ET7N2 = Integer.parseInt(sacarValorDelVector(6, 1, 0));
            ET7N3 = Integer.parseInt(sacarValorDelVector(6, 2, 0));
            System.out.println("ET7N1: " + ET7N1);
            System.out.println("ET7N2: " + ET7N2);
            System.out.println("ET7N2: " + ET7N2);
            todasExamen = ET1N1 + ET1N2 + ET1N3 + ET2N1 + ET2N2 + ET2N3 + ET3N1 + ET3N2 + ET3N3 + ET4N1 + ET4N2 + ET4N3 + ET5N1 + ET5N2 + ET5N3 + ET6N1 + ET6N2 + ET6N3 + ET7N1 + ET7N2 + ET7N3;
            minimo = 1;
            PCN3 = Integer.parseInt(sacarValorDelVector(0, 2, 1));
            SCN3 = Integer.parseInt(sacarValorDelVector(0, 2, 2));
            PCN2 = Integer.parseInt(sacarValorDelVector(0, 1, 1));
            SCN2 = Integer.parseInt(sacarValorDelVector(0, 1, 2));
            PCN1 = Integer.parseInt(sacarValorDelVector(0, 0, 1));
            SCN1 = Integer.parseInt(sacarValorDelVector(0, 0, 2));
            NTema1 = sacarNombreDelVector(0);
            ENTema1 = sacarNombreDelVector(0);
            NTema2 = sacarNombreDelVector(1);
            ENTema2 = sacarNombreDelVector(1);
            NTema3 = sacarNombreDelVector(2);
            ENTema3 = sacarNombreDelVector(2);
            NTema4 = sacarNombreDelVector(3);
            ENTema4 = sacarNombreDelVector(3);
            NTema5 = sacarNombreDelVector(4);
            ENTema5 = sacarNombreDelVector(4);
            NTema6 = sacarNombreDelVector(5);
            ENTema6 = sacarNombreDelVector(5);
            NTema7 = sacarNombreDelVector(6);
            ENTema7 = sacarNombreDelVector(6);
            if(todasExamen < minimo || !encontrado)
            {
                MensajeDeError mensaje = new MensajeDeError();
                mensaje.mensaje(true, Traducir.getTraduccion(AccederADatos.leer("h.proyecto"), "project.LeerConfiguracion", "200411171723", idi));
                mensaje = null;
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
            MensajeDeError mensaje = new MensajeDeError();
            mensaje.mensaje(true, Traducir.getTraduccion(AccederADatos.leer("h.proyecto"), "project.LeerConfiguracion", "200411171723", idi));
            mensaje = null;
        }
    }

    private String sacarValorDelVector(int tema, int grado, int valorRequerido)
    {
        String solucion = "0";
        if(tema < vDatosTemas.size())
        {
            Vector vec = (Vector)vDatosTemas.elementAt(tema);
            if(grado < vec.size())
            {
                vec = (Vector)vec.elementAt(grado);
                if(valorRequerido < vec.size())
                    solucion = (String)vec.elementAt(valorRequerido);
            }
        }
        if(solucion == null)
            solucion = "0";
        return solucion;
    }

    private String sacarNombreDelVector(int tema)
    {
        String solucion = "";
        if(tema < vNombreTemas.size())
            solucion = (String)vNombreTemas.elementAt(tema);
        if(solucion == null)
            solucion = "";
        return solucion;
    }

    String scontinuo;
    int num;
    DocumentBuilderFactory m_dbf;
    DocumentBuilder db1;
    Document doc;
    NodeList listOfQuestions;
    Element nextQuestion;
    InputStream stream;
    public static Vector vDatosTemas;
    public static Vector vNombreTemas;
    public int numero;
    public String NModulo;
    public String ENModulo;
    public String NTema1;
    public String ENTema1;
    public String NTema2;
    public String ENTema2;
    public String NTema3;
    public String ENTema3;
    public String NTema4;
    public String ENTema4;
    public String NTema5;
    public String ENTema5;
    public String NTema6;
    public String ENTema6;
    public String NTema7;
    public String ENTema7;
    public int PCN3;
    public int SCN3;
    public int PCN2;
    public int SCN2;
    public int PCN1;
    public int SCN1;
    public int ET1N1;
    public int ET1N2;
    public int ET1N3;
    public int ET2N1;
    public int ET2N2;
    public int ET2N3;
    public int ET3N1;
    public int ET3N2;
    public int ET3N3;
    public int ET4N1;
    public int ET4N2;
    public int ET4N3;
    public int ET5N1;
    public int ET5N2;
    public int ET5N3;
    public int ET6N1;
    public int ET6N2;
    public int ET6N3;
    public int ET7N1;
    public int ET7N2;
    public int ET7N3;
    public int ET8N1;
    public int ET8N2;
    public int ET8N3;
    public String fichero;
    public int minimo;
    public String modulo;
    public int todasExamen;
}