use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateConnectionsInfo.
/**
* Generates connections information base on <code>jobElement</code>,<code>connectionList</code>
*
* @param jobElement
* @param connectionList
*/
private void generateConnectionsInfo(Element jobElement, EList connectionList) {
//$NON-NLS-1$
Element connectionsElement = jobElement.addElement("connections");
for (int j = 0; j < connectionList.size(); j++) {
ConnectionType type = (ConnectionType) connectionList.get(j);
//$NON-NLS-1$
Element connectionElement = connectionsElement.addElement("connection");
//$NON-NLS-1$
connectionElement.addAttribute("label", HTMLDocUtils.checkString(type.getLabel()));
//$NON-NLS-1$ //$NON-NLS-2$
connectionElement.addAttribute("lineStyle", HTMLDocUtils.checkString(type.getLineStyle() + ""));
//$NON-NLS-1$
connectionElement.addAttribute("metaname", HTMLDocUtils.checkString(type.getMetaname()));
//$NON-NLS-1$ //$NON-NLS-2$
connectionElement.addAttribute("offsetLabelX", HTMLDocUtils.checkString(type.getOffsetLabelX() + ""));
//$NON-NLS-1$ //$NON-NLS-2$
connectionElement.addAttribute("offsetLabelY", HTMLDocUtils.checkString(type.getOffsetLabelY() + ""));
//$NON-NLS-1$
connectionElement.addAttribute("source", HTMLDocUtils.checkString(type.getSource()));
//$NON-NLS-1$
connectionElement.addAttribute("target", HTMLDocUtils.checkString(type.getTarget()));
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class HTMLDocGenerator method handleSourceAndTargetConnection.
/**
* Comment method "handleSourceAndTargetConnection".
*
* @param sourceConnectionMap
* @param targetConnectionMap
* @param connectionList
*/
protected void handleSourceAndTargetConnection(EList connectionList) {
List<String> targetList = new ArrayList<String>();
List<String> sourceList = new ArrayList<String>();
for (int j = 0; j < connectionList.size(); j++) {
ConnectionType type = (ConnectionType) connectionList.get(j);
if (!targetConnectionMap.containsKey(type.getSource())) {
targetList = new ArrayList<String>();
}
if (!targetList.contains(type.getTarget())) {
targetList.add(type.getTarget());
}
targetConnectionMap.put(type.getSource(), targetList);
if (!sourceConnectionMap.containsKey(type.getTarget())) {
sourceList = new ArrayList<String>();
}
sourceList.add(type.getSource());
sourceConnectionMap.put(type.getTarget(), sourceList);
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class AddConnectorNameInConnections method addConnectorName.
/**
* DOC nrousseau Comment method "addConnectorName".
*
* @param item
* @return
*/
private boolean addConnectorName(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName() == null) {
EConnectionType connectionType = EConnectionType.getTypeFromId(currentConnection.getLineStyle());
currentConnection.setConnectorName(connectionType.getName());
modified = true;
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType 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.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class RenameConnectionRunErrorToComponentErrorTask method renameConnections.
/**
* yzhang Comment method "renameConnections".
*
* @param item
* @param processType
*/
private void renameConnections(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName().equals("RUN_ERROR")) {
//$NON-NLS-1$
currentConnection.setConnectorName(EConnectionType.ON_COMPONENT_ERROR.getName());
currentConnection.setLabel(EConnectionType.ON_COMPONENT_ERROR.getDefaultLinkName());
currentConnection.setLineStyle(EConnectionType.ON_COMPONENT_ERROR.getId());
modified = true;
}
}
if (modified) {
factory.save(item, true);
}
}
Aggregations