Skip to content
Permalink
Browse files
refactor(groups): refactor groups route using value objects (DEV-66) (#…
…1913)

* refactor: add comments + move projects file in right place

* feat: add groups payloads and value objects

* update responder, messages, sparql and tests

* fix: sparql, responder + tests

* refactor: move valueObjects to proper package

* refactor: reduce valuObject package usage

* refactor: fix description name

* fixes

* test: update test data + docs

* cleanup

* build fix
  • Loading branch information
mpro7 committed Oct 7, 2021
1 parent 8875ffe commit 1cd98e638ca788b2ce93c3fa5b15be6f528ed19a
Showing with 381 additions and 257 deletions.
  1. +1 −1 docs/03-apis/api-admin/groups.md
  2. +3 −3 knora-ontologies/knora-admin.ttl
  3. +2 −2 test_data/all_data/admin-data.ttl
  4. +4 −4 test_data/other.v1.DrawingsGodsV1Spec/drawings-gods_admin-data.ttl
  5. +6 −6 test_data/other.v2.LumieresLausanneV2E2ESpec/lumieres-lausanne_admin.ttl
  6. +1 −1 webapi/src/main/scala/org/knora/webapi/messages/OntologyConstants.scala
  7. +1 −1 webapi/src/main/scala/org/knora/webapi/messages/StringFormatter.scala
  8. +45 −39 ...i/src/main/scala/org/knora/webapi/messages/admin/responder/groupsmessages/GroupsMessagesADM.scala
  9. +38 −0 ...i/src/main/scala/org/knora/webapi/messages/admin/responder/groupsmessages/GroupsPayloadsADM.scala
  10. +13 −1 ...knora/webapi/messages/admin/responder/{usersmessages → projectsmessages}/ProjectPayloadsADM.scala
  11. +1 −1 ...c/main/scala/org/knora/webapi/messages/admin/responder/projectsmessages/ProjectsMessagesADM.scala
  12. +10 −0 webapi/src/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/UserPayloadsADM.scala
  13. +10 −0 webapi/src/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADM.scala
  14. +58 −56 ...la/org/knora/webapi/messages/admin/responder/{usersmessages → valueObjects}/ValueObjectsADM.scala
  15. +41 −39 webapi/src/main/scala/org/knora/webapi/responders/admin/GroupsResponderADM.scala
  16. +0 −1 webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala
  17. +2 −2 webapi/src/main/scala/org/knora/webapi/responders/admin/UsersResponderADM.scala
  18. +14 −2 webapi/src/main/scala/org/knora/webapi/routing/admin/GroupsRouteADM.scala
  19. +2 −5 webapi/src/main/scala/org/knora/webapi/routing/admin/ProjectsRouteADM.scala
  20. +10 −0 webapi/src/main/scala/org/knora/webapi/routing/admin/UsersRouteADM.scala
  21. +1 −1 webapi/src/main/scala/org/knora/webapi/routing/admin/lists/NewListsRouteADMFeature.scala
  22. +1 −1 webapi/src/main/scala/org/knora/webapi/routing/admin/lists/OldListsRouteADMFeature.scala
  23. +16 −9 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewGroup.scala.txt
  24. +22 −15 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateGroup.scala.txt
  25. +9 −8 webapi/src/test/scala/org/knora/webapi/e2e/admin/GroupsADME2ESpec.scala
  26. +2 −1 ...c/test/scala/org/knora/webapi/messages/admin/responder/groupsmessages/GroupsMessagesADMSpec.scala
  27. +1 −1 ...i/src/test/scala/org/knora/webapi/messages/admin/responder/valueObjects/ValueObjectsADMSpec.scala
  28. +48 −43 webapi/src/test/scala/org/knora/webapi/responders/admin/GroupsResponderADMSpec.scala
  29. +4 −8 webapi/src/test/scala/org/knora/webapi/responders/admin/ProjectsResponderADMSpec.scala
  30. +11 −2 webapi/src/test/scala/org/knora/webapi/responders/admin/UsersResponderADMSpec.scala
  31. +4 −4 webapi/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala
