Created
November 1, 2011 15:15
-
-
Save theresajayne/1330759 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package uk.co.inbrand.model; | |
import java.io.Serializable; | |
import java.util.Collection; | |
import java.util.Date; | |
import java.util.Map; | |
import java.util.Set; | |
import javax.persistence.CascadeType; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.FetchType; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
import javax.persistence.Id; | |
import javax.persistence.JoinColumn; | |
import javax.persistence.JoinTable; | |
import javax.persistence.ManyToMany; | |
import javax.persistence.ManyToOne; | |
import javax.persistence.Table; | |
import javax.persistence.Temporal; | |
import javax.persistence.TemporalType; | |
import uk.co.inbrand.security.client.AssociableSecuredEntity; | |
import uk.co.inbrand.security.client.SecuredEntity; | |
import uk.co.inbrand.security.client.SecuredEntityTypeEnum; | |
import uk.co.inbrand.utilities.FieldManager; | |
@Entity | |
@Table (name="users") | |
public class Users implements AssociableSecuredEntity, Serializable{ | |
@Id | |
@GeneratedValue(strategy=GenerationType.AUTO) | |
@Column(name="user_id") | |
private int user_id; | |
@Column(name="user_name") | |
private String user_name; | |
@Column(name="user_password") | |
private String user_password; | |
@ManyToMany (fetch=FetchType.EAGER) | |
@JoinTable(name="user_roles",joinColumns = {@JoinColumn(name="user_id")},inverseJoinColumns = {@JoinColumn(name="id")}) | |
private Set<UserRoles> user_roles; | |
@ManyToOne(cascade = (CascadeType.PERSIST)) | |
private Organisation user_organisation; //Need to link to the organisation entity when declared | |
@ManyToOne(cascade = (CascadeType.PERSIST)) | |
private Users user_responsible; //Also need to be linked | |
@Column(name="user_firstname") | |
private String user_firstname; | |
@Column(name="user_lastname") | |
private String user_lastname; | |
@ManyToOne(cascade = (CascadeType.PERSIST)) | |
private Licences user_licence; //Again link to the entity | |
@Column(name="user_loggedin") | |
private Boolean user_loggedin; | |
@Column(name="user_lastlogged") | |
@Temporal(TemporalType.DATE) | |
private Date user_lastlogged; | |
@ManyToOne(cascade = (CascadeType.ALL)) | |
private Address user_address; //Link | |
@Column(name="user_fields") | |
private String user_fields; //This is the way we allow extra fields to be added to a user | |
public int getUser_id() { | |
return user_id; | |
} | |
public void setUser_id(int userId) { | |
user_id = userId; | |
} | |
public String getUser_name() { | |
return user_name; | |
} | |
public void setUser_name(String userName) { | |
user_name = userName; | |
} | |
public String getUser_password() { | |
return user_password; | |
} | |
public void setUser_password(String userPassword) { | |
user_password = userPassword; | |
} | |
public Organisation getUser_organisation() { | |
return user_organisation; | |
} | |
public void setUser_organisation(Organisation userOrganisation) { | |
user_organisation = userOrganisation; | |
} | |
public Users getUser_responsible() { | |
return user_responsible; | |
} | |
public void setUser_responsible(Users userResponsible) { | |
user_responsible = userResponsible; | |
} | |
public String getUser_firstname() { | |
return user_firstname; | |
} | |
public void setUser_firstname(String userFirstname) { | |
user_firstname = userFirstname; | |
} | |
public String getUser_lastname() { | |
return user_lastname; | |
} | |
public void setUser_lastname(String userLastname) { | |
user_lastname = userLastname; | |
} | |
public Licences getUser_licence() { | |
return user_licence; | |
} | |
public void setUser_licence(Licences userLicence) { | |
user_licence = userLicence; | |
} | |
public Boolean getUser_loggedin() { | |
return user_loggedin; | |
} | |
public void setUser_loggedin(Boolean userLoggedin) { | |
user_loggedin = userLoggedin; | |
} | |
public Date getUser_lastlogged() { | |
return user_lastlogged; | |
} | |
public void setUser_lastlogged(Date userLastlogged) { | |
user_lastlogged = userLastlogged; | |
} | |
public Address getUser_address() { | |
return user_address; | |
} | |
public void setUser_address(Address userAddress) { | |
user_address = userAddress; | |
} | |
public String getUser_fields() { | |
return user_fields; | |
} | |
public void setUser_fields(String userFields) { | |
user_fields = userFields; | |
} | |
//These 2 need to en/de crypt the userfield into a map for easy access to the XML stored in the text field | |
public Map<String, String> getUser_field_map() { | |
return FieldManager.getExtractedData(user_fields); | |
} | |
public void setUser_field_map(Map<String, String> userFieldMap) { | |
user_fields = FieldManager.getEncryptedData(userFieldMap); | |
} | |
@Override | |
public Collection<SecuredEntity> getAssociatedSecuredEntities() { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public Collection<SecuredEntity> getAssociatedSecuredEntities(SecuredEntityTypeEnum securedEntityType) { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public boolean isFullyPopulated() { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public void setFullyPopulated(boolean fullyPopulated) { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public Integer getSecuredEntityId() { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public Integer getParentOrganisationId() { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public Integer getOwningOrganisationId() { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
@Override | |
public SecuredEntityTypeEnum getSecuredEntityType() { | |
throw new UnsupportedOperationException("Not supported yet."); | |
} | |
/** | |
* @return the user_roles | |
*/ | |
public Set<UserRoles> getUser_roles() { | |
return user_roles; | |
} | |
/** | |
* @param user_roles the user_roles to set | |
*/ | |
public void setUser_roles(Set<UserRoles> user_roles) { | |
this.user_roles = user_roles; | |
} | |
} | |
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package uk.co.inbrand.model; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
import javax.persistence.Id; | |
import javax.persistence.Table; | |
/** | |
* | |
* @author Thersa Jayne Forster | |
*/ | |
@Entity | |
@Table(name="userroles") | |
public class UserRoles { | |
@Id | |
@GeneratedValue(strategy=GenerationType.AUTO) | |
@Column(name="id") | |
private int id; | |
@Column(name="description") | |
private String description; | |
@Column(name="role_code") | |
private String role_code; | |
@Column(name="role_value") | |
private int role_value; | |
/** | |
* @return the id | |
*/ | |
public int getId() { | |
return id; | |
} | |
/** | |
* @param id the id to set | |
*/ | |
public void setId(int id) { | |
this.id = id; | |
} | |
/** | |
* @return the description | |
*/ | |
public String getDescription() { | |
return description; | |
} | |
/** | |
* @param description the description to set | |
*/ | |
public void setDescription(String description) { | |
this.description = description; | |
} | |
/** | |
* @return the role_code | |
*/ | |
public String getRole_code() { | |
return role_code; | |
} | |
/** | |
* @param role_code the role_code to set | |
*/ | |
public void setRole_code(String role_code) { | |
this.role_code = role_code; | |
} | |
/** | |
* @return the role_value | |
*/ | |
public int getRole_value() { | |
return role_value; | |
} | |
/** | |
* @param role_value the role_value to set | |
*/ | |
public void setRole_value(int role_value) { | |
this.role_value = role_value; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment