use of au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList in project constellation by constellation-app.
the class ResetStatePluginNGTest method setupGraph.
private void setupGraph() {
graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
try {
WritableGraph wg = graph.getWritableGraph("", true);
final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.ensure(wg);
ArrayList<Attribute> attributeList = new ArrayList<>();
BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("label name", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
FindResultsList foundResult = new FindResultsList(2, parameters, graph.getId());
wg.setObjectValue(stateId, 0, foundResult);
wg.commit();
} catch (final InterruptedException ex) {
Exceptions.printStackTrace(ex);
Thread.currentThread().interrupt();
}
}
use of au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList in project constellation by constellation-app.
the class FindViewTopComponentNGTest method setupGraph.
private void setupGraph() {
graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
graphMap.put(graph.getId(), graph);
try {
WritableGraph wg = graph.getWritableGraph("", true);
final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.ensure(wg);
ArrayList<Attribute> attributeList = new ArrayList<>();
BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("label name", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
FindResultsList foundResult = new FindResultsList(2, parameters, graph.getId());
wg.setObjectValue(stateId, 0, foundResult);
wg.commit();
} catch (final InterruptedException ex) {
Exceptions.printStackTrace(ex);
Thread.currentThread().interrupt();
}
}
use of au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList in project constellation by constellation-app.
the class FindViewStateIoProvider method writeObject.
@Override
public void writeObject(final Attribute attribute, final int elementId, final JsonGenerator jsonGenerator, final GraphReadMethods graph, final GraphByteWriter byteWriter, boolean verbose) throws IOException {
if (verbose || !graph.isDefaultValue(attribute.getId(), elementId)) {
final FindResultsList originalResultsList = graph.getObjectValue(attribute.getId(), elementId);
if (originalResultsList == null) {
jsonGenerator.writeNullField(attribute.getName());
} else {
final FindResultsList resultsList = new FindResultsList(originalResultsList);
// Store the current index and the graph ID
jsonGenerator.writeObjectFieldStart(attribute.getName());
jsonGenerator.writeNumberField("currentIndex", resultsList.getCurrentIndex());
jsonGenerator.writeStringField("graphID", resultsList.getGraphId());
// Stores a list of the Find Results, ID, UID and Graph element type label
jsonGenerator.writeArrayFieldStart("findResults");
for (final FindResult fr : resultsList) {
jsonGenerator.writeNumber(fr.getID());
jsonGenerator.writeNumber(fr.getUID());
jsonGenerator.writeString(fr.getType().getShortLabel());
}
jsonGenerator.writeEndArray();
// Store all the basic find replace parameters
final BasicFindReplaceParameters parameters = resultsList.getSearchParameters();
jsonGenerator.writeStringField("findString", parameters.getFindString());
jsonGenerator.writeStringField("replaceString", parameters.getReplaceString());
jsonGenerator.writeStringField("graphElement", parameters.getGraphElement().getShortLabel());
jsonGenerator.writeBooleanField("standardText", parameters.isStandardText());
jsonGenerator.writeBooleanField("regEx", parameters.isRegEx());
jsonGenerator.writeBooleanField("ignoreCase", parameters.isIgnoreCase());
jsonGenerator.writeBooleanField("exactMatch", parameters.isExactMatch());
jsonGenerator.writeBooleanField("searchAllGraphs", parameters.isSearchAllGraphs());
jsonGenerator.writeBooleanField("addToSelection", parameters.isAddTo());
jsonGenerator.writeBooleanField("findInSelection", parameters.isFindIn());
jsonGenerator.writeBooleanField("removeFromSelection", parameters.isRemoveFrom());
jsonGenerator.writeBooleanField("replaceInSelected", parameters.isReplaceIn());
// Store all the selected attributes of the search
jsonGenerator.writeArrayFieldStart("selectedAttributes");
for (final Attribute a : parameters.getAttributeList()) {
jsonGenerator.writeObject(a.getName());
}
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject();
}
}
}
use of au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList in project constellation by constellation-app.
the class FindViewStateIoProvider method readObject.
@Override
public void readObject(final int attributeId, final int elementId, final JsonNode jnode, final GraphWriteMethods writableGraph, final Map<Integer, Integer> vertexMap, final Map<Integer, Integer> transactionMap, final GraphByteReader byteReader, final ImmutableObjectCache cache) throws IOException {
if (!jnode.isNull()) {
// Get the findResultsList variables
final int currentIndex = jnode.get("currentIndex").asInt();
final String graphID = jnode.get("graphID").asText();
// Get the basic find replace parameters
final String findString = jnode.get("findString").asText();
final String replaceString = jnode.get("replaceString").asText();
final String graphElementString = jnode.get("graphElement").asText();
final GraphElementType graphElement = GraphElementType.getValue(graphElementString);
final Boolean standardText = jnode.get("standardText").asBoolean();
final Boolean regEx = jnode.get("regEx").asBoolean();
final Boolean ignoreCase = jnode.get("ignoreCase").asBoolean();
final Boolean exactMatch = jnode.get("exactMatch").asBoolean();
final Boolean findInSelection = jnode.get("findInSelection").asBoolean();
final Boolean addToSelection = jnode.get("addToSelection").asBoolean();
final Boolean removeFromSelection = jnode.get("removeFromSelection").asBoolean();
final Boolean replaceInSelected = jnode.get("replaceInSelected").asBoolean();
final Boolean searchAllGraphs = jnode.get("searchAllGraphs").asBoolean();
// Get the selected attributes
final List<Attribute> selectedAttributes = new ArrayList<>();
final ArrayNode selectedAttributesArray = (ArrayNode) jnode.withArray("selectedAttributes");
for (int i = 0; i < selectedAttributesArray.size(); i++) {
if (selectedAttributesArray.get(i).isNull()) {
selectedAttributes.add(null);
} else {
int attributeInt = writableGraph.getAttribute(graphElement, selectedAttributesArray.get(i).asText());
selectedAttributes.add(new GraphAttribute(writableGraph, attributeInt));
}
}
// Create the basic find replace parameter object with the variables
final BasicFindReplaceParameters parameters = new BasicFindReplaceParameters(findString, replaceString, graphElement, selectedAttributes, standardText, regEx, ignoreCase, exactMatch, findInSelection, addToSelection, removeFromSelection, replaceInSelected, searchAllGraphs);
// Get the find results
final List<FindResult> findResults = new ArrayList<>();
final ArrayNode findResultsArray = (ArrayNode) jnode.withArray("findResults");
for (int i = 0; i < findResultsArray.size(); i = i + 3) {
findResults.add(findResultsArray.get(i).isNull() ? null : new FindResult(findResultsArray.get(i).asInt(), findResultsArray.get(i + 1).asInt(), GraphElementType.getValue(findResultsArray.get(i + 2).asText())));
}
// Create the findResultList object
final FindResultsList findResultList = new FindResultsList(currentIndex, parameters, graphID);
// Add the find results to the findResultsList
findResultList.addAll(findResults);
writableGraph.setObjectValue(attributeId, elementId, findResultList);
}
}
use of au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList in project constellation by constellation-app.
the class ResetStatePluginNGTest method testEdit.
/**
* Test of edit method, of class ResetStatePlugin.
*/
@Test
public void testEdit() throws Exception {
System.out.println("edit");
setupGraph();
ResetStatePlugin resetStatePlugin = new ResetStatePlugin();
PluginExecution.withPlugin(resetStatePlugin).executeNow(graph);
ReadableGraph rg = graph.getReadableGraph();
final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.get(rg);
FindResultsList graphFindResults = rg.getObjectValue(stateId, 0);
rg.close();
/**
* The FINDVIEW_STATE object was set to an empty FindResults list with a
* given current index of 2. The resetStatePlugin should reset its
* current index to -1.
*/
assertEquals(graphFindResults.getCurrentIndex(), -1);
}
Aggregations