use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getPropertyPublicPart.
private Command getPropertyPublicPart(RepositoryNode selectedNode, IElementParameter param, Node node, ConnectionItem connectionItem) {
param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
ChangeValuesFromRepository command2 = new ChangeValuesFromRepository(node, connectionItem.getConnection(), param.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
selectedNode.getObject().getProperty().getId());
if (selectedNode.getObject() instanceof IMetadataTable) {
IMetadataTable metadataTable = (IMetadataTable) selectedNode.getObject();
command2.setTable(metadataTable);
}
return command2;
}
use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.
the class ConvertRepositoryNodeToProcessNode method convertToProcessNode.
public void convertToProcessNode(ConnectionItem connectionItem, String tableName) throws ProcessorException {
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(connectionItem, ERepositoryObjectType.METADATA_CONNECTIONS);
String componentName = null;
componentName = name.getDefaultComponentName();
IComponent dbInputComponent = ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName());
Process process = new Process(GuessSchemaProcess.getNewmockProperty());
node = new Node(dbInputComponent, process);
selectedContext = node.getProcess().getContextManager().getDefaultContext();
// TDI-20011
IMetadataTable table = UpdateRepositoryUtils.getTableByName(connectionItem, tableName);
if (table == null) {
table = new MetadataTable();
table.setTableName(tableName);
table.setLabel(tableName);
}
IElementParameter propertyParam = ((Node) node).getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
IElementParameter schemaParam = ((Node) node).getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaParam == null) {
schemaParam = ((Node) node).getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
String propertyId = connectionItem.getProperty().getId();
String schema = databaseConnection.getUiSchema();
String dbType = databaseConnection.getDatabaseType();
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
CompoundCommand cc = new CompoundCommand();
// inital parameters command
ChangeValuesFromRepository changeValueCommand = new ChangeValuesFromRepository(node, databaseConnection, propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyId);
changeValueCommand.ignoreContextMode(true);
cc.add(changeValueCommand);
// change metadata command
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, table, null, null);
cc.add(changeMetadataCommand);
// guess query command
QueryGuessCommand queryGuessCommand = new QueryGuessCommand(node, node.getMetadataList().get(0), schema, dbType, databaseConnection);
cc.add(queryGuessCommand);
// execute the commands
cc.execute();
//$NON-NLS-1$
IElementParameter query = node.getElementParameter("QUERY");
//
memoSQL = query.getValue().toString();
String memoSQLTemp = TalendTextUtils.removeQuotesIfExist(memoSQL);
if ((memoSQLTemp == null || memoSQLTemp.equals("")) && tableName != null && !tableName.equals("")) {
//$NON-NLS-1$
boolean check = !Pattern.matches("^\\w+$", tableName);
boolean isJDBCForMysql = databaseConnection.getURL() == null ? false : databaseConnection.getURL().startsWith("jdbc:mysql");
if ((dbType.equals(EDatabaseTypeName.MYSQL.getDisplayName()) || isJDBCForMysql) && check) {
tableName = TalendQuoteUtils.addQuotes(tableName, TalendQuoteUtils.ANTI_QUOTE);
}
memoSQL = "select * from " + tableName;
memoSQL = TalendTextUtils.addSQLQuotes(memoSQL);
}
}
use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.
the class ValidationRuleTypeController method createComboCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createComboCommand(org
* .eclipse.swt.custom.CCombo)
*/
@Override
protected Command createComboCommand(CCombo combo) {
Connection repositoryConnection = null;
String paramName = (String) combo.getData(PARAMETER_NAME);
IElementParameter param = elem.getElementParameter(paramName);
String value = combo.getText();
for (int j = 0; j < param.getListItemsValue().length; j++) {
if (combo.getText().equals(param.getListItemsDisplayName()[j])) {
value = (String) param.getListItemsValue()[j];
}
}
if (value.equals(param.getValue())) {
return null;
}
ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, paramName, value);
return changeValuesFromRepository;
}
use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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);
}
}
}
use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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);
}
}
}
Aggregations