use of org.talend.core.model.properties.StatAndLogsSettings in project tdi-studio-se by Talend.
the class EncryptPasswordInProjectSettingsMigrationTask 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 ElementParameterType) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for Stat&Logs
if ("PASS".equals(name)) {
//$NON-NLS-1$
try {
if (encryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
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) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for implicit context
if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-1$
try {
if (encryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
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.core.model.properties.StatAndLogsSettings in project tdi-studio-se by Talend.
the class UnifyPasswordEncryption4ProjectSettingsMigrationTask 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 ElementParameterType) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for Stat&Logs
if ("PASS".equals(name)) {
//$NON-NLS-1$
parameterType.setField(EParameterFieldType.PASSWORD.getName());
try {
if (reencryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
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) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for implicit context
if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-1$
parameterType.setField(EParameterFieldType.PASSWORD.getName());
try {
if (reencryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
if (modified) {
try {
factory.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.core.model.properties.StatAndLogsSettings in project tdi-studio-se by Talend.
the class JobSettingProjectSettingPage method performOk.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
@Override
public boolean performOk() {
if (mComposite != null) {
ImplicitContextSettings implicit = pro.getEmfProject().getImplicitContextSettings();
if (implicit != null) {
// save to emf Model
ElementParameter2ParameterType.setParameterValue(implicit.getParameters(), EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName(), Boolean.valueOf(implicitBtn.getSelection()));
// save to the memory
IElementParameter elementParameter = pro.getInitialContextLoad().getElementParameter(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName());
if (elementParameter != null) {
elementParameter.setValue(Boolean.valueOf(implicitBtn.getSelection()));
}
}
StatAndLogsSettings stat = pro.getEmfProject().getStatAndLogsSettings();
if (stat != null) {
ElementParameter2ParameterType.setParameterValue(stat.getParameters(), EParameterName.STATS_DEFAULT_PROJECTSETTING.getName(), Boolean.valueOf(statBtn.getSelection()));
IElementParameter elementParameter = pro.getStatsAndLog().getElementParameter(EParameterName.STATS_DEFAULT_PROJECTSETTING.getName());
if (elementParameter != null) {
elementParameter.setValue(Boolean.valueOf(statBtn.getSelection()));
}
}
ProjectSettingManager.saveProject();
}
return super.performOk();
}
use of org.talend.core.model.properties.StatAndLogsSettings 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.core.model.properties.StatAndLogsSettings in project tdi-studio-se by Talend.
the class ChangeMysqlVersionForProjectSetting 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_VERSION".equals(name)) {
//$NON-NLS-1$
modified = updateJarValue(parameterType) || 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_VERSION_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-1$
modified = updateJarValue(parameterType) || 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;
}
Aggregations