Search in sources :

Example 1 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class AbstractInclusionGraph method createInclusionGraph.

private void createInclusionGraph() {
    final int vxCount = wg.getVertexCount();
    // Loop through all vertexes and count the number that have been
    // explictly selected by user and those that have been marked as pinned.
    // Vertexes marked as pinned will not be 'arranged'.
    int incCount = 0;
    int pinnedCount = 0;
    for (int position = 0; position < vxCount; position++) {
        final int vxId = wg.getVertex(position);
        if (isVertexIncluded(vxId)) {
            incCount++;
        }
        if (!wg.getBooleanValue(pinnedAttr, vxId)) {
            pinnedCount++;
        }
    }
    // If every vertex is a candidate to be moved we can just return the
    // current graph.
    inclusionGraphIsOriginalGraph = (incCount == vxCount || incCount == 0) && (pinnedCount == 0);
    if (inclusionGraphIsOriginalGraph) {
        // All vertices are (implicitly or explicitly) selected.
        // Pass the graph straight through.
        inclusionGraph = wg;
        return;
    }
    // Store the IDs of attributes that will be read from wg.
    final int xAttr = VisualConcept.VertexAttribute.X.get(wg);
    final int yAttr = VisualConcept.VertexAttribute.Y.get(wg);
    final int zAttr = VisualConcept.VertexAttribute.Z.get(wg);
    final int x2Attr = VisualConcept.VertexAttribute.X2.get(wg);
    final int y2Attr = VisualConcept.VertexAttribute.Y2.get(wg);
    final int z2Attr = VisualConcept.VertexAttribute.Z2.get(wg);
    final int nradiusAttr = VisualConcept.VertexAttribute.NODE_RADIUS.get(wg);
    final int lradiusAttr = VisualConcept.VertexAttribute.LABEL_RADIUS.get(wg);
    // Are the x2, y2, z2 attributes set
    final boolean xyz2AreSet = x2Attr != Graph.NOT_FOUND && y2Attr != Graph.NOT_FOUND && z2Attr != Graph.NOT_FOUND;
    // Create the inclusion graph.
    // We need to create some essential attributes, plus whatever other
    // attributes we've been told to create via calls to addAttributeToCopy().
    final StoreGraph storeGraph = new StoreGraph(wg.getSchema());
    VisualConcept.VertexAttribute.X.ensure(storeGraph);
    VisualConcept.VertexAttribute.Y.ensure(storeGraph);
    VisualConcept.VertexAttribute.Z.ensure(storeGraph);
    if (xyz2AreSet) {
        VisualConcept.VertexAttribute.X2.ensure(storeGraph);
        VisualConcept.VertexAttribute.Y2.ensure(storeGraph);
        VisualConcept.VertexAttribute.Z2.ensure(storeGraph);
    }
    if (nradiusAttr != Graph.NOT_FOUND) {
        VisualConcept.VertexAttribute.NODE_RADIUS.ensure(storeGraph);
    }
    if (lradiusAttr != Graph.NOT_FOUND) {
        VisualConcept.VertexAttribute.LABEL_RADIUS.ensure(storeGraph);
    }
    // Process any attributes specified by calls to addAttributeToCopy().
    final int[] selectionAttributes = new int[attributesToCopy.size()];
    for (int i = 0; i < attributesToCopy.size(); i++) {
        final Attribute attr = attributesToCopy.get(i);
        selectionAttributes[i] = storeGraph.addAttribute(attr.getElementType(), attr.getAttributeType(), attr.getName(), attr.getDescription(), attr.getDefaultValue(), null);
    }
    // Store the IDs of attributes that will be written to storeGraph.
    final int incXAttr = VisualConcept.VertexAttribute.X.get(storeGraph);
    final int incYAttr = VisualConcept.VertexAttribute.Y.get(storeGraph);
    final int incZAttr = VisualConcept.VertexAttribute.Z.get(storeGraph);
    final int incX2Attr = VisualConcept.VertexAttribute.X2.get(storeGraph);
    final int incY2Attr = VisualConcept.VertexAttribute.Y2.get(storeGraph);
    final int incZ2Attr = VisualConcept.VertexAttribute.Z2.get(storeGraph);
    final int incNradiusAttr = VisualConcept.VertexAttribute.NODE_RADIUS.get(storeGraph);
    final int incLradiusAttr = VisualConcept.VertexAttribute.LABEL_RADIUS.get(storeGraph);
    // Build the inclusion graph by copying vertices, connections, and values
    // from the original graph.  We remember which vertices have been included
    // for easy future reference.
    final BitSet vertices = new BitSet();
    for (int position = 0; position < vxCount; position++) {
        final int vxId = wg.getVertex(position);
        // A vertex goes into the inclusion graph if all vertexes are selected
        // or the explicit vertex is selected and the vertex is not marked as
        // pinned.
        final boolean allVertexesSelected = incCount == vxCount || incCount == 0;
        if ((allVertexesSelected || isVertexIncluded(vxId)) && !wg.getBooleanValue(pinnedAttr, vxId)) {
            vertices.set(vxId);
            // Create the vertex in the inclusion graph with the same vertex
            // ID as the original graph. This means we don't have to track
            // original id <-> inclusion graph id.
            final int incVxId = storeGraph.addVertex(vxId);
            storeGraph.setFloatValue(incXAttr, incVxId, wg.getFloatValue(xAttr, vxId));
            storeGraph.setFloatValue(incYAttr, incVxId, wg.getFloatValue(yAttr, vxId));
            storeGraph.setFloatValue(incZAttr, incVxId, wg.getFloatValue(zAttr, vxId));
            if (xyz2AreSet) {
                storeGraph.setFloatValue(incX2Attr, incVxId, wg.getFloatValue(x2Attr, vxId));
                storeGraph.setFloatValue(incY2Attr, incVxId, wg.getFloatValue(y2Attr, vxId));
                storeGraph.setFloatValue(incZ2Attr, incVxId, wg.getFloatValue(z2Attr, vxId));
            }
            if (incNradiusAttr != Graph.NOT_FOUND) {
                storeGraph.setFloatValue(incNradiusAttr, incVxId, wg.getFloatValue(nradiusAttr, vxId));
            }
            if (incLradiusAttr != Graph.NOT_FOUND) {
                storeGraph.setFloatValue(incLradiusAttr, incVxId, wg.getFloatValue(lradiusAttr, vxId));
            }
            // Copy the extra attribute values.
            for (int i = 0; i < attributesToCopy.size(); i++) {
                storeGraph.setObjectValue(selectionAttributes[i], incVxId, wg.getObjectValue(attributesToCopy.get(i).getId(), vxId));
            }
        }
    }
    if (connections == Connections.NONE) {
    // Do nothing, the inclusion graph won't have any transactions.
    } else if (connections == Connections.TRANSACTIONS) {
        addTransactionsFromTransactions(wg, storeGraph, vertices);
    } else if (connections == Connections.EDGES) {
        addTransactionsFromEdges(wg, storeGraph, vertices);
    } else {
        addTransactionsFromLinks(wg, storeGraph, vertices);
    }
    this.inclusionGraph = storeGraph;
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) BitSet(java.util.BitSet) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Example 2 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class ArrangeByNodeAttributePlugin method edit.

