diff --git a/TODO.txt b/TODO.txt
index 71202c7..c4c9d30 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -17,6 +17,7 @@
- Uso dei record all'interno del wf di provision
5) Generazione del record SOLR
+ - Usare classe eu.dnetlib.dhp.schema.solr.SolrRecord di dhp-schemas 9.0.0
- Profilo del MetadataFormat
- XML / JSON
diff --git a/pom.xml b/pom.xml
index 08f2a9e..6db7112 100644
--- a/pom.xml
+++ b/pom.xml
@@ -155,7 +155,20 @@
cxf-rt-transports-http
3.1.5
-
+
+
+
+ eu.dnetlib.dhp
+ dhp-schemas
+ ${dhp-schemas-version}
+
+
+ io.swagger.core.v3
+ swagger-annotations
+
+
+
+
org.apache.solr
@@ -279,13 +292,6 @@
2.3.2
-
-
- javax.mail
- mail
- 1.4.7
-
-
org.springdoc
@@ -293,67 +299,7 @@
1.6.10
-
-
- org.apache.hadoop
- hadoop-client
- 2.6.0-cdh5.9.2
-
-
- org.slf4j
- slf4j-log4j12
-
-
- javax.servlet
- servlet-api
-
-
- com.google.guava
- guava
-
-
- org.apache.hadoop
- hadoop-aws
-
-
-
-
-
- hwu.elixir
- bmuse-core
- 0.5.4
-
-
- org.apache.any23
- apache-any23-core
- 2.3
-
-
- org.eclipse.rdf4j
- rdf4j-rio-rdfxml
- 3.7.1
-
-
- org.eclipse.rdf4j
- rdf4j-model
- 3.7.1
-
-
- org.jsoup
- jsoup
- 1.13.1
-
-
- org.seleniumhq.selenium
- selenium-java
- 3.141.59
-
-
- commons-validator
- commons-validator
- 1.6
-
@@ -488,7 +434,7 @@
3.6.0
17
2.6.1
- 2.14.0
+ 9.0.0
9.7.0
3.4.2
0.10.0
diff --git a/src/main/java/eu/dnetlib/app/directindex/controllers/LegacyApiController.java b/src/main/java/eu/dnetlib/app/directindex/controllers/LegacyApiController.java
index 1015678..0b28d82 100644
--- a/src/main/java/eu/dnetlib/app/directindex/controllers/LegacyApiController.java
+++ b/src/main/java/eu/dnetlib/app/directindex/controllers/LegacyApiController.java
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
import eu.dnetlib.app.directindex.input.ResultEntry;
-import eu.dnetlib.app.directindex.mapping.OafMapper;
+import eu.dnetlib.app.directindex.mapping.SolrRecordMapper;
import eu.dnetlib.app.directindex.service.DirectIndexService;
@RestController("/api")
@@ -31,7 +31,7 @@ public class LegacyApiController {
private DirectIndexService service;
@Autowired
- private OafMapper oafMapper;
+ private SolrRecordMapper solrRecordMapper;
@PostMapping("/results/feedObject")
public String feedResult(@RequestBody final ResultEntry pub, @RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit)
@@ -56,7 +56,7 @@ public class LegacyApiController {
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId,
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirectIndexApiException {
- final String openaireId = oafMapper.calculateOpenaireId(originalId, collectedFromId);
+ final String openaireId = solrRecordMapper.calculateOpenaireId(originalId, collectedFromId);
service.prepareMetadataDeletion(openaireId);
diff --git a/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java b/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java
index c4b00c6..95c914a 100644
--- a/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java
+++ b/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java
@@ -2,7 +2,6 @@ package eu.dnetlib.app.directindex.controllers;
import java.io.IOException;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -29,12 +28,13 @@ import eu.dnetlib.app.directindex.errors.SwordError;
import eu.dnetlib.app.directindex.errors.SwordErrorType;
import eu.dnetlib.app.directindex.errors.SwordException;
import eu.dnetlib.app.directindex.input.ResultEntry;
-import eu.dnetlib.app.directindex.mapping.OafMapper;
+import eu.dnetlib.app.directindex.mapping.SolrRecordMapper;
import eu.dnetlib.app.directindex.service.DirectIndexService;
import eu.dnetlib.app.directindex.solr.SolrIndexClient;
import eu.dnetlib.app.directindex.solr.SolrIndexClientFactory;
import eu.dnetlib.app.directindex.sword.model.SwordServiceDocument;
import eu.dnetlib.app.directindex.sword.model.SwordStatusDocument;
+import eu.dnetlib.dhp.schema.solr.SolrRecord;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -49,7 +49,7 @@ public class SwordApiController {
private SolrIndexClientFactory solrIndexClientFactory;
@Autowired
- private OafMapper oafMapper;
+ private SolrRecordMapper solRecordMapper;
@Value("${dnet.directindex.baseurl}")
private String baseUrl;
@@ -105,11 +105,11 @@ public class SwordApiController {
final SolrIndexClient solr = solrIndexClientFactory.getClient();
- final String metadata = solr.findRecord(id);
+ final SolrRecord metadata = solr.findRecord(id);
- if (StringUtils.isBlank(metadata)) { throw new SwordException(SwordErrorType.NotFound); }
+ if (metadata == null) { throw new SwordException(SwordErrorType.NotFound); }
- return new ResponseEntity<>(oafMapper.toResultEntry(metadata), HttpStatus.OK);
+ return new ResponseEntity<>(solRecordMapper.toResultEntry(metadata), HttpStatus.OK);
}
@PutMapping("/objects/{id}/metadata")
diff --git a/src/main/java/eu/dnetlib/app/directindex/mapping/OafMapper.java b/src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java
similarity index 61%
rename from src/main/java/eu/dnetlib/app/directindex/mapping/OafMapper.java
rename to src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java
index a98dfcf..0287ebc 100644
--- a/src/main/java/eu/dnetlib/app/directindex/mapping/OafMapper.java
+++ b/src/main/java/eu/dnetlib/app/directindex/mapping/SolrRecordMapper.java
@@ -8,20 +8,37 @@ import eu.dnetlib.app.directindex.clients.DatasourceManagerClient;
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
import eu.dnetlib.app.directindex.input.DatasourceEntry;
import eu.dnetlib.app.directindex.input.ResultEntry;
+import eu.dnetlib.dhp.schema.solr.SolrRecord;
@Component
-public class OafMapper {
+public class SolrRecordMapper {
@Autowired
private DatasourceManagerClient dsmClient;
- public String toOAF(final ResultEntry result) {
+ public SolrRecord toSolrRecord(final ResultEntry result) {
// TODO
- return null;
+ final SolrRecord sr = new SolrRecord();
+
+ sr.setHeader(null);
+ sr.setResult(null);
+
+ sr.setDatasource(null); // NULL for Result Entry
+ sr.setProject(null); // NULL for Result Entry
+ sr.setOrganization(null); // NULL for Result Entry
+ sr.setPerson(null); // NULL for Result Entry
+
+ sr.setLinks(null);
+ sr.setCollectedfrom(null);
+ sr.setPid(null);
+ sr.setContext(null);
+ sr.setMeasures(null);
+
+ return sr;
}
- public ResultEntry toResultEntry(final String oaf) {
+ public ResultEntry toResultEntry(final SolrRecord r) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/main/java/eu/dnetlib/app/directindex/solr/SolrIndexClient.java b/src/main/java/eu/dnetlib/app/directindex/solr/SolrIndexClient.java
index e268b07..59fe411 100644
--- a/src/main/java/eu/dnetlib/app/directindex/solr/SolrIndexClient.java
+++ b/src/main/java/eu/dnetlib/app/directindex/solr/SolrIndexClient.java
@@ -1,9 +1,7 @@
package eu.dnetlib.app.directindex.solr;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Date;
import java.util.Iterator;
import java.util.stream.Stream;
@@ -14,6 +12,7 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.common.SolrInputDocument;
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
+import eu.dnetlib.dhp.schema.solr.SolrRecord;
public class SolrIndexClient {
@@ -42,7 +41,7 @@ public class SolrIndexClient {
}
}
- public void addRecords(final Stream records) throws DirectIndexApiException {
+ public void addRecords(final Stream records) throws DirectIndexApiException {
try {
final Iterator iter = records
.map(this::prepareSolrDocument)
@@ -54,24 +53,18 @@ public class SolrIndexClient {
}
}
- public void addRecords(final String... xmlRecords) throws Exception {
- addRecords(Arrays.stream(xmlRecords));
+ public void addRecords(final SolrRecord... records) throws Exception {
+ addRecords(Arrays.stream(records));
}
- protected SolrInputDocument prepareSolrDocument(final String record) {
+ protected SolrInputDocument prepareSolrDocument(final SolrRecord record) {
+ // TODO (usare classe ccondivisa preparata da Claudio)
- final String version = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'").format(new Date());
- final StreamingInputDocumentFactory documentFactory = new StreamingInputDocumentFactory(version);
- final String indexRecord = SolrRecordMappper.toSolr(record);
- if (log.isDebugEnabled()) {
- log.debug("***************************************\nSubmitting index record:\n" + indexRecord +
- "\n***************************************\n");
- }
- return documentFactory.parseDocument(indexRecord);
+ return null;
}
- public String findRecord(final String id) {
+ public SolrRecord findRecord(final String id) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/main/java/eu/dnetlib/app/directindex/solr/SolrRecordMappper.java b/src/main/java/eu/dnetlib/app/directindex/solr/SolrRecordMappper.java
deleted file mode 100644
index e190f3f..0000000
--- a/src/main/java/eu/dnetlib/app/directindex/solr/SolrRecordMappper.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package eu.dnetlib.app.directindex.solr;
-
-public class SolrRecordMappper {
-
- public static String toSolr(final String record) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/src/main/java/eu/dnetlib/app/directindex/tasks/ScheduledActions.java b/src/main/java/eu/dnetlib/app/directindex/tasks/ScheduledActions.java
index 7f9fb69..0ecf365 100644
--- a/src/main/java/eu/dnetlib/app/directindex/tasks/ScheduledActions.java
+++ b/src/main/java/eu/dnetlib/app/directindex/tasks/ScheduledActions.java
@@ -4,7 +4,6 @@ import java.time.OffsetDateTime;
import java.util.List;
import java.util.Objects;
-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;
@@ -16,7 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
import eu.dnetlib.app.directindex.input.ResultEntry;
-import eu.dnetlib.app.directindex.mapping.OafMapper;
+import eu.dnetlib.app.directindex.mapping.SolrRecordMapper;
import eu.dnetlib.app.directindex.repo.PendingAction;
import eu.dnetlib.app.directindex.repo.PendingActionRepository;
import eu.dnetlib.app.directindex.solr.SolrIndexClient;
@@ -34,7 +33,7 @@ public class ScheduledActions {
private SolrIndexClientFactory solrIndexClientFactory;
@Autowired
- private OafMapper oafMapper;
+ private SolrRecordMapper solrRecordMapper;
@Autowired
private PendingActionRepository pendingActionRepository;
@@ -66,8 +65,8 @@ public class ScheduledActions {
}
})
.filter(Objects::nonNull)
- .map(oafMapper::toOAF)
- .filter(StringUtils::isNotBlank));
+ .map(solrRecordMapper::toSolrRecord)
+ .filter(Objects::nonNull));
solr.commit();