Package com.GestDB.convert

Source Code of com.GestDB.convert.wizarExportarDatosTXT

/*
* wizarExportarDatosTXT.java
*
* Created on 2004
* Created by Arsenio Molinero
* Copyright (C) 2004, 2005 Arsenio Molinero
*
* GestDB - a Java multi database client
*
* This file is part of GestDB.
*
* GestDB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GestDB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GestDB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package com.GestDB.convert;

import com.GestDB.*;
import com.GestDB.convert.TipoSQL.GestorExport;
import com.GestDB.sql.ConexionTXT;
import com.GestDB.sql.SelectConexionTXT;
import com.utils.*;
import java.sql.*;
import java.util.*;
import java.io.*;

/**
*
* @author  amolinero
*/
public class wizarExportarDatosTXT {
    private boolean datos = false;
    private boolean estructura = false;
    private char alcance = 'B'; // 'Q' de query, 'T' de tabla, 'B' de toda la bbdd
    private String query = null;
    private String tabla = null;
    private char tipo = 'T'; // 'T' texto plano, 'I' Insert, 'U' Update, 'D' Delete
    private boolean primeralinea = false;
    private String separador = "|";
    private String delimitador = "";
    private boolean quitardecimales = false;
    private boolean bDropTable = false;
    private boolean btablespace = false;
    private String tabladestino = null;
    private String clave1 = null;
    private String clave2 = null;
    private GestorExport ogestor = null;
    private String archivo = null;
   
    /** Creates a new instance of wizarExportarDatosTXT */
    public wizarExportarDatosTXT()
    {
    }
   
