Search in sources :

Example 1 with ElementValueType

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

the class ChangeELTHiveOutputPartitionValue method wrapQuot.

private boolean wrapQuot(Item item, ProcessType processType) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    EList node = processType.getNode();
    for (Object n : node) {
        NodeType type = (NodeType) n;
        if (type.getComponentName().equals("tELTHiveOutput")) {
            //$NON-NLS-1$
            EList elementParameterList = type.getElementParameter();
            for (Object elem : elementParameterList) {
                ElementParameterType elemType = (ElementParameterType) elem;
                if (elemType.getName().equals("FIELD_PARTITION")) {
                    //$NON-NLS-1$
                    EList elemValue = elemType.getElementValue();
                    for (Object eVal : elemValue) {
                        ElementValueType elemVal = (ElementValueType) eVal;
                        String originV = elemVal.getValue();
                        //$NON-NLS-1$ //$NON-NLS-2$
                        elemVal.setValue("\"" + originV + "\"");
                        modified = true;
                    }
                }
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
    return modified;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 2 with ElementValueType

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

the class SettingValuesIntoHadoopPropertiesFortHiveConnection method moveValuesFromHiveMap2HiveConn.

/* <p>
	 * Copy the values of these parameters:SET_MAPRED_JT, MAPRED_JT, SET_FS_DEFAULT_NAME, FS_DEFAULT_NAME and HADOOP_ADVANCED_PROPERTIES
	 * From the tELTHiveMap to the tHiveConnection when the "Use Existing Connection" in tELTHiveMap is ticked.
	 * </p>
	 */
private void moveValuesFromHiveMap2HiveConn(NodeType tHiveMapNode, NodeType tHiveConnNode) {
    if (tHiveMapNode == null || tHiveConnNode == null) {
        return;
    }
    //$NON-NLS-1$
    ElementParameterType setMapredJt = ComponentUtilities.getNodeProperty(tHiveMapNode, "SET_MAPRED_JT");
    //$NON-NLS-1$	
    ElementParameterType mapredJt = ComponentUtilities.getNodeProperty(tHiveMapNode, "MAPRED_JT");
    if ((setMapredJt != null && "true".equalsIgnoreCase(setMapredJt.getValue())) && mapredJt != null) {
        //$NON-NLS-1$
        ElementParameterType setMapredJt2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "SET_MAPRED_JT");
        //$NON-NLS-1$
        ElementParameterType mapredJt2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "MAPRED_JT");
        if (setMapredJt2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "SET_MAPRED_JT", "CHECK");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "SET_MAPRED_JT", "true");
        if (mapredJt2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "MAPRED_JT", "TEXT");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "MAPRED_JT", mapredJt.getValue());
    }
    //$NON-NLS-1$
    ElementParameterType setFsDefaultName = ComponentUtilities.getNodeProperty(tHiveMapNode, "SET_FS_DEFAULT_NAME");
    //$NON-NLS-1$
    ElementParameterType fsDefaultName = ComponentUtilities.getNodeProperty(tHiveMapNode, "FS_DEFAULT_NAME");
    if ((setFsDefaultName != null && "true".equalsIgnoreCase(setFsDefaultName.getValue())) && fsDefaultName != null) {
        //$NON-NLS-1$
        ElementParameterType setFsDefaultName2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "SET_FS_DEFAULT_NAME");
        //$NON-NLS-1$
        ElementParameterType fsDefaultName2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "FS_DEFAULT_NAME");
        if (setFsDefaultName2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "SET_FS_DEFAULT_NAME", "CHECK");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "SET_FS_DEFAULT_NAME", "true");
        if (fsDefaultName2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "FS_DEFAULT_NAME", "TEXT");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "FS_DEFAULT_NAME", fsDefaultName.getValue());
    }
    ElementParameterType hadoopAdvancedPropertiesParam = //$NON-NLS-1$
    ComponentUtilities.getNodeProperty(tHiveMapNode, "HADOOP_ADVANCED_PROPERTIES");
    if (hadoopAdvancedPropertiesParam != null) {
        //$NON-NLS-1$
        EList<ElementValueType> hadoopAdvancedProperties = hadoopAdvancedPropertiesParam.getElementValue();
        ElementValueType columnNamePropertyElement = null;
        ElementValueType columnNameValueElement = null;
        if (hadoopAdvancedProperties != null && hadoopAdvancedProperties.size() > 0) {
            ElementParameterType hadoopAdvancedPropertiesParam2 = //$NON-NLS-1$
            ComponentUtilities.getNodeProperty(tHiveConnNode, "HADOOP_ADVANCED_PROPERTIES");
            if (hadoopAdvancedPropertiesParam2 == null) {
                ComponentUtilities.addNodeProperty(tHiveConnNode, "HADOOP_ADVANCED_PROPERTIES", "TABLE");
                hadoopAdvancedPropertiesParam2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "HADOOP_ADVANCED_PROPERTIES");
            }
            for (int i = 0; i < hadoopAdvancedProperties.size(); i = i + 2) {
                columnNamePropertyElement = TalendFileFactory.eINSTANCE.createElementValueType();
                //$NON-NLS-1$
                columnNamePropertyElement.setElementRef("PROPERTY");
                columnNamePropertyElement.setValue(hadoopAdvancedProperties.get(i).getValue());
                hadoopAdvancedPropertiesParam2.getElementValue().add(columnNamePropertyElement);
                columnNameValueElement = TalendFileFactory.eINSTANCE.createElementValueType();
                //$NON-NLS-1$
                columnNameValueElement.setElementRef("VALUE");
                columnNameValueElement.setValue(hadoopAdvancedProperties.get(i + 1).getValue());
                hadoopAdvancedPropertiesParam2.getElementValue().add(columnNameValueElement);
            }
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)

