-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nml upload with only ds name in nml by using user's orga as fallback #8277
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,7 +24,7 @@ import com.scalableminds.webknossos.tracingstore.tracings.ColorGenerator | |||||
import com.scalableminds.webknossos.tracingstore.tracings.skeleton.updating.TreeType | ||||||
import com.scalableminds.webknossos.tracingstore.tracings.skeleton.{MultiComponentTreeSplitter, TreeValidator} | ||||||
import com.typesafe.scalalogging.LazyLogging | ||||||
import models.annotation.UploadedVolumeLayer | ||||||
import models.annotation.{SharedParsingParameters, UploadedVolumeLayer} | ||||||
import models.dataset.DatasetDAO | ||||||
import net.liftweb.common.Box._ | ||||||
import net.liftweb.common.{Box, Empty, Failure, Full} | ||||||
|
@@ -48,13 +48,12 @@ class NmlParser @Inject()(datasetDAO: DatasetDAO) extends LazyLogging with Proto | |||||
|
||||||
def parse(name: String, | ||||||
nmlInputStream: InputStream, | ||||||
overwritingDatasetId: Option[String], | ||||||
isTaskUpload: Boolean, | ||||||
sharedParsingParameters: SharedParsingParameters, | ||||||
basePath: Option[String] = None)(implicit m: MessagesProvider, | ||||||
ec: ExecutionContext, | ||||||
ctx: DBAccessContext): Fox[NmlParseSuccessWithoutFile] = | ||||||
for { | ||||||
nmlParsedParameters <- getParametersFromNML(nmlInputStream, name, overwritingDatasetId, isTaskUpload).toFox | ||||||
nmlParsedParameters <- getParametersFromNML(nmlInputStream, name, sharedParsingParameters).toFox | ||||||
parsedResult <- nmlParametersToResult(nmlParsedParameters, basePath) | ||||||
} yield parsedResult | ||||||
|
||||||
|
@@ -121,10 +120,10 @@ class NmlParser @Inject()(datasetDAO: DatasetDAO) extends LazyLogging with Proto | |||||
} yield | ||||||
NmlParseSuccessWithoutFile(skeletonTracingOpt, volumeLayers, dataset._id, nmlParams.description, nmlParams.wkUrl) | ||||||
|
||||||
private def getParametersFromNML(nmlInputStream: InputStream, | ||||||
name: String, | ||||||
overwritingDatasetId: Option[String], | ||||||
isTaskUpload: Boolean)(implicit m: MessagesProvider): Box[NmlParsedParameters] = | ||||||
private def getParametersFromNML( | ||||||
nmlInputStream: InputStream, | ||||||
name: String, | ||||||
sharedParsingParameters: SharedParsingParameters)(implicit m: MessagesProvider): Box[NmlParsedParameters] = | ||||||
try { | ||||||
val nmlData = XML.load(nmlInputStream) | ||||||
for { | ||||||
|
@@ -143,21 +142,23 @@ class NmlParser @Inject()(datasetDAO: DatasetDAO) extends LazyLogging with Proto | |||||
_ <- TreeValidator.validateTrees(treesSplit, treeGroupsAfterSplit, branchPoints, comments) | ||||||
additionalAxisProtos <- parseAdditionalAxes(parameters \ "additionalAxes") | ||||||
datasetName = parseDatasetName(parameters \ "experiment") | ||||||
datasetIdOpt = if (overwritingDatasetId.isDefined) overwritingDatasetId | ||||||
datasetIdOpt = if (sharedParsingParameters.overwritingDatasetId.isDefined) | ||||||
sharedParsingParameters.overwritingDatasetId | ||||||
else parseDatasetId(parameters \ "experiment") | ||||||
organizationId = parseOrganizationId(parameters \ "experiment") | ||||||
organizationId = parseOrganizationId(parameters \ "experiment", sharedParsingParameters.userOrganizationId) | ||||||
description = parseDescription(parameters \ "experiment") | ||||||
wkUrl = parseWkUrl(parameters \ "experiment") | ||||||
activeNodeId = parseActiveNode(parameters \ "activeNode") | ||||||
(editPosition, editPositionAdditionalCoordinates) = parseEditPosition(parameters \ "editPosition") | ||||||
.getOrElse((SkeletonTracingDefaults.editPosition, Seq())) | ||||||
editRotation = parseEditRotation(parameters \ "editRotation").getOrElse(SkeletonTracingDefaults.editRotation) | ||||||
zoomLevel = parseZoomLevel(parameters \ "zoomLevel").getOrElse(SkeletonTracingDefaults.zoomLevel) | ||||||
taskBoundingBox: Option[BoundingBox] = if (isTaskUpload) parseTaskBoundingBox(parameters \ "taskBoundingBox") | ||||||
taskBoundingBox: Option[BoundingBox] = if (sharedParsingParameters.isTaskUpload) | ||||||
parseTaskBoundingBox(parameters \ "taskBoundingBox") | ||||||
else None | ||||||
userBoundingBoxes = parseBoundingBoxes(parameters \ "userBoundingBox") | ||||||
} yield { | ||||||
if (!isTaskUpload) { | ||||||
if (!sharedParsingParameters.isTaskUpload) { | ||||||
parseTaskBoundingBoxAsUserBoundingBox(parameters \ "taskBoundingBox", userBoundingBoxes) | ||||||
.map(asUserBoundingBox => userBoundingBoxes :+ asUserBoundingBox) | ||||||
} | ||||||
|
@@ -379,8 +380,10 @@ class NmlParser @Inject()(datasetDAO: DatasetDAO) extends LazyLogging with Proto | |||||
private def parseWkUrl(nodes: NodeSeq): Option[String] = | ||||||
nodes.headOption.map(node => getSingleAttribute(node, "wkUrl")) | ||||||
|
||||||
private def parseOrganizationId(nodes: NodeSeq): String = | ||||||
nodes.headOption.map(node => getSingleAttribute(node, "organization")).getOrElse("") | ||||||
private def parseOrganizationId(nodes: NodeSeq, fallbackOrganization: String): String = | ||||||
nodes.headOption | ||||||
.map(node => getSingleAttributeOpt(node, "organization").getOrElse(fallbackOrganization)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
would a flstMap work here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, good suggestion. Should work 🎉 |
||||||
.getOrElse(fallbackOrganization) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in both cases
the fallback organization (user orga) is used. |
||||||
|
||||||
private def parseActiveNode(nodes: NodeSeq): Option[Int] = | ||||||
nodes.headOption.flatMap(node => getSingleAttribute(node, "id").toIntOpt) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all members of sharedParsingParameters are passed to
nmlParser.parse
anyway. So just pass the wholesharedParsingParameters
object