Search in sources :

Example 1 with Relationship

use of org.talend.designer.neo4j.data.Relationship in project tbd-studio-se by Talend.

the class Neo4jManager method convert.

public void convert(Neo4jComponent externalNode, IMetadataTable outputMetaTable) {
    List<IMetadataColumn> exts = new ArrayList<IMetadataColumn>();
    for (IMetadataColumn column : outputMetaTable.getListColumns()) {
        if (column instanceof MetadataColumnExt) {
            exts.add(column.clone());
        } else if (column instanceof MetadataColumn) {
            MetadataColumnExt ext = new MetadataColumnExt((MetadataColumn) column);
            ext.setData(new Neo4jData());
            List<Map<String, Object>> mapValues = getNeo4jComponent().getOriginalValuesList();
            for (Map<String, Object> mapValue : mapValues) {
                if (ext.getLabel().equals(mapValue.get(Neo4jComponent.SCHEMA_COLUMN))) {
                    ext.getData().setAutoIndexed(Boolean.valueOf((String) mapValue.get(Neo4jComponent.AUTO_INDEXED)));
                }
            }
            mapValues = getNeo4jComponent().getOriginalIndexesList();
            for (Map<String, Object> mapValue : mapValues) {
                if (ext.getLabel().equals(mapValue.get(Neo4jComponent.SCHEMA_COLUMN))) {
                    Index index = new Index();
                    index.setName((String) mapValue.get(Neo4jComponent.INDEX_NAME));
                    index.setKey((String) mapValue.get(Neo4jComponent.KEY));
                    index.setUnique(Boolean.valueOf((String) mapValue.get(Neo4jComponent.UNIQUE)));
                    index.setValue((String) mapValue.get(Neo4jComponent.VALUE));
                    ext.getData().getIndexes().add(index);
                }
            }
            mapValues = getNeo4jComponent().getOriginalRelationshipsList();
            for (Map<String, Object> mapValue : mapValues) {
                if (ext.getLabel().equals(mapValue.get(Neo4jComponent.SCHEMA_COLUMN))) {
                    Relationship relationship = new Relationship();
                    Index index = new Index();
                    index.setName((String) mapValue.get(Neo4jComponent.INDEX_NAME));
                    index.setKey((String) mapValue.get(Neo4jComponent.KEY));
                    index.setValue((String) mapValue.get(Neo4jComponent.VALUE));
                    relationship.setIndex(index);
                    relationship.setType((String) mapValue.get(Neo4jComponent.TYPE));
                    relationship.setDirection(Direction.getFromName((String) mapValue.get(Neo4jComponent.DIRECTION)));
                    ext.getData().getRelationships().add(relationship);
                }
            }
            exts.add(ext);
        }
    }
    outputMetaTable.setListColumns(exts);
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) Relationship(org.talend.designer.neo4j.data.Relationship) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Index(org.talend.designer.neo4j.data.Index) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Map(java.util.Map) Neo4jData(org.talend.designer.neo4j.data.Neo4jData) MetadataColumnExt(org.talend.designer.neo4j.ui.editor.MetadataColumnExt)

Example 2 with Relationship

use of org.talend.designer.neo4j.data.Relationship in project tbd-studio-se by Talend.

the class Neo4jUI method updateTabs.

