Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSLogic
Commits
2bc5c365
Commit
2bc5c365
authored
2 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Improving documentation for the endpoints in ObservationService
parent
13796403
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/logic/service/ObservationService.java
+55
-8
55 additions, 8 deletions
.../java/no/nibio/vips/logic/service/ObservationService.java
with
55 additions
and
8 deletions
src/main/java/no/nibio/vips/logic/service/ObservationService.java
+
55
−
8
View file @
2bc5c365
/*
/*
* Copyright (c) 20
16
NIBIO <http://www.nibio.no/>.
* Copyright (c) 20
22
NIBIO <http://www.nibio.no/>.
*
*
* This file is part of VIPSLogic.
* This file is part of VIPSLogic.
* VIPSLogic is free software: you can redistribute it and/or modify
* VIPSLogic is free software: you can redistribute it and/or modify
...
@@ -22,6 +22,7 @@ package no.nibio.vips.logic.service;
...
@@ -22,6 +22,7 @@ package no.nibio.vips.logic.service;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.ibm.icu.util.ULocale
;
import
com.ibm.icu.util.ULocale
;
import
com.webcohesion.enunciate.metadata.rs.TypeHint
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URI
;
...
@@ -80,13 +81,13 @@ import org.slf4j.Logger;
...
@@ -80,13 +81,13 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @copyright 2016-202
1
<a href="http://www.nibio.no/">NIBIO</a>
* @copyright 2016-202
2
<a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
*/
@Path
(
"rest/observation"
)
@Path
(
"rest/observation"
)
public
class
ObservationService
{
public
class
ObservationService
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ObservationService
.
class
);
private
final
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ObservationService
.
class
);
@Context
@Context
private
HttpServletRequest
httpServletRequest
;
private
HttpServletRequest
httpServletRequest
;
...
@@ -115,14 +116,15 @@ public class ObservationService {
...
@@ -115,14 +116,15 @@ public class ObservationService {
* @param pestId
* @param pestId
* @param cropId
* @param cropId
* @param cropCategoryId
* @param cropCategoryId
* @param from
* @param from
Str
* @param to
* @param to
Str
* @return Observation objects with all data (full tree)
* @return Observation objects with all data (full tree)
*/
*/
@GET
@GET
@Path
(
"filter/{organizationId}"
)
@Path
(
"filter/{organizationId}"
)
@GZIP
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getFilteredObservations
(
public
Response
getFilteredObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"pestId"
)
Integer
pestId
,
@QueryParam
(
"pestId"
)
Integer
pestId
,
...
@@ -157,6 +159,7 @@ public class ObservationService {
...
@@ -157,6 +159,7 @@ public class ObservationService {
@Path
(
"list/filter/{organizationId}"
)
@Path
(
"list/filter/{organizationId}"
)
@GZIP
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
ObservationListItem
.
class
)
public
Response
getFilteredObservationListItems
(
public
Response
getFilteredObservationListItems
(
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"pestId"
)
Integer
pestId
,
@QueryParam
(
"pestId"
)
Integer
pestId
,
...
@@ -206,7 +209,16 @@ public class ObservationService {
...
@@ -206,7 +209,16 @@ public class ObservationService {
return
Response
.
ok
().
entity
(
observations
).
build
();
return
Response
.
ok
().
entity
(
observations
).
build
();
}
}
/**
*
* @param organizationId
* @param pestId
* @param cropId
* @param cropCategoryId
* @param fromStr
* @param toStr
* @return
*/
private
List
<
Observation
>
getFilteredObservationsFromBackend
(
private
List
<
Observation
>
getFilteredObservationsFromBackend
(
Integer
organizationId
,
Integer
organizationId
,
Integer
pestId
,
Integer
pestId
,
...
@@ -287,6 +299,7 @@ public class ObservationService {
...
@@ -287,6 +299,7 @@ public class ObservationService {
@GET
@GET
@Path
(
"pest/{organizationId}"
)
@Path
(
"pest/{organizationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservedPests
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
public
Response
getObservedPests
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
{
{
return
Response
.
ok
().
entity
(
observationBean
.
getObservedPests
(
organizationId
)).
build
();
return
Response
.
ok
().
entity
(
observationBean
.
getObservedPests
(
organizationId
)).
build
();
...
@@ -302,6 +315,7 @@ public class ObservationService {
...
@@ -302,6 +315,7 @@ public class ObservationService {
@GET
@GET
@Path
(
"crop/{organizationId}"
)
@Path
(
"crop/{organizationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservedCrops
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
public
Response
getObservedCrops
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
{
{
return
Response
.
ok
().
entity
(
observationBean
.
getObservedCrops
(
organizationId
)).
build
();
return
Response
.
ok
().
entity
(
observationBean
.
getObservedCrops
(
organizationId
)).
build
();
...
@@ -317,6 +331,7 @@ public class ObservationService {
...
@@ -317,6 +331,7 @@ public class ObservationService {
@Path
(
"list/{organizationId}"
)
@Path
(
"list/{organizationId}"
)
@GZIP
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
){
public
Response
getObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
){
return
Response
.
ok
().
entity
(
observationBean
.
getObservations
(
organizationId
,
Observation
.
STATUS_TYPE_ID_APPROVED
)).
build
();
return
Response
.
ok
().
entity
(
observationBean
.
getObservations
(
organizationId
,
Observation
.
STATUS_TYPE_ID_APPROVED
)).
build
();
}
}
...
@@ -324,11 +339,13 @@ public class ObservationService {
...
@@ -324,11 +339,13 @@ public class ObservationService {
/**
/**
* Get observations for a user
* Get observations for a user
* Requires a valid UUID to be provided in the Authorization header
* Requires a valid UUID to be provided in the Authorization header
* @param observationIds
* @return
* @return
*/
*/
@GET
@GET
@Path
(
"list/user"
)
@Path
(
"list/user"
)
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservationsForUser
(
public
Response
getObservationsForUser
(
@QueryParam
(
"observationIds"
)
String
observationIds
@QueryParam
(
"observationIds"
)
String
observationIds
)
)
...
@@ -365,13 +382,14 @@ public class ObservationService {
...
@@ -365,13 +382,14 @@ public class ObservationService {
}
}
/**
/**
* Get observations for a user
* Get
minimized (only synchronization info)
observations for a user
* Requires a valid UUID to be provided in the Authorization header
* Requires a valid UUID to be provided in the Authorization header
* @return
* @return
*/
*/
@GET
@GET
@Path
(
"list/minimized/user"
)
@Path
(
"list/minimized/user"
)
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
ObservationSyncInfo
[].
class
)
public
Response
getMinimizedObservationsForUser
()
public
Response
getMinimizedObservationsForUser
()
{
{
VipsLogicUser
user
=
userBean
.
getUserFromUUID
(
httpServletRequest
);
VipsLogicUser
user
=
userBean
.
getUserFromUUID
(
httpServletRequest
);
...
@@ -395,6 +413,7 @@ public class ObservationService {
...
@@ -395,6 +413,7 @@ public class ObservationService {
@Path
(
"broadcast/list/{organizationId}"
)
@Path
(
"broadcast/list/{organizationId}"
)
@GZIP
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getBroadcastObservations
(
public
Response
getBroadcastObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"season"
)
Integer
season
,
@QueryParam
(
"season"
)
Integer
season
,
...
@@ -434,6 +453,7 @@ public class ObservationService {
...
@@ -434,6 +453,7 @@ public class ObservationService {
@GET
@GET
@Path
(
"{observationId}"
)
@Path
(
"{observationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
.
class
)
public
Response
getObservation
(
public
Response
getObservation
(
@PathParam
(
"observationId"
)
Integer
observationId
,
@PathParam
(
"observationId"
)
Integer
observationId
,
@QueryParam
(
"userUUID"
)
String
userUUID
@QueryParam
(
"userUUID"
)
String
userUUID
...
@@ -482,9 +502,15 @@ public class ObservationService {
...
@@ -482,9 +502,15 @@ public class ObservationService {
return
Response
.
ok
().
entity
(
o
).
build
();
return
Response
.
ok
().
entity
(
o
).
build
();
}
}
/**
*
* @param organizationId
* @return
*/
@GET
@GET
@Path
(
"polygonservices/{organizationId}"
)
@Path
(
"polygonservices/{organizationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
PolygonService
[].
class
)
public
Response
getPolygonServicesForOrganization
(
public
Response
getPolygonServicesForOrganization
(
@PathParam
(
"organizationId"
)
Integer
organizationId
@PathParam
(
"organizationId"
)
Integer
organizationId
)
)
...
@@ -492,8 +518,11 @@ public class ObservationService {
...
@@ -492,8 +518,11 @@ public class ObservationService {
return
Response
.
ok
().
entity
(
observationBean
.
getPolygonServicesForOrganization
(
organizationId
)).
build
();
return
Response
.
ok
().
entity
(
observationBean
.
getPolygonServicesForOrganization
(
organizationId
)).
build
();
}
}
/**
/**
* Deletes a gis entity and its corresponding observation
* Deletes a gis entity and its corresponding observation
* @param gisId
* @return
*/
*/
@DELETE
@DELETE
@Path
(
"gisobservation/{gisId}"
)
@Path
(
"gisobservation/{gisId}"
)
...
@@ -570,6 +599,7 @@ public class ObservationService {
...
@@ -570,6 +599,7 @@ public class ObservationService {
@GET
@GET
@Path
(
"first/{organismId}"
)
@Path
(
"first/{organismId}"
)
@Produces
(
"text/plain;charset=UTF-8"
)
@Produces
(
"text/plain;charset=UTF-8"
)
@TypeHint
(
Date
.
class
)
public
Response
getFirstObservation
(
@PathParam
(
"organismId"
)
Integer
organismId
)
public
Response
getFirstObservation
(
@PathParam
(
"organismId"
)
Integer
organismId
)
{
{
Date
firstObsTime
=
observationBean
.
getFirstObservationTime
(
organismId
);
Date
firstObsTime
=
observationBean
.
getFirstObservationTime
(
organismId
);
...
@@ -579,12 +609,13 @@ public class ObservationService {
...
@@ -579,12 +609,13 @@ public class ObservationService {
/**
/**
* When was the last time a change was made in cropCategories or organisms?
* When was the last time a change was made in cropCategories or organisms?
*
*
@return last time a change was made in cropCategories or organisms
* @responseExample application/json {"lastUpdated": "2021-02-08T00:00:00Z"}
* @responseExample application/json {"lastUpdated": "2021-02-08T00:00:00Z"}
*/
*/
@GET
@GET
@Path
(
"organismsystemupdated"
)
@Path
(
"organismsystemupdated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@TypeHint
(
Date
.
class
)
public
Response
getDateOfLastOrganismSystemUpdate
()
public
Response
getDateOfLastOrganismSystemUpdate
()
{
{
HashMap
<
String
,
Object
>
result
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
result
=
new
HashMap
<>();
...
@@ -594,6 +625,17 @@ public class ObservationService {
...
@@ -594,6 +625,17 @@ public class ObservationService {
}
}
/**
*
* @param organizationId
* @param pestId
* @param cropId
* @param cropCategoryId
* @param fromStr
* @param toStr
* @param user
* @return
*/
private
List
<
Observation
>
getFilteredObservationsFromBackend
(
Integer
organizationId
,
Integer
pestId
,
Integer
cropId
,
List
<
Integer
>
cropCategoryId
,
String
fromStr
,
String
toStr
,
VipsLogicUser
user
)
{
private
List
<
Observation
>
getFilteredObservationsFromBackend
(
Integer
organizationId
,
Integer
pestId
,
Integer
cropId
,
List
<
Integer
>
cropCategoryId
,
String
fromStr
,
String
toStr
,
VipsLogicUser
user
)
{
List
<
Observation
>
filteredObservations
=
this
.
getFilteredObservationsFromBackend
(
organizationId
,
pestId
,
cropId
,
cropCategoryId
,
fromStr
,
toStr
);
List
<
Observation
>
filteredObservations
=
this
.
getFilteredObservationsFromBackend
(
organizationId
,
pestId
,
cropId
,
cropCategoryId
,
fromStr
,
toStr
);
//filteredObservations.forEach(o->System.out.println(o.getObservationId()));
//filteredObservations.forEach(o->System.out.println(o.getObservationId()));
...
@@ -708,6 +750,11 @@ public class ObservationService {
...
@@ -708,6 +750,11 @@ public class ObservationService {
return
observations
;
return
observations
;
}
}
/**
*
* @param observationJson
* @return
*/
@POST
@POST
@Path
(
"syncobservationfromapp"
)
@Path
(
"syncobservationfromapp"
)
@Consumes
(
"application/json;charset=UTF-8"
)
@Consumes
(
"application/json;charset=UTF-8"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment