Skip to content

Commit 02c4a7d

Browse files
authored
Merge pull request #493 from AtlasOfLivingAustralia/dev
Preparing v1.36
2 parents a15e151 + 090bb25 commit 02c4a7d

File tree

16 files changed

+726
-197
lines changed

16 files changed

+726
-197
lines changed

application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#Mon Nov 03 17:25:26 EST 2014
33
app.grails.version=2.4.5
44
app.name=ecodata
5-
app.version=1.35.1
5+
app.version=1.36-SNAPSHOT

grails-app/controllers/au/org/ala/ecodata/ReportController.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ class ReportController {
4343
respond reportList
4444
}
4545

46+
/**
47+
* Clears any data entered for this report.
48+
* @param id the reportId of the report to clear.
49+
* @return
50+
*/
51+
@RequireApiKey
52+
def reset(String id) {
53+
respond reportingService.reset(id)
54+
}
55+
4656
@RequireApiKey
4757
def submit(String id) {
4858
Map params = request.JSON

grails-app/domain/au/org/ala/ecodata/Activity.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class Activity {
7171
return progress in completedStates
7272
}
7373

74+
/** Activities with a progress of DEFFERED or CANCELLED should not have any outputs associated with them */
75+
public boolean supportsOutputs() {
76+
return progress in [PLANNED, STARTED, FINISHED]
77+
}
78+
7479
static transients = ['complete']
7580

7681
static constraints = {

grails-app/domain/au/org/ala/ecodata/AssociatedOrg.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class AssociatedOrg {
1111
String logo
1212
String url
1313

14+
/** A description of the association - e.g. Service Provider, Grantee, Sponsor */
15+
String description
16+
1417
// an AssociateOrg can either be another registered Organisation, in which case the organisationId field will be populated,
1518
// or just a reference to an external body, in which case just the name and an optional logo will be recorded
1619

@@ -19,6 +22,7 @@ class AssociatedOrg {
1922
name nullable: true
2023
logo nullable: true
2124
url nullable: true
25+
description nullable: true
2226
}
2327

2428
}

grails-app/domain/au/org/ala/ecodata/Program.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class Program {
3636
List<Program> subPrograms = []
3737
Program parent
3838

39+
List<AssociatedOrg> associatedOrganisations
40+
3941

4042
/** Custom rendering for the program */
4143
Map toMap() {
@@ -58,6 +60,7 @@ class Program {
5860
if (parent) {
5961
program.parentId = parent.programId
6062
}
63+
program.associatedOrganisations = associatedOrganisations
6164

6265
program
6366
}
@@ -88,6 +91,8 @@ class Program {
8891
version false
8992
}
9093

94+
static embedded = ['associatedOrganisations']
95+
9196
static hasMany = [subPrograms:Program]
9297

9398
static constraints = {
@@ -100,6 +105,7 @@ class Program {
100105
url nullable: true
101106
config nullable: true
102107
parent nullable: true
108+
associatedOrganisations nullable:true
103109
}
104110

105111
public String toString() {

grails-app/services/au/org/ala/ecodata/ActivityService.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ class ActivityService {
415415
deleteActivityOutputs(id)
416416
}
417417
commonService.updateProperties(activity, props)
418+
419+
// If the activity has been updated to a state where Outputs are not supported, delete any
420+
// existing outputs. This is to handle the case where an activity with output data is
421+
// cancelled or deferred.
422+
if (!activity.supportsOutputs()) {
423+
deleteActivityOutputs(id)
424+
}
425+
418426
} catch (Exception e) {
419427
Activity.withSession { session -> session.clear() }
420428
def error = "Error updating Activity ${id} - ${e.message}"

grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,6 @@ class ElasticSearchService {
10671067
List result = []
10681068
List navigatedPath = []
10691069
path?.each{ prop ->
1070-
navigatedPath.add(prop)
10711070
if(temp instanceof Map){
10721071
temp = temp[prop]
10731072
} else if(temp instanceof List){
@@ -1077,6 +1076,8 @@ class ElasticSearchService {
10771076

10781077
temp = null
10791078
}
1079+
1080+
navigatedPath.add(prop)
10801081
}
10811082

10821083
if(temp != null){

grails-app/services/au/org/ala/ecodata/ReportingService.groovy

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ReportingService {
1818

1919
AggregatorFactory aggregatorFactory = new AggregatorFactory()
2020

21+
private String INVALID_STATUS_FOR_UPDATE_ERROR_KEY = 'report.cannotUpdateSubmittedOrApprovedReport'
22+
2123
def get(String reportId, includeDeleted = false) {
2224

2325
Report report = null
@@ -113,8 +115,12 @@ class ReportingService {
113115

114116
Report update(String id, Map properties) {
115117
Report report = get(id)
118+
if (!report) {
119+
return null
120+
}
121+
116122
if (report.isSubmittedOrApproved()) {
117-
report.errors.rejectValue('report.cannotUpdateSubmittedOrApprovedReport')
123+
report.errors.reject(INVALID_STATUS_FOR_UPDATE_ERROR_KEY)
118124
}
119125
else {
120126
commonService.updateProperties(report, properties)
@@ -179,6 +185,31 @@ class ReportingService {
179185
}
180186
}
181187

188+
/**
189+
* If the report is completed via a single activity, this method deletes any activity output data and
190+
* resets the progress to planned. Otherwise, no changes are made.
191+
* @param id the report id to reset.
192+
* @return the report, after the update.
193+
*/
194+
Report reset(String id) {
195+
Report report = get(id)
196+
if (!report) {
197+
return null
198+
}
199+
if (report.isSubmittedOrApproved()) {
200+
report.errors.reject(INVALID_STATUS_FOR_UPDATE_ERROR_KEY)
201+
}
202+
else {
203+
if (report.isSingleActivityReport()) {
204+
activityService.update([progress:Activity.PLANNED, activityId:report.activityId], report.activityId)
205+
activityService.deleteActivityOutputs(report.activityId)
206+
}
207+
populateActivityInformation([report])
208+
209+
}
210+
return report
211+
}
212+
182213
def submit(String id, String comment = '') {
183214
def user = userService.getCurrentUserDetails()
184215
Report r = get(id)

models/rlpCommunicationMaterials/dataModel.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"title": "Releasing publications",
3-
"modelName": "RLP - Publications",
2+
"title": "Communication Materials",
3+
"modelName": "RLP - Communication Materials",
44
"dataModel": [
55
{
66
"dataType":"list",
7-
"name":"publications",
7+
"name":"communicationMaterials",
88
"columns":[
99
{
1010
"dataType": "text",
11-
"name": "publicationType",
11+
"name": "communicationMaterialType",
1212
"constraints":[
1313
"Media release",
1414
"Report",
@@ -21,25 +21,25 @@
2121
},
2222
{
2323
"dataType": "text",
24-
"name": "otherPublicationType",
24+
"name": "otherCommunicationMaterialType",
2525
"validate": "required",
2626
"behaviour":[
2727

2828
{
29-
"condition": "publicationType == \"Other\"",
29+
"condition": "communicationMaterialType == \"Other\"",
3030
"type": "enable"
3131
}
3232

3333
]
3434
},
3535
{
3636
"dataType": "number",
37-
"name": "numberOfPublications",
37+
"name": "numberOfCommunicationMaterials",
3838
"validate": "required,min[0]"
3939
},
4040
{
4141
"dataType": "text",
42-
"name": "publicationPurpose",
42+
"name": "communicationMaterialPurpose",
4343
"validate": "required"
4444
}
4545
]
@@ -53,31 +53,31 @@
5353
{
5454
"columns": [
5555
{
56-
"source": "publicationType",
57-
"title": "Type of publication",
56+
"source": "communicationMaterialType",
57+
"title": "Type of communication material",
5858
"type": "select2",
5959
"width":"25%"
6060
},
6161
{
62-
"source":"otherPublicationType",
63-
"title":"Other type of publication released",
62+
"source":"otherCommunicationMaterialType",
63+
"title":"Other type of communication material released",
6464
"width":"25",
6565
"type":"text"
6666
},
6767
{
68-
"source": "numberOfPublications",
69-
"title": "Number of publications released",
68+
"source": "numberOfCommunicationMaterials",
69+
"title": "Number of communication materials released",
7070
"type": "number",
7171
"width":"15%"
7272
},
7373
{
74-
"source": "publicationPurpose",
75-
"title": "Purpose of publication",
74+
"source": "communicationMaterialPurpose",
75+
"title": "Purpose of communication material",
7676
"type": "text",
7777
"width":"35%"
7878
}
7979
],
80-
"source":"publications",
80+
"source":"communicationMaterials",
8181
"type": "table",
8282
"userAddedRows": true
8383
},
@@ -86,7 +86,7 @@
8686
"items":[
8787
{
8888
"type":"literal",
89-
"source":"<i>Note: to upload a publication refer to the documents tab.</i>"
89+
"source":"<i>Note: to upload a communication material refer to the documents tab.</i>"
9090
}
9191
]
9292

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"title": "Community/stakeholder engagement",
3+
"modelName": "RLP - Community engagement",
4+
"dataModel": [
5+
{
6+
"dataType":"list",
7+
"name":"events",
8+
"columns":[
9+
{
10+
"dataType": "text",
11+
"name": "eventType",
12+
"constraints":[
13+
"On-farm trials",
14+
"On-farm inspections",
15+
"Field day activity",
16+
"Conference/Seminar",
17+
"Meeting",
18+
"Training session",
19+
"Planning session",
20+
"Working bee",
21+
"Workshop",
22+
"Project feedback / debrief session",
23+
"Other"
24+
],
25+
"validate": "required"
26+
},
27+
{
28+
"dataType": "text",
29+
"name": "otherEventType",
30+
"validate": "required",
31+
"behaviour":[
32+
33+
{
34+
"condition": "eventType == \"Other\"",
35+
"type": "enable"
36+
}
37+
38+
]
39+
},
40+
{
41+
"dataType": "number",
42+
"name": "numberOfParticipants",
43+
"validate": "required,min[0]"
44+
},
45+
{
46+
"dataType": "number",
47+
"name": "numberOfFarmers",
48+
"validate": "required,min[0]"
49+
},
50+
{
51+
"dataType": "stringList",
52+
"name": "industryType",
53+
"constraints":[
54+
"Broad acre cropping",
55+
"Dairy",
56+
"Horticulture",
57+
"Grazing",
58+
"Fisheries",
59+
"Aquaculture"
60+
],
61+
"validate": "required,min[0]"
62+
},
63+
{
64+
"dataType": "text",
65+
"name": "eventPurpose",
66+
"validate": "required,max[80]"
67+
}
68+
]
69+
}
70+
71+
],
72+
"viewModel": [
73+
74+
{
75+
"items": [
76+
{
77+
"columns": [
78+
{
79+
"source": "eventType",
80+
"title": "Community engagement activity type",
81+
"type": "select2",
82+
"width":"20%"
83+
},
84+
{
85+
"source": "otherEventType",
86+
"title": "Type of activity (if other)",
87+
"type": "text",
88+
"width":"20%"
89+
},
90+
{
91+
"source": "eventPurpose",
92+
"title": "Aim of activity",
93+
"type": "textarea",
94+
"width":"20%"
95+
},
96+
{
97+
"source": "numberOfParticipants",
98+
"title": "Total number of attendees / participants",
99+
"type": "number",
100+
"width":"10%"
101+
},
102+
{
103+
"source": "numberOfFarmers",
104+
"title": "Total number of farmers attending / participating",
105+
"type": "number",
106+
"width":"10%"
107+
},
108+
{
109+
"source": "industryType",
110+
"title": "Industry type engaged",
111+
"type": "select2Many",
112+
"width":"20%"
113+
}
114+
115+
],
116+
"source":"events",
117+
"userAddedRows":true,
118+
"type": "table"
119+
}
120+
],
121+
"type": "section"
122+
}
123+
]
124+
}

0 commit comments

Comments
 (0)