    public void run()
    {
        try {
            String stemp = null;
            // pregunta si se quiere exportar los datos, la estructura o ambos
            do
            {
                stemp = getTexto(Gestor.GetLiteral("wizarexportardatostxt.export_type","�Que desea exportar?: 'D'atos, 'E'structura, o 'A'mbos"), "D");
                stemp = stemp.toUpperCase();
            } while(stemp == null || stemp.length() != 1 || (stemp.charAt(0) != 'D' && stemp.charAt(0) != 'E' && stemp.charAt(0) != 'A'));
            switch(stemp.charAt(0))
            {
                case 'D':
                    datos = true;
                    estructura = false;
                    break;
                case 'E':
                    datos = false;
                    estructura = true;
                    break;
                case 'A':
                    datos = true;
                    estructura = true;
                    break;
            }

            // pregunta si se exporta de una query, de una tabla o de toda la bbdd
            do
            {
                stemp = getTexto(Gestor.GetLiteral("wizarexportardatostxt.export_source","Origen de la exportaci�n; 'Q'uery, 'T'abla, o toda la 'B'BDD"), "Q");
                stemp = stemp.toUpperCase();
            } while(stemp == null || stemp.length() != 1 || (stemp.charAt(0) != 'Q' && stemp.charAt(0) != 'T' && stemp.charAt(0) != 'B'));
            alcance = stemp.charAt(0);

            switch(alcance)
            {
                case 'Q':
                    query = getTexto("Query","");
                    if(query.length() == 0)
                        return;
                    tabladestino = wizarExportarDatos.SacaNombreTabla(query);
                    tabla = tabladestino;
                    break;
                case 'T':
                    tabla = getTabla();
                    if(tabla.length() == 0)
                        return;
                    tabladestino = tabla;
                    break;
                case 'B':
                    tabla = "";
                    break;
            }

            if(datos)
            {
                // pregunta el tipo de exportaci�n
                do
                {
                    stemp = getTexto(Gestor.GetLiteral("wizarexportardatostxt.export_format","Tipo de exportaci�n; 'T'exto plano con delimitadores, 'I'nsert, 'U'pdate, 'D'elete"), "T");
                    stemp = stemp.toUpperCase();
                } while(stemp == null || stemp.length() != 1 || (stemp.charAt(0) != 'I' && stemp.charAt(0) != 'T' && stemp.charAt(0) != 'U' && stemp.charAt(0) != 'D'));
                tipo = stemp.charAt(0);

                switch(tipo)
                {
                    case 'T':
                        stemp = getTexto(Gestor.GetLiteral("importartxt.firstline_with_name","�Primera linea con nombres de los campos?. 'S'i, 'N'o"),"N");
                        stemp = stemp.toUpperCase();
                        if(stemp.length() == 0)
                            return;
                        if(stemp.charAt(0) == 'N')
                            primeralinea = false;
                        else
                            primeralinea = true;
                        stemp = getTexto(Gestor.GetLiteral("wizarexportardatostxt.ignore_secons_decimals","�Quitar decimales de los segundos en los campos fecha?. 'S'i, 'N'o"),"N");
                        stemp = stemp.toUpperCase();
                        if(stemp.length() == 0)
                            return;
                        if(stemp.charAt(0) == 'N')
                            quitardecimales = false;
                        else
                            quitardecimales = true;

                        separador = getTexto(Gestor.GetLiteral("importartxt.fields_delimiter","Separador de campos"),"|");

                        stemp = getTexto(Gestor.GetLiteral("importartxt.string_delimiter","�Delimitar las cadenas de caracteres con alg�n caracter?. 'S'i, 'N'o"),"N");
                        stemp = stemp.toUpperCase();
                        if(stemp.length() == 0)
                            return;
                        if(stemp.charAt(0) == 'N')
                            delimitador = "";
                        else
                            delimitador = getTexto(Gestor.GetLiteral("wizarexportardatos.label9","Delimitador de cadenas"),"\"");
                        break;
                    case 'I':
                        if(alcance != 'B')
                        {
                            tabladestino = getTexto(Gestor.GetLiteral("wizarexportardatos.label10","tabla de destino"),tabladestino);
                            if(tabla.length() == 0)
                                return;
                        }
                        break; // 20-09-2006, seni correction done. if the user  choose "Export type text with insert commands", he is asked to select some key column. it is a error, the insert command don't use any key column.
                    case 'U':
                    case 'D':
                        if(alcance != 'B')
                        {
                            try {
                                if(ConexionTXT.connection == null)
                                {
                                    //get connection
                                    Class.forName(SelectConexionTXT.jdbcDriverClass);
                                    if(SelectConexionTXT.user != null && SelectConexionTXT.user.trim().length() != 0)
                                        ConexionTXT.connection = DriverManager.getConnection(SelectConexionTXT.jdbcDriverURL, SelectConexionTXT.user, SelectConexionTXT.password);
                                    else
                                        ConexionTXT.connection = DriverManager.getConnection(SelectConexionTXT.jdbcDriverURL);
                                }
                                Vector vcampos = wizarExportarDatos.campos(tabla, ConexionTXT.connection);

                                clave1 = getCampo(vcampos);
                                clave2 = getCampo(vcampos);
                            } catch(Exception e)
                            {
                                System.out.println("[wizarExportarDatosTXT.run] " + Gestor.GetLiteral("gestor.error_1","Error") + ": " + e.getMessage());
                                e.printStackTrace();
                                return;
                            }
                        }
                        break;
                }
            } // fin del if(datos)

            // va el gestor
            getGestor();

            // preguntamos si exportar a archivos o a otra conexi�n
            boolean bBorrarEstructura = false;
            boolean bBorrarRegistros = false;
            String sOtraConexion = null;
            archivo = getArchivo();
            if(archivo.equals("-")) // ha decidido exportar a otra conexi�n
            {
                // se le pide al usuario que seleccione la conexi�n
                SelectConexionTXT sc = new SelectConexionTXT(true);
                sc.run();

                sOtraConexion = sc.nombre;

                bBorrarEstructura = getBoolean(Gestor.GetLiteral("wizarexportardatos.delete_table","Borrar tablas si existen (s�lo si se ha seleccionado exportar tablas)"),
                        Gestor.GetLiteral("wizarexportardatos.calc_rows_no","N"));
                bBorrarRegistros = getBoolean(Gestor.GetLiteral("wizarexportardatos.delete_rows","Borrar registros en las tablas destino"),
                        Gestor.GetLiteral("wizarexportardatos.calc_rows_no","N"));
            }

            boolean bCalcularRegistros = getCalcular();

            CompruebaDatos();

            // lanza la exportaci�n
            try {
                // ya esta todo OK, hay que hacer la exportaci�n, tenemos
                // varios tipos, El usuario podr�a seleccionar exportar datos
                // y estructura, de ser as�, se tendr�a que exportar primero
                // la estructura y despues los datos.
                String sEstructura = "";
                int tipoExportacion = 0;
                int tipoOrigen = 0;
                int tipoDatos = 0;

                if(estructura)
                {
                    tipoExportacion |= ExportarDatos.ESTRUCTURA;

                    stemp = getTexto(Gestor.GetLiteral("wizarexportardatostxt.include_tablespace","�Incluir informaci�n de tablespace(s�lo para la exportaci�n de estructura en Oracle y DB2)?. 'S'i, 'N'o"),"N");
                    stemp = stemp.toUpperCase();
                    if(stemp.length() == 0)
                        return;
                    if(stemp.charAt(0) == 'N')
                        btablespace = false;
                    else
                        btablespace = true;

                    stemp = getTexto(Gestor.GetLiteral("wizarexportardatostxt.droptable","�Generar drop table para cada tabla?. 'S'i, 'N'o"),"N");
                    stemp = stemp.toUpperCase();
                    if(stemp.length() == 0)
                        return;
                    if(stemp.charAt(0) == 'N')
                        bDropTable = false;
                    else
                        bDropTable = true;
                }

                if(datos)
                    tipoExportacion |= ExportarDatos.DATOS;

                if(alcance == 'B')
                    tipoExportacion |= ExportarDatos.DB;

                String tablaOrigen = tabla;
                if(tablaOrigen != null)
                    tablaOrigen = tablaOrigen.trim();
                if(tabladestino != null)
                    tabla = tabladestino.trim();
                else
                    tabla = tabladestino;

                if(alcance == 'T')
                {
                    query = "select * from " + tablaOrigen;
                    tipoOrigen = ExportarDatos.TABLA;
                }
                else if(alcance == 'Q')
                    tipoOrigen = ExportarDatos.QUERY;
                else
                    tipoOrigen = ExportarDatos.BBDD;

                if(tipo == 'T')
                    tipoDatos = ExportarDatos.TEXTO;
                else if(tipo == 'I')
                    tipoDatos = ExportarDatos.INSERT;
                else if(tipo == 'U')
                    tipoDatos = ExportarDatos.UPDATE;
                else if(tipo == 'D')
                    tipoDatos = ExportarDatos.DELETE;

                if(clave1 == null) clave1 = "";
                else clave1.toUpperCase().trim();
                if(clave2 == null) clave2 = "";
                else clave2.toUpperCase().trim();
                ExportarDatos exp = new ExportarDatos(query, tablaOrigen, tabla, 
                        archivo, primeralinea, separador, delimitador,null,null, null,
                        tipoExportacion, tipoOrigen, tipoDatos,
                        ogestor, clave1, clave2,
                        "",quitardecimales, btablespace, bDropTable, SelectConexionTXT.jdbcDriverURL,
                        SelectConexionTXT.jdbcDriverClass,
                        SelectConexionTXT.user, SelectConexionTXT.password,null,null,null,null,null,null,
                        bCalcularRegistros,sOtraConexion,bBorrarEstructura,bBorrarRegistros, null);
                exp.run(); // llama al run para que no se lance como un thread
            } catch(Exception e)
            {
                System.out.println("[wizarExportarDatosTXT.run 2]" + Gestor.GetLiteral("gestor.error_1","Error") + ": " + e.getMessage());
                e.printStackTrace();
            }
        } catch(Exception e2)
        {
            System.out.println("[wizarExportarDatosTXT.run 3]" + Gestor.GetLiteral("gestor.error_1","Error") + ": " + e2.getMessage());
            e2.printStackTrace();
        }
    }
   
