Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ontology): Don't accept list values without gui attribute (DEV-775)…
… (#2089) * add test data * fix bug and add test * add missing import * fix typo in test data * add checks for all gui elements that need a gui attribute * update freetest data * fix typo in test data * check more values * add tests * remove prints * wip * remove featureFactoryConfig from new tests * refactor schema domain * remove make() from option * bump zio prelude version * rename decision file * rename file * add value objects * move salsah-gui constants to shared project * rename SalsahGuiApiV2WithValueObjects * improve value objects * improve validation * use val instead of string * small improvements * add more tests * improve docs * add r2r test * update expected client test data * Update expected-client-test-data.txt * Update expected-client-test-data.txt * make unit tests more readable * add new error type for validation fails * improve error messages
- Loading branch information
irinaschubert
committed
Jul 18, 2022
1 parent
c39b3d3
commit 74a14e1
Showing
28 changed files
with
1,273 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
dsp-shared/src/main/scala/dsp/constants/SalsahGui.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package dsp.constants | ||
|
||
import dsp.errors._ | ||
|
||
/** | ||
* Contains string constants for IRIs from ontologies used by the application. | ||
*/ | ||
object SalsahGui { | ||
|
||
/** | ||
* `IRI` is a synonym for `String`, used to improve code readability. | ||
*/ | ||
type IRI = String | ||
|
||
val InternalOntologyStart = "http://www.knora.org/ontology" | ||
|
||
val SalsahGuiOntologyLabel: String = "salsah-gui" | ||
val SalsahGuiOntologyIri: IRI = InternalOntologyStart + "/" + SalsahGuiOntologyLabel | ||
val SalsahGuiPrefixExpansion: IRI = SalsahGuiOntologyIri + "#" | ||
|
||
val GuiAttribute: IRI = SalsahGuiPrefixExpansion + "guiAttribute" | ||
val GuiAttributeDefinition: IRI = SalsahGuiPrefixExpansion + "guiAttributeDefinition" | ||
val GuiOrder: IRI = SalsahGuiPrefixExpansion + "guiOrder" | ||
val GuiElementProp: IRI = SalsahGuiPrefixExpansion + "guiElement" | ||
val GuiElementClass: IRI = SalsahGuiPrefixExpansion + "Guielement" | ||
|
||
val SimpleText: IRI = SalsahGuiPrefixExpansion + "SimpleText" | ||
val Textarea: IRI = SalsahGuiPrefixExpansion + "Textarea" | ||
val Pulldown: IRI = SalsahGuiPrefixExpansion + "Pulldown" | ||
val Slider: IRI = SalsahGuiPrefixExpansion + "Slider" | ||
val Spinbox: IRI = SalsahGuiPrefixExpansion + "Spinbox" | ||
val Searchbox: IRI = SalsahGuiPrefixExpansion + "Searchbox" | ||
val Date: IRI = SalsahGuiPrefixExpansion + "Date" | ||
val Geometry: IRI = SalsahGuiPrefixExpansion + "Geometry" | ||
val Colorpicker: IRI = SalsahGuiPrefixExpansion + "Colorpicker" | ||
val List: IRI = SalsahGuiPrefixExpansion + "List" | ||
val Radio: IRI = SalsahGuiPrefixExpansion + "Radio" | ||
val Checkbox: IRI = SalsahGuiPrefixExpansion + "Checkbox" | ||
val Richtext: IRI = SalsahGuiPrefixExpansion + "Richtext" | ||
val Interval: IRI = SalsahGuiPrefixExpansion + "Interval" | ||
val TimeStamp: IRI = SalsahGuiPrefixExpansion + "TimeStamp" | ||
val Geonames: IRI = SalsahGuiPrefixExpansion + "Geonames" | ||
val Fileupload: IRI = SalsahGuiPrefixExpansion + "Fileupload" | ||
|
||
val GuiElements = scala.collection.immutable.List( | ||
SimpleText, | ||
Textarea, | ||
Pulldown, | ||
Slider, | ||
Spinbox, | ||
Searchbox, | ||
Date, | ||
Geometry, | ||
Colorpicker, | ||
List, | ||
Radio, | ||
Checkbox, | ||
Richtext, | ||
Interval, | ||
TimeStamp, | ||
Geonames, | ||
Fileupload | ||
) | ||
|
||
val GuiAttributes = scala.collection.immutable.List( | ||
"ncolors", | ||
"hlist", | ||
"numprops", | ||
"size", | ||
"maxlength", | ||
"min", | ||
"max", | ||
"cols", | ||
"rows", | ||
"width", | ||
"wrap" | ||
) | ||
|
||
object SalsahGuiAttributeType extends Enumeration { | ||
|
||
val Integer: Value = Value(0, "integer") | ||
val Percent: Value = Value(1, "percent") | ||
val Decimal: Value = Value(2, "decimal") | ||
val Str: Value = Value(3, "string") | ||
val Iri: Value = Value(4, "iri") | ||
|
||
val valueMap: Map[String, Value] = values.map(v => (v.toString, v)).toMap | ||
|
||
def lookup(name: String): Value = | ||
valueMap.get(name) match { | ||
case Some(value) => value | ||
case None => throw InconsistentRepositoryDataException(s"salsah-gui attribute type not found: $name") | ||
} | ||
} | ||
|
||
object External { | ||
// external representation of salsah-gui entities of the form: http://api.knora.org/ontology/salsah-gui/v2#... | ||
val ApiOntologyHostname: String = "http://api.knora.org" | ||
val ApiOntologyStart: String = ApiOntologyHostname + "/ontology/" | ||
val VersionSegment = "/v2" | ||
val SalsahGuiOntologyIri: IRI = ApiOntologyStart + SalsahGui.SalsahGuiOntologyLabel + VersionSegment | ||
val SalsahGuiPrefixExpansion: IRI = SalsahGuiOntologyIri + "#" | ||
|
||
val GuiAttribute: IRI = SalsahGuiPrefixExpansion + "guiAttribute" | ||
val GuiOrder: IRI = SalsahGuiPrefixExpansion + "guiOrder" | ||
val GuiElementProp: IRI = SalsahGuiPrefixExpansion + "guiElement" | ||
val GuiAttributeDefinition: IRI = SalsahGuiPrefixExpansion + "guiAttributeDefinition" | ||
val GuiElementClass: IRI = SalsahGuiPrefixExpansion + "Guielement" | ||
val Geometry: IRI = SalsahGuiPrefixExpansion + "Geometry" | ||
val Colorpicker: IRI = SalsahGuiPrefixExpansion + "Colorpicker" | ||
val Fileupload: IRI = SalsahGuiPrefixExpansion + "Fileupload" | ||
val Richtext: IRI = SalsahGuiPrefixExpansion + "Richtext" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.