Skip to content

Commit 5b02542

Browse files
chrisalatemi
authored andcommitted
Fixed locale dependency, remove project name from data set name #942
1 parent dccc4f4 commit 5b02542

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class ParatooService {
196196

197197
private static String buildName(String protocolId, String displayDate, Project project) {
198198
ActivityForm protocolForm = ActivityForm.findByExternalId(protocolId)
199-
String dataSetName = protocolForm?.name + " - " + displayDate + " (" + project.name + ")"
199+
String dataSetName = protocolForm?.name + " - " + displayDate
200200
dataSetName
201201
}
202202

src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import org.codehaus.jackson.map.ObjectMapper
1212
import org.grails.web.converters.marshaller.json.CollectionMarshaller
1313
import org.grails.web.converters.marshaller.json.MapMarshaller
1414

15+
import java.time.format.DateTimeTextProvider
16+
import java.time.temporal.TemporalField
17+
1518
import static grails.async.Promises.waitAll
1619
/**
1720
* Tests for the ParatooService.
@@ -33,6 +36,10 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
3336
static Map DUMMY_POLYGON = [type: 'Polygon', coordinates: [[[1, 2], [2, 2], [2, 1], [1, 1], [1, 2]]]]
3437
static Map DUMMY_PLOT = ['type':'Point', coordinates: [1,2]]
3538

39+
// The am/pm in the formatted time is local dependent and this appears to be easiest way to determine the value.
40+
String am = DateUtil.formatAsDisplayDateTime("2024-05-14T00:00:00Z")[-2..-1]
41+
String pm = am == "AM" ? "PM" : "pm"
42+
3643
def setup() {
3744

3845
deleteAll()
@@ -156,7 +163,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
156163
assert dataSet.protocol == collectionId.protocolId
157164
assert dataSet.grantId == "g1"
158165
assert dataSet.progress == 'planned'
159-
assert dataSet.name == "aParatooForm 1 - ${DateUtil.formatAsDisplayDateTime(collectionId.eventTime)} (Project 1)"
166+
assert dataSet.name == "aParatooForm 1 - ${DateUtil.formatAsDisplayDateTime(collectionId.eventTime)}"
160167

161168
[status: 'ok']
162169
}
@@ -182,7 +189,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
182189
Map dataSet = [dataSetId:'d1', grantId:'g1', surveyId:paratooCollectionId.toMap(), activityId: "123"]
183190
dataSet.surveyId.survey_metadata.orgMintedUUID = orgMintedId
184191
Map expectedDataSetSync = dataSet + [progress: Activity.STARTED]
185-
Map expectedDataSetAsync = dataSet + [progress: Activity.STARTED, startDate: "2023-09-01T00:00:00Z", endDate: "2023-09-01T00:00:00Z", areSpeciesRecorded: false, activityId: '123', siteId: null, format: "Database Table", sizeUnknown: true, name: "aParatooForm 1 - 2023-09-01 10:00 am"]
192+
Map expectedDataSetAsync = dataSet + [progress: Activity.STARTED, startDate: "2023-09-01T00:00:00Z", endDate: "2023-09-01T00:00:00Z", areSpeciesRecorded: false, activityId: '123', siteId: null, format: "Database Table", sizeUnknown: true, name: "aParatooForm 1 - 2023-09-01 10:00 ${am}"]
186193
ParatooProject project = new ParatooProject(id: projectId, project: new Project(projectId: projectId, custom: [dataSets: [dataSet]]))
187194

188195
when:
@@ -1339,10 +1346,11 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
13391346

13401347
def "The data set name will be updated after the callback to Monitor core and be created from available information"() {
13411348
expect:
1342-
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", "2024-05-14T10:00:00Z", "Protocol 1", null) == "Protocol 1 (site) - 2024-05-14 10:00 am to 2024-05-14 8:00 pm"
1343-
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", null, "Protocol 1", null) == "Protocol 1 (site) - 2024-05-14 10:00 am"
1344-
ParatooService.buildUpdatedDataSetSummaryName(null, "2024-05-14T00:00:00Z", null, "Protocol 1", null) == "Protocol 1 - 2024-05-14 10:00 am"
1345-
ParatooService.buildUpdatedDataSetSummaryName(null, null, null, "Protocol 1", new ParatooCollectionId(eventTime:DateUtil.parse("2024-05-14T00:00:00Z"))) == "Protocol 1 - 2024-05-14 10:00 am"
1349+
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", "2024-05-14T10:00:00Z", "Protocol 1", null) == "Protocol 1 (site) - 2024-05-14 10:00 ${am} to 2024-05-14 8:00 ${pm}"
1350+
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", null, "Protocol 1", null) == "Protocol 1 (site) - 2024-05-14 10:00 ${am}"
1351+
ParatooService.buildUpdatedDataSetSummaryName(null, "2024-05-14T00:00:00Z", null, "Protocol 1", null) == "Protocol 1 - 2024-05-14 10:00 ${am}"
1352+
ParatooService.buildUpdatedDataSetSummaryName(null, null, null, "Protocol 1", new ParatooCollectionId(eventTime:DateUtil.parse("2024-05-14T00:00:00Z"))) == "Protocol 1 - 2024-05-14 10:00 ${am}"
1353+
13461354

13471355
}
13481356

0 commit comments

Comments
 (0)