    private String getCampo(Vector vcampos)
    {
        String elcampo = "";
        boolean fincampos = false;

        try
        {
            while(!fincampos)
            {
                System.out.println(Gestor.GetLiteral("wizarexportardatostxt.select_field","Seleccione un campo de la tabla") + " '" + tabla + "': ");

                int contador = 0;
                int contador2 = 0;
                int caracteresColumna = (ConexionTXT.numAncho / 19);
                while (contador < vcampos.size())
                {
                    contador++;
                    if(contador2 != 0 && contador2%ConexionTXT.numPaginacion == 0 && (contador-1)%caracteresColumna == 0)
                    {
                        // se hace una pausa.
                        if(contador < (ConexionTXT.numPaginacion*caracteresColumna))
                            System.out.println("\n1 " + Gestor.GetLiteral("conexiontxt.run_query_to","al") + " " +
                                (contador-1) + " " + Gestor.GetLiteral("wizarexportardatostxt.more_view",
                                "[intro] ver mas campos. un n�mero de campo e intro para seleccionar."));
                        else
                            System.out.println("\n" + (contador-(ConexionTXT.numPaginacion*caracteresColumna)) + " " +
                                Gestor.GetLiteral("conexiontxt.run_query_to","al") + " " + (contador-1) + " " +
                                Gestor.GetLiteral("wizarexportardatostxt.more_view",
                                "[intro] ver mas campos. un n�mero de campos e intro para seleccionar."));
                        String buffer = ConexionTXT.LeeLinea();
                        try {
                            int numero = Integer.parseInt(buffer.trim());
                            if(buffer.length() > 0 && numero >= 1 && numero <= vcampos.size())
                            {
                                return (String)vcampos.elementAt(numero-1);
                            }
                        }catch(java.lang.NumberFormatException ne)
                        {
                            ;
                        }
                    }

                    System.out.print(utilidades.AddCadena("" + contador + " - " + vcampos.elementAt(contador-1),18," ") + " ");
                    if(contador%caracteresColumna == 0)
                    {
                        System.out.println();
                        contador2++;
                    }
                } 
                if(contador == 0)
                {
                    System.out.println(Gestor.GetLiteral("wizarexportardatostxt.columns_not_found","No hay columnas."));
                    System.out.println("--------------------------------------------------------------------------------");
                    System.out.println(Gestor.GetLiteral("conexiontxt.comand2","'-V' Volver.") + " ");
                    System.out.println("--------------------------------------------------------------------------------");
                }
                else
                {
                    System.out.println();
                    System.out.println("--------------------------------------------------------------------------------");
                    System.out.println(Gestor.GetLiteral("wizarexportardatostxt.comand1","'-T' Ver campos '-V' Volver. Un n�mero de campo e intro para seleccionar."));
                    System.out.println("--------------------------------------------------------------------------------");
                }

                String buffer = ConexionTXT.LeeLinea();
                if(buffer == null || buffer.length() == 0 || buffer.toLowerCase().equals("-v") || contador == 0)
                    fincampos = true;
               
                if(buffer.length() > 0 && contador > 0)
                {
                    try {
                        int numero = Integer.parseInt(buffer.trim());
                        if(buffer.length() > 0 && numero >= 1 && numero <= vcampos.size())
                        {
                            elcampo = (String)vcampos.elementAt(numero-1);
                            fincampos = true;
                        }
                    }catch(java.lang.NumberFormatException ne)
                    {
                        ;
                    }
                }
            }
        } catch(Exception e)
        {
            System.out.println("[wizarExportarDatosTXT.getCampo] " + Gestor.GetLiteral("gestor.error_1","Error") + ": " + e.getMessage());
            e.printStackTrace();
        }        
       
        return elcampo;
    }

