Skip to content

Commit

Permalink
add a bare bones observation resource
Browse files Browse the repository at this point in the history
  • Loading branch information
pahjbo committed Aug 21, 2024
1 parent 0012687 commit fb74601
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/main/java/org/uksrc/archive/ObservationResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.uksrc.archive;
/*
* Created on 21/08/2024 by Paul Harrison ([email protected]).
*/

import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.ivoa.dm.caom2.caom2.Observation;


@Produces(MediaType.APPLICATION_JSON)
@Path("/observation")
public class ObservationResource {


@PersistenceContext
protected EntityManager em; // exists for the application lifetime no need to close

@POST
@Operation(summary = "create a new Observation")
@Consumes(MediaType.APPLICATION_JSON)
@Transactional
public Observation addObservation(Observation observation) {
em.persist(observation);
return observation;
}

}

0 comments on commit fb74601

Please sign in to comment.