Search in sources :

Example 16 with FindCriteriaValues

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);
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) GridPane(javafx.scene.layout.GridPane) AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) ArrayList(java.util.ArrayList) ColourCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 17 with FindCriteriaValues

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");
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) GridPane(javafx.scene.layout.GridPane) AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) ArrayList(java.util.ArrayList) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StringCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues) Test(org.testng.annotations.Test)

Example 18 with FindCriteriaValues

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);
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) IconCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.IconCriteriaValues) ZonedDateTime(java.time.ZonedDateTime) ColourCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues) BooleanCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.BooleanCriteriaValues) DateTimeCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.DateTimeCriteriaValues) FloatCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues) Test(org.testng.annotations.Test)

Example 19 with FindCriteriaValues

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);
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) StringCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues)

Example 20 with FindCriteriaValues

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;
}
Also used : ZonedDateTime(java.time.ZonedDateTime) DateTimeCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.DateTimeCriteriaValues)

Aggregations

FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)15 ArrayList (java.util.ArrayList)11 Test (org.testng.annotations.Test)11 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)9 StringCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues)9 BooleanCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.BooleanCriteriaValues)5 ColourCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues)5 FloatCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues)5 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)4 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)4 StringCriteriaPanel (au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel)4 DateTimeCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.DateTimeCriteriaValues)4 IconCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.IconCriteriaValues)4 AdvancedSearchParameters (au.gov.asd.tac.constellation.views.find2.components.advanced.utilities.AdvancedSearchParameters)4 GridPane (javafx.scene.layout.GridPane)4 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)3 ChoiceBox (javafx.scene.control.ChoiceBox)3 ZonedDateTime (java.time.ZonedDateTime)2 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)1