Source Code Cross Referenced for WriteImportDefinition.java in  » Database-JDBC-Connection-Pool » octopus » org » webdocwf » util » loader » generator » 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 » Database JDBC Connection Pool » octopus » org.webdocwf.util.loader.generator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
003:
004:
005:         Copyright (C) 2003  Together
006:
007:         This library is free software; you can redistribute it and/or
008:         modify it under the terms of the GNU Lesser General Public
009:         License as published by the Free Software Foundation; either
010:         version 2.1 of the License, or (at your option) any later version.
011:
012:         This library is distributed in the hope that it will be useful,
013:         but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         Lesser General Public License for more details.
016:
017:         You should have received a copy of the GNU Lesser General Public
018:         License along with this library; if not, write to the Free Software
019:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:
022:        package org.webdocwf.util.loader.generator;
023:
024:        import org.w3c.dom.Document;
025:        import org.w3c.dom.Element;
026:        import org.webdocwf.util.loader.LoaderException;
027:        import org.webdocwf.util.loader.logging.Logger;
028:        import org.webdocwf.util.loader.logging.StandardLogger;
029:
030:        /**
031:         *
032:         * WriteImportDefinition class creates ImportDefinition.xml file.
033:         * @author Radoslav Dutina
034:         * @version 1.0
035:         */
036:        public class WriteImportDefinition {
037:            private Logger logger;
038:
039:            /**
040:             * Construct object WriteImportDefinition with associated parameters.
041:             * @param document is the org.w3c.dom.Document object, which is created in CreateIncludeFile class.
042:             * @param root is the root element from document object.
043:             * @param importDefinitionAttributes is references to ImportDefinitionAttributes object.
044:             * @param generatorParameters represents the references to InputParameter object.
045:             * @throws LoaderException
046:             */
047:
048:            public WriteImportDefinition(Document document, Element root,
049:                    ImportDefinitionAttributes importDefinitionAttributes,
050:                    InputParameters generatorParameters) throws LoaderException {
051:                setLogger();
052:                this .logger.write("full", "WriteImportDefinition is started.");
053:                if (!generatorParameters.getFullMode()) {
054:
055:                    Element childRoot1 = (Element) document
056:                            .createElement("copyTable");
057:                    root.appendChild(childRoot1);
058:                    childRoot1.setAttribute("name", importDefinitionAttributes
059:                            .getName());
060:                    childRoot1.setAttribute("sourceTableName",
061:                            importDefinitionAttributes.getName());
062:                    childRoot1.setAttribute("targetTableName",
063:                            importDefinitionAttributes.getName());
064:                    //      childRoot1.setAttribute("logMode", importDefinitionAttributes.getLogMode());
065:                    childRoot1
066:                            .setAttribute("objectIDIncrement",
067:                                    importDefinitionAttributes
068:                                            .getObjectIDIncrementid());
069:                    childRoot1.setAttribute("oidLogic", "false");
070:                    childRoot1.setAttribute("onErrorContinue", "false");
071:
072:                } else {
073:                    Element childRoot1 = (Element) document
074:                            .createElement("importDefinition");
075:                    root.appendChild(childRoot1);
076:                    childRoot1.setAttribute("name", importDefinitionAttributes
077:                            .getName());
078:                    childRoot1.setAttribute("tableName",
079:                            importDefinitionAttributes.getTableName());
080:                    //childRoot1.setAttribute("objectIDIncrement", importDefinitionAttributes.getObjectIDIncrementid());
081:                    //      childRoot1.setAttribute("logMode", importDefinitionAttributes.getLogMode());
082:
083:                    Element childRoot2 = (Element) document
084:                            .createElement("valueColumns");
085:                    childRoot1.appendChild(childRoot2);
086:
087:                    for (int i = 0; i < importDefinitionAttributes
088:                            .getTagSourceColumnName().length; i++) {
089:                        if (generatorParameters.getSourceType()
090:                                .equalsIgnoreCase("csv")) {
091:                            Element childRoot3 = (Element) document
092:                                    .createElement("valueColumn");
093:                            childRoot2.appendChild(childRoot3);
094:                            childRoot3.setAttribute("sourceColumnName",
095:                                    importDefinitionAttributes
096:                                            .getTagSourceColumnName()[i]);
097:                            childRoot3.setAttribute("targetTableName",
098:                                    importDefinitionAttributes
099:                                            .getTagTargetTableName()[i]);
100:                            childRoot3.setAttribute("targetColumnName",
101:                                    importDefinitionAttributes
102:                                            .getTagTargetColumnName()[i]);
103:                            childRoot3.setAttribute("targetTableID",
104:                                    importDefinitionAttributes
105:                                            .getTagTargetTableID()[i]);
106:                            childRoot3.setAttribute("valueMode",
107:                                    generatorParameters.getValueMode());
108:                        } else {
109:                            if (!generatorParameters.getValueMode()
110:                                    .equalsIgnoreCase("Overwrite")) {
111:                                if (!importDefinitionAttributes
112:                                        .getTagSourceColumnName()[i]
113:                                        .equalsIgnoreCase("oid")
114:                                        && !importDefinitionAttributes
115:                                                .getTagSourceColumnName()[i]
116:                                                .equalsIgnoreCase("version")) {
117:                                    boolean fk = true;
118:                                    for (int j = 0; j < RelationshipsAttributes
119:                                            .getForeignVariables().length; j = j + 5) {
120:                                        if (RelationshipsAttributes
121:                                                .getForeignVariables()[j + 2]
122:                                                .equalsIgnoreCase(importDefinitionAttributes
123:                                                        .getTagSourceColumnName()[i])) {
124:                                            fk = false;
125:                                            break;
126:                                        }
127:                                    }
128:                                    if (fk) {
129:                                        Element childRoot3 = (Element) document
130:                                                .createElement("valueColumn");
131:                                        childRoot2.appendChild(childRoot3);
132:                                        childRoot3
133:                                                .setAttribute(
134:                                                        "sourceColumnName",
135:                                                        importDefinitionAttributes
136:                                                                .getTagSourceColumnName()[i]);
137:                                        childRoot3
138:                                                .setAttribute(
139:                                                        "targetTableName",
140:                                                        importDefinitionAttributes
141:                                                                .getTagTargetTableName()[i]);
142:                                        childRoot3
143:                                                .setAttribute(
144:                                                        "targetColumnName",
145:                                                        importDefinitionAttributes
146:                                                                .getTagTargetColumnName()[i]);
147:                                        childRoot3
148:                                                .setAttribute(
149:                                                        "targetTableID",
150:                                                        importDefinitionAttributes
151:                                                                .getTagTargetTableID()[i]);
152:                                        childRoot3.setAttribute("valueMode",
153:                                                generatorParameters
154:                                                        .getValueMode());
155:
156:                                    }
157:                                }
158:                            } else {
159:                                //                        if (!importDefinitionAttributes.getTagSourceColumnName()[i].equalsIgnoreCase("version")) {
160:                                if (!importDefinitionAttributes
161:                                        .getTagColumnType()[i].toLowerCase()
162:                                        .endsWith("identity")) {
163:                                    Element childRoot3 = (Element) document
164:                                            .createElement("valueColumn");
165:                                    childRoot2.appendChild(childRoot3);
166:                                    childRoot3
167:                                            .setAttribute(
168:                                                    "sourceColumnName",
169:                                                    importDefinitionAttributes
170:                                                            .getTagSourceColumnName()[i]);
171:                                    childRoot3
172:                                            .setAttribute(
173:                                                    "targetTableName",
174:                                                    importDefinitionAttributes
175:                                                            .getTagTargetTableName()[i]);
176:                                    childRoot3
177:                                            .setAttribute(
178:                                                    "targetColumnName",
179:                                                    importDefinitionAttributes
180:                                                            .getTagTargetColumnName()[i]);
181:                                    childRoot3.setAttribute("targetTableID",
182:                                            importDefinitionAttributes
183:                                                    .getTagTargetTableID()[i]);
184:                                    childRoot3.setAttribute("valueMode",
185:                                            generatorParameters.getValueMode());
186:                                }
187:                                //                        } else {
188:                                //                            Element childRoot5 = (Element) document.createElement("constantColumns");
189:                                //                            childRoot1.appendChild(childRoot5);
190:                                //                            Element childRoot3 = (Element) document.createElement("constantColumn");
191:                                //                            childRoot5.appendChild(childRoot3);
192:                                //                            childRoot3.setAttribute("constantValue", "0");
193:                                //                            childRoot3.setAttribute("targetTableName", importDefinitionAttributes.getTagTargetTableName()[i]);
194:                                //                            childRoot3.setAttribute("targetColumnName", "version");
195:                                //                            childRoot3.setAttribute("targetTableID", "0");
196:                                //                            childRoot3.setAttribute("valueMode", generatorParameters.getValueMode());
197:                                //                        }
198:                            }
199:                        }
200:                    }
201:
202:                    if (!generatorParameters.getSourceType().equalsIgnoreCase(
203:                            "csv")) {
204:                        int j = 0;
205:                        if (generatorParameters.getValueMode()
206:                                .equalsIgnoreCase("Overwrite")) {
207:                            //
208:                        } else {
209:                            //valueMode=Overwrite
210:                            if (RelationshipsAttributes.getForeignVariables().length != 0) {
211:                                Element childRoot100 = (Element) document
212:                                        .createElement("relationColumns");
213:                                childRoot1.appendChild(childRoot100);
214:                                for (int i = 0; i < RelationshipsAttributes
215:                                        .getForeignVariables().length; i = i + 5) {
216:                                    Element childRoot101 = (Element) document
217:                                            .createElement("relationColumn");
218:                                    childRoot100.appendChild(childRoot101);
219:                                    childRoot101
220:                                            .setAttribute(
221:                                                    "relationSourceTableName",
222:                                                    RelationshipsAttributes
223:                                                            .getForeignVariables()[i + 3]);
224:                                    childRoot101.setAttribute(
225:                                            "relationTargetTableName",
226:                                            importDefinitionAttributes
227:                                                    .getTableName());
228:                                    childRoot101
229:                                            .setAttribute(
230:                                                    "relationTargetColumnName",
231:                                                    RelationshipsAttributes
232:                                                            .getForeignVariables()[i + 2]);
233:
234:                                    if (i > 5
235:                                            && RelationshipsAttributes
236:                                                    .getForeignVariables()[i + 3]
237:                                                    .equalsIgnoreCase(RelationshipsAttributes
238:                                                            .getForeignVariables()[(i + 3) - 5])) {
239:                                        j = j + 1;
240:                                    } else {
241:                                        j = 0;
242:                                    }
243:                                    childRoot101.setAttribute(
244:                                            "relationSourceTableID", "" + j);
245:                                    childRoot101.setAttribute(
246:                                            "relationTargetTableID", "0");
247:                                    childRoot101.setAttribute("relationMode",
248:                                            generatorParameters.getValueMode());
249:                                }
250:                            }
251:                        }
252:
253:                        int k = 0;
254:                        int l = 0;
255:                        if (RelationshipsAttributes.getForeignVariables().length != 0) {
256:                            Element childRoot200 = (Element) document
257:                                    .createElement("tables");
258:                            childRoot1.appendChild(childRoot200);
259:                            for (int i = 0; i < RelationshipsAttributes
260:                                    .getForeignVariables().length; i = i + 5) {
261:                                TableAttributes tableAttributes = new TableAttributes(
262:                                        importDefinitionAttributes
263:                                                .getTableName(),
264:                                        generatorParameters.getValueMode());
265:                                if (l == 0) {
266:                                    //in the first loop
267:                                    Element childRoot201 = (Element) document
268:                                            .createElement("table");
269:                                    childRoot200.appendChild(childRoot201);
270:                                    childRoot201.setAttribute("tableName",
271:                                            tableAttributes.getTableName());
272:                                    childRoot201
273:                                            .setAttribute("tableID", "" + k);
274:                                    childRoot201.setAttribute("insert",
275:                                            tableAttributes.getInsert());
276:                                    childRoot201.setAttribute("tableMode",
277:                                            tableAttributes.getTableMode());
278:                                    childRoot201.setAttribute("oidLogic",
279:                                            tableAttributes.getOidLogic());
280:                                    l++;
281:                                    k++;
282:                                }
283:                                if (generatorParameters.getValueMode()
284:                                        .equalsIgnoreCase("Overwrite")) {
285:                                    //
286:                                } else {
287:                                    //valueMode=Overwrite
288:                                    if (RelationshipsAttributes
289:                                            .getForeignVariables()[i + 3]
290:                                            .equalsIgnoreCase(importDefinitionAttributes
291:                                                    .getTableName())) {
292:                                        //k=k+1
293:                                        Element childRoot202 = (Element) document
294:                                                .createElement("table");
295:                                        childRoot200.appendChild(childRoot202);
296:                                        childRoot202.setAttribute("tableName",
297:                                                tableAttributes.getTableName());
298:                                        childRoot202.setAttribute("tableID", ""
299:                                                + k);
300:                                        childRoot202.setAttribute("insert",
301:                                                "false");
302:                                        childRoot202.setAttribute("tableMode",
303:                                                tableAttributes.getTableMode());
304:                                        childRoot202.setAttribute("oidLogic",
305:                                                tableAttributes.getOidLogic());
306:                                        k++; //
307:                                    } else {
308:                                        k = 0;
309:                                        if (i > 5
310:                                                && RelationshipsAttributes
311:                                                        .getForeignVariables()[i + 3]
312:                                                        .equalsIgnoreCase(RelationshipsAttributes
313:                                                                .getForeignVariables()[(i + 3) - 5])) {
314:                                            k = k + 1;
315:                                        } else {
316:                                            k = 0;
317:                                        }
318:                                        Element childRoot205 = (Element) document
319:                                                .createElement("table");
320:                                        childRoot200.appendChild(childRoot205);
321:                                        childRoot205
322:                                                .setAttribute(
323:                                                        "tableName",
324:                                                        RelationshipsAttributes
325:                                                                .getForeignVariables()[i + 3]);
326:                                        childRoot205.setAttribute("tableID", ""
327:                                                + k);
328:                                        childRoot205.setAttribute("insert",
329:                                                "false");
330:                                        childRoot205.setAttribute("tableMode",
331:                                                tableAttributes.getTableMode());
332:                                        childRoot205.setAttribute("oidLogic",
333:                                                tableAttributes.getOidLogic());
334:                                    }
335:                                }
336:                            }
337:                        } else {
338:                            //RelationshipsAttributes.getForeignVariables().length==0
339:                            Element childRoot200 = (Element) document
340:                                    .createElement("tables");
341:                            childRoot1.appendChild(childRoot200);
342:                            Element childRoot203 = (Element) document
343:                                    .createElement("table");
344:                            childRoot200.appendChild(childRoot203);
345:                            TableAttributes tableAttributes = new TableAttributes(
346:                                    importDefinitionAttributes.getTableName(),
347:                                    generatorParameters.getValueMode());
348:                            childRoot203.setAttribute("tableName",
349:                                    tableAttributes.getTableName());
350:                            childRoot203.setAttribute("tableID", "" + k);
351:                            childRoot203.setAttribute("insert", tableAttributes
352:                                    .getInsert());
353:                            childRoot203.setAttribute("tableMode",
354:                                    tableAttributes.getTableMode());
355:                            childRoot203.setAttribute("oidLogic",
356:                                    tableAttributes.getOidLogic());
357:                        }
358:                    } else {
359:                        //for csv tables
360:                        Element childRoot200 = (Element) document
361:                                .createElement("tables");
362:                        childRoot1.appendChild(childRoot200);
363:                        Element childRoot201 = (Element) document
364:                                .createElement("table");
365:                        childRoot200.appendChild(childRoot201);
366:                        TableAttributes tableAttributes = new TableAttributes(
367:                                importDefinitionAttributes.getTableName(),
368:                                generatorParameters.getValueMode());
369:                        childRoot201.setAttribute("tableName", tableAttributes
370:                                .getTableName());
371:                        childRoot201.setAttribute("tableID", tableAttributes
372:                                .getTableID());
373:                        childRoot201.setAttribute("insert", tableAttributes
374:                                .getInsert());
375:                        childRoot201.setAttribute("tableMode", tableAttributes
376:                                .getTableMode());
377:                        childRoot201.setAttribute("oidLogic", tableAttributes
378:                                .getOidLogic());
379:
380:                    }
381:                }
382:                this .logger.write("full", "WriteImportDefinition is finished.");
383:            }
384:
385:            /**
386:             * This method will set logger object
387:             * @param logger
388:             */
389:            private void setLogger() {
390:                this.logger = StandardLogger.getCentralLogger();
391:            }
392:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.