use of org.talend.designer.core.model.process.DataNode in project tdi-studio-se by Talend.
the class StatsAndLogsManager method addConnection.
private static DataNode addConnection(DataNode connectionNode, IProcess process, String connectionUID, DataNode dataNode, List<DataNode> nodeList, DataNode commitNode) {
IElementParameter param = dataNode.getElementParameter(EParameterName.USE_EXISTING_CONNECTION.getName());
if (param != null) {
param.setValue(Boolean.TRUE);
}
param = dataNode.getElementParameter(EParameterName.CONNECTION.getName());
if (param != null) {
param.setValue(connectionUID);
}
if (connectionNode == null) {
IComponent component = null;
String[] javaDbComponents = StatsAndLogsConstants.DB_OUTPUT_COMPONENTS;
for (String dbComponent : javaDbComponents) {
String connectionComponentName = null;
if (OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue()).equals(dbComponent)) {
if (dbComponent.endsWith("Output")) {
//$NON-NLS-1$
//$NON-NLS-1$
String substring = dbComponent.substring(0, dbComponent.lastIndexOf("Output"));
//$NON-NLS-1$
connectionComponentName = substring + "Connection";
} else {
//$NON-NLS-1$
connectionComponentName = "tOracleConnection";
}
component = ComponentsFactoryProvider.getInstance().get(connectionComponentName, process.getComponentsType());
if (component != null) {
connectionNode = new DataNode(component, connectionUID);
connectionNode.setSubProcessStart(true);
connectionNode.setActivate(true);
// check if shared parameter exist, if yes, use it ONLY when use the project settings.
// name for shared connection can be always the same, as we use only when project settings is
// activated.
IElementParameter elementParameter = connectionNode.getElementParameter(EParameterName.USE_SHARED_CONNECTION.getName());
if (elementParameter != null && elementParameter.getName() != null) {
elementParameter.setValue(Boolean.TRUE);
//$NON-NLS-1$
final String sharedConnName = "StatsAndLog_Shared_Connection";
if ((Boolean) process.getElementParameter(EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName()).getValue()) {
connectionNode.getElementParameter(EParameterName.SHARED_CONNECTION_NAME.getName()).setValue(TalendTextUtils.addQuotes(sharedConnName));
} else {
String url = getUrl(process);
if (url == null || url.equals("")) {
// fix bug of stats/logs found for sybase
connectionNode.getElementParameter(EParameterName.SHARED_CONNECTION_NAME.getName()).setValue(TalendTextUtils.addQuotes(sharedConnName));
} else {
connectionNode.getElementParameter(EParameterName.SHARED_CONNECTION_NAME.getName()).setValue(//$NON-NLS-1$ //$NON-NLS-2$
url + "+" + TalendTextUtils.addQuotes("_" + sharedConnName));
}
}
}
setConnectionParameter(connectionNode, process, connectionUID, dataNode, nodeList);
if (connectionComponentName.contains("Oracle")) {
//$NON-NLS-1$
if (connectionNode.getElementParameter(EParameterName.CONNECTION_TYPE.getName()) != null) {
connectionNode.getElementParameter(EParameterName.CONNECTION_TYPE.getName()).setValue(dbComponent);
}
}
connectionNode.setProcess(process);
nodeList.add(connectionNode);
IComponent prejobComponent = ComponentsFactoryProvider.getInstance().get(TPREJOB, ComponentCategory.CATEGORY_4_DI.getName());
DataNode preNode = new DataNode(prejobComponent, PRE_STA_LOG_CON);
preNode.setStart(true);
preNode.setSubProcessStart(true);
preNode.setActivate(true);
preNode.setProcess(process);
nodeList.add(preNode);
DataConnection dataConnec = createDataConnectionForComponentOK(preNode, connectionNode);
((List<IConnection>) preNode.getOutgoingConnections()).add(dataConnec);
((List<IConnection>) connectionNode.getIncomingConnections()).add(dataConnec);
}
}
}
}
DataConnection dataConnec = createDataConnectionForSubJobOK(dataNode, commitNode);
((List<IConnection>) dataNode.getOutgoingConnections()).add(dataConnec);
((List<IConnection>) commitNode.getIncomingConnections()).add(dataConnec);
return connectionNode;
}
use of org.talend.designer.core.model.process.DataNode in project tdi-studio-se by Talend.
the class StatsAndLogsManager method createMetterNode.
private static DataNode createMetterNode(boolean useFile, boolean console, String dbOutput) {
JobMetterComponent statsComponent = new JobMetterComponent(useFile, console, dbOutput);
DataNode statsNode = new DataNode(statsComponent, METER_UNIQUE_NAME);
statsNode.setStart(true);
statsNode.setSubProcessStart(true);
statsNode.setActivate(true);
statsNode.getMetadataList().clear();
// load the tFlowMeterCatcher to get the schema.
IComponent tmpComponent = ComponentsFactoryProvider.getInstance().get("tFlowMeterCatcher", //$NON-NLS-1$
ComponentCategory.CATEGORY_4_DI.getName());
//$NON-NLS-1$
DataNode tmpNode = new DataNode(tmpComponent, "tmp");
boolean found = false;
for (int k = 0; k < tmpNode.getElementParameters().size() && !found; k++) {
IElementParameter currentParam = tmpNode.getElementParameters().get(k);
if (currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
Object value = currentParam.getValue();
if (value instanceof IMetadataTable) {
IMetadataTable table = ((IMetadataTable) value).clone();
table.setTableName(METER_UNIQUE_NAME);
table.setAttachedConnector(currentParam.getContext());
statsNode.getMetadataList().add(table);
}
found = true;
}
}
return statsNode;
}
use of org.talend.designer.core.model.process.DataNode in project tdi-studio-se by Talend.
the class NodeUtilTest method testIsBigDataFrameworkNode.
@Test
public void testIsBigDataFrameworkNode() {
DummyComponent comp = Mockito.mock(DummyComponent.class);
Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
//$NON-NLS-1$
INode node = new DataNode(comp, "");
assertFalse(NodeUtil.isBigDataFrameworkNode(node));
Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_DI.getName());
//$NON-NLS-1$
node = new DataNode(comp, "");
assertFalse(NodeUtil.isBigDataFrameworkNode(node));
Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_MAPREDUCE.getName());
//$NON-NLS-1$
node = new DataNode(comp, "");
assertTrue(NodeUtil.isBigDataFrameworkNode(node));
Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_SPARK.getName());
//$NON-NLS-1$
node = new DataNode(comp, "");
assertTrue(NodeUtil.isBigDataFrameworkNode(node));
Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName());
//$NON-NLS-1$
node = new DataNode(comp, "");
assertTrue(NodeUtil.isBigDataFrameworkNode(node));
Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_STORM.getName());
//$NON-NLS-1$
node = new DataNode(comp, "");
assertTrue(NodeUtil.isBigDataFrameworkNode(node));
}
Aggregations