Search in sources :

Example 31 with Schema

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

the class DefaultQualityControlAutoButtonNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
    rules = new ArrayList<>();
    events = new ArrayList<>();
    // mock QualityControlEvent
    qualityControlEvent = mock(QualityControlEvent.class);
    when(qualityControlEvent.getCategory()).thenReturn(QualityCategory.CRITICAL);
    when(qualityControlEvent.getReasons()).thenReturn("Reason 1, Reason2");
    events.add(qualityControlEvent);
}
Also used : QualityControlEvent(au.gov.asd.tac.constellation.views.qualitycontrol.QualityControlEvent) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 32 with Schema

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

the class QualityControlViewPaneNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    // create an analytic graph
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
    // add attributes
    vertexIdentifierAttribute = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
    vertexTypeAttribute = AnalyticConcept.VertexAttribute.TYPE.ensure(graph);
    vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    // add vertices
    vxId1 = graph.addVertex();
    vxId2 = graph.addVertex();
    vxId3 = graph.addVertex();
    // set all vertices to be selected
    graph.setBooleanValue(vertexSelectedAttribute, vxId1, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId2, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId3, false);
    rules = new ArrayList<>(Lookup.getDefault().lookupAll(QualityControlRule.class));
    vertices = Arrays.asList(vxId1, vxId2);
    for (final QualityControlRule rule : rules) {
        rule.executeRule(graph, vertices);
    }
    events = new ArrayList<>();
    for (final int vertexId : vertices) {
        final String type = graph.getStringValue(vertexTypeAttribute, vertexId);
        events.add(new QualityControlEvent(vertexId, graph.getStringValue(vertexIdentifierAttribute, vertexId), SchemaVertexTypeUtilities.getType(type), rules));
    }
}
Also used : QualityControlRule(au.gov.asd.tac.constellation.views.qualitycontrol.rules.QualityControlRule) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 33 with Schema

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

the class AttributeNodeProvider method getSchemaInfo.

private List<AttributeEntry> getSchemaInfo(final Graph graph) {
    final List<AttributeEntry> attrs = new ArrayList<>();
    final Schema schema = graph.getSchema();
    final SchemaFactory factory = schema.getFactory();
    // Get the keys for each element type.
    final Map<GraphElementType, List<String>> elementKeys = new HashMap<>();
    for (final GraphElementType et : new GraphElementType[] { GraphElementType.VERTEX, GraphElementType.TRANSACTION }) {
        final List<SchemaAttribute> keys = factory.getKeyAttributes(et);
        final List<String> keyLabels = keys.stream().map(key -> key.getName()).collect(Collectors.toList());
        elementKeys.put(et, keyLabels);
    }
    for (final GraphElementType et : GraphElementType.values()) {
        final Map<String, SchemaAttribute> attrsMap = factory.getRegisteredAttributes(et);
        attrsMap.values().stream().forEach(schemaAttribute -> {
            final int keyIx = elementKeys.containsKey(schemaAttribute.getElementType()) ? elementKeys.get(schemaAttribute.getElementType()).indexOf(schemaAttribute.getName()) : -1;
            final Collection<SchemaConcept> concepts = SchemaConceptUtilities.getAttributeConcepts(schemaAttribute);
            final StringBuilder categories = new StringBuilder();
            for (SchemaConcept concept : concepts) {
                categories.append(concept.getName()).append(",");
            }
            if (categories.length() > 0) {
                categories.deleteCharAt(categories.length() - 1);
            }
            attrs.add(new AttributeEntry(schemaAttribute, categories.toString(), keyIx));
        });
    }
    return attrs;
}
Also used : SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) Pos(javafx.geometry.Pos) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) GraphManagerListener(au.gov.asd.tac.constellation.graph.manager.GraphManagerListener) VBox(javafx.scene.layout.VBox) SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) Graph(au.gov.asd.tac.constellation.graph.Graph) Insets(javafx.geometry.Insets) Map(java.util.Map) ServiceProvider(org.openide.util.lookup.ServiceProvider) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) TableView(javafx.scene.control.TableView) UserInterfaceIconProvider(au.gov.asd.tac.constellation.utilities.icon.UserInterfaceIconProvider) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute) SchemaConceptUtilities(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConceptUtilities) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) SeparatorConstants(au.gov.asd.tac.constellation.utilities.text.SeparatorConstants) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Collection(java.util.Collection) StaticResource(org.netbeans.api.annotations.common.StaticResource) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) List(java.util.List) ToggleGroup(javafx.scene.control.ToggleGroup) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) RadioButton(javafx.scene.control.RadioButton) ImageView(javafx.scene.image.ImageView) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) HashMap(java.util.HashMap) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) ArrayList(java.util.ArrayList) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)

Example 34 with Schema

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

the class PreferentialAttachmentGraphBuilderPluginNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 35 with Schema

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

the class SmallWorldGraphBuilderPluginNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Schema (au.gov.asd.tac.constellation.graph.schema.Schema)74 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)63 BeforeMethod (org.testng.annotations.BeforeMethod)50 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)17 Graph (au.gov.asd.tac.constellation.graph.Graph)15 Test (org.testng.annotations.Test)13 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)10 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)8 ArrayList (java.util.ArrayList)8 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)7 IOException (java.io.IOException)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)5 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)5 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)3 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)3 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)2 SchemaAttribute (au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)2