use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class WSDLSchemaDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new FillLayout());
tableEditor = new MetadataEmfTableEditor("");
tableEditor.setMetadataTable(metadataTable);
// (List<MetadataColumn>)
List<MetadataColumn> list = metadataTable.getColumns();
// form.getSchemaViewer().getInput();
tableEditor.addAll(list);
tableEditorView = new MetadataEmfTableEditorView(composite, SWT.NONE);
tableEditorView.setMetadataEditor(tableEditor);
return composite;
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class SchemaUtils method convertComponentSchemaIntoTalendSchema.
private static void convertComponentSchemaIntoTalendSchema(Schema schema, MetadataTable metadataTable) {
if (schema == null || metadataTable == null) {
return;
}
for (Schema.Field field : schema.getFields()) {
MetadataColumn metadataColumn = MetadataToolAvroHelper.convertFromAvro(field);
metadataTable.getColumns().add(metadataColumn);
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method initXmlTreeData.
private void initXmlTreeData(List<String> schemaList, List<HL7FileNode> root, List<HL7TreeNode> treeData) {
Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>();
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear();
incomingConnections = NodeUtil.getIncomingConnections(hl7ui.gethl7Manager().getHl7Component(), IConnectionCategory.FLOW);
}
}
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<MetadataTable> iMetadataTables = new ArrayList<MetadataTable>();
HL7TreeNode rootNode = null;
Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
Map<String, MetadataTable> schemaNameToOutputTable = new HashMap<String, MetadataTable>();
for (String schemaName : schemaList) {
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(schemaName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
break;
}
}
MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
targetMetadataTable.setId(factory.getNextId());
schemaNameToOutputTable.put(schemaName, targetMetadataTable);
targetMetadataTable.setLabel(schemaName);
iMetadataTables.add(targetMetadataTable);
}
HL7TreeNode current = null;
HL7TreeNode temp = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (int i = 0; i < root.size(); i++) {
HL7FileNode node = root.get(i);
String newPath = node.getFilePath();
defaultValue = node.getDefaultValue();
String columnName = node.getRelatedColumn();
// String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = node.getOrder();
}
String rowName = columnName;
if (columnName != null && columnName.contains(":")) {
String[] names = columnName.split(":");
rowName = names[0];
columnName = names[1];
} else {
columnName = null;
}
temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
if (temp == null) {
// should not happen
continue;
}
// temp.setDataType(type);
if (rootNode == null) {
rootNode = temp;
}
if (node.getAttribute().equals("main")) {
temp.setMain(true);
}
current = temp;
currentPath = newPath;
if (haveOrder) {
temp.setOrder(nodeOrder);
}
if (rowName != null && rowName.length() > 0) {
temp.setRow(rowName);
}
if (columnName != null) {
IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
// group node can not get the metadata table
if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
for (IConnection connection : incomingConnections) {
metadataTableTemp = connection.getMetadataTable();
String connectionName = metadataTableTemp.getLabel();
if (connectionName == null) {
connectionName = connection.getUniqueName();
}
if (columnName.startsWith(connectionName)) {
break;
}
}
temp.setColumnName(columnName);
if (metadataTableTemp != null) {
temp.setColumn(metadataTableTemp.getColumn(columnName));
temp.setTable(metadataTableTemp);
}
} else {
temp.setColumnName(columnName);
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
//
if (!temp.isMain()) {
MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
newColumn.setLabel(columnName);
newColumn.setName(temp.getLabel());
newColumn.setLength(226);
newColumn.setTalendType("id_String");
schemaNameToOutputTable.get(rowName).getColumns().add(newColumn);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
if (haveOrder) {
orderNode(rootNode);
}
if (rootNode != null) {
treeData.add(rootNode);
}
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(rootNode.getColumnLabel(), treeData);
}
} else if (form != null) {
for (HL7TreeNode hl7Node : treeData) {
form.getContents().put(rootNode.getColumnLabel(), hl7Node);
}
}
if (hl7ui != null) {
// execute the commands,initialize the propertiesView .
List<Command> commands = new ArrayList<Command>();
for (MetadataTable tableTemp : iMetadataTables) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(hl7ui.gethl7Manager().getHl7Component(), IHL7Constant.TABLE_SCHEMAS, tableTemp.getLabel(), ConvertionHelper.convert(tableTemp));
commands.add(hl7Cmd);
}
for (Command command : commands) {
command.execute();
}
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class HL7Manager method convertMetadataColumns2Propertis.
public List<Map<String, String>> convertMetadataColumns2Propertis() {
List<Map<String, String>> schemas = new ArrayList<Map<String, String>>();
Iterator<String> it = schemaRelationMap.keySet().iterator();
while (it.hasNext()) {
MetadataTable metatable = ConnectionFactory.eINSTANCE.createMetadataTable();
String schemaKey = it.next().toString();
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
columns.addAll(schemaRelationMap.get(schemaKey));
Map<String, String> oneSchema = new HashMap<String, String>();
//$NON-NLS-N$
String displayName = "";
for (int i = 0; i < columns.size(); i++) {
MetadataColumn column = columns.get(i);
String original = columns.get(i).getOriginalField();
if (original != null && !"".equals(original)) {
if (original.indexOf(TalendTextUtils.LBRACKET) > 0) {
original = original.substring(0, original.indexOf(TalendTextUtils.LBRACKET));
}
}
if (i != columns.size() - 1) {
displayName = displayName + TalendTextUtils.QUOTATION_MARK + original + TalendTextUtils.QUOTATION_MARK + ",";
} else {
displayName = displayName + TalendTextUtils.QUOTATION_MARK + original + TalendTextUtils.QUOTATION_MARK;
}
if (column.getSourceType() == null) {
column.setSourceType("id_String");
}
if (column.getTalendType() == null) {
column.setTalendType("id_String");
}
// column.setLabel(column.getOriginalField()); // display user defined column name
metatable.getColumns().add(column);
}
metatable.setLabel(schemaKey);
schemaKey = mapSchemaKeyFromNode(schemaKey);
IMetadataTable table = ConvertionHelper.convert(metatable);
table.setTableName(schemaKey);
if (displayName != null && !"".equals(displayName)) {
//$NON-NLS-N$
oneSchema.put("SCHEMA", schemaKey);
//$NON-NLS-N$
oneSchema.put("MAPPING", displayName);
schemas.add(oneSchema);
}
if (table != null && !table.getListColumns().isEmpty()) {
//
boolean find = false;
int index = 0;
for (int i = 0; i < hl7Component.getMetadataList().size(); i++) {
if (table.getLabel().equals(hl7Component.getMetadataList().get(i).getLabel())) {
find = true;
index = i;
break;
}
}
if (find) {
hl7Component.getMetadataList().remove(index);
} else {
schemaKey = hl7Component.getProcess().generateUniqueConnectionName(MultiSchemasUtil.getConnectionBaseName(schemaKey));
table.setTableName(schemaKey);
}
hl7Component.getMetadataList().add(table);
} else if (table != null && table.getListColumns().isEmpty()) {
boolean find = false;
int index = 0;
for (int i = 0; i < hl7Component.getMetadataList().size(); i++) {
if (table.getLabel().equals(hl7Component.getMetadataList().get(i).getLabel())) {
find = true;
index = i;
break;
}
}
if (find) {
hl7Component.getMetadataList().remove(index);
hl7Component.getMetadataList().add(table);
}
}
}
return schemas;
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class HL7MultiSchemaUI method buildCurrentTable.
private MetadataTable buildCurrentTable(MetadataColumn[] beans, String schemaKey) {
MetadataTable metatable = ConnectionFactory.eINSTANCE.createMetadataTable();
//$NON-NLS-N$
String displayName = "";
for (int i = 0; i < beans.length; i++) {
MetadataColumn column = beans[i];
String original = beans[i].getOriginalField();
if (original != null && !"".equals(original)) {
if (original.indexOf(TalendTextUtils.LBRACKET) > 0) {
original = original.substring(0, original.indexOf(TalendTextUtils.LBRACKET));
}
}
if (i != beans.length - 1) {
displayName = displayName + TalendTextUtils.QUOTATION_MARK + original + TalendTextUtils.QUOTATION_MARK + ",";
} else {
displayName = displayName + TalendTextUtils.QUOTATION_MARK + original + TalendTextUtils.QUOTATION_MARK;
}
if (column.getSourceType() == null) {
column.setSourceType("id_String");
}
if (column.getTalendType() == null) {
column.setTalendType("id_String");
}
// column.setLabel(column.getOriginalField()); // display user defined column name
metatable.getColumns().add(column);
}
metatable.setLabel(schemaKey);
return metatable;
}
Aggregations