Simplifed DB table structure
parent
9184050986
commit
97afa16b46
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2023-02-22T184921",
|
"version": "7.0.0-SNAPSHOT.2023-02-23T193303",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2023-02-22T184921",
|
"version": "7.0.0-SNAPSHOT.2023-02-23T193303",
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tiptap/core": "^2.0.0-beta.127",
|
"@tiptap/core": "^2.0.0-beta.127",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2023-02-22T184921",
|
"version": "7.0.0-SNAPSHOT.2023-02-23T193303",
|
||||||
"description": "JavaScript stuff for ccm-cms",
|
"description": "JavaScript stuff for ccm-cms",
|
||||||
"main": "target/generated-resources/assets/@content-sections/cms-admin.js",
|
"main": "target/generated-resources/assets/@content-sections/cms-admin.js",
|
||||||
"types": "target/generated-resources/assets/@content-sections/cms-admin.d.ts",
|
"types": "target/generated-resources/assets/@content-sections/cms-admin.d.ts",
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
import org.librecms.contentsection.privileges.TypePrivileges;
|
import org.librecms.contentsection.privileges.TypePrivileges;
|
||||||
import org.librecms.lifecycle.LifecycleDefinition;
|
import org.librecms.lifecycle.LifecycleDefinition;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.OrderBy;
|
import javax.persistence.OrderBy;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
@ -168,6 +171,10 @@ public class ContentSection
|
||||||
@JsonIdentityReference(alwaysAsId = true)
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Folder rootAssetsFolder;
|
private Folder rootAssetsFolder;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "section", orphanRemoval = true)
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
|
private Set<Folder> folders;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "CONTENT_SECTION_ROLES",
|
@JoinTable(name = "CONTENT_SECTION_ROLES",
|
||||||
schema = DB_SCHEMA,
|
schema = DB_SCHEMA,
|
||||||
|
|
@ -239,6 +246,22 @@ public class ContentSection
|
||||||
return rootAssetsFolder;
|
return rootAssetsFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Set<Folder> getFolders() {
|
||||||
|
return Collections.unmodifiableSet(folders);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFolder(final Folder folder) {
|
||||||
|
folders.add(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void removeFolder(final Folder folder) {
|
||||||
|
folders.remove(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setFolders(final Set<Folder> folders) {
|
||||||
|
this.folders = new HashSet<>(folders);
|
||||||
|
}
|
||||||
|
|
||||||
protected void setRootAssetsFolder(final Folder rootAssetsFolder) {
|
protected void setRootAssetsFolder(final Folder rootAssetsFolder) {
|
||||||
this.rootAssetsFolder = rootAssetsFolder;
|
this.rootAssetsFolder = rootAssetsFolder;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ package org.librecms.contentsection;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.libreccm.categorization.Categorization;
|
import org.libreccm.categorization.Categorization;
|
||||||
|
|
||||||
|
|
@ -43,6 +44,7 @@ import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedNativeQueries;
|
import javax.persistence.NamedNativeQueries;
|
||||||
import javax.persistence.NamedNativeQuery;
|
import javax.persistence.NamedNativeQuery;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
|
|
@ -317,17 +319,20 @@ public class Folder extends Category implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
// @OneToOne(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
// @JoinTable(
|
||||||
name = "FOLDER_CONTENT_SECTION_MAP", schema = DB_SCHEMA,
|
// name = "FOLDER_CONTENT_SECTION_MAP", schema = DB_SCHEMA,
|
||||||
inverseJoinColumns = {
|
// inverseJoinColumns = {
|
||||||
@JoinColumn(name = "CONTENT_SECTION_ID")
|
// @JoinColumn(name = "CONTENT_SECTION_ID")
|
||||||
},
|
// },
|
||||||
joinColumns = {
|
// joinColumns = {
|
||||||
@JoinColumn(name = "FOLDER_ID")
|
// @JoinColumn(name = "FOLDER_ID")
|
||||||
}
|
// }
|
||||||
)
|
// )
|
||||||
@JsonIdentityReference(alwaysAsId = true)
|
// @JsonIdentityReference(alwaysAsId = true)
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "content_section_id")
|
||||||
|
@JsonIgnore
|
||||||
private ContentSection section;
|
private ContentSection section;
|
||||||
|
|
||||||
@Column(name = "TYPE", nullable = false)
|
@Column(name = "TYPE", nullable = false)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ public class FolderImExporter extends AbstractEntityImExporter<Folder> {
|
||||||
protected void init() {
|
protected void init() {
|
||||||
addRequiredEntities(
|
addRequiredEntities(
|
||||||
Set.of(
|
Set.of(
|
||||||
ContentSection.class,
|
|
||||||
Category.class,
|
Category.class,
|
||||||
Domain.class
|
Domain.class
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
alter table ccm_cms.folders add column content_section_id int8;
|
||||||
|
|
||||||
|
update ccm_cms.folders
|
||||||
|
set content_section_id = (
|
||||||
|
select content_section_id
|
||||||
|
from ccm_cms.folder_content_section_map
|
||||||
|
where ccm_cms.folder_content_section_map.folder_id = ccm_cms.folders.object_id
|
||||||
|
);
|
||||||
|
|
||||||
|
alter table CCM_CMS.FOLDERS
|
||||||
|
add constraint FKpl9im9yrxktlhyq2fx39xoowp
|
||||||
|
foreign key (content_section_id)
|
||||||
|
references CCM_CMS.CONTENT_SECTIONS;
|
||||||
|
|
||||||
|
|
||||||
|
drop table ccm_cms.folder_content_section_map;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
alter table ccm_cms.folders add column content_section_id bigint;
|
||||||
|
|
||||||
|
update ccm_cms.folders
|
||||||
|
set content_section_id = (
|
||||||
|
select content_section_id
|
||||||
|
from ccm_cms.folder_content_section_map
|
||||||
|
where ccm_cms.folder_content_section_map.folder_id = ccm_cms.folders.object_id
|
||||||
|
);
|
||||||
|
|
||||||
|
alter table CCM_CMS.FOLDERS
|
||||||
|
add constraint FKpl9im9yrxktlhyq2fx39xoowp
|
||||||
|
foreign key (content_section_id)
|
||||||
|
references CCM_CMS.CONTENT_SECTIONS;
|
||||||
|
|
||||||
|
|
||||||
|
drop table ccm_cms.folder_content_section_map;
|
||||||
Loading…
Reference in New Issue