Search in sources :

Example 76 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class ReplaceMultiFlowBytReplicateMigrationTask method createNodeType.

/**
     * DOC nrousseau Comment method "createNodeType".
     * 
     * @param processType
     * @param replicatePos
     * @param nodeTypeSource
     * @param sourceName
     * @param nodeConnector
     * @param connections
     * @param fileFact
     * @return
     */
private String createNodeType(ProcessType processType, Point replicatePos, NodeType nodeTypeSource, String sourceName, INodeConnector nodeConnector, List<ConnectionType> connections, TalendFileFactory fileFact) {
    NodeType nodeType = fileFact.createNodeType();
    //$NON-NLS-1$
    String uniqueName = ComponentUtilities.generateUniqueNodeName("tReplicate", processType);
    ElementParameterType elemParam = fileFact.createElementParameterType();
    //$NON-NLS-1$
    elemParam.setField("TEXT");
    //$NON-NLS-1$
    elemParam.setName("UNIQUE_NAME");
    elemParam.setValue(uniqueName);
    nodeType.getElementParameter().add(elemParam);
    ComponentUtilities.setNodeUniqueName(nodeType, uniqueName);
    //$NON-NLS-1$
    nodeType.setComponentName("tReplicate");
    for (ConnectionType connectionType : connections) {
        //$NON-NLS-1$
        connectionType.setConnectorName("FLOW");
        connectionType.setSource(uniqueName);
        connectionType.setMetaname(uniqueName);
    }
    nodeType.setPosX(replicatePos.x);
    nodeType.setPosY(replicatePos.y);
    nodeType.setSizeX(GRID_SIZE);
    nodeType.setSizeY(GRID_SIZE);
    if (nodeTypeSource.getMetadata().size() != 0) {
        MetadataType metadataTypeSource = null;
        for (Object oMetadataType : nodeTypeSource.getMetadata()) {
            MetadataType metadataType = (MetadataType) oMetadataType;
            if ((metadataType.getConnector() != null && metadataType.getConnector().equals(nodeConnector.getName())) || metadataType.getName().equals(sourceName)) {
                metadataTypeSource = metadataType;
            }
        }
        if (metadataTypeSource != null) {
            MetadataType newMetadataType = fileFact.createMetadataType();
            newMetadataType.setComment(metadataTypeSource.getComment());
            //$NON-NLS-1$
            newMetadataType.setConnector("FLOW");
            newMetadataType.setName(uniqueName);
            for (Object oColumn : metadataTypeSource.getColumn()) {
                ColumnType columnType = (ColumnType) oColumn;
                ColumnType newColumnType = fileFact.createColumnType();
                newColumnType.setComment(columnType.getComment());
                newColumnType.setDefaultValue(columnType.getDefaultValue());
                if (columnType.isSetKey()) {
                    newColumnType.setKey(columnType.isKey());
                }
                if (columnType.isSetLength()) {
                    newColumnType.setLength(columnType.getLength());
                }
                newColumnType.setName(columnType.getName());
                if (columnType.isSetNullable()) {
                    newColumnType.setNullable(columnType.isNullable());
                }
                newColumnType.setOriginalDbColumnName(columnType.getOriginalDbColumnName());
                newColumnType.setPattern(columnType.getPattern());
                if (columnType.isSetPrecision()) {
                    newColumnType.setPrecision(columnType.getPrecision());
                }
                newColumnType.setSourceType(columnType.getSourceType());
                newColumnType.setType(columnType.getType());
                newMetadataType.getColumn().add(newColumnType);
            }
            nodeType.getMetadata().add(newMetadataType);
        }
    }
    processType.getNode().add(nodeType);
    return uniqueName;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Example 77 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class ReplaceMultiFlowBytReplicateMigrationTask method findLocationForNode.

/**
     * DOC nrousseau Comment method "findLocationForNode".
     * 
     * @param processType
     * @param point
     * @return
     */
private Point findLocationForNode(ProcessType processType, Point point) {
    Rectangle newRect = new Rectangle(point, new Dimension(GRID_SIZE, GRID_SIZE));
    Point newLocation = new Point(point);
    for (Object oNodeType : processType.getNode()) {
        NodeType node = (NodeType) oNodeType;
        String uniqueName = ComponentUtilities.getNodeUniqueName(node);
        Rectangle currentRect = getNodeRectangle(processType, uniqueName);
        if (currentRect.intersects(newRect)) {
            newLocation.x += GRID_SIZE;
            newLocation.y += GRID_SIZE;
            return findLocationForNode(processType, point);
        }
    }
    return newLocation;
}
Also used : NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 78 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class SetUrltStewardshipXXXTDI32354 method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String[] componentsName = new String[] { "tStewardshipTaskInput", "tStewardshipTaskOutput", "tStewardshipTaskDelete" };
    IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType host = ComponentUtilities.getNodeProperty(node, "HOST");
            ElementParameterType port = ComponentUtilities.getNodeProperty(node, "PORT");
            String url = "";
            if (host != null && port != null) {
                if ("tStewardshipTaskOutput".equals(node.getComponentName())) {
                    url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/dsctaskloader\"";
                } else {
                    url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/TDSCWS?wsdl\"";
                }
            }
            ElementParameterType serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
            if (serverVersion == null) {
                ComponentUtilities.addNodeProperty(node, "URL", "TEXT");
                serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
                serverVersion.setValue(url);
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) 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) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 79 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class SettingValuesIntoHadoopPropertiesFortHiveConnection method execute.

public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    try {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter("tELTHiveMap");
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ElementParameterType useExistingConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
                if (useExistingConn != null && "true".equalsIgnoreCase(useExistingConn.getValue())) {
                    //$NON-NLS-1$
                    ElementParameterType connNamePara = ComponentUtilities.getNodeProperty(node, "CONNECTION");
                    if (connNamePara != null) {
                        NodeType tHiveConnNode = searchNodeTypeByUniqName(processType, connNamePara.getValue());
                        moveValuesFromHiveMap2HiveConn(node, tHiveConnNode);
                    }
                }
            }
        }));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 80 with NodeType

use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.

the class SetDefaultValue4tWriteJSONFieldGroupByOutput method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    IComponentFilter filter = new NameComponentFilter("tWriteJSONField");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                EList<ElementValueType> list = ComponentUtilities.getNodeProperty(node, "GROUPBYS").getElementValue();
                ElementValueType outputColumnPropertyElement = null;
                int size = list.size();
                if (list != null && size > 0) {
                    String outputFieldValue = ComponentUtilities.getNodeProperty(node, "JSONFIELD").getValue();
                    for (int i = 0, j = 0; i < size; i++) {
                        outputColumnPropertyElement = TalendFileFactory.eINSTANCE.createElementValueType();
                        //$NON-NLS-1$
                        outputColumnPropertyElement.setElementRef("OUTPUT_COLUMN");
                        outputColumnPropertyElement.setValue(outputFieldValue);
                        list.add(j, outputColumnPropertyElement);
                        j = j + 2;
                    }
                }
            }
        }));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)198 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)157 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)127 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)112 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)111 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)110 PersistenceException (org.talend.commons.exception.PersistenceException)93 ProcessItem (org.talend.core.model.properties.ProcessItem)25 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)21 List (java.util.List)20 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)18 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)13 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)13 IComponent (org.talend.core.model.components.IComponent)10 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)9 Property (org.talend.core.model.properties.Property)8