@Override
public void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
    final boolean threeD = parameters.getParameters().get(THREE_D_PARAMETER_ID).getBooleanValue();
    final String attribute = parameters.getParameters().get(ATTRIBUTE_PARAMETER_ID).getStringValue();
    if (threeD) {
        if (attribute != null) {
            final SelectedInclusionGraph selectedGraph = new SelectedInclusionGraph(wg, SelectedInclusionGraph.Connections.NONE);
            final Attribute attr = new GraphAttribute(wg, wg.getAttribute(GraphElementType.VERTEX, attribute));
            selectedGraph.addAttributeToCopy(attr);
            final GraphWriteMethods ig = selectedGraph.getInclusionGraph();
            final int iattrId = ig.getAttribute(GraphElementType.VERTEX, attribute);
            final LayerArranger arranger = new LayerArranger();
            arranger.setLevelAttr(iattrId);
            arranger.setMaintainMean(!selectedGraph.isArrangingAll());
            arranger.arrange(ig);
            selectedGraph.retrieveCoords();
        }
    } else {
        if (attribute != null) {
            final Arranger inner = new GridArranger();
            final Arranger outer = new GridArranger();
            final GraphTaxonomyArranger arranger = new ArrangeByGroupTaxonomy(inner, outer, Connections.NONE, attribute);
            arranger.setMaintainMean(true);
            final SelectedInclusionGraph selectedGraph = new SelectedInclusionGraph(wg, Connections.NONE);
            selectedGraph.addAttributeToCopy(new GraphAttribute(wg, wg.getAttribute(GraphElementType.VERTEX, attribute)));
            arranger.arrange(selectedGraph.getInclusionGraph());
            selectedGraph.retrieveCoords();
        }
    }
}
Also used : GridArranger(au.gov.asd.tac.constellation.plugins.arrangements.grid.GridArranger) GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) GridArranger(au.gov.asd.tac.constellation.plugins.arrangements.grid.GridArranger) Arranger(au.gov.asd.tac.constellation.plugins.arrangements.Arranger) GraphTaxonomyArranger(au.gov.asd.tac.constellation.plugins.arrangements.GraphTaxonomyArranger) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) SelectedInclusionGraph(au.gov.asd.tac.constellation.plugins.arrangements.SelectedInclusionGraph) GraphTaxonomyArranger(au.gov.asd.tac.constellation.plugins.arrangements.GraphTaxonomyArranger)

