use of orgomg.cwm.objectmodel.core.Package 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 orgomg.cwm.objectmodel.core.Package in project tdi-studio-se by Talend.
the class FileJSONTableWizardPage method createControl.
/**
* Create the first composite, addComponentsAndControls and initialize TableWizardPage.
*
* @see IDialogPage#createControl(Composite)
*/
public void createControl(final Composite parent) {
final AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {
public void checkPerformed(final AbstractForm source) {
if (source.isStatusOnError()) {
FileJSONTableWizardPage.this.setPageComplete(false);
setErrorMessage(source.getStatus());
} else {
FileJSONTableWizardPage.this.setPageComplete(isRepositoryObjectEditable);
setErrorMessage(null);
setMessage(source.getStatus(), source.getStatusLevel());
}
}
};
Composite theForm = null;
Connection connection = null;
if (metadataTable.getNamespace() != null) {
if (metadataTable.getNamespace() instanceof Package) {
Package pkg = (Package) metadataTable.getNamespace();
if (!pkg.getDataManager().isEmpty()) {
connection = (Connection) pkg.getDataManager().get(0);
}
}
}
theForm = (Composite) new JsonSwitch() {
public Object caseJSONFileConnection(final JSONFileConnection object) {
JSONFileConnection jsonFileConnection = (JSONFileConnection) connectionItem.getConnection();
boolean isInputModel = jsonFileConnection.isInputModel();
if (isInputModel) {
JSONFileStep3Form xmlFileStep3Form = new JSONFileStep3Form(parent, connectionItem, metadataTable, null, TableHelper.getTableNames(object, metadataTable.getLabel()));
xmlFileStep3Form.setReadOnly(!isRepositoryObjectEditable);
xmlFileStep3Form.setListener(listener);
return xmlFileStep3Form;
} else {
JSONFileOutputStep3Form xmlFileOutputStep3Form = new JSONFileOutputStep3Form(parent, connectionItem, metadataTable, TableHelper.getTableNames(object, metadataTable.getLabel()));
xmlFileOutputStep3Form.setReadOnly(!isRepositoryObjectEditable);
xmlFileOutputStep3Form.setListener(listener);
return xmlFileOutputStep3Form;
}
}
}.doSwitch(connection);
setControl(theForm);
}
Aggregations