Skip to content

Commit

Permalink
add allowed magnifications to annotation settings #4075
Browse files Browse the repository at this point in the history
  • Loading branch information
Youri K committed May 16, 2019
1 parent a5c6731 commit 6bdce19
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/models/annotation/AnnotationSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions app/models/task/TaskType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ()
Expand All @@ -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}
Expand Down
13 changes: 13 additions & 0 deletions conf/evolutions/043-annotationsettings-allowedMagnifications.sql
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 4 additions & 2 deletions tools/postgres/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6bdce19

Please sign in to comment.