Source Code Cross Referenced for MigradorDBWizard.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfp » db » migration » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Personal Finance Manager » br.com.gfp.db.migration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 21/10/2005
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2005  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         * 
022:         */
023:        package br.com.gfp.db.migration;
024:
025:        import java.awt.Frame;
026:        import java.awt.GridBagConstraints;
027:        import java.awt.GridBagLayout;
028:        import java.io.BufferedReader;
029:        import java.io.IOException;
030:        import java.io.InputStream;
031:        import java.io.InputStreamReader;
032:        import java.io.LineNumberReader;
033:        import java.sql.SQLException;
034:        import java.util.Enumeration;
035:
036:        import javax.swing.JPanel;
037:        import javax.swing.JTextArea;
038:
039:        import br.com.gfp.internationalization.BasicWizardMessages;
040:        import br.com.gfp.internationalization.TipoDeLancamentosMessages;
041:        import br.com.gfp.wizard.BasicWizard;
042:        import br.com.gfpshare.db.DataBaseManager;
043:        import br.com.gfpshare.plugin.core.DynamicClassLoader;
044:
045:        /**
046:         *
047:         * @author Igor Regis da Silva Simoes
048:         * @since 21/10/2005
049:         */
050:        public abstract class MigradorDBWizard extends BasicWizard {
051:            /**
052:             * 
053:             * @param owner 
054:             * @param dbManager 
055:             */
056:            public MigradorDBWizard(Frame owner) {
057:                super (owner);
058:            }
059:
060:            /**
061:             * Indica se o wizard será ou não executado.
062:             * O default é não executar o Winzard. As subclasse que sobrescreverem este método por necessitarem de winzard
063:             * devem chama-lo (super.precisaDeWizard) e depois retornar true, caso desejem que o script sql de migração seja
064:             * executado.
065:             * @return boolean 
066:             */
067:            @Override
068:            protected boolean precisaDeWizard() {
069:                int versaoDB = Integer.parseInt(getClass().getName().substring(
070:                        "br.com.gfp.db.migration.MigrarDB".length()));
071:                InputStream is = DynamicClassLoader.getClassLoader()
072:                        .getResourceAsStream(
073:                                "db/migration/db" + versaoDB + ".sql");
074:
075:                BufferedReader reader = new LineNumberReader(
076:                        new InputStreamReader(is));
077:                String ddl = "", temp = null;
078:
079:                do {
080:                    try {
081:                        if ((temp = reader.readLine()) != null)
082:                            ddl += temp;
083:                    } catch (IOException e) {
084:                        throw new RuntimeException("Erro na migracao do DB de "
085:                                + (versaoDB - 1) + " para " + versaoDB, e);
086:                    }
087:                } while (temp != null);
088:
089:                //Se existirem ddl's para alterar a tabela TipoLancamento
090:                if (ddl.indexOf("TipoLancamento") != -1) {
091:                    //Tipos de Lancamentos são internacionalizaveis, portanto devemos substituir
092:                    // o conteudo do ddl pelos valores no idioma em que está o arquivo.
093:                    Enumeration chaves = TipoDeLancamentosMessages
094:                            .getMessages().getProperties().getKeys();
095:                    while (chaves.hasMoreElements()) {
096:                        String chave = chaves.nextElement().toString();
097:                        ddl.replaceAll(chave, TipoDeLancamentosMessages
098:                                .getMessages().getString(chave));
099:                    }
100:                }
101:
102:                //Executamos o script ddl para mudança de layout do banco de dados
103:                try {
104:                    DataBaseManager.getDataBaseManager().executarAtualizacao(
105:                            ddl, null);
106:                } catch (SQLException e) {
107:                    if (e.getMessage().indexOf("already exists") != -1)
108:                        return true;
109:                    throw new RuntimeException("Erro na migracao do DB de "
110:                            + versaoDB + " para " + (versaoDB + 1), e);
111:                }
112:                return false;
113:            }
114:
115:            /**
116:             * Sobrescrevemos o painel da superclasse
117:             *
118:             */
119:            @Override
120:            protected void adicionaPainelWelcome() {
121:
122:                JPanel painelWelcome = new JPanel();
123:                painelWelcome.setLayout(new GridBagLayout());
124:                painelWelcome.setSize(421, 242);
125:
126:                JTextArea jtaTitulo = new JTextArea();
127:                jtaTitulo.setText(BasicWizardMessages.getMessages().getString(
128:                        "welcomeTitle"));
129:                jtaTitulo.setFont(new java.awt.Font("Times New Roman",
130:                        java.awt.Font.BOLD | java.awt.Font.ITALIC, 18));
131:                jtaTitulo.setEditable(false);
132:                jtaTitulo.setOpaque(false);
133:                GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
134:                gridBagConstraints1.gridx = 0;
135:                gridBagConstraints1.gridy = 0;
136:                gridBagConstraints1.insets = new java.awt.Insets(00, 0, 20, 0);
137:                gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
138:                gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
139:                painelWelcome.add(jtaTitulo, gridBagConstraints1);
140:
141:                JTextArea jtaIntro = new JTextArea();
142:                jtaIntro.setText(BasicWizardMessages.getMessages().getString(
143:                        "intro"));
144:                jtaIntro.setEditable(false);
145:                jtaIntro.setOpaque(false);
146:                GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
147:                gridBagConstraints2.gridx = 0;
148:                gridBagConstraints2.gridy = 1;
149:                gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
150:                painelWelcome.add(jtaIntro, gridBagConstraints2);
151:
152:                JTextArea jtaAviso = new JTextArea();
153:                jtaAviso.setText(BasicWizardMessages.getMessages().getString(
154:                        "aviso"));
155:                jtaAviso.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD
156:                        | java.awt.Font.ITALIC, 12));
157:                jtaAviso.setEditable(false);
158:                jtaAviso.setOpaque(false);
159:                GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
160:                gridBagConstraints6.gridx = 0;
161:                gridBagConstraints6.gridy = 3;
162:                gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;
163:                gridBagConstraints6.insets = new java.awt.Insets(10, 0, 10, 0);
164:                painelWelcome.add(jtaAviso, gridBagConstraints6);
165:
166:                JTextArea jtaFinal = new JTextArea();
167:                jtaFinal.setText(BasicWizardMessages.getMessages().getString(
168:                        "final"));
169:                jtaFinal.setEditable(false);
170:                jtaFinal.setOpaque(false);
171:                GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
172:                gridBagConstraints4.gridx = 0;
173:                gridBagConstraints4.gridy = 5;
174:                gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST;
175:                painelWelcome.add(jtaFinal, gridBagConstraints4);
176:
177:                addPage(painelWelcome);
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.