From 542af7e97cdc1cfc6d8c50e786c6900a603a5d14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marina=20M=C4=83d=C4=83ra=C8=99?=
 <m.madara@student.tudelft.nl>
Date: Wed, 2 Apr 2025 12:11:08 +0200
Subject: [PATCH] Make jobholder abstract

---
 .../java/nl/tudelft/tam/model/JobHolder.java  |  10 +-
 .../java/nl/tudelft/tam/model/Project.java    |  11 +-
 .../tudelft/tam/model/ProjectJobOffers.java   |  29 ----
 src/main/resources/migrations.yaml            | 142 +-----------------
 4 files changed, 16 insertions(+), 176 deletions(-)
 delete mode 100644 src/main/java/nl/tudelft/tam/model/ProjectJobOffers.java

diff --git a/src/main/java/nl/tudelft/tam/model/JobHolder.java b/src/main/java/nl/tudelft/tam/model/JobHolder.java
index 86d876044..444610edc 100644
--- a/src/main/java/nl/tudelft/tam/model/JobHolder.java
+++ b/src/main/java/nl/tudelft/tam/model/JobHolder.java
@@ -31,11 +31,13 @@ import lombok.experimental.SuperBuilder;
 @SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-@Inheritance(strategy = InheritanceType.JOINED)
-public class JobHolder {
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+public sealed abstract class JobHolder permits Project {
+
 	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY) //TODO: Once suborganisation is implemented, change to move this annotation to SubOrganisation id
-	private Long id;
+	public abstract Long getId();
+
+	public abstract void setId(Long id);
 
 	@OneToMany(mappedBy = "holder")
 	private Set<JobOffer> jobOffers = new HashSet<>();
diff --git a/src/main/java/nl/tudelft/tam/model/Project.java b/src/main/java/nl/tudelft/tam/model/Project.java
index 4dcf9c791..98a7ec499 100644
--- a/src/main/java/nl/tudelft/tam/model/Project.java
+++ b/src/main/java/nl/tudelft/tam/model/Project.java
@@ -25,13 +25,20 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.SuperBuilder;
 
-// TODO: once suborganisation is implemented, change JobHolder to SubOrganisation
+/*
+ * TODO: once suborganisation is implemented, change JobHolder to SubOrganisation and add a one to one
+ * ProjectJobOffers entity
+ */
 @Data
 @Entity
 @SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Project extends JobHolder {
+public non-sealed class Project extends JobHolder {
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	private Long id;
+
 	@NotNull
 	private String name;
 
diff --git a/src/main/java/nl/tudelft/tam/model/ProjectJobOffers.java b/src/main/java/nl/tudelft/tam/model/ProjectJobOffers.java
deleted file mode 100644
index 6699b34f8..000000000
--- a/src/main/java/nl/tudelft/tam/model/ProjectJobOffers.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * TAM
- * Copyright (C) 2021 - Delft University of Technology
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-package nl.tudelft.tam.model;
-
-import jakarta.persistence.Entity;
-import lombok.NoArgsConstructor;
-import lombok.experimental.SuperBuilder;
-
-@Entity
-@SuperBuilder
-@NoArgsConstructor
-//@AllArgsConstructor
-public class ProjectJobOffers extends JobHolder {
-}
diff --git a/src/main/resources/migrations.yaml b/src/main/resources/migrations.yaml
index 496e246ed..a64ca9c17 100644
--- a/src/main/resources/migrations.yaml
+++ b/src/main/resources/migrations.yaml
@@ -940,144 +940,4 @@ databaseChangeLog:
           tableName: job_offer
 
 ## TAM Improvement
-- changeSet:
-    id: 1743251882315-1
-    author: marina (generated)
-    changes:
-      - createTable:
-          columns:
-            - column:
-                autoIncrement: true
-                constraints:
-                  nullable: false
-                  primaryKey: true
-                  primaryKeyName: CONSTRAINT_8D
-                name: id
-                type: BIGINT
-          tableName: job_holder
-- changeSet:
-    id: 1743251882315-2
-    author: marina (generated)
-    changes:
-      - createTable:
-          columns:
-            - column:
-                constraints:
-                  nullable: false
-                  primaryKey: true
-                  primaryKeyName: CONSTRAINT_ED9
-                name: id
-                type: BIGINT
-            - column:
-                name: organisation_id
-                type: BIGINT
-            - column:
-                name: name
-                type: VARCHAR(255)
-          tableName: project
-- changeSet:
-    id: 1743251882315-3
-    author: marina (generated)
-    changes:
-      - createTable:
-          columns:
-            - column:
-                constraints:
-                  nullable: false
-                  primaryKey: true
-                  primaryKeyName: CONSTRAINT_9
-                name: id
-                type: BIGINT
-          tableName: project_job_offers
-- changeSet:
-    id: 1743251882315-4
-    author: marina (generated)
-    changes:
-      - addColumn:
-          columns:
-            - column:
-                name: holder_id
-                type: BIGINT
-          tableName: job_offer
-- changeSet:
-    id: 1743251882315-5
-    author: marina (generated)
-    changes:
-      - createIndex:
-          associatedWith: ''
-          columns:
-            - column:
-                name: holder_id
-          indexName: FK37ddvbsl9gj5fxvi77f235buj_INDEX_5
-          tableName: job_offer
-- changeSet:
-    id: 1743251882315-6
-    author: marina (generated)
-    changes:
-      - createIndex:
-          associatedWith: ''
-          columns:
-            - column:
-                name: organisation_id
-          indexName: FK3quouuek44c2lxbp9uh7b4pm1_INDEX_E
-          tableName: project
-- changeSet:
-    id: 1743251882315-7
-    author: marina (generated)
-    changes:
-      - addForeignKeyConstraint:
-          baseColumnNames: holder_id
-          baseTableName: job_offer
-          constraintName: FK37ddvbsl9gj5fxvi77f235buj
-          deferrable: false
-          initiallyDeferred: false
-          onDelete: RESTRICT
-          onUpdate: RESTRICT
-          referencedColumnNames: id
-          referencedTableName: job_holder
-          validate: true
-- changeSet:
-    id: 1743251882315-8
-    author: marina (generated)
-    changes:
-      - addForeignKeyConstraint:
-          baseColumnNames: organisation_id
-          baseTableName: project
-          constraintName: FK3quouuek44c2lxbp9uh7b4pm1
-          deferrable: false
-          initiallyDeferred: false
-          onDelete: RESTRICT
-          onUpdate: RESTRICT
-          referencedColumnNames: id
-          referencedTableName: tamprogram
-          validate: true
-- changeSet:
-    id: 1743251882315-9
-    author: marina (generated)
-    changes:
-      - addForeignKeyConstraint:
-          baseColumnNames: id
-          baseTableName: project_job_offers
-          constraintName: FKlr407g8ab3ipnis7hjb04j39n
-          deferrable: false
-          initiallyDeferred: false
-          onDelete: RESTRICT
-          onUpdate: RESTRICT
-          referencedColumnNames: id
-          referencedTableName: job_holder
-          validate: true
-- changeSet:
-    id: 1743251882315-10
-    author: marina (generated)
-    changes:
-      - addForeignKeyConstraint:
-          baseColumnNames: id
-          baseTableName: project
-          constraintName: FKnkb4e1xadrghkv5x4vbipkxgr
-          deferrable: false
-          initiallyDeferred: false
-          onDelete: RESTRICT
-          onUpdate: RESTRICT
-          referencedColumnNames: id
-          referencedTableName: job_holder
-          validate: true
\ No newline at end of file
+
-- 
GitLab