public void updateTabs(Table table) {
    if (table.getSelection().length < 1) {
        return;
    }
    TableItem item = table.getSelection()[0];
    if (item.getData() != null) {
        List<Index> indexes = ((MetadataColumnExt) item.getData()).getData().getIndexes();
        tabFolderEditors.getInputIndexEditor().getExtendedToolbar().getAddButton().getButton().setEnabled(true);
        if (indexes != null) {
            tabFolderEditors.getInputIndexEditor().update((MetadataColumnExt) item.getData());
        }
        List<Relationship> relationships = ((MetadataColumnExt) item.getData()).getData().getRelationships();
        tabFolderEditors.getInputRelationshipEditor().getExtendedToolbar().getAddButton().getButton().setEnabled(true);
        if (relationships != null) {
            tabFolderEditors.getInputRelationshipEditor().update((MetadataColumnExt) item.getData());
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Relationship(org.talend.designer.neo4j.data.Relationship) Index(org.talend.designer.neo4j.data.Index)

Example 3 with Relationship

use of org.talend.designer.neo4j.data.Relationship in project tbd-studio-se by Talend.

the class UIManager method getNewRelationShipsList.

private List<Map<String, Object>> getNewRelationShipsList() {
    List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
    MetadataTable table = (MetadataTable) neo4jManager.getNeo4jComponent().getMetadataList().get(0);
    neo4jManager.convert(neo4jManager.getNeo4jComponent(), table);
    for (IMetadataColumn col : table.getListColumns()) {
        MetadataColumnExt ext = (MetadataColumnExt) col;
        for (Relationship relationship : ext.getData().getRelationships()) {
            Map<String, Object> value = new HashMap<String, Object>();
            value.put(Neo4jComponent.SCHEMA_COLUMN, ext.getLabel());
            value.put(Neo4jComponent.TYPE, relationship.getType());
            value.put(Neo4jComponent.DIRECTION, relationship.getDirection().getName());
            value.put(Neo4jComponent.INDEX_NAME, relationship.getIndex().getName());
            value.put(Neo4jComponent.KEY, relationship.getIndex().getKey());
            value.put(Neo4jComponent.VALUE, relationship.getIndex().getValue());
            map.add(value);
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) Relationship(org.talend.designer.neo4j.data.Relationship) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) HashMap(java.util.HashMap) Map(java.util.Map) MetadataColumnExt(org.talend.designer.neo4j.ui.editor.MetadataColumnExt)

Example 4 with Relationship

use of org.talend.designer.neo4j.data.Relationship in project tbd-studio-se by Talend.

the class RelationshipTableView method createColumns.

// TODO: Create relationship direction column
@Override
protected void createColumns(TableViewerCreator<Relationship> tableViewerCreator, Table table) {
    TableViewerCreatorColumn<Relationship, String> column = new TableViewerCreatorColumn<Relationship, String>(tableViewerCreator);
    // TODO: Internationalize this
    column.setTitle("Type");
    column.setModifiable(true);
    column.setWidth(115);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Relationship, String>() {

        @Override
        public void set(Relationship bean, String value) {
            bean.setType(value);
        }

        @Override
        public String get(Relationship bean) {
            return bean.getType() == null ? "" : bean.getType();
        }
    });
    column.setCellEditor(new TextCellEditor(table));
    column = new TableViewerCreatorColumn<Relationship, String>(tableViewerCreator);
    // TODO: Internationalize this
    column.setTitle("Direction");
    column.setModifiable(true);
    column.setWidth(115);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Relationship, String>() {

        @Override
        public String get(Relationship bean) {
            return bean.getDirection() == null ? Relationship.Direction.OUTGOING.getName() : bean.getDirection().getName();
        }

        @Override
        public void set(Relationship bean, String value) {
            bean.setDirection(Relationship.Direction.getFromName(value));
        }
    });
    column.setCellEditor(createComboBoxCellEditor(table));
    column = new TableViewerCreatorColumn<Relationship, String>(tableViewerCreator);
    // TODO: Internationalize this
    column.setTitle("Index Name");
    column.setModifiable(true);
    column.setWidth(115);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Relationship, String>() {

        @Override
        public String get(Relationship bean) {
            return bean.getIndex().getName() == null ? "" : bean.getIndex().getName();
        }

        @Override
        public void set(Relationship bean, String value) {
            bean.getIndex().setName((value));
        }
    });
    column.setCellEditor(new TextCellEditor(table));
    column = new TableViewerCreatorColumn<Relationship, String>(tableViewerCreator);
    // TODO: Internationalize this
    column.setTitle("Index Key");
    column.setModifiable(true);
    column.setWidth(115);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Relationship, String>() {

        @Override
        public void set(Relationship bean, String value) {
            bean.getIndex().setKey(value);
        }

        @Override
        public String get(Relationship bean) {
            return bean.getIndex().getKey() == null ? "" : bean.getIndex().getKey();
        }
    });
    column.setCellEditor(new TextCellEditor(table));
    column = new TableViewerCreatorColumn<Relationship, String>(tableViewerCreator);
    // TODO: Internationalize this
    column.setTitle("Index Value (empty for current row)");
    column.setModifiable(true);
    column.setWidth(115);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Relationship, String>() {

        @Override
        public String get(Relationship bean) {
            return bean.getIndex().getValue() == null ? "" : bean.getIndex().getValue();
        }

        @Override
        public void set(Relationship bean, String value) {
            bean.getIndex().setValue(value);
        }
    });
    column.setCellEditor(new TextCellEditor(table));
}
Also used : Relationship(org.talend.designer.neo4j.data.Relationship) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Aggregations

Relationship (org.talend.designer.neo4j.data.Relationship)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 Index (org.talend.designer.neo4j.data.Index)2 MetadataColumnExt (org.talend.designer.neo4j.ui.editor.MetadataColumnExt)2 HashMap (java.util.HashMap)1 List (java.util.List)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 TableItem (org.eclipse.swt.widgets.TableItem)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)1 MetadataTable (org.talend.core.model.metadata.MetadataTable)1 Neo4jData (org.talend.designer.neo4j.data.Neo4jData)1