use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues in project constellation by constellation-app.
the class ColourCriteriaPanelNGTest method testGetCriteriaValues.
/**
* Test of getCriteriaValues method, of class ColourCriteriaPanel.
*/
@Test
public void testGetCriteriaValues() {
System.out.println("getCriteriaValues");
setupGraph();
AdvancedFindTab parentComponent = spy(advancedTab);
final GraphElementType type = GraphElementType.VERTEX;
ColourCriteriaPanel colourCriteriaPanel = new ColourCriteriaPanel(parentComponent, "color", type);
colourCriteriaPanel.getFilterChoiceBox().getSelectionModel().select("Is");
final List<AdvancedCriteriaBorderPane> tempList = new ArrayList<>();
final GridPane tempGrid = new GridPane();
tempList.add(colourCriteriaPanel);
tempGrid.add(tempList.get(0), 0, 0);
when(parentComponent.getCorrespondingCriteriaList(Mockito.eq(type))).thenReturn(tempList);
when(parentComponent.getCorrespondingGridPane(Mockito.eq(type))).thenReturn(tempGrid);
final List<AdvancedCriteriaBorderPane> criteriaList = parentComponent.getCorrespondingCriteriaList(type);
final FindCriteriaValues result = criteriaList.get(0).getCriteriaValues();
final ColourCriteriaValues colourResult = (ColourCriteriaValues) result;
assertEquals(colourResult.getAttribute(), "color");
assertEquals(colourResult.getAttributeType(), "color");
assertEquals(colourResult.getFilter(), "Is");
assertEquals(colourResult.getColorValue(), ConstellationColor.BLUE);
}
use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues in project constellation by constellation-app.
the class StringCriteriaPanelNGTest method testGetCriteriaValues.
/**
* Test of getCriteriaValues method, of class StringCriteriaPanel.
*/
@Test
public void testGetCriteriaValues() {
System.out.println("getCriteriaValues");
setupGraph();
AdvancedFindTab parentComponent = spy(advancedTab);
final GraphElementType type = GraphElementType.VERTEX;
StringCriteriaPanel stringCriteriaPanel = new StringCriteriaPanel(parentComponent, "Identifier", type);
stringCriteriaPanel.getFilterChoiceBox().getSelectionModel().select("Is");
stringCriteriaPanel.setSearchFieldText("hello");
final List<AdvancedCriteriaBorderPane> tempList = new ArrayList<>();
final GridPane tempGrid = new GridPane();
tempList.add(stringCriteriaPanel);
tempGrid.add(tempList.get(0), 0, 0);
when(parentComponent.getCorrespondingCriteriaList(Mockito.eq(type))).thenReturn(tempList);
when(parentComponent.getCorrespondingGridPane(Mockito.eq(type))).thenReturn(tempGrid);
final List<AdvancedCriteriaBorderPane> criteriaList = parentComponent.getCorrespondingCriteriaList(type);
final FindCriteriaValues result = criteriaList.get(0).getCriteriaValues();
final StringCriteriaValues floatResult = (StringCriteriaValues) result;
assertEquals(floatResult.getAttribute(), "Identifier");
assertEquals(floatResult.getAttributeType(), "string");
assertEquals(floatResult.getFilter(), "Is");
assertEquals(floatResult.getText(), "hello");
}
use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues in project constellation by constellation-app.
the class AdvancedSearchParametersNGTest method testEquals.
/**
* Test of equals method, of class AdvancedSearchParameters.
*/
@Test
public void testEquals() {
System.out.println("equals");
populateCriteriaLists();
paramatersOne = new AdvancedSearchParameters(criteriaValuesListOne, GraphElementType.VERTEX, "Any", "Ignore", false);
paramatersTwo = new AdvancedSearchParameters();
paramatersTwo.copyParameters(paramatersOne);
boolean result = paramatersOne.equals(paramatersTwo);
assertEquals(result, true);
paramatersTwo = new AdvancedSearchParameters(criteriaValuesListTwo, GraphElementType.VERTEX, "All", "Ignore", true);
result = paramatersOne.equals(paramatersTwo);
assertEquals(result, false);
// float , colour, boolean, zoned datetime, icon
FindCriteriaValues valueOne = new FloatCriteriaValues("float", "x", "Is", 1);
FindCriteriaValues valueTwo = new FloatCriteriaValues("float", "x", "Is", 6);
criteriaValuesListOne.clear();
criteriaValuesListTwo.clear();
criteriaValuesListOne.add(valueOne);
criteriaValuesListTwo.add(valueTwo);
paramatersOne = new AdvancedSearchParameters(criteriaValuesListOne, GraphElementType.VERTEX, "Any", "Ignore", false);
paramatersTwo = new AdvancedSearchParameters(criteriaValuesListTwo, GraphElementType.VERTEX, "Any", "Ignore", false);
result = paramatersOne.equals(paramatersTwo);
assertEquals(result, false);
valueOne = new BooleanCriteriaValues("boolean", "dim", "Is", true);
valueTwo = new BooleanCriteriaValues("boolean", "dim", "Is", false);
criteriaValuesListOne.clear();
criteriaValuesListTwo.clear();
criteriaValuesListOne.add(valueOne);
criteriaValuesListTwo.add(valueTwo);
paramatersOne = new AdvancedSearchParameters(criteriaValuesListOne, GraphElementType.VERTEX, "Any", "Ignore", false);
paramatersTwo = new AdvancedSearchParameters(criteriaValuesListTwo, GraphElementType.VERTEX, "Any", "Ignore", false);
result = paramatersOne.equals(paramatersTwo);
assertEquals(result, false);
valueOne = new ColourCriteriaValues("color", "color", "Is", ConstellationColor.BLUE);
valueTwo = new ColourCriteriaValues("color", "color", "Is", ConstellationColor.GREEN);
criteriaValuesListOne.clear();
criteriaValuesListTwo.clear();
criteriaValuesListOne.add(valueOne);
criteriaValuesListTwo.add(valueTwo);
paramatersOne = new AdvancedSearchParameters(criteriaValuesListOne, GraphElementType.VERTEX, "Any", "Ignore", false);
paramatersTwo = new AdvancedSearchParameters(criteriaValuesListTwo, GraphElementType.VERTEX, "Any", "Ignore", false);
result = paramatersOne.equals(paramatersTwo);
assertEquals(result, false);
valueOne = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
valueTwo = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.England"));
criteriaValuesListOne.clear();
criteriaValuesListTwo.clear();
criteriaValuesListOne.add(valueOne);
criteriaValuesListTwo.add(valueTwo);
paramatersOne = new AdvancedSearchParameters(criteriaValuesListOne, GraphElementType.VERTEX, "Any", "Ignore", false);
paramatersTwo = new AdvancedSearchParameters(criteriaValuesListTwo, GraphElementType.VERTEX, "Any", "Ignore", false);
result = paramatersOne.equals(paramatersTwo);
assertEquals(result, false);
ZonedDateTime testTimeOne = ZonedDateTime.now();
ZonedDateTime testTimeTwo = ZonedDateTime.now().plusHours(2);
valueOne = new DateTimeCriteriaValues("datetime", "DateTime", "Occured On", formatDateTime(testTimeOne));
valueTwo = new DateTimeCriteriaValues("datetime", "DateTime", "Occured On", formatDateTime(testTimeTwo));
criteriaValuesListOne.clear();
criteriaValuesListTwo.clear();
criteriaValuesListOne.add(valueOne);
criteriaValuesListTwo.add(valueTwo);
paramatersOne = new AdvancedSearchParameters(criteriaValuesListOne, GraphElementType.TRANSACTION, "Any", "Ignore", false);
paramatersTwo = new AdvancedSearchParameters(criteriaValuesListTwo, GraphElementType.TRANSACTION, "Any", "Ignore", false);
result = paramatersOne.equals(paramatersTwo);
assertEquals(result, false);
}
use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues in project constellation by constellation-app.
the class AdvancedSearchParametersNGTest method populateCriteriaLists.
private void populateCriteriaLists() {
FindCriteriaValues valueOne = new StringCriteriaValues("string", "Identifier", "Is", "one", true, false);
FindCriteriaValues valueTwo = new StringCriteriaValues("string", "Identifier", "Is", "two", true, false);
criteriaValuesListOne.add(valueOne);
criteriaValuesListOne.add(valueTwo);
FindCriteriaValues valueThree = new StringCriteriaValues("string", "Identifier", "Is", "three", true, false);
FindCriteriaValues valueFour = new StringCriteriaValues("string", "Identifier", "Is", "four", true, false);
criteriaValuesListTwo.add(valueThree);
criteriaValuesListTwo.add(valueFour);
}
use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues in project constellation by constellation-app.
the class AdvancedSearchPlugin method searchAsDateTime.
/**
* This function checks to see if a graph elements zoned date time attribute
* matches the criteria specified by the DateTimeCriteriaValues.
*
* @param values the date time criteriaValues
* @param attributeInt the int of the attribute
* @param currElement the currentElement
* @param graph the current graph
* @return
*/
private boolean searchAsDateTime(final FindCriteriaValues values, final int attributeInt, final int currElement, final GraphWriteMethods graph) {
final DateTimeCriteriaValues dateTimeValues = (DateTimeCriteriaValues) values;
String dateTimeString = graph.getStringValue(attributeInt, currElement);
boolean matches = false;
if (dateTimeString == null || dateTimeValues.getDateTimeStringPrimaryValue().isEmpty()) {
if ("Didn't Occur On".equals(dateTimeValues.getFilter())) {
matches = true;
}
return matches;
}
// convert the string date time into a zonedDateTime for comparisons
final String[] splitDateTime = dateTimeValues.getDateTimeStringPrimaryValue().split(" ");
final String parseFormatedString = splitDateTime[0] + "T" + splitDateTime[1] + splitDateTime[2];
final ZonedDateTime valueDateTime = ZonedDateTime.parse(parseFormatedString);
// convert the string date time into a zonedDateTime for comparisons
final String[] splitAttributeDateTime = dateTimeString.split(" ");
final String parseAttributeFormatedString = splitAttributeDateTime[0] + "T" + splitAttributeDateTime[1] + splitAttributeDateTime[2];
final ZonedDateTime attributeDateTime = ZonedDateTime.parse(parseAttributeFormatedString);
/**
* This switch handles the matching check based on the filter choice by
* the user. It checks the users date time values against the attributes
* date time values
*/
switch(dateTimeValues.getFilter()) {
case "Occured On":
if (valueDateTime.isEqual(attributeDateTime)) {
matches = true;
}
break;
case "Didn't Occur On":
if (!valueDateTime.isEqual(attributeDateTime)) {
matches = true;
}
break;
case "Occured Before":
if (!valueDateTime.isBefore(attributeDateTime)) {
matches = true;
}
break;
case "Occured After":
if (!valueDateTime.isAfter(attributeDateTime)) {
matches = true;
}
break;
case "Occured Between":
if (dateTimeValues.getDateTimeStringSecondaryValue().isEmpty()) {
return matches;
}
final String[] splitDateTimeTwo = dateTimeValues.getDateTimeStringSecondaryValue().split(" ");
final String parseFormatedStringTwo = splitDateTimeTwo[0] + "T" + splitDateTimeTwo[1] + splitDateTimeTwo[2];
final ZonedDateTime valueDateTimeTwo = ZonedDateTime.parse(parseFormatedStringTwo);
if (attributeDateTime.isAfter(valueDateTime) && attributeDateTime.isBefore(valueDateTimeTwo)) {
matches = true;
}
if (attributeDateTime.isAfter(valueDateTimeTwo) && attributeDateTime.isBefore(valueDateTime)) {
matches = true;
}
break;
}
return matches;
}
Aggregations