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
No related branches found
No related tags found
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.
* VIPSLogic is free software: you can redistribute it and/or modify
...
...
@@ -22,6 +22,7 @@ package no.nibio.vips.logic.service;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.ibm.icu.util.ULocale
;
import
com.webcohesion.enunciate.metadata.rs.TypeHint
;
import
java.io.IOException
;
import
java.net.URI
;
...
...
@@ -80,13 +81,13 @@ import org.slf4j.Logger;
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>
*/
@Path
(
"rest/observation"
)
public
class
ObservationService
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ObservationService
.
class
);
private
final
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ObservationService
.
class
);
@Context
private
HttpServletRequest
httpServletRequest
;
...
...
@@ -115,14 +116,15 @@ public class ObservationService {
* @param pestId
* @param cropId
* @param cropCategoryId
* @param from
* @param to
* @param from
Str
* @param to
Str
* @return Observation objects with all data (full tree)
*/
@GET
@Path
(
"filter/{organizationId}"
)
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getFilteredObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"pestId"
)
Integer
pestId
,
...
...
@@ -157,6 +159,7 @@ public class ObservationService {
@Path
(
"list/filter/{organizationId}"
)
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
ObservationListItem
.
class
)
public
Response
getFilteredObservationListItems
(
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"pestId"
)
Integer
pestId
,
...
...
@@ -206,7 +209,16 @@ public class ObservationService {
return
Response
.
ok
().
entity
(
observations
).
build
();
}
/**
*
* @param organizationId
* @param pestId
* @param cropId
* @param cropCategoryId
* @param fromStr
* @param toStr
* @return
*/
private
List
<
Observation
>
getFilteredObservationsFromBackend
(
Integer
organizationId
,
Integer
pestId
,
...
...
@@ -287,6 +299,7 @@ public class ObservationService {
@GET
@Path
(
"pest/{organizationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservedPests
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
{
return
Response
.
ok
().
entity
(
observationBean
.
getObservedPests
(
organizationId
)).
build
();
...
...
@@ -302,6 +315,7 @@ public class ObservationService {
@GET
@Path
(
"crop/{organizationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservedCrops
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
{
return
Response
.
ok
().
entity
(
observationBean
.
getObservedCrops
(
organizationId
)).
build
();
...
...
@@ -317,6 +331,7 @@ public class ObservationService {
@Path
(
"list/{organizationId}"
)
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
){
return
Response
.
ok
().
entity
(
observationBean
.
getObservations
(
organizationId
,
Observation
.
STATUS_TYPE_ID_APPROVED
)).
build
();
}
...
...
@@ -324,11 +339,13 @@ public class ObservationService {
/**
* Get observations for a user
* Requires a valid UUID to be provided in the Authorization header
* @param observationIds
* @return
*/
@GET
@Path
(
"list/user"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getObservationsForUser
(
@QueryParam
(
"observationIds"
)
String
observationIds
)
...
...
@@ -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
* @return
*/
@GET
@Path
(
"list/minimized/user"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
ObservationSyncInfo
[].
class
)
public
Response
getMinimizedObservationsForUser
()
{
VipsLogicUser
user
=
userBean
.
getUserFromUUID
(
httpServletRequest
);
...
...
@@ -395,6 +413,7 @@ public class ObservationService {
@Path
(
"broadcast/list/{organizationId}"
)
@GZIP
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
[].
class
)
public
Response
getBroadcastObservations
(
@PathParam
(
"organizationId"
)
Integer
organizationId
,
@QueryParam
(
"season"
)
Integer
season
,
...
...
@@ -434,6 +453,7 @@ public class ObservationService {
@GET
@Path
(
"{observationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
Observation
.
class
)
public
Response
getObservation
(
@PathParam
(
"observationId"
)
Integer
observationId
,
@QueryParam
(
"userUUID"
)
String
userUUID
...
...
@@ -482,9 +502,15 @@ public class ObservationService {
return
Response
.
ok
().
entity
(
o
).
build
();
}
/**
*
* @param organizationId
* @return
*/
@GET
@Path
(
"polygonservices/{organizationId}"
)
@Produces
(
"application/json;charset=UTF-8"
)
@TypeHint
(
PolygonService
[].
class
)
public
Response
getPolygonServicesForOrganization
(
@PathParam
(
"organizationId"
)
Integer
organizationId
)
...
...
@@ -492,8 +518,11 @@ public class ObservationService {
return
Response
.
ok
().
entity
(
observationBean
.
getPolygonServicesForOrganization
(
organizationId
)).
build
();
}
/**
* Deletes a gis entity and its corresponding observation
* @param gisId
* @return
*/
@DELETE
@Path
(
"gisobservation/{gisId}"
)
...
...
@@ -570,6 +599,7 @@ public class ObservationService {
@GET
@Path
(
"first/{organismId}"
)
@Produces
(
"text/plain;charset=UTF-8"
)
@TypeHint
(
Date
.
class
)
public
Response
getFirstObservation
(
@PathParam
(
"organismId"
)
Integer
organismId
)
{
Date
firstObsTime
=
observationBean
.
getFirstObservationTime
(
organismId
);
...
...
@@ -579,12 +609,13 @@ public class ObservationService {
/**
* 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"}
*/
@GET
@Path
(
"organismsystemupdated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@TypeHint
(
Date
.
class
)
public
Response
getDateOfLastOrganismSystemUpdate
()
{
HashMap
<
String
,
Object
>
result
=
new
HashMap
<>();
...
...
@@ -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
)
{
List
<
Observation
>
filteredObservations
=
this
.
getFilteredObservationsFromBackend
(
organizationId
,
pestId
,
cropId
,
cropCategoryId
,
fromStr
,
toStr
);
//filteredObservations.forEach(o->System.out.println(o.getObservationId()));
...
...
@@ -708,6 +750,11 @@ public class ObservationService {
return
observations
;
}
/**
*
* @param observationJson
* @return
*/
@POST
@Path
(
"syncobservationfromapp"
)
@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