use of org.talend.core.model.metadata.builder.connection.MetadataColumn 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.MetadataColumn in project tdi-studio-se by Talend.
the class HL7UI method copyColumn.
protected MetadataColumn copyColumn(MetadataColumn column) {
MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
newColumn.setComment(column.getComment());
newColumn.setDefaultValue(column.getDefaultValue());
newColumn.setKey(column.isKey());
newColumn.setLabel(column.getLabel());
newColumn.setPattern(column.getPattern());
if (column.getLength() < 0) {
newColumn.setLength(0);
} else {
newColumn.setLength(column.getLength());
}
newColumn.setNullable(column.isNullable());
if (column.getPrecision() < 0) {
newColumn.setPrecision(0);
} else {
newColumn.setPrecision(column.getPrecision());
}
newColumn.setTalendType(column.getTalendType());
newColumn.setSourceType(column.getSourceType());
if (column.getOriginalField() == null || column.getOriginalField().equals("")) {
//$NON-NLS-1$
newColumn.setLabel(column.getLabel());
} else {
newColumn.setOriginalField(column.getOriginalField());
}
return newColumn;
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class HL7MetadataEmfTableEditorView method getDbColumnNameAccessor.
@Override
protected IBeanPropertyAccessors<MetadataColumn, String> getDbColumnNameAccessor() {
return new IBeanPropertyAccessors<MetadataColumn, String>() {
public String get(MetadataColumn bean) {
return bean.getOriginalField();
}
public void set(MetadataColumn bean, String value) {
bean.setOriginalField(value);
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
linker.getManager().updateRelationMapping(key, bean, false);
// if (columns.indexOf(bean) > 0) {
// columns.get(columns.indexOf(bean)).setOriginalField(value);
// }
}
}
};
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class ErDiagramComposite method createErDiagram.
/**
* admin Comment method "createErDiagram".
*
* @return
*/
private ErDiagram createErDiagram(boolean isShowDesignerPage) {
erDiagram = new ErDiagram();
erDiagram.setErDiagramComposite(this);
if (isShowDesignerPage) {
IRunnableWithProgress progress = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask("", IProgressMonitor.UNKNOWN);
try {
List<MetadataColumn> selectedColumns = new ArrayList<MetadataColumn>();
List<MetadataTable> tables = EMFRepositoryNodeManager.getInstance().getTables(getNodes(), selectedColumns);
erDiagram.setMetadataTables(tables);
List<String[]> fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(tables, erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
for (MetadataTable metadataTable : tables) {
Table table = new Table();
table.setMetadataTable(metadataTable, selectedColumns);
table.setErDiagram(erDiagram);
erDiagram.addTable(table);
}
erDiagram.setRelations(fks);
} finally {
monitor.done();
}
}
};
UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
} else {
erDiagram.setMetadataTables(new ArrayList<MetadataTable>());
erDiagram.setRelations(new ArrayList<String[]>());
}
return erDiagram;
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class MetadataColumnComparator method modifyOldOneTableFromDB.
/**
* dev Comment method "modifyOldOneTableFromDB".
*
* @param metaFromDB
* @param connectionLabel
* @param emf
*/
@SuppressWarnings("unchecked")
private boolean modifyOldOneTableFromDB(List<MetadataTable> metaFromDB, MetadataTable emf) {
boolean flag = true;
for (MetadataTable db : metaFromDB) {
if (db.getSourceName().equals(emf.getSourceName())) {
flag = false;
if (!emf.getLabel().equals("") && !emf.getLabel().equals(db.getSourceName())) {
//$NON-NLS-1$
emf.setDivergency(true);
}
}
}
if (flag) {
List<MetadataColumn> columns = emf.getColumns();
for (MetadataColumn column : columns) {
//$NON-NLS-1$
column.setOriginalField(" ");
column.setDivergency(true);
column.setSynchronised(false);
}
//$NON-NLS-1$
emf.setSourceName(" ");
emf.setDivergency(true);
emf.setSynchronised(false);
}
return flag;
}
Aggregations