Search in sources :

Example 1 with RemovePropertyComponentConversion

use of org.talend.core.model.components.conversions.RemovePropertyComponentConversion in project tdi-studio-se by Talend.

the class MoveExcelSheetnameToSheetlist method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() == ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentFilter filter1 = new NameComponentFilter("tFileInputExcel");
        IComponentConversion addNewProperty = new IComponentConversion() {

            public void transform(NodeType node) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.addNodeProperty(node, "SHEETLIST", "TABLE");
                List<ElementValueType> values = new ArrayList<ElementValueType>();
                ElementValueType eValue = TalendFileFactory.eINSTANCE.createElementValueType();
                //$NON-NLS-1$
                eValue.setElementRef("SHEETNAME");
                //$NON-NLS-1$
                eValue.setValue(ComponentUtilities.getNodePropertyValue(node, "SHEETNAME"));
                values.add(eValue);
                //$NON-NLS-1$
                ComponentUtilities.setNodeProperty(node, "SHEETLIST", values);
            }
        };
        //$NON-NLS-1$
        IComponentConversion removeOldProperty = new RemovePropertyComponentConversion("SHEETNAME");
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(addNewProperty, removeOldProperty));
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
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) ArrayList(java.util.ArrayList) RemovePropertyComponentConversion(org.talend.core.model.components.conversions.RemovePropertyComponentConversion) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 2 with RemovePropertyComponentConversion

use of org.talend.core.model.components.conversions.RemovePropertyComponentConversion in project tdi-studio-se by Talend.

the class MoveExcelSheetnameToSheetlistForJava method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() == ECodeLanguage.PERL || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentFilter filter1 = new NameComponentFilter("tFileInputExcel");
        IComponentConversion addNewProperty = new IComponentConversion() {

            public void transform(NodeType node) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.addNodeProperty(node, "SHEETLIST", "TABLE");
                List<ElementValueType> values = new ArrayList<ElementValueType>();
                ElementValueType eValue = TalendFileFactory.eINSTANCE.createElementValueType();
                //$NON-NLS-1$
                eValue.setElementRef("SHEETNAME");
                //$NON-NLS-1$
                eValue.setValue(ComponentUtilities.getNodePropertyValue(node, "SHEETNAME"));
                values.add(eValue);
                //$NON-NLS-1$
                ComponentUtilities.setNodeProperty(node, "SHEETLIST", values);
            }
        };
        //$NON-NLS-1$
        IComponentConversion removeOldProperty = new RemovePropertyComponentConversion("SHEETNAME");
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(addNewProperty, removeOldProperty));
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
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) ArrayList(java.util.ArrayList) RemovePropertyComponentConversion(org.talend.core.model.components.conversions.RemovePropertyComponentConversion) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 3 with RemovePropertyComponentConversion

use of org.talend.core.model.components.conversions.RemovePropertyComponentConversion in project tdi-studio-se by Talend.

the class RenametDBInputToMssqlMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentConversion removePropertyComponentConversion = new RemovePropertyComponentConversion("TYPE");
        //$NON-NLS-1$
        RenameComponentConversion renameComponentConversion = new RenameComponentConversion("tMSSqlInput");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter1 = new PropertyComponentFilter("tDBInput", "TYPE", "mssql");
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        //$NON-NLS-1$
        renameComponentConversion.setNewName("tMSSqlOutput");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter2 = new PropertyComponentFilter("tDBOutput", "TYPE", "mssql");
        ModifyComponentsAction.searchAndModify(item, processType, filter2, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        //$NON-NLS-1$
        renameComponentConversion.setNewName("tMSSqlRow");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter3 = new PropertyComponentFilter("tDBSQLRow", "TYPE", "mssql");
        ModifyComponentsAction.searchAndModify(item, processType, filter3, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) RemovePropertyComponentConversion(org.talend.core.model.components.conversions.RemovePropertyComponentConversion) PropertyComponentFilter(org.talend.core.model.components.filters.PropertyComponentFilter) RenameComponentConversion(org.talend.core.model.components.conversions.RenameComponentConversion) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 4 with RemovePropertyComponentConversion

use of org.talend.core.model.components.conversions.RemovePropertyComponentConversion in project tdi-studio-se by Talend.

the class RenametDBInputToOracleMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentConversion removePropertyComponentConversion = new RemovePropertyComponentConversion("TYPE");
        //$NON-NLS-1$
        RenameComponentConversion renameComponentConversion = new RenameComponentConversion("tOracleInput");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter1 = new PropertyComponentFilter("tDBInput", "TYPE", "oracle");
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        //$NON-NLS-1$
        renameComponentConversion.setNewName("tOracleOutput");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter2 = new PropertyComponentFilter("tDBOutput", "TYPE", "oracle");
        ModifyComponentsAction.searchAndModify(item, processType, filter2, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        //$NON-NLS-1$
        renameComponentConversion.setNewName("tOracleRow");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter3 = new PropertyComponentFilter("tDBSQLRow", "TYPE", "oracle");
        ModifyComponentsAction.searchAndModify(item, processType, filter3, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) RemovePropertyComponentConversion(org.talend.core.model.components.conversions.RemovePropertyComponentConversion) PropertyComponentFilter(org.talend.core.model.components.filters.PropertyComponentFilter) RenameComponentConversion(org.talend.core.model.components.conversions.RenameComponentConversion) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 5 with RemovePropertyComponentConversion

use of org.talend.core.model.components.conversions.RemovePropertyComponentConversion in project tdi-studio-se by Talend.

the class RenametDBInputToPostgresqlMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentConversion removePropertyComponentConversion = new RemovePropertyComponentConversion("TYPE");
        //$NON-NLS-1$
        RenameComponentConversion renameComponentConversion = new RenameComponentConversion("tPostgresqlInput");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter1 = new PropertyComponentFilter("tDBInput", "TYPE", "postgresql");
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        //$NON-NLS-1$
        renameComponentConversion.setNewName("tPostgresqlOutput");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter2 = new PropertyComponentFilter("tDBOutput", "TYPE", "postgresql");
        ModifyComponentsAction.searchAndModify(item, processType, filter2, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        //$NON-NLS-1$
        renameComponentConversion.setNewName("tPostgresqlRow");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        IComponentFilter filter3 = new PropertyComponentFilter("tDBSQLRow", "TYPE", "postgresql");
        ModifyComponentsAction.searchAndModify(item, processType, filter3, Arrays.<IComponentConversion>asList(renameComponentConversion, removePropertyComponentConversion));
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) RemovePropertyComponentConversion(org.talend.core.model.components.conversions.RemovePropertyComponentConversion) PropertyComponentFilter(org.talend.core.model.components.filters.PropertyComponentFilter) RenameComponentConversion(org.talend.core.model.components.conversions.RenameComponentConversion) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)9 RemovePropertyComponentConversion (org.talend.core.model.components.conversions.RemovePropertyComponentConversion)9 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)9 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)9 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)6 PropertyComponentFilter (org.talend.core.model.components.filters.PropertyComponentFilter)6 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)3 ArrayList (java.util.ArrayList)2 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)1 AddPropertyUniqueKeyFortUniqRowConversion (org.talend.core.model.components.conversions.AddPropertyUniqueKeyFortUniqRowConversion)1