    private String getTabla()
    {
        String latabla = "";
        boolean fintablas = false;
        HashMap hm = new HashMap();

        try
        {
            if(ConexionTXT.connection == null)
            {
                //get connection
                Class.forName(SelectConexionTXT.jdbcDriverClass);
                if(SelectConexionTXT.user != null && SelectConexionTXT.user.trim().length() != 0)
                    ConexionTXT.connection = DriverManager.getConnection(SelectConexionTXT.jdbcDriverURL, SelectConexionTXT.user, SelectConexionTXT.password);
                else
                    ConexionTXT.connection = DriverManager.getConnection(SelectConexionTXT.jdbcDriverURL);
            }
            DatabaseMetaData dbmd = ConexionTXT.connection.getMetaData();

            String tabla = null;
            String tipotabla = null;
            String tiposdetabla[] = new String[1];
            int numTiposTablas = 1;
            tiposdetabla[0] = "TABLE";

            ResultSet r2 = null;
           
            while(!fintablas)
            {
                System.out.println(Gestor.GetLiteral("wizarexportardatostxt.select_one_table","Seleccione una tabla") + ": ");

                r2 = dbmd.getTables(null, null, null,tiposdetabla);
                int contador = 0;
                int contador2 = 0;
                hm.clear();
                int caracteresColumna = (ConexionTXT.numAncho / 19);
                while (r2.next())
                {
                    contador++;
                    if(contador2 != 0 && contador2%ConexionTXT.numPaginacion == 0 && (contador-1)%caracteresColumna == 0)
                    {
                        // se hace una pausa.
                        if(contador < (ConexionTXT.numPaginacion*caracteresColumna))
                            System.out.println("\n1 " + Gestor.GetLiteral("conexiontxt.run_query_to","al") + " " +
                                (contador-1) + " " +
                                Gestor.GetLiteral("wizarexportardatostxt.more_tables",
                                "[intro] ver mas tablas. -N[tabla] o un n�mero de tabla e intro para seleccionar."));
                        else
                            System.out.println("\n" + (contador-(ConexionTXT.numPaginacion*caracteresColumna)) + " " +
                                Gestor.GetLiteral("conexiontxt.run_query_to","al") + " " + (contador-1) + " " +
                                Gestor.GetLiteral("wizarexportardatostxt.more_tables",
                                "[intro] ver mas tablas. -N[tabla] o un n�mero de tabla e intro para seleccionar."));
                        String buffer = ConexionTXT.LeeLinea();
                        if(buffer.length() > 0)
                        {
                            if(hm.containsKey(buffer.trim()))
                            {
                                return (String)hm.get(buffer.trim());
                            }
                            else if(buffer.length() > 2 && buffer.substring(0,2).toUpperCase().equals("-N"))
                            {
                                return buffer.substring(2).trim();
                            }
                        }
                    }

                    tabla = r2.getString("TABLE_NAME");
                    hm.put(String.valueOf(contador), tabla);
                    System.out.print(utilidades.AddCadena("" + contador + " - " + tabla,18," ") + " ");
                    if(contador%caracteresColumna == 0)
                    {
                        System.out.println();
                        contador2++;
                    }
                } 
                if(contador == 0)
                {
                    System.out.println(Gestor.GetLiteral("conexiontxt.tables_not_found","No hay tablas."));
                    System.out.println("--------------------------------------------------------------------------------");
                    System.out.println(Gestor.GetLiteral("wizarexportardatostxt.comand2","'-V' Volver '-N[tabla]'") + ". ");
                    System.out.println("--------------------------------------------------------------------------------");
                }
                else
                {
                    System.out.println();
                    System.out.println("--------------------------------------------------------------------------------");
                    System.out.println(Gestor.GetLiteral("wizarexportardatostxt.comand2","'-T' Ver tablas '-V' Volver '-N[tabla]'. Un n�mero de tabla e intro para seleccionar."));
                    System.out.println("--------------------------------------------------------------------------------");
                }

                r2.close();
                String buffer = ConexionTXT.LeeLinea();
                if(buffer == null || buffer.length() == 0 || buffer.toLowerCase().equals("-v") || contador == 0)
                    fintablas = true;
               
                if(buffer.length() > 0 && contador > 0 && hm.containsKey(buffer.trim()))
                {
                    if(buffer.length() > 0)
                    {
                        if(contador > 0 && hm.containsKey(buffer.trim()))
                        {
                            latabla = (String)hm.get(buffer.trim());
                            fintablas = true;
                        }
                        else if(buffer.length() > 2 && buffer.substring(0,2).toUpperCase().equals("-N"))
                        {
                            latabla = buffer.substring(2).trim();
                            fintablas = true;
                        }
                    }
                }
            }
        } catch(Exception e)
        {
            System.out.println("[wizarExportarDatosTXT.getTabla] " + Gestor.GetLiteral("gestor.error_1","Error") + ": " + e.getMessage());
            e.printStackTrace();
        }        
       
        return latabla;
    }
   
