Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story/cite 172 - From the managed authority page, there should be a link that lists all citations that reference that authority #55

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -57,7 +56,7 @@ public interface ICitationDao {

Persons findAllPeople(String groupId, long start, int pageSize);

Citations findCitationsByPersonUri(String uri);
Citations findCitationsByPersonUri(String uri, Set<String> groupIds);

Citations findCitationsByPersonCitationKey(String citationKey);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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<String> 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");

Expand Down