From 71866f464fe0a6cdf23fa4929691aebe97df76e7 Mon Sep 17 00:00:00 2001 From: chrisala Date: Fri, 17 May 2024 08:44:46 +1000 Subject: [PATCH] Don't include site name in data set name for non-plot protocols #942 --- .../services/au/org/ala/ecodata/ParatooService.groovy | 9 +++++---- .../groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy index f0c5ced05..2a5be244b 100644 --- a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy @@ -299,8 +299,8 @@ class ParatooService { dataSet.format = DATASET_DATABASE_TABLE dataSet.sizeUnknown = true // Update the data set name as the information supplied during /mint-identifier isn't enough - // to ensure uniqueness - dataSet.name = buildUpdatedDataSetSummaryName(siteName, dataSet.startDate, dataSet.endDate, form.name, surveyId) + // to ensure uniqueness. + dataSet.name = buildUpdatedDataSetSummaryName(siteName, dataSet.startDate, dataSet.endDate, form.name, surveyId, config) // Delete previously created activity so that duplicate species records are not created. // Updating existing activity will also create duplicates since it relies on outputSpeciesId to determine @@ -319,9 +319,10 @@ class ParatooService { } } - protected static String buildUpdatedDataSetSummaryName(String siteName, String startDate, String endDate, String protocolName, ParatooCollectionId surveyId) { + protected static String buildUpdatedDataSetSummaryName(String siteName, String startDate, String endDate, String protocolName, ParatooCollectionId surveyId, ParatooProtocolConfig config) { String name = protocolName - if (siteName) { + //The site name for non-plot based data sets is not used as it contains the same data (protocol and time) as the name + if (siteName && config.usesPlotLayout) { name += " (" + siteName + ")" } if (startDate && endDate && startDate != endDate) { diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy index 2d6fd58c2..18b2fb6a5 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy @@ -1494,10 +1494,10 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest