@Override public boolean evaluate(Graph graph, Element element) { return element.getAttribute(column) != null; }
/** * Used to negate the values of a single boolean column. */ private void negateColumnBooleanType(Table table, Column column) { Object value; Boolean newValue; for (Element row : getTableAttributeRows(table)) { value = row.getAttribute(column); if (value != null) { newValue = !((Boolean) value); row.setAttribute(column, newValue); } } }
private S getTimeSet(Element element) { Object[] attributes = element.getAttributes(); if (GraphStoreConfiguration.ENABLE_ELEMENT_TIME_SET && GraphStoreConfiguration.ELEMENT_TIMESET_INDEX < attributes.length) { return (S) attributes[GraphStoreConfiguration.ELEMENT_TIMESET_INDEX]; } return null; }
@Override public void setValueByte(Byte object) { row.setAttribute(column, object); }
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); } } } }
@Override public void copyColumnDataToOtherColumn(Table table, Column sourceColumn, Column targetColumn) { if (sourceColumn == targetColumn) { throw new IllegalArgumentException("Source and target columns can't be equal"); } Class targetType = targetColumn.getTypeClass(); Object value; if (!targetType.equals(sourceColumn.getTypeClass())) { for (Element row : getTableAttributeRows(table)) { value = row.getAttribute(sourceColumn); setAttributeValue(value, row, targetColumn); } } else { for (Element row : getTableAttributeRows(table)) { value = row.getAttribute(sourceColumn); if (value == null) { row.removeAttribute(targetColumn); } else { row.setAttribute(targetColumn, value); } } } }
@Override public void copyRowDataToOtherRows(Element row, Element[] otherRows, Column[] columnsToCopy) { if (columnsToCopy != null) { for (Column column : columnsToCopy) { //Copy all except id and computed attributes: if (canChangeColumnData(column)) { for (Element otherRow : otherRows) { Object value = row.getAttribute(column); setAttributeValue(value, otherRow, column); } } } } else { Table table; if (row instanceof Node) { table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable(); } else { table = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getNodeTable(); } for (Column column : table) { if (canChangeColumnData(column)) { for (Element otherRow : otherRows) { otherRow.removeAttribute(column); } } } } }
try { if (value == null) { row.removeAttribute(column); } else { row.setAttribute(column, value);
private String buildText(Graph graph, Element element, Column[] selectedColumns) { String txt; if (selectedColumns == null || selectedColumns.length == 0) { txt = element.getLabel(); } else if (selectedColumns.length == 1) { return buildText(graph, element, selectedColumns[0]); } else { StringBuilder sb = new StringBuilder(); int i = 0; for (Column c : selectedColumns) { if (i++ > 0) { sb.append(" - "); } sb.append(buildText(graph, element, c)); } txt = sb.toString(); } return (txt != null && !txt.isEmpty()) ? txt : null; }
@Override public void transform(Element element, Graph graph) { if (isSimple()) { ((SimpleTransformer) transformer).transform(element); } else if (isRanking()) { Number val = ranking.getValue(element, graph); if (val == null) { Logger.getLogger("").log(Level.WARNING, "The element with id ''{0}'' has a null value for ranking. Using 0 instead", element.getId()); val = 0; } ((RankingTransformer) transformer).transform(element, ranking, interpolator, val); } else if (isPartition()) { Object val = partition.getValue(element, graph); ((PartitionTransformer) transformer).transform(element, partition, val); } }
@Override public void setValueDouble(Double object) { row.setAttribute(column, object); }
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); } } } }
@Override public String getValueString() { return (String) row.getAttribute(column); }
/** * Used to negate all values of a list of boolean values column. */ private void negateColumnListBooleanType(Table table, Column column) { Object value; Boolean[] newValues; for (Element row : getTableAttributeRows(table)) { value = row.getAttribute(column); if (value != null) { Boolean[] list = (Boolean[]) value; newValues = new Boolean[list.length]; for (int i = 0; i < list.length; i++) { newValues[i] = !list[i]; } row.setAttribute(column, newValues); } } }
@Override public void setValueLong(Long object) { row.setAttribute(column, object); }
private S getTimeSet(Element element) { Object[] attributes = element.getAttributes(); if (GraphStoreConfiguration.ENABLE_ELEMENT_TIME_SET && GraphStoreConfiguration.ELEMENT_TIMESET_INDEX < attributes.length) { return (S) attributes[GraphStoreConfiguration.ELEMENT_TIMESET_INDEX]; } return null; }
@Override public Object getValueFor(T element) { return element.getAttribute(column); }
value = (Boolean) row.getAttribute(columnsToMerge[0]); value = value != null ? value : false;//Use false if null for (int i = 0; i < booleanOperations.length; i++) { secondValue = (Boolean) row.getAttribute(columnsToMerge[i + 1]); secondValue = secondValue != null ? secondValue : false;//Use false if null switch (booleanOperations[i]) { row.setAttribute(newColumn, value);
private void setValueToAllElements(Object object) { this.value = object; for (Element row : rows) { row.setAttribute(column, value); } }
public void index(Element element) { S timeSet = getTimeSet(element); if (timeSet != null) { add(timeSet); } for (Object val : element.getAttributes()) { if (val != null && val instanceof TimeMap) { TimeMap dynamicValue = (TimeMap) val; add(dynamicValue); } } if (timeSet != null && mainIndex != null) { K[] ts = timeSet.toArray(); int tsLength = ts.length; for (int i = 0; i < tsLength; i++) { int timestampIndex = timeSortedMap.get(ts[i]); mainIndex.add(timestampIndex, element); } } }