use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class EncryptDbPasswordMigrationTask method encryptItem.
/**
* DOC chuang Comment method "encryptItem".
*
* @param item
* @return
*/
private ExecutionResult encryptItem(DatabaseConnectionItem item) {
Connection conn = item.getConnection();
if (conn instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) conn;
if (needEncrypted(dbConn)) {
try {
encryptPassword(dbConn);
factory.save(item, true);
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class EncryptPassword4FTPItemFileMigrationTask 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 FTPConnectionItem) {
FTPConnectionItem item1 = (FTPConnectionItem) item;
Connection connection = item1.getConnection();
if (connection instanceof FTPConnection) {
FTPConnection ftpConn = (FTPConnection) connection;
try {
if (encryptPassword(ftpConn)) {
factory.save(item, true);
}
} catch (Exception e1) {
ExceptionHandler.process(e1);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class ConvertLabelForConnectionItemMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
boolean changed = false;
if (item instanceof ConnectionItem) {
ConnectionItem conItem = (ConnectionItem) item;
Connection connection = conItem.getConnection();
Set tables = ConnectionHelper.getTables(connection);
for (Object tableObj : tables) {
MetadataTable table = (MetadataTable) tableObj;
String label = table.getLabel();
if (label != null) {
String validateValue = MetadataToolHelper.validateValue(label);
if (validateValue != null && !label.equals(validateValue)) {
table.setLabel(validateValue);
changed = true;
}
}
}
}
if (changed) {
try {
FACTORY.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 RepositoryChangeMetadataCommand method setTableRelevantParameterValues.
protected void setTableRelevantParameterValues() {
Connection conn = connection;
if (conn == null) {
if (newPropValue != null && newPropValue instanceof String) {
String schemaId = (String) newPropValue;
//$NON-NLS-1$
String[] values = schemaId.split(" - ");
String repositoryID = values[0];
IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(repositoryID);
if (repositoryNode != null && repositoryNode.getObject() != null) {
Item item = repositoryNode.getObject().getProperty().getItem();
if (item instanceof ConnectionItem) {
ConnectionItem conItem = (ConnectionItem) item;
conn = conItem.getConnection();
}
}
}
}
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
if (handler.canHandle(conn)) {
handler.handleTableRelevantParameters(conn, node, newOutputMetadata);
}
}
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class ComponentChooseDialog method propaHadoopCfgChanges.
/**
* DOC ycbai Comment method "propaHadoopCfgChanges".
*
* <P>
* Propagate the changes from hadoop cluster to M/R process when drag&drop hadoop subnode from repository view to
* M/R process.
* </P>
*
* @param repositoryNode
*/
private void propaHadoopCfgChanges(IRepositoryNode repositoryNode) {
if (repositoryNode == null || repositoryNode.getObject() == null) {
return;
}
IHadoopClusterService hadoopClusterService = HadoopRepositoryUtil.getHadoopClusterService();
if (hadoopClusterService == null || !hadoopClusterService.isHadoopSubnode(repositoryNode)) {
return;
}
IProcess process = editor.getProcess();
if (!ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
return;
}
if ((process instanceof IProcess2) && (((IProcess2) process).getProperty().getItem() instanceof JobletProcessItem)) {
return;
}
Item subItem = repositoryNode.getObject().getProperty().getItem();
String propertyParamName = MR_PROPERTY_PREFIX + EParameterName.PROPERTY_TYPE.getName();
String propertyRepTypeParamName = MR_PROPERTY_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
IElementParameter propertyParam = process.getElementParameter(propertyParamName);
if (propertyParam == null) {
return;
}
String repositoryValue = propertyParam.getRepositoryValue();
if (repositoryValue == null) {
return;
}
//$NON-NLS-1$
String[] supportedRepositoryTypes = repositoryValue.split("\\|");
String repositoryType = hadoopClusterService.getRepositoryTypeOfHadoopSubItem(subItem);
if (!ArrayUtils.contains(supportedRepositoryTypes, repositoryType)) {
return;
}
Item hadoopClusterItem = hadoopClusterService.getHadoopClusterBySubitemId(new Project(ProjectManager.getInstance().getProject(subItem)), subItem.getProperty().getId());
String hadoopClusterId = hadoopClusterItem.getProperty().getId();
if (EmfComponent.REPOSITORY.equals(propertyParam.getValue())) {
// do nothing when select the same hadoop cluster.
String propertyId = (String) process.getElementParameter(propertyRepTypeParamName).getValue();
if (hadoopClusterId.equals(propertyId)) {
return;
}
}
Connection connection = ((ConnectionItem) subItem).getConnection();
if (hadoopClusterService.hasDiffsFromClusterToProcess(subItem, process)) {
boolean confirmUpdate = MessageDialog.openConfirm(editor.getSite().getShell(), //$NON-NLS-1$
Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.title"), //$NON-NLS-1$
Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.msg"));
if (confirmUpdate) {
// Update spark mode to YARN_CLIENT if repository
if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
IElementParameter sparkLocalParam = process.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
IElementParameter sparkParam = process.getElementParameter(HadoopConstants.SPARK_MODE);
if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
sparkLocalParam.setValue(false);
}
if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
}
}
propertyParam.setValue(EmfComponent.REPOSITORY);
ChangeValuesFromRepository command = new ChangeValuesFromRepository(process, connection, propertyRepTypeParamName, subItem.getProperty().getId());
execCommandStack(command);
}
}
}
Aggregations