diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java index 8147de2de..02ed4fc09 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java @@ -5,15 +5,13 @@ import eu.eudat.commons.enums.IsActive; import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.enums.DescriptionStatusConverter; import eu.eudat.data.converters.enums.IsActiveConverter; -import jakarta.persistence.Column; -import jakarta.persistence.Convert; -import jakarta.persistence.Id; +import jakarta.persistence.*; import java.time.Instant; import java.util.UUID; -//@Entity -//@Table(name = "\"Description\"") +@Entity +@Table(name = "\"Description\"") public class DescriptionEntity { @Id diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java index b471fdcbe..0d8fafa31 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java @@ -8,8 +8,8 @@ import jakarta.persistence.*; import java.time.Instant; import java.util.UUID; -//@Entity -//@Table(name = "\"DescriptionReference\"") +@Entity +@Table(name = "\"DescriptionReference\"") public class DescriptionReferenceEntity { @Id diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java index b67455f62..eff9dd0ae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DmpEntity.java @@ -10,9 +10,8 @@ import org.hibernate.annotations.GenericGenerator; import java.time.Instant; import java.util.UUID; -//TODO: (thgiannos) Wire up when all other dependent entities are refactored -//@Entity -//@Table(name = "\"DMP\"") +@Entity +@Table(name = "\"Dmp\"") public class DmpEntity { @Id @@ -85,73 +84,23 @@ public class DmpEntity { public static final String _isActive = "isActive"; - @Column(name = "\"finalized_at\"") + @Column(name = "finalized_at") @Convert(converter = DateToUTCConverter.class) private Instant finalizedAt; public static final String _finalizedAt = "finalizedAt"; - @Column(name = "\"published_at\"") + @Column(name = "published_at") @Convert(converter = DateToUTCConverter.class) private Instant publishedAt; public static final String _publishedAt = "publishedAt"; - // @ManyToOne(fetch = FetchType.LAZY) -// @JoinColumn(name = "\"Grant\"") - //TODO: (thgiannos) Previously 'Grant' - private UUID grant; - - public static final String _grant = "grant"; - - //TODO: (thgiannos) Handle using the DMPEntity builder -// @OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp") -// private Set associatedDmps; - - // @ManyToOne(fetch = FetchType.LAZY) -// @JoinColumn(name = "\"Profile\"") - //TODO: (thgiannos) Previously 'DMPProfile' - private UUID profile; - - public static final String _profile = "profile"; - - // @ManyToOne(fetch = FetchType.LAZY) -// @JoinColumn(name = "\"Creator\"") - //TODO: (thgiannos) Previously 'UserInfo' + @Column(name = "creator") private UUID creator; public static final String _creator = "creator"; - //TODO: (thgiannos) Handle using the DMPEntity builder -// @OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY) -// private Set dois; - - // @ManyToOne(fetch = FetchType.LAZY) -// @JoinColumn(name = "\"Project\"") - //TODO: (thgiannos) Previously 'Project' - private UUID project; - - public static final String _project = "project"; - - // TODO: (thgiannos) Implement join entity -// @OneToMany(fetch = FetchType.LAZY) -// @JoinTable(name = "\"DMPOrganisation\"", -// joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}, -// inverseJoinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")} -// ) -// private Set organisations; - - // TODO: (thgiannos) Implement join entity -// @OneToMany(fetch = FetchType.LAZY) -// @JoinTable(name = "\"DMPResearcher\"", -// joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}, -// inverseJoinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")} -// ) -// private Set researchers; - - //TODO: (thgiannos) Handle using the DMPEntity builder -// private Set users; - public UUID getId() { return id; } @@ -272,22 +221,6 @@ public class DmpEntity { this.publishedAt = publishedAt; } - public UUID getGrant() { - return grant; - } - - public void setGrant(UUID grant) { - this.grant = grant; - } - - public UUID getProfile() { - return profile; - } - - public void setProfile(UUID profile) { - this.profile = profile; - } - public UUID getCreator() { return creator; } @@ -296,12 +229,4 @@ public class DmpEntity { this.creator = creator; } - public UUID getProject() { - return project; - } - - public void setProject(UUID project) { - this.project = project; - } - } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java b/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java index c95d19e32..7ad6d86d6 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java @@ -69,22 +69,10 @@ public class Dmp { public static final String _publishedAt = "publishedAt"; - private UUID grant; - - public static final String _grant = "grant"; - - private UUID profile; - - public static final String _profile = "profile"; - private UUID creator; public static final String _creator = "creator"; - private UUID project; - - public static final String _project = "project"; - private String hash; public static final String _hash = "hash"; @@ -216,22 +204,6 @@ public class Dmp { this.publishedAt = publishedAt; } - public UUID getGrant() { - return grant; - } - - public void setGrant(UUID grant) { - this.grant = grant; - } - - public UUID getProfile() { - return profile; - } - - public void setProfile(UUID profile) { - this.profile = profile; - } - public UUID getCreator() { return creator; } @@ -240,14 +212,6 @@ public class Dmp { this.creator = creator; } - public UUID getProject() { - return project; - } - - public void setProject(UUID project) { - this.project = project; - } - public String getHash() { return hash; } diff --git a/dmp-db-scema/updates/00.01.003_Align_Dmp_blueprint_table.sql b/dmp-db-scema/updates/00.01.004_Align_Dmp_blueprint_table.sql similarity index 75% rename from dmp-db-scema/updates/00.01.003_Align_Dmp_blueprint_table.sql rename to dmp-db-scema/updates/00.01.004_Align_Dmp_blueprint_table.sql index bf66b6146..c8167bf12 100644 --- a/dmp-db-scema/updates/00.01.003_Align_Dmp_blueprint_table.sql +++ b/dmp-db-scema/updates/00.01.004_Align_Dmp_blueprint_table.sql @@ -1,3 +1,9 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.004'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + ALTER TABLE public."DMPProfile" RENAME TO "DmpBlueprint"; ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id; @@ -23,4 +29,8 @@ UPDATE public."DmpBlueprint" SET is_active = 1; UPDATE public."DmpBlueprint" SET is_active = 0 where status = 99; UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0; -ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL; \ No newline at end of file +ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL; + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.004', '2023-10-27 12:00:00.000000+02', now(), 'Align dmp blueprint table.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql b/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql new file mode 100644 index 000000000..02de486e5 --- /dev/null +++ b/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql @@ -0,0 +1,29 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.005'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."Dmp" +( + "id" uuid NOT NULL, + "label" character varying(250) COLLATE pg_catalog."default" NOT NULL, + "version" integer NOT NULL, + "status" smallint NOT NULL DEFAULT 0, + "properties" text COLLATE pg_catalog."default", + "dmp_properties" text COLLATE pg_catalog."default", + "group_id" uuid, + "description" text COLLATE pg_catalog."default", + "is_public" boolean NOT NULL DEFAULT false, + "extra_properties" text COLLATE pg_catalog."default", + "created_at" timestamp without time zone NOT NULL DEFAULT now(), + "updated_at" timestamp without time zone NOT NULL DEFAULT now(), + "is_active" smallint NOT NULL DEFAULT 1, + "finalized_at" timestamp without time zone, + "published_at" timestamp without time zone, + CONSTRAINT "Dmp_pkey" PRIMARY KEY (id) +) + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.005', '2023-10-27 12:00:00.000000+02', now(), 'Add Dmp table.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.006_Add_Dmp_reference_table.sql b/dmp-db-scema/updates/00.01.006_Add_Dmp_reference_table.sql new file mode 100644 index 000000000..81b9dd635 --- /dev/null +++ b/dmp-db-scema/updates/00.01.006_Add_Dmp_reference_table.sql @@ -0,0 +1,23 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.006'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."DmpReference" +( + "id" uuid NOT NULL, + "dmp_id" uuid NOT NULL, + "reference_id" uuid NOT NULL, + "data" text COLLATE pg_catalog."default", + "created_at" timestamp without time zone NOT NULL DEFAULT now(), + "updated_at" timestamp without time zone NOT NULL DEFAULT now(), + "is_active" smallint NOT NULL DEFAULT 1, + CONSTRAINT "DmpReference_pkey" PRIMARY KEY (id), + CONSTRAINT "DmpReference_dmp_id_fkey" FOREIGN KEY ("dmp_id") REFERENCES public."Dmp"("id"), + CONSTRAINT "DmpReference_reference_id_fkey" FOREIGN KEY ("reference_id") REFERENCES public."Reference"("id") +) + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.006', '2023-10-27 12:00:00.000000+02', now(), 'Add DescriptionReference table.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.007_Add_Description_table_former_Dataset.sql b/dmp-db-scema/updates/00.01.007_Add_Description_table_former_Dataset.sql new file mode 100644 index 000000000..efd2ef90d --- /dev/null +++ b/dmp-db-scema/updates/00.01.007_Add_Description_table_former_Dataset.sql @@ -0,0 +1,30 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.007'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."Description" +( + "id" uuid NOT NULL, + "label" character varying(250) COLLATE pg_catalog."default" NOT NULL, + "dmp" uuid, + "uri" character varying(250) COLLATE pg_catalog."default", + "properties" text COLLATE pg_catalog."default", + "profile" uuid, + "reference" text COLLATE pg_catalog."default", + "status" smallint NOT NULL DEFAULT 0, + "description" text COLLATE pg_catalog."default", + "dmp_section_index" integer NOT NULL, + "created_at" timestamp without time zone NOT NULL DEFAULT now(), + "updated_at" timestamp without time zone NOT NULL DEFAULT now(), + "is_active" smallint NOT NULL DEFAULT 1, + "finalized_at" timestamp without time zone, + CONSTRAINT "Description_pkey" PRIMARY KEY (id), + CONSTRAINT "Description_dmp_fkey" FOREIGN KEY ("dmp") REFERENCES public."Dmp"("id"), + CONSTRAINT "Description_profile_fkey" FOREIGN KEY ("profile") REFERENCES public."DescriptionTemplate"("ID") +) + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.007', '2023-10-27 12:00:00.000000+02', now(), 'Add Description table (former Dataset).'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.008_Add_DescriptionReference_table.sql b/dmp-db-scema/updates/00.01.008_Add_DescriptionReference_table.sql new file mode 100644 index 000000000..e9c9aaa5d --- /dev/null +++ b/dmp-db-scema/updates/00.01.008_Add_DescriptionReference_table.sql @@ -0,0 +1,23 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.008'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."DescriptionReference" +( + "id" uuid NOT NULL, + "data" text COLLATE pg_catalog."default" NOT NULL, + "description_id" uuid NOT NULL, + "reference_id" uuid NOT NULL, + "created_at" timestamp without time zone NOT NULL DEFAULT now(), + "updated_at" timestamp without time zone NOT NULL DEFAULT now(), + "is_active" smallint NOT NULL DEFAULT 1, + CONSTRAINT "DescriptionReference_pkey" PRIMARY KEY (id), + CONSTRAINT "DescriptionReference_description_fkey" FOREIGN KEY ("description_id") REFERENCES public."Description"("id"), + CONSTRAINT "DescriptionReference_reference_fkey" FOREIGN KEY ("reference_id") REFERENCES public."Reference"("id") +) + +INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.008', '2023-10-27 12:00:00.000000+02', now(), 'Add DescriptionReference table.'); + +END$$; \ No newline at end of file