use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl in project tdi-studio-se by Talend.
the class UpdateJobSettingsForPostgresMigrationTask method updateJarValue.
private boolean updateJarValue(EList elementParameter) {
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
String name = parameterType.getName();
if ("DB_VERSION".equals(name)) {
String value = parameterType.getValue();
if (value.equals(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue()) || value.equals(EDatabaseVersion4Drivers.PSQL_V9_X.getVersionValue())) {
// do nothing
} else {
parameterType.setValue(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue());
return true;
}
}
}
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl 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;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl in project tdi-studio-se by Talend.
the class ChangePostgresDbVersionForProjectSetting method execute.
/*
* (non-Javadoc)
*
* @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
*/
@Override
public ExecutionResult execute(Project project) {
org.talend.core.model.properties.Project emfProject = project.getEmfProject();
StatAndLogsSettings statAndLogs = emfProject.getStatAndLogsSettings();
boolean modified = false;
if (statAndLogs != null && statAndLogs.getParameters() != null) {
ParametersType parameters = statAndLogs.getParameters();
List elementParameter = parameters.getElementParameter();
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
String name = parameterType.getName();
if ("ON_DATABASE_FLAG".equals(name) && !Boolean.valueOf(parameterType.getValue())) {
//$NON-NLS-1$
break;
}
if ("DB_TYPE".equals(name) && parameterType.getValue().startsWith("tPostgresql")) {
//$NON-NLS-1$
modified = updateJarValue(elementParameter) || modified;
}
}
}
}
ImplicitContextSettings implicitContext = emfProject.getImplicitContextSettings();
if (implicitContext != null && implicitContext.getParameters() != null) {
ParametersType parameters = implicitContext.getParameters();
List elementParameter = parameters.getElementParameter();
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
String name = parameterType.getName();
if ("FROM_DATABASE_FLAG_IMPLICIT_CONTEXT".equals(name) && !Boolean.valueOf(parameterType.getValue())) {
//$NON-NLS-1$
break;
}
if ("DB_TYPE_IMPLICIT_CONTEXT".equals(name) && parameterType.getValue().startsWith("tPostgresql")) {
//$NON-NLS-1$
modified = updateJarValueForImplici(elementParameter) || modified;
}
}
}
}
if (modified) {
try {
IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
prf.saveProject(project);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl in project tdi-studio-se by Talend.
the class ChangePostgresDbVersionForProjectSetting method updateJarValue.
private boolean updateJarValue(List elementParameter) {
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
String name = parameterType.getName();
if ("DB_VERSION".equals(name)) {
String value = parameterType.getValue();
if (value.equals(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue()) || value.equals(EDatabaseVersion4Drivers.PSQL_V9_X.getVersionValue())) {
// do nothing
} else {
parameterType.setValue(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue());
return true;
}
}
}
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl in project tdi-studio-se by Talend.
the class ChangePostgresDbVersionForProjectSetting method updateJarValueForImplici.
private boolean updateJarValueForImplici(List elementParameter) {
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
String name = parameterType.getName();
if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
String value = parameterType.getValue();
if (value.equals(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue()) || value.equals(EDatabaseVersion4Drivers.PSQL_V9_X.getVersionValue())) {
// do nothing
} else {
parameterType.setValue(EDatabaseVersion4Drivers.PSQL_PRIOR_TO_V9.getVersionValue());
return true;
}
}
}
}
return false;
}
Aggregations