diff --git a/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/ICitationDao.java b/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/ICitationDao.java index f06f6eb..cd67c7a 100644 --- a/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/ICitationDao.java +++ b/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/ICitationDao.java @@ -1,12 +1,11 @@ package edu.asu.diging.citesphere.data.bib; import java.util.List; +import java.util.Set; -import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.util.CloseableIterator; import edu.asu.diging.citesphere.model.bib.ICitation; -import edu.asu.diging.citesphere.model.bib.impl.Person; import edu.asu.diging.citesphere.model.transfer.impl.Citations; import edu.asu.diging.citesphere.model.transfer.impl.Persons; @@ -57,7 +56,7 @@ public interface ICitationDao { Persons findAllPeople(String groupId, long start, int pageSize); - Citations findCitationsByPersonUri(String uri); + Citations findCitationsByPersonUri(String uri, Set groupIds); Citations findCitationsByPersonCitationKey(String citationKey); } \ No newline at end of file diff --git a/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/impl/CitationMongoDao.java b/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/impl/CitationMongoDao.java index 89a445c..970204c 100644 --- a/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/impl/CitationMongoDao.java +++ b/citesphere-model/src/main/java/edu/asu/diging/citesphere/data/bib/impl/CitationMongoDao.java @@ -1,13 +1,13 @@ package edu.asu.diging.citesphere.data.bib.impl; import java.util.List; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.aggregation.Aggregation; import org.springframework.data.mongodb.core.aggregation.AggregationResults; -import org.springframework.data.mongodb.core.aggregation.ConditionalOperators; import org.springframework.data.mongodb.core.aggregation.GroupOperation; import org.springframework.data.mongodb.core.aggregation.LimitOperation; import org.springframework.data.mongodb.core.aggregation.MatchOperation; @@ -21,11 +21,11 @@ import org.springframework.stereotype.Repository; import com.mongodb.BasicDBObject; + import edu.asu.diging.citesphere.data.bib.ICitationDao; import edu.asu.diging.citesphere.model.bib.ICitation; import edu.asu.diging.citesphere.model.bib.ItemType; import edu.asu.diging.citesphere.model.bib.impl.Citation; -import edu.asu.diging.citesphere.model.bib.impl.Person; import edu.asu.diging.citesphere.model.transfer.impl.Citations; import edu.asu.diging.citesphere.model.transfer.impl.Persons; @@ -258,14 +258,16 @@ public Persons findAllPeople(String groupId, long start, int pageSize) { } @Override - public Citations findCitationsByPersonUri(String uri) { + public Citations findCitationsByPersonUri(String uri, Set groupIds) { - ProjectionOperation project = Aggregation.project().and("authors") - .unionArrays("editors", "otherCreators.person").as("persons").and(Aggregation.ROOT).as("citation"); + ProjectionOperation project = Aggregation.project() + .and("authors").unionArrays("editors", "otherCreators.person").as("persons") + .and("group").as("group") + .and(Aggregation.ROOT).as("citation"); UnwindOperation unwind = Aggregation.unwind("persons"); - MatchOperation match = Aggregation.match(Criteria.where("persons.uri").is(uri)); + MatchOperation match = Aggregation.match(Criteria.where("persons.uri").is(uri).and("group").in(groupIds)); GroupOperation group = Aggregation.group("persons.uri").addToSet("citation").as("citations");