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.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<>();
@ManyToOne(optional=false)
//<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

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;
//</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,28 +94,6 @@ public class ActivityPlanTemplate extends DomainObject {
this.description = description;
}
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);
}
public List<ActivityTemplate> getActivityTemplates(){
return Collections.unmodifiableList(activityTemplates);
}
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
this.activityTemplates = new ArrayList<>(activityTemplates);
}
public User getCreator() {
return this.creator;
}
@ -113,6 +102,16 @@ public class ActivityPlanTemplate extends DomainObject {
this.creator = creator;
}
public List<ActivityTemplate> getActivityTemplates(){
return Collections.unmodifiableList(activityTemplates);
}
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
this.activityTemplates = new ArrayList<>(activityTemplates);
}
//</editor-fold>
//<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>
}

View File

@ -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>
}