@Override public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); IComponentFilter filter = new NameComponentFilter("tMDMConnection"); try { ModifyComponentsAction.searchAndModify( item, processType, filter, Arrays.<IComponentConversion>asList( new IComponentConversion() { public void transform(NodeType node) { ElementParameterType username = ComponentUtilities.getNodeProperty(node, "USER"); // $NON-NLS-1$ ElementParameterType passwd = ComponentUtilities.getNodeProperty(node, "PASS"); // $NON-NLS-1$ if (username != null) { // $NON-NLS-1$ ComponentUtilities.getNodeProperty(node, "USER").setName("USERNAME"); } if (passwd != null) { // $NON-NLS-1$ ComponentUtilities.getNodeProperty(node, "PASS").setName("PASSWORD"); } } })); } catch (PersistenceException e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } return ExecutionResult.SUCCESS_NO_ALERT; }
@Override public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); String[] tmomCompNames = {"tMomInput", "tMomInputLoop", "tMomOutput"}; // $NON-NLS-1$ IComponentConversion changeActiveMqDriverJarType = new IComponentConversion() { public void transform(NodeType node) { ElementParameterType mq_drivers = ComponentUtilities.getNodeProperty(node, PROPERTY_TO_REMOVE); // $NON-NLS-2$ if (mq_drivers != null) { ComponentUtilities.removeNodeProperty(node, PROPERTY_TO_REMOVE); } } }; for (String name : tmomCompNames) { IComponentFilter filter = new NameComponentFilter(name); // $NON-NLS-4$ try { ModifyComponentsAction.searchAndModify( item, processType, filter, Arrays.<IComponentConversion>asList(changeActiveMqDriverJarType)); } catch (PersistenceException e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } } return ExecutionResult.SUCCESS_NO_ALERT; }
public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); if (processType == null) { return ExecutionResult.NOTHING_TO_DO; } try { IComponentFilter filter1 = new NameComponentFilter("tFileInputCSV"); // $NON-NLS-1$ IComponentConversion addProperty = new AddPropertyCSVOptionConversion(); IComponentConversion renameComponent = new RenameComponentConversion("tFileInputDelimited"); // $NON-NLS-1$ ModifyComponentsAction.searchAndModify( item, processType, filter1, Arrays.<IComponentConversion>asList(addProperty, renameComponent)); return ExecutionResult.SUCCESS_WITH_ALERT; } catch (Exception e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } }
/* * (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 (processType == null) { return ExecutionResult.NOTHING_TO_DO; } String[] componentsName = new String[] {"tPigLoad"}; // $NON-NLS-1$ try { for (String element : componentsName) { IComponentFilter filter = new NameComponentFilter(element); ModifyComponentsAction.searchAndModify( item, processType, filter, Arrays.<IComponentConversion>asList( new IComponentConversion() { @Override public void transform(NodeType node) { ElementParameterType ept = ComponentUtilities.getNodeProperty(node, "PIG_VERSION"); // $NON-NLS-1$ if (ept != null) { if ("CLOUDERA_0.20_CDH3U1".equals(ept.getValue())) { // $NON-NLS-1$ ComponentUtilities.setNodeValue( node, "PIG_VERSION", "Cloudera_0_20_CDH3U1"); //$NON-NLS-1$//$NON-NLS-2$ } else if ("CLOUDERA_CDH4".equals(ept.getValue())) { // $NON-NLS-1$ ComponentUtilities.setNodeValue( node, "PIG_VERSION", "Cloudera_CDH4"); // $NON-NLS-1$//$NON-NLS-2$ } else if ("MAPR".equals(ept.getValue())) { // $NON-NLS-1$ ComponentUtilities.setNodeValue( node, "PIG_VERSION", "MapR"); // $NON-NLS-1$//$NON-NLS-2$ } else if ("MAPR2".equals(ept.getValue())) { // $NON-NLS-1$ ComponentUtilities.setNodeValue( node, "PIG_VERSION", "MapR2"); // $NON-NLS-1$//$NON-NLS-2$ } } } })); } return ExecutionResult.SUCCESS_NO_ALERT; } catch (Exception e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } }
private void replaceHostAndPort(Item item) throws Exception { ProcessType processType = getProcessType(item); java.util.List<IComponentFilter> filters = new java.util.ArrayList<IComponentFilter>(); filters.add(new NameComponentFilter("tHDFSPut")); filters.add(new NameComponentFilter("tHDFSGet")); filters.add(new NameComponentFilter("tHDFSRename")); IComponentConversion addNNUri = new AddNNUri(); java.util.Iterator<IComponentFilter> iter = filters.iterator(); while (iter.hasNext()) { IComponentFilter filter = (IComponentFilter) iter.next(); ModifyComponentsAction.searchAndModify( item, processType, filter, Arrays.<IComponentConversion>asList(addNNUri)); } }
@Override public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) { try { ModifyComponentsAction.searchAndRename( item, processType, "tBuffer", "tBufferOutput"); // $NON-NLS-1$ //$NON-NLS-2$ return ExecutionResult.SUCCESS_WITH_ALERT; } catch (Exception e) { ExceptionHandler.process(e); return ExecutionResult.FAILURE; } } else { return ExecutionResult.NOTHING_TO_DO; } }
@Override public ExecutionResult execute(Item item) { ProcessType processType = getProcessType(item); String[] oracleCompNames = { "tOracleBulkExec", "tOracleClose", "tOracleCommit", "tOracleConnection", "tOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ "tOracleOutput", "tOracleOutputBulk", "tOracleOutputBulkExec", "tOracleRollback", "tOracleRow", "tOracleSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // //$NON-NLS-6$ "tOracleSCDELT", "tOracleSP", "tOracleTableList", "tAmazonOracleClose", "tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ "tAmazonOracleConnection", "tAmazonOracleInput", "tAmazonOracleOutput", "tAmazonOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "tAmazonOracleRow", "tMondrianInput", "tCreateTable", "tOracleInvalidRows", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "tOracleValidRows", "tELTOracleMap", "tOracleCDC", "tOracleSCDELT" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ IComponentConversion changeOracleDriverJarType = new IComponentConversion() { public void transform(NodeType node) { ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION"); // $NON-NLS-1$ if (dbVersion != null) { String jarValue = dbVersion.getValue(); if ("ojdbc6.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$ dbVersion.setValue("ORACLE_11-6"); // $NON-NLS-1$ } else if ("ojdbc5.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$ dbVersion.setValue("ORACLE_11"); // $NON-NLS-1$ } else if ("ojdbc14.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$ dbVersion.setValue("ORACLE_10"); // $NON-NLS-1$ } else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$ dbVersion.setValue("ORACLE_9"); // $NON-NLS-1$ } else if ("ojdbc12.jar".equalsIgnoreCase(jarValue)) { // $NON-NLS-1$ dbVersion.setValue("ORACLE_8"); // $NON-NLS-1$ } } } }; for (String name : oracleCompNames) { IComponentFilter filter = new NameComponentFilter(name); try { ModifyComponentsAction.searchAndModify( item, processType, filter, Arrays.<IComponentConversion>asList(changeOracleDriverJarType)); } catch (PersistenceException e) { // TODO Auto-generated catch block ExceptionHandler.process(e); return ExecutionResult.FAILURE; } } return ExecutionResult.SUCCESS_NO_ALERT; }
@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; } }