com.salesmanager.core.model.user.Group Maven / Gradle / Ivy
package com.salesmanager.core.model.user;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.validation.constraints.NotEmpty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.salesmanager.core.constants.SchemaConstant;
import com.salesmanager.core.model.common.audit.AuditListener;
import com.salesmanager.core.model.common.audit.AuditSection;
import com.salesmanager.core.model.common.audit.Auditable;
import com.salesmanager.core.model.generic.SalesManagerEntity;
@Entity
@EntityListeners(value = AuditListener.class)
@Table(name = "SM_GROUP", schema = SchemaConstant.SALESMANAGER_SCHEMA, indexes = {
@Index(name = "SM_GROUP_GROUP_TYPE", columnList = "GROUP_TYPE") })
public class Group extends SalesManagerEntity implements Auditable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(name = "GROUP_ID", unique = true, nullable = false)
@TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "GROUP_SEQ_NEXT_VAL")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
private Integer id;
public Group() {
}
@Column(name = "GROUP_TYPE")
@Enumerated(value = EnumType.STRING)
private GroupType groupType;
@NotEmpty
@Column(name = "GROUP_NAME", unique = true)
private String groupName;
public Group(String groupName) {
this.groupName = groupName;
}
@JsonIgnore
@ManyToMany(mappedBy = "groups") // TODO LAZY LOAD
private Set permissions = new HashSet();
public Set getPermissions() {
return permissions;
}
public void setPermissions(Set permissions) {
this.permissions = permissions;
}
@Embedded
private AuditSection auditSection = new AuditSection();
@Override
public AuditSection getAuditSection() {
return this.auditSection;
}
@Override
public void setAuditSection(AuditSection audit) {
this.auditSection = audit;
}
@Override
public Integer getId() {
return this.id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public void setGroupType(GroupType groupType) {
this.groupType = groupType;
}
public GroupType getGroupType() {
return groupType;
}
}