use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class NodeContainerPart method createFigure.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
@Override
protected IFigure createFigure() {
NodeContainerFigure nodeContainerFigure = new NodeContainerFigure((NodeContainer) this.getModel());
Node node = ((NodeContainer) getModel()).getNode();
if (node.isActivate()) {
nodeContainerFigure.setAlpha(-1);
} else {
nodeContainerFigure.setAlpha(Node.ALPHA_VALUE);
}
IElementParameter param = node.getElementParameter(EParameterName.INFORMATION.getName());
if (param != null) {
boolean showInfoFlag = Boolean.TRUE.equals(param.getValue());
nodeContainerFigure.updateStatus(node.getStatus(), showInfoFlag);
nodeContainerFigure.setInfoHint(node.getShowHintText());
}
return nodeContainerFigure;
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class NodeContainerFigure method updateParallelFigure.
/**
* DOC YeXiaowei Comment method "updateParallelFigure".
*
* @param status
*/
private void updateParallelFigure(int status) {
if (!PluginChecker.isTeamEdition() || parallelFigure == null) {
return;
}
//$NON-NLS-1$
String numberParallel = "0";
if ((status & Process.PARALLEL_STATUS) != 0) {
IElementParameter numberParallelizeParameter = nodeContainer.getNode().getElementParameter(EParameterName.PARALLELIZE_NUMBER.getName());
if (numberParallelizeParameter != null) {
numberParallel = (String) numberParallelizeParameter.getValue();
}
//$NON-NLS-1$
String paralString = "x" + numberParallel;
parallelFigure.setText(paralString);
parallelFigure.setToolTip(new Label(paralString));
parallelFigure.setVisible(true);
} else {
parallelFigure.setVisible(false);
}
}
use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.
the class JobletUtil method cloneNode.
public Node cloneNode(Node node, IProcess process, Map<String, List<? extends IElementParameter>> paraMap, boolean lockByOther) {
NodePart nodePart = new NodePart();
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
boolean isInOut = false;
if (service != null) {
isInOut = service.isJobletInOutComponent(node);
}
Node cloneNode = new Node(node.getComponent(), (IProcess2) process, node.getUniqueName());
nodePart.setModel(cloneNode);
if (lockByOther) {
cloneNode.setReadOnly(true);
} else {
cloneNode.setReadOnly(false);
}
cloneNode.setDummy(node.isDummy());
cloneNode.setActivate(node.isActivate());
List<? extends IElementParameter> elementParas = null;
if (paraMap.containsKey(node.getUniqueName())) {
elementParas = paraMap.get(node.getUniqueName());
} else {
elementParas = node.getElementParameters();
}
for (IElementParameter elementPara : elementParas) {
if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
IElementParameter cloneElement = cloneNode.getElementParameter(elementPara.getName());
Object paValue = elementPara.getValue();
if (paValue instanceof List) {
List list = new ArrayList();
list.addAll((List) paValue);
cloneElement.setValue(list);
} else {
// TDI-25599
cloneElement.setContextMode(elementPara.isContextMode());
cloneElement.setValue(elementPara.getValue());
}
if (lockByOther) {
cloneElement.setReadOnly(true);
} else {
cloneElement.setReadOnly(elementPara.isReadOnly());
}
if (elementPara.getChildParameters() != null) {
Map<String, IElementParameter> elementParaChild = elementPara.getChildParameters();
Map<String, IElementParameter> cloneElementChild = cloneElement.getChildParameters();
Iterator<Entry<String, IElementParameter>> ite = elementParaChild.entrySet().iterator();
while (ite.hasNext()) {
Entry<String, IElementParameter> entry = ite.next();
String key = entry.getKey();
IElementParameter c = entry.getValue();
if (key != null && c != null) {
IElementParameter cloneC = cloneElementChild.get(key);
if (cloneC != null) {
cloneC.setValue(c.getValue());
if (lockByOther) {
cloneC.setReadOnly(true);
} else {
cloneC.setReadOnly(c.isReadOnly());
}
}
}
}
}
}
}
for (IElementParameter param : cloneNode.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(cloneNode.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL) {
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
}
}
cloneNode.setMetadataList(node.getMetadataList());
cloneNode.setListConnector(node.getListConnector());
cloneNode.setConnectionName(node.getConnectionName());
cloneNode.setLocation(node.getLocation());
IExternalNode externalNode = cloneNode.getExternalNode();
if (externalNode != null) {
if (node.getExternalData() != null) {
try {
externalNode.setExternalData(node.getExternalData().clone());
} catch (CloneNotSupportedException e) {
ExceptionHandler.process(e);
}
cloneNode.setExternalData(externalNode.getExternalData());
}
if (node.getExternalNode().getExternalEmfData() != null) {
externalNode.setExternalEmfData(EcoreUtil.copy(node.getExternalNode().getExternalEmfData()));
}
// when copy a external node, should also copy screeshot
if (node.getExternalNode() != null) {
ImageDescriptor screenshot = node.getExternalNode().getScreenshot();
if (screenshot != null) {
externalNode.setScreenshot(screenshot);
}
}
}
if (node.getElementParameter(EParameterName.LABEL.getName()) != null) {
cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getElementParameter(EParameterName.LABEL.getName()).getValue());
} else {
cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getLabel());
}
boolean found = false;
for (INode inode : process.getGraphicalNodes()) {
if (inode.getUniqueName().equals(cloneNode.getUniqueName())) {
found = true;
}
}
if (!found) {
((IProcess2) process).removeUniqueNodeName(cloneNode.getUniqueName());
}
return cloneNode;
}
use of org.talend.core.model.process.IElementParameter 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.process.IElementParameter in project tdi-studio-se by Talend.
the class HadoopJarSetupController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#createControl
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
final Composite container = subComposite;
//$NON-NLS-1$
Button subButton = getWidgetFactory().createButton(container, "", SWT.PUSH);
subButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
initHadoopVersionType();
boolean readonly = false;
String readOnlyIfString = param.getReadOnlyIf();
if (StringUtils.isNotEmpty(readOnlyIfString)) {
if (param.isReadOnly(elem.getElementParameters())) {
readonly = true;
}
}
// if readonly is true, then needn't to do this check, since it's aim is check readonly also
if (readonly == false) {
IElementParameter propertyParameter = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
if (propertyParameter != null) {
if (EmfComponent.REPOSITORY.equals(propertyParameter.getValue())) {
readonly = true;
}
}
}
HadoopCustomVersionDefineDialog customVersionDialog = new HadoopCustomVersionDefineDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getCustomVersionMap()) {
@Override
protected ECustomVersionType[] getDisplayTypes() {
return new ECustomVersionType[] { versionType };
}
};
IElementParameter sparkLocalParam = elem.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
IElementParameter sparkParam = elem.getElementParameter(HadoopConstants.SPARK_MODE);
boolean isSparkLocalMode = false;
if (sparkLocalParam != null) {
isSparkLocalMode = (Boolean) sparkLocalParam.getValue();
}
if (sparkParam != null) {
String sparkMode = null;
if (isSparkLocalMode) {
//$NON-NLS-1$
sparkMode = "LOCAL";
} else {
//$NON-NLS-1$
sparkMode = "" + sparkParam.getValue();
}
customVersionDialog.setSparkMode(sparkMode);
customVersionDialog.setSparkStreamingMode(sparkMode);
}
customVersionDialog.setReadonly(readonly);
Set<String> oldLibList = customVersionDialog.getLibList(versionType.getGroup());
if (customVersionDialog.open() == Window.OK) {
Set<String> newLibList = customVersionDialog.getLibList(versionType.getGroup());
if (oldLibList != null && newLibList != null && oldLibList.size() == newLibList.size() && oldLibList.containsAll(newLibList)) {
// means nothing changes, so nothing need to do
} else {
// changed
String customJars = customVersionDialog.getLibListStr(versionType.getGroup());
executeCommand(new PropertyChangeCommand(elem, EParameterName.HADOOP_CUSTOM_JARS.getName(), StringUtils.trimToEmpty(customJars)));
}
}
}
});
subButton.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
FormData data = new FormData();
data.left = new FormAttachment(lastControl, 0);
data.right = new FormAttachment(lastControl, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
data.top = new FormAttachment(0, top);
data.height = STANDARD_HEIGHT - 2;
subButton.setLayoutData(data);
return container;
}
Aggregations