Source Code Cross Referenced for ValidatingStrategyBuilderImpl.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » etl » codegen » impl » 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 » IDE Netbeans » etl.project » org.netbeans.modules.etl.codegen.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:        package org.netbeans.modules.etl.codegen.impl;
020:
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.netbeans.modules.etl.codegen.ETLScriptBuilderModel;
025:        import org.netbeans.modules.etl.codegen.ETLStrategyBuilderContext;
026:        import org.netbeans.modules.sql.framework.common.jdbc.SQLDBConnectionDefinition;
027:        import org.netbeans.modules.sql.framework.common.utils.MonitorUtil;
028:        import org.netbeans.modules.sql.framework.codegen.StatementContext;
029:        import org.netbeans.modules.sql.framework.model.SQLDBTable;
030:        import org.netbeans.modules.sql.framework.model.SQLModelObjectFactory;
031:        import org.netbeans.modules.sql.framework.model.TargetTable;
032:
033:        import com.sun.etl.engine.ETLEngine;
034:        import com.sun.etl.engine.ETLTaskNode;
035:        import com.sun.sql.framework.exception.BaseException;
036:        import com.sun.sql.framework.jdbc.SQLPart;
037:        import org.netbeans.modules.sql.framework.model.DBConnectionDefinition;
038:
039:        /**
040:         * Extends base pipelining strategy builder to override methods which affect conduct and
041:         * execution of a validating collaboration.
042:         *
043:         * @author Jonathan Giron
044:         * @version $Revision$
045:         */
046:        public class ValidatingStrategyBuilderImpl extends
047:                PipelinedStrategyBuilderImpl {
048:            public ValidatingStrategyBuilderImpl(ETLScriptBuilderModel model)
049:                    throws BaseException {
050:                super (model);
051:            }
052:
053:            /**
054:             * Adds statement, if appropriate, to the given ETLTaskNode in order to obtain count
055:             * of rejected rows from rejection details table.
056:             *
057:             * @param updateStats ETLTaskNode to receive new statement
058:             * @param tt TargetTable instance from which rejected row table information is derived
059:             * @throws BaseException if error occurs during statement generation
060:             */
061:            @Override
062:            public void addSelectRejectedRowCountStatement(
063:                    ETLTaskNode updateStats, TargetTable tt)
064:                    throws BaseException {
065:                StatementContext context = new StatementContext();
066:                context.setUsingFullyQualifiedTablePrefix(false);
067:                context.setUsingUniqueTableName(true);
068:
069:                // Add SelectRejectedRowsCountFromDetailsTableStatement
070:                SQLPart selectRejectedCountPart = pipelineStmts
071:                        .getSelectRejectedRowsCountFromDetailsTableStatement(tt);
072:                selectRejectedCountPart
073:                        .setConnectionPoolName(ETLScriptBuilderModel.ETL_MONITOR_DB_CONN_DEF_NAME);
074:
075:                String tableName = db.getUnescapedName(db.getGeneratorFactory()
076:                        .generate(tt, context));
077:                selectRejectedCountPart.setTableName(tableName);
078:                updateStats.addTableSpecificStatement(tableName,
079:                        selectRejectedCountPart);
080:            }
081:
082:            @Override
083:            public String getScriptToDisplay(ETLStrategyBuilderContext context)
084:                    throws BaseException {
085:                super .checkTargetConnectionDefinition(context);
086:
087:                StringBuilder buffer = new StringBuilder();
088:                TargetTable targetTable = context.getTargetTable();
089:
090:                StatementContext stmtContext = new StatementContext();
091:                stmtContext.setUsingFullyQualifiedTablePrefix(false);
092:
093:                DBConnectionDefinition tgtConnDef = context.getModel()
094:                        .getConnectionDefinition(targetTable);
095:                buffer.append(MSG_MGR.getString(
096:                        "DISPLAY_TARGET_LOG_VALIDATING", targetTable
097:                                .getParent().getModelName(), tgtConnDef
098:                                .getDBType()));
099:                buffer.append("\n");
100:
101:                String targetLogSQL = getCreateLogDetailsTableSQL(targetTable);
102:                buffer.append(targetLogSQL).append("\n\n");
103:
104:                String transformSQL = createTransformStatement(targetTable,
105:                        stmtContext).getSQL();
106:                buffer.append(getCommentForTransformer(targetTable)).append(
107:                        "\n");
108:                buffer.append(transformSQL);
109:
110:                return buffer.toString();
111:            }
112:
113:            @Override
114:            protected void buildCleanupStatements(ETLTaskNode cleanupTask,
115:                    List targetTables) throws BaseException {
116:                super .buildCleanupStatements(cleanupTask, targetTables);
117:
118:                // Add statement to shut down the pipelining database.
119:                SQLPart shutdownPipeline = new SQLPart("SHUTDOWN",
120:                        SQLPart.STMT_DEFRAG,
121:                        ETLScriptBuilderModel.ETL_INSTANCE_DB_CONN_DEF_NAME);
122:                cleanupTask.addStatement(shutdownPipeline);
123:            }
124:
125:            @Override
126:            protected void buildInitializationStatements(SQLDBTable table,
127:                    ETLTaskNode initTask, Map connDefToLinkName)
128:                    throws BaseException {
129:                super .buildInitializationStatements(table, initTask,
130:                        connDefToLinkName);
131:                if (table instanceof  TargetTable) {
132:                    doBuildInitializationStatements((TargetTable) table,
133:                            initTask, connDefToLinkName);
134:                }
135:            }
136:
137:            /**
138:             * Implements construction of appropriate initialization statements for a validating
139:             * engine task.
140:             *
141:             * @param table TargetTable for which to construct initialization statements
142:             * @param initTask ETLTaskNode representing initialization node to hold generated
143:             *        statements
144:             * @param connDefToLinkName Map of DBConnectionDefinition instances to DB link names
145:             * @param pfGen PipelinedFlowGenerator instance to use in generating statements
146:             * @throws BaseException if error occurs during statement generation
147:             */
148:            protected void doBuildInitializationStatements(TargetTable table,
149:                    ETLTaskNode initTask, Map connDefToLinkName)
150:                    throws BaseException {
151:                StatementContext localContext = new StatementContext();
152:                localContext.setUsingFullyQualifiedTablePrefix(false);
153:                localContext.setUsingUniqueTableName(true);
154:
155:                TargetTable detailsTable = getLogTableFor(table);
156:
157:                if (!this .builderModel.isConnectionDefinitionOverridesApplied()) {
158:                    SQLPart dropLogPart = new SQLPart(getDropExternalTableSQL(
159:                            detailsTable, "", true, localContext),
160:                            SQLPart.STMT_INITIALIZESTATEMENTS,
161:                            ETLScriptBuilderModel.ETL_MONITOR_DB_CONN_DEF_NAME);
162:                    initTask.addOptionalTask(dropLogPart);
163:                }
164:
165:                SQLPart createLogPart = new SQLPart(
166:                        getCreateLogDetailsTableSQL(table),
167:                        SQLPart.STMT_INITIALIZESTATEMENTS,
168:                        ETLScriptBuilderModel.ETL_MONITOR_DB_CONN_DEF_NAME);
169:                initTask.addOptionalTask(createLogPart);
170:
171:                if (!this .builderModel.isConnectionDefinitionOverridesApplied()) {
172:                    SQLPart truncateLogPart = stmts.getTruncateStatement(
173:                            detailsTable, localContext);
174:                    truncateLogPart
175:                            .setConnectionPoolName(ETLScriptBuilderModel.ETL_MONITOR_DB_CONN_DEF_NAME);
176:                    truncateLogPart.setType(SQLPart.STMT_INITIALIZESTATEMENTS);
177:                    initTask.addOptionalTask(truncateLogPart);
178:                }
179:
180:                // Create DBLink for monitoring DB
181:                DBConnectionDefinition monitorDef = builderModel
182:                        .getConnectionDefinition(ETLScriptBuilderModel.ETL_MONITOR_DB_CONN_DEF_NAME);
183:                String linkName = monitorDef.getName();
184:
185:                SQLDBConnectionDefinition linkConnDef = SQLModelObjectFactory
186:                        .getInstance().createDBConnectionDefinition(monitorDef);
187:                linkConnDef.setDriverClass(monitorDef.getDriverClass());
188:                SQLPart createMonitorDbLink = new SQLPart(super 
189:                        .getCreateDBLinkSQL(linkConnDef, linkName),
190:                        SQLPart.STMT_INITIALIZESTATEMENTS,
191:                        ETLScriptBuilderModel.ETL_INSTANCE_DB_CONN_DEF_NAME);
192:                initTask.addOptionalTask(createMonitorDbLink);
193:
194:                // Add remote reference to table in monitoring DB from pipeline DB
195:                SQLPart createRemoteRefPart = new SQLPart(pipelineStmts
196:                        .getCreateRemoteLogDetailsTableStatement(table,
197:                                linkName).getSQL(),
198:                        SQLPart.STMT_INITIALIZESTATEMENTS,
199:                        ETLScriptBuilderModel.ETL_INSTANCE_DB_CONN_DEF_NAME);
200:                initTask.addOptionalTask(createRemoteRefPart);
201:
202:                SQLPart remountPart = new SQLPart(pipelineStmts
203:                        .getRemountRemoteLogDetailsStatement(detailsTable)
204:                        .getSQL(), SQLPart.STMT_INITIALIZESTATEMENTS,
205:                        ETLScriptBuilderModel.ETL_INSTANCE_DB_CONN_DEF_NAME);
206:                initTask.addOptionalTask(remountPart);
207:            }
208:
209:            /**
210:             * Overrides parent implementation to indicate that design-time form of the create
211:             * statement should be generated.
212:             *
213:             * @see org.netbeans.modules.etl.codegen.impl.ValidatingStrategyBuilderImpl#getCreateLogDetailsTableSQL(org.netbeans.modules.sql.framework.model.TargetTable)
214:             */
215:            protected String getCreateLogDetailsTableSQL(TargetTable table)
216:                    throws BaseException {
217:                return pipelineStmts.getCreateLogDetailsTableStatement(table,
218:                        this .builderModel.isMemoryMonitorDB()).getSQL();
219:            }
220:
221:            protected TargetTable getLogTableFor(SQLDBTable table) {
222:                TargetTable clone = SQLModelObjectFactory.getInstance()
223:                        .createTargetTable(table);
224:                clone.setAliasName(table.getAliasName());
225:                clone.setTablePrefix(MonitorUtil.LOG_DETAILS_TABLE_PREFIX);
226:                return clone;
227:            }
228:
229:            @Override
230:            protected String getTaskType() {
231:                return ETLEngine.VALIDATING;
232:            }
233:
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.