From 6bdce19ad94d85d39dc67c3df68b1d2a8800ffa0 Mon Sep 17 00:00:00 2001 From: Youri K Date: Thu, 16 May 2019 17:50:11 +0200 Subject: [PATCH] add allowed magnifications to annotation settings #4075 --- app/models/annotation/AnnotationSettings.scala | 3 ++- app/models/task/TaskType.scala | 8 ++++++-- ...043-annotationsettings-allowedMagnifications.sql | 13 +++++++++++++ ...043-annotationsettings-allowedMagnifications.sql | 11 +++++++++++ tools/postgres/schema.sql | 6 ++++-- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 conf/evolutions/043-annotationsettings-allowedMagnifications.sql create mode 100644 conf/evolutions/reversions/043-annotationsettings-allowedMagnifications.sql diff --git a/app/models/annotation/AnnotationSettings.scala b/app/models/annotation/AnnotationSettings.scala index 556d4d5984a..62b52ca53e4 100755 --- a/app/models/annotation/AnnotationSettings.scala +++ b/app/models/annotation/AnnotationSettings.scala @@ -9,7 +9,8 @@ case class AnnotationSettings( allowedModes: List[String] = SKELETON_MODES, preferredMode: Option[String] = None, branchPointsAllowed: Boolean = true, - somaClickingAllowed: Boolean = true + somaClickingAllowed: Boolean = true, + allowedMagnifications: Option[JsValue] = None ) object AnnotationSettings { diff --git a/app/models/task/TaskType.scala b/app/models/task/TaskType.scala index df806156cc6..e4cf9f30243 100755 --- a/app/models/task/TaskType.scala +++ b/app/models/task/TaskType.scala @@ -74,7 +74,8 @@ class TaskTypeDAO @Inject()(sqlClient: SQLClient)(implicit ec: ExecutionContext) parseArrayTuple(r.settingsAllowedmodes), r.settingsPreferredmode, r.settingsBranchpointsallowed, - r.settingsSomaclickingallowed + r.settingsSomaclickingallowed, + r.settingsAllowedmagnifications.map(Json.parse) ), r.recommendedconfiguration.map(Json.parse), tracingType, @@ -114,10 +115,11 @@ class TaskTypeDAO @Inject()(sqlClient: SQLClient)(implicit ec: ExecutionContext) for { _ <- run( sqlu"""insert into webknossos.taskTypes(_id, _team, summary, description, settings_allowedModes, settings_preferredMode, - settings_branchPointsAllowed, settings_somaClickingAllowed, recommendedConfiguration, tracingType, created, isDeleted) + settings_branchPointsAllowed, settings_somaClickingAllowed, settings_allowedMagnifications, recommendedConfiguration, tracingType, created, isDeleted) values(${t._id.id}, ${t._team.id}, ${t.summary}, ${t.description}, '#${sanitize( writeArrayTuple(t.settings.allowedModes))}', #${optionLiteral(t.settings.preferredMode.map(sanitize(_)))}, ${t.settings.branchPointsAllowed}, ${t.settings.somaClickingAllowed}, #${optionLiteral( + t.settings.allowedMagnifications.map(c => sanitize(Json.toJson(c).toString)))}, #${optionLiteral( t.recommendedConfiguration.map(c => sanitize(Json.toJson(c).toString)))}, '#${t.tracingType.toString}', ${new java.sql.Timestamp(t.created)}, ${t.isDeleted})""") } yield () @@ -135,6 +137,8 @@ class TaskTypeDAO @Inject()(sqlClient: SQLClient)(implicit ec: ExecutionContext) settings_preferredMode = #${optionLiteral(t.settings.preferredMode.map(sanitize(_)))}, settings_branchPointsAllowed = ${t.settings.branchPointsAllowed}, settings_somaClickingAllowed = ${t.settings.somaClickingAllowed}, + settings_allowedMagnifications = #${optionLiteral( + t.settings.allowedMagnifications.map(c => sanitize(Json.toJson(c).toString)))}, recommendedConfiguration = #${optionLiteral( t.recommendedConfiguration.map(c => sanitize(Json.toJson(c).toString)))}, isDeleted = ${t.isDeleted} diff --git a/conf/evolutions/043-annotationsettings-allowedMagnifications.sql b/conf/evolutions/043-annotationsettings-allowedMagnifications.sql new file mode 100644 index 00000000000..ffde0736a0b --- /dev/null +++ b/conf/evolutions/043-annotationsettings-allowedMagnifications.sql @@ -0,0 +1,13 @@ +-- https://github.com/scalableminds/webknossos/pull/X + +START TRANSACTION; + +DROP VIEW webknossos.taskTypes_; +ALTER TABLE webknossos.taskTypes ADD COLUMN settings_allowedMagnifications JSONB; + + +CREATE VIEW webknossos.taskTypes_ AS SELECT * FROM webknossos.taskTypes WHERE NOT isDeleted; + +UPDATE webknossos.releaseInformation SET schemaVersion = 43; + +COMMIT TRANSACTION; diff --git a/conf/evolutions/reversions/043-annotationsettings-allowedMagnifications.sql b/conf/evolutions/reversions/043-annotationsettings-allowedMagnifications.sql new file mode 100644 index 00000000000..ec394e59a70 --- /dev/null +++ b/conf/evolutions/reversions/043-annotationsettings-allowedMagnifications.sql @@ -0,0 +1,11 @@ +START TRANSACTION; + +DROP VIEW webknossos.taskTypes_; +ALTER TABLE webknossos.taskTypes DROP settings_allowedMagnifications; + + +CREATE VIEW webknossos.taskTypes_ AS SELECT * FROM webknossos.taskTypes WHERE NOT isDeleted; + +UPDATE webknossos.releaseInformation SET schemaVersion = 42; + +COMMIT TRANSACTION; diff --git a/tools/postgres/schema.sql b/tools/postgres/schema.sql index 645c0e7fe31..cdef62002d3 100644 --- a/tools/postgres/schema.sql +++ b/tools/postgres/schema.sql @@ -21,7 +21,7 @@ START TRANSACTION; CREATE TABLE webknossos.releaseInformation ( schemaVersion BIGINT NOT NULL ); -INSERT INTO webknossos.releaseInformation(schemaVersion) values(42); +INSERT INTO webknossos.releaseInformation(schemaVersion) values(43); COMMIT TRANSACTION; CREATE TABLE webknossos.analytics( @@ -188,11 +188,13 @@ CREATE TABLE webknossos.taskTypes( settings_preferredMode webknossos.TASKTYPE_MODES DEFAULT 'orthogonal', settings_branchPointsAllowed BOOLEAN NOT NULL, settings_somaClickingAllowed BOOLEAN NOT NULL, + settings_allowedMagnifications JSONB, recommendedConfiguration JSONB, tracingType webknossos.TASKTYPE_TRACINGTYPES NOT NULL DEFAULT 'skeleton', created TIMESTAMPTZ NOT NULL DEFAULT NOW(), isDeleted BOOLEAN NOT NULL DEFAULT false, - CONSTRAINT recommendedConfigurationIsJsonObject CHECK(jsonb_typeof(recommendedConfiguration) = 'object') + CONSTRAINT recommendedConfigurationIsJsonObject CHECK(jsonb_typeof(recommendedConfiguration) = 'object'), + CONSTRAINT settings_allowedMagnificationsIsJsonObject CHECK(jsonb_typeof(settings_allowedMagnifications) = 'object') ); CREATE TABLE webknossos.tasks(