use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementValueTypeImpl in project tdi-studio-se by Talend.
the class AddPortForTCassandraConfigurationSpark method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$
String[] compNames = { "tCassandraConfiguration" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "PORT");
List<Object> needRemovedList = new ArrayList<Object>();
if (parameter == null) {
// get the value of native port if the user defined it on the configuration table
String portValue = null;
//$NON-NLS-1$
ElementParameterType configTable = ComponentUtilities.getNodeProperty(node, "CASSANDRA_CONFIGURATION");
boolean findNative = false;
boolean findRpc = false;
for (Object e : configTable.getElementValue()) {
ElementValueTypeImpl el = (ElementValueTypeImpl) e;
if (findNative && "VALUE".equals(el.getElementRef())) {
//$NON-NLS-1$
portValue = el.getValue();
needRemovedList.add(e);
findNative = false;
}
if (findRpc && "VALUE".equals(el.getElementRef())) {
//$NON-NLS-1$
needRemovedList.add(e);
findRpc = false;
}
if ("KEY".equals(el.getElementRef())) {
//$NON-NLS-1$
if ("connection_native_port".equals(el.getValue())) {
//$NON-NLS-1$
findNative = true;
needRemovedList.add(e);
}
if ("connection_rpc_port".equals(el.getValue())) {
//$NON-NLS-1$
findRpc = true;
needRemovedList.add(e);
}
}
}
configTable.getElementValue().removeAll(needRemovedList);
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "PORT", "TEXT");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "PORT", portValue == null ? "\"9042\"" : portValue);
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementValueTypeImpl in project tdi-studio-se by Talend.
the class ChangeValueBug14780 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 (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tSchemaComplianceCheck" };
try {
for (int i = 0; i < componentsName.length; i++) {
IComponentFilter filter = new NameComponentFilter(componentsName[i]);
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "EMPTY_IS_NULL") != null) {
if (ComponentUtilities.getNodeProperty(node, "EMPTY_IS_NULL").getValue().equals("true")) {
ComponentUtilities.addNodeProperty(node, "ALL_EMPTY_ARE_NULL", "CHECK");
ComponentUtilities.getNodeProperty(node, "ALL_EMPTY_ARE_NULL").setValue("false");
ComponentUtilities.getNodeProperty(node, "EMPTY_IS_NULL").setValue("false");
} else {
for (Object obj : ComponentUtilities.getNodeProperty(node, "EMPTY_NULL_TABLE").getElementValue()) {
ElementValueTypeImpl evt = (ElementValueTypeImpl) obj;
if ("EMPTY_NULL".equals(evt.getElementRef())) {
evt.setValue("false");
}
}
ComponentUtilities.addNodeProperty(node, "ALL_EMPTY_ARE_NULL", "CHECK");
ComponentUtilities.getNodeProperty(node, "ALL_EMPTY_ARE_NULL").setValue("false");
}
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementValueTypeImpl in project tdi-studio-se by Talend.
the class MapNetsuiteOperatorValueTDI32245 method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {
public void transform(NodeType node) {
Map<String, String> operatorMap = new HashMap<String, String>();
operatorMap.put("contains", "S-contains");
operatorMap.put("doesNotContain", "S-doesNotContain");
operatorMap.put("doesNotStartWith", "S-doesNotStartWith");
operatorMap.put("emptyS", "S-empty");
operatorMap.put("hasKeywords", "S-hasKeywords");
operatorMap.put("is", "S-is");
operatorMap.put("isNot", "S-isNot");
operatorMap.put("notEmptyS", "S-notEmpty");
operatorMap.put("startsWith", "S-startsWith");
operatorMap.put("between", "N-between");
operatorMap.put("notBetween", "N-notBetween");
operatorMap.put("emptyN", "N-empty");
operatorMap.put("equalTo", "N-equalTo");
operatorMap.put("greaterThan", "N-greaterThan");
operatorMap.put("greaterThanOrEqualTo", "N-greaterThanOrEqualTo");
operatorMap.put("lessThan", "N-lessThan");
operatorMap.put("lessThanOrEqualTo", "N-lessThanOrEqualTo");
operatorMap.put("notEmptyN", "N-notEmpty");
operatorMap.put("notEqualTo", "N-notEqualTo");
operatorMap.put("notGreaterThan", "N-notGreaterThan");
operatorMap.put("notGreaterThanOrEqualTo", "N-notGreaterThanOrEqualTo");
operatorMap.put("notLessThan", "N-notLessThan");
operatorMap.put("notLessThanOrEqualTo", "N-notLessThanOrEqualTo");
operatorMap.put("anyOf", "L-anyOf");
operatorMap.put("noneOf", "L-noneOf");
operatorMap.put("after", "D-after");
operatorMap.put("before", "D-before");
operatorMap.put("emptyD", "D-empty");
operatorMap.put("notAfter", "D-notAfter");
operatorMap.put("notBefore", "D-notBefore");
operatorMap.put("notEmptyD", "D-notEmpty");
operatorMap.put("notOn", "D-notOn");
operatorMap.put("notOnOrAfter", "D-notOnOrAfter");
operatorMap.put("notOnOrBefore", "D-notOnOrBefore");
operatorMap.put("notWithin", "D-notWithin");
operatorMap.put("on", "D-on");
operatorMap.put("onOrAfter", "D-onOrAfter");
operatorMap.put("onOrBefore", "D-onOrBefore");
operatorMap.put("within", "D-within");
operatorMap.put("boolean", "B-boolean");
ElementParameterType criteriaTable = ComponentUtilities.getNodeProperty(node, "CONDITIONS");
if (criteriaTable != null) {
for (Object o : criteriaTable.getElementValue()) {
ElementValueTypeImpl el = (ElementValueTypeImpl) o;
if (el.getElementRef().equals("OPERATOR")) {
String oldValue = el.getValue();
String newValue = operatorMap.get(oldValue);
el.setValue(newValue);
}
}
}
}
};
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tNetsuiteInput");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementValueTypeImpl in project tdi-studio-se by Talend.
the class UpgradeAttributestFilterRow 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 (getProject().getLanguage() == ECodeLanguage.PERL || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
} else {
//$NON-NLS-1$
String functionName = "FUNCTION";
//$NON-NLS-1$
String operatorName = "OPERATOR";
String[][] replaceFuntions = new String[][] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "S_VALUE_OF", "" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "N_VALUE_OF_FLOAT", "" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "N_VALUE_OF_INTEGER", "" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
{ "ABS_VALUE_FLOAT", "Math.abs($source) $operator $target" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "ABS_VALUE_INTEGER", "Math.abs($source) $operator $target" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "LC", "$source == null? false : $source.toLowerCase().compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "UC", "$source == null? false : $source.toUpperCase().compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "LCFIRST", "$source == null? false : $source.toLowerCase().charAt(0).compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "UCFIRST", "$source == null? false : $source.toUpperCase().charAt(0).compareTo($target) $operator 0" }, //$NON-NLS-1$ //$NON-NLS-2$
{ "LENGTH", "$source == null? false : $source.length() $operator $target" } };
String[][] replaceOperator = new String[][] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "EQ", "==" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "NE", "!=" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "GT", ">" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "LT", "<" }, { "GE", ">=" }, { "LE", "<=" }, { "MATCH", "==" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
{ "NMATCH", "!=" } };
boolean isModified = false;
NodeType tFilterRow = null;
for (Object oNodeType : processType.getNode()) {
NodeType nodeType = (NodeType) oNodeType;
if (nodeType.getComponentName().equals("tFilterRow")) {
//$NON-NLS-1$
tFilterRow = nodeType;
break;
}
}
if (tFilterRow != null) {
EList elementParameter = tFilterRow.getElementParameter();
for (Object object : elementParameter) {
ElementParameterTypeImpl parameter = (ElementParameterTypeImpl) object;
if (parameter.getName().equals("CONDITIONS")) {
//$NON-NLS-1$
EList elementValue = parameter.getElementValue();
ElementValueTypeImpl lastFunctionForMatch = null;
for (Object object2 : elementValue) {
ElementValueTypeImpl tableElement = (ElementValueTypeImpl) object2;
if (tableElement.getElementRef().equals(functionName)) {
for (String[] element : replaceFuntions) {
if (element[0].equals(tableElement.getValue())) {
tableElement.setValue(element[1]);
lastFunctionForMatch = tableElement;
isModified = true;
}
}
} else if (tableElement.getElementRef().equals(operatorName)) {
for (String[] element : replaceOperator) {
// list"
if ("MATCH".equals(tableElement.getValue()) || "NMATCH".equals(tableElement.getValue())) {
//$NON-NLS-1$ //$NON-NLS-2$
if (lastFunctionForMatch != null) {
lastFunctionForMatch.setValue(//$NON-NLS-1$
"$source == null? false : $source.matches($target) $operator true");
isModified = true;
}
}
if (element[0].equals(tableElement.getValue())) {
tableElement.setValue(element[1]);
isModified = true;
}
}
}
}
} else if (parameter.getName().equals("LOGICAL_OP")) {
//$NON-NLS-1$
if (parameter.getValue().equals("AND")) {
//$NON-NLS-1$
//$NON-NLS-1$
parameter.setValue("&&");
isModified = true;
} else if (parameter.getValue().equals("OR")) {
//$NON-NLS-1$
//$NON-NLS-1$
parameter.setValue("||");
isModified = true;
}
}
}
}
if (isModified) {
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
try {
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
Aggregations