Example 3 with ElementValueType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType 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)

Example 4 with ElementValueType

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

the class SetFilterTiemFromTotoFromPOPComponentsMigrationTask method execute.

/*
	 * (non-Javadoc)
	 * 
	 * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
	 * ProcessItem)
	 */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        IComponentFilter filter = new NameComponentFilter("tPOP");
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                ElementParameterType p = ComponentUtilities.getNodeProperty(node, "ADVANCED_FILTER");
                EList<ElementValueType> es = p.getElementValue();
                for (int j = 0; j < es.size(); j++) {
                    if (es.get(j) != null && "To".equals(es.get(j).getValue())) {
                        es.get(j).setValue("From");
                    }
                }
            }
        }));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        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) 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) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 5 with ElementValueType

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

the class ChangeRecordMatchingCustomFunctionValueTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    IComponentConversion changeCustomFunctionValue = new IComponentConversion() {

        @Override
        public void transform(NodeType node) {
            //$NON-NLS-1$
            ElementParameterType eleParam = ComponentUtilities.getNodeProperty(node, "JOIN_KEY");
            if (eleParam != null) {
                EList<ElementValueType> currentEleValues = eleParam.getElementValue();
                Iterator<ElementValueType> iterator = currentEleValues.iterator();
                while (iterator.hasNext()) {
                    ElementValueType param = iterator.next();
                    if ("MATCHING_TYPE".equals(param.getElementRef()) && "Custom".equals(param.getValue())) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        //$NON-NLS-1$
                        param.setValue("custom");
                    }
                }
            }
        }
    };
    try {
        List<IComponentFilter> filters = new ArrayList<IComponentFilter>();
        //$NON-NLS-1$
        filters.add(new NameComponentFilter("tRecordMatching"));
        Iterator<IComponentFilter> iter = filters.iterator();
        while (iter.hasNext()) {
            IComponentFilter filter = iter.next();
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeCustomFunctionValue));
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) ArrayList(java.util.ArrayList) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) 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) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)35 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)28 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)21 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)16 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)15 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)15 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)13 ArrayList (java.util.ArrayList)12 List (java.util.List)11 EList (org.eclipse.emf.common.util.EList)8 HashMap (java.util.HashMap)7 Map (java.util.Map)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)4 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)4 HashSet (java.util.HashSet)2 EObject (org.eclipse.emf.ecore.EObject)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)2 RemovePropertyComponentConversion (org.talend.core.model.components.conversions.RemovePropertyComponentConversion)2