Example 3 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class LayerByTimePlugin method read.

@Override
public void read(final GraphReadMethods rg, final PluginInteraction interaction, final PluginParameters parameters) throws PluginException, InterruptedException {
    // We have the dtAttr from the original wg: we should have been passed the label, but never mind.
    // We need to get the label from the original, so we can get the dtAttr for the copy.
    final String dtAttrOrig = parameters.getParameters().get(DATETIME_ATTRIBUTE_PARAMETER_ID).getStringValue();
    if (dtAttrOrig == null) {
        interaction.notify(PluginNotificationLevel.ERROR, "A date-time attribute must be specified.");
        return;
    }
    final int dtAttrOrigId = rg.getAttribute(GraphElementType.TRANSACTION, dtAttrOrig);
    if (dtAttrOrigId == Graph.NOT_FOUND) {
        interaction.notify(PluginNotificationLevel.ERROR, "A valid date-time attribute must be specified.");
        return;
    }
    Graph copy;
    try {
        final Plugin copyGraphPlugin = PluginRegistry.get(InteractiveGraphPluginRegistry.COPY_TO_NEW_GRAPH);
        final PluginParameters copyParams = copyGraphPlugin.createParameters();
        copyParams.getParameters().get(CopyToNewGraphPlugin.NEW_SCHEMA_NAME_PARAMETER_ID).setStringValue(rg.getSchema().getFactory().getName());
        copyParams.getParameters().get(CopyToNewGraphPlugin.COPY_ALL_PARAMETER_ID).setBooleanValue(true);
        copyParams.getParameters().get(CopyToNewGraphPlugin.COPY_KEYS_PARAMETER_ID).setBooleanValue(false);
        PluginExecution.withPlugin(copyGraphPlugin).withParameters(copyParams).executeNow(rg);
        copy = (Graph) copyParams.getParameters().get(CopyToNewGraphPlugin.NEW_GRAPH_OUTPUT_PARAMETER_ID).getObjectValue();
    } catch (final PluginException ex) {
        copy = null;
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    }
    if (copy == null) {
        // The copy failed, drop out now.
        return;
    }
    final Attribute dt = new GraphAttribute(rg, dtAttrOrigId);
    final WritableGraph wgcopy = copy.getWritableGraph("Layer by time", true);
    try {
        final int dtAttr = wgcopy.getAttribute(GraphElementType.TRANSACTION, dt.getName());
        final boolean useIntervals = parameters.getParameters().get(LAYER_BY_PARAMETER_ID).getStringValue().equals(INTERVAL_METHOD);
        final ZonedDateTime[] startEnd = parameters.getParameters().get(DATE_RANGE_PARAMETER_ID).getDateTimeRangeValue().getZonedStartEnd();
        final ZonedDateTime start = startEnd[0];
        final ZonedDateTime end = startEnd[1];
        final boolean isTransactionLayers = parameters.getParameters().get(TRANSACTION_AS_LAYER_PARAMETER_ID).getBooleanValue();
        // Establish new attributes.
        // Create and store graph attributes.
        final LayerName defaultName = new LayerName(Graph.NOT_FOUND, "Default");
        final int timeLayerAttr = wgcopy.addAttribute(GraphElementType.TRANSACTION, LayerNameAttributeDescription.ATTRIBUTE_NAME, LAYER_NAME, "time layer", defaultName, null);
        wgcopy.addAttribute(GraphElementType.GRAPH, IntegerAttributeDescription.ATTRIBUTE_NAME, NLAYERS, "The number of layers to layer by time", 1, null);
        final int txColorAttr = wgcopy.getAttribute(GraphElementType.TRANSACTION, "color");
        final int txGuideline = wgcopy.addAttribute(GraphElementType.TRANSACTION, BooleanAttributeDescription.ATTRIBUTE_NAME, "layer_guideline", "This transaction is a layer guideline", false, null);
        final ConstellationColor guidelineColor = ConstellationColor.getColorValue(0.25F, 0.25F, 0.25F, 1F);
        wgcopy.addAttribute(GraphElementType.VERTEX, IntegerAttributeDescription.ATTRIBUTE_NAME, ORIGINAL_ID_LABEL, "Original Node Id", -1, null);
        final List<Float> values = new ArrayList<>();
        final Map<Integer, List<Float>> remappedLayers = new HashMap<>();
        final Map<Integer, String> displayNames = new HashMap<>();
        if (useIntervals) {
            final int intervalUnit = LAYER_INTERVALS.get(parameters.getParameters().get(UNIT_PARAMETER_ID).getStringValue());
            final int intervalAmount = parameters.getParameters().get(AMOUNT_PARAMETER_ID).getIntegerValue();
            buildIntervals(wgcopy, values, remappedLayers, displayNames, dtAttr, start.toInstant(), end.toInstant(), intervalUnit, intervalAmount);
        } else {
            final int calendarUnit = BIN_CALENDAR_UNITS.get(parameters.getParameters().get(UNIT_PARAMETER_ID).getStringValue());
            final int binAmount = parameters.getParameters().get(AMOUNT_PARAMETER_ID).getIntegerValue();
            buildBins(wgcopy, values, remappedLayers, displayNames, dtAttr, start.toInstant(), end.toInstant(), calendarUnit, binAmount);
        }
        final boolean keepTxColors = parameters.getParameters().get(KEEP_TX_COLORS_PARAMETER_ID).getBooleanValue();
        final boolean drawTxGuides = parameters.getParameters().get(DRAW_TX_GUIDES_PARAMETER_ID).getBooleanValue();
        // Modify the copied graph to show our layers.
        int z = 0;
        float step = getWidth(wgcopy) / values.size();
        for (final Entry<Integer, List<Float>> entry : remappedLayers.entrySet()) {
            for (final Entry<Float, List<Integer>> currentLayer : transactionLayers.entrySet()) {
                if (entry.getValue().contains(currentLayer.getKey())) {
                    for (final int txId : currentLayer.getValue()) {
                        final float origLayer = currentLayer.getKey();
                        int newLayer = 0;
                        if (entry.getValue().contains(origLayer)) {
                            // Overwrite value
                            newLayer = entry.getKey();
                        }
                        final LayerName dn = new LayerName(newLayer, displayNames.get(newLayer));
                        wgcopy.setObjectValue(timeLayerAttr, txId, dn);
                        final float normLayer = newLayer / (remappedLayers.keySet().size() * 1F);
                        if (!keepTxColors) {
                            final Color heatmap = new Color(Color.HSBtoRGB((1 - normLayer) * 2F / 3F, 0.5F, 1));
                            final ConstellationColor color = ConstellationColor.getColorValue(heatmap.getRed() / 255F, heatmap.getGreen() / 255F, heatmap.getBlue() / 255F, 1F);
                            wgcopy.setObjectValue(txColorAttr, txId, color);
                        }
                        if (isTransactionLayers) {
                            transactionsAsLayers(wgcopy, txId, z, step);
                        } else {
                            nodesAsLayers(wgcopy, txId, newLayer);
                        }
                    }
                }
            }
            if (isTransactionLayers) {
                srcVxMap = dstVxMap;
                dstVxMap = new HashMap<>();
                z += step;
            }
        }
        // Remove any outstanding transactions flagged for deletion
        for (int txId = txToDelete.nextSetBit(0); txId >= 0; txId = txToDelete.nextSetBit(txId + 1)) {
            wgcopy.removeTransaction(txId);
        }
        // Get rid of all of the nodes that don't have any transactions.
        // By definition, the duplicates will have transactions between them, including the original layer
        // (because we just deleted transactions that belong in different layers, leaving only the transactions
        // that belong in the original layer).
        final List<Integer> vertices = new ArrayList<>();
        for (int position = 0; position < wgcopy.getVertexCount(); position++) {
            final int vertexId = wgcopy.getVertex(position);
            final int nTx = wgcopy.getVertexTransactionCount(vertexId);
            if (nTx == 0) {
                vertices.add(vertexId);
            }
        }
        vertices.stream().forEach(wgcopy::removeVertex);
        if (drawTxGuides) {
            interaction.setProgress(5, 6, "Draw guide lines", false);
            // We have to do this after the "remove node without transactions" step because we're adding more transactions.
            if (!isTransactionLayers && remappedLayers.keySet().size() > 1) {
                nodeIdToLayers.keySet().stream().forEach(origNodeId -> {
                    int prevNodeId = -1;
                    final BitSet layers = nodeIdToLayers.get(origNodeId);
                    for (int layer = layers.nextSetBit(0); layer >= 0; layer = layers.nextSetBit(layer + 1)) {
                        final int nodeId = layer == 0 ? origNodeId : nodeDups.get(String.format("%s/%s", origNodeId, layer));
                        if (prevNodeId != -1) {
                            final int sTxId = wgcopy.addTransaction(prevNodeId, nodeId, false);
                            wgcopy.setBooleanValue(txGuideline, sTxId, true);
                            wgcopy.setObjectValue(txColorAttr, sTxId, guidelineColor);
                            final LayerName dn = new LayerName(1107, "Guideline");
                            wgcopy.setObjectValue(timeLayerAttr, sTxId, dn);
                        }
                        prevNodeId = nodeId;
                    }
                });
            }
        }
    } finally {
        wgcopy.commit();
    }
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) HashMap(java.util.HashMap) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ArrayList(java.util.ArrayList) ZonedDateTime(java.time.ZonedDateTime) List(java.util.List) ArrayList(java.util.ArrayList) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LayerName(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.LayerName) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) BitSet(java.util.BitSet) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) CopyToNewGraphPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin) SimpleReadPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleReadPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 4 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class LayerByTimePlugin method updateParameters.

