Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #24 from academic/feature/additional-filters
Browse files Browse the repository at this point in the history
Feature/additional filters
  • Loading branch information
Hüseyin Mert authored Feb 24, 2018
2 parents ec598fb + 1082350 commit 76c75ee
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 125 deletions.
11 changes: 10 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,16 @@
<version>4.0.0</version>
</dependency>

</dependencies>
<!-- https://mvnrepository.com/artifact/de.dnb/oaiharvester -->
<dependency>
<groupId>de.dnb</groupId>
<artifactId>oaiharvester</artifactId>
<version>3.0.0</version>
</dependency>



</dependencies>

<build>
<plugins>
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/io/academic/controller/SearchController.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.academic.controller;

import io.academic.service.AcademicSearchService;
import io.academic.service.OaiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

Expand All @@ -16,21 +13,27 @@
@RestController
@RequestMapping("/api/elastic")
public class SearchController {
private final OaiService service;
private final AcademicSearchService service;

@Autowired
public SearchController(OaiService service) {
public SearchController(AcademicSearchService service) {
this.service = service;
}

@RequestMapping(method = GET, value = "/_search")
public String search(@RequestParam(value= "q") String term) throws IOException {
return service.search(term);
return service.searchPretty(term);
}

@RequestMapping(method = GET)
public String allData(@RequestParam(defaultValue = "") String query) throws IOException {
return service.getAll();
return service.getAllPretty();
}

//search doing by article criterias such as authors,body,date, keywords, publisher, title
@RequestMapping(method = GET, value = "/_search/{criteria}")
public @ResponseBody String searchByCriteria(@RequestParam(value= "q") String term, @PathVariable(value = "criteria") String criteria) throws IOException {
return service.searchPrettyByCriteria(term,criteria);
}


Expand Down
22 changes: 17 additions & 5 deletions src/main/java/io/academic/controller/SearchformController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import io.academic.dao.SearchDao;
import io.academic.service.AcademicSearchService;
import io.academic.service.OaiService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
Expand All @@ -15,9 +16,9 @@
@Controller
public class SearchformController {

private final OaiService service;
private final AcademicSearchService service;

public SearchformController(OaiService service) {
public SearchformController(AcademicSearchService service) {
this.service = service;
}

Expand All @@ -31,9 +32,20 @@ public String searchForm(Model model) {
@PostMapping("/searchform")
public String greetingSubmit(@ModelAttribute SearchDao searchDao) throws IOException {
System.out.println("inside post");
System.out.println(searchDao.getValue());
System.out.println(service.searchForm(searchDao.getValue()));
searchDao.setResult(service.searchForm(searchDao.getValue()));
String value = searchDao.getValue();
String result = "";
String criteria = searchDao.getCriteria();
if (criteria.equals("all"))
{
result = service.searchForm(searchDao.getValue());
}
else
{
result = service.searchFormByCriteria(searchDao.getValue(),criteria);
}
System.out.println(value);
System.out.println(result);
searchDao.setResult(result);
return "searchresult";
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/academic/dao/SearchDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class SearchDao {


private String value;
private String criteria;
private String result;

public String getValue() {
Expand All @@ -14,6 +15,13 @@ public void setValue(String value) {
this.value = value;
}

public String getCriteria() {
return criteria;
}

public void setCriteria(String criteria) {
this.criteria = criteria;
}

public String getResult() {
return result;
Expand Down
52 changes: 42 additions & 10 deletions src/main/java/io/academic/entity/Article.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.persistence.Entity;
import javax.persistence.Table;


@Table(name = "articles")
@Entity
public class Article extends AbstractAuditingEntity {
Expand All @@ -30,48 +31,79 @@ public class Article extends AbstractAuditingEntity {
@Type(type = "text")
private String dc;

@Column
@Type(type = "text")
private String publisher;

@Column
@Type(type = "text")
private String date;

@Column
@Type(type = "text")
private String type;

public String getTitle() {
return title;
}

public Article setTitle(String title) {
public void setTitle(String title) {
this.title = title;
return this;
}

public String getBody() {
return body;
}

public Article setBody(String body) {
public void setBody(String body) {
this.body = body;
return this;
}

public String getKeywords() {
return keywords;
}

public Article setKeywords(String keywords) {
public void setKeywords(String keywords) {
this.keywords = keywords;
return this;
}

public String getAuthors() {
return authors;
}

public Article setAuthors(String authors) {
public void setAuthors(String authors) {
this.authors = authors;
return this;
}

public String getDc() {
return dc;
}

public Article setDc(String dc) {
public void setDc(String dc) {
this.dc = dc;
return this;
}

public String getPublisher() {
return publisher;
}

public void setPublisher(String publisher) {
this.publisher = publisher;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
2 changes: 2 additions & 0 deletions src/main/java/io/academic/entity/ArticleRepository.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.academic.entity;

import org.elasticsearch.action.search.*;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
Expand All @@ -9,4 +10,5 @@ public interface ArticleRepository extends PagingAndSortingRepository<Article, U

List<Article> findByTitle(String title);


}
Loading

0 comments on commit 76c75ee

Please sign in to comment.