Search in sources :

Example 1 with ConnectionType

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()));
    }
}
Also used : ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) Element(org.dom4j.Element) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with ConnectionType

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);
    }
}
Also used : ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with ConnectionType

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;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 4 with ConnectionType

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;
    }
}
Also used : EConnectionType(org.talend.core.model.process.EConnectionType) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) ArrayList(java.util.ArrayList) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) ArrayList(java.util.ArrayList) List(java.util.List) EConnectionType(org.talend.core.model.process.EConnectionType) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 5 with ConnectionType

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);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType)

Aggregations

ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)29 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)14 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)13 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)13 EConnectionType (org.talend.core.model.process.EConnectionType)12 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)11 List (java.util.List)7 ArrayList (java.util.ArrayList)6 PersistenceException (org.talend.commons.exception.PersistenceException)5 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)5 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)5 HashMap (java.util.HashMap)4 Point (org.eclipse.draw2d.geometry.Point)4 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)4 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)4 EList (org.eclipse.emf.common.util.EList)3 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)3 Matcher (java.util.regex.Matcher)2 MalformedPatternException (org.apache.oro.text.regex.MalformedPatternException)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2