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 com.sun.jbi.ui.devtool.bpms.common.model.visitor.XMLParseVisitorException;
022: //import com.sun.jbi.ui.devtool.bpms.common.model.wsdl.Operation;
023: //import com.sun.jbi.ui.devtool.bpms.common.model.wsdl.PortType;
024: //import com.sun.jbi.ui.devtool.bpms.common.model.wsdl.WSDLDefinitions;
025: //import com.sun.jbi.ui.devtool.bpms.common.model.wsdl.WSDLDocument;
026: //import com.sun.jbi.ui.devtool.bpms.common.model.wsdl.WSDLMessage;
027: //import com.sun.jbi.ui.devtool.codegen.framework.model.CodeGenException;
028: //import com.sun.jbi.ui.devtool.codegen.framework.model.CodeGenFileSystem;
029: //import com.sun.jbi.ui.devtool.codegen.framework.model.CodeGenFramework;
030: //import com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet;
031: //import com.sun.jbi.ui.devtool.codegen.framework.model.ErrorBundle;
032: //import com.sun.jbi.ui.devtool.codegen.framework.model.FileGeneratorCodelet;
033: //import com.sun.jbi.ui.devtool.codegen.framework.model.ValidationCodelet;
034: //import com.sun.jbi.ui.devtool.codegen.framework.model.CodeGenFileSystem.CodeGenFolder;
035: //import com.sun.jbi.ui.devtool.codegen.framework.model.util.CodeGenHelper;
036: //import com.sun.jbi.ui.devtool.codegen.framework.model.util.DeploymentProfileGenerator;
037: //import com.sun.jbi.ui.devtool.codegen.framework.model.util.DeploymentProfileGenerator.MDBAttributes;
038: //import com.sun.jbi.ui.devtool.codegen.framework.runtime.DeployedElementName;
039: //import com.sun.jbi.ui.devtool.configuration.IConfiguration;
040: //import com.sun.jbi.ui.devtool.connector.repository.EWayConfiguration;
041: //import com.sun.jbi.ui.devtool.connector.repository.ExternalApplication;
042: //import com.sun.jbi.ui.devtool.connector.repository.ExternalSystemType;
043: //import com.sun.jbi.ui.devtool.connector.repository.ExternalType;
044: //import com.sun.jbi.ui.devtool.deployment.repository.ProjectDeployment;
045: //import com.sun.jbi.ui.devtool.etl.codegen.ETLCodegenUtil;
046: //import com.sun.jbi.ui.devtool.etl.codegen.ETLProcessFlowGeneratorFactory;
047: //import com.sun.jbi.ui.devtool.etl.model.ETLDefinition;
048: //import com.sun.jbi.ui.devtool.etl.model.ETLDefinitionProjectElement;
049: //import com.sun.jbi.ui.devtool.etl.model.impl.ETLDefinitionImpl;
050: //import com.sun.jbi.ui.devtool.etl.runtime.ejb.ETLRuntimeHandler;
051: //import com.sun.jbi.ui.devtool.etl.utils.ETLDeploymentConstants;
052: //import com.sun.jbi.ui.devtool.etl.utils.MessageManager;
053: //import com.sun.jbi.ui.devtool.logicalhost.repository.IntegrationServer;
054: //import com.sun.jbi.ui.devtool.model.common.Environment;
055: //import com.sun.jbi.ui.devtool.model.common.EnvironmentElement;
056: //import com.sun.jbi.ui.devtool.model.common.cme.CMLink;
057: //import com.sun.jbi.ui.devtool.model.common.cme.CMNode;
058: //import com.sun.jbi.ui.devtool.model.common.cme.Connectable;
059: //import com.sun.jbi.ui.devtool.model.common.cme.ConnectorConfiguration;
060: //import com.sun.jbi.ui.devtool.model.common.cme.ConnectorNode;
061: //import com.sun.jbi.ui.devtool.model.common.cme.Deployable;
062: //import com.sun.jbi.ui.devtool.model.common.cme.Port;
063: //import com.sun.jbi.ui.devtool.model.common.cme.ProcessingNode;
064: //import com.sun.jbi.ui.devtool.repository.RepositoryException;
065: //import com.sun.jbi.ui.devtool.sql.framework.exception.BaseException;
066: //import com.sun.jbi.ui.devtool.sql.framework.model.ValidationInfo;
067: //import com.sun.jbi.ui.devtool.sql.framework.utils.Logger;
068: //import com.sun.jbi.ui.devtool.sql.framework.utils.StringUtil;
069: //import com.sun.jbi.ui.devtool.sql.framework.utils.XmlUtil;
070:
071: /**
072: * Generates code for a given (@link Deployable) that includes ejb and resource adapter.
073: * Resource adapters are shared by mutiple collab participating in the same CME
074: *
075: * @author Sudhi Seshachala
076: * @author Ahimanikya Satapathy
077: * @author Jonathan Giron
078: * @author Girish Patil
079: * @version $Revision$
080: */
081:
082: public class ETLCodelet /*implements FileGeneratorCodelet, DeploymentProfileMgrCodelet, ValidationCodelet*/{
083:
084: // public static final String EXTERNAL_APPLICATION_TYPE_FLATFILEDB = "STCDBADAPTER"; // NOI18N
085: // private static final String LOG_CATEGORY = ETLCodelet.class.getName();
086: // private static final MessageManager MESSAGE_MGR = MessageManager.getManager(ETLCodelet.class);
087: // private static final String CONTAINER_TXN_MODE = "NotSupported";
088: // private static final List DEPENDENT_CLASS_NAMES = new ArrayList();
089: //
090: // static {
091: // /*
092: // * Note: the following JARs are in the RTS server classpath, so they won't be declared below:
093: // * <pre>
094: // * - activation.jar
095: // * - commons-collections[-3.x].jar
096: // * - commons-logging.jar
097: // * - jakarta-regexp.jar
098: // * </pre>
099: // */
100: // // com.sun.jbi.ui.devtool.etl.engineapi.jar: eTL (engine)
101: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.engine.ETLTask");
102: //
103: // // com.sun.jbi.ui.devtool.etl.engineimpl.jar: eTL (engine)
104: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.engine.impl.InitTask");
105: //
106: // // com.sun.jbi.ui.devtool.etl.utils.jar: eTL (engine)
107: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.utils.ETLException");
108: //
109: // // com.sun.jbi.ui.devtool.sqlframework.common.jar: eTL, sqlframework, flatfiledb (various)
110: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.sql.framework.exception.BaseException");
111: //
112: // // commons-jxpath.jar: eTL (runtime.ETLBeanMessageImpl)
113: // DEPENDENT_CLASS_NAMES.add("org.apache.commons.jxpath.JXPathContext");
114: //
115: // // com.sun.jbi.ui.devtool.etl.monitor.jar: eTL (ETL MBean server)
116: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.monitor.mbeans.ETLMBeanLoader");
117: //
118: // // AxionDB.jar: eTL, sqlframework, flatfiledb (various)
119: // DEPENDENT_CLASS_NAMES.add("org.axiondb.jdbc.AxionDriver");
120: //
121: // // add axion query jar org.axiondb.service
122: // DEPENDENT_CLASS_NAMES.add("org.axiondb.service.AxionDBQuery");
123: //
124: // // add eView API jar "com.sun.jbi.ui.devtool.sbmeapi.jar"
125: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.sbmeapi.StandardizationAPI");
126: //
127: // // add eView API Impl/Lib jar "com.sun.jbi.ui.devtool.sbmeapiimpl.jar"
128: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.sbmeapi.impl.StandConfigFilesAccessImpl");
129: //
130: // // add eInsight jar, required by com.sun.jbi.ui.devtool.etl.runtime.ETLBeanMessageFactory
131: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.bpms.bpel.runtime.BeanMessageFactory");
132: //
133: // // com.sun.jbi.ui.devtool.sunconfigapi_runtime.jar
134: // DEPENDENT_CLASS_NAMES.add("com.sun.jbi.ui.devtool.configuration.AttributeTransformer");
135: //
136: //
137: // // >
138: // // > Listed below are JARs which require special handling.
139: // // >
140: //
141: // // NOTE: We don't use UnmodifiableIntIterator in our code, but reference it here
142: // // because it doesn't exist in obsolete versions of commons-collections JARs which
143: // // also include tbe primitives package.
144: //
145: // // commons-primitives-1.0.jar: AxionDB (various)
146: // DEPENDENT_CLASS_NAMES.add("org.apache.commons.collections.primitives.decorators.UnmodifiableIntIterator");
147: // }
148: //
149: // private static final List RUNTIME_CLASS_NAMES = new ArrayList();
150: // static {
151: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.ETLBeanMessageImpl");
152: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.ETLBeanMessageImpl$1");
153: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.ETLPersistableMessageImpl");
154: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.ETLBeanMessageFactory");
155: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.StartETLEngine");
156: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.RuntimeUtil");
157: // RUNTIME_CLASS_NAMES.add("com.sun.jbi.ui.devtool.etl.runtime.ejb.ETLRuntimeHandler");
158: // }
159: //
160: // private static final List RESOURCE_NAMES = new ArrayList();
161: // static {
162: // RESOURCE_NAMES.add("com/sun/jbi/ui/devtool/etl/runtime/eTLAlert.properties");
163: // }
164: //
165: // private Deployable deployable;
166: // private DeployedElementName deployedName;
167: //
168: // private CodeGenFolder ejbFolder;
169: // private CodeGenFramework framework;
170: // private CodeGenHelper helper;
171: // private ProjectDeployment projectDeployment;
172: // private ETLDefinitionProjectElement etlDef;
173: // private DeploymentProfileGenerator dpGen;
174: // private String runtimeServerWorkspaceDir;
175: //
176: // public ETLCodelet(ProjectDeployment pd, CodeGenFramework fw, Deployable theDeployable) throws CodeGenException {
177: // this.framework = fw;
178: // this.deployable = theDeployable;
179: // this.projectDeployment = pd;
180: // this.dpGen = fw.createDeploymentProfileHelper();
181: //
182: // try {
183: // this.etlDef = (ETLDefinitionProjectElement) ((ProcessingNode) deployable).getProcessingDefinition();
184: // } catch (RepositoryException repoEx) {
185: // String errMsg = MESSAGE_MGR.getString("ERR_REPOSITORY_EX");
186: // Logger.print(Logger.ERROR, LOG_CATEGORY, errMsg, repoEx);
187: // throw new CodeGenException(errMsg);
188: // }
189: //
190: // try {
191: // this.deployedName = framework.getDeployedElementName(deployable);
192: // } catch (CodeGenException e) {
193: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Failed to initialize in ETLCodelet", e);
194: // throw new CodeGenException(MESSAGE_MGR.getString("ERR_BADNAME_CONSTRUCTOR"));
195: // }
196: // }
197: //
198: // // NOTE: codegen framework calls generateFiles() first and then
199: // // generateDeploymentProfile() get called.
200: //
201: // /*
202: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#generateDeploymentProfile
203: // */
204: // public void generateDeploymentProfile(CodeGenFileSystem fs) throws CodeGenException {
205: // try {
206: // // Specify the name space for ETL Runtime Handler
207: // addEnv(ETLDeploymentConstants.STC_NAME_SPACE, deployedName.getNamespace());
208: //
209: // // Specify the engine file name generated earlier
210: // addEnv(ETLDeploymentConstants.ETL_ENGINE_FILE, StringUtil.escapeNonAlphaNumericCharacters(getLocalPart()) + ".xml");
211: //
212: // // Specify the Collaboration name
213: // addEnv(ETLDeploymentConstants.COLLAB_NAME, getLocalPart());
214: //
215: // // Specify the Project name
216: // String projName = ((ProcessingNode) this.deployable).getParentConnectivityMap().getParentProject().getName();
217: // projName = getHelper().convertString(projName);
218: // addEnv(ETLDeploymentConstants.PROJECT_NAME, projName);
219: //
220: // // Specify the class name for ETLHandler; do we still need it ?
221: // addEnv(ETLDeploymentConstants.CLASS_NAME, ETLRuntimeHandler.class.getName());
222: //
223: // // Specify the operation name; currently we only support "execute"
224: // addEnv(ETLDeploymentConstants.OPERATION_NAME_TAG, ETLDeploymentConstants.OPERATION_NAME);
225: //
226: // // Specify relative path to engine working directory in app-server file
227: // // system, assuming we use whatever working directory is supplied by the
228: // // app-server as the root.
229: // addEnv(ETLDeploymentConstants.ETL_ENGINE_INSTANCE_DB_DIR, getEngineInstanceDBDirectory());
230: // addEnv(ETLDeploymentConstants.ETL_MONITOR_DB_DIR, getEngineMonitorDBDirectory());
231: // addEnv(ETLDeploymentConstants.RUNTIME_SERVER_WORKSPACE_DIR, getRuntimeServerWorkspaceDir());
232: //
233: // // Get Project Deployment Reference
234: // ProjectDeployment projDeployment = framework.getProjectDeployment();
235: //
236: // // Get the deployment envronment to which the project has been deployed
237: // Environment environment = projDeployment.getEnvironment();
238: // EnvironmentElement envElement = projDeployment.getDeployedElement(this.deployable, environment);
239: //
240: // // Get the Integration server from the envronment
241: // String is = ((IntegrationServer) envElement).getName();
242: // addEnv(ETLDeploymentConstants.IS, is);
243: //
244: // // Get the LogicalHost server from the envronment
245: // String lh = ((IntegrationServer) envElement).getParentLogicalHost().getName();
246: // addEnv(ETLDeploymentConstants.LH, lh);
247: //
248: // // Copy required jar files to EJBFolder
249: // copyDependentJars(fs);
250: //
251: // // Specify the deployment name
252: // addEnv(ETLDeploymentConstants.DEPLOYMENT_NAME, projDeployment.getName());
253: //
254: // // Specify the environment name
255: // String environmentName = environment.getName();
256: // addEnv(ETLDeploymentConstants.ENVIRONMENT_NAME, environmentName);
257: //
258: // // Set container transaction mode
259: // dpGen.addContainerTransactionForDeployedService(this, ejbFolder, null, "*", null, CONTAINER_TXN_MODE);
260: //
261: // // validate the WSDL
262: // validateWSDL(etlDef);
263: // } catch (BaseException baseEx) {
264: // String errMsg = MESSAGE_MGR.getString("ERR_BASE_EX");
265: // Logger.print(Logger.ERROR, LOG_CATEGORY, errMsg, baseEx);
266: // throw new CodeGenException(errMsg, baseEx);
267: // } catch (RepositoryException repoEx) {
268: // String errMsg = MESSAGE_MGR.getString("ERR_REPOSITORY_EX");
269: // Logger.print(Logger.ERROR, LOG_CATEGORY, errMsg, repoEx);
270: // throw new CodeGenException(errMsg, repoEx);
271: // }
272: // }
273: //
274: // public void generateFiles(CodeGenFileSystem codeGenFileSystem) throws CodeGenException {
275: // // STEP1:Create and Initialize the EJB folder for Runtime Handler
276: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Code generation: generating files for " + this.getLocalPart());
277: //
278: // ejbFolder = codeGenFileSystem.createEJBFolder(this);
279: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Code generation: target dir = " + ejbFolder.getDir());
280: //
281: // try {
282: // // STEP2: Generate eTL engine file
283: // // Use collabServiceName as it is guaranteed to be unique in multi collab CMAP.
284: // String collabServiceName = StringUtil.escapeNonAlphaNumericCharacters(getLocalPart()) + ".xml";
285: // Collection pnLinks = getProcessingNode().getLinks();
286: // GenerateEngineFile fileGenerator = new GenerateEngineFile(this, pnLinks, this.etlDef, this.projectDeployment);
287: // String engineFile = fileGenerator.getEngineTaskNodes();
288: // writeEngineFile(engineFile, collabServiceName);
289: // } catch (RepositoryException e) {
290: // String errMsg = MESSAGE_MGR.getString("ERR_REPOSIT_EX_GENERATE_FILES");
291: // Logger.print(Logger.ERROR, LOG_CATEGORY, errMsg, e.toString());
292: // throw new CodeGenException(errMsg, e);
293: // } catch (Exception t) {
294: // String errMsg = MESSAGE_MGR.getString("ERR_THROWABLE_GENERATE_FILES");
295: // Logger.print(Logger.ERROR, LOG_CATEGORY, errMsg, t);
296: // if (t instanceof CodeGenException) {
297: // errMsg = ((CodeGenException) t).getLocalizedMessage();
298: // }
299: // throw new CodeGenException(errMsg, t);
300: // }
301: // }
302: //
303: // /*
304: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.Codelet#getDebugName
305: // */
306: // public String getDebugName() {
307: // return "eTL Integrator Codelet";
308: // }
309: //
310: // /*
311: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#getRequestHandlerAttributes
312: // */
313: // public DeployedServiceAttributes getDeployedServiceAttributes() {
314: // return new DeployedServiceAttributes() {
315: // public String getClassName() {
316: // return ETLRuntimeHandler.class.getName();
317: // }
318: // };
319: // }
320: //
321: // /*
322: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#getEntryPointAttributes
323: // */
324: // public MDBAttributes getEntryPointAttributes() {
325: // return null;
326: // }
327: //
328: // /*
329: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.Codelet#getOwner
330: // */
331: // public Deployable getOwner() {
332: // return this.deployable;
333: // }
334: //
335: // /*
336: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#isRequestHandler()
337: // */
338: // public boolean isDeployedService() {
339: // return true;
340: // }
341: //
342: // /*
343: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#isEntryPointForRequestHandler
344: // */
345: // public boolean isEntryPointToDeployedService() {
346: // return false;
347: // }
348: //
349: // /*
350: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#postDeploymentProfileGeneration
351: // */
352: // public void postDeploymentProfileGeneration(CodeGenFileSystem fs) throws CodeGenException {
353: // }
354: //
355: // /*
356: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.FileGeneratorCodelet#postFileGeneration
357: // */
358: // public void postFileGeneration(CodeGenFileSystem fs) throws CodeGenException {
359: // }
360: //
361: // /*
362: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.DeploymentProfileMgrCodelet#preDeploymentProfileGeneration
363: // */
364: // public void preDeploymentProfileGeneration(CodeGenFileSystem fs) throws CodeGenException {
365: // }
366: //
367: // /*
368: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.FileGeneratorCodelet#preFileGeneration
369: // */
370: // public void preFileGeneration(CodeGenFileSystem fs) throws CodeGenException {
371: // }
372: //
373: // /**
374: // * @see com.sun.jbi.ui.devtool.codegen.framework.model.ValidationCodelet#validate()
375: // */
376: // public ErrorBundle validate(){
377: // ErrorBundle errBundle = framework.createErrorBundle();
378: // try {
379: // validateETLDefinition(errBundle);
380: // validateDeplymentConfiguration(errBundle);
381: // // TODO move below validation to SQLDefination.
382: // ETLProcessFlowGeneratorFactory.validateExecutionMode(this.getETLDefinition(etlDef).getSQLDefinition());
383: // }catch (Exception ex) {
384: // int i = getNextSequenceForErrorBundle(errBundle);
385: // errBundle.addError(framework.createErrorEntry(projectDeployment, new Integer(i++), "Exception:" + ex.getMessage()));
386: // }
387: // return errBundle;
388: // }
389: //
390: // public String getExternalSystemType(CMLink link) throws RepositoryException {
391: // CMNode destNode = link.getDestinationNode();
392: // Connectable connectable = null;
393: // if (destNode instanceof ConnectorNode) {
394: // connectable = ((ConnectorNode) destNode).getConnectable();
395: // return getDeploymentDBType(connectable);
396: // }
397: // return null;
398: // }
399: //
400: // /**
401: // * Gets full name of ExternalSystem type associated with the given CMLink.
402: // *
403: // * @param link CMLink whose ExternalSystem type name is to be obtained
404: // * @return full name of ExternalSystem type, or " <Unknown>" if non-existent.
405: // */
406: // public String getExternalSystemTypeName(CMLink link) throws RepositoryException {
407: // ConnectorConfiguration connConfig = link.getConnectorConfiguration();
408: // ExternalSystemType extSystemType = null;
409: //
410: // if (connConfig != null){
411: // ExternalType extType = ((EWayConfiguration) connConfig).getExternalType();
412: // // Some migrated AxionDB's configuration have null values.
413: // if (extType != null){
414: // extSystemType = extType.getExternalSystemType();
415: // }
416: // }
417: //
418: // return (extSystemType != null) ? extSystemType.getName() : MESSAGE_MGR.getString("LBL_UNKNOWN");
419: // }
420: //
421: //
422: // /**
423: // * Generates a unique relative path to engine working directory.
424: // * @return String representing relative path to engine working directory on app server
425: // */
426: // String getEngineInstanceDBDirectory() throws BaseException {
427: // return ETLCodegenUtil.getEngineInstanceWorkingFolder();
428: // }
429: //
430: // /**
431: // * Generates a unique relative path to monitor db directory.
432: // * @return String representing relative path to monitor db directory on app server
433: // */
434: // String getEngineMonitorDBDirectory() throws BaseException {
435: // return ETLCodegenUtil.getMonitorDBDir(this.getDeployable());
436: // }
437: //
438: //
439: // private String getDeploymentDBType(Connectable connectable) throws RepositoryException {
440: // if (connectable != null && connectable instanceof ExternalApplication) {
441: // ExternalApplication extApp = (ExternalApplication) connectable;
442: // return extApp.getExternalApplicationType().getModuleName();
443: // }
444: // return EXTERNAL_APPLICATION_TYPE_FLATFILEDB;
445: // }
446: //
447: // /**
448: // * @return Returns the deployedName.
449: // */
450: // protected DeployedElementName getDeployedName() {
451: // return deployedName;
452: // }
453: //
454: // protected ETLDefinition getETLDefinition(ETLDefinitionProjectElement etldef) throws RepositoryException, BaseException {
455: // String content = etldef.getETLDefinitionContent();
456: // Element elem = XmlUtil.loadXMLString(content);
457: // ETLDefinition etlDefn = new ETLDefinitionImpl(elem, etldef);
458: // return etlDefn;
459: // }
460: //
461: // private void addEnv(String key, String value) throws CodeGenException {
462: // String type = ETLDeploymentConstants.STRING;
463: // this.dpGen.addEnv(this.ejbFolder, getLocalPart(), key, type, value);
464: // }
465: //
466: // private void copyDependentJars(CodeGenFileSystem codeGenFileSystem) throws CodeGenException {
467: //
468: // // Add other required jar files to the EAR file and have the RAR file refer it.
469: // Iterator iter = DEPENDENT_CLASS_NAMES.iterator();
470: // while (iter.hasNext()) {
471: // String className = (String) iter.next();
472: // if (!addJarForClass(className, codeGenFileSystem)) {
473: // throw new CodeGenException(MESSAGE_MGR.getString("ERR_JARMISSING_COPY_DEPENDENT_JARS", className));
474: // }
475: // }
476: //
477: // // Just to package what is needed for ETLRuntimeHandler
478: // packageRuntime(ejbFolder.getDir());
479: // }
480: //
481: //
482: // /**
483: // * Gets path to library JAR file, if any, that contains the given Class.
484: // *
485: // * @param clazz Class whose containing JAR is to be located
486: // * @return String representing path to containing JAR, or null if no such JAR exists
487: // */
488: // private String getFilePath(Class clazz) {
489: // File jarFile = (clazz != null) ? getHelper().getJar(getClass().getClassLoader(), clazz) : null;
490: // return (jarFile != null) ? jarFile.getAbsolutePath() : null;
491: // }
492: //
493: // /**
494: // * Gets path to library JAR file, if any, that contains the Class represented by the
495: // * given String.
496: // *
497: // * @param clazz Class whose containing JAR is to be located
498: // * @return String representing path to containing JAR, or null if no such JAR exists
499: // */
500: // private String getFilePath(String className) {
501: // try {
502: // ClassLoader cl = getClass().getClassLoader();
503: // return getFilePath(cl.loadClass(className));
504: // } catch (ClassNotFoundException cnf) {
505: // return null;
506: // }
507: // }
508: //
509: // /**
510: // * Locates the JAR, if any, containing the class represented by the given classname
511: // * String and adds it to the EAR.
512: // *
513: // * @param className name of class whose JAR is to be added
514: // * @param cgFileSystem ref to CodeGenFileSystem representing EAR image
515: // * @return true if JAR was located for <code>className</code> and copied to
516: // * <code>cgFileSystem</code>, false otherwise
517: // */
518: // private boolean addJarForClass(String className, CodeGenFileSystem cgFileSystem) {
519: // if (Logger.isDebugEnabled(LOG_CATEGORY)) {
520: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Resolving JAR for class " + className);
521: // }
522: //
523: // String filePath = getFilePath(className);
524: // if (filePath != null) {
525: // if (Logger.isDebugEnabled(LOG_CATEGORY)) {
526: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Resolved " + className + " to JAR " + filePath);
527: // }
528: //
529: // File jarFile = new File(filePath);
530: // cgFileSystem.addApplicationAPI(jarFile, this);
531: // return true;
532: // }
533: //
534: // return false;
535: // }
536: //
537: // /**
538: // * Gets instance of CodeGenHelper for this codelet instance.
539: // *
540: // * @return associated CodeGenHelper instance
541: // */
542: // private CodeGenHelper getHelper() {
543: // if (this.helper == null) {
544: // this.helper = framework.createCodeGenHelper();
545: // }
546: // return this.helper;
547: // }
548: //
549: // private String getLocalPart() {
550: // return deployedName.getLocalPart();
551: // }
552: //
553: // private ProcessingNode getProcessingNode() throws CodeGenException {
554: // try {
555: // return (ProcessingNode) this.deployable;
556: // } catch (ClassCastException e) {
557: // String msg = MESSAGE_MGR.getString("ERR_CLASSCAST_EX_GETPROCESSINGNODE");
558: // Logger.print(Logger.WARN, LOG_CATEGORY, msg);
559: // throw new CodeGenException(msg);
560: // }
561: // }
562: //
563: // private void packageRuntime(File outputDir) throws CodeGenException {
564: // CodeGenHelper cgHelper = getHelper();
565: //
566: // // Packages individual classes
567: // String className = null;
568: // Iterator iter = RUNTIME_CLASS_NAMES.iterator();
569: // try {
570: // while (iter.hasNext()) {
571: // className = (String) iter.next();
572: // cgHelper.copyJavaClassToFile(className, getClass().getClassLoader(), outputDir);
573: // }
574: // } catch (IOException e) {
575: // throw new CodeGenException(MESSAGE_MGR.getString("ERR_IO_EX_PACKAGERUNTIME", className));
576: // }
577: //
578: // // Package individual resources
579: // String resourceName = null;
580: // iter = RESOURCE_NAMES.iterator();
581: // try {
582: // while (iter.hasNext()) {
583: // resourceName = (String) iter.next();
584: // cgHelper.copyResourceToFile(resourceName, getClass().getClassLoader(), outputDir);
585: // }
586: // } catch (IOException e) {
587: // throw new CodeGenException(MESSAGE_MGR.getString("ERR_IO_EX_PACKAGERUNTIME", className));
588: // }
589: //
590: // }
591: //
592: // private int validateETLDefinition(ErrorBundle errorBundle) {
593: // int i = 1;
594: // try {
595: // i = getNextSequenceForErrorBundle(errorBundle);
596: // List invalidObjectList = this.getETLDefinition(etlDef).validate();
597: // if (invalidObjectList.size() > 0) {
598: // Iterator iter = invalidObjectList.iterator();
599: // while (iter.hasNext()) {
600: // ValidationInfo invalidObj = (ValidationInfo) iter.next();
601: // if (invalidObj.getValidationType() == ValidationInfo.VALIDATION_ERROR) {
602: // String errorMessage = MESSAGE_MGR.getString("ERR_ENTRY_VALIDATECONFIG", invalidObj.getDescription());
603: // errorBundle.addError(this.framework.createErrorEntry(etlDef, new Integer(i++), errorMessage));
604: // }
605: // }
606: // }
607: // } catch (Exception e) {
608: // errorBundle.addError(this.framework.createErrorEntry(etlDef, new Integer(i), e.toString()));
609: // }
610: // return i;
611: // }
612: //
613: // private int getNextSequenceForErrorBundle(ErrorBundle errorBundle) {
614: // int i = 1;
615: //
616: // if (errorBundle == null) {
617: // errorBundle = framework.createErrorBundle();
618: // }
619: //
620: // Collection tc = errorBundle.getErrors() ;
621: // if (tc != null) {
622: // i = (i <= tc.size())?(tc.size()+1): i;
623: // }
624: // return i;
625: // }
626: //
627: // private void validateDeplymentConfiguration(ErrorBundle errorBundle){
628: // try {
629: // validateDBConfiguarion(errorBundle);
630: // validateRuntimeServerConfiguarion(errorBundle);
631: //
632: // }catch (CodeGenException ex) {
633: // int i = getNextSequenceForErrorBundle(errorBundle);
634: // errorBundle.addError(this.framework.createErrorEntry(etlDef, new Integer(i++), ex.getMessage()));
635: // }catch (RepositoryException ex) {
636: // int i = getNextSequenceForErrorBundle(errorBundle);
637: // errorBundle.addError(this.framework.createErrorEntry(etlDef, new Integer(i++), ex.getMessage()));
638: // }
639: // }
640: //
641: // private int validateDBConfiguarion(ErrorBundle errorBundle)
642: // throws CodeGenException, RepositoryException {
643: // int i = getNextSequenceForErrorBundle(errorBundle);
644: // String portName = null;
645: // String externalSystemType = null;
646: // String extSysTypeName = null;
647: // String errorMessage = null;
648: // String linkName = null;
649: //
650: // Collection pnLinks = getProcessingNode().getLinks();
651: // ETLDefinitionProjectElement etlProcessDefinition = this.etlDef;
652: // CMLink link = null;
653: // Port port = null;
654: // com.sun.jbi.ui.devtool.model.common.cme.PortType portType = null;
655: // ConnectorConfiguration connectorConfig = null;
656: // IConfiguration config = null;
657: // EnvironmentElement ee = null;
658: //
659: // Iterator it = pnLinks.iterator();
660: // while (it.hasNext()) {
661: // Object objRef = it.next();
662: // if (objRef != null && objRef instanceof CMLink) {
663: // link = (CMLink) objRef;
664: // portName = link.getSourcePort();
665: // port = null;
666: // externalSystemType = getExternalSystemType(link);
667: // extSysTypeName = "<Unknown>";
668: // config = null;
669: // errorMessage = null;
670: // linkName = link.getName();
671: // ee = projectDeployment.getDeployedElement(link, projectDeployment.getEnvironment());
672: //
673: // if (portName != null) {
674: // port = etlProcessDefinition.getDestination(portName);
675: // if (port != null) {
676: // if ((!EXTERNAL_APPLICATION_TYPE_FLATFILEDB.equalsIgnoreCase(externalSystemType))) {
677: // portType = port.getPortType();
678: // connectorConfig = link.getConnectorConfiguration();
679: //
680: // if (portType != null) {
681: // config = ETLCodegenHelper.getIConfiguration(connectorConfig, link.getName());
682: // if ((config == null) || (config.getSections() == null)) {
683: // errorMessage = MESSAGE_MGR.getString("ERR_CONN_CONFIG_MISSING", linkName);
684: // errorBundle.addError(this.framework.createErrorEntry(ee, new Integer(i++), errorMessage));
685: // } else {
686: // extSysTypeName = getExternalSystemTypeName(link);
687: // Map sectionMap = config.getSections();
688: // if (!sectionMap.containsKey("JDBCConnectorSettings")) {
689: // errorMessage = MESSAGE_MGR.getString("ERR_CONN_CONFIG_SECTION_JDBC_MISSING", linkName);
690: // errorBundle.addError(this.framework.createErrorEntry(ee, new Integer(i++), errorMessage));
691: // }
692: // }
693: // }
694: //
695: // }
696: //
697: // try {
698: // config = ETLCodegenHelper.getExternalSystemConfiguration(link, this.projectDeployment, extSysTypeName);
699: // if (config == null) {
700: // errorMessage = MESSAGE_MGR.getString("ERR_CONN_PARAMS_MISSING", ee.getName(), extSysTypeName);
701: // errorBundle.addError(this.framework.createErrorEntry(ee, new Integer(i++), errorMessage));
702: // }
703: // } catch (Exception ex) {
704: // errorMessage = MESSAGE_MGR.getString("ERR_CONN_PARAMS_MISSING", ee.getName(), extSysTypeName);
705: // errorBundle.addError(this.framework.createErrorEntry(ee, new Integer(i++), errorMessage));
706: // }
707: // }
708: // }
709: // }
710: // }
711: // return i;
712: // }
713: //
714: // private void validateRuntimeServerConfiguarion(ErrorBundle errorBundle){
715: // String tWorkspaceDir = null;
716: //
717: // if (errorBundle == null) {
718: // errorBundle = framework.createErrorBundle();
719: // }
720: //
721: //
722: // tWorkspaceDir = ETLCodegenUtil.getRSWorkspaceDir(framework, errorBundle, projectDeployment, getDeployable());
723: //
724: // if (tWorkspaceDir != null) {
725: // this.runtimeServerWorkspaceDir = tWorkspaceDir;
726: // }
727: // }
728: //
729: // private void validateWSDL(ETLDefinitionProjectElement def) throws RepositoryException, XMLParseVisitorException, CodeGenException {
730: // WSDLDocument doc = def.getWSDLDocument();
731: // WSDLDefinitions wsdlDef = doc.getDocumentDefinitions();
732: // Collection portTypes = wsdlDef.getPortTypes();
733: // Collection messages = wsdlDef.getMessages();
734: // List messageList = new ArrayList();
735: //
736: // if (portTypes == null || portTypes.size() == 0) {
737: // String mesg = MESSAGE_MGR.getString("ERR_NOPORTTYPES_VALIDATEWSDL", getLocalPart());
738: // Logger.print(Logger.ERROR, LOG_CATEGORY, mesg);
739: // throw new CodeGenException(mesg);
740: // }
741: //
742: // for (Iterator it = portTypes.iterator(); it.hasNext();) {
743: // PortType type = (PortType) it.next();
744: // Collection operations = type.getOperations();
745: //
746: // if (operations == null || operations.size() == 0) {
747: // String mesg = MESSAGE_MGR.getString("ERR_NOOPERATIONS_VALIDATEWSDL", type.getName());
748: // Logger.print(Logger.ERROR, LOG_CATEGORY, mesg);
749: // throw new CodeGenException(mesg);
750: // }
751: //
752: // for (Iterator opIt = operations.iterator(); opIt.hasNext();) {
753: // Operation op = (Operation) opIt.next();
754: // messageList.add(op.getInput().getMessage());
755: // messageList.add(op.getOutput().getMessage());
756: // }
757: //
758: // if (messageList.size() == 0) {
759: // String mesg = MESSAGE_MGR.getString("ERR_NOMESSAGETYPES_VALIDATEWSDL", getLocalPart());
760: // Logger.print(Logger.ERROR, LOG_CATEGORY, mesg);
761: // throw new CodeGenException(mesg);
762: // }
763: // }
764: //
765: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Message List = " + messageList);
766: // for (Iterator it = messageList.iterator(); it.hasNext();) {
767: // String mesgName = (String) it.next();
768: // boolean messageTypeFound = false;
769: // for (Iterator ms = messages.iterator(); ms.hasNext();) {
770: // WSDLMessage wMesg = (WSDLMessage) ms.next();
771: // String mesg = wMesg.getName();
772: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "message type = " + mesg);
773: // if (mesgName.equals("tns:" + mesg)) {
774: // messageTypeFound = true;
775: // mesgName = mesg;
776: // break;
777: // }
778: // }
779: //
780: // if (!messageTypeFound) {
781: // String msg = MESSAGE_MGR.getString("ERR_NOMSGMATCHFOROPER_VALIDATEWSDL", mesgName);
782: // Logger.print(Logger.DEBUG, LOG_CATEGORY, msg);
783: // throw new CodeGenException(msg);
784: // }
785: // }
786: // }
787: //
788: // private void writeEngineFile(String engineContent, String fileName) throws IOException {
789: // String filePath = ejbFolder.getDir() + File.separator;
790: // File etlEngineFile = new File(filePath + fileName);
791: //
792: // Logger.print(Logger.DEBUG, LOG_CATEGORY, "Creating eTL engine file: " + etlEngineFile);
793: // FileWriter writer = new FileWriter(etlEngineFile);
794: // writer.write(engineContent);
795: // writer.close();
796: // }
797: //
798: // public Deployable getDeployable() {
799: // return this.deployable;
800: // }
801: //
802: // public String getRuntimeServerWorkspaceDir() {
803: // return this.runtimeServerWorkspaceDir;
804: // }
805: }
|