Search in sources :

Example 6 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class ComponentSettingsView method getCategories.

/**
     * yzhang Comment method "getCategories".
     * 
     * @param elem
     * @return
     */
private EComponentCategory[] getCategories(Element elem) {
    if (elem instanceof Connection) {
        EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
        if (PluginChecker.isTeamEdition()) {
            Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
            if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
                // if (((Connection) elem).checkTraceShowEnable()) {
                final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
                boolean isMRProcess = false;
                IProcess process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
                        isMRProcess = true;
                    }
                }
                boolean isStormProcess = false;
                process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
                        isStormProcess = true;
                    }
                }
                // mrjob and stormjob not add breakpoint
                if (!isStormProcess && !isMRProcess) {
                    list.add(EComponentCategory.BREAKPOINT);
                }
                if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
                    list.add(EComponentCategory.PARALLELIZATION);
                }
                // if it mr group line then add errorRecovery
                if (isMRProcess && isMrGroupLine(elem)) {
                    list.add(EComponentCategory.RESUMING);
                }
                return list.toArray(new EComponentCategory[0]);
            // }
            } else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
                boolean isMRProcess = false;
                IProcess process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
                        isMRProcess = true;
                    }
                }
                boolean isStormProcess = false;
                process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
                        isStormProcess = true;
                    }
                }
                int length = categories.length;
                EComponentCategory[] newCategories;
                boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
                boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
                if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
                    newCategories = new EComponentCategory[length + 1];
                    for (int i = 0; i < length; i++) {
                        newCategories[i] = categories[i];
                    }
                    EComponentCategory resuming = EComponentCategory.RESUMING;
                    newCategories[length] = resuming;
                } else {
                    newCategories = new EComponentCategory[length];
                    for (int i = 0; i < length; i++) {
                        newCategories[i] = categories[i];
                    }
                }
                return newCategories;
            }
        }
        return categories;
    } else if (elem instanceof Node) {
        // if (isAdvancedType(elem)) {
        if (((Node) elem).isELTComponent()) {
            if (//$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
                //$NON-NLS-1$
                return EElementType.ELT_NODE.getCategories();
            }
        }
        EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
        // add for bug TDI-8476
        if (((Node) elem).getComponent() != null) {
            String paletteType = ((Node) elem).getComponent().getPaletteType();
            if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
                categories = EElementType.NODE.getCategories();
            }
        }
        if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
            // show
            EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
            System.arraycopy(categories, 0, newCategories, 0, categories.length);
            newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
            return newCategories;
        }
        return categories;
    } else if (elem instanceof Note) {
        return EElementType.NOTE.getCategories();
    } else if (elem instanceof SubjobContainer) {
        return EElementType.SUBJOB.getCategories();
    } else if (elem instanceof ConnectionLabel) {
        return getCategories(((ConnectionLabel) elem).getConnection());
    }
    return null;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ArrayList(java.util.ArrayList) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IProcess2(org.talend.core.model.process.IProcess2) EConnectionType(org.talend.core.model.process.EConnectionType) IProcess(org.talend.core.model.process.IProcess) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 7 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class DisableUseBatchWhenRejectLineExists method execute.

