forked from blcham/record-manager
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kbss-cvut/record-manager-ui#202] Refactor Permission and Role to Rol…
…e and RoleGroup
- Loading branch information
Showing
5 changed files
with
163 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package cz.cvut.kbss.study.model; | ||
|
||
import cz.cvut.kbss.jopa.model.annotations.Individual; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum Role { | ||
|
||
@Individual(iri=Vocabulary.s_i_administrator) | ||
administrator(Vocabulary.s_i_administrator), | ||
|
||
@Individual(iri = Vocabulary.s_i_user) | ||
user(Vocabulary.s_i_user), | ||
|
||
@Individual(iri = Vocabulary.s_i_delete_all_records_role) | ||
deleteAllRecords(Vocabulary.s_i_delete_all_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_view_all_records_role) | ||
viewAllRecords(Vocabulary.s_i_view_all_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_edit_all_records_role) | ||
editAllRecords(Vocabulary.s_i_edit_all_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_delete_organization_records_role) | ||
deleteOrganizationRecords(Vocabulary.s_i_delete_organization_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_view_organization_records_role) | ||
viewOrganizationRecords(Vocabulary.s_i_view_organization_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_edit_organization_records_role) | ||
editOrganizationRecords(Vocabulary.s_i_edit_organization_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_edit_users_role) | ||
editUsers(Vocabulary.s_i_edit_users_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_complete_records_role) | ||
completeRecords(Vocabulary.s_i_complete_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_reject_records_role) | ||
rejectRecords(Vocabulary.s_i_reject_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_publish_records_role) | ||
publishRecords(Vocabulary.s_i_publish_records_role), | ||
|
||
@Individual(iri = Vocabulary.s_i_import_codelists_role) | ||
importCodelists(Vocabulary.s_i_import_codelists_role); | ||
|
||
private final String iri; | ||
|
||
Role(String iri) { | ||
this.iri = iri; | ||
} | ||
|
||
/** | ||
* Returns {@link Role} with the specified IRI. | ||
* | ||
* @param iri role identifier | ||
* @return matching {@code Role} | ||
* @throws IllegalArgumentException When no matching role is found | ||
*/ | ||
public static Role fromIri(String iri) { | ||
for (Role r : values()) { | ||
if (r.getIri().equals(iri)) { | ||
return r; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unknown role identifier '" + iri + "'."); | ||
} | ||
|
||
/** | ||
* Returns {@link Role} with the specified constant name. | ||
* | ||
* @param name role name | ||
* @return matching {@code Role} | ||
* @throws IllegalArgumentException When no matching role is found | ||
*/ | ||
public static Role fromName(String name) { | ||
for (Role r : values()) { | ||
if (r.name().equalsIgnoreCase(name)) { | ||
return r; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unknown role '" + name + "'."); | ||
} | ||
|
||
/** | ||
* Returns a {@link Role} with the specified IRI or constant name. | ||
* <p> | ||
* This function first tries to find the enum constant by IRI. If it is not found, constant name matching is | ||
* attempted. | ||
* | ||
* @param identification Constant IRI or name to find match by | ||
* @return matching {@code Role} | ||
* @throws IllegalArgumentException When no matching role is found | ||
*/ | ||
public static Role fromIriOrName(String identification) { | ||
try { | ||
return fromIri(identification); | ||
} catch (IllegalArgumentException e) { | ||
return fromName(identification); | ||
} | ||
} | ||
} |
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,46 @@ | ||
package cz.cvut.kbss.study.model; | ||
import cz.cvut.kbss.jopa.model.annotations.Id; | ||
import cz.cvut.kbss.jopa.model.annotations.OWLClass; | ||
import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty; | ||
import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty; | ||
|
||
import java.net.URI; | ||
import java.util.Set; | ||
|
||
@OWLClass(iri = Vocabulary.s_c_Person) | ||
public class RoleGroup { | ||
|
||
@Id | ||
private URI uri; | ||
|
||
@OWLDataProperty(iri = Vocabulary.s_p_roleGroupName) | ||
private String roleGroupName; | ||
|
||
@OWLObjectProperty(iri = Vocabulary.s_p_has_role) | ||
private Set<Role> roles; | ||
|
||
|
||
public URI getUri() { | ||
return uri; | ||
} | ||
|
||
public void setUri(URI uri) { | ||
this.uri = uri; | ||
} | ||
|
||
public String getRoleGroupName() { | ||
return roleGroupName; | ||
} | ||
|
||
public void setRoleGroupName(String roleGroupName) { | ||
this.roleGroupName = roleGroupName; | ||
} | ||
|
||
public Set<Role> getRoles() { | ||
return roles; | ||
} | ||
|
||
public void setRoles(Set<Role> roles) { | ||
this.roles = roles; | ||
} | ||
} |
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
43 changes: 0 additions & 43 deletions
43
src/main/java/cz/cvut/kbss/study/security/model/RoleGroup.java
This file was deleted.
Oops, something went wrong.
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