Repository: CSCfi/rems
Pull request #1431 (2019-07-30 12:55:43)

Schema cleanup
#1101


Patch:
diff --git a/src/clj/rems/api/applications.clj b/src/clj/rems/api/applications.clj
index da8637d1f..6130ab622 100644
--- a/src/clj/rems/api/applications.clj
+++ b/src/clj/rems/api/applications.clj
@@ -55,10 +55,6 @@
 (s/defschema Deciders
   [Decider])
 
-(s/defschema Command
-  {:type s/Keyword
-   s/Any s/Any})
-
 (s/defschema AcceptInvitationResult
   {:success s/Bool
    (s/optional-key :application-id) s/Int
diff --git a/src/clj/rems/api/schema.clj b/src/clj/rems/api/schema.clj
index d85acb73f..57d07184d 100644
--- a/src/clj/rems/api/schema.clj
+++ b/src/clj/rems/api/schema.clj
@@ -42,21 +42,6 @@
 
 (s/defschema ResourceLicense License)
 
-(s/defschema ApplicationLicense
-  (merge License
-         {:type (s/eq "license") ;; TODO this is pretty redundant
-          :approved s/Bool}))
-
-(s/defschema Item
-  {:id s/Int
-   :localizations {s/Keyword {:title s/Str :inputprompt (s/maybe s/Str)}}
-   :optional s/Bool
-   :options [{:key s/Str :label {s/Keyword s/Str}}]
-   :maxlength (s/maybe s/Int)
-   :type s/Str
-   :value (s/maybe s/Str)
-   :previous-value (s/maybe s/Str)})
-
 (s/defschema Event
   (assoc events/EventBase
          s/Keyword s/Any))
@@ -110,11 +95,6 @@
 
 (def UserId s/Str)
 
-(s/defschema Actor
-  {:actoruserid UserId
-   :round s/Int
-   :role (s/enum "approver" "reviewer")})
-
 (s/defschema WorkflowLicense
   {:type s/Str
    :start DateTime
@@ -122,26 +102,20 @@
    :localizations [s/Any]
    :end (s/maybe DateTime)})
 
-(s/defschema WorkflowDB ; TODO: unify workflow schemas
+(s/defschema Workflow
   {:id s/Int
    :organization s/Str
    :owneruserid UserId
    :modifieruserid UserId
    :title s/Str
    :workflow s/Any
-   :licenses s/Any
+   :licenses [WorkflowLicense]
    :start DateTime
    :end (s/maybe DateTime)
    :expired s/Bool
    :enabled s/Bool
    :archived s/Bool})
 
-(s/defschema Workflow
-  (-> WorkflowDB
-      (dissoc :licenses)
-      (assoc :actors [Actor]
-             :licenses [WorkflowLicense])))
-
 (def not-neg? (partial <= 0))
 
 (s/defschema FieldTemplate
diff --git a/src/clj/rems/api/workflows.clj b/src/clj/rems/api/workflows.clj
index 67b4fd585..6ce90b00e 100644
--- a/src/clj/rems/api/workflows.clj
+++ b/src/clj/rems/api/workflows.clj
@@ -30,7 +30,7 @@
       (assoc :end (parse-db-time (:end license)))))
 
 (defn- format-workflow
-  [{:keys [id organization owneruserid modifieruserid title workflow start end expired enabled archived licenses actors]}]
+  [{:keys [id organization owneruserid modifieruserid title workflow start end expired enabled archived licenses]}]
   {:id id
    :organization organization
    :owneruserid owneruserid
@@ -42,8 +42,7 @@
    :expired expired
    :enabled enabled
    :archived archived
-   :licenses (mapv format-license licenses)
-   :actors actors})
+   :licenses (mapv format-license licenses)})
 
 (s/defschema CreateWorkflowCommand
   {:organization s/Str


Test patch:
diff --git a/test/clj/rems/application/test_model.clj b/test/clj/rems/application/test_model.clj
index 2877e2d36..5148dacbb 100644
--- a/test/clj/rems/application/test_model.clj
+++ b/test/clj/rems/application/test_model.clj
@@ -194,7 +194,7 @@
   (doseq [[description schema dummies] [["form template" schema/FormTemplate get-form-template]
                                         ["catalogue item" schema/CatalogueItem get-catalogue-item]
                                         ["license" schema/License get-license]
-                                        ["workflow" schema/WorkflowDB get-workflow]]]
+                                        ["workflow" schema/Workflow get-workflow]]]
     (doseq [[id dummy] dummies]
       (testing (str description " " id)
         (is (s/validate schema dummy))))))