use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class GuessSchemaProcess method buildProcess.
private void buildProcess() {
process = new Process(property);
process.getContextManager().getListContext().addAll(node.getProcess().getContextManager().getListContext());
process.getContextManager().setDefaultContext(this.selectContext);
outputComponent = ComponentsFactoryProvider.getInstance().get(EDatabaseComponentName.FILEDELIMITED.getOutPutComponentName(), ComponentCategory.CATEGORY_4_DI.getName());
if (node.getModulesNeeded().size() > 0 && !node.getComponent().getName().equals("tRedshiftInput")) {
//$NON-NLS-1$
for (ModuleNeeded module : node.getModulesNeeded()) {
if (module.isRequired(node.getElementParameters())) {
Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE, ComponentCategory.CATEGORY_4_DI.getName()), process);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
libNode1.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
NodeContainer nc = process.loadNodeContainer(libNode1, false);
process.addNodeContainer(nc);
}
}
} else {
// hywang add for 9594
if (node.getComponent().getName().equals("tJDBCInput") || node.getComponent().getName().equals("tRedshiftInput")) {
List<String> drivers = EDatabaseVersion4Drivers.getDrivers(info.getTrueDBTypeForJDBC(), info.getDbVersion());
String moduleNeedName = "";
Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE, ComponentCategory.CATEGORY_4_DI.getName()), process);
if (drivers.size() > 0) {
// use the first driver as defalult.
// added for bug 13592
moduleNeedName = drivers.get(0).toString();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
libNode1.setPropertyValue("LIBRARY", "\"" + moduleNeedName + "\"");
}
process.addNodeContainer(new NodeContainer(libNode1));
}
}
INode connectionNode = null;
IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
if (useExistConnection) {
IElementParameter connector = node.getElementParameter("CONNECTION");
if (connector != null) {
String connectorValue = connector.getValue().toString();
List<? extends INode> generatingNodes = originalProcess.getGeneratingNodes();
for (INode node : generatingNodes) {
if (node.getUniqueName().equals(connectorValue)) {
connectionNode = node;
break;
}
}
}
}
List<ModuleNeeded> neededLibraries = new ArrayList<ModuleNeeded>();
JavaProcessUtil.addNodeRelatedModules(process, neededLibraries, node);
for (ModuleNeeded module : neededLibraries) {
Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE), process);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
libNode1.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
process.addNodeContainer(new NodeContainer(libNode1));
}
if (connectionNode != null) {
neededLibraries = new ArrayList<ModuleNeeded>();
JavaProcessUtil.addNodeRelatedModules(process, neededLibraries, connectionNode);
for (ModuleNeeded module : neededLibraries) {
Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE), process);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
libNode1.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
process.addNodeContainer(new NodeContainer(libNode1));
}
}
// create the tLibraryLoad for the output component which is "tFileOutputDelimited"
for (ModuleNeeded module : outputComponent.getModulesNeeded()) {
Node libNode2 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE), process);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
libNode2.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
process.addNodeContainer(new NodeContainer(libNode2));
}
// for sql statement, feature 6622.
int fetchSize = maximumRowsToPreview;
if (maximumRowsToPreview > 1000) {
fetchSize = 1000;
}
String codeStart, codeMain, codeEnd;
temppath = buildTempCSVFilename();
// Should also replace "/r". NMa.
// ISO-8859-15
memoSQL = memoSQL.replace("\r", " ");
// fix for TDI-26285
//$NON-NLS-1$
String createStatament = "conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY)";
//$NON-NLS-1$
String systemProperty = "";
if (info.isHive()) {
//$NON-NLS-1$
createStatament = "conn.createStatement()";
systemProperty = //$NON-NLS-1$ //$NON-NLS-2$
"System.setProperty(\"mapred.job.tracker\",\"" + info.getJobTracker() + "\");\r\n" + "System.setProperty(\"fs.default.name\", \"" + info.getNameNode() + //$NON-NLS-1$ //$NON-NLS-2$
"\");\r\n";
// only embeded hive need the following params
if (info.getThrifturi() != null) {
systemProperty = //$NON-NLS-1$
systemProperty + " System.setProperty(\"hive.metastore.local\", \"false\");\r\n" + " System.setProperty(\"hive.metastore.uris\", \"" + info.getThrifturi() + //$NON-NLS-1$ //$NON-NLS-2$
"\");\r\n" + //$NON-NLS-1$
"System.setProperty(\"hive.metastore.execute.setugi\", \"true\");\r\n";
}
}
// add for bug TDI-27137 by fwang on 27 August, 2013.
EDatabaseTypeName dbType = EDatabaseTypeName.JAVADB_EMBEDED.getTypeFromDbType(info.getDbType());
if (EDatabaseTypeName.JAVADB_EMBEDED.equals(dbType)) {
IElementParameter dbPathElement = node.getElementParameter("DBPATH");
if (dbPathElement != null) {
String derbyPath = dbPathElement.getValue().toString().replace("\"", "").trim();
systemProperty = systemProperty + "System.setProperty(\"derby.system.home\",\"" + derbyPath + "\");\r\n";
}
}
// the Sqlite
if (EDatabaseTypeName.SQLITE.getXmlName().equals(info.getDbType())) {
createStatament = "conn.createStatement()";
}
// the VERTICA
if (ConnectionUtils.isVertica(info.getUrl())) {
createStatament = "conn.createStatement()";
}
if (EDatabaseTypeName.GENERAL_JDBC.getXmlName().equals(info.getDbType()) && "com.sap.db.jdbc.Driver".equals(info.getDriverClassName()) || EDatabaseTypeName.SAPHana.getXmlName().equals(info.getDbType())) {
createStatament = "conn.createStatement()";
}
codeStart = systemProperty + getCodeStart(connectionNode, createStatament, fetchSize);
codeMain = //$NON-NLS-1$ //$NON-NLS-2$
"String[] dataOneRow = new String[numbOfColumn];\r\n" + "for (int i = 1; i <= numbOfColumn; i++) {\r\n" + " \r\n" + " try{\r\n" + " String tempStr = rs.getString(i);\r\n" + " dataOneRow[i-1] = tempStr;\r\n" + " } catch (java.sql.SQLException e) {\r\n" + "}\r\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"}\r\n" + //$NON-NLS-1$
"csvWriter.writeNext(dataOneRow);";
if (EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())) {
codeEnd = //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" + "conn.close();\r\n" + //$NON-NLS-1$ //$NON-NLS-2$
"csvWriter.close();\r\n";
} else {
codeEnd = //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" + "conn.close();\r\n" + //$NON-NLS-1$ //$NON-NLS-2$
"csvWriter.close();\r\n";
}
IComponent component = null;
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
//$NON-NLS-1$
component = ComponentsFactoryProvider.getInstance().get("tJavaFlex");
break;
case PERL:
default:
//$NON-NLS-1$
component = ComponentsFactoryProvider.getInstance().get("tPerlFlex");
break;
}
Node flexNode = new Node(component, process);
//$NON-NLS-1$
flexNode.setPropertyValue("CODE_START", codeStart);
//$NON-NLS-1$
flexNode.setPropertyValue("CODE_MAIN", codeMain);
//$NON-NLS-1$
flexNode.setPropertyValue("CODE_END", codeEnd);
process.addNodeContainer(new NodeContainer(flexNode));
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class MissingSettingsMultiThreadDynamicComposite method checkVisibleTopMessages.
@Override
protected void checkVisibleTopMessages() {
missModulesNeeded.clear();
final Element ele = this.getElement();
if (ele instanceof Node) {
// get not installed modules
List<ModuleNeeded> updatedModules = LibrariesManagerUtils.getNotInstalledModules(((Node) ele));
missModulesNeeded.addAll(updatedModules);
}
setVisibleTopMessage(!missModulesNeeded.isEmpty());
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class StatsAndLogsManager method statsAndLogsParametersDBPart.
private static List<IElementParameter> statsAndLogsParametersDBPart(IProcess process) {
ElementParameter param;
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
List<IElementParameter> paramList = new ArrayList<IElementParameter>();
//$NON-NLS-1$
String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
// on database
param = new ElementParameter(process);
param.setName(EParameterName.ON_DATABASE_FLAG.getName());
param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.ON_DATABASE_FLAG.getName()));
// On Database
param.setDisplayName(EParameterName.ON_DATABASE_FLAG.getDisplayName());
param.setFieldType(EParameterFieldType.CHECK);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(50);
//$NON-NLS-1$
param.setShowIf("(ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
ElementParameter parentPropertyType = new ElementParameter(process);
parentPropertyType.setName(EParameterName.PROPERTY_TYPE.getName());
parentPropertyType.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
//$NON-NLS-1$
parentPropertyType.setValue("");
parentPropertyType.setCategory(EComponentCategory.STATSANDLOGS);
parentPropertyType.setFieldType(EParameterFieldType.PROPERTY_TYPE);
parentPropertyType.setRepositoryValue(ERepositoryCategoryType.DATABASE.getName());
parentPropertyType.setNumRow(51);
parentPropertyType.setShowIf(//$NON-NLS-1$
"(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(parentPropertyType);
param = new ElementParameter(process);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setName(EParameterName.PROPERTY_TYPE.getName());
param.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
param.setListItemsDisplayName(new String[] { EmfComponent.TEXT_BUILTIN, EmfComponent.TEXT_REPOSITORY });
param.setListItemsDisplayCodeName(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
param.setListItemsValue(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
param.setValue(preferenceStore.getString(languagePrefix + EParameterName.PROPERTY_TYPE.getName()));
param.setNumRow(51);
param.setFieldType(EParameterFieldType.TECHNICAL);
param.setRepositoryValue(ERepositoryCategoryType.DATABASE.getName());
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
param.setParentParameter(parentPropertyType);
// paramList.add(param);
param = new ElementParameter(process);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setName(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
param.setDisplayName(EParameterName.REPOSITORY_PROPERTY_TYPE.getDisplayName());
param.setListItemsDisplayName(new String[] {});
param.setListItemsValue(new String[] {});
param.setNumRow(51);
param.setFieldType(EParameterFieldType.TECHNICAL);
param.setValue(preferenceStore.getString(languagePrefix + EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
param.setShow(false);
param.setRequired(true);
// paramList.add(param);
param.setParentParameter(parentPropertyType);
// dbType
param = new ElementParameter(process);
param.setName(EParameterName.DB_TYPE.getName());
String type = preferenceStore.getString(languagePrefix + EParameterName.DB_TYPE.getName());
if (type == null || "".equals(type.trim())) {
//$NON-NLS-1$
type = StatsAndLogsConstants.DB_COMPONENTS[1][0];
}
param.setValue(type);
param.setDisplayName(EParameterName.DB_TYPE.getDisplayName());
param.setFieldType(EParameterFieldType.CLOSED_LIST);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setListItemsDisplayName(StatsAndLogsConstants.DISPLAY_DBNAMES[1]);
param.setListItemsValue(StatsAndLogsConstants.DB_COMPONENTS[1]);
param.setListRepositoryItems(StatsAndLogsConstants.REPOSITORY_ITEMS[1]);
param.setListItemsDisplayCodeName(StatsAndLogsConstants.CODE_LIST[1]);
param.setNumRow(52);
//$NON-NLS-1$
param.setRepositoryValue("TYPE");
param.setRequired(true);
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
// dbVersion
if (process.getElementParameter(EParameterName.DB_VERSION.getName()) == null) {
param = new ElementParameter(process);
param.setName(EParameterName.DB_VERSION.getName());
param.setDisplayName(EParameterName.DB_VERSION.getDisplayName());
param.setFieldType(EParameterFieldType.CLOSED_LIST);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setValue(StatsAndLogsConstants.DB_VERSION_DRIVER[1]);
param.setListItemsDisplayName(StatsAndLogsConstants.DB_VERSION_DISPLAY);
param.setListItemsValue(StatsAndLogsConstants.DB_VERSION_DRIVER);
param.setListItemsDisplayCodeName(StatsAndLogsConstants.DB_VERSION_CODE);
param.setNumRow(52);
//$NON-NLS-1$
param.setRepositoryValue("DB_VERSION");
param.setRequired(true);
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (DB_TYPE == 'POSTGRESQL' or DB_TYPE == 'OCLE' or DB_TYPE == 'ACCESS' or DB_TYPE == 'OCLE_OCI' or DB_TYPE == 'MSSQL' or DB_TYPE == 'MYSQL') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
}
// jdbc url
param = new ElementParameter(process);
param.setName(EParameterName.URL.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.URL.getName())));
param.setDisplayName(EParameterName.URL.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(53);
//$NON-NLS-1$
param.setRepositoryValue("URL");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE=='JDBC')");
paramList.add(param);
// jdbc child param
if (moduleNameList == null) {
List<ModuleNeeded> moduleNeededList = ModulesNeededProvider.getModulesNeeded();
moduleNameList = new ArrayList<String>();
moduleValueList = new ArrayList<String>();
for (ModuleNeeded module : moduleNeededList) {
String moduleName = module.getModuleName();
if (moduleName != null) {
if (!moduleNameList.contains(moduleName)) {
moduleNameList.add(moduleName);
}
String moduleValue = TalendTextUtils.addQuotes(moduleName);
if (!moduleValueList.contains(moduleValue)) {
moduleValueList.add(moduleValue);
}
}
}
Comparator<String> comprarator = new IgnoreCaseComparator();
Collections.sort(moduleNameList, comprarator);
Collections.sort(moduleValueList, comprarator);
}
String[] moduleNameArray = moduleNameList.toArray(new String[0]);
String[] moduleValueArray = moduleValueList.toArray(new String[0]);
ElementParameter childParam = new ElementParameter(process);
childParam.setName("JAR_NAME");
childParam.setDisplayName("JAR_NAME");
childParam.setFieldType(EParameterFieldType.MODULE_LIST);
childParam.setListItemsDisplayName(moduleNameArray);
childParam.setListItemsValue(moduleValueArray);
// driver jar for jdbc
param = new ElementParameter(process);
param.setName(EParameterName.DRIVER_JAR.getName());
param.setDisplayName(EParameterName.DRIVER_JAR.getDisplayName());
param.setFieldType(EParameterFieldType.TABLE);
param.setListItemsDisplayCodeName(new String[] { "JAR_NAME" });
param.setListItemsDisplayName(new String[] { "Jar Name" });
param.setListItemsValue(new ElementParameter[] { childParam });
param.setValue(new ArrayList<Map<String, Object>>());
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(54);
//$NON-NLS-1$
param.setRepositoryValue("DRIVER_JAR");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE=='JDBC')");
paramList.add(param);
// class name for jdbc
param = new ElementParameter(process);
param.setName(EParameterName.DRIVER_CLASS.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.DRIVER_CLASS.getName())));
param.setDisplayName(EParameterName.DRIVER_CLASS.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(57);
//$NON-NLS-1$
param.setRepositoryValue("DRIVER_CLASS");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE=='JDBC')");
paramList.add(param);
// host
param = new ElementParameter(process);
param.setName(EParameterName.HOST.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.HOST.getName())));
param.setDisplayName(EParameterName.HOST.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(53);
//$NON-NLS-1$
param.setRepositoryValue("SERVER_NAME");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE!='SQLITE' and DB_TYPE!='ACCESS' and DB_TYPE!='OCLE_OCI' and DB_TYPE!='JDBC') ");
paramList.add(param);
// port
param = new ElementParameter(process);
param.setName(EParameterName.PORT.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.PORT.getName())));
param.setDisplayName(EParameterName.PORT.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(53);
//$NON-NLS-1$
param.setRepositoryValue("PORT");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE!='SQLITE' and DB_TYPE!='ACCESS' and DB_TYPE!='FIREBIRD' and DB_TYPE!='OCLE_OCI' and DB_TYPE!='JDBC') ");
paramList.add(param);
// databaseSource
// gcui:see bug 7456.
param = new ElementParameter(process);
param.setName(EParameterName.DATASOURCE.getName());
param.setDisplayName(EParameterName.DATASOURCE.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.DATASOURCE.getName())));
param.setNumRow(53);
//$NON-NLS-1$
param.setRepositoryValue("DATASOURCE");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')and (DB_TYPE =='INFORMIX' or DB_TYPE =='GODBC' or DB_TYPE =='MSODBC') ");
paramList.add(param);
// dbName
param = new ElementParameter(process);
param.setName(EParameterName.DBNAME.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.DBNAME.getName())));
param.setDisplayName(EParameterName.DBNAME.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(54);
//$NON-NLS-1$
param.setRepositoryValue("SID");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE!='SQLITE' and DB_TYPE!='ACCESS' and DB_TYPE!='FIREBIRD' and DB_TYPE != 'OCLE_OCI' and DB_TYPE!='JDBC')");
paramList.add(param);
// local service name
param = new ElementParameter(process);
param.setName(EParameterName.LOCAL_SERVICE_NAME.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.LOCAL_SERVICE_NAME.getName())));
param.setDisplayName(EParameterName.LOCAL_SERVICE_NAME.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(54);
//$NON-NLS-1$
param.setRepositoryValue("SID");
//$NON-NLS-1$ //and (DB_TYPE == 'OCLE_OCI'
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and DB_TYPE =='OCLE_OCI'");
paramList.add(param);
// additional parameters
param = new ElementParameter(process);
param.setName(EParameterName.PROPERTIES.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.PROPERTIES.getName())));
param.setDisplayName(EParameterName.PROPERTIES.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(54);
//$NON-NLS-1$
param.setRepositoryValue("PROPERTIES_STRING");
//$NON-NLS-1$
param.setShowIf("(DB_TYPE=='MSSQL' or DB_TYPE=='MYSQL' or DB_TYPE=='INFORMIX' or DB_TYPE=='OCLE' or DB_TYPE=='OCLE_OCI' or DB_TYPE=='SYBASE') and (ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
// schema
param = new ElementParameter(process);
param.setName(EParameterName.SCHEMA_DB.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.SCHEMA_DB.getName())));
param.setDisplayName(EParameterName.SCHEMA_DB.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(54);
//$NON-NLS-1$
param.setRepositoryValue("SCHEMA");
//$NON-NLS-1$
param.setShowIf("(DB_TYPE=='OCLE' or DB_TYPE=='POSTGRESQL' or DB_TYPE=='POSTGRESPLUS' or DB_TYPE=='OCLE_OCI' or DB_TYPE=='MSSQL' or DB_TYPE=='INFORMIX' or DB_TYPE=='IBM_DB2' or DB_TYPE=='SYBASE' ) and (ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
// username
param = new ElementParameter(process);
param.setName(EParameterName.USER.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.USER.getName())));
param.setDisplayName(EParameterName.USER.getDisplayName());
param.setFieldType(EParameterFieldType.TEXT);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(55);
param.setRequired(true);
//$NON-NLS-1$
param.setRepositoryValue("USERNAME");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')and (DB_TYPE!='SQLITE')");
paramList.add(param);
// password
param = new ElementParameter(process);
param.setName(EParameterName.PASS.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.PASS.getName())));
param.setDisplayName(EParameterName.PASS.getDisplayName());
param.setFieldType(EParameterFieldType.PASSWORD);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(55);
param.setRequired(true);
//$NON-NLS-1$
param.setRepositoryValue("PASSWORD");
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true') and (DB_TYPE!='SQLITE')");
paramList.add(param);
// databse file path
param = new ElementParameter(process);
param.setName(EParameterName.DBFILE.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.DBFILE.getName())));
param.setDisplayName(EParameterName.DBFILE.getDisplayName());
param.setFieldType(EParameterFieldType.FILE);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(56);
//$NON-NLS-1$
param.setRepositoryValue("FILE");
//$NON-NLS-1$
param.setShowIf("(DB_TYPE=='SQLITE' or DB_TYPE=='ACCESS' or DB_TYPE=='FIREBIRD') and (ON_DATABASE_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
// Stats table
param = new ElementParameter(process);
param.setName(EParameterName.TABLE_STATS.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.TABLE_STATS.getName())));
param.setDisplayName(EParameterName.TABLE_STATS.getDisplayName());
param.setFieldType(EParameterFieldType.DBTABLE);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(57);
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true' and ON_STATCATCHER_FLAG == 'true')");
paramList.add(param);
// Log table
param = new ElementParameter(process);
param.setName(EParameterName.TABLE_LOGS.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.TABLE_LOGS.getName())));
param.setDisplayName(EParameterName.TABLE_LOGS.getDisplayName());
param.setFieldType(EParameterFieldType.DBTABLE);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(58);
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true' and ON_LOGCATCHER_FLAG == 'true')");
paramList.add(param);
// Metter table
param = new ElementParameter(process);
param.setName(EParameterName.TABLE_METER.getName());
param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.TABLE_METER.getName())));
param.setDisplayName(EParameterName.TABLE_METER.getDisplayName());
param.setFieldType(EParameterFieldType.DBTABLE);
param.setCategory(EComponentCategory.STATSANDLOGS);
param.setNumRow(59);
//$NON-NLS-1$
param.setShowIf("(ON_DATABASE_FLAG == 'true' and ON_METERCATCHER_FLAG == 'true')");
paramList.add(param);
return paramList;
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class JavaProcessUtil method getNeededModules.
public static Set<ModuleNeeded> getNeededModules(final IProcess process, boolean withChildrens, boolean forMR) {
List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
// see bug 4939: making tRunjobs work loop will cause a error of "out of memory"
Set<ProcessItem> searchItems = new HashSet<ProcessItem>();
if (withChildrens) {
ProcessItem processItem = null;
if (process.getVersion() != null) {
processItem = ItemCacheManager.getProcessItem(process.getId(), process.getVersion());
} else {
processItem = ItemCacheManager.getProcessItem(process.getId());
}
if (processItem != null) {
searchItems.add(processItem);
}
}
// call recursive function to get all dependencies from job & subjobs
getNeededModules(process, withChildrens, searchItems, modulesNeeded, forMR);
/*
* Remove duplicates in the modulesNeeded list after having prioritize the modules. Details in the
* ModuleNeededComparator class.
*/
Collections.sort(modulesNeeded, new ModuleNeededComparator());
Set<String> dedupModulesList = new HashSet<String>();
Iterator<ModuleNeeded> it = modulesNeeded.iterator();
while (it.hasNext()) {
ModuleNeeded module = it.next();
// in some case it's not a real library, but just a text.
if (!module.getModuleName().contains(".")) {
//$NON-NLS-1$
it.remove();
} else if (dedupModulesList.contains(module.getModuleName())) {
it.remove();
} else {
dedupModulesList.add(module.getModuleName());
}
}
return new HashSet<ModuleNeeded>(modulesNeeded);
}
use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.
the class JavaProcessUtil method getNeededModules.
private static void getNeededModules(final IProcess process, boolean withChildrens, Set<ProcessItem> searchItems, List<ModuleNeeded> modulesNeeded, boolean forMR) {
IElementParameter headerParameter = process.getElementParameter(EParameterName.HEADER_LIBRARY.getName());
if (headerParameter != null) {
Object value = headerParameter.getValue();
if (value != null) {
String headerLibraries = (String) value;
if (headerLibraries.indexOf(File.separatorChar) > 0 && headerLibraries.length() > headerLibraries.lastIndexOf(File.separatorChar) + 1) {
String substring = headerLibraries.substring(headerLibraries.lastIndexOf(File.separatorChar) + 1);
if (!"".equals(substring)) {
//$NON-NLS-1$
modulesNeeded.add(getModuleValue(process, substring));
}
}
}
}
IElementParameter footerParameter = process.getElementParameter(EParameterName.FOOTER_LIBRARY.getName());
if (footerParameter != null) {
Object value = footerParameter.getValue();
if (value != null) {
String footerLibraries = (String) value;
if (footerLibraries.indexOf(File.separatorChar) > 0 && footerLibraries.length() > footerLibraries.lastIndexOf(File.separatorChar) + 1) {
String substring = footerLibraries.substring(footerLibraries.lastIndexOf(File.separatorChar) + 1);
if (!"".equals(substring)) {
//$NON-NLS-1$
modulesNeeded.add(getModuleValue(process, substring));
}
}
}
}
IElementParameter elementParameter = process.getElementParameter(EParameterName.DRIVER_JAR.getName());
if (elementParameter != null && elementParameter.getFieldType() == EParameterFieldType.TABLE) {
getModulesInTable(process, elementParameter, modulesNeeded);
}
if (process instanceof IProcess2) {
Item item = ((IProcess2) process).getProperty().getItem();
if (item instanceof ProcessItem) {
modulesNeeded.addAll(ModulesNeededProvider.getModulesNeededForProcess((ProcessItem) item, process));
}
}
if (ProcessUtils.isTestContainer(process)) {
// if it is a test container, add junit jars.
addJunitNeededModules(modulesNeeded);
}
String hadoopItemId = null;
List<? extends INode> nodeList = process.getGeneratingNodes();
for (INode node : nodeList) {
if (hadoopItemId == null) {
String itemId = getHadoopClusterItemId(node);
if (itemId != null) {
hadoopItemId = itemId;
}
}
if (process instanceof IProcess2) {
((IProcess2) node.getProcess()).setNeedLoadmodules(((IProcess2) process).isNeedLoadmodules());
}
Set<ModuleNeeded> nodeNeededModules = getNeededModules(node, searchItems, withChildrens, forMR);
if (nodeNeededModules != null) {
modulesNeeded.addAll(nodeNeededModules);
}
}
if (hadoopItemId == null) {
// Incase it is a bigdata process.
//$NON-NLS-1$
IElementParameter propertyParam = process.getElementParameter("MR_PROPERTY");
if (propertyParam != null) {
IElementParameter repositoryParam = propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (repositoryParam != null) {
hadoopItemId = String.valueOf(repositoryParam.getValue());
}
}
}
if (hadoopItemId != null) {
useCustomConfsJarIfNeeded(modulesNeeded, hadoopItemId);
}
}
Aggregations