@@ -117,7 +117,7 @@ Example Group Information stored in admin named graph: :
<http://rdfh.ch/groups/[shortcode]/[UUID]>
rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Name of the group" ;
knora-admin:groupDescription "A description of the group" ;
knora-admin:groupDescriptions "A description of the group" ;
knora-admin:belongsToProject <http://rdfh.ch/projects/[UUID]> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .
@@ -165,9 +165,9 @@



### http://www.knora.org/ontology/knora-admin#groupDescription
### http://www.knora.org/ontology/knora-admin#groupDescriptions

:groupDescription rdf:type owl:DatatypeProperty ;
:groupDescriptions rdf:type owl:DatatypeProperty ;

rdfs:subPropertyOf knora-base:objectCannotBeMarkedAsDeleted ;

@@ -568,7 +568,7 @@
owl:cardinality "1"^^xsd:nonNegativeInteger
] ,
[ rdf:type owl:Restriction ;
owl:onProperty :groupDescription ;
owl:onProperty :groupDescriptions ;
owl:maxCardinality "1"^^xsd:nonNegativeInteger
] ,
[ rdf:type owl:Restriction ;
@@ -204,7 +204,7 @@

knora-admin:groupName "Image reviewer"^^xsd:string ;

knora-admin:groupDescription "A group for image reviewers."^^xsd:string ;
knora-admin:groupDescriptions "A group for image reviewers."^^xsd:string ;

knora-admin:belongsToProject <http://rdfh.ch/projects/00FF> ;

@@ -433,7 +433,7 @@ Die Internetpublikation macht das digitalisierte Korpus dieser Frühdrucke durc

<http://rdfh.ch/groups/0001/thing-searcher> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Thing searcher"^^xsd:string ;
knora-admin:groupDescription "A group for thing searchers."^^xsd:string ;
knora-admin:groupDescriptions "A group for thing searchers."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0001> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "true"^^xsd:boolean .
@@ -20,28 +20,28 @@

<http://rdfh.ch/groups/0105/drawings-gods-meta-annotators> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Meta-annotators"^^xsd:string ;
knora-admin:groupDescription "A group of users allowed to annotate data. Does not upload images nor files. Does not access to personal data."^^xsd:string ;
knora-admin:groupDescriptions "A group of users allowed to annotate data. Does not upload images nor files. Does not access to personal data."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0105> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0105/drawings-gods-add-drawings> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Drawings contributors"^^xsd:string ;
knora-admin:groupDescription "A group of users allowed to upload images, files and annotate data. Does not access to personal data."^^xsd:string ;
knora-admin:groupDescriptions "A group of users allowed to upload images, files and annotate data. Does not access to personal data."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0105> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0105/drawings-gods-snf-team> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "SNF team"^^xsd:string ;
knora-admin:groupDescription "A core group of members from the SNF project. Access to any data, including sensitive."^^xsd:string ;
knora-admin:groupDescriptions "A core group of members from the SNF project. Access to any data, including sensitive."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0105> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0105/drawings-gods-admin> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Administrators"^^xsd:string ;
knora-admin:groupDescription "A custom admin group created to apply permission precedence rules. Replaces the built-in knora-admin:ProjectAdmin group, not used for this project."^^xsd:string ;
knora-admin:groupDescriptions "A custom admin group created to apply permission precedence rules. Replaces the built-in knora-admin:ProjectAdmin group, not used for this project."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0105> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .
@@ -25,42 +25,42 @@

<http://rdfh.ch/groups/0113/lumieres-lausanne-user> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Utilisateur"^^xsd:string ;
knora-admin:groupDescription """Statut permanent. Attribué à toute personne désireuse de s'enregistrer. N'est membre d'aucun autre groupe (étudiant, chercheur). Par rapport au visiteur anonyme sans login, accès supplémentaire à la gestion des collections, aux transcriptions/documents joints/projets slmt si autorisation."""^^xsd:string ;
knora-admin:groupDescriptions """Statut permanent. Attribué à toute personne désireuse de s'enregistrer. N'est membre d'aucun autre groupe (étudiant, chercheur). Par rapport au visiteur anonyme sans login, accès supplémentaire à la gestion des collections, aux transcriptions/documents joints/projets slmt si autorisation."""^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0113> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0113/lumieres-lausanne-student> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Etudiant"^^xsd:string ;
knora-admin:groupDescription """Statut temporaire. Uniquement les étudiants UNIL liés à un séminaire donné dans le cadre du projet Lumières.Lausanne. Ont reçu les consignes ainsi qu'une initiation (obligatoire). A la fin du séminaire, leur statut est changé en statut "Utilisateur", sauf demande particulière."""^^xsd:string ;
knora-admin:groupDescriptions """Statut temporaire. Uniquement les étudiants UNIL liés à un séminaire donné dans le cadre du projet Lumières.Lausanne. Ont reçu les consignes ainsi qu'une initiation (obligatoire). A la fin du séminaire, leur statut est changé en statut "Utilisateur", sauf demande particulière."""^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0113> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0113/lumieres-lausanne-researcher> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Chercheur"^^xsd:string ;
knora-admin:groupDescription "Statut permanent. Doctorants, professeurs, autres chercheurs qui ont reçu préalablement l'autorisation d'un directeur. Ont reçu les consignes (obligatoire), et si possible une initiation."^^xsd:string ;
knora-admin:groupDescriptions "Statut permanent. Doctorants, professeurs, autres chercheurs qui ont reçu préalablement l'autorisation d'un directeur. Ont reçu les consignes (obligatoire), et si possible une initiation."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0113> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0113/lumieres-lausanne-phdstudent> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Doctorant"^^xsd:string ;
knora-admin:groupDescription "Statut temporaire. Doctorants et étudiants-assistants directement liés au Projet Lumières.Lausanne. Ont reçu les consignes ainsi qu'une initiation (obligatoire). Une fois leur mandat terminé, passent en statut Chercheur."^^xsd:string ;
knora-admin:groupDescriptions "Statut temporaire. Doctorants et étudiants-assistants directement liés au Projet Lumières.Lausanne. Ont reçu les consignes ainsi qu'une initiation (obligatoire). Une fois leur mandat terminé, passent en statut Chercheur."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0113> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0113/lumieres-lausanne-director> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Directeur"^^xsd:string ;
knora-admin:groupDescription "Béla Kapossy, Béatrice Lovis."^^xsd:string ;
knora-admin:groupDescriptions "Béla Kapossy, Béatrice Lovis."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0113> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .

<http://rdfh.ch/groups/0113/lumieres-lausanne-administrator> rdf:type knora-admin:UserGroup ;
knora-admin:groupName "Administrateur"^^xsd:string ;
knora-admin:groupDescription "Béatrice Lovis."^^xsd:string ;
knora-admin:groupDescriptions "Béatrice Lovis."^^xsd:string ;
knora-admin:belongsToProject <http://rdfh.ch/projects/0113> ;
knora-admin:status "true"^^xsd:boolean ;
knora-admin:hasSelfJoinEnabled "false"^^xsd:boolean .
@@ -490,7 +490,7 @@ object OntologyConstants {
/* Group */
val UserGroup: IRI = KnoraAdminPrefixExpansion + "UserGroup"
val GroupName: IRI = KnoraAdminPrefixExpansion + "groupName"
val GroupDescription: IRI = KnoraAdminPrefixExpansion + "groupDescription"
val GroupDescriptions: IRI = KnoraAdminPrefixExpansion + "groupDescriptions"
val BelongsToProject: IRI = KnoraAdminPrefixExpansion + "belongsToProject"

/* Built-In Groups */
@@ -1673,7 +1673,7 @@ class StringFormatter private (
* IRI.
* @return the same optional string.
*/
def toOptionalIri(maybeString: Option[String], errorFun: => Nothing): Option[IRI] =
def validateAndEscapeOptionalIri(maybeString: Option[String], errorFun: => Nothing): Option[IRI] =
maybeString match {
case Some(s) => Some(validateAndEscapeIri(s, errorFun))
case None => None
Loading

0 comments on commit 1cd98e6

Please sign in to comment.