task/3382: Harmonisera tabellnamn #6

Merged
ansv7779 merged 104 commits from task/3382 into develop 2024-11-12 13:33:44 +01:00
2 changed files with 117 additions and 75 deletions
Showing only changes of commit 8b705706b5 - Show all commits

View File

@ -6,6 +6,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column; import jakarta.persistence.Column;
@ -28,28 +29,38 @@ import se.su.dsv.scipro.system.User;
@Cacheable(true) @Cacheable(true)
public class ActivityPlanTemplate extends DomainObject { public class ActivityPlanTemplate extends DomainObject {
//<editor-fold desc="Basic JPA-mappings">
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Basic
@Column(name = "is_sys_admin_template", nullable=false) @Column(name = "is_sys_admin_template", nullable=false)
private boolean isSysAdminTemplate = false; private boolean isSysAdminTemplate = false;
@Basic
@Column(nullable=false) @Column(nullable=false)
private String title; private String title;
@Basic
@Column(name = "description")
@Lob @Lob
private String description; private String description;
//</editor-fold>
@OrderColumn(name = "number_in_order") //<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan_template) referencing other tables.">
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
@ManyToOne(optional=false) @ManyToOne(optional=false)
@JoinColumn(name = "user_id") @JoinColumn(name = "user_id")
tozh4728 marked this conversation as resolved Outdated

Again less self describing column name. creator_id tells you it is the user who created the template rather than just a generic user_id. The referenced table/type is visible from the foreign key/class.

Again less self describing column name. `creator_id` tells you it is the user who created the template rather than just a generic `user_id`. The referenced table/type is visible from the foreign key/class.
private User creator; 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 @Override
public Long getId() { public Long getId() {
return this.id; return this.id;
@ -83,18 +94,12 @@ public class ActivityPlanTemplate extends DomainObject {
this.description = description; this.description = description;
} }
public void addActivity(ActivityTemplate activity){ public User getCreator() {
activity.setActivityPlanTemplate(this); return this.creator;
activity.setNumberInOrder(activityTemplates.size());
activityTemplates.add(activity);
} }
public void clearActivities(){ public void setCreator(User creator) {
activityTemplates.clear(); this.creator = creator;
}
public void addActivities(final Collection<ActivityTemplate> activities){
activityTemplates.addAll(activities);
} }
public List<ActivityTemplate> getActivityTemplates(){ public List<ActivityTemplate> getActivityTemplates(){
@ -104,15 +109,9 @@ public class ActivityPlanTemplate extends DomainObject {
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){ public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
this.activityTemplates = new ArrayList<>(activityTemplates); this.activityTemplates = new ArrayList<>(activityTemplates);
} }
//</editor-fold>
public User getCreator() { //<editor-fold desc="Methods Common To All Objects">
return this.creator;
}
public void setCreator(User creator) {
this.creator = creator;
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (o == this) return true; if (o == this) return true;
@ -139,6 +138,25 @@ public class ActivityPlanTemplate extends DomainObject {
@Override @Override
public String toString() { 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>
} }

View File

@ -2,6 +2,7 @@ package se.su.dsv.scipro.activityplan;
import java.util.Objects; import java.util.Objects;
import jakarta.persistence.Basic;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.EnumType; import jakarta.persistence.EnumType;
@ -21,110 +22,121 @@ import se.su.dsv.scipro.system.DomainObject;
@Table(name = "activity_template") @Table(name = "activity_template")
public class ActivityTemplate extends DomainObject { public class ActivityTemplate extends DomainObject {
//<editor-fold desc="Basic JPA-mappings">
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(nullable = false) @Basic
@Column(name = "title", nullable = false)
private String title; private String title;
@Basic
@Column(name = "description")
@Lob @Lob
private String description; private String description;
@ManyToOne @Basic
@JoinColumn(name = "activity_plan_template_id")
private ActivityPlanTemplate activityPlanTemplate;
@Column(name = "days_offset", nullable = false) @Column(name = "days_offset", nullable = false)
private int daysOffset; private int daysOffset;
@Basic
@Column(name = "action")
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private Action action = Action.NONE; 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; 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) @ManyToOne(optional = true)
@JoinColumn(name = "checklist_template_id") @JoinColumn(name = "checklist_template_id", referencedColumnName = "id")
private ChecklistTemplate checklistTemplate; private ChecklistTemplate checklistTemplate;
//</editor-fold>
//<editor-fold desc="Constructors">
public ActivityTemplate() { public ActivityTemplate() {
} }
public ActivityTemplate(int daysOffset) { public ActivityTemplate(int daysOffset) {
this.daysOffset = daysOffset; this.daysOffset = daysOffset;
} }
//</editor-fold>
public int getDaysOffset() { //<editor-fold desc="Properties (Getters and Setters">
return daysOffset;
}
public int getNumberInOrder() {
return numberInOrder;
}
@Override @Override
public Long getId() { public Long getId() {
return this.id; 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) { public void setId(Long id) {
this.id = id; this.id = id;
} }
public String getTitle() {
return this.title;
}
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
public String getDescription() {
return this.description;
}
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public void setActivityPlanTemplate(ActivityPlanTemplate activityPlanTemplate) { public int getDaysOffset() {
this.activityPlanTemplate = activityPlanTemplate; return daysOffset;
} }
public void setDaysOffset(int daysOffset) { public void setDaysOffset(int daysOffset) {
this.daysOffset = daysOffset; this.daysOffset = daysOffset;
} }
public Action getAction() {
return this.action;
}
public void setAction(Action action) { public void setAction(Action action) {
this.action = action; this.action = action;
} }
public int getNumberInOrder() {
return numberInOrder;
}
public void setNumberInOrder(int numberInOrder) { public void setNumberInOrder(int numberInOrder) {
this.numberInOrder = 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) { public void setChecklistTemplate(ChecklistTemplate checklistTemplate) {
this.checklistTemplate = checklistTemplate; this.checklistTemplate = checklistTemplate;
} }
//</editor-fold>
@Override //<editor-fold desc="Methods Common To All Objects">
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() + ")";
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (o == this) return true; if (o == this) return true;
@ -134,12 +146,24 @@ public class ActivityTemplate extends DomainObject {
&& Objects.equals(this.getId(), other.getId()); && Objects.equals(this.getId(), other.getId());
} }
protected boolean canEqual(final Object other) {
return other instanceof ActivityTemplate;
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(this.getId()); 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>
} }