BrightSide Workbench Full Report + Source Code
DataChecker.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.financials.db;
19 
24 public class DataChecker {
25 
26 // public static void checkMajors(Application app) {
27 // Dao dao = new FinancialsPU();
28 // if(dao.getResultList("select book from BookDefinition as book"
29 // ).isEmpty()) {
30 // BufferedReader br = null;
31 // try {
32 // br = new BufferedReader(new InputStreamReader(new FileInputStream(app.getRealPath("/WEB-INF/elephant/sql/financials/book_ca.data"))));
33 // String s;
34 // while ((s = br.readLine()) != null) {
35 // String v[] = s.split("\\|");
36 // BookDefinition bd = new BookDefinition();
37 // bd.setId(Long.valueOf(v[0]));
38 // bd.setDescription(v[1]);
39 // dao.saveObject(bd);
40 // }
41 // } catch (IOException ex) {
42 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
43 // } finally {
44 // try {
45 // br.close();
46 // } catch (IOException ex) {
47 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
48 // }
49 // }
50 // }
51 // if(dao.getResultList(
52 // "select major from MajorAccount as major"
53 // ).isEmpty()) {
54 // BufferedReader br = null;
55 // try {
56 // br = new BufferedReader(new InputStreamReader(new FileInputStream(app.getRealPath("/WEB-INF/elephant/sql/financials/major_ca.data"))));
57 // String s;
58 // while ((s = br.readLine()) != null) {
59 // String v[] = s.split("\\|");
60 // MajorAccount ma = new MajorAccount();
61 // ma.setAccount(v[0]);
62 // ma.setDescription(v[1]);
63 // ma.setBookDefinition(dao.find(BookDefinition.class, Long.valueOf(v[2])));
64 // dao.saveObject(ma);
65 // }
66 // } catch (IOException ex) {
67 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
68 // } finally {
69 // try {
70 // br.close();
71 // } catch (IOException ex) {
72 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
73 // }
74 // }
75 // }
76 // }
77 //
78 // public static void checkLineTypes(Application app) {
79 // Dao dao = new FinancialsPU();
80 // if(dao.getResultList("select lineType from LineType as lineType"
81 // ).isEmpty()) {
82 // BufferedReader br = null;
83 // try {
84 // br = new BufferedReader(new InputStreamReader(new FileInputStream(app.getRealPath("/WEB-INF/elephant/sql/financials/role_ca.data"))));
85 // String s;
86 // while ((s = br.readLine()) != null) {
87 // String v[] = s.split("\\|");
88 // LineType lt = new LineType();
89 // lt.setId(Long.valueOf(v[0]));
90 // lt.setName(v[1]);
91 // dao.saveObject(lt);
92 // }
93 // } catch (IOException ex) {
94 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
95 // } finally {
96 // try {
97 // br.close();
98 // } catch (IOException ex) {
99 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
100 // }
101 // }
102 // }
103 // if(dao.getResultList(
104 // "select ltAccount from LineTypeAccount as ltAccount"
105 // ).isEmpty()) {
106 // BufferedReader br = null;
107 // try {
108 // br = new BufferedReader(new InputStreamReader(new FileInputStream(app.getRealPath("/WEB-INF/elephant/sql/financials/roleAccount_ca.data"))));
109 // String s;
110 // while ((s = br.readLine()) != null) {
111 // String v[] = s.split("\\|");
112 // LineTypeAccount lta = new LineTypeAccount();
113 // lta.setLineType(dao.find(LineType.class, Long.valueOf(v[0])));
114 // int type = Integer.valueOf(v[1]);
115 // switch(type) {
116 // case 0 :
117 // lta.setType(LineTypeAccountType.LTAT_TOTAL);
118 // break;
119 // case 1 :
120 // lta.setType(LineTypeAccountType.LTAT_TAX_BASE);
121 // break;
122 // case 2 :
123 // lta.setType(LineTypeAccountType.LTAT_TAX);
124 // break;
125 // case 3 :
126 // lta.setType(LineTypeAccountType.LTAT_DISCOUNT);
127 // break;
128 // }
129 // lta.setTypeValue(Double.valueOf(v[2]));
130 // lta.setPattern(v[3]);
131 // int pos = Integer.valueOf(v[4]);
132 // if(pos == 0)
133 // lta.setPosition(AccountPosition.ACC_DEBIT);
134 // else
135 // lta.setPosition(AccountPosition.ACC_CREDIT);
136 // lta.setView(dao.find(RegisterView.class, Long.valueOf(v[5])));
137 // lta.setCoefficient(Double.valueOf(v[7]));
138 // dao.saveObject(lta);
139 // }
140 // } catch (IOException ex) {
141 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
142 // } finally {
143 // try {
144 // br.close();
145 // } catch (IOException ex) {
146 // Logger.getLogger(DataChecker.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
147 // }
148 // }
149 // }
150 // }
151 //
152 }