Adding migration scripts for Dmp, DmpReference, Description and DescriptionReference entities, other fixes / clear up dmp entity
This commit is contained in:
parent
8d1c988135
commit
e31970c7ea
|
@ -5,15 +5,13 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.*;
|
||||||
import jakarta.persistence.Convert;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
//@Entity
|
@Entity
|
||||||
//@Table(name = "\"Description\"")
|
@Table(name = "\"Description\"")
|
||||||
public class DescriptionEntity {
|
public class DescriptionEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|
|
@ -8,8 +8,8 @@ import jakarta.persistence.*;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
//@Entity
|
@Entity
|
||||||
//@Table(name = "\"DescriptionReference\"")
|
@Table(name = "\"DescriptionReference\"")
|
||||||
public class DescriptionReferenceEntity {
|
public class DescriptionReferenceEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|
|
@ -10,9 +10,8 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
//TODO: (thgiannos) Wire up when all other dependent entities are refactored
|
@Entity
|
||||||
//@Entity
|
@Table(name = "\"Dmp\"")
|
||||||
//@Table(name = "\"DMP\"")
|
|
||||||
public class DmpEntity {
|
public class DmpEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -85,73 +84,23 @@ public class DmpEntity {
|
||||||
|
|
||||||
public static final String _isActive = "isActive";
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
@Column(name = "\"finalized_at\"")
|
@Column(name = "finalized_at")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Instant finalizedAt;
|
private Instant finalizedAt;
|
||||||
|
|
||||||
public static final String _finalizedAt = "finalizedAt";
|
public static final String _finalizedAt = "finalizedAt";
|
||||||
|
|
||||||
@Column(name = "\"published_at\"")
|
@Column(name = "published_at")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Instant publishedAt;
|
private Instant publishedAt;
|
||||||
|
|
||||||
public static final String _publishedAt = "publishedAt";
|
public static final String _publishedAt = "publishedAt";
|
||||||
|
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
@Column(name = "creator")
|
||||||
// @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<DMPDatasetProfile> 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'
|
|
||||||
private UUID creator;
|
private UUID creator;
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
public static final String _creator = "creator";
|
||||||
|
|
||||||
//TODO: (thgiannos) Handle using the DMPEntity builder
|
|
||||||
// @OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
|
|
||||||
// private Set<EntityDoiEntity> 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<Organisation> 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<Researcher> researchers;
|
|
||||||
|
|
||||||
//TODO: (thgiannos) Handle using the DMPEntity builder
|
|
||||||
// private Set<UserDMP> users;
|
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -272,22 +221,6 @@ public class DmpEntity {
|
||||||
this.publishedAt = publishedAt;
|
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() {
|
public UUID getCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
@ -296,12 +229,4 @@ public class DmpEntity {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProject(UUID project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,22 +69,10 @@ public class Dmp {
|
||||||
|
|
||||||
public static final String _publishedAt = "publishedAt";
|
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;
|
private UUID creator;
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
public static final String _creator = "creator";
|
||||||
|
|
||||||
private UUID project;
|
|
||||||
|
|
||||||
public static final String _project = "project";
|
|
||||||
|
|
||||||
private String hash;
|
private String hash;
|
||||||
|
|
||||||
public static final String _hash = "hash";
|
public static final String _hash = "hash";
|
||||||
|
@ -216,22 +204,6 @@ public class Dmp {
|
||||||
this.publishedAt = publishedAt;
|
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() {
|
public UUID getCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
@ -240,14 +212,6 @@ public class Dmp {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProject(UUID project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHash() {
|
public String getHash() {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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."DMPProfile" RENAME TO "DmpBlueprint";
|
||||||
|
|
||||||
ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id;
|
ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id;
|
||||||
|
@ -24,3 +30,7 @@ UPDATE public."DmpBlueprint" SET is_active = 0 where status = 99;
|
||||||
UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0;
|
UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0;
|
||||||
|
|
||||||
ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL;
|
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$$;
|
|
@ -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$$;
|
|
@ -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$$;
|
|
@ -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$$;
|
|
@ -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$$;
|
Loading…
Reference in New Issue