/*
     * (non-Javadoc)
     *
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    List<String> filterList = Arrays.asList("tFirebirdOutput", "tGreenplumOutput", "tIngresOutput", "tInterbaseOutput", "tParAccelOutput", "tPostgresPlusOutput", "tSQLiteOutput", "tRedshiftOutput");
    List<String> filterListMore = Arrays.asList("tTeradataOutput", "tOracleOutput");
    IComponentConversion disableUseBatchWhenRejectLineExists = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH");
            List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
            for (ConnectionType connType : list) {
                EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
                if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
                    if (useBatch == null) {
                        ComponentUtilities.addNodeProperty(node, "USE_BATCH", "CHECK");
                    }
                    ComponentUtilities.getNodeProperty(node, "USE_BATCH").setValue("false");
                    break;
                }
            }
        }
    };
    IComponentConversion disableUseBatchWhenRejectLineExistsMore = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
            ElementParameterType useBatchAndUseExistingConn = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
            List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
            for (ConnectionType connType : list) {
                EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
                if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
                    if (useBatch == null) {
                        ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
                    }
                    if (useBatchAndUseExistingConn == null) {
                        ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
                    }
                    ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
                    ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
                    break;
                }
            }
        }
    };
    for (String componentName : filterList) {
        IComponentFilter filter = new NameComponentFilter(componentName);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExists));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    for (String componentName : filterListMore) {
        IComponentFilter filter = new NameComponentFilter(componentName);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExistsMore));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) EConnectionType(org.talend.core.model.process.EConnectionType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) EConnectionType(org.talend.core.model.process.EConnectionType) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 8 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class SetParallelizationCommand method setDeparallelization.

private void setDeparallelization(INode node) {
    if (node.isActivate()) {
        for (IConnection con : node.getIncomingConnections()) {
            EConnectionType lineStyle = con.getLineStyle();
            if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
                con.getElementParameter(EParameterName.PARTITIONER.getName()).setValue(Boolean.FALSE);
                con.getElementParameter(EParameterName.REPARTITIONER.getName()).setValue(Boolean.FALSE);
                con.getElementParameter(EParameterName.NONE.getName()).setValue(Boolean.FALSE);
                con.setPropertyValue(EParameterName.DEPARTITIONER.getName(), Boolean.TRUE);
            }
        }
        if (node.getOutgoingConnections().size() > 0) {
            setParallelization(node);
        }
    }
}
Also used : IConnection(org.talend.core.model.process.IConnection) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 9 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class DisableParallelizationCommand method disableParallelization.

private void disableParallelization(INode node) {
    if (node.getOutgoingConnections().size() > 0) {
        for (IConnection con : node.getOutgoingConnections()) {
            EConnectionType lineStyle = con.getLineStyle();
            if (lineStyle.hasConnectionCategory(IConnectionCategory.DATA)) {
                con.getElementParameter(EParameterName.REPARTITIONER.getName()).setValue(Boolean.FALSE);
                con.getElementParameter(EParameterName.DEPARTITIONER.getName()).setValue(Boolean.FALSE);
                con.getElementParameter(EParameterName.PARTITIONER.getName()).setValue(Boolean.FALSE);
                con.setPropertyValue(EParameterName.NONE.getName(), Boolean.TRUE);
                if (con.getTarget() != null) {
                    disableParallelization(con.getTarget());
                }
            } else {
                node = con.getTarget();
                disableParallelization(node);
            }
        }
    }
}
Also used : IConnection(org.talend.core.model.process.IConnection) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 10 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class Component method createConnectors.

@Override
public List<INodeConnector> createConnectors(INode parentNode) {
    List<INodeConnector> listConnector = new ArrayList<>();
    ComponentProperties componentProperties = ComponentsUtils.getComponentProperties(getName());
    Set<? extends Connector> inputConnectors = componentProperties.getPossibleConnectors(false);
    if (inputConnectors.isEmpty()) {
        INodeConnector connector = null;
        connector = addStandardType(listConnector, EConnectionType.FLOW_MAIN, parentNode);
        connector.setMaxLinkInput(0);
        connector.setMaxLinkOutput(0);
    } else {
        for (Connector connector : inputConnectors) {
            addGenericType(listConnector, EConnectionType.FLOW_MAIN, connector.getName(), parentNode, componentProperties, false);
        }
    }
    Set<? extends Connector> outputConnectors = componentProperties.getPossibleConnectors(true);
    List<? extends Connector> sortedOutputConnectors = new ArrayList<>(outputConnectors);
    sortedOutputConnectors.sort(new Comparator<Connector>() {

        @Override
        public int compare(Connector o1, Connector o2) {
            if (Connector.MAIN_NAME.equals(o1.getName())) {
                return -1;
            }
            if (Connector.MAIN_NAME.equals(o2.getName())) {
                return 1;
            }
            return 0;
        }
    });
    for (Connector connector : sortedOutputConnectors) {
        EConnectionType type = EConnectionType.FLOW_MAIN;
        if (Connector.REJECT_NAME.equals(connector.getName())) {
            type = EConnectionType.REJECT;
        }
        addGenericType(listConnector, type, connector.getName(), parentNode, componentProperties, true);
    }
    addStandardType(listConnector, EConnectionType.RUN_IF, parentNode);
    addStandardType(listConnector, EConnectionType.ON_COMPONENT_OK, parentNode);
    addStandardType(listConnector, EConnectionType.ON_COMPONENT_ERROR, parentNode);
    addStandardType(listConnector, EConnectionType.ON_SUBJOB_OK, parentNode);
    addStandardType(listConnector, EConnectionType.ON_SUBJOB_ERROR, parentNode);
    Set<ConnectorTopology> topologies = componentDefinition.getSupportedConnectorTopologies();
    createIterateConnectors(topologies, listConnector, parentNode);
    for (int i = 0; i < EConnectionType.values().length; i++) {
        EConnectionType currentType = EConnectionType.values()[i];
        if ((currentType == EConnectionType.FLOW_REF) || (currentType == EConnectionType.FLOW_MERGE)) {
            continue;
        }
        boolean exists = false;
        for (INodeConnector curNodeConn : listConnector) {
            if (curNodeConn.getDefaultConnectionType().equals(currentType)) {
                exists = true;
                if (currentType == EConnectionType.FLOW_MAIN) {
                    curNodeConn.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
                    curNodeConn.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
                }
            }
        }
        if (!exists) {
            // will add by default all connectors not defined in
            NodeConnector nodeConnector = new NodeConnector(parentNode);
            nodeConnector.setDefaultConnectionType(currentType);
            nodeConnector.setName(currentType.getName());
            nodeConnector.setBaseSchema(currentType.getName());
            nodeConnector.addConnectionProperty(currentType, currentType.getRGB(), currentType.getDefaultLineStyle());
            nodeConnector.setLinkName(currentType.getDefaultLinkName());
            nodeConnector.setMenuName(currentType.getDefaultMenuName());
            if ((currentType == EConnectionType.PARALLELIZE) || (currentType == EConnectionType.SYNCHRONIZE)) {
                nodeConnector.setMaxLinkInput(1);
            } else {
                nodeConnector.setMaxLinkInput(0);
            }
            nodeConnector.setMaxLinkOutput(0);
            nodeConnector.setMinLinkInput(0);
            nodeConnector.setMinLinkOutput(0);
            listConnector.add(nodeConnector);
        }
    }
    return listConnector;
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) INodeConnector(org.talend.core.model.process.INodeConnector) Connector(org.talend.components.api.component.Connector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ComponentProperties(org.talend.components.api.properties.ComponentProperties) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ArrayList(java.util.ArrayList) INodeConnector(org.talend.core.model.process.INodeConnector) EConnectionType(org.talend.core.model.process.EConnectionType) ConnectorTopology(org.talend.components.api.component.ConnectorTopology)

Aggregations

EConnectionType (org.talend.core.model.process.EConnectionType)32 INode (org.talend.core.model.process.INode)9 INodeConnector (org.talend.core.model.process.INodeConnector)9 ArrayList (java.util.ArrayList)8 IConnection (org.talend.core.model.process.IConnection)7 Node (org.talend.designer.core.ui.editor.nodes.Node)7 Point (org.eclipse.draw2d.geometry.Point)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 List (java.util.List)4 EConnectionCategory (org.talend.core.model.process.EConnectionCategory)4 Dimension (org.eclipse.draw2d.geometry.Dimension)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)3 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)3 MalformedPatternException (org.apache.oro.text.regex.MalformedPatternException)2 PointList (org.eclipse.draw2d.geometry.PointList)2 CreateConnectionRequest (org.eclipse.gef.requests.CreateConnectionRequest)2 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)2 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)2 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)2