task/3382: Harmonisera tabellnamn #6
@ -6,6 +6,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Cacheable;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
@ -28,28 +29,38 @@ import se.su.dsv.scipro.system.User;
|
||||
@Cacheable(true)
|
||||
public class ActivityPlanTemplate extends DomainObject {
|
||||
|
||||
//<editor-fold desc="Basic JPA-mappings">
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Basic
|
||||
@Column(name = "is_sys_admin_template", nullable=false)
|
||||
private boolean isSysAdminTemplate = false;
|
||||
|
||||
@Basic
|
||||
@Column(nullable=false)
|
||||
private String title;
|
||||
|
||||
@Basic
|
||||
@Column(name = "description")
|
||||
@Lob
|
||||
private String description;
|
||||
//</editor-fold>
|
||||
|
||||
@OrderColumn(name = "number_in_order")
|
||||
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
|
||||
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
|
||||
|
||||
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan_template) referencing other tables.">
|
||||
@ManyToOne(optional=false)
|
||||
@JoinColumn(name = "user_id")
|
||||
tozh4728 marked this conversation as resolved
Outdated
|
||||
private User creator;
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="JPA-mappings of other tables referencing to this table 'activity_plan_template'">
|
||||
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
|
||||
@OrderColumn(name = "number_in_order")
|
||||
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Properties (Getters and Setters)">
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
@ -83,18 +94,12 @@ public class ActivityPlanTemplate extends DomainObject {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void addActivity(ActivityTemplate activity){
|
||||
activity.setActivityPlanTemplate(this);
|
||||
activity.setNumberInOrder(activityTemplates.size());
|
||||
activityTemplates.add(activity);
|
||||
public User getCreator() {
|
||||
return this.creator;
|
||||
}
|
||||
|
||||
public void clearActivities(){
|
||||
activityTemplates.clear();
|
||||
}
|
||||
|
||||
public void addActivities(final Collection<ActivityTemplate> activities){
|
||||
activityTemplates.addAll(activities);
|
||||
public void setCreator(User creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public List<ActivityTemplate> getActivityTemplates(){
|
||||
@ -104,15 +109,9 @@ public class ActivityPlanTemplate extends DomainObject {
|
||||
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
|
||||
this.activityTemplates = new ArrayList<>(activityTemplates);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
public User getCreator() {
|
||||
return this.creator;
|
||||
}
|
||||
|
||||
public void setCreator(User creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
//<editor-fold desc="Methods Common To All Objects">
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -139,6 +138,25 @@ public class ActivityPlanTemplate extends DomainObject {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActivityPlanTemplate(id=" + this.getId() + ", creator=" + this.getCreator() + ", title=" + this.getTitle() + ", description=" + this.getDescription() + ", isSysAdminTemplate=" + this.isSysAdminTemplate() + ")";
|
||||
return "ActivityPlanTemplate(id=" + this.getId() + ", creator=" + this.getCreator() +
|
||||
", title=" + this.getTitle() + ", description=" + this.getDescription() +
|
||||
", isSysAdminTemplate=" + this.isSysAdminTemplate() + ")";
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Other methods">
|
||||
public void addActivity(ActivityTemplate activity){
|
||||
activity.setActivityPlanTemplate(this);
|
||||
activity.setNumberInOrder(activityTemplates.size());
|
||||
activityTemplates.add(activity);
|
||||
}
|
||||
|
||||
public void clearActivities(){
|
||||
activityTemplates.clear();
|
||||
}
|
||||
|
||||
public void addActivities(final Collection<ActivityTemplate> activities){
|
||||
activityTemplates.addAll(activities);
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package se.su.dsv.scipro.activityplan;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
@ -21,110 +22,121 @@ import se.su.dsv.scipro.system.DomainObject;
|
||||
@Table(name = "activity_template")
|
||||
public class ActivityTemplate extends DomainObject {
|
||||
|
||||
//<editor-fold desc="Basic JPA-mappings">
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Basic
|
||||
@Column(name = "title", nullable = false)
|
||||
private String title;
|
||||
|
||||
@Basic
|
||||
@Column(name = "description")
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "activity_plan_template_id")
|
||||
private ActivityPlanTemplate activityPlanTemplate;
|
||||
|
||||
@Basic
|
||||
@Column(name = "days_offset", nullable = false)
|
||||
private int daysOffset;
|
||||
|
||||
@Basic
|
||||
@Column(name = "action")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Action action = Action.NONE;
|
||||
|
||||
@Column(name =" number_in_order", nullable = false)
|
||||
@Basic
|
||||
@Column(name = "number_in_order", nullable = false)
|
||||
private int numberInOrder = Integer.MAX_VALUE;
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_template) referencing other tables.">
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "activity_plan_template_id", referencedColumnName = "id")
|
||||
private ActivityPlanTemplate activityPlanTemplate;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "checklist_template_id")
|
||||
@JoinColumn(name = "checklist_template_id", referencedColumnName = "id")
|
||||
private ChecklistTemplate checklistTemplate;
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Constructors">
|
||||
public ActivityTemplate() {
|
||||
}
|
||||
|
||||
public ActivityTemplate(int daysOffset) {
|
||||
this.daysOffset = daysOffset;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
public int getDaysOffset() {
|
||||
return daysOffset;
|
||||
}
|
||||
|
||||
public int getNumberInOrder() {
|
||||
return numberInOrder;
|
||||
}
|
||||
|
||||
//<editor-fold desc="Properties (Getters and Setters">
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public ActivityPlanTemplate getActivityPlanTemplate() {
|
||||
return this.activityPlanTemplate;
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public ChecklistTemplate getChecklistTemplate() {
|
||||
return this.checklistTemplate;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setActivityPlanTemplate(ActivityPlanTemplate activityPlanTemplate) {
|
||||
this.activityPlanTemplate = activityPlanTemplate;
|
||||
public int getDaysOffset() {
|
||||
return daysOffset;
|
||||
}
|
||||
|
||||
public void setDaysOffset(int daysOffset) {
|
||||
this.daysOffset = daysOffset;
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public void setAction(Action action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public int getNumberInOrder() {
|
||||
return numberInOrder;
|
||||
}
|
||||
|
||||
public void setNumberInOrder(int numberInOrder) {
|
||||
this.numberInOrder = numberInOrder;
|
||||
}
|
||||
|
||||
public ActivityPlanTemplate getActivityPlanTemplate() {
|
||||
return this.activityPlanTemplate;
|
||||
}
|
||||
|
||||
public void setActivityPlanTemplate(ActivityPlanTemplate activityPlanTemplate) {
|
||||
this.activityPlanTemplate = activityPlanTemplate;
|
||||
}
|
||||
|
||||
public ChecklistTemplate getChecklistTemplate() {
|
||||
return this.checklistTemplate;
|
||||
}
|
||||
|
||||
public void setChecklistTemplate(ChecklistTemplate checklistTemplate) {
|
||||
this.checklistTemplate = checklistTemplate;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActivityTemplate(id=" + this.getId() + ", title=" + this.getTitle() + ", description=" + this.getDescription() + ", activityPlanTemplate=" + this.getActivityPlanTemplate() + ", daysOffset=" + this.getDaysOffset() + ", action=" + this.getAction() + ", numberInOrder=" + this.getNumberInOrder() + ", checklistTemplate=" + this.getChecklistTemplate() + ")";
|
||||
}
|
||||
|
||||
//<editor-fold desc="Methods Common To All Objects">
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -134,12 +146,24 @@ public class ActivityTemplate extends DomainObject {
|
||||
&& Objects.equals(this.getId(), other.getId());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActivityTemplate(id=" + this.getId() + ", title=" + this.getTitle() +
|
||||
", description=" + this.getDescription() + ", activityPlanTemplate=" +
|
||||
this.getActivityPlanTemplate() + ", daysOffset=" + this.getDaysOffset() + ", action=" +
|
||||
this.getAction() + ", numberInOrder=" + this.getNumberInOrder() + ", checklistTemplate=" +
|
||||
this.getChecklistTemplate() + ")";
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Other methods">
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityTemplate;
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user
Again less self describing column name.
creator_id
tells you it is the user who created the template rather than just a genericuser_id
. The referenced table/type is visible from the foreign key/class.