first import
This commit is contained in:
parent
4e315b361f
commit
489f2e7363
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
<artifactId>apps</artifactId>
|
||||
<version>3.1.9-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>dnet-directindex</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>${mongodb.driver.version}</version>
|
||||
</dependency>
|
||||
<!-- hot swapping, disable cache for template, enable live reload -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-help-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" ?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet45-parent</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-directindex-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.2.2-SNAPSHOT</version>
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-directindex-api/trunk</developerConnection>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-openaireplus-mapping-utils</artifactId>
|
||||
<version>[6.3.24,7.0.0)</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-hadoop-commons</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-index-client</artifactId>
|
||||
<version>[2.3.4,3.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${springfox-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.9.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>antlr</artifactId>
|
||||
<groupId>antlr</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-tools</artifactId>
|
||||
<version>2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>antlr</artifactId>
|
||||
<groupId>antlr</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<springfox-version>2.5.0</springfox-version>
|
||||
</properties>
|
||||
</project>
|
|
@ -0,0 +1,72 @@
|
|||
package eu.dnetlib.openaire.directindex;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
public class DirectIndexApplication extends AbstractDnetApp {
|
||||
|
||||
@Value("${openaire.api.directindex.mongo.url}")
|
||||
private String mongoUrl;
|
||||
|
||||
@Value("${openaire.api.directindex.mongo.db}")
|
||||
private String mongoDb;
|
||||
|
||||
@Value("${openaire.api.directindex.mongo.collection}")
|
||||
private String mongoColl;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(DirectIndexApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/api/"))
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("OpenAIRE DirectIndex APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoClient mongoClient() {
|
||||
return new MongoClient(mongoUrl);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoDatabase mongoDatabase() {
|
||||
return mongoClient().getDatabase(mongoDb);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoCollection<Document> mongoCollection() {
|
||||
return mongoDatabase().getCollection(mongoColl);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
public class DirectIndexApiException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3888037031334809448L;
|
||||
|
||||
public DirectIndexApiException(final String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public DirectIndexApiException(final String string, final Throwable exception) {
|
||||
super(string, exception);
|
||||
}
|
||||
|
||||
public DirectIndexApiException(final Throwable exception) {
|
||||
super(exception);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.utils.ISLookupClient;
|
||||
|
||||
@Component
|
||||
public class IndexDSRetriever {
|
||||
|
||||
private static final Log log = LogFactory.getLog(IndexDSRetriever.class);
|
||||
|
||||
@Autowired
|
||||
private ISLookupClient lookupClient;
|
||||
|
||||
@Cacheable("indexDsInfo")
|
||||
public IndexDsInfo calculateCurrentIndexDsInfo() {
|
||||
try {
|
||||
log.info("Not using cache");
|
||||
|
||||
final String queryUrl = IOUtils.toString(getClass().getResourceAsStream("/xquery/findSolrIndexUrl.xquery"));
|
||||
final String queryDs = IOUtils.toString(getClass().getResourceAsStream("/xquery/findIndexDsInfo.xquery"));
|
||||
|
||||
final String indexBaseUrl = lookupClient.findOne(queryUrl);
|
||||
final String idxDs = lookupClient.findOne(queryDs);
|
||||
|
||||
if (idxDs.isEmpty()) { throw new IllegalStateException(queryDs + "\n\nreturned no results, check IS profiles"); }
|
||||
|
||||
final String[] arr = idxDs.split("@@@");
|
||||
return new IndexDsInfo(indexBaseUrl, arr[0].trim(), arr[1].trim(), arr[2].trim());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@CacheEvict(value = "indexDsInfo", allEntries = true)
|
||||
public void evictCache() {
|
||||
log.info("Evicting indexDsInfo cache");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
public class IndexDsInfo {
|
||||
|
||||
private final String indexBaseUrl;
|
||||
private final String indexDsId;
|
||||
private final String format;
|
||||
private final String coll;
|
||||
|
||||
public IndexDsInfo(final String indexBaseUrl, final String indexDsId, final String format, final String coll) {
|
||||
this.indexBaseUrl = indexBaseUrl;
|
||||
this.indexDsId = indexDsId;
|
||||
this.format = format;
|
||||
this.coll = coll;
|
||||
}
|
||||
|
||||
public String getIndexBaseUrl() {
|
||||
return indexBaseUrl;
|
||||
}
|
||||
|
||||
public String getIndexDsId() {
|
||||
return indexDsId;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public String getColl() {
|
||||
return coll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColl().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof IndexDsInfo)) return false;
|
||||
|
||||
return getColl().equals(((IndexDsInfo) other).getColl());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,293 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.objects.ZenodoContextList;
|
||||
|
||||
public class OpenAIRESubmitterUtils {
|
||||
|
||||
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(OpenAIRESubmitterUtils.class);
|
||||
private static final String ZENODO_COMMUNITY = "zenodo.org/communities/";
|
||||
private final String community_api;
|
||||
|
||||
public OpenAIRESubmitterUtils(final String community_api) {
|
||||
this.community_api = community_api;
|
||||
}
|
||||
|
||||
public Map<String, String> calculateProjectInfo(final String link) {
|
||||
final Map<String, String> info = new HashMap<>();
|
||||
final String[] arr = link.split("/");
|
||||
// info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble
|
||||
|
||||
if (arr.length > 4) {
|
||||
final String acronym = arr.length > 7 ? arr[7] : "";
|
||||
final String title = arr.length > 6 ? StringUtils.isNotBlank(arr[6]) ? arr[6] : acronym : "";
|
||||
final String jurisdiction = arr.length > 5 ? arr[5] : "";
|
||||
final String funderId = calculateFunderId(arr[2], arr[3]);
|
||||
info.put("id", calculateProjectId(arr[2], arr[3], arr[4]));
|
||||
info.put("funderShortName", fixFunderShortName(arr[2]));
|
||||
info.put("fundingName", arr[3]);
|
||||
info.put("code", unescape(arr[4]));
|
||||
info.put("jurisdiction", jurisdiction);
|
||||
info.put("title", title);
|
||||
info.put("acronym", acronym);
|
||||
info.put("funderId", funderId);
|
||||
info.put("funderName", calculateFunderName(arr[2]));
|
||||
if (StringUtils.isNotBlank(arr[3])) {
|
||||
info.put("fundingId", funderId + "::" + arr[3]);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
// TODO: remove me when Zenodo ingests the good UKRI projects
|
||||
protected String fixFunderShortName(final String funderShortName) {
|
||||
switch (funderShortName) {
|
||||
case "RCUK":
|
||||
return "UKRI";
|
||||
default:
|
||||
return funderShortName;
|
||||
}
|
||||
}
|
||||
|
||||
protected String calculateFunderPrefix(final String funderShortName, final String funding) {
|
||||
switch (funderShortName.toLowerCase()) {
|
||||
case "conicyt":
|
||||
return "conicytf____::";
|
||||
case "dfg":
|
||||
return "dfgf________::";
|
||||
case "ec":
|
||||
if (funding.equalsIgnoreCase("fp7")) {
|
||||
return "corda_______::";
|
||||
} else {
|
||||
return "corda__h2020::";
|
||||
}
|
||||
case "eea":
|
||||
return "euenvagency_::";
|
||||
case "hrzz":
|
||||
case "mzos":
|
||||
return "irb_hr______::";
|
||||
case "tara":
|
||||
return "taraexp_____::";
|
||||
case "tubitak":
|
||||
return "tubitakf____::";
|
||||
case "rcuk":
|
||||
return "ukri________::";
|
||||
default:
|
||||
String prefix = funderShortName.toLowerCase();
|
||||
// ensure we have 12 chars
|
||||
while (prefix.length() < 12) {
|
||||
prefix += "_";
|
||||
}
|
||||
return prefix + "::";
|
||||
}
|
||||
}
|
||||
|
||||
protected String calculateProjectId(final String funderShortName, final String funding, final String code) {
|
||||
final String suffix = DigestUtils.md5Hex(unescape(code));
|
||||
final String funderPrefix = calculateFunderPrefix(funderShortName, funding);
|
||||
return funderPrefix + suffix;
|
||||
}
|
||||
|
||||
private String unescape(final String code) {
|
||||
return StringUtils.replaceChars(code, "%2F", "/");
|
||||
}
|
||||
|
||||
protected String calculateFunderId(final String funderShortName, final String funding) {
|
||||
switch (funderShortName.toLowerCase()) {
|
||||
case "ec":
|
||||
return "ec__________::EC";
|
||||
default:
|
||||
final String fixedFunderShortName = fixFunderShortName(funderShortName);
|
||||
final String prefix = calculateFunderPrefix(fixedFunderShortName, funding);
|
||||
return prefix + fixedFunderShortName.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
protected String calculateFunderName(final String funderShortName) {
|
||||
|
||||
switch (funderShortName.toLowerCase()) {
|
||||
case "aff":
|
||||
case "aka":
|
||||
return "Academy of Finland";
|
||||
case "anr":
|
||||
return "French National Research Agency (ANR)";
|
||||
case "arc":
|
||||
return "Australian Research Council (ARC)";
|
||||
case "cihr":
|
||||
return "Canadian Institutes of Health Research";
|
||||
case "conicyt":
|
||||
return "Comisión Nacional de Investigación Científica y Tecnológica";
|
||||
case "dfg":
|
||||
return "Deutsche Forschungsgemeinschaft";
|
||||
case "ec":
|
||||
return "European Commission";
|
||||
case "eea":
|
||||
return "European Environment Agency";
|
||||
case "fct":
|
||||
return "Fundação para a Ciência e a Tecnologia, I.P.";
|
||||
case "fwf":
|
||||
return "Austrian Science Fund (FWF)";
|
||||
case "gsrt":
|
||||
return "General Secretariat of Research and Technology (GSRT)";
|
||||
case "hrzz":
|
||||
return "Croatian Science Foundation (CSF)";
|
||||
case "innoviris":
|
||||
return "INNOVIRIS";
|
||||
case "mestd":
|
||||
return "Ministry of Education, Science and Technological Development of Republic of Serbia";
|
||||
case "miur":
|
||||
return "Ministero dell'Istruzione dell'Università e della Ricerca";
|
||||
case "mzos":
|
||||
return "Ministry of Science, Education and Sports of the Republic of Croatia (MSES)";
|
||||
case "nhmrc":
|
||||
return "National Health and Medical Research Council (NHMRC)";
|
||||
case "nih":
|
||||
return "National Institutes of Health";
|
||||
case "nsf":
|
||||
return "National Science Foundation";
|
||||
case "nserc":
|
||||
return "Natural Sciences and Engineering Research Council of Canada";
|
||||
case "nwo":
|
||||
return "Netherlands Organisation for Scientific Research (NWO)";
|
||||
case "rcuk":
|
||||
case "ukri":
|
||||
return "UK Research and Innovation";
|
||||
case "rif":
|
||||
case "rpf":
|
||||
return "Research and Innovation Foundation";
|
||||
case "rsf":
|
||||
return "Russian Science Foundation";
|
||||
case "sfi":
|
||||
return "Science Foundation Ireland";
|
||||
case "sgov":
|
||||
return "Gobierno de España";
|
||||
case "snsf":
|
||||
return "Swiss National Science Foundation";
|
||||
case "sshrc":
|
||||
return "Social Sciences and Humanities Research Council";
|
||||
case "tara":
|
||||
return "Tara Expeditions Foundation";
|
||||
case "tubitak":
|
||||
return "Türkiye Bilimsel ve Teknolojik Araştırma Kurumu";
|
||||
case "wt":
|
||||
return "Wellcome Trust";
|
||||
default:
|
||||
log.error("Funder short name '" + funderShortName + "' not managed");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> filterContexts(List<String> contexts) {
|
||||
|
||||
final List<String> zenodoContexts = contexts.stream()
|
||||
.map(c -> {
|
||||
if (c.contains(ZENODO_COMMUNITY)) { return c.substring(c.lastIndexOf("/") + 1); }
|
||||
return null;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (zenodoContexts.size() > 0) {
|
||||
contexts = contexts.stream().filter(c -> !c.contains(ZENODO_COMMUNITY)).collect(Collectors.toList());
|
||||
final RestTemplate rt = new RestTemplate();
|
||||
final Set<String> zenodoOpenAIRE = new HashSet<>();
|
||||
for (final String context : zenodoContexts) {
|
||||
// String ct = context.substring(context.lastIndexOf("/")+1);
|
||||
try {
|
||||
zenodoOpenAIRE
|
||||
.addAll(rt.getForObject(community_api + context + "/openairecommunities", ZenodoContextList.class).getOpenAirecommunitylist());
|
||||
} catch (final RestClientException rce) {
|
||||
log.error("Unable to get object for " + community_api + context + "/openairecommunities");
|
||||
}
|
||||
|
||||
}
|
||||
contexts.addAll(zenodoOpenAIRE);
|
||||
}
|
||||
|
||||
return contexts;
|
||||
|
||||
}
|
||||
|
||||
public List<ContextInfo> processContexts(final List<String> list) {
|
||||
// filterContexts(list);
|
||||
return Lists.newArrayList(Lists.transform(filterContexts(list), new Function<String, ContextInfo>() {
|
||||
|
||||
@Override
|
||||
public ContextInfo apply(final String s) {
|
||||
return createContextInfo(s.split("::"), 0);
|
||||
}
|
||||
|
||||
private ContextInfo createContextInfo(final String[] arr, final int pos) {
|
||||
final StringWriter id = new StringWriter();
|
||||
id.write(arr[0]);
|
||||
for (int i = 0; i < pos; i++) {
|
||||
id.write("::");
|
||||
id.write(arr[i + 1]);
|
||||
}
|
||||
final String elem = pos == 0 ? "context" : pos == 1 ? "category" : "concept";
|
||||
final ContextInfo info = new ContextInfo(elem, id.toString());
|
||||
if (pos + 1 < arr.length) {
|
||||
info.getChildren().add(createContextInfo(arr, pos + 1));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
public class ContextInfo {
|
||||
|
||||
private String elem;
|
||||
private String id;
|
||||
private List<ContextInfo> children = new ArrayList<>();
|
||||
|
||||
public ContextInfo(final String elem,
|
||||
final String id) {
|
||||
this.elem = elem;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getElem() {
|
||||
return elem;
|
||||
}
|
||||
|
||||
public void setElem(final String elem) {
|
||||
this.elem = elem;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<ContextInfo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(final List<ContextInfo> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return elem.equals("context");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.openaire.directindex.objects.ResultEntry;
|
||||
import eu.dnetlib.openaire.directindex.utils.ISLookupClient;
|
||||
import eu.dnetlib.openaire.directindex.utils.OafRecordConverter;
|
||||
import eu.dnetlib.openaire.directindex.utils.OafToIndexRecordFactory;
|
||||
import eu.dnetlib.openaire.directindex.utils.SolrIndexClient;
|
||||
import eu.dnetlib.openaire.directindex.utils.SolrIndexClientFactory;
|
||||
|
||||
@RestController
|
||||
public class OpenaireResultSubmitter extends AbstractDnetController {
|
||||
|
||||
private static final Log log = LogFactory.getLog(OpenaireResultSubmitter.class);
|
||||
|
||||
@Autowired
|
||||
private RecentResultsQueue recentResultsQueue;
|
||||
|
||||
@Autowired
|
||||
private OafRecordConverter oafRecordConverter;
|
||||
|
||||
@Autowired
|
||||
private SolrIndexClientFactory solrIndexClientFactory;
|
||||
|
||||
@Autowired
|
||||
private ResultSubmitterService submitterService;
|
||||
|
||||
@Autowired
|
||||
private IndexDSRetriever indexDSRetriever;
|
||||
|
||||
@Autowired
|
||||
private ISLookupClient isLookupClient;
|
||||
|
||||
@GetMapping("/api/admin/autocommit/active")
|
||||
public Boolean getAutocommit() throws DirectIndexApiException {
|
||||
return submitterService.isAutocommitactive();
|
||||
}
|
||||
|
||||
@PostMapping("/api/admin/autocommit/active")
|
||||
public Boolean setAutocommit(@RequestParam final Boolean active) throws DirectIndexApiException {
|
||||
submitterService.setAutocommitactive(active);
|
||||
log.info(String.format("automatic commit, active '%s', frequency '%s'", submitterService.isAutocommitactive(), submitterService.getCommitfrquency()));
|
||||
return submitterService.isAutocommitactive();
|
||||
}
|
||||
|
||||
@GetMapping("/api/admin/evictCache")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void evictCache() {
|
||||
indexDSRetriever.evictCache();
|
||||
}
|
||||
|
||||
@PostMapping("/api/results/feedObject")
|
||||
public String feedResult(@RequestBody final ResultEntry pub,
|
||||
@RequestParam(required = false, defaultValue = "true") final boolean commit)
|
||||
throws DirectIndexApiException {
|
||||
|
||||
return feed(pub, commit);
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/api/result/{openaireId}")
|
||||
public boolean deleteResultWithOpenaireId(
|
||||
@PathVariable final String openaireId,
|
||||
@RequestParam(required = false, defaultValue = "true") final boolean commit) throws DirectIndexApiException {
|
||||
|
||||
return deleteResult(openaireId);
|
||||
}
|
||||
|
||||
@DeleteMapping("/api/results")
|
||||
public boolean deleteResultWithOriginalId(
|
||||
@RequestParam final String originalId,
|
||||
@RequestParam final String collectedFromId,
|
||||
@RequestParam(required = false, defaultValue = "true") final boolean commit) throws Exception {
|
||||
|
||||
final String openaireId = oafRecordConverter.calculateOpenaireId(originalId, collectedFromId);
|
||||
return deleteResult(openaireId);
|
||||
}
|
||||
|
||||
private String feed(final ResultEntry pub, final boolean commit) throws DirectIndexApiException {
|
||||
log.debug(pub);
|
||||
final IndexDsInfo info = indexDSRetriever.calculateCurrentIndexDsInfo();
|
||||
final String oafRecord = oafRecordConverter.convert(pub);
|
||||
|
||||
final SolrIndexClient client = solrIndexClientFactory.getClient(info);
|
||||
|
||||
try {
|
||||
client.addRecord(oafRecord, info.getIndexDsId(), OafToIndexRecordFactory.newTransformerForMdFormat(info.getFormat(), isLookupClient));
|
||||
recentResultsQueue.add(oafRecord);
|
||||
return pub.getOpenaireId();
|
||||
} catch (final Throwable e) {
|
||||
log.error("Error saving record", e);
|
||||
log.debug(pub.toString());
|
||||
throw new DirectIndexApiException("Error adding publication: " + e.getMessage(), e);
|
||||
} finally {
|
||||
if (commit) {
|
||||
client.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deleteResult(final String openaireId) throws DirectIndexApiException {
|
||||
try {
|
||||
final IndexDsInfo info = indexDSRetriever.calculateCurrentIndexDsInfo();
|
||||
final String query = String.format("objidentifier:\"%s\" OR resultdupid:\"%s\"", openaireId, openaireId);
|
||||
solrIndexClientFactory.getClient(info).deleteByQuery(query);
|
||||
|
||||
log.info("Deleted result with id: " + openaireId + " from: " + info.getIndexBaseUrl());
|
||||
|
||||
recentResultsQueue.remove(openaireId);
|
||||
return true;
|
||||
} catch (final Throwable e) {
|
||||
throw new DirectIndexApiException("Error deleting publication: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoCursor;
|
||||
import com.mongodb.client.model.UpdateOptions;
|
||||
|
||||
@Component
|
||||
public class RecentResultsQueue implements Iterable<String> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(RecentResultsQueue.class);
|
||||
|
||||
@Autowired
|
||||
private MongoCollection<Document> collection;
|
||||
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
|
||||
final MongoCursor<Document> cursor = collection.find().iterator();
|
||||
|
||||
return new Iterator<String>() {
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return cursor.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String next() {
|
||||
final Document obj = cursor.next();
|
||||
return obj != null && obj.containsKey("record") ? obj.get("record").toString() : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new RuntimeException("NOT IMPLEMENTED");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
synchronized public void add(final String oaf) throws Exception {
|
||||
final String id = new SAXReader().read(new StringReader(oaf)).valueOf("//*[local-name() = 'objIdentifier']");
|
||||
|
||||
log.debug("MongoDB: Saving record " + id);
|
||||
|
||||
final Document obj = new Document();
|
||||
obj.append("id", id);
|
||||
obj.append("record", oaf);
|
||||
obj.append("date", System.currentTimeMillis());
|
||||
|
||||
final UpdateOptions opts = new UpdateOptions();
|
||||
opts.upsert(true);
|
||||
|
||||
collection.updateOne(new BasicDBObject("id", id), obj, opts);
|
||||
|
||||
}
|
||||
|
||||
public void remove(final List<String> list) {
|
||||
for (final String id : list) {
|
||||
collection.deleteOne(new BasicDBObject("id", id));
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(final String... ids) {
|
||||
for (final String id : ids) {
|
||||
collection.deleteOne(new BasicDBObject("id", id));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package eu.dnetlib.openaire.directindex.api;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.utils.SolrIndexClient;
|
||||
import eu.dnetlib.openaire.directindex.utils.SolrIndexClientFactory;
|
||||
|
||||
@Component
|
||||
public class ResultSubmitterService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ResultSubmitterService.class);
|
||||
|
||||
@Autowired
|
||||
private IndexDSRetriever indexDSRetriever;
|
||||
|
||||
@Autowired
|
||||
private SolrIndexClientFactory solrIndexClientFactory;
|
||||
|
||||
/**
|
||||
* Autocommit feature activation flag
|
||||
*/
|
||||
@Value("${openaire.api.directindex.autocommit.active}")
|
||||
private boolean autocommitactive;
|
||||
|
||||
/**
|
||||
* Autocommit frequency (Seconds)
|
||||
*/
|
||||
@Value("${openaire.api.directindex.autocommit.frequency}")
|
||||
private long commitfrquency = 60;
|
||||
|
||||
private final ScheduledExecutorService executor;
|
||||
|
||||
public ResultSubmitterService() {
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
updateCommitSchedule();
|
||||
}
|
||||
|
||||
private void updateCommitSchedule() {
|
||||
log.info("updating commit schedule");
|
||||
|
||||
executor.scheduleAtFixedRate(() -> {
|
||||
if (isAutocommitactive()) {
|
||||
try {
|
||||
final IndexDsInfo info = indexDSRetriever.calculateCurrentIndexDsInfo();
|
||||
final SolrIndexClient client = solrIndexClientFactory.getClient(info);
|
||||
log.info("performing commit on " + info.getColl());
|
||||
client.commit();
|
||||
} catch (final Throwable e) {
|
||||
log.error("unable to perform commit", e);
|
||||
}
|
||||
}
|
||||
}, 0, getCommitfrquency(), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public boolean isAutocommitactive() {
|
||||
return autocommitactive;
|
||||
}
|
||||
|
||||
public synchronized void setAutocommitactive(final boolean autocommitactive) {
|
||||
this.autocommitactive = autocommitactive;
|
||||
}
|
||||
|
||||
public long getCommitfrquency() {
|
||||
return commitfrquency;
|
||||
}
|
||||
|
||||
public synchronized void setCommitfrquency(final long commitfrquency) {
|
||||
this.commitfrquency = commitfrquency;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package eu.dnetlib.openaire.directindex.objects;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by michele on 02/12/15.
|
||||
*/
|
||||
public class DatasourceEntry {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String prefix;
|
||||
|
||||
public DatasourceEntry() {}
|
||||
|
||||
public DatasourceEntry(final String id, final String name, final String prefix) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(final String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String calculateOpenaireId() {
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
final String[] arr = id.split("::");
|
||||
if (arr.length == 2) { return String.format("%s::%s", arr[0], DigestUtils.md5Hex(arr[1])); }
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package eu.dnetlib.openaire.directindex.objects;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Created by michele on 02/12/15.
|
||||
*/
|
||||
public class PidEntry {
|
||||
|
||||
private String type;
|
||||
private String value;
|
||||
|
||||
public PidEntry() {
|
||||
}
|
||||
|
||||
public PidEntry(final String type, final String value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ApiModelProperty(required = true, value = "E.g. doi, pmc, urn. See http://api.openaire.eu/vocabularies/dnet:pid_types")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ApiModelProperty(required = true)
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,229 @@
|
|||
package eu.dnetlib.openaire.directindex.objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Created by michele on 02/12/15.
|
||||
*/
|
||||
public class ResultEntry {
|
||||
|
||||
private String openaireId;
|
||||
private String originalId;
|
||||
private String title;
|
||||
private List<String> authors = new ArrayList<>();
|
||||
private String publisher;
|
||||
private String description;
|
||||
private String language;
|
||||
private List<PidEntry> pids = new ArrayList<>();
|
||||
/**
|
||||
* @Deprecated: use accessRightCode
|
||||
*/
|
||||
@Deprecated
|
||||
private String licenseCode;
|
||||
private String accessRightCode;
|
||||
private String embargoEndDate;
|
||||
/**
|
||||
* One of publication, dataset, software, other. Default value is publication.
|
||||
*/
|
||||
private String type = "publication";
|
||||
private String resourceType;
|
||||
private String url;
|
||||
private String collectedFromId;
|
||||
private String hostedById;
|
||||
|
||||
// String according to the EGI context profile, example: egi::classification::natsc::math
|
||||
private List<String> contexts = new ArrayList<>();
|
||||
|
||||
// String according to openaire guidelines:
|
||||
// info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID/[Jurisdiction]/[ProjectName]/[ProjectAcronym]
|
||||
private List<String> linksToProjects = new ArrayList<>();
|
||||
|
||||
private static final Log log = LogFactory.getLog(ResultEntry.class);
|
||||
|
||||
public ResultEntry() {}
|
||||
|
||||
public String getOpenaireId() {
|
||||
return openaireId;
|
||||
}
|
||||
|
||||
public void setOpenaireId(final String openaireId) {
|
||||
this.openaireId = openaireId;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(final String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
@ApiModelProperty(required = true)
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public List<String> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(final List<String> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public String getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(final String publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "ISO Alpha-3 code. E.g. 'eng', 'ita'")
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(final String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public List<PidEntry> getPids() {
|
||||
return pids;
|
||||
}
|
||||
|
||||
public void setPids(final List<PidEntry> pids) {
|
||||
this.pids = pids;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiModelProperty(required = false, allowableValues = "OPEN, CLOSED, RESTRICTED, EMBARGO, UNKNOWN, OTHER, OPEN SOURCE")
|
||||
public String getLicenseCode() {
|
||||
return licenseCode;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setLicenseCode(final String licenseCode) {
|
||||
this.licenseCode = licenseCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set required = true when the deprecated licenseCode is not used anymore by our client and it is removed
|
||||
*
|
||||
* @return access rights code
|
||||
*/
|
||||
@ApiModelProperty(required = false, allowableValues = "OPEN, CLOSED, RESTRICTED, EMBARGO, UNKNOWN, OTHER, OPEN SOURCE")
|
||||
public String getAccessRightCode() {
|
||||
return accessRightCode;
|
||||
}
|
||||
|
||||
public void setAccessRightCode(final String accessRightCode) {
|
||||
this.accessRightCode = accessRightCode;
|
||||
}
|
||||
|
||||
@ApiModelProperty(required = true, value = "Use 001 for articles, 021 for datasets, 0029 for software. See: http://api.openaire.eu/vocabularies/dnet:publication_resource for all the available resource types.")
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(final String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
@ApiModelProperty(required = true)
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(final String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@ApiModelProperty(required = true, value = "Use opendoar___::2659 for Zenodo Publications; re3data_____::r3d100010468 for Zenodo datasets; infrastruct::openaire for OpenAIRE portal.")
|
||||
public String getCollectedFromId() {
|
||||
return collectedFromId;
|
||||
}
|
||||
|
||||
public void setCollectedFromId(final String collectedFromId) {
|
||||
this.collectedFromId = collectedFromId;
|
||||
}
|
||||
|
||||
public String getHostedById() {
|
||||
return hostedById;
|
||||
}
|
||||
|
||||
public void setHostedById(final String hostedById) {
|
||||
this.hostedById = hostedById;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "E.g. fet, egi::classification::natsc::math::pure, egi::projects::EMI")
|
||||
public List<String> getContexts() {
|
||||
return contexts;
|
||||
}
|
||||
|
||||
public void setContexts(final List<String> contexts) {
|
||||
this.contexts = contexts;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "E.g. info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus")
|
||||
public List<String> getLinksToProjects() {
|
||||
return linksToProjects;
|
||||
}
|
||||
|
||||
public void setLinksToProjects(final List<String> linksToProjects) {
|
||||
this.linksToProjects = linksToProjects;
|
||||
}
|
||||
|
||||
@ApiModelProperty(allowableValues = "publication, dataset, software, other")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getEmbargoEndDate() {
|
||||
return embargoEndDate;
|
||||
}
|
||||
|
||||
public void setEmbargoEndDate(final String embargoEndDate) {
|
||||
this.embargoEndDate = embargoEndDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
} catch (final JsonProcessingException e) {
|
||||
log.error("Error converting object in json", e);
|
||||
throw new RuntimeException("Error converting object in json", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getAnyId() {
|
||||
return StringUtils.isNotBlank(openaireId) ? openaireId : originalId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package eu.dnetlib.openaire.directindex.objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ZenodoContextList {
|
||||
|
||||
|
||||
private String zenodoid;
|
||||
|
||||
|
||||
private List<String> openAirecommunitylist;
|
||||
|
||||
|
||||
|
||||
public List<String> getOpenAirecommunitylist() {
|
||||
return openAirecommunitylist;
|
||||
}
|
||||
|
||||
public void setOpenAirecommunitylist(List<String> openAirecommunitylist) {
|
||||
this.openAirecommunitylist = openAirecommunitylist;
|
||||
|
||||
}
|
||||
|
||||
public String getZenodoid() {
|
||||
return zenodoid;
|
||||
}
|
||||
|
||||
public void setZenodoid(String zenodoid) {
|
||||
this.zenodoid = zenodoid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package eu.dnetlib.openaire.directindex.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ISLookupClient {
|
||||
|
||||
public String findOne(final String query) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> find(final String query) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
package eu.dnetlib.openaire.directindex.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.api.DirectIndexApiException;
|
||||
import eu.dnetlib.openaire.directindex.objects.DatasourceEntry;
|
||||
import eu.dnetlib.openaire.directindex.objects.ResultEntry;
|
||||
|
||||
@Component
|
||||
public class OafRecordConverter {
|
||||
|
||||
@Value("${openaire.api.community}")
|
||||
private String community_api;
|
||||
|
||||
@Value("${oaf.schema.location}")
|
||||
private String oafSchemaLocation;
|
||||
|
||||
@Autowired
|
||||
private ISLookupClient lookupClient;
|
||||
|
||||
private static long last_cache_update = 0;
|
||||
private static final Map<String, Map<String, String>> cached_vocabularies = new HashMap<>();
|
||||
private static final Map<String, DatasourceEntry> cached_datasources = new HashMap<>();
|
||||
private static final Map<String, String> cached_contexts = new HashMap<>();
|
||||
|
||||
private static final Log log = LogFactory.getLog(OafRecordConverter.class);
|
||||
|
||||
public String convert(final ResultEntry pub) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private synchronized Map<String, String> getVocabulary(final String voc) throws Exception {
|
||||
|
||||
if (System.currentTimeMillis() - last_cache_update < TimeUnit.MINUTES.toMillis(15) && cached_vocabularies.containsKey(voc)) {
|
||||
return cached_vocabularies.get(voc);
|
||||
} else {
|
||||
final String query = "collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code='" + voc
|
||||
+ "']//TERM/concat(@code, ' @@@ ', @english_name)";
|
||||
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (final String s : lookupClient.find(query)) {
|
||||
final String[] arr = s.split("@@@");
|
||||
map.put(arr[0].trim(), arr[1].trim());
|
||||
}
|
||||
|
||||
cached_vocabularies.put(voc, map);
|
||||
|
||||
last_cache_update = System.currentTimeMillis();
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized Map<String, String> getContexts() throws Exception {
|
||||
if (System.currentTimeMillis() - last_cache_update > TimeUnit.MINUTES.toMillis(15) || cached_contexts.isEmpty()) {
|
||||
final String query =
|
||||
"collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')[.//context/@type='community' or .//context/@type='ri']//*[name()='context' or name()='category' or name()='concept']/concat(@id, ' @@@ ', @label)";
|
||||
|
||||
cached_contexts.clear();
|
||||
for (final String s : lookupClient.find(query)) {
|
||||
final String[] arr = s.split("@@@");
|
||||
cached_contexts.put(arr[0].trim(), arr[1].trim());
|
||||
}
|
||||
last_cache_update = System.currentTimeMillis();
|
||||
}
|
||||
return cached_contexts;
|
||||
}
|
||||
|
||||
public String calculateOpenaireId(final String originalId, final String collectedFromId)
|
||||
throws Exception {
|
||||
return calculateOpenaireId(originalId, getDatasourceInfo(collectedFromId));
|
||||
}
|
||||
|
||||
private String calculateOpenaireId(final String originalId, final DatasourceEntry collectedFromEntry) {
|
||||
return collectedFromEntry.getPrefix() + "::" + DigestUtils.md5Hex(originalId);
|
||||
}
|
||||
|
||||
private synchronized DatasourceEntry getDatasourceInfo(final String dsId) throws Exception {
|
||||
if (StringUtils
|
||||
.isBlank(dsId)) {
|
||||
return new DatasourceEntry("openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18", "Unknown Repository", "unknown_____");
|
||||
}
|
||||
|
||||
if (!cached_datasources.containsKey(dsId)) {
|
||||
final String query =
|
||||
"collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//CONFIGURATION[./DATASOURCE_ORIGINAL_ID='" + dsId
|
||||
+ "']/concat(./OFFICIAL_NAME, ' @@@ ', .//FIELD/value[../key='NamespacePrefix'])";
|
||||
final String s = lookupClient.findOne(query);
|
||||
final String[] arr = s.split("@@@");
|
||||
|
||||
final DatasourceEntry ds = new DatasourceEntry(dsId, arr[0].trim(), arr[1].trim());
|
||||
|
||||
if (StringUtils.isBlank(ds.getName()) || StringUtils.isBlank(ds.getPrefix())) {
|
||||
log.error("Invalid datasource id: " + dsId);
|
||||
throw new DirectIndexApiException("Invalid datasource id: " + dsId);
|
||||
} else {
|
||||
cached_datasources.put(dsId, ds);
|
||||
}
|
||||
}
|
||||
|
||||
return cached_datasources.get(dsId);
|
||||
|
||||
}
|
||||
// public String asOafRecord(final VelocityEngine ve,
|
||||
// final ISLookupClient lookupClient,
|
||||
// final String oafSchemaLocation,
|
||||
// final String community_api) throws Exception {
|
||||
//
|
||||
// if (StringUtils.isBlank(getOriginalId())
|
||||
// && StringUtils
|
||||
// .isBlank(getOpenaireId())) {
|
||||
// throw new DirectIndexApiException("One of the following fields is required: originalId or openaireId");
|
||||
// }
|
||||
// if (StringUtils.isBlank(getTitle())) { throw new DirectIndexApiException("A required field is missing: title"); }
|
||||
// if (StringUtils.isBlank(getUrl())) { throw new DirectIndexApiException("A required field is missing: url"); }
|
||||
// if (StringUtils.isBlank(getLicenseCode()) && StringUtils.isBlank(getAccessRightCode())) {
|
||||
// throw new DirectIndexApiException("A required field is missing: accessRightCode");
|
||||
// }
|
||||
// if (StringUtils.isBlank(getResourceType())) { throw new DirectIndexApiException("A required field is missing: resourceType"); }
|
||||
// if (StringUtils.isBlank(getCollectedFromId())) { throw new DirectIndexApiException("A required field is missing: collectedFromId"); }
|
||||
// if (StringUtils.isBlank(getType())) { throw new DirectIndexApiException("A required field is missing: type"); }
|
||||
//
|
||||
// final DatasourceEntry collectedFromEntry = getDatasourceInfo(collectedFromId, lookupClient);
|
||||
// final DatasourceEntry hostedByEntry = getDatasourceInfo(hostedById, lookupClient);
|
||||
//
|
||||
// if (StringUtils.isBlank(openaireId)) {
|
||||
// setOpenaireId(calculateOpenaireId(originalId, collectedFromEntry));
|
||||
// }
|
||||
//
|
||||
// if (!openaireId
|
||||
// .matches("^\\w{12}::\\w{32}$")) {
|
||||
// throw new DirectIndexApiException(
|
||||
// "Invalid openaireId: " + openaireId + " - regex ^\\w{12}::\\w{32}$ not matched");
|
||||
// }
|
||||
//
|
||||
// final Map<String, Object> model = new HashMap<>();
|
||||
// model.put("esc", new EscapeXml());
|
||||
// model.put("util", new OpenAIRESubmitterUtils(community_api));
|
||||
// model.put("pub", this);
|
||||
// model.put("objIdentifier", getOpenaireId());
|
||||
// model.put("oafSchemaLocation", oafSchemaLocation);
|
||||
// model.put("resultTypes", getVocabulary("dnet:result_typologies", lookupClient));
|
||||
// model.put("rights", getVocabulary("dnet:access_modes", lookupClient));
|
||||
// model.put("resourceTypes", getVocabulary("dnet:publication_resource", lookupClient));
|
||||
// model.put("pidTypes", getVocabulary("dnet:pid_types", lookupClient));
|
||||
// model.put("languages", getVocabulary("dnet:languages", lookupClient));
|
||||
// model.put("contexts", getContexts(lookupClient));
|
||||
// model.put("dateOfCollection", new SimpleDateFormat("yyyy-MM-dd\'T\'hh:mm:ss\'Z\'").format(new Date()));
|
||||
// model.put("collectedFrom", collectedFromEntry);
|
||||
// model.put("hostedBy", hostedByEntry);
|
||||
//
|
||||
// return VelocityEngineUtils.mergeTemplateIntoString(ve, "/eu/dnetlib/openaire/directindex/indexRecord.xml.vm", "UTF-8", model);
|
||||
// }
|
||||
|
||||
protected String getCommunity_api() {
|
||||
return community_api;
|
||||
}
|
||||
|
||||
protected void setCommunity_api(final String community_api) {
|
||||
this.community_api = community_api;
|
||||
}
|
||||
|
||||
protected String getOafSchemaLocation() {
|
||||
return oafSchemaLocation;
|
||||
}
|
||||
|
||||
protected void setOafSchemaLocation(final String oafSchemaLocation) {
|
||||
this.oafSchemaLocation = oafSchemaLocation;
|
||||
}
|
||||
|
||||
protected ISLookupClient getLookupClient() {
|
||||
return lookupClient;
|
||||
}
|
||||
|
||||
protected void setLookupClient(final ISLookupClient lookupClient) {
|
||||
this.lookupClient = lookupClient;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.dnetlib.openaire.directindex.utils;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public class OafToIndexRecordFactory {
|
||||
|
||||
public static Function<String, String> newTransformerForMdFormat(final String format, final ISLookupClient isLookupClient) throws Exception {
|
||||
final Transformer layoutTransformer =
|
||||
newTransformer(IOUtils.toString(OafToIndexRecordFactory.class.getResourceAsStream("/xslt/openaireLayoutToRecordStylesheet.xslt")));
|
||||
|
||||
layoutTransformer.setParameter("format", format);
|
||||
|
||||
final String xslt = transform(layoutTransformer, getLayoutSource(format, isLookupClient));
|
||||
|
||||
final Transformer recordTransformer = newTransformer(xslt);
|
||||
|
||||
return s -> transform(recordTransformer, s);
|
||||
}
|
||||
|
||||
private static Transformer newTransformer(final String xslt) throws TransformerConfigurationException {
|
||||
final TransformerFactory factory = TransformerFactory.newInstance();
|
||||
return factory.newTransformer(new StreamSource(new StringReader(xslt)));
|
||||
}
|
||||
|
||||
private static String transform(final Transformer t, final String xml) {
|
||||
try {
|
||||
final StreamResult res = new StreamResult(new StringWriter());
|
||||
t.transform(new StreamSource(new StringReader(xml)), res);
|
||||
return res.getWriter().toString();
|
||||
} catch (final TransformerException e) {
|
||||
throw new RuntimeException("Error transforming record: " + xml, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getLayoutSource(final String format, final ISLookupClient isLookupClient) throws Exception {
|
||||
return isLookupClient
|
||||
.findOne("collection('/db/DRIVER/MDFormatDSResources/MDFormatDSResourceType')[.//NAME='" + format + "']//LAYOUT[@name='index']");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package eu.dnetlib.openaire.directindex.utils;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class SolrIndexClient {
|
||||
|
||||
private final String solrCollection;
|
||||
|
||||
public SolrIndexClient(final String solrCollection) {
|
||||
this.solrCollection = solrCollection;
|
||||
}
|
||||
|
||||
public void commit() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void deleteByQuery(final String query) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void addRecord(final String oafRecord, final String indexDsId, final Function<String, String> newTransformerForMdFormat) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
// private SolrInputDocument prepareSolrDocument(final String record, final String indexDsId, final Function<String, String>
|
||||
// toIndexRecord)
|
||||
// throws CloudIndexClientException {
|
||||
// try {
|
||||
// final StreamingInputDocumentFactory documentFactory = new StreamingInputDocumentFactory();
|
||||
// final String version = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'").format(new Date());
|
||||
// final String indexRecord = toIndexRecord.apply(record);
|
||||
// if (log.isDebugEnabled()) {
|
||||
// log.debug("***************************************\nSubmitting index record:\n" + indexRecord +
|
||||
// "\n***************************************\n");
|
||||
// }
|
||||
//
|
||||
// return documentFactory.parseDocument(version, indexRecord, indexDsId, "dnetResult");
|
||||
// } catch (final Throwable e) {
|
||||
// throw new CloudIndexClientException("Error creating solr document", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.dnetlib.openaire.directindex.utils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.api.IndexDsInfo;
|
||||
|
||||
@Component
|
||||
public class SolrIndexClientFactory {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SolrIndexClientFactory.class);
|
||||
|
||||
// private CloudSolrClient client = null;
|
||||
//
|
||||
// public CloudSolrClient getClient(final IndexDsInfo info) {
|
||||
//
|
||||
// if (client == null) {
|
||||
// log.info(String.format("Initializing solr client (%s) with collection %s", info.getIndexBaseUrl(), info.getColl()));
|
||||
// final ZkServers zk = ZkServers.newInstance(info.getIndexBaseUrl());
|
||||
// final CloudSolrClient.Builder builder = new CloudSolrClient.Builder(zk.getHosts(), zk.getChroot()).withParallelUpdates(true);
|
||||
// client = builder.build();
|
||||
// }
|
||||
// client.setDefaultCollection(info.getColl());
|
||||
// return client;
|
||||
// }
|
||||
|
||||
public SolrIndexClient getClient(final IndexDsInfo info) {
|
||||
// TODO
|
||||
return new SolrIndexClient(info.getColl());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
openaire.api.directindex.mongo.url=mongodb://localhost:27017
|
||||
openaire.api.directindex.mongo.db=openaireplus_apis
|
||||
openaire.api.directindex.mongo.collection=recent_publications
|
||||
|
||||
openaire.api.directindex.layoutToRecord.xslt=/eu/dnetlib/msro/openaireplus/workflows/index/openaireLayoutToRecordStylesheet.xsl
|
||||
|
||||
openaire.api.directindex.autocommit.active=true
|
||||
openaire.api.directindex.autocommit.frequency=6
|
||||
|
||||
openaire.api.community=http://${container.hostname}/openaire/community/
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
#macro(context $ctx)
|
||||
<$!ctx.elem id="$!esc.evaluate($!ctx.id)" label="$!esc.evaluate($contexts.get($!ctx.id))" #if($!ctx.isRoot()) type="community"#end>
|
||||
#foreach($child in $!ctx.children)#context($child)#end
|
||||
</$!ctx.elem>
|
||||
#end
|
||||
-->
|
||||
|
||||
<record xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaf="http://namespace.openaire.eu/oaf">
|
||||
<result>
|
||||
<header>
|
||||
<dri:objIdentifier>$!esc.evaluate($!objIdentifier)</dri:objIdentifier>
|
||||
<dri:dateOfCollection>$!esc.evaluate($!dateOfCollection)</dri:dateOfCollection>
|
||||
<dri:status>under curation</dri:status>
|
||||
<counters/>
|
||||
</header>
|
||||
<metadata>
|
||||
<oaf:entity schemaLocation="http://namespace.openaire.eu/oaf $!oafSchemaLocation">
|
||||
<oaf:result>
|
||||
<title classid="main title" classname="main title" schemeid="dnet:dataCite_title" schemename="dnet:dataCite_title">
|
||||
$!esc.evaluate($!pub.title)
|
||||
</title>
|
||||
#foreach($author in $!pub.authors)
|
||||
<creator rank="$velocityCount" name="" surname="">$!esc.evaluate($!author)</creator>
|
||||
#end
|
||||
<dateofacceptance/>
|
||||
<resulttype classid="$!esc.evaluate($!pub.type)" classname="$!esc.evaluate($!resultTypes.get($!pub.type))" schemeid="dnet:result_typologies" schemename="dnet:result_typologies"/>
|
||||
<language classid="$!esc.evaluate($!pub.language)" classname="$!esc.evaluate($!languages.get($!pub.language))" schemeid="dnet:languages"
|
||||
schemename="dnet:languages"/>
|
||||
<description>
|
||||
$!esc.evaluate($!pub.description)
|
||||
</description>
|
||||
<country classid="" classname="" schemeid="" schemename=""/>
|
||||
<subject classid="" classname="" schemeid="" schemename=""/>
|
||||
<relevantdate classid="" classname="" schemeid="" schemename=""/>
|
||||
<publisher>$!esc.evaluate($!pub.publisher)</publisher>
|
||||
<embargoenddate>$!esc.evaluate($!pub.embargoEndDate)</embargoenddate>
|
||||
<journal issn="" eissn="" lissn="" ep="" iss="" sp="" vol=""/>
|
||||
<source/>
|
||||
<fulltext/>
|
||||
<format/>
|
||||
<storagedate/>
|
||||
<resourcetype classid="" classname="" schemeid="" schemename=""/>
|
||||
<device/>
|
||||
<size/>
|
||||
<version/>
|
||||
<lastmetadataupdate/>
|
||||
<metadataversionnumber/>
|
||||
<documentationUrl/>
|
||||
<codeRepositoryUrl/>
|
||||
<programmingLanguage classid="" classname="" schemeid="" schemename="" />
|
||||
<contactperson />
|
||||
<contactgroup />
|
||||
<tool />
|
||||
<originalId>$!esc.evaluate($!pub.originalId)</originalId>
|
||||
<collectedfrom name="$!esc.evaluate($!collectedFrom.name)" id="$!esc.evaluate($!collectedFrom.calculateOpenaireId())"/>
|
||||
|
||||
#foreach($pid in $!pub.pids)
|
||||
<pid classid="$!esc.evaluate($!pid.type)" classname="$!esc.evaluate($!pidTypes.get($!pid.type))" schemeid="dnet:pid_types"
|
||||
schemename="dnet:pid_types">$!esc.evaluate($pid.value)</pid>
|
||||
#end
|
||||
#if($!pub.accessRightCode)
|
||||
<bestaccessright classid="$!esc.evaluate($!pub.accessRightCode)" classname="$!esc.evaluate($!rights.get($!pub.accessRightCode))"
|
||||
schemeid="dnet:access_modes" schemename="dnet:access_modes"/>
|
||||
#elseif($!pub.licenseCode)
|
||||
<bestaccessright classid="$!esc.evaluate($!pub.licenseCode)" classname="$!esc.evaluate($!rights.get($!pub.licenseCode))"
|
||||
schemeid="dnet:access_modes" schemename="dnet:access_modes"/>
|
||||
#else
|
||||
<bestaccessright classid="UNKNOWN" classname="not available" schemeid="dnet:access_modes" schemename="dnet:access_modes" />
|
||||
#end
|
||||
|
||||
#foreach($ctx in $util.processContexts($!pub.contexts))
|
||||
#context($ctx)
|
||||
#end
|
||||
|
||||
<datainfo>
|
||||
<inferred>false</inferred>
|
||||
<deletedbyinference>false</deletedbyinference>
|
||||
<trust>0.9</trust>
|
||||
<inferenceprovenance/>
|
||||
<provenanceaction classid="user:insert" classname="user:insert" schemeid="dnet:provenanceActions" schemename="dnet:provenanceActions"/>
|
||||
</datainfo>
|
||||
|
||||
<rels>
|
||||
#foreach($link in $!pub.linksToProjects)
|
||||
|
||||
#set( $info = $!util.calculateProjectInfo($!link) )
|
||||
<rel inferred="false" trust="0.9" inferenceprovenance="" provenanceaction="user:claim">
|
||||
<to class="isProducedBy" scheme="dnet:result_project_relations" type="project">$!esc.evaluate($!info.id)</to>
|
||||
<code>$!esc.evaluate($!info.code)</code>
|
||||
<acronym>$!esc.evaluate($!info.acronym)</acronym>
|
||||
<title>$!esc.evaluate($!info.title)</title>
|
||||
<contracttype classid="" classname="" schemeid="" schemename=""/>
|
||||
|
||||
<funding>
|
||||
<funder id="$!esc.evaluate($!info.funderId)"
|
||||
shortname="$!esc.evaluate($!info.funderShortName)"
|
||||
name="$!esc.evaluate($!info.funderName)"
|
||||
jurisdiction="$!esc.evaluate($!info.jurisdiction)"/>
|
||||
#if($!info.fundingId)
|
||||
<funding_level_0 name="$!esc.evaluate($!info.fundingName)">$!esc.evaluate($!info.fundingId)</funding_level_0>
|
||||
#end
|
||||
</funding>
|
||||
<websiteurl/>
|
||||
</rel>
|
||||
#end
|
||||
</rels>
|
||||
<children>
|
||||
<instance id="$!esc.evaluate($!objIdentifier)">
|
||||
<instancetype classid="$!esc.evaluate($!pub.resourceType)" classname="$!esc.evaluate($resourceTypes.get($!pub.resourceType))"
|
||||
schemeid="dnet:publication_resource" schemename="dnet:publication_resource"/>
|
||||
<collectedfrom name="$!esc.evaluate($!collectedFrom.name)" id="$!esc.evaluate($!collectedFrom.calculateOpenaireId())"/>
|
||||
<hostedby name="$!esc.evaluate($!hostedBy.name)" id="$!esc.evaluate($!hostedBy.calculateOpenaireId())"/>
|
||||
#if($!pub.accessRightCode)
|
||||
<accessright classid="$!esc.evaluate($!pub.accessRightCode)" classname="$!esc.evaluate($!rights.get($!pub.accessRightCode))"
|
||||
schemeid="dnet:access_modes" schemename="dnet:access_modes"/>
|
||||
#elseif($!pub.licenseCode)
|
||||
<accessright classid="$!esc.evaluate($!pub.licenseCode)" classname="$!esc.evaluate($!rights.get($!pub.licenseCode))"
|
||||
schemeid="dnet:access_modes" schemename="dnet:access_modes"/>
|
||||
#else
|
||||
<accessright classid="UNKNOWN" classname="not available" schemeid="dnet:access_modes" schemename="dnet:access_modes" />
|
||||
#end
|
||||
<dateofacceptance/>
|
||||
<webresource>
|
||||
<url>$!esc.evaluate($!pub.url)</url>
|
||||
</webresource>
|
||||
</instance>
|
||||
</children>
|
||||
</oaf:result>
|
||||
</oaf:entity>
|
||||
</metadata>
|
||||
</result>
|
||||
</record>
|
|
@ -0,0 +1,11 @@
|
|||
distinct-values(for $s in collection('/db/DRIVER/ServiceResources/SearchServiceResourceType')//SERVICE_PROPERTIES[./PROPERTY[@key = 'infrastructure' and @value = 'public'] ]
|
||||
let $format := $s/PROPERTY[@key = "mdformat"]/@value/string()
|
||||
return(
|
||||
for $x in collection('/db/DRIVER/IndexDSResources/IndexDSResourceType')
|
||||
where
|
||||
$x//METADATA_FORMAT =$format and
|
||||
$x//METADATA_FORMAT_INTERPRETATION = 'openaire' and
|
||||
$x//METADATA_FORMAT_LAYOUT = 'index'
|
||||
return
|
||||
concat($x//RESOURCE_IDENTIFIER/@value/string(), ' @@@ ', $format , ' @@@ ', $format , '-index-openaire')
|
||||
))
|
|
@ -0,0 +1 @@
|
|||
distinct-values(collection("/db/DRIVER/ServiceResources/IndexServiceResourceType")//PROTOCOL[@name = "solr" or @name = "SOLR"]/@address/string())
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nxsl="http://www.w3.org/1999/XSL/TransformXX">
|
||||
|
||||
<xsl:output omit-xml-declaration="yes" method="xml"/>
|
||||
<xsl:namespace-alias stylesheet-prefix="nxsl" result-prefix="xsl"/>
|
||||
|
||||
<xsl:param name="format"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="//LAYOUT"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="LAYOUT">
|
||||
<nxsl:stylesheet version="1.0"
|
||||
xmlns:dnet="eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions"
|
||||
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
|
||||
exclude-result-prefixes="dnet">
|
||||
|
||||
<nxsl:output version="1.0" omit-xml-declaration="yes"
|
||||
method="xml"/>
|
||||
|
||||
<nxsl:variable name="format">
|
||||
<xsl:value-of select="$format"/>
|
||||
</nxsl:variable>
|
||||
|
||||
<nxsl:template match="/">
|
||||
<indexRecord>
|
||||
<indexRecordIdentifier>
|
||||
<nxsl:value-of select="//dri:objIdentifier"/>
|
||||
</indexRecordIdentifier>
|
||||
<targetFields>
|
||||
<nxsl:if test="count(//*[local-name()='metadata']/*) > 0">
|
||||
<xsl:apply-templates select="FIELDS/FIELD[@indexable='true']"/>
|
||||
</nxsl:if>
|
||||
</targetFields>
|
||||
<dnetResult>
|
||||
<nxsl:copy-of select="/*[local-name()='record']/*[local-name()='result']/*[local-name()='header']"/>
|
||||
<metadata>
|
||||
<xsl:apply-templates select="FIELDS/FIELD"
|
||||
mode="result"/>
|
||||
</metadata>
|
||||
</dnetResult>
|
||||
</indexRecord>
|
||||
</nxsl:template>
|
||||
</nxsl:stylesheet>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="FIELD[@indexable='true']">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@constant">
|
||||
<xsl:element name="{@name}">
|
||||
<xsl:value-of select="@constant"/>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="@value and not(@xpath)">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(@type, 'date')">
|
||||
<nxsl:variable name="{@name}" select="dnet:normalizeDate(normalize-space({normalize-space(@value)}), false())"/>
|
||||
<nxsl:if test="string-length(${@name}) > 0">
|
||||
<nxsl:element name="{@name}">
|
||||
<nxsl:value-of select="${@name}"/>
|
||||
</nxsl:element>
|
||||
</nxsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<nxsl:element name="{@name}">
|
||||
<nxsl:value-of select="{@value}"/>
|
||||
</nxsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@value">
|
||||
<xsl:value-of select="@value"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
.
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<nxsl:for-each select="{@xpath}">
|
||||
<xsl:element name="{@name}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@tokenizable='false'">
|
||||
<nxsl:value-of select="normalize-space({normalize-space($value)})"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<nxsl:value-of select="{normalize-space($value)}"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
</nxsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="FIELD" mode="result">
|
||||
<xsl:if test="@result='true'">
|
||||
<nxsl:copy-of select="{@xpath}"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="FIELD" mode="header">
|
||||
<xsl:if test="@header='true'">
|
||||
<nxsl:copy-of select="{@xpath}"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -0,0 +1,85 @@
|
|||
package eu.dnetlib.openaire.directindex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.api.OpenAIRESubmitterUtils;
|
||||
|
||||
/**
|
||||
* Created by Alessia Bardi on 26/05/2017.
|
||||
*
|
||||
* @author Alessia Bardi
|
||||
*/
|
||||
public class OpenAIRESubmitterUtilsTest {
|
||||
|
||||
private final OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils(
|
||||
"http://beta.services.openaire.eu/openaire/community/");
|
||||
|
||||
final String fullProject = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble";
|
||||
final String minimalProject = "info:eu-repo/grantAgreement/EC/FP7/244909///WorkAble";
|
||||
final String onlyId = "info:eu-repo/grantAgreement/EC/FP7/244909/";
|
||||
final String onlyTitle = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work";
|
||||
final String escapedId = "info:eu-repo/grantAgreement/RCUK//NE%2FL003066%2F1/";
|
||||
|
||||
@Test
|
||||
public void testCalculateProjectInfoEscaped() {
|
||||
final Map<String, String> project = utils.calculateProjectInfo(escapedId);
|
||||
print(project);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateProjectInfoFull() {
|
||||
final Map<String, String> project = utils.calculateProjectInfo(fullProject);
|
||||
print(project);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateProjectInfoOnlyId() {
|
||||
final Map<String, String> project = utils.calculateProjectInfo(onlyId);
|
||||
print(project);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateProjectInfoMinimalAcro() {
|
||||
final Map<String, String> project = utils.calculateProjectInfo(minimalProject);
|
||||
print(project);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateProjectInfoOnlyTitle() {
|
||||
final Map<String, String> project = utils.calculateProjectInfo(onlyTitle);
|
||||
print(project);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJerusalem() {
|
||||
final String s =
|
||||
"info:eu-repo/grantAgreement/EC/FP7/337895/EU/Opening Jerusalem Archives: For a connected History of ‘Citadinité’ in the Holy City (1840-1940)/OPEN-JERUSALEM";
|
||||
final Map<String, String> project = utils.calculateProjectInfo(s);
|
||||
print(project);
|
||||
}
|
||||
|
||||
private void print(final Map<String, String> map) {
|
||||
for (final Entry<String, String> e : map.entrySet()) {
|
||||
System.out.println(e.getKey() + " = " + e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContext() {
|
||||
final List<String> contexts = new ArrayList<>();
|
||||
contexts.add("https://zenodo.org/communities/dimpo");
|
||||
contexts.add("https://zenodo.org/communities/aoo_beopen");
|
||||
final List<OpenAIRESubmitterUtils.ContextInfo> tmp = utils.processContexts(contexts);
|
||||
|
||||
Assert.assertEquals(2, tmp.size());
|
||||
|
||||
Assert.assertTrue(tmp.get(0).getId().equals("dh-ch") || tmp.get(1).getId().equalsIgnoreCase("dh-ch"));
|
||||
Assert.assertTrue(tmp.get(0).getId().equals("dariah") || tmp.get(1).getId().equalsIgnoreCase("dariah"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,284 @@
|
|||
package eu.dnetlib.openaire.directindex.utils;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import eu.dnetlib.openaire.directindex.api.DirectIndexApiException;
|
||||
import eu.dnetlib.openaire.directindex.objects.PidEntry;
|
||||
import eu.dnetlib.openaire.directindex.objects.ResultEntry;
|
||||
|
||||
/**
|
||||
* Created by michele on 14/12/15.
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class OafRecordConverterTest {
|
||||
|
||||
// private VelocityEngine ve;
|
||||
|
||||
private final String community_api = "https://dev-openaire.d4science.org/openaire/community/";
|
||||
|
||||
@Mock
|
||||
private ISLookupClient lookupClient;
|
||||
|
||||
// Class Under Test
|
||||
private OafRecordConverter oafRecordConverter;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
oafRecordConverter = new OafRecordConverter();
|
||||
oafRecordConverter.setCommunity_api(community_api);
|
||||
oafRecordConverter.setOafSchemaLocation("http://oaf/oaf.xsd");
|
||||
oafRecordConverter.setLookupClient(lookupClient);
|
||||
|
||||
// final Properties props = new Properties();
|
||||
// props.setProperty("resource.loader", "class");
|
||||
// props.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||
// props.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.Log4JLogChute");
|
||||
|
||||
when(lookupClient.find(anyString())).thenAnswer(invocation -> {
|
||||
final String query = invocation.getArguments()[0].toString();
|
||||
if (query.contains("dnet:result_typologies")) {
|
||||
return Arrays.asList("publication @@@ publication", "dataset @@@ dataset", "software @@@ software", "other @@@ other");
|
||||
} else if (query.contains("dnet:access_modes")) {
|
||||
return Arrays.asList("OPEN @@@ Open Access");
|
||||
} else if (query.contains("dnet:publication_resource")) {
|
||||
return Arrays.asList("0001 @@@ Journal Article");
|
||||
} else if (query.contains("dnet:pid_types")) {
|
||||
return Arrays.asList("oai @@@ Open Archive Initiative", "doi @@@ Digital object identifier");
|
||||
} else if (query.contains("dnet:languages")) {
|
||||
return Arrays.asList("ita @@@ Italian");
|
||||
} else if (query.contains("ContextDSResourceType")) {
|
||||
return Arrays
|
||||
.asList("egi::classification::natsc::math::stats @@@ Statistics and Probability", "egi::classification::natsc::math::pure @@@ Pure Mathematics", "egi::classification::natsc::math @@@ Mathematics", "egi::classification::natsc @@@ Natural Sciences", "egi::classification @@@ EGI classification scheme", "egi @@@ EGI", "enermaps::selection @@@ Selected by the H2020 EnerMaps project");
|
||||
} else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
});
|
||||
|
||||
when(lookupClient.findOne(anyString())).thenAnswer(invocation -> "REPO NAME @@@ repo________");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord() throws Exception {
|
||||
final ResultEntry pub = new ResultEntry();
|
||||
pub.setOriginalId("ORIG_ID_1234");
|
||||
pub.setTitle("TEST TITLE <test>");
|
||||
pub.getAuthors().add("Michele Artini");
|
||||
pub.getAuthors().add("Claudio Atzori");
|
||||
pub.getAuthors().add("Alessia Bardi");
|
||||
pub.setPublisher("Test publisher");
|
||||
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION ");
|
||||
pub.setLanguage("ita");
|
||||
pub.setLicenseCode("OPEN");
|
||||
pub.setResourceType("0001");
|
||||
pub.setUrl("http://test.it/a=1&b=2");
|
||||
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123"));
|
||||
pub.getPids().add(new PidEntry("oai", "oai:1234"));
|
||||
pub.setCollectedFromId("test________::zenodo");
|
||||
pub.setHostedById("test________::UNKNOWN");
|
||||
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus");
|
||||
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/RCUK//244%2F909/EU/Making Capabilities Work/WorkAble");
|
||||
pub.getContexts().add("egi::classification::natsc::math::pure");
|
||||
pub.getContexts().add("egi::classification::natsc::math::stats");
|
||||
pub.getContexts().add("enermaps");
|
||||
pub.getContexts().add("enermaps::selection");
|
||||
final String xml = oafRecordConverter.convert(pub);
|
||||
|
||||
final Document doc = new SAXReader().read(new StringReader(xml));
|
||||
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
|
||||
final XMLWriter writer = new XMLWriter(System.out, format);
|
||||
|
||||
writer.write(doc);
|
||||
|
||||
/* writer.close(); */
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecordAccessRight() throws Exception {
|
||||
final ResultEntry pub = new ResultEntry();
|
||||
pub.setOriginalId("ORIG_ID_1234");
|
||||
pub.setTitle("TEST TITLE <test>");
|
||||
pub.getAuthors().add("Michele Artini");
|
||||
pub.getAuthors().add("Claudio Atzori");
|
||||
pub.getAuthors().add("Alessia Bardi");
|
||||
pub.setPublisher("Test publisher");
|
||||
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION ");
|
||||
pub.setLanguage("ita");
|
||||
pub.setLicenseCode("CLOSED");
|
||||
pub.setAccessRightCode("OPEN");
|
||||
pub.setResourceType("0001");
|
||||
pub.setUrl("http://test.it/a=1&b=2");
|
||||
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123"));
|
||||
pub.getPids().add(new PidEntry("oai", "oai:1234"));
|
||||
pub.setCollectedFromId("test________::zenodo");
|
||||
pub.setHostedById("test________::UNKNOWN");
|
||||
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus");
|
||||
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble");
|
||||
pub.getContexts().add("egi::classification::natsc::math::pure");
|
||||
pub.getContexts().add("egi::classification::natsc::math::stats");
|
||||
|
||||
final String xml = oafRecordConverter.convert(pub);
|
||||
|
||||
final Document doc = new SAXReader().read(new StringReader(xml));
|
||||
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
|
||||
final XMLWriter writer = new XMLWriter(System.out, format);
|
||||
|
||||
writer.write(doc);
|
||||
|
||||
/* writer.close(); */
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsORP() throws Exception {
|
||||
final ResultEntry pub = new ResultEntry();
|
||||
pub.setOriginalId("ORIG_ID_1234");
|
||||
pub.setTitle("TEST TITLE <test>");
|
||||
pub.getAuthors().add("Michele Artini");
|
||||
pub.getAuthors().add("Claudio Atzori");
|
||||
pub.getAuthors().add("Alessia Bardi");
|
||||
pub.setPublisher("Test publisher");
|
||||
pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION ");
|
||||
pub.setLanguage("ita");
|
||||
pub.setLicenseCode("CLOSED");
|
||||
pub.setAccessRightCode("OPEN");
|
||||
pub.setResourceType("0020");
|
||||
pub.setType("other");
|
||||
pub.setUrl("http://test.it/a=1&b=2");
|
||||
pub.getPids().add(new PidEntry("doi", "10.000/xyz-123"));
|
||||
pub.getPids().add(new PidEntry("oai", "oai:1234"));
|
||||
pub.setCollectedFromId("test________::zenodo");
|
||||
pub.setHostedById("test________::UNKNOWN");
|
||||
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus");
|
||||
pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble");
|
||||
pub.getContexts().add("egi::classification::natsc::math::pure");
|
||||
pub.getContexts().add("egi::classification::natsc::math::stats");
|
||||
|
||||
final String xml = oafRecordConverter.convert(pub);
|
||||
|
||||
final Document doc = new SAXReader().read(new StringReader(xml));
|
||||
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
|
||||
final XMLWriter writer = new XMLWriter(System.out, format);
|
||||
|
||||
writer.write(doc);
|
||||
|
||||
/* writer.close(); */
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json() throws Exception {
|
||||
testAsIndexRecord_json("test_record.json");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json_with_greek_chars() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_record_with_greek_chars.json");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_openaireId() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_record_openaireId.json");
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = DirectIndexApiException.class)
|
||||
public void testAsIndexRecord_wrongOpenaireId() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_record_wrong_openaireId.json");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json_zenodo() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_zenodo.json");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json_zenodoWithAmpersand() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_zenodoAmpersandEverywhere.json");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json_software() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_record_software.json");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json_orp() throws Exception {
|
||||
|
||||
testAsIndexRecord_json("test_record_orp.json");
|
||||
|
||||
}
|
||||
|
||||
private void testAsIndexRecord_json(final String filename) throws Exception {
|
||||
final ResultEntry pub =
|
||||
new ObjectMapper().readValue(getClass().getResourceAsStream(filename), ResultEntry.class);
|
||||
|
||||
final String xml = oafRecordConverter.convert(pub);
|
||||
// System.out.println(xml);
|
||||
|
||||
final Document doc = new SAXReader().read(new StringReader(xml));
|
||||
|
||||
final OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
|
||||
final XMLWriter writer = new XMLWriter(System.out, format);
|
||||
|
||||
writer.write(doc);
|
||||
|
||||
/* writer.close(); */
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecord_json_zenodocommunities() throws Exception {
|
||||
testAsIndexRecord_json("test_zenodo_community.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIndexRecordFromSandbox_json_zenodocommunities() throws Exception {
|
||||
testAsIndexRecord_json("test_zenodo_community2.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEscapeUnicode() {
|
||||
final String unicodeTxt =
|
||||
"i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$";
|
||||
System.out.println(StringEscapeUtils.escapeXml11(unicodeTxt));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
### Root Level ###
|
||||
log4j.rootLogger=WARN, CONSOLE
|
||||
### Configuration for the CONSOLE appender ###
|
||||
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d %c - %m%n
|
||||
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
|
||||
### Application Level ###
|
||||
log4j.logger.eu.dnetlib=INFO
|
||||
log4j.logger.eu.dnetlib.msro.openaireplus.workflows.nodes.contexts=DEBUG
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"originalId": "ORIG_ID_12345",
|
||||
"title": "TEST TITLE",
|
||||
"authors": [
|
||||
"Michele Artini",
|
||||
"Claudio Atzori",
|
||||
"Alessia Bardi"
|
||||
],
|
||||
"publisher": "Test publisher",
|
||||
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
|
||||
"language": "ita",
|
||||
"pids": [
|
||||
{
|
||||
"type": "doi",
|
||||
"value": "10.000/xyz-123"
|
||||
},
|
||||
{
|
||||
"type": "oai",
|
||||
"value": "oai:1234"
|
||||
}
|
||||
],
|
||||
"accessRightCode": "OPEN",
|
||||
"resourceType": "0001",
|
||||
"url": "http://test.it/xyz",
|
||||
"collectedFromId": "opendoar____::2659",
|
||||
"hostedById": "opendoar____::2367",
|
||||
"linksToProjects": [
|
||||
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
|
||||
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
|
||||
],
|
||||
"contexts": [
|
||||
"egi::classification::natsc::math::pure",
|
||||
"egi::classification::natsc::math::stats"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982950",
|
||||
"originalId": "oai:rudar.ruc.dk:1800/24690",
|
||||
"type": "publication",
|
||||
"title": "Autofiktion",
|
||||
"authors": [
|
||||
"Sloan, Patrick Alexander Raaby",
|
||||
"Strange, Gustav Valdemar",
|
||||
"Freund-Jensen, Sofie",
|
||||
"Canvin, Emilie Meistrup",
|
||||
"Faaborg, Ida Selvejer",
|
||||
"Kruse, Mikkel"
|
||||
],
|
||||
"publisher": "",
|
||||
"description": "The following paper is a project on the autofictional book Færdig med Eddy Bellegueule by Édouard Louis (2015). The main focus is to ascertain how the novel is an expression of the author’s effort to connect social life and literature, and what part autofiction as a genre plays in this process. A textual analysis will describe the narrator’s position, and the aesthetic grip of the novel. Furthermore, we will analyze the central themes in Louis’ novel with theories by sociologist Pierre Bourdieu, gender theorist Judith Butler and postcolonial theorist Gayatri Spivak. This includes symbolic violence, gender roles, language and suppression. With use of classic literary theory and the more recent and specific theory on autofiction, the paper concludes, that Færdig med Eddy Bellegueule is based on non-fictional events, but presents these events through a fictionalization that raise the story into a literary work of art. The genre autofiction encircles a current tendency to blend non-fictional events and characters into literature, and Færdig med Eddy Bellegueule writes itself perfectly into this twilight zone between fact and fiction.",
|
||||
"language": "eng",
|
||||
"pids": [],
|
||||
"licenseCode": "OPEN",
|
||||
"resourceType": "0006",
|
||||
"url": "http://rudar.ruc.dk/handle/1800/24690",
|
||||
"collectedFromId": "opendoar____::278",
|
||||
"hostedById": "opendoar____::278",
|
||||
"linksToProjects": [],
|
||||
"contexts": []
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"originalId": "ORIG_ID_TEST",
|
||||
"type": "publication",
|
||||
"title": "TEST TITLE",
|
||||
"authors": [
|
||||
"Michele Artini",
|
||||
"Claudio Atzori",
|
||||
"Alessia Bardi"
|
||||
],
|
||||
"publisher": "Test publisher",
|
||||
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
|
||||
"language": "ita",
|
||||
"pids": [
|
||||
{
|
||||
"type": "doi",
|
||||
"value": "10.000/xyz-123"
|
||||
},
|
||||
{
|
||||
"type": "oai",
|
||||
"value": "oai:1234"
|
||||
}
|
||||
],
|
||||
"accessRightCode": "EMBARGO",
|
||||
"embargoEndDate": "2018-02-02",
|
||||
"resourceType": "0001",
|
||||
"url": "http://test.it/xyz",
|
||||
"collectedFromId": "opendoar____::2659",
|
||||
"hostedById": "opendoar____::2659",
|
||||
"linksToProjects": [
|
||||
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
|
||||
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
|
||||
],
|
||||
"contexts": [
|
||||
"egi::classification::natsc::math::pure",
|
||||
"egi::classification::natsc::math::stats"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"openaireId":"dedup_wf_001::ab42e8116f4ae3c4021fb7c643a8167a",
|
||||
"originalId": "ORIG_ID_TEST",
|
||||
"type": "publication",
|
||||
"title": "TEST TITLE",
|
||||
"authors": [
|
||||
"Michele Artini",
|
||||
"Claudio Atzori",
|
||||
"Alessia Bardi"
|
||||
],
|
||||
"publisher": "Test publisher",
|
||||
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
|
||||
"language": "ita",
|
||||
"pids": [
|
||||
{
|
||||
"type": "doi",
|
||||
"value": "10.000/xyz-123"
|
||||
},
|
||||
{
|
||||
"type": "oai",
|
||||
"value": "oai:1234"
|
||||
}
|
||||
],
|
||||
"accessRightCode": "EMBARGO",
|
||||
"licenseCode": "OPEN",
|
||||
"embargoEndDate": "2018-02-02",
|
||||
"resourceType": "0001",
|
||||
"url": "http://test.it/xyz",
|
||||
"collectedFromId": "opendoar____::2659",
|
||||
"hostedById": "opendoar____::2659",
|
||||
"linksToProjects": [
|
||||
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
|
||||
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
|
||||
],
|
||||
"contexts": [
|
||||
"egi::classification::natsc::math::pure",
|
||||
"egi::classification::natsc::math::stats"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982951",
|
||||
"originalId": "oai:rudar.ruc.dk:1800/24691",
|
||||
"type": "other",
|
||||
"title": "Other test record",
|
||||
"authors": [
|
||||
"Sloan, Patrick Alexander Raaby",
|
||||
"Strange, Gustav Valdemar"
|
||||
],
|
||||
"publisher": "",
|
||||
"description": "This is for testing software",
|
||||
"language": "eng",
|
||||
"pids": [],
|
||||
"licenseCode": "OPEN SOURCE",
|
||||
"resourceType": "0000",
|
||||
"url": "http://rudar.ruc.dk/handle/1800/24691",
|
||||
"collectedFromId": "opendoar____::278",
|
||||
"hostedById": "opendoar____::278",
|
||||
"linksToProjects": [],
|
||||
"contexts": []
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982951",
|
||||
"originalId": "oai:rudar.ruc.dk:1800/24691",
|
||||
"type": "software",
|
||||
"title": "Software test",
|
||||
"authors": [
|
||||
"Sloan, Patrick Alexander Raaby",
|
||||
"Strange, Gustav Valdemar"
|
||||
],
|
||||
"publisher": "",
|
||||
"description": "This is for testing software",
|
||||
"language": "eng",
|
||||
"pids": [],
|
||||
"licenseCode": "OPEN SOURCE",
|
||||
"resourceType": "0000",
|
||||
"url": "http://rudar.ruc.dk/handle/1800/24691",
|
||||
"collectedFromId": "opendoar____::278",
|
||||
"hostedById": "opendoar____::278",
|
||||
"linksToProjects": [],
|
||||
"contexts": []
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"originalId": "ORIG_ID_12345",
|
||||
"title": "TEST TITLE WITH Greek Characters",
|
||||
"authors": [
|
||||
"αβγδεζηθικλμ νξοπρσςτυφχψω",
|
||||
"ΑΒΓΔΕΖΗΘΙΚΛ ΜΝΞΟΠΡΣΤΥΦΧΨΩ"
|
||||
],
|
||||
"publisher": "âââââââ",
|
||||
"description": "Αν περιμένατε να βρίσκεται εδώ μια σελίδα και δεν υπάρχει, η σελίδα μπορεί να μην εμφανίζεται λόγω καθυστέρησης στην ανανέωση της βάσης δεδομένων, ή μπορεί να έχει διαγραφεί. (Δείτε την γρήγορη διαγραφή σελίδων για πιθανούς λόγους). Μπορείτε να δοκιμάστε την λειτουργία εκκαθάρισης, και να ελέγξετε το αρχείο διαγραφών.",
|
||||
"language": "ell",
|
||||
"pids": [
|
||||
{
|
||||
"type": "doi",
|
||||
"value": "10.000/xyz-123-gr"
|
||||
}
|
||||
],
|
||||
"licenseCode": "EMBARGO",
|
||||
"embargoEndDate": "2018-02-02",
|
||||
"resourceType": "0001",
|
||||
"url": "http://test.it/xyz",
|
||||
"collectedFromId": "opendoar____::2659",
|
||||
"hostedById": "opendoar____::2367",
|
||||
"linksToProjects": [
|
||||
"info:eu-repo/grantAgreement/EC/FP7/123456/EU//Test"
|
||||
],
|
||||
"contexts": [
|
||||
"egi::classification::natsc::math::stats"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"openaireId":"dedup_wf_001::ab42e811",
|
||||
"originalId": "ORIG_ID_TEST",
|
||||
"type": "publication",
|
||||
"title": "TEST TITLE",
|
||||
"authors": [
|
||||
"Michele Artini",
|
||||
"Claudio Atzori",
|
||||
"Alessia Bardi"
|
||||
],
|
||||
"publisher": "Test publisher",
|
||||
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
|
||||
"language": "ita",
|
||||
"pids": [
|
||||
{
|
||||
"type": "doi",
|
||||
"value": "10.000/xyz-123"
|
||||
},
|
||||
{
|
||||
"type": "oai",
|
||||
"value": "oai:1234"
|
||||
}
|
||||
],
|
||||
"licenseCode": "EMBARGO",
|
||||
"embargoEndDate": "2018-02-02",
|
||||
"resourceType": "0001",
|
||||
"url": "http://test.it/xyz",
|
||||
"collectedFromId": "opendoar____::2659",
|
||||
"hostedById": "opendoar____::2659",
|
||||
"linksToProjects": [
|
||||
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
|
||||
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
|
||||
],
|
||||
"contexts": [
|
||||
"egi::classification::natsc::math::pure",
|
||||
"egi::classification::natsc::math::stats"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"authors":[
|
||||
"Alouges, Fran\u00e7ois",
|
||||
"Di Fratta, Giovanni"
|
||||
],
|
||||
"collectedFromId":"opendoar____::2659",
|
||||
"description":"The paper is about the parking 3-sphere swimmer ($\\text{sPr}_3$). This is a low-Reynolds number model swimmer composed of three balls of equal radii. The three balls can move along three horizontal axes (supported in the same plane) that mutually meet at the center of $\\text{sPr}_3$ with angles of $120^{\u2218}$ . The governing dynamical system is introduced and the implications of its geometric symmetries revealed. It is then shown that, in the first order range of small strokes, optimal periodic strokes are ellipses embedded in 3d space, i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$ and $v$ of $\u211d^3$. A simple analytic expression for the vectors $u$ and $v$ is derived. The results of the paper are used in a second article where the real physical dynamics of $\\text{sPr}_3$ is analyzed in the asymptotic range of very long arms. ; Comment: 17 pages, 4 figures",
|
||||
"hostedById":"opendoar____::2659",
|
||||
"licenseCode":"OPEN",
|
||||
"originalId":"oai:zenodo.org:996201",
|
||||
"pids":[
|
||||
{
|
||||
"type":"oai",
|
||||
"value":"oai:zenodo.org:996201"
|
||||
},
|
||||
{
|
||||
"type":"doi",
|
||||
"value":"10.5281/zenodo.996201"
|
||||
}
|
||||
],
|
||||
"publisher":"Zenodo",
|
||||
"resourceType":"0020",
|
||||
"title":"Parking 3-sphere swimmer. I. Energy minimizing strokes",
|
||||
"type":"publication",
|
||||
"url":"https://zenodo.org/record/996201"
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"authors": [
|
||||
"Conradt, Tobias",
|
||||
"& members of the ISIMIP project (original data provision), cf. Hempel et al. 2013, https://doi.org/10.5194/esd-4-219-2013"
|
||||
],
|
||||
"collectedFromId": "re3data_____::r3d100010468",
|
||||
"description": "<p>ISIMIP-2a climate data cutout provided for Sardinia in the framework of SIM4NEXUS & X<\/p>",
|
||||
"hostedById": "re3data_____::r3d100010468",
|
||||
"licenseCode": "OPEN",
|
||||
"linksToProjects": ["info:eu-repo/grantAgreement/EC/H2020/689150//Sustainable Integrated Management FOR the NEXUS of water-land-food-energy-climate for a resource-efficient Europe & beyond/SIM4NEXUS"],
|
||||
"originalId": "10.5281/zenodo.1460665",
|
||||
"pids": [
|
||||
{
|
||||
"type": "oai",
|
||||
"value": "oai:zenodo.org:1460665"
|
||||
},
|
||||
{
|
||||
"type": "doi",
|
||||
"value": "10.5281/zenodo.1460665"
|
||||
}
|
||||
],
|
||||
"publisher": "Zenodo & Zenodo",
|
||||
"resourceType": "0021",
|
||||
"title": "sardinia_tasmax_MIROC-ESM-CHEM_rcp4p5_2006-2099_daily.nc4 & the title has && in it",
|
||||
"type": "dataset",
|
||||
"url": "https://zenodo.org/record/1460665"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{"authors": ["Dag Haug", "Marius J\xf8hndal"],
|
||||
"collectedFromId": "re3data_____::r3d100010468",
|
||||
"contexts": ["https://sandbox.zenodo.org/communities/oac-ni","pippo"],
|
||||
"description": "<p>Official releases of the PROIEL treebank of ancient Indo-European languages</p>",
|
||||
"hostedById": "re3data_____::r3d100010468",
|
||||
"licenseCode": "OPEN",
|
||||
"originalId": "10.5281/zenodo.11003",
|
||||
"pids": [{"type": "oai", "value": "oai:zenodo.org:11003"},
|
||||
{"type": "doi", "value": "10.5281/zenodo.11003"}],
|
||||
"publisher": "Zenodo",
|
||||
"resourceType": "0021",
|
||||
"title": "proiel-treebank: 20140723 version",
|
||||
"type": "dataset",
|
||||
"url": "https://zenodo.org/record/11003"}
|
|
@ -0,0 +1,9 @@
|
|||
{"authors":["test"],
|
||||
"collectedFromId":"re3data_____::r3d100010468",
|
||||
"contexts":["https://zenodo.org/communities/oac-ni"],
|
||||
"description":"<p>test</p>",
|
||||
"hostedById":"re3data_____::r3d100010468",
|
||||
"licenseCode":"OPEN",
|
||||
"originalId":"oai:zenodo.org:315784",
|
||||
"pids":[{"type":"oai","value":"oai:zenodo.org:315784"},
|
||||
{"type":"doi","value":"10.5072/zenodo.315784"}],"resourceType":"0020","title":"test","type":"other","url":"https://zenodo.org/record/315784"}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"authors": ["Milanese, Alessio", "Mende, Daniel", "Zeller, Georg", "Sunagawa, Shinichi"],
|
||||
"collectedFromId": "re3data_____::r3d100010468",
|
||||
"description": "<p>We simulated ten human gut metagenomic samples to assess the taxonomic quantification accuracy of the mOTUs tool (<a href=\"http: \// motu-tool.org \/\">link</a>). In this directory you can find the metagenomic samples, the gold standard (used to produce them) and the profiles obtained with four metagenomic profiler tools.</p>\\n\\n<p>Check README.txt for more information.</p>",
|
||||
"hostedById": "re3data_____::r3d100010468",
|
||||
"licenseCode": "OPEN",
|
||||
"originalId": "10.5281/zenodo.1473645",
|
||||
"pids": [
|
||||
{"type": "oai", "value": "oai:zenodo.org:1473645"},
|
||||
{"type": "doi", "value": "10.5281/zenodo.1473645"}
|
||||
],
|
||||
"publisher": "Zenodo",
|
||||
"resourceType": "0021",
|
||||
"title": "Simulated Human gut metagenomic samples to benchmark mOTUs v2",
|
||||
"type": "dataset",
|
||||
"url": "https://zenodo.org/record/1473645",
|
||||
"version": "2"
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
<module>dhp-broker-public-application</module>
|
||||
<module>dhp-mdstore-manager</module>
|
||||
<module>dnet-orgs-database-application</module>
|
||||
<module>dnet-directindex</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
|
Loading…
Reference in New Issue