use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class StatsAndLogsHelper method changeRepositoryConnection.
static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class ProjectSettingManager method changeImplicitContextRepositoryItem.
static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
// change repository item
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class DetectContextVarsUtils method detectByPropertyType.
/**
*
* ggu Comment method "detectByPropertyType".
*
* type is the EParameterFieldType.PROPERTY_TYPE
*/
public static Map<String, Set<String>> detectByPropertyType(Element element, boolean show) {
Map<String, Set<String>> varsMap = new HashMap<String, Set<String>>();
// PTODO
List<IElementParameter> elementParameters = element.getElementParametersFromField(EParameterFieldType.PROPERTY_TYPE);
if (elementParameters != null) {
for (IElementParameter ptParam : elementParameters) {
IElementParameter rParam = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
IElementParameter idParam = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (rParam != null && idParam != null && EmfComponent.REPOSITORY.equals(rParam.getValue())) {
String id = (String) idParam.getValue();
ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId(id);
if (connItem != null) {
ConnectionContextHelper.checkContextMode(connItem);
Connection connection = connItem.getConnection();
if (connection.isContextMode() && (!show || (show && ptParam.isShow(element.getElementParameters())))) {
Set<String> neededVars = ConnectionContextHelper.retrieveContextVar(element.getElementParameters(), connection, null);
if (neededVars != null && !neededVars.isEmpty()) {
Set<String> varsSet = varsMap.get(id);
if (varsSet == null) {
varsMap.put(id, neededVars);
} else {
varsSet.addAll(neededVars);
}
}
}
}
}
}
}
return varsMap;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class UpdateUrlForRedShiftMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
Connection connection = ((DatabaseConnectionItem) item).getConnection();
if (connection instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) connection;
try {
if (EDatabaseTypeName.REDSHIFT.getDisplayName().equals(dbConn.getDatabaseType())) {
// old url: //jdbc:[postgresql|paraccel]://localhost:5439/test
String oldUrl = dbConn.getURL();
if (oldUrl != null) {
//$NON-NLS-1$ //$NON-NLS-2$
String newUrl = oldUrl.replaceFirst("jdbc:\\w+:", "jdbc:redshift:");
if (!oldUrl.equals(newUrl)) {
dbConn.setURL(newUrl);
ProxyRepositoryFactory.getInstance().save(item, true);
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.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class UnifyPasswordEncryption4DBConnectionMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
Connection connection = ((DatabaseConnectionItem) item).getConnection();
if (connection instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) connection;
try {
if (!dbConn.isContextMode()) {
String pass = dbConn.getPassword();
String rawPass = null;
try {
rawPass = PasswordEncryptUtil.decryptPassword(pass);
} catch (Exception e) {
// MOD xqliu 2010-07-07 bug 13826
rawPass = ConnectionHelper.getDecryptPassword(pass);
// ~ 13826
}
// decrypt the old password.
dbConn.setRawPassword(rawPass);
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations