Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue1659 #1663

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.apache.commons.io.FilenameUtils
import org.apache.http.HttpStatus
import org.apache.http.entity.ContentType
import org.grails.web.json.JSONArray
import org.grails.web.json.JSONObject
import org.springframework.context.MessageSource
import org.springframework.web.multipart.MultipartFile

Expand Down Expand Up @@ -1820,6 +1821,12 @@ class BioActivityController {
in = ParameterIn.PATH,
required = true,
description = "Activity id"
),
@Parameter(
name = "includeSiteData",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add includeSiteData as a query parameter.

in = ParameterIn.QUERY,
description = "Include site data",
schema = @Schema(type = "boolean", defaultValue = "false")
)
],
responses = [
Expand Down Expand Up @@ -1855,9 +1862,12 @@ class BioActivityController {
security = @SecurityRequirement(name="auth")
)
@Path("ws/bioactivity/data/simplified/{id}")
def getOutputForActivitySimplified(String id){
def getOutputForActivitySimplified(String id, boolean includeSiteData){
log.debug("id = ${id}")
log.debug("includeSiteData = ${includeSiteData}")

String userId = userService.getCurrentUserId()
def activity = activityService.get(id)
def activity = activityService.get(id, null, userId, false,includeSiteData)
String projectId = activity?.projectId
def model = [:]

Expand All @@ -1871,6 +1881,9 @@ class BioActivityController {
} else if (!projectId) {
model.error = "No project associated with the activity"
} else if (projectService.isUserAdminForProject(userId, projectId) || activityService.isUserOwnerForActivity(userId, activity?.activityId)) {
if (includeSiteData) {
activity.site = new JSONObject([siteId:activity.site.siteId, name:activity.site.name, geoJson:activity.site.geoIndex])
}
model = [activity: activity]
} else {
response.status = 401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ class ActivityService {
webService.getJson(grailsApplication.config.ecodata.service.url + '/activity/getDistinctSitesForProject/'+ id)
}

def get(id, version = null, userId = null, hideMemberOnlyFlds = false) {
def get(id, version = null, userId = null, hideMemberOnlyFlds = false, includeSiteData = false) {
def params = '?hideMemberOnlyFlds=' + hideMemberOnlyFlds
if (version) {
params += '&version=' + version
}
if (userId) {
params += '&userId=' + userId
}
if (includeSiteData) {
params += '&view=site'
}

def activity = webService.getJson(grailsApplication.config.ecodata.service.url + '/activity/' + id + params)
activity
Expand Down
Loading