    public static String getTexto(String titulo, String valor)
    {
        String resultado = valor;
        String buffer = null;
        do {
            System.out.print(titulo + "(" + resultado + "): ");
            buffer = ConexionTXT.LeeLinea();
            if(buffer.length() > 0)
                resultado = buffer;
        } while(resultado == null || resultado.trim().length() == 0);
    
        return resultado;
    }

    public static String getArchivo()
    {
        String archivo = "";
        File farchivo = null;
        File fdir = null;
        String dir = "";
        int pos=0, pos2=0;
        do {
            archivo = getTexto(Gestor.GetLiteral("importar.file2","Escriba la ruta al archivo o un guion(-) si quiere exportar directamnete a otra conexi�n. "),archivo);
            if(archivo != null && archivo.equals("-"))
                break;
           
            farchivo = new File(archivo);
            if(farchivo.exists() && farchivo.isDirectory())
                break;
            // saca el directorio
            dir = farchivo.getAbsolutePath();
            pos = dir.lastIndexOf('/');
            pos2 = dir.lastIndexOf('\\');
            if(pos2 > pos)
                pos = pos2;

            if(pos != -1)
                dir = dir.substring(0,pos);
            fdir = new File(dir);
            if(!fdir.exists() || !fdir.isDirectory())
                System.out.println(Gestor.GetLiteral("wizarexportardatostxt.dir_not_exist","directorio inexistente.") + dir);
        } while(farchivo == null || !fdir.exists());
        return archivo;
    }
   
