Search in sources :

Example 6 with Factoid

use of retrospector.model.Factoid in project Retrospector by NonlinearFruit.

the class QueryProcessor method toSearchable.

private static List<String> toSearchable(Media media) {
    List<String> searchables = new ArrayList<>();
    searchables.addAll(Arrays.asList(media.getTitle().toLowerCase(), media.getCreator().toLowerCase(), media.getSeasonId().toLowerCase(), media.getEpisodeId().toLowerCase(), media.getCategory().toLowerCase()));
    for (Factoid fact : media.getFactoids()) {
        searchables.add(fact.getContent().toLowerCase());
    }
    return searchables;
}
Also used : ArrayList(java.util.ArrayList) Factoid(retrospector.model.Factoid)

Example 7 with Factoid

use of retrospector.model.Factoid in project Retrospector by NonlinearFruit.

the class SearchTabController method isMatchForMedia.

private boolean isMatchForMedia(String query, Media media) {
    boolean pass = true;
    if (query.endsWith("|") && !query.endsWith("||"))
        query = query.substring(0, query.length() - 1);
    String[] queries = query.toLowerCase().split(":");
    List<String> searchables = new ArrayList<>();
    searchables.addAll(Arrays.asList(media.getTitle().toLowerCase(), media.getCreator().toLowerCase(), media.getSeasonId().toLowerCase(), media.getEpisodeId().toLowerCase(), media.getCategory().toLowerCase()));
    for (Factoid fact : media.getFactoids()) {
        searchables.add(fact.getContent().toLowerCase());
    }
    for (String q : queries) {
        String[] optns = q.split("\\|\\|");
        boolean minorPass = false;
        for (String optn : optns) {
            boolean negator = optn.length() > 1 && optn.startsWith("!");
            if (!negator && searchables.stream().anyMatch(s -> s.contains(optn)))
                minorPass = true;
            if (negator && !searchables.stream().anyMatch(s -> s.contains(optn.substring(1))))
                minorPass = true;
        }
        if (!minorPass) {
            pass = false;
        }
    }
    return pass;
}
Also used : Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) URL(java.net.URL) ButtonType(javafx.scene.control.ButtonType) Factoid(retrospector.model.Factoid) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) Media(retrospector.model.Media) Application(javafx.application.Application) BigDecimal(java.math.BigDecimal) Parent(javafx.scene.Parent) ResourceBundle(java.util.ResourceBundle) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) FXMLLoader(javafx.fxml.FXMLLoader) QuickEntryController(retrospector.fxml.QuickEntryController) NaturalOrderComparator(retrospector.util.NaturalOrderComparator) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) SortedList(javafx.collections.transformation.SortedList) Alert(javafx.scene.control.Alert) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Review(retrospector.model.Review) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) TableRow(javafx.scene.control.TableRow) FilteredList(javafx.collections.transformation.FilteredList) TAB(retrospector.fxml.CoreController.TAB) FXML(javafx.fxml.FXML) Text(javafx.scene.text.Text) List(java.util.List) Stage(javafx.stage.Stage) MenuButton(javafx.scene.control.MenuButton) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) DataManager(retrospector.model.DataManager) ArrayList(java.util.ArrayList) Factoid(retrospector.model.Factoid)

Aggregations

Factoid (retrospector.model.Factoid)7 ArrayList (java.util.ArrayList)4 Media (retrospector.model.Media)4 Review (retrospector.model.Review)4 URL (java.net.URL)3 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ResourceBundle (java.util.ResourceBundle)3 ObjectProperty (javafx.beans.property.ObjectProperty)3 ObservableList (javafx.collections.ObservableList)3 FXML (javafx.fxml.FXML)3 Initializable (javafx.fxml.Initializable)3 XYChart (javafx.scene.chart.XYChart)3 Text (javafx.scene.text.Text)3 TAB (retrospector.fxml.CoreController.TAB)3 DataManager (retrospector.model.DataManager)3 LocalDate (java.time.LocalDate)2 ChronoUnit (java.time.temporal.ChronoUnit)2 HashSet (java.util.HashSet)2