diff --git a/src/main/scala/com/campudus/tableaux/arguments.scala b/src/main/scala/com/campudus/tableaux/arguments.scala index 2d0646fe..e3dc4a38 100644 --- a/src/main/scala/com/campudus/tableaux/arguments.scala +++ b/src/main/scala/com/campudus/tableaux/arguments.scala @@ -109,27 +109,6 @@ object ArgumentChecker { } } - def isDefined(options: Seq[Option[_]], trys: Seq[Try[Option[_]]], name: String): ArgumentCheck[Unit] = { - val empty = !options.exists(_.isDefined) - val noneHaveBeenDefined = trys.forall(_.isFailure) - - if (empty && noneHaveBeenDefined) { - FailArg(InvalidRequestException(s"None of these options has a (valid) value. ($name)")) - } else { - OkArg(()) - } - - } - - def nullableValuesAreDefined(trys: Seq[Try[Option[_]]], name: String = ""): ArgumentCheck[Unit] = { - val allHaveBeenSupplied = trys.forall(_.isSuccess) - if (allHaveBeenSupplied) { - FailArg(InvalidRequestException(s"None of these options has a (valid) value. ($name)")) - } else { - OkArg(()) - } - } - def oneOf[A](x: => A, list: List[A], name: String): ArgumentCheck[A] = { if (list.contains(x)) { OkArg(x) diff --git a/src/main/scala/com/campudus/tableaux/controller/StructureController.scala b/src/main/scala/com/campudus/tableaux/controller/StructureController.scala index 4ec4a2e7..cac2502f 100644 --- a/src/main/scala/com/campudus/tableaux/controller/StructureController.scala +++ b/src/main/scala/com/campudus/tableaux/controller/StructureController.scala @@ -474,20 +474,16 @@ class StructureController( attributes, rules, hidden, - showMemberColumns + maxLength, + minLength, + showMemberColumns, + decimalDigits ), - Seq(maxLengthTry, minLengthTry), - "name, ordering, kind, identifier, displayInfos, countryCodes, separator, attributes, rules, hidden, maxLength, minLength, showMemberColumns" + "name, ordering, kind, identifier, displayInfos, countryCodes, separator, attributes, " + + "rules, hidden, maxLength, minLength, showMemberColumns, decimalDigits" ) ) - val maxLength = maxLengthTry match { - case Failure(exception) => None - case Success(opt) => opt - } - val minLength = minLengthTry match { - case Failure(exception) => None - case Success(opt) => opt - } + val structureProperties: Seq[Option[Any]] = Seq(columnName, ordering, kind, identifier, countryCodes) val isAtLeastOneStructureProperty: Boolean = structureProperties.exists(_.isDefined) @@ -514,7 +510,8 @@ class StructureController( hidden, maxLength, minLength, - showMemberColumns + showMemberColumns, + decimalDigits ) for { diff --git a/src/main/scala/com/campudus/tableaux/helper/JsonUtils.scala b/src/main/scala/com/campudus/tableaux/helper/JsonUtils.scala index 38589d3f..02a0a986 100644 --- a/src/main/scala/com/campudus/tableaux/helper/JsonUtils.scala +++ b/src/main/scala/com/campudus/tableaux/helper/JsonUtils.scala @@ -323,11 +323,11 @@ object JsonUtils extends LazyLogging { } yield valueList } - private def getNullableJsonIntegerValue(key: String, json: JsonObject): Try[Option[Int]] = { + private def getNullableJsonIntegerValue(key: String, json: JsonObject): Try[Int] = { Try({ json.containsKey(key) match { case false => throw new KeyNotFoundInJsonException(key) - case true => Option(json.getInteger(key)).map(_.toInt) + case true => json.getInteger(key) } }) } @@ -343,9 +343,10 @@ object JsonUtils extends LazyLogging { Option[JsonObject], Option[JsonArray], Option[Boolean], - Try[Option[Int]], - Try[Option[Int]], - Option[Boolean] + Option[Int], + Option[Int], + Option[Boolean], + Option[Int] ) = { val name = Try(notNull(json.getString("name"), "name").get).toOption @@ -378,8 +379,9 @@ object JsonUtils extends LazyLogging { } ).map(_.asScala.toSeq.map({ case code: String => code })) - val maxLength = getNullableJsonIntegerValue("maxLength", json) - val minLength = getNullableJsonIntegerValue("minLength", json) + val maxLength = getNullableJsonIntegerValue("maxLength", json).toOption + val minLength = getNullableJsonIntegerValue("minLength", json).toOption + val decimalDigits = getNullableJsonIntegerValue("decimalDigits", json).toOption ( name, @@ -394,7 +396,8 @@ object JsonUtils extends LazyLogging { hidden, maxLength, minLength, - showMemberColumns + showMemberColumns, + decimalDigits ) }