package ca.corefacility.bioinformatics.irida.model;

import ca.corefacility.bioinformatics.irida.model.roles.impl.Audit;
import ca.corefacility.bioinformatics.irida.model.roles.impl.Identifier;
import ca.corefacility.bioinformatics.irida.model.roles.Auditable;
import ca.corefacility.bioinformatics.irida.model.roles.Identifiable;
import java.util.Objects;
import javax.validation.constraints.NotNull;
import org.springframework.security.core.GrantedAuthority;

/**
 * Roles for authorization in the application.
 *
 * @author Franklin Bristow <franklin.bristow@phac-aspc.gc.ca>
 */
public class Role implements Comparable<Role>, GrantedAuthority, Auditable<Audit>, Identifiable<Identifier> {

    private Identifier id;
    @NotNull
    private String name;
    @NotNull
    private String description;
    @NotNull
    private Audit audit;

    public Role() {
        audit = new Audit();
    }

    public Role(Identifier id) {
        this();
        this.id = id;
    }

    @Override
    public int compareTo(Role r) {
        return audit.compareTo(r.audit);
    }

    @Override
    public boolean equals(Object other) {
        if (other instanceof Role) {
            Role r = (Role) other;
            return Objects.equals(id, r.id)
                    && Objects.equals(name, r.name)
                    && Objects.equals(description, r.description);
        }

        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, description);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String getAuthority() {
        return name;
    }

    @Override
    public Audit getAuditInformation() {
        return audit;
    }

    @Override
    public Identifier getIdentifier() {
        return id;
    }

    @Override
    public void setIdentifier(Identifier identifier) {
        this.id = identifier;
    }

    @Override
    public void setAuditInformation(Audit audit) {
        this.audit = audit;
    }
}

@@ -106,18 +106,17 @@
 les.
-impl.
 Audit
+able
 ;%0Aim
@@ -173,21 +173,16 @@
 les.
-impl.
 Identifi
 er;%0A
@@ -177,18 +177,20 @@
 Identifi
+abl
 e
-r
 ;%0Aimport
@@ -235,33 +235,34 @@
 model.roles.
+impl.
 Audit
-able
 ;%0Aimport ca.
@@ -303,32 +303,37 @@
 model.roles.
+impl.
 Identifi
 able;%0Aimport
@@ -312,36 +312,34 @@
 es.impl.Identifi
-abl
 e
+r
 ;%0Aimport java.ut
@@ -335,26 +335,60 @@
 ort 
-java.util.Objects;
+org.springframework.security.core.GrantedAuthority;%0A
 %0Aimp
@@ -440,58 +440,25 @@
 ort 
-org.springframework.security.core.GrantedAuthority
+java.util.Objects
 ;%0A%0A/
@@ -963,32 +963,112 @@
 id = id;%0A    %7D%0A%0A
+    public Role(String name) %7B%0A        this();%0A        this.name = name;%0A    %7D%0A%0A
     @Override%0A  
@@ -2035,32 +2035,132 @@
 n audit;%0A    %7D%0A%0A
+    @Override%0A    public void setAuditInformation(Audit audit) %7B%0A        this.audit = audit;%0A    %7D%0A%0A
     @Override%0A  
@@ -2331,107 +2331,7 @@
    %7D
-%0A%0A    @Override%0A    public void setAuditInformation(Audit audit) %7B%0A        this.audit = audit;%0A    %7D
 %0A%7D%0A

Add constructor for Role to allow specifying the name of the role.