From 6f98a9c07b50e18feeaca456598541311dd6438c Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Mon, 19 Aug 2024 15:23:47 -0500 Subject: [PATCH 1/2] require feature id's to be in tasks --- app/org/maproulette/provider/ChallengeProvider.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/org/maproulette/provider/ChallengeProvider.scala b/app/org/maproulette/provider/ChallengeProvider.scala index 75222141..2a7ab105 100644 --- a/app/org/maproulette/provider/ChallengeProvider.scala +++ b/app/org/maproulette/provider/ChallengeProvider.scala @@ -330,7 +330,10 @@ class ChallengeProvider @Inject() ( if (!challenge.extra.osmIdProperty.getOrElse("").isEmpty) { return featureOSMId(value, challenge) match { case Some(osmId) => osmId - case None => UUID.randomUUID().toString // task does not contain id property + case None => + throw new InvalidException( + s"No OSM/External Id Property matching ${challenge.extra.osmIdProperty} found." + ) } } @@ -354,10 +357,9 @@ class ChallengeProvider @Inject() ( // See if we can find an id field on the feature properties case Some(properties) => taskNameFromJsValue(properties, challenge) case None => - // if we still don't find anything, create a UUID for it. The - // caveat to this is that if you upload the same file again, it - // will create duplicate tasks - UUID.randomUUID().toString + throw new InvalidException( + s"A feature id is required to prevent duplicate tasks on rebuild. Examples of feature id's include 'id', '@id', 'osmid', 'osm_id', 'name'" + ) } } } From 1fb455d09b82158fc798e94876843dadae0a1844 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Tue, 27 Aug 2024 15:41:37 -0500 Subject: [PATCH 2/2] implement manditory feature id requirements on tasks in challenge with local geojson build process --- app/org/maproulette/provider/ChallengeProvider.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/org/maproulette/provider/ChallengeProvider.scala b/app/org/maproulette/provider/ChallengeProvider.scala index 2a7ab105..ae4a37f5 100644 --- a/app/org/maproulette/provider/ChallengeProvider.scala +++ b/app/org/maproulette/provider/ChallengeProvider.scala @@ -330,9 +330,12 @@ class ChallengeProvider @Inject() ( if (!challenge.extra.osmIdProperty.getOrElse("").isEmpty) { return featureOSMId(value, challenge) match { case Some(osmId) => osmId - case None => + case None => throw new InvalidException( - s"No OSM/External Id Property matching ${challenge.extra.osmIdProperty} found." + s"External ID property '${challenge.extra.osmIdProperty}' not found. To resolve this issue, you have two options: " + + "1. Remove the external ID, and Maproulette will attempt to use one of the default IDs: 'id', '@id', 'osmid', 'osm_id', or 'name'. " + + "2. Provide a valid external ID that matches your data. " + + "Rebuild the challenge after these changes are made." ) } } @@ -356,9 +359,9 @@ class ChallengeProvider @Inject() ( (value \ "properties").asOpt[JsObject] match { // See if we can find an id field on the feature properties case Some(properties) => taskNameFromJsValue(properties, challenge) - case None => + case None => throw new InvalidException( - s"A feature id is required to prevent duplicate tasks on rebuild. Examples of feature id's include 'id', '@id', 'osmid', 'osm_id', 'name'" + s"One or more tasks in your GeoJSON file are missing one or more of the required feature IDs: 'id', '@id', 'osmid', 'osm_id', or 'name'. These IDs are necessary for each task to build a challenge correctly. Please upload a valid GeoJSON file, and rebuild the tasks." ) } }