@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
    final ReadableGraph rg = graph.getReadableGraph();
    final List<String> dateTimeAttributes = new ArrayList<>();
    try {
        final int attributeCount = rg.getAttributeCount(GraphElementType.TRANSACTION);
        for (int i = 0; i < attributeCount; i++) {
            final int attrId = rg.getAttribute(GraphElementType.TRANSACTION, i);
            final Attribute attr = new GraphAttribute(rg, attrId);
            if (attr.getAttributeType().equals(ZonedDateTimeAttributeDescription.ATTRIBUTE_NAME)) {
                dateTimeAttributes.add(attr.getName());
            }
        }
    } finally {
        rg.release();
    }
    SingleChoiceParameterType.setOptions(dtAttrParam, dateTimeAttributes);
    parameters.addController(DATETIME_ATTRIBUTE_PARAMETER_ID, (masterId, paramMap, change) -> {
        if (change == ParameterChange.VALUE) {
            final String attrName = paramMap.get(DATETIME_ATTRIBUTE_PARAMETER_ID).getStringValue();
            final ReadableGraph rg2 = graph.getReadableGraph();
            try {
                final int attrId = rg2.getAttribute(GraphElementType.TRANSACTION, attrName);
                if (attrId == Graph.NOT_FOUND) {
                    return;
                }
                ZonedDateTime min = ZonedDateTime.ofInstant(Instant.now(), TimeZoneUtilities.UTC);
                ZonedDateTime max = ZonedDateTime.ofInstant(Instant.EPOCH, TimeZoneUtilities.UTC);
                final int txCount = rg.getTransactionCount();
                boolean nonNullDateTimeFound = false;
                for (int position = 0; position < txCount; position++) {
                    final int txId = rg.getTransaction(position);
                    // Ignore zero and "null" dates.
                    final ZonedDateTime dt = rg.getObjectValue(attrId, txId);
                    if (dt != null) {
                        nonNullDateTimeFound = true;
                        if (dt.toInstant().isBefore(min.toInstant())) {
                            min = dt;
                        }
                        if (dt.toInstant().isAfter(max.toInstant())) {
                            max = dt;
                        }
                    }
                }
                if (!nonNullDateTimeFound) {
                    final ZonedDateTime swap = min;
                    min = max;
                    max = swap;
                }
                dateRangeParam.setDateTimeRangeValue(new DateTimeRange(min, max));
            } finally {
                rg2.release();
            }
        }
    });
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ZonedDateTime(java.time.ZonedDateTime) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ArrayList(java.util.ArrayList) DateTimeRange(au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRange)

Example 5 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class DataAccessStateIoProviderNGTest method writeObjectIsDefaultValue.

@Test
public void writeObjectIsDefaultValue() throws IOException {
    final Attribute attribute = mock(Attribute.class);
    when(attribute.getId()).thenReturn(ATTRIBUTE_ID);
    when(attribute.getName()).thenReturn("ATTR NAME");
    final GraphWriteMethods graph = mock(GraphWriteMethods.class);
    when(graph.isDefaultValue(ATTRIBUTE_ID, ELEMENT_ID)).thenReturn(true);
    final JsonFactory factory = new JsonFactory();
    final ByteArrayOutputStream output = new ByteArrayOutputStream();
    final JsonGenerator jsonGenerator = factory.createGenerator(output);
    dataAccessStateIoProvider.writeObject(attribute, ELEMENT_ID, jsonGenerator, graph, null, false);
    jsonGenerator.flush();
    assertEquals(new String(output.toByteArray(), StandardCharsets.UTF_8), "");
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) Attribute(au.gov.asd.tac.constellation.graph.Attribute) JsonFactory(com.fasterxml.jackson.core.JsonFactory) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Aggregations

Attribute (au.gov.asd.tac.constellation.graph.Attribute)94 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)55 ArrayList (java.util.ArrayList)30 Test (org.testng.annotations.Test)23 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)18 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)15 TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)13 Graph (au.gov.asd.tac.constellation.graph.Graph)12 BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObservableList (javafx.collections.ObservableList)8 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)7 Column (au.gov.asd.tac.constellation.views.tableview.api.Column)7 TableColumn (javafx.scene.control.TableColumn)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)6 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)5 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)5 Tuple (au.gov.asd.tac.constellation.utilities.datastructure.Tuple)5 JsonFactory (com.fasterxml.jackson.core.JsonFactory)5