Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a bug where changing the color of a segment via the menu in the segments tab would update the segment color of the previous segment, on which the context menu was opened. [#8225](https://github.com/scalableminds/webknossos/pull/8225)
- Fixed a bug where in the add remote dataset view the dataset name setting was not in sync with the datasource setting of the advanced tab making the form not submittable. [#8245](https://github.com/scalableminds/webknossos/pull/8245)
- Fixed a bug when importing an NML with groups when only groups but no trees exist in an annotation. [#8176](https://github.com/scalableminds/webknossos/pull/8176)
- Fix read and update dataset route for versions 8 and lower. [#8263](https://github.com/scalableminds/webknossos/pull/8263)
- Added missing legacy support for `isValidNewName` route. [#8252](https://github.com/scalableminds/webknossos/pull/8252)
- Fixed a bug where trying to delete a non-existing node (via the API, for example) would delete the whole active tree. [#8176](https://github.com/scalableminds/webknossos/pull/8176)
- Fixed a bug where dataset uploads would fail if the organization directory on disk is missing. [#8230](https://github.com/scalableminds/webknossos/pull/8230)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/DatasetController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class DatasetController @Inject()(userService: UserService,
sil.SecuredAction.async(parse.json) { implicit request =>
withJsonBodyUsing(datasetPublicReads) {
case (description, datasetName, legacyDatasetDisplayName, sortingKey, isPublic, tags, metadata, folderId) => {
val name = if (datasetName.isDefined) datasetName else legacyDatasetDisplayName
val name = if (legacyDatasetDisplayName.isDefined) legacyDatasetDisplayName else datasetName
for {
datasetIdValidated <- ObjectId.fromString(datasetId)
dataset <- datasetDAO.findOne(datasetIdValidated) ?~> notFoundMessage(datasetIdValidated.toString) ~> NOT_FOUND
Comment on lines 340 to 345
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the precedence issue described in the pr description

Expand Down
19 changes: 17 additions & 2 deletions app/controllers/LegacyApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
for {
dataset <- datasetDAO.findOneByNameAndOrganization(datasetName, organizationId)
result <- datasetController.read(dataset._id.toString, sharingToken)(request)
} yield result
adaptedResult <- replaceInResult(migrateDatasetJsonToOldFormat)(result)
} yield adaptedResult
}

def updateDatasetV8(organizationId: String, datasetName: String): Action[JsValue] =
Expand All @@ -81,7 +82,8 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
_ <- Fox.successful(logVersioned(request))
dataset <- datasetDAO.findOneByNameAndOrganization(datasetName, organizationId)
result <- datasetController.update(dataset._id.toString)(request)
} yield result
adaptedResult <- replaceInResult(migrateDatasetJsonToOldFormat)(result)
} yield adaptedResult
}

def updateDatasetTeamsV8(organizationId: String, datasetName: String): Action[List[ObjectId]] =
Expand Down Expand Up @@ -241,6 +243,19 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,

/* private helper methods for legacy adaptation */

private def migrateDatasetJsonToOldFormat(jsResult: JsObject): Fox[JsObject] = {
val datasetName = (jsResult \ "name").asOpt[String]
val directoryName = (jsResult \ "directoryName").asOpt[String]
datasetName.zip(directoryName) match {
case Some((name, dirName)) =>
for {
dsWithOldNameField <- tryo(jsResult - "directoryName" + ("name" -> Json.toJson(dirName))).toFox
dsWithOldDisplayNameField <- tryo(dsWithOldNameField + ("displayName" -> Json.toJson(name))).toFox
} yield dsWithOldDisplayNameField
case _ => Fox.successful(jsResult)
}
}

private def addDataSetToTaskInAnnotation(jsResult: JsObject): Fox[JsObject] = {
val taskObjectOpt = (jsResult \ "task").asOpt[JsObject]
taskObjectOpt
Expand Down