Skip to content

Commit 7184cb7

Browse files
authored
Merge pull request #950 from AtlasOfLivingAustralia/feature/issue942
Don't include site name in data set name for non-plot protocols #942
2 parents 1ac3b7e + 71866f4 commit 7184cb7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ class ParatooService {
299299
dataSet.format = DATASET_DATABASE_TABLE
300300
dataSet.sizeUnknown = true
301301
// Update the data set name as the information supplied during /mint-identifier isn't enough
302-
// to ensure uniqueness
303-
dataSet.name = buildUpdatedDataSetSummaryName(siteName, dataSet.startDate, dataSet.endDate, form.name, surveyId)
302+
// to ensure uniqueness.
303+
dataSet.name = buildUpdatedDataSetSummaryName(siteName, dataSet.startDate, dataSet.endDate, form.name, surveyId, config)
304304

305305
// Delete previously created activity so that duplicate species records are not created.
306306
// Updating existing activity will also create duplicates since it relies on outputSpeciesId to determine
@@ -319,9 +319,10 @@ class ParatooService {
319319
}
320320
}
321321

322-
protected static String buildUpdatedDataSetSummaryName(String siteName, String startDate, String endDate, String protocolName, ParatooCollectionId surveyId) {
322+
protected static String buildUpdatedDataSetSummaryName(String siteName, String startDate, String endDate, String protocolName, ParatooCollectionId surveyId, ParatooProtocolConfig config) {
323323
String name = protocolName
324-
if (siteName) {
324+
//The site name for non-plot based data sets is not used as it contains the same data (protocol and time) as the name
325+
if (siteName && config.usesPlotLayout) {
325326
name += " (" + siteName + ")"
326327
}
327328
if (startDate && endDate && startDate != endDate) {

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1494,10 +1494,10 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
14941494

14951495
def "The data set name will be updated after the callback to Monitor core and be created from available information"() {
14961496
expect:
1497-
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}"
1498-
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", null, "Protocol 1", null) == "Protocol 1 (site) - 2024-05-14 10:00 ${am}"
1499-
ParatooService.buildUpdatedDataSetSummaryName(null, "2024-05-14T00:00:00Z", null, "Protocol 1", null) == "Protocol 1 - 2024-05-14 10:00 ${am}"
1500-
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}"
1497+
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", "2024-05-14T10:00:00Z", "Protocol 1", null, new ParatooProtocolConfig()) == "Protocol 1 (site) - 2024-05-14 10:00 ${am} to 2024-05-14 8:00 ${pm}"
1498+
ParatooService.buildUpdatedDataSetSummaryName("site", "2024-05-14T00:00:00Z", null, "Protocol 1", null, new ParatooProtocolConfig(usesPlotLayout: false)) == "Protocol 1 - 2024-05-14 10:00 ${am}"
1499+
ParatooService.buildUpdatedDataSetSummaryName(null, "2024-05-14T00:00:00Z", null, "Protocol 1", null, new ParatooProtocolConfig()) == "Protocol 1 - 2024-05-14 10:00 ${am}"
1500+
ParatooService.buildUpdatedDataSetSummaryName(null, null, null, "Protocol 1", new ParatooCollectionId(eventTime:DateUtil.parse("2024-05-14T00:00:00Z")), new ParatooProtocolConfig()) == "Protocol 1 - 2024-05-14 10:00 ${am}"
15011501

15021502

15031503
}

0 commit comments

Comments
 (0)