Dataobjects för schematemplates + en liten metod i User för att få en Label med en fin ikon framför
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@327 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
3a394e306e
commit
280c5ea522
src/main/java/se/su/dsv/scipro/data/dataobjects
@ -0,0 +1,144 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy=InheritanceType.JOINED)
|
||||
@Table(name="event_template")
|
||||
public abstract class EventTemplate extends DomainObject implements Comparable<EventTemplate> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(nullable=false)
|
||||
private String title;
|
||||
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
/*
|
||||
* Always the same as the scheduleTemplates create
|
||||
*/
|
||||
@ManyToOne
|
||||
private User templateCreator;
|
||||
|
||||
@ManyToOne
|
||||
private ScheduleTemplate scheduleTemplate;
|
||||
|
||||
@Column(nullable=false)
|
||||
private long estimatedTimeConsumption = 0;
|
||||
|
||||
@Column(nullable=false)
|
||||
private int numberInOrder = Integer.MAX_VALUE;
|
||||
|
||||
public EventTemplate(){}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public User getTemplateCreator() {
|
||||
return templateCreator;
|
||||
}
|
||||
|
||||
public void setTemplateCreator(User templateCreator) {
|
||||
this.templateCreator = templateCreator;
|
||||
}
|
||||
|
||||
public long getEstimatedTimeConsumption() {
|
||||
return estimatedTimeConsumption;
|
||||
}
|
||||
|
||||
public void setEstimatedTimeConsumption(long estimatedTimeConsumption) {
|
||||
this.estimatedTimeConsumption = estimatedTimeConsumption;
|
||||
}
|
||||
|
||||
public int getNumberInOrder() {
|
||||
return numberInOrder;
|
||||
}
|
||||
|
||||
public void setNumberInOrder(int numberInOrder) {
|
||||
this.numberInOrder = numberInOrder;
|
||||
}
|
||||
|
||||
public void setScheduleTemplate(ScheduleTemplate scheduleTemplate) {
|
||||
this.scheduleTemplate = scheduleTemplate;
|
||||
}
|
||||
|
||||
public ScheduleTemplate getScheduleTemplate() {
|
||||
return scheduleTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
EventTemplate other = (EventTemplate) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "id: " + getId() + " Name: " + getTitle() + " Creatorid: " + getTemplateCreator().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EventTemplate other){
|
||||
return numberInOrder - other.numberInOrder;
|
||||
}
|
||||
|
||||
public abstract Event createEventFromTemplate();
|
||||
}
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="group_event_template")
|
||||
public class GroupEventTemplate extends EventTemplate {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public GroupEvent createEventFromTemplate() {
|
||||
GroupEvent event = new GroupEvent();
|
||||
event.setDescription(getDescription());
|
||||
event.setTitle(getTitle());
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="project_event_template")
|
||||
public class ProjectEventTemplate extends EventTemplate {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean done = false;
|
||||
|
||||
@Override
|
||||
public ProjectEvent createEventFromTemplate() {
|
||||
ProjectEvent event = new ProjectEvent();
|
||||
event.setDone(done);
|
||||
event.setTitle(getTitle());
|
||||
event.setDescription(getDescription());
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.PreRemove;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name="schedule_template")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public class ScheduleTemplate extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
/*
|
||||
* Using composition for ScheduleTemplate -> EventTemplate
|
||||
*/
|
||||
@OneToMany(mappedBy="scheduleTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
|
||||
private List<EventTemplate> eventTemplates = new ArrayList<EventTemplate>();
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private User creator;
|
||||
|
||||
@ManyToOne(optional=true)
|
||||
private ProjectClass projectClass;
|
||||
|
||||
@Column(nullable=false)
|
||||
private String templateName;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Boolean active = false;
|
||||
|
||||
@Lob
|
||||
private String templateDescription;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Boolean isSysAdminTemplate = false;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<EventTemplate> getEventTemplates() {
|
||||
Collections.sort(eventTemplates);
|
||||
return eventTemplates;
|
||||
}
|
||||
|
||||
public void setEventTemplates(List<EventTemplate> eventTemplates) {
|
||||
Collections.sort(eventTemplates);
|
||||
this.eventTemplates = eventTemplates;
|
||||
}
|
||||
|
||||
public User getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(User creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public ProjectClass getProjectClass() {
|
||||
return projectClass;
|
||||
}
|
||||
|
||||
public void setProjectClass(ProjectClass projectClass) {
|
||||
this.projectClass = projectClass;
|
||||
}
|
||||
|
||||
public String getTemplateName() {
|
||||
return templateName;
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName) {
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
public String getTemplateDescription() {
|
||||
return templateDescription;
|
||||
}
|
||||
|
||||
public void setTemplateDescription(String templateDescription) {
|
||||
this.templateDescription = templateDescription;
|
||||
}
|
||||
|
||||
public void setSysAdminTemplate(boolean isSysAdminTemplate) {
|
||||
this.isSysAdminTemplate = isSysAdminTemplate;
|
||||
}
|
||||
|
||||
public boolean isSysAdminTemplate() {
|
||||
return isSysAdminTemplate;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void addEventTemplate(EventTemplate e){
|
||||
e.setScheduleTemplate(this);
|
||||
eventTemplates.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
ScheduleTemplate other = (ScheduleTemplate) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "id: " + getId() + " Name: " + getTemplateName() + "||";
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
@ -13,6 +11,9 @@ import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.wicket.behavior.AttributeAppender;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@ -162,5 +163,11 @@ public class User extends LazyDeletableDomainObject implements Comparable<User>
|
||||
|
||||
return id.intValue() - other.id.intValue();
|
||||
}
|
||||
|
||||
public Label getWebLabel(String id){
|
||||
Label l = new Label(id, new Model<String>(firstName + " " + lastName));
|
||||
l.add(new AttributeAppender("class", new Model<String>("icon icon-user"), " "));
|
||||
return l;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user