use of se.light.assembly64.service.SearchService in project assembly64fx by freabemania.
the class SearchController method init.
public void init(Artifact searchEntry) throws Exception {
localDb = LocalDBService.getInstance();
userService = UserService.getInstance();
searchService = SearchService.getInstance();
mappingService = CategoryMappingService.getInstance();
// populate years
table.setPlaceholder(new Label(""));
yearInput.getItems().add(ALL);
IntStream.range(1980, Calendar.getInstance().get(Calendar.YEAR) + 1).forEach(item -> yearInput.getItems().add(String.valueOf(item)));
yearInput.getSelectionModel().selectFirst();
// populate ratings
ratingInput.getItems().add(ALL);
IntStream.range(1, 10).forEach(item -> ratingInput.getItems().add(String.valueOf(item)));
ratingInput.getSelectionModel().selectFirst();
categoryInput.getItems().add(ALL);
List<CategoryMapping> l = new ArrayList<CategoryMapping>(mappingService.values());
Collections.sort(l, (i1, i2) -> i1.getDescription().toLowerCase().compareTo(i2.getDescription().toLowerCase()));
l.stream().forEach(item -> categoryInput.getItems().add(item.getDescription()));
if (searchEntry != null) {
try {
CategoryMapping categoryMappingByName = mappingService.getCategoryMappingByName(searchEntry.getDatabaseId());
categoryInput.getSelectionModel().select(categoryMappingByName.getDescription());
} catch (Exception e) {
categoryInput.getSelectionModel().selectFirst();
}
} else {
categoryInput.getSelectionModel().selectFirst();
}
name.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("name"));
group.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("group"));
year.setCellValueFactory(new PropertyValueFactory<SearchResultItem, Integer>("year"));
handle.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("handle"));
event.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("event"));
group.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("group"));
rating.setCellValueFactory(new PropertyValueFactory<SearchResultItem, Integer>("rating"));
category.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("categoryName"));
updated.setCellValueFactory(new PropertyValueFactory<SearchResultItem, String>("updated"));
EventHandler<MouseEvent> mouseEventHandle = (MouseEvent event) -> {
handleMouseClicked(event);
};
table.setOnKeyTyped(event -> {
if (event.getCharacter().length() > 0 && event.getCharacter().charAt(0) == ENTER_KEY) {
openFiles();
}
});
table.addEventHandler(MouseEvent.MOUSE_PRESSED, mouseEventHandle);
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
registerSearchOnEnter(nameInput);
registerSearchOnEnter(groupInput);
registerSearchOnEnter(handleInput);
registerSearchOnEnter(eventInput);
registerChoice(yearInput);
registerChoice(categoryInput);
registerChoice(ratingInput);
checkCheckbox(t64, T64SEARCH);
checkCheckbox(d64, D64SEARCH);
checkCheckbox(d71, T71SEARCH);
checkCheckbox(d81, T81SEARCH);
checkCheckbox(prg, PRGSEARCH);
checkCheckbox(tap, TAPSEARCH);
checkCheckbox(crt, CRTSEARCH);
checkCheckbox(bin, BINSEARCH);
checkCheckbox(sid, SIDSEARCH);
checkCheckbox(g64, G64SEARCH);
searchPeriod.setItems(FXCollections.observableArrayList(SEARCH_PERIOD.ALL, SEARCH_PERIOD.ONE_DAY, SEARCH_PERIOD.TWO_DAYS, SEARCH_PERIOD.FOUR_DAYS, SEARCH_PERIOD.ONE_WEEK, SEARCH_PERIOD.TWO_WEEKS, SEARCH_PERIOD.THREE_WEEKS, SEARCH_PERIOD.ONE_MONTH, SEARCH_PERIOD.TWO_MONTHS));
searchPeriod.getSelectionModel().select(0);
try {
searchPeriod.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends SEARCH_PERIOD> observable, SEARCH_PERIOD oldValue, SEARCH_PERIOD newValue) -> performSearch());
} catch (Exception e) {
logger.error("Unable to install listener", e);
}
registerCheckboxChangeForSearch(t64, T64SEARCH);
registerCheckboxChangeForSearch(d64, D64SEARCH);
registerCheckboxChangeForSearch(d71, T71SEARCH);
registerCheckboxChangeForSearch(d81, T81SEARCH);
registerCheckboxChangeForSearch(prg, PRGSEARCH);
registerCheckboxChangeForSearch(tap, TAPSEARCH);
registerCheckboxChangeForSearch(crt, CRTSEARCH);
registerCheckboxChangeForSearch(bin, BINSEARCH);
registerCheckboxChangeForSearch(sid, SIDSEARCH);
registerCheckboxChangeForSearch(g64, G64SEARCH);
searchFromStartOfString.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
ExecutorUtil.executeAsyncWithRetry(() -> {
localDb.addLocalDBSetting("search_from_start", String.valueOf(newVal));
return null;
});
}
});
String val = localDb.getLocalDBSetting("search_from_start");
if (val != null) {
searchFromStartOfString.setSelected(Boolean.valueOf(val));
} else {
searchFromStartOfString.setSelected(true);
}
if (!userService.isLocationSelectedAndExisting()) {
downloadFolderImage.setVisible(false);
}
}
use of se.light.assembly64.service.SearchService in project vind by RBMHTechnology.
the class SearchApplication method main.
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JavaTimeModule());
try (SearchService searchService = new SearchService()) {
// index
searchService.index();
// search
SearchResult result = searchService.news("vind");
System.out.println(mapper.writeValueAsString(result));
}
}
use of se.light.assembly64.service.SearchService in project vind by RBMHTechnology.
the class SearchApplication method main.
public static void main(String[] args) {
try (SearchService search = new SearchService(args[0])) {
get("/index", (req, res) -> search.index());
Spark.get("/search", (req, res) -> search.search(req.queryParams("q"), req.queryParamsValues("filter")), new ResultTransformer());
get("/news", (req, res) -> search.search(req.queryParams("q"), Integer.parseInt(StringUtils.defaultIfBlank(req.queryParams("p"), "1")), SearchService.Sort.pares(req.queryParams("sort"))), new ResultTransformer());
get("/suggest", (req, res) -> search.suggest(req.queryParams("q")), new ResultTransformer());
// of the core is deleted.
while (true) {
}
}
}
use of se.light.assembly64.service.SearchService in project vind by RBMHTechnology.
the class SearchApplication method main.
public static void main(String[] args) {
try (SearchService searchService = new SearchService()) {
// index
searchService.index();
// search
SearchResult result = searchService.search("vind", 1);
System.out.println(result);
}
}
Aggregations