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 #19 from academic/feature/oai-endpoint
Browse files Browse the repository at this point in the history
Feature/oai endpoint
  • Loading branch information
Hüseyin Mert authored Feb 1, 2018
2 parents 22d11d7 + 70c434f commit 2d6676e
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
<version>2.7</version>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.0.0</version>
</dependency>

</dependencies>

<build>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/academic/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.academic.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.academic.controller;


import io.academic.dao.OaiDataProviderDao;
import io.academic.dao.SearchDao;
import io.academic.entity.OaiDataProvider;
import io.academic.entity.OaiDataProviderRepository;
import io.academic.service.OaiDataProviderService;
import io.academic.service.OaiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;

import java.io.IOException;
import java.util.List;


@Controller
public class DataproviderformController {

private OaiDataProviderService oaiDataProviderService;
@Autowired
private OaiDataProviderRepository oaiDataProviderRepository;

public DataproviderformController(OaiDataProviderService oaiDataProviderService) {
this.oaiDataProviderService=oaiDataProviderService;
}


@GetMapping("/dataproviderform")
public String addForm(ModelMap modelMap) {
modelMap.addAttribute("dataproviderForm", new OaiDataProviderDao());
return "dataproviderform";
}

@PostMapping("/dataproviderform")
public String greetingSubmit(Model model, @ModelAttribute("dataproviderForm")OaiDataProviderDao oaiDataProviderDao) throws IOException {

System.out.println(oaiDataProviderDao.getName());
System.out.println(oaiDataProviderDao.getUrl());
System.out.println(oaiDataProviderDao.getIdentifier());
oaiDataProviderService.queue(oaiDataProviderDao);
model.addAttribute("oaiDataProviderDao",oaiDataProviderDao);
Page<OaiDataProvider>providers= oaiDataProviderRepository.findAll(new PageRequest(0,10));
model.addAttribute("providers",providers);
return "dataproviderresult";
}



}
17 changes: 16 additions & 1 deletion src/main/java/io/academic/dao/OaiDataProviderDao.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.academic.dao;

public class OaiDataProviderDao {
import io.academic.entity.OaiDataProviderRepository;

public class OaiDataProviderDao {

private String name;
private String url;
Expand Down Expand Up @@ -35,4 +37,17 @@ public String getIdentifier() {
}


public void setName(String name) {
this.name = name;
}

public void setUrl(String url) {
this.url = url;
}

public void setIdentifier(String identifier) {
this.identifier = identifier;
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.academic.entity;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
Expand All @@ -10,6 +13,6 @@ public interface OaiDataProviderRepository extends PagingAndSortingRepository<Oa

List<OaiDataProvider> findByName(String name);



@Override
Page<OaiDataProvider> findAll(Pageable pageable);
}
9 changes: 5 additions & 4 deletions src/main/java/io/academic/service/ProcessorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ public void startProcessors() {

// oaiDataProviderService.queue(new OaiDataProvider("Acta Medica Anatolia","http://dergipark.gov.tr/api/public/oai/","dergipark.ulakbim.gov.tr" ));
// oaiDataProviderService.queue(new OaiDataProvider("http://export.arxiv.org/oai2"));
try {
oaiService.delete();
} catch (IOException e) {
e.printStackTrace();
}

}

public boolean submitUrl(String url) throws InterruptedException {
return urlProcessor.submit(url);
}

// public boolean submitDataProvider(OaiDataProviderDao oai) throws InterruptedException {
// return oaiDataProviderProcessor.submit(oai);
//
// }



Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/templates/dataproviderform.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
<head>
<title>OAI Data Provider Adding Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Bootstrap -->
<link href="webjars/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> </link>
</head>
<body>
<h1>OAI Data Provider Adding Form</h1>
<form action="#" th:action="@{/dataproviderform}" th:object="${dataproviderForm}" method="post">
<p>Search: <input type="text" th:field="*{value}" /></p>
<p>Name of Data Provider: <input type="text" th:field="*{name}" /></p>
<p>URL of Data Provider : <input type="text" th:field="*{url}" /></p>
<p>Identifier of Data Provider: <input type="text" th:field="*{identifier}" /></p>
<p><input type="submit" value="Add" /> <input type="reset" value="Reset" /></p>
</form>

<script src="webjars/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions src/main/resources/templates/dataproviderresult.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Data Provider List</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Bootstrap -->
<link href="webjars/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> </link>
</head>
<body>
<h1>Data Provider Added</h1>
<p th:text="'name: ' + ${oaiDataProviderDao.name}"/>
<p th:text="'url: ' + ${oaiDataProviderDao.url}"/>
<p th:text="'identifier: ' + ${oaiDataProviderDao.identifier}"/>
<a href="/dataproviderform">Submit another data provider</a>
<h1>Current Data Provider List</h1>
<div>
<table class="table table-striped">
<caption >Current Data Provider List</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col" >First URL</th>
<th scope="col">Identifier</th>
</tr>
</thead>
<tbody>
<tr th:each="provider : ${providers}">
<td th:text="${provider.name}">Name ...</td>
<td><a href="${provider.url}" th:text="${provider.url}">URL ...</a></td>
<td th:text="${provider.identifier}">Identifier ...</td>
</tr>
</tbody>
</table>
</div>
<script src="webjars/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions src/main/resources/templates/searchform.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
<head>
<title>OAI Harvester Search Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Bootstrap -->
<link href="webjars/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> </link>
</head>
<body>
<h1>OAI Harvester Search Form</h1>
<form action="#" th:action="@{/searchform}" th:object="${searchForm}" method="post">
<p>Search: <input type="text" th:field="*{value}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
<script src="webjars/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion src/main/resources/templates/searchresult.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
<head>
<title>Search Result</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Bootstrap -->
<link href="webjars/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> </link>
</head>
<body>
<h1>Result</h1>
<p th:text="'value: ' + ${searchDao.value}"/>
<a href="/searchform">Search moooore</a>
<pre th:utext="${searchDao.result}"></pre>
<a href="/searchDao">Submit another message</a>
<script src="webjars/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>

0 comments on commit 2d6676e

Please sign in to comment.