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;
}
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;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class NewNetsuiteMigrationTask method processSearchConditionsTable.
private void processSearchConditionsTable(GenericElementParameter param, ElementParameterType paramType, NamedThing target) {
ComponentProperties searchQueryProps = (ComponentProperties) target;
List<ElementValueType> columns = paramType.getElementValue();
if (!(columns != null && columns.size() > 0)) {
return;
}
Map<String, String> columnMapping = new HashMap<String, String>();
columnMapping.put("INPUT_COLUMN", "field");
columnMapping.put("OPERATOR", "operator");
columnMapping.put("RVALUE", "value1");
columnMapping.put("RVALUE2", "value2");
List<String> fieldPropPossibleValues = new ArrayList<String>();
List<Map<String, Object>> tableEntries = new ArrayList<Map<String, Object>>();
Map<String, Object> tableEntry = null;
for (ElementValueType column : columns) {
String sourceName = column.getElementRef();
if ("INPUT_COLUMN".equals(sourceName)) {
if (tableEntry != null) {
tableEntries.add(tableEntry);
}
tableEntry = new HashMap<String, Object>();
}
String targetName = columnMapping.get(sourceName);
Object targetValue = column.getValue();
if ("field".equals(targetName)) {
String mappedFieldName = toInitialLower(targetValue.toString());
targetValue = mappedFieldName;
fieldPropPossibleValues.add(mappedFieldName);
} else if ("operator".equals(targetName)) {
String mappedOperatorName = searchOperatorMapping.get(targetValue.toString());
if (mappedOperatorName != null) {
targetValue = mappedOperatorName;
}
}
tableEntry.put(targetName, targetValue);
}
tableEntries.add(tableEntry);
GenericTableUtils.setTableValues(searchQueryProps, tableEntries, param);
Property<String> fieldProp = (Property<String>) searchQueryProps.getProperty("field");
fieldProp.setPossibleValues(Arrays.asList("type"));
Property<String> operatorProp = (Property<String>) searchQueryProps.getProperty("operator");
List<String> operatorPropPossibleValues = new ArrayList<String>(searchOperatorMapping.values());
Collections.sort(operatorPropPossibleValues);
operatorProp.setPossibleValues(operatorPropPossibleValues);
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class ChangeModelForRoutineParameterMigrationTask2 method execute.
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
try {
List<String> possibleRoutines = new ArrayList<String>();
List<String> routinesToAdd = new ArrayList<String>();
String additionalString = LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA ? "." : "";
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> routines = factory.getAll(ProjectManager.getInstance().getCurrentProject(), ERepositoryObjectType.ROUTINES);
// always add the system, others must be checked
for (IRepositoryViewObject object : routines) {
if (((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
routinesToAdd.add(object.getLabel());
} else {
possibleRoutines.add(object.getLabel());
}
}
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject object : refRoutines) {
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
if (!possibleRoutines.contains(object.getLabel())) {
possibleRoutines.add(object.getLabel());
routines.add(object);
}
}
}
}
List<RoutinesParameterType> oldList = Collections.EMPTY_LIST;
ProcessType processType = getProcessType(item);
if (null != processType) {
if (processType.getParameters() != null && processType.getParameters().getRoutinesParameter() == null) {
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
processType.setParameters(parameterType);
if (item instanceof ProcessItem) {
routinesToAdd.addAll(possibleRoutines);
possibleRoutines.clear();
}
} else {
if (processType.getParameters() == null) {
processType.setParameters(TalendFileFactory.eINSTANCE.createParametersType());
}
oldList = new ArrayList<RoutinesParameterType>(processType.getParameters().getRoutinesParameter());
if (oldList.isEmpty() && item instanceof ProcessItem) {
routinesToAdd.addAll(possibleRoutines);
possibleRoutines.clear();
}
processType.getParameters().getRoutinesParameter().clear();
}
if (processType.getRoutinesDependencies() != null && !processType.getRoutinesDependencies().isEmpty()) {
processType.getRoutinesDependencies().clear();
}
List<RoutinesParameterType> routinesDependencies = (List<RoutinesParameterType>) processType.getParameters().getRoutinesParameter();
if (!possibleRoutines.isEmpty()) {
// check possible routines to setup in process
for (ElementParameterType param : (List<ElementParameterType>) processType.getParameters().getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
// check possible routines to setup in nodes
for (NodeType node : ((List<NodeType>) processType.getNode())) {
for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
// check possible routines to setup in connections
for (ConnectionType connection : ((List<ConnectionType>) processType.getConnection())) {
for (ElementParameterType param : (List<ElementParameterType>) connection.getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
}
// just in case some routine dependencies exist before but are lost... (migration from 4.1.1 or 4.1.2)
for (RoutinesParameterType routine : oldList) {
if (!routinesToAdd.contains(routine.getName())) {
routinesDependencies.add(routine);
}
}
for (IRepositoryViewObject object : routines) {
if (routinesToAdd.contains(object.getLabel())) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(object.getId());
routinesParameterType.setName(object.getLabel());
routinesDependencies.add(routinesParameterType);
}
}
factory.save(item, true);
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class ChangeReturnTypeOfServerAliveResult method convertItem.
private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ECodeLanguage language = getProject().getLanguage();
EList node = processType.getNode();
EList connections = processType.getConnection();
for (Object n : node) {
NodeType type = (NodeType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemType.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemType.setValue(replace);
modified = true;
}
}
}
// for table
EList elemValue = elemType.getElementValue();
for (Object elemV : elemValue) {
ElementValueType elemVal = (ElementValueType) elemV;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemVal.getValue() != null && elemVal.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemVal.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemVal.setValue(replace);
modified = true;
}
}
}
}
}
}
// the links
for (Object n : connections) {
ConnectionType type = (ConnectionType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemType.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemType.setValue(replace);
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
Aggregations