use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class AddPerlRefArrayMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
try {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
} else {
List<String> namesList = new ArrayList<String>();
for (Object o : processType.getNode()) {
NodeType nt = (NodeType) o;
namesList.add(ComponentUtilities.getNodeUniqueName(nt));
}
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
int lineStyle = currentConnection.getLineStyle();
EConnectionType connectionType = EConnectionType.getTypeFromId(lineStyle);
if (connectionType.hasConnectionCategory(EConnectionType.FLOW)) {
namesList.add(currentConnection.getLabel());
}
}
final String[] namesArrays = namesList.toArray(new String[0]);
IComponentFilter filter1 = new IComponentFilter() {
/*
* (non-Javadoc)
*
* @see org.talend.core.model.components.filters.IComponentFilter#accept(org.talend.designer.core.model.utils.emf.talendfile.NodeType)
*/
public boolean accept(NodeType node) {
return true;
}
};
IComponentConversion componentConversion = new IComponentConversion() {
RefArraySyntaxReplacerForPerl parser = new RefArraySyntaxReplacerForPerl();
/*
* (non-Javadoc)
*
* @see org.talend.core.model.components.conversions.IComponentConversion#transform(org.talend.designer.core.model.utils.emf.talendfile.NodeType)
*/
public void transform(NodeType node) {
for (Object o : node.getElementParameter()) {
ElementParameterType pType = (ElementParameterType) o;
if (pType.getField().equals("TABLE")) {
//$NON-NLS-1$
for (ElementValueType elementValue : (List<ElementValueType>) pType.getElementValue()) {
elementValue.getValue();
String value = elementValue.getValue();
if (value != null) {
String newValue = parser.processReplacementOperations(value, namesArrays);
elementValue.setValue(newValue);
}
}
} else {
String value = pType.getValue();
if (value != null) {
String newValue = parser.processReplacementOperations(value, namesArrays);
pType.setValue(newValue);
}
}
}
}
};
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(componentConversion));
return ExecutionResult.SUCCESS_WITH_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class ConnectionCreateActionTest method testRun2.
private void testRun2() {
EConnectionType ct = EConnectionType.FLOW_MAIN;
String text = "Main";
String tableName = text;
IMetadataTable meta = node.getMetadataTable("JOBS");
String connectionName = meta.getTableName();
assertEquals(connectionName, "JOBS");
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class ConnectionCreateCommand method execute.
@Override
public void execute() {
canExecute();
if (connectionName == null) {
// ask for the name if there is no
final INodeConnector mainConnector;
EConnectionType connecType;
if (source.isELTComponent()) {
connecType = EConnectionType.TABLE;
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(source.getComponent().getType())) {
connecType = EConnectionType.ROUTE;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
connecType = camelService.getTargetConnectionType(source);
} else {
connecType = EConnectionType.ROUTE;
}
} else {
connecType = EConnectionType.FLOW_MAIN;
}
mainConnector = NodeUtil.getValidConnector(source);
if (source.getConnectorFromName(connectorName).isMultiSchema()) {
boolean connectionOk = false;
while (!connectionOk) {
connectionName = askForConnectionName(source.getLabel(), connectionName);
if (StringUtils.isEmpty(connectionName)) {
creatingConnection = false;
connectionName = null;
dispose();
return;
}
metaName = connectionName;
newMetadata = getNewMetadataTable();
newMetadata.setTableName(connectionName);
newMetadata.setLabel(connectionName);
newMetadata.setAttachedConnector(connectorName);
if ((connecType.equals(EConnectionType.TABLE) || source.getProcess().checkValidConnectionName(connectionName)) && (ConnectionManager.canConnectToTarget(source, null, target, source.getConnectorFromName(connectorName).getDefaultConnectionType(), connectorName, connectionName))) {
connectionOk = true;
} else {
String message = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ConnectionCreateAction.errorCreateConnectionName", connectionName);
//$NON-NLS-1$
MessageDialog.openError(null, Messages.getString("ConnectionCreateAction.error"), message);
}
}
// add for feature TDI-17358
//$NON-NLS-1$
IElementParameter elementParameter = source.getElementParameter("SCHEMAS");
if (elementParameter != null) {
Map<String, Object> map = new HashMap<String, Object>();
Object[] itemsValue = elementParameter.getListItemsValue();
String[] items = elementParameter.getListItemsDisplayCodeName();
map.put(IEbcdicConstant.FIELD_CODE, newMetadata.getTableName());
map.put(IEbcdicConstant.FIELD_SCHEMA, newMetadata.getTableName());
for (int i = 1; i < items.length; i++) {
map.put(items[i], ((IElementParameter) itemsValue[i]).getValue());
}
Object value = elementParameter.getValue();
if (value instanceof List) {
List list = (List) value;
list.add(map);
}
ComponentSettings.switchToCurComponentSettingsView();
}
} else {
newMetadata = null;
if (source.isELTComponent()) {
if (source.getElementParameter("ELT_SCHEMA_NAME") != null) {
connectionName = askForConnectionSchemaAndTableName(source.getLabel(), connectionName);
} else {
connectionName = askForConnectionName(source.getLabel(), connectionName);
}
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(source.getComponent().getType())) {
connectionName = ConnectionUtil.generateUniqueConnectionName(connecType, source.getProcess(), source.getConnectorFromType(connecType));
} else {
IMetadataTable metaTable = source.getMetadataFromConnector(mainConnector.getName());
if (metaTable != null) {
metaName = metaTable.getTableName();
}
String baseName = source.getConnectionName();
if (source.getProcess().checkValidConnectionName(baseName)) {
connectionName = source.getProcess().generateUniqueConnectionName(baseName);
}
}
}
}
if (insertTMap) {
metaName = connectionName;
newMetadata = getNewMetadataTable();
newMetadata.setTableName(connectionName);
newMetadata.setLabel(connectionName);
newMetadata.setAttachedConnector(connectorName);
}
// Default not monitor the connection
boolean monitorConnection = false;
if (newLineStyle == null) {
newLineStyle = source.getConnectorFromName(connectorName).getDefaultConnectionType();
}
if (connection == null) {
if (newMetadata != null) {
// add for eltmap
if (source instanceof Node && source.isELTMapComponent()) {
for (IMetadataTable metaTable : source.getMetadataList()) {
String tableName = metaTable.getTableName();
if (tableName != null && source.getProcess().checkValidConnectionName(tableName)) {
source.getProcess().addUniqueConnectionName(tableName);
}
}
}
source.getMetadataList().add(newMetadata);
this.connection = new Connection(source, target, newLineStyle, connectorName, metaName, connectionName, monitorConnection);
} else {
this.connection = new Connection(source, target, newLineStyle, connectorName, metaName, connectionName, metaName, monitorConnection);
}
} else {
// in case of redo, reuse the same instance
if (newMetadata != null) {
source.getMetadataList().add(newMetadata);
}
connection.reconnect(source, target, newLineStyle);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
nodeConnectorTarget = connection.getTargetNodeConnector();
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
creatingConnection = false;
((Process) source.getProcess()).checkStartNodes();
source.checkAndRefreshNode();
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null && jobletService.isJobletComponent(target)) {
jobletService.upateJobletComonentList(target);
isJoblet = true;
}
}
if (!isJoblet) {
target.checkAndRefreshNode();
}
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class ChangeMetadataCommand method syncOutputNodeColumnsList.
/*
* use to synchronize column list for output connections.
*/
private void syncOutputNodeColumnsList(List<ColumnNameChanged> columnNameChanged) {
if (outputdataContainer == null) {
return;
}
for (IConnection conn : node.getOutgoingConnections()) {
INode targetNode = conn.getTarget();
EConnectionType connStyle = conn.getLineStyle();
if (EConnectionType.FLOW_MAIN.equals(connStyle) || EConnectionType.FLOW_MERGE.equals(connStyle) || EConnectionType.FLOW_REF.equals(connStyle)) {
ColumnListController.updateColumnList(targetNode, columnNameChanged);
// fix for TDI-23202
// reset value in order to call "firePropertyChange(RETURNS_CHANGED, null, null)"
IElementParameter defaultMap = targetNode.getElementParameter(EParameterName.DEFAULT_MAP.getName());
if (defaultMap != null) {
if ("tFlowToIterate".equals(targetNode.getComponent().getName())) {
// update target properties incase any old columns are removed
IElementParameter elementParameter = targetNode.getElementParameter("MAP");
if (elementParameter != null) {
Object value = elementParameter.getValue();
if (value instanceof List) {
for (Object obj : (List) value) {
if (obj instanceof Map) {
Object object = ((Map) obj).get("VALUE");
if (newOutputMetadata != null && !newOutputMetadata.getListColumns().isEmpty()) {
boolean found = false;
for (IMetadataColumn column : newOutputMetadata.getListColumns()) {
if (column.getLabel().equals(object)) {
found = true;
}
}
if (!found) {
((Map) obj).put("VALUE", newOutputMetadata.getListColumns().get(0).getLabel());
}
} else {
((Map) obj).put("VALUE", "");
}
}
}
}
}
}
targetNode.setPropertyValue(EParameterName.DEFAULT_MAP.getName(), defaultMap.getValue());
}
}
}
}
use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.
the class SetParallelizationCommand method setParallelization.
private void setParallelization(INode node) {
if (node.isActivate()) {
if (node.getOutgoingConnections().size() > 0) {
for (IConnection con : node.getOutgoingConnections()) {
EConnectionType lineStyle = con.getLineStyle();
if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
if (!lineStyle.equals(EConnectionType.FLOW_MERGE)) {
boolean isEndRow = con.getTarget().getOutgoingConnections().size() == 0;
boolean isStartRow = node.isStart();
if (ParallelExecutionUtils.isPartitionKeysExist(con)) {
ParallelExecutionUtils.reSetParKeyValuesForCon(con);
}
if (!isEndRow && isComponentCanParlization(con, (Node) con.getTarget())) {
// tPartitioner,need do Repartitioner automatic
if (isExistParalInSubjob(existParallelMap, node) && !isStartRow && isComponentNeedRepartion(con, (Node) con.getTarget())) {
setRepartioner(con);
} else {
// when pervious con is par/repar/none,keep current is none
if (isExistParalInSubjob(existParallelMap, node) && (ParallelExecutionUtils.existPreviousPar((Node) con.getSource()) || ParallelExecutionUtils.existPreviousNone((Node) con.getSource()) || ParallelExecutionUtils.existPreviousRepar((Node) con.getSource()))) {
setNone(con);
} else {
setPartioner(con, lineStyle, isStartRow);
}
}
} else {
if (!con.getSource().isStart()) {
setDepartioner(con);
}
}
} else {
setParallelization(con.getTarget());
}
} else {
// in case the con here is not data flow,such as onSubjobOk,we skip to next target
setParallelization(con.getTarget());
}
}
} else {
if (!node.isStart()) {
setDeparallelization(node);
}
}
}
}
Aggregations