Skip to content

Commit a74df1f

Browse files
committed
Check distinct attachment names during datasource validation
1 parent 86ba40d commit a74df1f

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DataLayer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ trait StaticLayer extends DataLayer {
8383

8484
def numChannels: Int = if (elementClass == ElementClass.uint24) 3 else 1
8585

86+
def attachments: Option[DataLayerAttachments]
87+
8688
def withMergedAndResolvedAttachments(dataSourcePath: UPath, attachments: DataLayerAttachments): StaticLayer =
8789
this match {
8890
case l: StaticSegmentationLayer =>

webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DataLayerAttachments.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ case class DataLayerAttachments(
4545
connectomes = connectomes.map(_.relativizedIn(dataSourcePath)),
4646
cumsum = cumsum.map(_.relativizedIn(dataSourcePath))
4747
)
48+
49+
lazy val containsDuplicateNames: Boolean =
50+
meshes.distinctBy(_.name).length == meshes.length &&
51+
agglomerates.distinctBy(_.name).length == agglomerates.length &&
52+
connectomes.distinctBy(_.name).length == connectomes.length
4853
}
4954

5055
object DataLayerAttachments {

webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/DataSourceValidation.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ trait DataSourceValidation {
5555
check(
5656
dataSource.dataLayers.map(_.name).forall(!_.startsWith(".")),
5757
"Layer names must not start with dot."
58+
),
59+
check(
60+
dataSource.dataLayers.flatMap(_.attachments).forall(!_.containsDuplicateNames),
61+
"Layer attachments must have unique names in their respective category."
5862
)
5963
).flatten
6064

0 commit comments

Comments
 (0)