Search in sources :

Example 1 with ColourCriteriaValues

use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues in project constellation by constellation-app.

the class AdvancedSearchParameters method equals.

/**
 * This checks equality between 2 AdvancedSearchParamter objects. It needs
 * to check every attribute to determine true equality.
 *
 * @param object
 * @return
 */
@Override
public boolean equals(final Object object) {
    int matches = 0;
    if (object == null || getClass() != object.getClass()) {
        return false;
    }
    final AdvancedSearchParameters parameters = (AdvancedSearchParameters) object;
    if (searchAllGraphs == parameters.isSearchAllGraphs()) {
        matches++;
    }
    if (graphElementType.equals(parameters.getGraphElementType())) {
        matches++;
    }
    if (allOrAny.equals(parameters.getAllOrAny())) {
        matches++;
    }
    if (currentSelection == parameters.getCurrentSelection()) {
        matches++;
    }
    // if the size is the same to the new object. continue
    int i = 0;
    if (criteriaValuesList.size() == parameters.getCriteriaValuesList().size()) {
        // for each value in the criteriaValuesList
        for (FindCriteriaValues values : criteriaValuesList) {
            // if the two objects have different attributes return false
            if (!values.getAttribute().equals(parameters.getCriteriaValuesList().get(i).getAttribute()) || !values.getAttributeType().equals(parameters.getCriteriaValuesList().get(i).getAttributeType()) || !values.getFilter().equals(parameters.getCriteriaValuesList().get(i).getFilter())) {
                return false;
            }
            // if the two objects attributeType is the same. continue
            if (values.getAttributeType().equals(parameters.getCriteriaValuesList().get(i).getAttributeType())) {
                // for the object comparion all values must be identical
                switch(values.getAttributeType()) {
                    // treat values as strings
                    case StringAttributeDescription.ATTRIBUTE_NAME:
                        StringCriteriaValues stringParameterValues = (StringCriteriaValues) values;
                        StringCriteriaValues stringActualValues = (StringCriteriaValues) parameters.getCriteriaValuesList().get(i);
                        if (!stringParameterValues.isIgnoreCase() == stringActualValues.isIgnoreCase() || !stringParameterValues.isUseList() == stringActualValues.isUseList() || (!stringActualValues.isUseList() && !stringParameterValues.getText().equals(stringActualValues.getText())) || (stringActualValues.isUseList() && !stringParameterValues.getTextList().equals(stringActualValues.getTextList()))) {
                            return false;
                        }
                        break;
                    // treat values as floats
                    case FloatAttributeDescription.ATTRIBUTE_NAME:
                        FloatCriteriaValues floatParameterValues = (FloatCriteriaValues) values;
                        FloatCriteriaValues floatActualValues = (FloatCriteriaValues) parameters.getCriteriaValuesList().get(i);
                        if (floatParameterValues.getFloatValuePrimary() != floatActualValues.getFloatValuePrimary() || floatParameterValues.getFloatValueSecondary() != floatActualValues.getFloatValueSecondary()) {
                            return false;
                        }
                        break;
                    // treat values as booleans
                    case BooleanAttributeDescription.ATTRIBUTE_NAME:
                        BooleanCriteriaValues boolParameterValues = (BooleanCriteriaValues) values;
                        BooleanCriteriaValues boolActualValues = (BooleanCriteriaValues) parameters.getCriteriaValuesList().get(i);
                        if (boolParameterValues.getBoolValue() != boolActualValues.getBoolValue()) {
                            return false;
                        }
                        break;
                    // treat values as colors
                    case ColorAttributeDescription.ATTRIBUTE_NAME:
                        ColourCriteriaValues colourParameterValues = (ColourCriteriaValues) values;
                        ColourCriteriaValues colourActualValues = (ColourCriteriaValues) parameters.getCriteriaValuesList().get(i);
                        if (!colourParameterValues.getColorValue().equals(colourActualValues.getColorValue())) {
                            return false;
                        }
                        break;
                    // treat values as dateTimes
                    case ZonedDateTimeAttributeDescription.ATTRIBUTE_NAME:
                        DateTimeCriteriaValues dateTimeParameterValues = (DateTimeCriteriaValues) values;
                        DateTimeCriteriaValues dateTimeActualValues = (DateTimeCriteriaValues) parameters.getCriteriaValuesList().get(i);
                        if (!dateTimeParameterValues.getDateTimeStringPrimaryValue().equals(dateTimeActualValues.getDateTimeStringPrimaryValue()) || !dateTimeParameterValues.getDateTimeStringSecondaryValue().equals(dateTimeActualValues.getDateTimeStringSecondaryValue())) {
                            return false;
                        }
                        break;
                    // treat values as icons
                    case IconAttributeDescription.ATTRIBUTE_NAME:
                        IconCriteriaValues iconParameterValues = (IconCriteriaValues) values;
                        IconCriteriaValues iconActualValues = (IconCriteriaValues) parameters.getCriteriaValuesList().get(i);
                        if (!iconParameterValues.getIconValue().equals(iconActualValues.getIconValue())) {
                            return false;
                        }
                        break;
                    default:
                        break;
                }
            }
            i++;
        }
    } else {
        return false;
    }
    /**
     * matches will == 4 if all criteria of object a is the same as object
     * b. It will return false if there is any criteria that doesn't match
     */
    return matches == 4;
}
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) 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) StringCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues) FloatCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues)

