-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a bare bones observation resource
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |