task/3382: Harmonisera tabellnamn #6
|
@ -1,42 +1,87 @@
|
||||||
package se.su.dsv.scipro.activityplan;
|
package se.su.dsv.scipro.activityplan;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import jakarta.persistence.Cacheable;
|
||||||
|
import jakarta.persistence.CascadeType;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.Lob;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.OrderColumn;
|
||||||
|
|
||||||
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
|
@Table(name = "activity_plan_template")
|
||||||
public class ActivityPlanTemplate extends DomainObject {
|
public class ActivityPlanTemplate extends DomainObject {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@OrderColumn(name = "numberInOrder")
|
@Column(name = "is_sys_admin_template", nullable=false)
|
||||||
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
|
private boolean isSysAdminTemplate = false;
|
||||||
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
|
|
||||||
|
|
||||||
public List<ActivityTemplate> getActivityTemplates(){
|
|
||||||
return Collections.unmodifiableList(activityTemplates);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
|
|
||||||
this.activityTemplates = new ArrayList<>(activityTemplates);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToOne(optional=false)
|
|
||||||
private User creator;
|
|
||||||
|
|
||||||
@Column(nullable=false)
|
@Column(nullable=false)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Column(nullable=false)
|
@OrderColumn(name = "number_in_order")
|
||||||
private boolean isSysAdminTemplate = false;
|
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL)
|
||||||
|
private List<ActivityTemplate> activityTemplates = new ArrayList<>();
|
||||||
|
|
||||||
|
@ManyToOne(optional=false)
|
||||||
|
@JoinColumn(name = "user_id")
|
||||||
|
private User creator;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSysAdminTemplate() {
|
||||||
|
return this.isSysAdminTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSysAdminTemplate(boolean isSysAdminTemplate) {
|
||||||
|
this.isSysAdminTemplate = isSysAdminTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 addActivity(ActivityTemplate activity){
|
public void addActivity(ActivityTemplate activity){
|
||||||
activity.setActivityPlanTemplate(this);
|
activity.setActivityPlanTemplate(this);
|
||||||
|
@ -52,47 +97,22 @@ public class ActivityPlanTemplate extends DomainObject {
|
||||||
activityTemplates.addAll(activities);
|
activityTemplates.addAll(activities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<ActivityTemplate> getActivityTemplates(){
|
||||||
public Long getId() {
|
return Collections.unmodifiableList(activityTemplates);
|
||||||
return this.id;
|
}
|
||||||
|
|
||||||
|
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){
|
||||||
|
this.activityTemplates = new ArrayList<>(activityTemplates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getCreator() {
|
public User getCreator() {
|
||||||
return this.creator;
|
return this.creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSysAdminTemplate() {
|
|
||||||
return this.isSysAdminTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreator(User creator) {
|
public void setCreator(User creator) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSysAdminTemplate(boolean isSysAdminTemplate) {
|
|
||||||
this.isSysAdminTemplate = isSysAdminTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
|
|
|
@ -1004,7 +1004,7 @@ alter table `application_period_project_type` rename column `activityPlanTemplat
|
||||||
|
|
||||||
alter table `application_period_project_type` add primary key (application_period_id, project_type_id);
|
alter table `application_period_project_type` add primary key (application_period_id, project_type_id);
|
||||||
|
|
||||||
-- >>> STACK PUSH: 2nd table group: target, ActivityPlanTemplate and ActivityTemplate
|
-- >>> STACK PUSH: 2nd table group: ActivityPlanTemplate and ActivityTemplate
|
||||||
|
|
||||||
-- table: ActivityTemplate, except foreign key to coming table activity_plan_template
|
-- table: ActivityTemplate, except foreign key to coming table activity_plan_template
|
||||||
|
|
||||||
|
@ -1028,15 +1028,21 @@ alter table `activity_template`
|
||||||
|
|
||||||
-- table: ActivityPlanTemplate (at this stage, no any foreign key is are referenced to ActivityPlanTemplate)
|
-- table: ActivityPlanTemplate (at this stage, no any foreign key is are referenced to ActivityPlanTemplate)
|
||||||
|
|
||||||
|
alter table `ActivityPlanTemplate` drop foreign key `FK_rgwf80yvcy2msbb6g80bae10p`;
|
||||||
|
alter table `ActivityPlanTemplate` drop key `FK_rgwf80yvcy2msbb6g80bae10p`;
|
||||||
|
alter table `ActivityPlanTemplate` drop key `FKACCF6522E44F4DBE`;
|
||||||
|
|
||||||
|
rename table `ActivityPlanTemplate` to `activity_plan_template`;
|
||||||
|
|
||||||
|
alter table `activity_plan_template` rename column `isSysAdminTemplate` to `is_sys_admin_template`;
|
||||||
|
alter table `activity_plan_template` rename column `creator_id` to `user_id`;
|
||||||
|
|
||||||
|
alter table `activity_plan_template`
|
||||||
|
add constraint fk_activity_plan_template_user_id
|
||||||
|
foreign key (user_id) references user (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
/* Activate following later
|
-- Add back all foreign key references to activity_plan_template
|
||||||
|
|
||||||
-- **********************************************************************************
|
|
||||||
-- TODO: -- Add back all foreign key references to activity_plan_template
|
|
||||||
-- **********************************************************************************
|
|
||||||
|
|
||||||
-- add foreign key reference from activity_template to activity_plan_template
|
-- add foreign key reference from activity_template to activity_plan_template
|
||||||
alter table `activity_template`
|
alter table `activity_template`
|
||||||
|
@ -1044,15 +1050,18 @@ alter table `activity_template`
|
||||||
foreign key (activity_plan_template_id) references activity_plan_template (id)
|
foreign key (activity_plan_template_id) references activity_plan_template (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
|
||||||
-- add foreign key reference from application_period_project_type to activity_plan_template
|
-- add foreign key reference from application_period_project_type to activity_plan_template
|
||||||
alter table `application_period_project_type`
|
alter table `application_period_project_type`
|
||||||
add constraint fk_ap_pt_activity_plan_template_id
|
add constraint fk_ap_pt_activity_plan_template_id
|
||||||
foreign key (activity_plan_template_id) references activity_plan_template (id)
|
foreign key (activity_plan_template_id) references activity_plan_template (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- >>> STACK POP: 2nd table group (ActivityPlanTemplate and ActivityTemplate) is done!!!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Activate following later
|
||||||
|
|
||||||
-- **********************************************************************************
|
-- **********************************************************************************
|
||||||
-- TODO: fix table ApplicationPeriod, verify no foreign keys are referenced to ApplicationPeriod before fix it
|
-- TODO: fix table ApplicationPeriod, verify no foreign keys are referenced to ApplicationPeriod before fix it
|
||||||
-- **********************************************************************************
|
-- **********************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue
Block a user