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 tesb-studio-se by Talend.
the class CreateNewJobAction method repositoryChange.
private void repositoryChange(RepositoryNode nodeOperation, Node nodeProviderRequest) {
IElementParameter param = nodeProviderRequest.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (param != null) {
param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
ConnectionItem connectionItem = (ConnectionItem) nodeOperation.getObject().getProperty().getItem();
String serviceId = connectionItem.getProperty().getId();
String portId = ((PortRepositoryObject) nodeOperation.getParent().getObject()).getId();
String operationId = ((OperationRepositoryObject) nodeOperation.getObject()).getId();
ChangeValuesFromRepository command2 = new ChangeValuesFromRepository(nodeProviderRequest, connectionItem.getConnection(), param.getName() + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
serviceId + " - " + portId + " - " + operationId);
command2.execute();
}
}
use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tesb-studio-se by Talend.
the class AssignJobAction method repositoryChangeToBuildIn.
private void repositoryChangeToBuildIn(RepositoryNode repNode, INode node) {
IElementParameter param = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
ConnectionItem connectionItem = (ConnectionItem) repNode.getObject().getProperty().getItem();
if (param != null) {
param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.BUILTIN);
ChangeValuesFromRepository command2 = new ChangeValuesFromRepository(node, connectionItem.getConnection(), param.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
EmfComponent.BUILTIN);
command2.execute();
command2 = new ChangeValuesFromRepository(node, connectionItem.getConnection(), param.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
"");
command2.execute();
}
}
Aggregations