use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class RepositoryUpdateTest method prepareTableForTest.
private MetadataTable prepareTableForTest(String id) {
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
table.setLabel("myTableTest");
MetadataColumn col1 = ConnectionFactory.eINSTANCE.createMetadataColumn();
col1.setLabel("myColumn1");
col1.setTalendType(JavaTypesManager.STRING.getId());
col1.setLength(25);
table.getColumns().add(col1);
Schema avroSchema = MetadataToolAvroHelper.convertToAvro(table);
TaggedValue tv = CoreFactory.eINSTANCE.createTaggedValue();
tv.setTag(IComponentConstants.COMPONENT_PROPERTIES_TAG);
SalesforceModuleProperties smp = new SalesforceModuleProperties("test");
smp.connection.init();
// because we should get connection always from the main
smp.connection.userPassword.userId.setValue("old");
// SalesforceConnectionProperties
smp.moduleName.setStoredValue("myModule");
smp.main.schema.setStoredValue(avroSchema);
GenericRepository gr = new GenericRepository();
gr.storeProperties(smp, table.getLabel(), id + "#", "main.schema");
return table;
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class BRMSSchemaOutputDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
applyDialogFont(composite);
// Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new FillLayout());
tableEditor = new MetadataEmfTableEditor("");
MetadataTable metadataTable = form.getMetadataOutputTable();
tableEditor.setMetadataTable(metadataTable);
tableEditor.removeAll();
// List<MetadataColumn> list = (List<MetadataColumn>) metadataTable.getColumns();
// tableEditor.addAll(list);
// if (list.size() > 0) {
// for (MetadataColumn column : list) {
// boolean toAdd = true;
// for (int i = 0; i < list.size(); i++) {
// String label = column.getLabel();
// String curLabel = list.get(i).getLabel();
// if (label.equals(curLabel)) {
// toAdd = false;
// break;
// }
// }
// if (toAdd) {
// tableEditor.add(column);
// }
// }
// }
tableEditorView = new MetadataEmfTableEditorView(composite, SWT.NONE);
tableEditorView.setMetadataEditor(tableEditor);
addListeners();
return composite;
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable 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.MetadataTable in project tdi-studio-se by Talend.
the class ComponentChooseDialog method setSAPSpecailValueForCommand.
private void setSAPSpecailValueForCommand(RepositoryNode selectedNode, ChangeValuesFromRepository command) {
// Noted by Marvin Wang on Jun. 29, 2012. The piece of code is used to judge if the selected node is SAP
// Table node, if so, set up the table name to command.
IRepositoryViewObject object = selectedNode.getObject();
if (object instanceof MetadataColumnRepositoryObject) {
object = selectedNode.getParent().getParent().getObject();
}
SAPFunctionUnit unit = null;
if (object != null) {
if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) object;
MetadataTable abstractMetadataObject = (MetadataTable) tableObject.getAbstractMetadataObject();
if (abstractMetadataObject != null && abstractMetadataObject.eContainer() instanceof SAPFunctionUnit) {
unit = (SAPFunctionUnit) abstractMetadataObject.eContainer();
command.setSapFunctionLabel(unit.getLabel());
// set table name to functionName/type/tablename;
String currentTableName = //$NON-NLS-1$ //$NON-NLS-2$
unit.getLabel() + "/" + abstractMetadataObject.getTableType() + "/" + abstractMetadataObject.getLabel();
command.setCurrentTableName(currentTableName);
} else if (abstractMetadataObject instanceof SAPTable) {
command.setCurrentTableName(abstractMetadataObject.getLabel());
}
} else if (object instanceof SAPFunctionRepositoryObject) {
SAPFunctionRepositoryObject sapObj = (SAPFunctionRepositoryObject) object;
unit = sapObj.getModelElement();
command.setSapFunctionLabel(unit.getLabel());
} else if (object instanceof SAPIDocRepositoryObject) {
SAPIDocRepositoryObject sapObj = (SAPIDocRepositoryObject) object;
command.setSapIDocLabel(sapObj.getLabel());
}
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class DowngradeParameterHelper method getOldLabelFromId.
/**
* DOC nrousseau Comment method "getOldLabelFromId".
*
* @param id
* @param type
* @return
*/
private static String getOldLabelFromId(String id, ERepositoryObjectType type) {
final IProxyRepositoryFactory proxyRepositoryFactory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
try {
ERepositoryObjectType repositoryConnectionsNeeded;
if (type == ERepositoryObjectType.METADATA_CON_QUERY) {
repositoryConnectionsNeeded = ERepositoryObjectType.METADATA_CONNECTIONS;
} else {
repositoryConnectionsNeeded = ERepositoryObjectType.METADATA;
}
List<IRepositoryViewObject> objects = proxyRepositoryFactory.getAll(repositoryConnectionsNeeded);
ConnectionItem connectionItem = null;
for (IRepositoryViewObject object : objects) {
connectionItem = (ConnectionItem) object.getProperty().getItem();
if (type == ERepositoryObjectType.METADATA_CON_QUERY) {
QueriesConnection queries = connectionItem.getConnection().getQueries();
if (queries == null) {
continue;
}
for (Query query : (List<Query>) queries.getQuery()) {
if (query.getId().equals(id)) {
return connectionItem.getProperty().getId() + SEPARATOR + query.getLabel();
}
}
} else if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
for (MetadataTable table : (Set<MetadataTable>) ConnectionHelper.getTables(connectionItem.getConnection())) {
if (table.getId().equals(id)) {
return connectionItem.getProperty().getId() + SEPARATOR + table.getLabel();
}
}
}
}
} catch (PersistenceException e) {
return null;
}
return null;
}
Aggregations