Added institution & landingPage to the resource web-service (close #777)
Change-Id: I0f527c4dbf1eb50f3ab105ca95a44e1db689e7cc
diff --git a/Changes b/Changes
index 2011974..cf7213f 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
# version 0.76-SNAPSHOT
+- Add institution & landingPage to the resource web-service (#777)
+
# version 0.75
- Alter role and remove privilege database tables (#763)
diff --git a/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java b/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java
index e8047d3..be84ed9 100644
--- a/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java
+++ b/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java
@@ -62,7 +62,10 @@
resourceDao.createResource(resource.at("/id").asText(),
resource.at("/de_title").asText(),
resource.at("/en_title").asText(),
- resource.at("/en_description").asText(), layers);
+ resource.at("/en_description").asText(),
+ layers,
+ resource.at("/institution").asText(),
+ resource.at("/corpus_query").asText());
}
}
catch (Exception e) {
diff --git a/src/main/java/de/ids_mannheim/korap/dao/ResourceDao.java b/src/main/java/de/ids_mannheim/korap/dao/ResourceDao.java
index 62d3b79..79cfad7 100644
--- a/src/main/java/de/ids_mannheim/korap/dao/ResourceDao.java
+++ b/src/main/java/de/ids_mannheim/korap/dao/ResourceDao.java
@@ -69,13 +69,14 @@
@Transactional
public void createResource (String id, String germanTitle,
String englishTitle, String englishDescription,
- Set<AnnotationLayer> layers) throws KustvaktException {
+ Set<AnnotationLayer> layers, String institution,
+ String corpusQuery) throws KustvaktException {
ParameterChecker.checkStringValue(id, "id");
ParameterChecker.checkStringValue(englishTitle, "en_title");
ParameterChecker.checkStringValue(germanTitle, "de_title");
Resource r = new Resource(id, germanTitle, englishTitle,
- englishDescription, layers);
+ englishDescription, layers, institution, corpusQuery);
entityManager.persist(r);
}
diff --git a/src/main/java/de/ids_mannheim/korap/dto/ResourceDto.java b/src/main/java/de/ids_mannheim/korap/dto/ResourceDto.java
index 27952a6..063861e 100644
--- a/src/main/java/de/ids_mannheim/korap/dto/ResourceDto.java
+++ b/src/main/java/de/ids_mannheim/korap/dto/ResourceDto.java
@@ -21,11 +21,14 @@
private String description;
private String[] languages;
private Map<Integer, String> layers;
+ private String institution;
+ private String landingPage;
@Override
public String toString () {
return "resourceId= " + resourceId + ", description= " + description
+ ", titles= " + titles + ", languages= " + languages
- + ", layers= " + layers;
+ + ", layers= " + layers + ", institution=" + institution
+ + ", landingPage=" + landingPage;
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/dto/converter/ResourceConverter.java b/src/main/java/de/ids_mannheim/korap/dto/converter/ResourceConverter.java
index 0ee0bef..5f13d52 100644
--- a/src/main/java/de/ids_mannheim/korap/dto/converter/ResourceConverter.java
+++ b/src/main/java/de/ids_mannheim/korap/dto/converter/ResourceConverter.java
@@ -48,6 +48,8 @@
layers.put(annotationPair.getId(), code);
}
dto.setLayers(layers);
+ dto.setLandingPage("https://korap.ids-mannheim.de?" +r.getCorpusQuery());
+ dto.setInstitution(r.getInstitution());
resourceDtoList.add(dto);
}
diff --git a/src/main/java/de/ids_mannheim/korap/entity/Resource.java b/src/main/java/de/ids_mannheim/korap/entity/Resource.java
index cd5ba9a..4e9906b 100644
--- a/src/main/java/de/ids_mannheim/korap/entity/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/entity/Resource.java
@@ -38,6 +38,11 @@
@Column(name = "en_description")
private String englishDescription;
+
+ @Column(name = "corpus_query")
+ private String corpusQuery;
+
+ private String institution;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "resource_layer", joinColumns = @JoinColumn(name = "resource_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "layer_id", referencedColumnName = "id"))
@@ -46,19 +51,23 @@
public Resource () {}
public Resource (String id, String germanTitle, String englishTitle,
- String englishDescription, Set<AnnotationLayer> layers) {
+ String englishDescription, Set<AnnotationLayer> layers,
+ String institution, String corpusQuery) {
this.id = id;
this.germanTitle = germanTitle;
this.englishTitle = englishTitle;
this.englishDescription = englishDescription;
this.layers = layers;
+ this.corpusQuery = corpusQuery;
+ this.institution=institution;
}
@Override
public String toString () {
return "id=" + id + ", germanTitle=" + germanTitle + ", englishTitle="
+ englishTitle + ", description=" + englishDescription
- + ", layers= " + layers;
+ + ", layers= " + layers + ", institution=" + institution
+ + ", corpusQuery=" + corpusQuery;
}
}
diff --git a/src/main/resources/db/sqlite/V4.1__resource_alteration.sql b/src/main/resources/db/sqlite/V4.1__resource_alteration.sql
new file mode 100644
index 0000000..20a9aa3
--- /dev/null
+++ b/src/main/resources/db/sqlite/V4.1__resource_alteration.sql
@@ -0,0 +1,5 @@
+ALTER TABLE resource
+ADD COLUMN institution VARCHAR(100) DEFAULT NULL;
+
+ALTER TABLE resource
+ADD COLUMN corpus_query VARCHAR(500) DEFAULT NULL;
\ No newline at end of file
diff --git a/src/main/resources/json/free-resources.json b/src/main/resources/json/free-resources.json
index b41581e..95ee585 100644
--- a/src/main/resources/json/free-resources.json
+++ b/src/main/resources/json/free-resources.json
@@ -10,7 +10,9 @@
"opennlp/p",
"tt/l",
"tt/p"
- ]
+ ],
+ "corpus_query":"corpusSigle=WPD17",
+ "institution" : "Wikimedia Foundation"
},
{
"id": "WDD17",
@@ -24,7 +26,9 @@
"opennlp/p",
"tt/l",
"tt/p"
- ]
+ ],
+ "corpus_query":"corpusSigle=WDD17",
+ "institution" : "Wikimedia Foundation"
},
{
"id": "WUD17",
@@ -38,6 +42,8 @@
"opennlp/p",
"tt/l",
"tt/p"
- ]
+ ],
+ "corpus_query":"corpusSigle=WUD17",
+ "institution" : "Wikimedia Foundation"
}
]
\ No newline at end of file
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/FreeResourceControllerTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/FreeResourceControllerTest.java
index c909064..2343dd7 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/FreeResourceControllerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/FreeResourceControllerTest.java
@@ -19,13 +19,19 @@
Response response = target().path(API_VERSION).path("resource")
.request().get();
String entity = response.readEntity(String.class);
- JsonNode n = JsonUtils.readTree(entity).get(0);
- assertEquals("WPD17", n.at("/resourceId").asText());
- assertEquals("Deutsche Wikipedia Artikel 2017",
- n.at("/titles/de").asText());
- assertEquals("German Wikipedia Articles 2017",
- n.at("/titles/en").asText());
- assertEquals(n.at("/languages").size(), 1);
- assertEquals(n.at("/layers").size(), 6);
+ JsonNode n = JsonUtils.readTree(entity);
+ assertEquals(3, n.size());
+
+ n = n.get(0);
+ assertEquals(n.at("/resourceId").asText(), "WPD17");
+ assertEquals(n.at("/titles/de").asText(),
+ "Deutsche Wikipedia Artikel 2017");
+ assertEquals(n.at("/titles/en").asText(),
+ "German Wikipedia Articles 2017");
+ assertEquals(1, n.at("/languages").size());
+ assertEquals(6, n.at("/layers").size());
+ assertEquals("Wikimedia Foundation", n.at("/institution").asText());
+ assertEquals("https://korap.ids-mannheim.de?corpusSigle=WPD17",
+ n.at("/landingPage").asText());
}
}