    private void getGestor()
    {
        // cargamos los tipos posibles de gestorios
        TipoSQL.CargarTipos();
        ogestor = null;
       
        // va el gestor, le saca las opciones
        String stempGestores = "";
        String msgGestor = Gestor.GetLiteral("wizarexportardatostxt.select_gestor","Gestor (del * al #)");
        String msgGestorError = Gestor.GetLiteral("wizarexportardatostxt.type_number","Introduzca un numero del * al #");
        GestorExport gex = null;
        int numGestores = TipoSQL.oGestoresCombo.size();
        int minGestor = 0;
        int maxGestor = 0;
        for(int g = 0; g < numGestores; g++)
        {
            gex = TipoSQL.oGestoresCombo.elementAt(g);
            minGestor = Math.min(gex.id, minGestor);
            maxGestor = Math.max(gex.id, maxGestor);
            stempGestores += ((g > 0)?", ":"") + gex.id + ". " + gex.title;
        }
       
        msgGestor = msgGestor.replace("*", String.valueOf(minGestor));
        msgGestor = msgGestor.replace("#", String.valueOf(maxGestor));
        msgGestorError = msgGestorError.replace("*", String.valueOf(minGestor));
        msgGestorError = msgGestorError.replace("#", String.valueOf(maxGestor));
       
        System.out.println(Gestor.GetLiteral("wizarexportardatostxt.gestor_target","Gestor de destino: ") + stempGestores);
        boolean fin = false;
        String buffer = null;
        int igestor = minGestor;
        while(!fin)
        {
            System.out.print(msgGestor + "("+ igestor + "): ");
            buffer = ConexionTXT.LeeLinea();
            try {
                igestor = Integer.parseInt(buffer);
                for(int g = 0; g < numGestores; g++)
                {
                    gex = TipoSQL.oGestoresCombo.elementAt(g);
                    if(gex.id == igestor)
                    {
                        ogestor = gex;
                        fin = true;
                        break;
                    }
                }
                if(!fin)
                {
                    System.out.println(msgGestorError);
                }
            }catch(java.lang.NumberFormatException nu)
            {
                System.out.println(msgGestorError);
            }
        } // fin while                           
    }
   
