Skip to content

Commit

Permalink
Merge pull request #56 from orppst/55-add-investigator-query-to-getsu…
Browse files Browse the repository at this point in the history
…bmittedproposals-call

proposal title and investigator name queries added to getSubmittedProposals
  • Loading branch information
DJWalker42 authored Nov 6, 2024
2 parents ee86ddf + ee68375 commit aa4eda7
Showing 1 changed file with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.ivoa.dm.proposal.management.*;
import org.ivoa.dm.proposal.prop.Observation;
import org.ivoa.dm.proposal.prop.ObservingProposal;
import org.jboss.resteasy.reactive.RestQuery;
import org.orph2020.pst.apiimpl.entities.SubmissionConfiguration;
import org.orph2020.pst.common.json.ObjectIdentifier;
import org.orph2020.pst.common.json.ProposalSynopsis;
Expand All @@ -26,15 +27,36 @@ public class SubmittedProposalResource extends ObjectResourceBase{

@GET
@Operation(summary = "get the identifiers for the SubmittedProposals in the ProposalCycle")
public List<ObjectIdentifier> getSubmittedProposals(@PathParam("cycleCode") Long cycleCode)
public List<ObjectIdentifier> getSubmittedProposals(
@PathParam("cycleCode") Long cycleCode,
@RestQuery String title,
@RestQuery String investigatorName
)
{
String select = "select s._id,s.proposal.title ";
String from = "from ProposalCycle c ";
String innerJoins = "inner join c.submittedProposals s inner join s.proposal p ";
String where = "where c._id=" + cycleCode + " ";
String orderBy = "order by p.title";
boolean noQuery = investigatorName == null && title == null;
boolean investigatorOnly = investigatorName != null && title == null;
boolean titleOnly = title != null && investigatorName == null;

return getObjectIdentifiers("select s._id, s.proposal.title from ProposalCycle c inner join c.submittedProposals s where c._id=" + cycleCode + " order by s.proposal.title ");

String baseStr = "select distinct s._id, s.proposal.title from ProposalCycle c, Investigator i "
+ "inner join c.submittedProposals s "
+ "where i member of s.proposal.investigators "
+ "and c._id=" + cycleCode + " ";

String orderByStr = "order by s.proposal.title";

String investigatorLikeStr = "and i.person.fullName like '" + investigatorName + "' ";
String titleLikeStr = "and s.proposal.title like '" + title + "' ";

if (noQuery) {
return getObjectIdentifiers(baseStr + orderByStr);
} else if (investigatorOnly) {
return getObjectIdentifiers(baseStr + investigatorLikeStr + orderByStr);
} else if (titleOnly) {
return getObjectIdentifiers(baseStr + titleLikeStr + orderByStr);
} else {
return getObjectIdentifiers(baseStr + investigatorLikeStr + titleLikeStr + orderByStr);
}
}

@GET
Expand Down

0 comments on commit aa4eda7

Please sign in to comment.