diff --git a/solr/configsets/scholars-discovery/conf/managed-schema.xml b/solr/configsets/scholars-discovery/conf/managed-schema.xml
index 9b732b66a..2330f9510 100644
--- a/solr/configsets/scholars-discovery/conf/managed-schema.xml
+++ b/solr/configsets/scholars-discovery/conf/managed-schema.xml
@@ -111,7 +111,6 @@
-->
-
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java b/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java
index d44104d28..c530c70d5 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java
@@ -16,6 +16,8 @@ public class DiscoveryConstants {
public static final String MOD_TIME = "modTime";
+ public static final String SYNC_IDS = "syncIds";
+
public static final String QUERY_DELIMETER = ":";
public static final String DEFAULT_QUERY = WILDCARD + QUERY_DELIMETER + WILDCARD;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java
index 6371170ba..1302adc30 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java
@@ -1,13 +1,14 @@
package edu.tamu.scholars.middleware.discovery.component;
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
+import edu.tamu.scholars.middleware.discovery.model.Individual;
import reactor.core.publisher.Flux;
public interface Harvester {
- public Flux harvest();
+ public Flux harvest();
- public AbstractIndexDocument harvest(String subject);
+ public Individual harvest(String subject);
public Class type();
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java
index 10c07f3e5..81556bfe2 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java
@@ -3,14 +3,15 @@
import java.util.Collection;
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
+import edu.tamu.scholars.middleware.discovery.model.Individual;
public interface Indexer {
public void init();
- public void index(Collection documents);
+ public void index(Collection documents);
- public void index(AbstractIndexDocument document);
+ public void index(Individual document);
public void optimize();
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java b/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java
index 0f8575a96..14aa6a3c1 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java
@@ -1,16 +1,20 @@
package edu.tamu.scholars.middleware.discovery.component.jena;
+import static edu.tamu.scholars.middleware.discovery.DiscoveryConstants.CLASS;
import static edu.tamu.scholars.middleware.discovery.DiscoveryConstants.ID;
import static edu.tamu.scholars.middleware.discovery.DiscoveryConstants.NESTED_DELIMITER;
+import static edu.tamu.scholars.middleware.discovery.DiscoveryConstants.SYNC_IDS;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -32,6 +36,7 @@
import edu.tamu.scholars.middleware.discovery.annotation.FieldType;
import edu.tamu.scholars.middleware.discovery.component.Harvester;
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
+import edu.tamu.scholars.middleware.discovery.model.Individual;
import edu.tamu.scholars.middleware.service.TemplateService;
import edu.tamu.scholars.middleware.service.Triplestore;
import reactor.core.publisher.Flux;
@@ -66,22 +71,21 @@ public TriplestoreHarvester(Class type) {
this.indexedFields = FieldUtils.getFieldsListWithAnnotation(type, FieldType.class);
}
- public Flux harvest() {
+ public Flux harvest() {
CollectionSource source = type.getAnnotation(CollectionSource.class);
String query = templateService.templateSparql(COLLECTION_SPARQL_TEMPLATE, source.predicate());
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("%s:\n%s", COLLECTION_SPARQL_TEMPLATE, query));
- }
+ logger.debug(String.format("%s:\n%s", COLLECTION_SPARQL_TEMPLATE, query));
QueryExecution queryExecution = triplestore.createQueryExecution(query);
Iterator tripleIterator = queryExecution.execConstructTriples();
Iterable triples = () -> tripleIterator;
+
return Flux.fromIterable(triples)
.map(this::subject)
.map(this::harvest)
.doFinally(onFinally -> queryExecution.close());
}
- public AbstractIndexDocument harvest(String subject) {
+ public Individual harvest(String subject) {
try {
return createDocument(subject);
} catch (Exception e) {
@@ -102,22 +106,36 @@ private String subject(Triple triple) {
return triple.getSubject().toString();
}
- private AbstractIndexDocument createDocument(String subject) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- AbstractIndexDocument document = construct();
- Field field = FieldUtils.getField(type, ID, true);
- field.set(document, parse(subject));
- lookupProperties(document, subject);
- lookupSyncIds(document);
- return document;
+ private Individual createDocument(String subject) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ Individual individual = new Individual();
+ individual.setId(parse(subject));
+ individual.setClazz(name());
+
+ lookupProperties(individual, subject);
+ lookupSyncIds(individual);
+
+ Map> content = individual.getContent();
+ content.put(ID, Arrays.asList(individual.getId()));
+ content.put(CLASS, Arrays.asList(individual.getClazz()));
+ content.put(SYNC_IDS, new ArrayList<>(individual.getSyncIds()));
+
+ return individual;
}
- private void lookupProperties(AbstractIndexDocument document, String subject) {
+ private void lookupProperties(Individual individual, String subject) {
+ Map> content = individual.getContent();
propertySourceTypeOps.parallelStream().forEach(typeOp -> {
try {
FieldSource source = typeOp.getPropertySource();
Model model = queryForModel(source, subject);
List