    private void CompruebaDatos() {
        if(alcance == 'Q' && query.trim().length() < 1)
        {
            System.out.println(Gestor.GetLiteral("wizarexportardatostxt.query_required","Tiene que escribir una query"));
            query = getTexto("Query", query);
        }
       
        if(alcance == 'T' && tabla.trim().length() < 1)
        {
            System.out.println(Gestor.GetLiteral("wizarexportardatos.error_7","Tiene que seleccionar una tabla"));
            tabla = getTabla();
        }
       
        // s�lo si esta marcada la exportaci�n de datos
        if(datos)
        {
            if(alcance != 'B' && tipo != 'T' && tabladestino.trim().length() < 1)
            {
                System.out.println(Gestor.GetLiteral("wizarexportardatostxt.name_table_target_required","Tiene que escribir el nombre de la tabla destino"));
                tabladestino = getTexto(Gestor.GetLiteral("wizarexportardatos.label10","Tabla destino"), tabladestino);
            }
           
            if(alcance != 'B' && (tipo == 'U' || tipo == 'D') && clave1.trim().length() < 1)
            {
                System.out.println(Gestor.GetLiteral("wizarexportardatos.error_5","Tiene que Seleccionar una clave"));
                clave1 = getTexto("Clave 1", clave1);
            }
        }
       
        if(ogestor == null && ((datos && tipo != 'T') || estructura))
        {
            System.out.println(Gestor.GetLiteral("wizarexportardatostxt.gestor_required","Tiene que seleccionar un tipo de gestor de destino"));
            getGestor();
        }

        if(archivo == null || archivo.trim().length() < 1)
        {
            System.out.println(Gestor.GetLiteral("wizarexportardatostxt.file_required","Tiene que seleccionar un archivo o directorio de destino"));
            archivo = getArchivo();
        }
    }

    private boolean getCalcular() {
        boolean bCalcular = true;
        String texto = getTexto(Gestor.GetLiteral("wizarexportardatos.calc_rows","Calcular registros de la tabla") +
                Gestor.GetLiteral("wizarexportardatos.calc_rows2","(no recomendado si hay tablas con m�s de 500.000 registros)") +
                "[" + Gestor.GetLiteral("wizarexportardatos.calc_rows_yes","S") +
                "/" + Gestor.GetLiteral("wizarexportardatos.calc_rows_no","N")+ "]","S");
        if(texto != null && texto.toUpperCase().equals(Gestor.GetLiteral("wizarexportardatos.calc_rows_no","N")))
            bCalcular = false;
       
        return bCalcular;
    }
   
    private boolean getBoolean(String literal, String respuestaPorDefecto)
    {
        boolean bResultado = true;
        String texto = getTexto(literal +
                "[" + Gestor.GetLiteral("wizarexportardatos.calc_rows_yes","S") +
                "/" + Gestor.GetLiteral("wizarexportardatos.calc_rows_no","N")+ "]",respuestaPorDefecto);
        if(texto != null && texto.toUpperCase().equals(Gestor.GetLiteral("wizarexportardatos.calc_rows_no","N")))
            bResultado = false;

        return bResultado;
    }

}
TOP

Related Classes of com.GestDB.convert.wizarExportarDatosTXT

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.