use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.
the class SmallWorldGraphBuilderPlugin method updateParameters.
@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
final List<String> nAttributes = new ArrayList<>();
final List<String> tAttributes = new ArrayList<>();
final List<String> nChoices = new ArrayList<>();
final List<String> tChoices = new ArrayList<>();
if (graph != null) {
final Set<Class<? extends SchemaConcept>> concepts = graph.getSchema().getFactory().getRegisteredConcepts();
final Collection<SchemaVertexType> nodeTypes = SchemaVertexTypeUtilities.getTypes(concepts);
for (final SchemaVertexType type : nodeTypes) {
nAttributes.add(type.getName());
}
nAttributes.sort(String::compareTo);
final Collection<SchemaTransactionType> transactionTypes = SchemaTransactionTypeUtilities.getTypes(concepts);
for (final SchemaTransactionType type : transactionTypes) {
tAttributes.add(type.getName());
}
tAttributes.sort(String::compareTo);
nChoices.add(nAttributes.get(0));
tChoices.add(tAttributes.get(0));
}
if (parameters != null && parameters.getParameters() != null) {
// NODE_TYPES_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(NODE_TYPES_PARAMETER_ID);
// TRANSACTION_TYPES_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
MultiChoiceParameterType.setOptions(nAttribute, nAttributes);
MultiChoiceParameterType.setOptions(tAttribute, tAttributes);
MultiChoiceParameterType.setChoices(nAttribute, nChoices);
MultiChoiceParameterType.setChoices(tAttribute, tChoices);
}
}
use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.
the class PreferentialAttachmentGraphBuilderPlugin method updateParameters.
@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
final List<String> nAttributes = new ArrayList<>();
final List<String> tAttributes = new ArrayList<>();
final List<String> nChoices = new ArrayList<>();
final List<String> tChoices = new ArrayList<>();
if (graph != null) {
final Set<Class<? extends SchemaConcept>> concepts = graph.getSchema().getFactory().getRegisteredConcepts();
final Collection<SchemaVertexType> nodeTypes = SchemaVertexTypeUtilities.getTypes(concepts);
for (final SchemaVertexType type : nodeTypes) {
nAttributes.add(type.getName());
}
nAttributes.sort(String::compareTo);
final Collection<SchemaTransactionType> transactionTypes = SchemaTransactionTypeUtilities.getTypes(concepts);
for (final SchemaTransactionType type : transactionTypes) {
tAttributes.add(type.getName());
}
tAttributes.sort(String::compareTo);
nChoices.add(nAttributes.get(0));
tChoices.add(tAttributes.get(0));
}
if (parameters != null && parameters.getParameters() != null) {
// NODE_TYPES_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(NODE_TYPES_PARAMETER_ID);
// TRANSACTION_TYPES_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
MultiChoiceParameterType.setOptions(nAttribute, nAttributes);
MultiChoiceParameterType.setOptions(tAttribute, tAttributes);
MultiChoiceParameterType.setChoices(nAttribute, nChoices);
MultiChoiceParameterType.setChoices(tAttribute, tChoices);
}
}
use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.
the class GraphRecordStoreUtilitiesNGTest method addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseAndCompleteWithSchema.
@Test
public void addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseAndCompleteWithSchema() {
final RecordStore recordStore = new GraphRecordStore();
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "vx1");
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + GraphRecordStoreUtilities.DIRECTED_KEY, false);
// the communication type is directed
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + AnalyticConcept.TransactionAttribute.TYPE, AnalyticConcept.TransactionType.COMMUNICATION);
final boolean initializeWithSchema = true;
final boolean completeWithSchema = true;
final List<String> vertexIdAttributes = new ArrayList<>();
final Map<String, Integer> vertexMap = new HashMap<>();
final Map<String, Integer> transactionMap = new HashMap<>();
final List<Integer> veritices = GraphRecordStoreUtilities.addRecordStoreToGraph(graph, recordStore, initializeWithSchema, completeWithSchema, vertexIdAttributes, vertexMap, transactionMap);
assertEquals(2, veritices.size());
assertEquals(2, graph.getVertexCount());
assertEquals(1, graph.getTransactionCount());
// try {
// SaveGraphUtilities.saveGraphToTemporaryDirectory(graph, "testAddedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseAndCompleteWithSchema");
// } catch (IOException ex) {
// Assert.fail(ex.getLocalizedMessage());
// }
final int transactionTypeId = AnalyticConcept.TransactionAttribute.TYPE.get(graph);
SchemaTransactionType type = (SchemaTransactionType) graph.getObjectValue(transactionTypeId, 0);
Assert.assertFalse(type.isDirected());
}
use of au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType in project constellation by constellation-app.
the class GraphRecordStoreUtilitiesNGTest method addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema.
@Test
public void addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema() {
final RecordStore recordStore = new GraphRecordStore();
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "vx1");
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + GraphRecordStoreUtilities.DIRECTED_KEY, false);
// the communication type is directed
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + AnalyticConcept.TransactionAttribute.TYPE, AnalyticConcept.TransactionType.COMMUNICATION);
final boolean initializeWithSchema = true;
final boolean completeWithSchema = false;
final List<String> vertexIdAttributes = new ArrayList<>();
final Map<String, Integer> vertexMap = new HashMap<>();
final Map<String, Integer> transactionMap = new HashMap<>();
final List<Integer> veritices = GraphRecordStoreUtilities.addRecordStoreToGraph(graph, recordStore, initializeWithSchema, completeWithSchema, vertexIdAttributes, vertexMap, transactionMap);
assertEquals(2, veritices.size());
assertEquals(2, graph.getVertexCount());
assertEquals(1, graph.getTransactionCount());
// try {
// SaveGraphUtilities.saveGraphToTemporaryDirectory(graph, "testAddedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema");
// } catch (IOException ex) {
// Assert.fail(ex.getLocalizedMessage());
// }
final int transactionTypeId = AnalyticConcept.TransactionAttribute.TYPE.get(graph);
SchemaTransactionType type = (SchemaTransactionType) graph.getObjectValue(transactionTypeId, 0);
Assert.assertFalse(type.isDirected());
}
Aggregations