use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class HL7UI method initTableViewer.
private void initTableViewer() {
List<IMetadataTable> tables = externalNode.getMetadataList();
for (IMetadataTable table : tables) {
MetadataTable loaded = ConvertionHelper.convert(table);
List<MetadataColumn> columns = loaded.getColumns();
String trueTableName = table.getLabel();
if (trueTableName.split("_").length > 2) {
// get true table name from node draged from repository
//$NON-NLS-N$
trueTableName = trueTableName.split("_")[1];
}
if (hl7Manager.getSchemaRelationMap().get(trueTableName) != null) {
hl7Manager.getSchemaRelationMap().remove(trueTableName);
hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
} else {
hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
}
MetadataColumn[] array = new MetadataColumn[columns.size()];
int i = 0;
for (MetadataColumn column : columns) {
MetadataColumn newColumn = copyColumn(column);
array[i] = newColumn;
i++;
}
if (this.getMetaTableViewer().getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) this.getMetaTableViewer().getSelection();
if (selection.getFirstElement() != null) {
String name = ((IModel) selection.getFirstElement()).getDisplayName();
if (name.equals(trueTableName)) {
for (int j = 0; j < array.length; j++) {
hl7SchemaEditorView.getMetadataEditor().add(array[j]);
}
// hl7SchemaEditorView.getMetadataEditor().addAll(columns);
}
}
}
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class JSONRepositoryContentHandler method addNode.
@Override
public void addNode(ERepositoryObjectType type, RepositoryNode recBinNode, IRepositoryViewObject repositoryObject, RepositoryNode node) {
if (type == JSONRepositoryNodeType.JSON) {
JSONFileConnection connection = (JSONFileConnection) ((JSONFileConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
Set<MetadataTable> tableset = ConnectionHelper.getTables(connection);
for (MetadataTable metadataTable : tableset) {
if (!SubItemHelper.isDeleted(metadataTable)) {
RepositoryNode tableNode = RepositoryNodeManager.createMetatableNode(node, repositoryObject, metadataTable);
node.getChildren().add(tableNode);
if (metadataTable.getColumns().size() > 0) {
RepositoryNodeManager.createColumns(tableNode, repositoryObject, metadataTable);
}
}
}
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class GenericSchemaWizardPage method createControl.
@Override
public void createControl(final Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
container.setLayout(new GridLayout());
setControl(container);
List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(getConnection(), SubContainer.class);
List<String> existingTableLabels = new ArrayList<>();
for (MetadataTable metaTable : metadataTables) {
String label = metaTable.getLabel();
if (!label.equals(metadataTable.getLabel())) {
existingTableLabels.add(label);
}
}
String[] existingTableLabelsArray = existingTableLabels.toArray(new String[0]);
GenericSchemaForm schemaForm = new GenericSchemaForm(container, connectionItem, metadataTable, existingTableLabelsArray);
schemaForm.setLayoutData(new GridData(GridData.FILL_BOTH));
schemaForm.setReadOnly(!isRepositoryObjectEditable);
addCheckListener(schemaForm.getChecker());
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class GenericUpdateManager method getConversionMetadataTables.
public static List<IMetadataTable> getConversionMetadataTables(Connection conn) {
if (conn == null) {
return Collections.emptyList();
}
List<IMetadataTable> tables = new ArrayList<>();
List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(conn, SubContainer.class);
for (MetadataTable metadataTable : metadataTables) {
tables.add(ConvertionHelper.convert(metadataTable));
}
return tables;
}
use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.
the class SchemaUtils method createSchema.
public static MetadataTable createSchema(String name, ComponentProperties properties, String schemaPropertyName) {
if (name == null || properties == null || schemaPropertyName == null) {
return null;
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
metadataTable.setId(factory.getNextId());
metadataTable.setName(name);
metadataTable.setLabel(name);
metadataTable.setSourceName(name);
Object schemaObj = ComponentsUtils.getGenericPropertyValue(properties, schemaPropertyName);
if (schemaObj instanceof String) {
Schema avroSchema = new Schema.Parser().parse((String) schemaObj);
convertComponentSchemaIntoTalendSchema(avroSchema, metadataTable);
} else if (schemaObj instanceof Schema) {
convertComponentSchemaIntoTalendSchema((Schema) schemaObj, metadataTable);
}
IMetadataTable iMetadataTable = MetadataToolHelper.convert(metadataTable);
updateComponentSchema(properties, schemaPropertyName, iMetadataTable);
metadataTable = ConvertionHelper.convert(iMetadataTable);
properties.setValue(schemaPropertyName, convertTalendSchemaIntoComponentSchema(metadataTable));
TaggedValue serializedPropsTV = CoreFactory.eINSTANCE.createTaggedValue();
serializedPropsTV.setTag(IComponentConstants.COMPONENT_PROPERTIES_TAG);
serializedPropsTV.setValue(properties.toSerialized());
metadataTable.getTaggedValue().add(serializedPropsTV);
TaggedValue schemaPropertyTV = CoreFactory.eINSTANCE.createTaggedValue();
schemaPropertyTV.setTag(IComponentConstants.COMPONENT_SCHEMA_TAG);
schemaPropertyTV.setValue(schemaPropertyName);
metadataTable.getTaggedValue().add(schemaPropertyTV);
return metadataTable;
}
Aggregations