Example 2 with ColourCriteriaValues

use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues in project constellation by constellation-app.

the class AdvancedSearchPluginNGTest method testEdit.

/**
 * Test of edit method, of class AdvancedSearchPlugin.
 */
@Test
public void testEdit() throws Exception {
    System.out.println("edit");
    setupGraph();
    GraphElementType elementType = GraphElementType.VERTEX;
    final String all = "All";
    final String any = "Any";
    final String ignore = "Ignore";
    final String addTo = "Add To";
    final String removeFrom = "Remove From";
    final String findIn = "Find In";
    boolean searchAllGraphs = false;
    // STRING | VERTEX | MATCH ANY CRITERIA | INGORE CURRENT SELECTION | SEARCH 1 GRAPH
    // Is
    List<FindCriteriaValues> findCriteriaValuesList = new ArrayList<>();
    StringCriteriaValues stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    AdvancedSearchParameters parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    AdvancedSearchPlugin advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    ReadableGraph rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is not
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is Not", "identifer name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Contains
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Contains", "identifer", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Doesn't Contain
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Doesn't Contain", "identifer", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Begins With
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Begins With", "iden", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Ends With
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Ends With", "name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Matches (Regex)
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Matches (Regex)", "den", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Float
    // Is
    findCriteriaValuesList = new ArrayList<>();
    FloatCriteriaValues floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is", 1);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Not
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Not", 1);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Is Less Than
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Less Than", 4);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Greater Than
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Greater Than", 0);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Between
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Between", 0, 4);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Boolean
    // Is
    findCriteriaValuesList = new ArrayList<>();
    BooleanCriteriaValues booleanCriteriaValue = new BooleanCriteriaValues("boolean", "dim", "Is", true);
    findCriteriaValuesList.add(booleanCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Constellation Color
    // Is
    findCriteriaValuesList = new ArrayList<>();
    ColourCriteriaValues colourCriteriaValue = new ColourCriteriaValues("color", "color", "Is", ConstellationColor.BLUE);
    findCriteriaValuesList.add(colourCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Not
    findCriteriaValuesList = new ArrayList<>();
    colourCriteriaValue = new ColourCriteriaValues("color", "color", "Is Not", ConstellationColor.BLUE);
    findCriteriaValuesList.add(colourCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Constellation Icon
    // Is
    findCriteriaValuesList = new ArrayList<>();
    IconCriteriaValues iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
    findCriteriaValuesList.add(iconCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Not
    findCriteriaValuesList = new ArrayList<>();
    iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is Not", IconManager.getIcon("Flag.Australia"));
    findCriteriaValuesList.add(iconCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // DateTime
    // Occured On
    findCriteriaValuesList = new ArrayList<>();
    DateTimeCriteriaValues dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured On", formatDateTime(testTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    elementType = GraphElementType.TRANSACTION;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    LOG.log(Level.SEVERE, dateTimeCriteriaValue.getDateTimeStringPrimaryValue());
    LOG.log(Level.SEVERE, dateTimeCriteriaValue.getDateTimeStringPrimaryValue());
    LOG.log(Level.SEVERE, rg.getObjectValue(dateTimeT, txId1).toString());
    assertEquals(rg.getBooleanValue(selectedT, txId1), true);
    assertEquals(rg.getBooleanValue(selectedT, txId2), true);
    assertEquals(rg.getBooleanValue(selectedT, txId3), false);
    assertEquals(rg.getBooleanValue(selectedT, txId4), false);
    rg.close();
    // Didn't Occur On
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Didn't Occur On", formatDateTime(testTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), false);
    assertEquals(rg.getBooleanValue(selectedT, txId2), false);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), true);
    rg.close();
    // Occured Before
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured Before", formatDateTime(plus1YearTestTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), true);
    assertEquals(rg.getBooleanValue(selectedT, txId2), true);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), false);
    rg.close();
    // Occured After
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured After", formatDateTime(plus1YearTestTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), false);
    assertEquals(rg.getBooleanValue(selectedT, txId2), false);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), true);
    rg.close();
    // Occured Between
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured Between", formatDateTime(testTime), formatDateTime(plus2YearTestTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), false);
    assertEquals(rg.getBooleanValue(selectedT, txId2), false);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), false);
    rg.close();
    // Test multiple criteria (any)
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
    iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
    findCriteriaValuesList.add(stringCriteriaValue1);
    findCriteriaValuesList.add(iconCriteriaValue);
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId6), false);
    rg.close();
    // Test multiple criteria (any)
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "a vertex", true, false);
    iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.England"));
    findCriteriaValuesList.add(stringCriteriaValue1);
    findCriteriaValuesList.add(iconCriteriaValue);
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, all, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
    rg.close();
    // Test find next
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    rg.close();
    // Test find prev
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    // Test add to
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, addTo, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    WritableGraph wg = graph.getWritableGraph("", true);
    wg.setBooleanValue(selectedV, vxId6, true);
    wg.setBooleanValue(selectedV, vxId7, true);
    wg.commit();
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId7), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    rg.close();
    // Test Remove From
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, removeFrom, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    // all but vxId6 match the criteria, so vxId6 remains selected
    assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    // Test Find In
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, findIn, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    wg = graph.getWritableGraph("", true);
    wg.setBooleanValue(selectedV, vxId1, true);
    wg.setBooleanValue(selectedV, vxId2, true);
    wg.commit();
    rg = graph.getReadableGraph();
    // vxId3 is not selected so will not be considered in the
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ArrayList(java.util.ArrayList) ColourCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues) DateTimeCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.DateTimeCriteriaValues) AdvancedSearchParameters(au.gov.asd.tac.constellation.views.find2.components.advanced.utilities.AdvancedSearchParameters) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StringCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues) FloatCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues) FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) IconCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.IconCriteriaValues) BooleanCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.BooleanCriteriaValues) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 3 with ColourCriteriaValues

use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues 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 4 with ColourCriteriaValues

use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues 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 5 with ColourCriteriaValues

use of au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues in project constellation by constellation-app.

the class AdvancedSearchPlugin method searchAsColor.

/**
 * This function checks to see if a graph elements color attribute matches
 * the criteria specified by the ColourCriteriaValues.
 *
 * @param values the color criteriaValues
 * @param attributeInt the int of the attribute
 * @param currElement the currentElement
 * @param graph the current graph
 * @return
 */
private boolean searchAsColor(final FindCriteriaValues values, final int attributeInt, final int currElement, final GraphWriteMethods graph) {
    final ColourCriteriaValues colorValues = (ColourCriteriaValues) values;
    final ConstellationColor color = graph.getObjectValue(attributeInt, currElement);
    boolean matches = false;
    // if the color of the attribute matches the users color matches = true
    if (colorValues.getFilter().equals(IS) && colorValues.getColorValue().equals(color)) {
        matches = true;
    // if the color of the attribute doesnt match the users color matches = true
    } else if (colorValues.getFilter().equals(IS_NOT) && !colorValues.getColorValue().equals(color)) {
        matches = true;
    }
    return matches;
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) ColourCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues)

Aggregations

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