use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class SalesforceMultiSchemaMigrationTask 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 SalesforceSchemaConnectionItem) {
boolean modify = false;
SalesforceSchemaConnectionItem salesforceItem = (SalesforceSchemaConnectionItem) item;
if (salesforceItem.getConnection() instanceof SalesforceSchemaConnection) {
SalesforceSchemaConnection sfConnection = (SalesforceSchemaConnection) salesforceItem.getConnection();
SalesforceModuleUnit module = ConnectionFactory.eINSTANCE.createSalesforceModuleUnit();
module.setId(ProxyRepositoryFactory.getInstance().getNextId());
String moduleName = sfConnection.getModuleName();
if (moduleName == null || "".equals(moduleName)) {
moduleName = "Default";
}
module.setLabel(moduleName);
module.setModuleName(moduleName);
EList<orgomg.cwm.objectmodel.core.Package> originalPackages = sfConnection.getDataPackage();
for (int i = 0; i < originalPackages.size(); i++) {
MetadataTable table = (MetadataTable) originalPackages.get(i).getOwnedElement().get(0);
if (originalPackages.get(i) instanceof RecordFile) {
table.setLabel(moduleName);
}
module.getTables().add(table);
}
sfConnection.getModules().add(module);
modify = true;
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception 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 SchemaUtilsTest method createMetadataTable.
private MetadataTable createMetadataTable(String name) {
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
table.setName(name);
table.setLabel(table.getName());
return table;
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class SchemaUtilsTest method testGetMetadataTables.
@Test
public void testGetMetadataTables() {
// Create some MetadataTables for test.
//$NON-NLS-1$
MetadataTable table1 = createMetadataTable("table1");
//$NON-NLS-1$
MetadataTable table2 = createMetadataTable("table2");
//$NON-NLS-1$
MetadataTable table3 = createMetadataTable("table3");
//$NON-NLS-1$
MetadataTable table4 = createMetadataTable("table4");
// ///////////////////////////////////
// Overall structure:
//
// . parentPackage
// .. table1
// .. container1
// ... table2
// ... container1_1
// .... table4
// .. container2
// ... table3
//
// ///////////////////////////////////
Package parentPackage = CoreFactory.eINSTANCE.createPackage();
parentPackage.getOwnedElement().add(table1);
Package container1 = new TestContainer();
container1.getOwnedElement().add(table2);
Package container1_1 = new TestContainer();
container1_1.getOwnedElement().add(table4);
container1.getOwnedElement().add(container1_1);
parentPackage.getOwnedElement().add(container1);
Package container2 = new OtherTestContainer();
container2.getOwnedElement().add(table3);
parentPackage.getOwnedElement().add(container2);
// When there is not any sub-container specified, will return all direct MetadataTables of the parent package.
List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(parentPackage, null);
assertNotNull(getTheTable(metadataTables, table1.getName()));
// When there is one sub-container specified, will return all direct MetadataTables of the parent package and
// sub-container recursively.
metadataTables = SchemaUtils.getMetadataTables(parentPackage, TestContainer.class);
assertNotNull(getTheTable(metadataTables, table1.getName()));
assertNotNull(getTheTable(metadataTables, table2.getName()));
assertNotNull(getTheTable(metadataTables, table4.getName()));
assertNull(getTheTable(metadataTables, table3.getName()));
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class AddTablesComposite method createTableList.
/**
* DOC admin Comment method "createTableList".
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private Composite createTableList() {
Composite div1 = new Composite(tabFolder, SWT.NONE);
div1.setLayout(new GridLayout());
GridData lgid = new GridData();
lgid.grabExcessHorizontalSpace = true;
lgid.horizontalAlignment = GridData.FILL_BOTH;
lgid.heightHint = 1;
lgid.verticalIndent = 1;
div1.setLayoutData(lgid);
div1.setBackground(ColorConstants.white);
listTables = new org.eclipse.swt.widgets.List(div1, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
listTables.setLayoutData(new GridData(GridData.FILL_BOTH));
DatabaseConnectionItem item = SQLBuilderRepositoryNodeManager.getItem(getRootNode());
tables = ConnectionHelper.getTables((DatabaseConnection) item.getConnection());
for (MetadataTable table : tables) {
if (table.getSourceName() != null) {
listTables.add(table.getSourceName());
}
}
return div1;
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class AddTablesDialog method setRootNode.
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void setRootNode(RepositoryNode rootNode) {
this.rootNode = rootNode;
DatabaseConnectionItem item = SQLBuilderRepositoryNodeManager.getItem(getRootNode());
tables = new HashSet<MetadataTable>();
tables.addAll(ConnectionHelper.getTables((DatabaseConnection) item.getConnection()));
}
Aggregations