Skip to content

Commit

Permalink
Merge branch 'hotfix/3.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
bivab committed Nov 15, 2017
2 parents 608a659 + 8272ea7 commit c8dfaeb
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.2.0
current_version = 3.2.1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>\w+))?
tag = False
commit = True
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ script:
- lein launch4j

after_success:
- travis-custom-deploy sftp target/mincer-3.2.0-standalone.jar target/mincer-3.2.0.exe
- travis-custom-deploy sftp target/mincer-3.2.1-standalone.jar target/mincer-3.2.1.exe
env:
global:
- DISPLAY=:99.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Mincer supports two usage modes: batch/CLI and GUI modes.
To start the graphical user-interface run the provided jar without arguments:

```
$ java -jar mincer-3.2.0-standalone.jar
$ java -jar mincer-3.2.1-standalone.jar
```

### CLI
Expand Down
10 changes: 5 additions & 5 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>target/mincer-3.2.0-standalone.jar</jar>
<outfile>target/mincer-3.2.0.exe</outfile>
<jar>target/mincer-3.2.1-standalone.jar</jar>
<outfile>target/mincer-3.2.1.exe</outfile>
<errTitle></errTitle>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
Expand All @@ -23,15 +23,15 @@
</jre>
<versionInfo>
<fileVersion>0.0.0.1</fileVersion>
<txtFileVersion>3.2.0-dev</txtFileVersion>
<txtFileVersion>3.2.1-dev</txtFileVersion>
<fileDescription>mincer</fileDescription>
<copyright>ISC</copyright>
<productVersion>0.0.0.1</productVersion>
<txtProductVersion>3.2.0-dev</txtProductVersion>
<txtProductVersion>3.2.1-dev</txtProductVersion>
<productName>mincer</productName>
<companyName></companyName>
<internalName>mincer</internalName>
<originalFilename>mincer-3.2.0.exe</originalFilename>
<originalFilename>mincer-3.2.1.exe</originalFilename>
</versionInfo>
<messages>
<startupErr>Startup Error</startupErr>
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject mincer "3.2.0"
(defproject mincer "3.2.1"
:description "Tool to create a SQLite database from PlüS module tree and data XML files."
:url "https://github.com/plues/mincer"
:license {:name "Eclipse Public License"
Expand Down
2 changes: 1 addition & 1 deletion src/mincer/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[clojure.java.jdbc :refer [with-db-transaction]]
[clojure.tools.logging :as log]))

(def mincer-version "3.2.0") ; updated with bumpversion
(def mincer-version "3.2.1") ; updated with bumpversion

(defn now [] (new java.util.Date))

Expand Down
2 changes: 1 addition & 1 deletion src/mincer/ui.clj
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
(let [lbl-mincer (label ::mincer)
lbl-icon (label :icon logo)
lbl-file-select (label ::file-select)
lbl-version (label "3.2.0") ; managed by bumpversion
lbl-version (label "3.2.1") ; managed by bumpversion
lbl-save (label ::save)]
(doall (map #(config! % :border 10) [lbl-mincer lbl-file-select lbl-version lbl-icon]))
(config! lbl-save :halign :center)
Expand Down
49 changes: 47 additions & 2 deletions src/mincer/xml/tree_validation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[clojure.tools.logging :as log]))

(defmulti validate :tag)
(defmulti validate-cp :tag)

(def ^:dynamic errors)

Expand Down Expand Up @@ -40,7 +41,10 @@

(defmethod validate :b [b]
(log/trace (:tag b))
(flatten (map validate (:content b))))
; if b tag has cp field

(let [validation-fn (if (contains? (:attrs b) :cp) validate-cp validate)]
(flatten (map validation-fn (:content b)))))

(defmethod validate :l [l]
(log/trace (:tag l))
Expand Down Expand Up @@ -78,6 +82,47 @@
(log/trace "Ignoring" tag)
[])

(defmethod validate-cp :l [l]
(log/trace (:tag l))
(log/trace l)
; validate that l has min-cp and max-cp attrs
(if (not (subset? #{:min-cp :max-cp} (-> l :attrs keys set)))
(do
(set! errors true)
(log/error "l (level) tag for a cp based course does not contain min-cp and max-cp attributes" (-> l :attrs :name))))
; validate mixed l and m tags in levels
; checking if content containts l and m tags
(if (subset? #{:l :m} (set (map :tag (:content l))))
(do
(set! errors true)
(log/error "level containts l and m tags as children in level " (-> l :attrs :name))))
(flatten (map validate-cp (:content l))))

(defmethod validate-cp :minors [minors]
(log/trace (:tag minors))
; only minor tags
(if (not (= #{:minor} (set (map :tag (:content minors)))))
(log/error "Tag 'minors' can only contain minor-Tags."))
(flatten (map validate-cp (:content minors))))

(defmethod validate-cp :minor [minor]
(log/trace (:tag minor))
(let [stg (-> minor :attrs :stg)
po (-> minor :attrs :pversion)]
(do (when (nil? stg) (log_error "Missing 'stg' in minor tag."))
(when (nil? po) (log_error "Missing 'pversion' in minor tag."))
(try (Integer/parseInt po) (catch NumberFormatException e (log_error "Attribute 'pversion' has to be an integer."))))))

(defmethod validate-cp :m [m]
(log/trace (:tag m))
(let [pordnr (-> m :attrs :pordnr)]
(when (nil? pordnr) (log/error "pordnr missing " (-> m :attrs :name)))
pordnr))

(defmethod validate-cp :default [tag]
(log/trace "Ignoring" tag)
[])

(defn validate-modules [xml]
(let [modules (group-by (fn [node] (-> node :attrs :pordnr))
(filter (fn [node] (= :m (:tag node)))
Expand All @@ -93,4 +138,4 @@
(validate xml)
(validate-modules xml)
(if errors
(throw (IllegalArgumentException. "Module tree contains validation errors.")))))
(throw (IllegalArgumentException. "Module tree contains validation errors.")))))
3 changes: 3 additions & 0 deletions test/mincer/xml/tree_cp_test_data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
:content [m-cp-tag]
:tag :l}]
:tag :l})
(def l-cp-tag-missing-data {:attrs {:name "Wahlpflichtmodule"}
:content []
:tag :l})

(def b-cp-tag {:attrs {:abschl "bk"
:kzfa "H"
Expand Down
6 changes: 6 additions & 0 deletions test/mincer/xml/tree_test_cp.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns mincer.xml.tree-test-cp
(:require [clojure.test :refer :all]
[mincer.xml.tree-cp-test-data :refer :all]
[mincer.xml.tree-validation :refer :all]
[mincer.xml.tree :refer :all]))

(def result-cp-module {:type :module
Expand Down Expand Up @@ -84,3 +85,8 @@
children (:children course)]
(is (= 1 (count children)))
(is (not-any? nil? children))))

(deftest test-validate-cp-based-level-with-missing-cp-data
(binding [errors false]
(validate-cp l-cp-tag-missing-data)
(is errors)))

0 comments on commit c8dfaeb

Please sign in to comment.