void checkReadOnlyColumn(Column column) { if (column.isReadOnly()) { throw new RuntimeException("Can't modify the read-only '" + column.getId() + "' column"); } }
void checkReadOnlyColumn(Column column) { if (column.isReadOnly()) { throw new RuntimeException("Can't modify the read-only '" + column.getId() + "' column"); } }
protected String getId(Transformer transformer, Column column) { return getIdPrefix() + "_" + transformer.getClass().getSimpleName() + "_column_" + column.getId(); }
protected String getIdCol(Column column) { return (AttributeUtils.isNodeColumn(column) ? "node" : "edge") + "_column_" + column.getId(); }
@Override public boolean canClearColumnData(Column column) { if (isEdgeColumn(column) && column.getId().equalsIgnoreCase("weight")) { return false;//Should not remove weight value but grapshtore currently allows it } return !column.isReadOnly(); }
private boolean canChangeTimeRepresentation(GraphModel graphModel) { if (graphModel.getGraph().getNodeCount() > 0) { return false;//Graph has to be empty } //Also there cannot be any column apart from the basic ones: for (Column column : graphModel.getNodeTable()) { String id = column.getId(); if (!id.equalsIgnoreCase("Id") && !id.equalsIgnoreCase("Label") && !id.equalsIgnoreCase("timeset")) { return false; } } for (Column column : graphModel.getEdgeTable()) { String id = column.getId(); if (!id.equalsIgnoreCase("Id") && !id.equalsIgnoreCase("Label") && !id.equalsIgnoreCase("timeset") && !id.equalsIgnoreCase("Weight")) { return false; } } return true; }
private void refreshColumns() { if (graphModel == null) { return; } columnsPanel.removeAll(); columnsPanel.setLayout(new MigLayout("", "[pref!]")); ArrayList<ColumnCheckboxWrapper> columnCheckboxesList = new ArrayList<>(); //Show rest of columns: Table table = getSelectedTable() == ExporterSpreadsheet.ExportTable.NODES ? graphModel.getNodeTable() : graphModel.getEdgeTable(); for (Column column : table) { columnCheckboxesList.add(new ColumnCheckboxWrapper(column.getId(), column.getTitle())); } columnsCheckBoxes = columnCheckboxesList.toArray(new ColumnCheckboxWrapper[0]); for (ColumnCheckboxWrapper columnCheckboxWrapper : columnsCheckBoxes) { columnsPanel.add(columnCheckboxWrapper, "wrap"); } columnsPanel.revalidate(); columnsPanel.repaint(); }
for (Column sourceCol : sourceStore.nodeTable) { if (!sourceCol.isProperty()) { Column destColumn = destNodeTable.getColumn(sourceCol.getId()); if (destColumn != null && !destColumn.getTypeClass().equals(sourceCol.getTypeClass())) { throw new RuntimeException( "A node column '" + destColumn.getId() + "' already exists with a different type"); for (Column sourceCol : sourceStore.edgeTable) { if (!sourceCol.isProperty()) { Column destColumn = destEdgeTable.getColumn(sourceCol.getId()); if (destColumn != null && !destColumn.getTypeClass().equals(sourceCol.getTypeClass())) { throw new RuntimeException( "An edge column '" + destColumn.getId() + "' already exists with a different type");
for (Column sourceCol : sourceStore.nodeTable) { if (!sourceCol.isProperty()) { Column destColumn = destNodeTable.getColumn(sourceCol.getId()); if (destColumn != null && !destColumn.getTypeClass().equals(sourceCol.getTypeClass())) { throw new RuntimeException( "A node column '" + destColumn.getId() + "' already exists with a different type"); for (Column sourceCol : sourceStore.edgeTable) { if (!sourceCol.isProperty()) { Column destColumn = destEdgeTable.getColumn(sourceCol.getId()); if (destColumn != null && !destColumn.getTypeClass().equals(sourceCol.getTypeClass())) { throw new RuntimeException( "An edge column '" + destColumn.getId() + "' already exists with a different type");
private void updateConfiguration(Column changedColumn) { String columnId = changedColumn.getId(); if (Edge.class.equals(elementType)) { if (columnId.equals(GraphStoreConfiguration.EDGE_WEIGHT_COLUMN_ID)) { if (hasColumn(columnId)) { Class edgeWeightColumnClass = getColumn(columnId).getTypeClass(); configuration.setEdgeWeightType(edgeWeightColumnClass); configuration.setEdgeWeightColumn(true); } else { configuration.setEdgeWeightColumn(false); } } else if (columnId.equals(GraphStoreConfiguration.ELEMENT_ID_COLUMN_ID)) { configuration.setEdgeIdType(changedColumn.getTypeClass()); } } else if (Node.class.equals(elementType)) { if (columnId.equals(GraphStoreConfiguration.ELEMENT_ID_COLUMN_ID)) { configuration.setNodeIdType(changedColumn.getTypeClass()); } } }
private void copyColumns(TableImpl sourceTable, TableImpl destTable) { for (Column col : sourceTable.toArray()) { if (!col.isProperty() && !destTable.hasColumn(col.getId())) { destTable.addColumn(col.getId(), col.getTitle(), col.getTypeClass(), col.getOrigin(), col .getDefaultValue(), col.isIndexed()); } } }
private void copyColumns(TableImpl sourceTable, TableImpl destTable) { for (Column col : sourceTable.toArray()) { if (!col.isProperty() && !destTable.hasColumn(col.getId())) { destTable.addColumn(col.getId(), col.getTitle(), col.getTypeClass(), col.getOrigin(), col .getDefaultValue(), col.isIndexed()); } } }
private void updateConfiguration(Column changedColumn) { String columnId = changedColumn.getId(); if (Edge.class.equals(elementType)) { if (columnId.equals(GraphStoreConfiguration.EDGE_WEIGHT_COLUMN_ID)) { if (hasColumn(columnId)) { Class edgeWeightColumnClass = getColumn(columnId).getTypeClass(); configuration.setEdgeWeightType(edgeWeightColumnClass); configuration.setEdgeWeightColumn(true); } else { configuration.setEdgeWeightColumn(false); } } else if (columnId.equals(GraphStoreConfiguration.ELEMENT_ID_COLUMN_ID)) { configuration.setEdgeIdType(changedColumn.getTypeClass()); } } else if (Node.class.equals(elementType)) { if (columnId.equals(GraphStoreConfiguration.ELEMENT_ID_COLUMN_ID)) { configuration.setNodeIdType(changedColumn.getTypeClass()); } } }
@Override public void execute(Table table, Column column) { Class dynamicType = AttributeUtils.getIntervalMapType(column.getTypeClass()); AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class); Element[] rows = ac.getTableAttributeRows(table); Object[] values = new Object[rows.length]; Interval interval = new Interval(Double.parseDouble(start), Double.parseDouble(end)); for (int i = 0; i < values.length; i++) { try { IntervalMap val = (IntervalMap) dynamicType.newInstance(); val.put(interval, rows[i].getAttribute(column)); } catch (Exception e) { } } table.removeColumn(column); Column dynamicColumn = table.addColumn(column.getId(), column.getTitle(), dynamicType, null); for (int i = 0; i < values.length; i++) { rows[i].setAttribute(dynamicColumn, values[i]); } }
p.setName(column.getId()); set.put(p);
private void copyAttributes(TableImpl sourceTable, TableImpl destTable, Element element, Element elementCopy) { TimeRepresentation tr = sourceTable.store.configuration.getTimeRepresentation(); for (Column col : sourceTable.toArray()) { if (!col.isProperty()) { Column colCopy = destTable.getColumn(col.getId()); if (col.isDynamic() && tr.equals(TimeRepresentation.TIMESTAMP)) { for (Map.Entry<Double, Object> entry : element.getAttributes(col)) { Double key = entry.getKey(); Object value = entry.getValue(); elementCopy.setAttribute(colCopy, value, key); } } else if (col.isDynamic() && tr.equals(TimeRepresentation.INTERVAL)) { for (Map.Entry<Interval, Object> entry : element.getAttributes(col)) { Interval key = entry.getKey(); Object value = entry.getValue(); elementCopy.setAttribute(colCopy, value, key); } } else { Object attribute = element.getAttribute(col); elementCopy.setAttribute(colCopy, attribute); } } } }
private void copyAttributes(TableImpl sourceTable, TableImpl destTable, Element element, Element elementCopy) { TimeRepresentation tr = sourceTable.store.configuration.getTimeRepresentation(); for (Column col : sourceTable.toArray()) { if (!col.isProperty()) { Column colCopy = destTable.getColumn(col.getId()); if (col.isDynamic() && tr.equals(TimeRepresentation.TIMESTAMP)) { for (Map.Entry<Double, Object> entry : element.getAttributes(col)) { Double key = entry.getKey(); Object value = entry.getValue(); elementCopy.setAttribute(colCopy, value, key); } } else if (col.isDynamic() && tr.equals(TimeRepresentation.INTERVAL)) { for (Map.Entry<Interval, Object> entry : element.getAttributes(col)) { Interval key = entry.getKey(); Object value = entry.getValue(); elementCopy.setAttribute(colCopy, value, key); } } else { Object attribute = element.getAttribute(col); elementCopy.setAttribute(colCopy, attribute); } } } }
idMap.put(column.getId(), id); int intIndex = shortToInt(id); columnImpl.setStoreId(intIndex);
idMap.put(column.getId(), id); int intIndex = shortToInt(id); columnImpl.setStoreId(intIndex);
short id = idMap.removeShort(column.getId()); if (id == NULL_SHORT) { throw new IllegalArgumentException("The column doesnt exist");