Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
DJWalker42 committed May 29, 2024
2 parents b9032b8 + 077e09d commit 166bd6b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.ivoa.dm.proposal.management.ProposalCycle;
import org.ivoa.dm.proposal.management.ProposalReview;
import org.ivoa.dm.proposal.management.ReviewedProposal;
import org.ivoa.dm.proposal.management.SubmittedProposal;
import org.orph2020.pst.common.json.ObjectIdentifier;

import java.util.Date;
import java.util.List;

@Path("proposalCycles/{cycleCode}/proposalsInReview/{reviewedProposalId}/reviews")
@Path("proposalCycles/{cycleCode}/submittedProposals/{reviewedProposalId}/reviews")
@Tag(name = "proposalCycles-proposals-in-review-the-reviews")
@Produces(MediaType.APPLICATION_JSON)
public class ProposalReviewResource extends ObjectResourceBase{
Expand All @@ -29,7 +29,7 @@ public List<ObjectIdentifier> getReviews(@PathParam("cycleCode") Long cycleCode,
{
String select = "select r._id,r.reviewer.person.fullName ";
String from = "from ProposalCycle c ";
String innerJoins = "inner join c.reviewedProposals p inner join p.reviews r ";
String innerJoins = "inner join c.submittedProposals p inner join p.reviews r ";
String where = "where c._id=" + cycleCode + " and p._id=" + reviewedProposalId + " ";
String orderBy = "order by r.reviewer.person.fullName";

Expand All @@ -43,7 +43,7 @@ public ProposalReview getReview(@PathParam("cycleCode") Long cycleCode,
@PathParam("reviewedProposalId") Long reviewedProposalId,
@PathParam("reviewId") Long reviewId)
{
return findChildByQuery(ReviewedProposal.class, ProposalReview.class,
return findChildByQuery(SubmittedProposal.class, ProposalReview.class,
"reviews", reviewedProposalId, reviewId);
}

Expand All @@ -56,8 +56,9 @@ public ProposalReview addReview(@PathParam("cycleCode") Long cycleCode,
ProposalReview proposalReview)
throws WebApplicationException
{
ReviewedProposal reviewedProposal = findChildByQuery(ProposalCycle.class, ReviewedProposal.class,
"reviewedProposals", cycleCode, reviewedProposalId);
//IMPL do not strictly need to do thi
SubmittedProposal reviewedProposal = findChildByQuery(ProposalCycle.class, SubmittedProposal.class,
"submittedProposals", cycleCode, reviewedProposalId);

//set the date to the posix epoch, user must confirm that the review is complete at which
//point this date is updated to that at the point of confirmation, and the review becomes
Expand All @@ -76,10 +77,10 @@ public Response removeReview(@PathParam("cycleCode") Long cycleCode,
@PathParam("reviewId") Long reviewId)
throws WebApplicationException
{
ReviewedProposal reviewedProposal = findChildByQuery(ProposalCycle.class,
ReviewedProposal.class, "reviewedProposals", cycleCode, reviewedProposalId);
SubmittedProposal reviewedProposal = findChildByQuery(ProposalCycle.class,
SubmittedProposal.class, "submittedProposals", cycleCode, reviewedProposalId);

ProposalReview proposalReview = findChildByQuery(ReviewedProposal.class,
ProposalReview proposalReview = findChildByQuery(SubmittedProposal.class,
ProposalReview.class, "reviews", reviewedProposalId, reviewId);

return deleteChildObject(reviewedProposal,proposalReview,
Expand Down Expand Up @@ -108,7 +109,7 @@ public ProposalReview updateReviewComment(
)
throws WebApplicationException
{
ProposalReview proposalReview = findChildByQuery(ReviewedProposal.class,
ProposalReview proposalReview = findChildByQuery(SubmittedProposal.class,
ProposalReview.class, "reviews", reviewedProposalId, reviewId);

if (proposalReview.getReviewDate().compareTo(new Date(0L)) > 0) {
Expand Down Expand Up @@ -137,7 +138,7 @@ public ProposalReview updateReviewScore(@PathParam("cycleCode") Long cycleCode,
)
throws WebApplicationException
{
ProposalReview proposalReview = findChildByQuery(ReviewedProposal.class,
ProposalReview proposalReview = findChildByQuery(SubmittedProposal.class,
ProposalReview.class, "reviews", reviewedProposalId, reviewId);

if (proposalReview.getReviewDate().compareTo(new Date(0L)) > 0) {
Expand Down Expand Up @@ -167,7 +168,7 @@ public ProposalReview updateReviewFeasibility(
)
throws WebApplicationException
{
ProposalReview proposalReview = findChildByQuery(ReviewedProposal.class,
ProposalReview proposalReview = findChildByQuery(SubmittedProposal.class,
ProposalReview.class, "reviews", reviewedProposalId, reviewId);

if (proposalReview.getReviewDate().compareTo(new Date(0L)) > 0) {
Expand Down Expand Up @@ -196,7 +197,7 @@ public ProposalReview confirmReviewComplete(
)
throws WebApplicationException
{
ProposalReview proposalReview = findChildByQuery(ReviewedProposal.class,
ProposalReview proposalReview = findChildByQuery(SubmittedProposal.class,
ProposalReview.class, "reviews", reviewedProposalId, reviewId);

proposalReview.setReviewDate(new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.transaction.Transactional;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.ivoa.dm.proposal.management.ProposalCycle;
Expand Down Expand Up @@ -34,6 +35,17 @@ public List<ObjectIdentifier> getSubmittedProposals(@PathParam("cycleCode") Long
return getObjectIdentifiers(select + from + innerJoins + where + orderBy);
}

@GET
@Path("/{reviewedProposalId}")
@Operation(summary = "get the ReviewedProposal specified by 'reviewedProposalId'")
public SubmittedProposal getReviewedProposal(@PathParam("cycleCode") Long cycleCode,
@PathParam("reviewedProposalId") Long reviewedProposalId)
{
return findChildByQuery(ProposalCycle.class, SubmittedProposal.class,
"submittedProposals", cycleCode, reviewedProposalId);
}


@PUT
@Operation(summary = "submit a proposal")
@Consumes(MediaType.TEXT_PLAIN)
Expand All @@ -60,7 +72,7 @@ public ProposalSynopsis submitProposal(@PathParam("cycleCode") long cycleId, lon
pclone.updateClonedReferences();// TODO API subject to change
pclone.setSubmitted(true);
em.persist(pclone);
SubmittedProposal submittedProposal = new SubmittedProposal(new Date(), false, new Date(), pclone);
SubmittedProposal submittedProposal = new SubmittedProposal(new Date(), false, new Date(), null, pclone);
cycle.addToSubmittedProposals(submittedProposal);
em.merge(cycle);

Expand All @@ -72,5 +84,44 @@ public ProposalSynopsis submitProposal(@PathParam("cycleCode") long cycleId, lon
return new ProposalSynopsis(responseProposal);
}

@PUT
@Path("/{reviewedProposalId}/success")
@Operation(summary = "update the 'successful' status of the given ReviewedProposal")
@Consumes(MediaType.APPLICATION_JSON)
@Transactional(rollbackOn = {WebApplicationException.class})
public Response updateReviewedProposalSuccess(@PathParam("cycleCode") Long cycleCode,
@PathParam("reviewedProposalId") Long reviewedProposalId,
Boolean successStatus)
throws WebApplicationException
{
SubmittedProposal reviewedProposal = findChildByQuery(ProposalCycle.class, SubmittedProposal.class,
"submittedProposals", cycleCode, reviewedProposalId);

reviewedProposal.setSuccessful(successStatus);



return mergeObject(reviewedProposalId);
}

@PUT
@Path("/{reviewedProposalId}/completeDate")
@Operation(summary = "update the 'reviewsCompleteDate' of the given ReviewedProposal to today's date")
@Transactional(rollbackOn = {WebApplicationException.class})
public Response updateReviewedProposalCompleteDate(
@PathParam("cycleCode") Long cycleCode,
@PathParam("reviewedProposalId") Long reviewedProposalId)
throws WebApplicationException
{
SubmittedProposal reviewedProposal = findChildByQuery(ProposalCycle.class, SubmittedProposal.class,
"submittedProposals", cycleCode, reviewedProposalId);

reviewedProposal.setReviewsCompleteDate(new Date());

return mergeObject(reviewedProposalId);
}

}



Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,13 @@ void testListSubmittedProposals() {
"$.size()", greaterThan(0)
);

}
@Test
void setProposalForReview() throws JsonProcessingException {
long subId = given()
.when()
.get("proposalCycles/" + cycleId + "/submittedProposals")
.then()
.statusCode(200)
.body(
"$.size()", greaterThan(0)
)
.extract().jsonPath().getLong("[0].dbid");

given()
.contentType("application/json; charset=UTF-16")
.body(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(subId))
.when()
.put("proposalCycles/" + cycleId + "/proposalsInReview")
.then()
.contentType(JSON)
.statusCode(200)
.log().body(); // TODO not sure that we want to return this all...

// when all proposals set for review send emails to the tac members, telling them to review.

}

@Test
void reviewProposal() throws JsonProcessingException {
long revId = given()
.when()
.get("proposalCycles/" + cycleId + "/proposalsInReview")
.get("proposalCycles/" + cycleId + "/submittedProposals")
.then()
.statusCode(200)
.body(
Expand All @@ -113,12 +88,12 @@ void reviewProposal() throws JsonProcessingException {
.extract().jsonPath().getLong("[0].dbid");

// the TAC member gets a proposal for review
ReviewedProposal revprop = given()
SubmittedProposal revprop = given()
.when()
.get("proposalCycles/" + cycleId + "/proposalsInReview/" + revId)
.get("proposalCycles/" + cycleId + "/submittedProposals/" + revId)
.then()
.statusCode(200)
.extract().as(ReviewedProposal.class, raObjectMapper);
.extract().as(SubmittedProposal.class, raObjectMapper);


// TAC member adds a review
Expand All @@ -128,7 +103,7 @@ void reviewProposal() throws JsonProcessingException {
.contentType("application/json; charset=UTF-16")
.body(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rev))
.when()
.post("proposalCycles/" + cycleId + "/proposalsInReview/"+revId+"/reviews")
.post("proposalCycles/" + cycleId + "/submittedProposals/"+revId+"/reviews")
.then()
.contentType(JSON)
.statusCode(200)
Expand All @@ -140,22 +115,22 @@ void reviewProposal() throws JsonProcessingException {
void allocateProposal() throws JsonProcessingException {
long revId = given()
.when()
.get("proposalCycles/" + cycleId + "/proposalsInReview")
.get("proposalCycles/" + cycleId + "/submittedProposals")
.then()
.statusCode(200)
.body(
"$.size()", greaterThan(0)
)
.extract().jsonPath().getLong("[0].dbid");

ReviewedProposal revprop = given()
SubmittedProposal revprop = given()
.when()
.get("proposalCycles/" + cycleId + "/proposalsInReview/" + revId)
.get("proposalCycles/" + cycleId + "/submittedProposals/" + revId)
.then()
.statusCode(200)
.extract().as(ReviewedProposal.class, raObjectMapper);
.extract().as(SubmittedProposal.class, raObjectMapper);

long subId = revprop.getSubmitted().getId();
long subId = revprop.getId();

//push reviewed proposal to 'allocatedProposals' list
given()
Expand Down

0 comments on commit 166bd6b

Please sign in to comment.