CCM NG: Added OrderBy annotation to several lists

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5172 8810af33-2d31-482b-a856-94f89814c4df
jensp 2017-12-14 16:34:03 +00:00
parent fd3730bb9d
commit 5215362d4a
16 changed files with 51 additions and 3 deletions

View File

@ -41,6 +41,7 @@ import javax.persistence.JoinTable;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
@ -416,6 +417,7 @@ public class Asset extends CcmObject {
private static final long serialVersionUID = -3499741368562653529L; private static final long serialVersionUID = -3499741368562653529L;
@OneToMany(mappedBy = "asset") @OneToMany(mappedBy = "asset")
@OrderBy("sortKey ASC")
private List<ItemAttachment<?>> itemAttachments; private List<ItemAttachment<?>> itemAttachments;
@Embedded @Embedded

View File

@ -43,6 +43,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
@ -140,6 +141,7 @@ public class AttachmentList implements Comparable<AttachmentList>,
private LocalizedString description; private LocalizedString description;
@OneToMany(mappedBy = "attachmentList") @OneToMany(mappedBy = "attachmentList")
@OrderBy("sortKey ASC")
@RecursivePermissions(privileges = {AssetPrivileges.EDIT, @RecursivePermissions(privileges = {AssetPrivileges.EDIT,
AssetPrivileges.DELETE, AssetPrivileges.DELETE,
AssetPrivileges.VIEW}) AssetPrivileges.VIEW})

View File

@ -56,6 +56,8 @@ import javax.persistence.FetchType;
import org.hibernate.envers.NotAudited; import org.hibernate.envers.NotAudited;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import javax.persistence.OrderBy;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
@ -586,6 +588,7 @@ public class ContentItem extends CcmObject implements Serializable {
private String ancestors; private String ancestors;
@OneToMany(mappedBy = "item", fetch = FetchType.LAZY) @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
@OrderBy("order ASC")
private List<AttachmentList> attachments; private List<AttachmentList> attachments;
@OneToOne() @OneToOne()

View File

@ -48,6 +48,8 @@ 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 javax.persistence.OrderBy;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
@ -180,6 +182,7 @@ public class ContentSection extends CcmApplication implements Serializable {
private Locale defaultLocale; private Locale defaultLocale;
@OneToMany(mappedBy = "contentSection") @OneToMany(mappedBy = "contentSection")
@OrderBy("contentItemClass ASC")
private List<ContentType> contentTypes = new ArrayList<>(); private List<ContentType> contentTypes = new ArrayList<>();
@OneToMany @OneToMany

View File

@ -39,6 +39,7 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
@ -90,6 +91,7 @@ public class MultiPartArticle extends ContentItem implements Serializable {
@OneToMany @OneToMany
@JoinColumn(name = "MULTIPART_ARTICLE_ID") @JoinColumn(name = "MULTIPART_ARTICLE_ID")
@OrderBy("rank ASC")
private List<MultiPartArticleSection> sections; private List<MultiPartArticleSection> sections;
public MultiPartArticle() { public MultiPartArticle() {

View File

@ -227,6 +227,7 @@ public class Category extends CcmObject implements Serializable, Portable {
*/ */
@RecursivePermissions @RecursivePermissions
@OneToMany(mappedBy = "category", fetch = FetchType.LAZY) @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
@OrderBy("objectOrder ASC")
@XmlElementWrapper(name = "objects", namespace = CAT_XML_NS) @XmlElementWrapper(name = "objects", namespace = CAT_XML_NS)
@JsonIgnore @JsonIgnore
private List<Categorization> objects; private List<Categorization> objects;

View File

@ -113,6 +113,7 @@ public class CcmObject implements Identifiable, Serializable {
* Permissions granted on this object. * Permissions granted on this object.
*/ */
@OneToMany(mappedBy = "object", fetch = FetchType.LAZY) @OneToMany(mappedBy = "object", fetch = FetchType.LAZY)
@OrderBy("grantedPrivilege ASC")
@IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"}) @IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"})
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS) @XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
@XmlElement(name = "permission", namespace = CORE_XML_NS) @XmlElement(name = "permission", namespace = CORE_XML_NS)
@ -123,6 +124,7 @@ public class CcmObject implements Identifiable, Serializable {
* Categories which have been assigned to this {@code CcmObject}. * Categories which have been assigned to this {@code CcmObject}.
*/ */
@OneToMany(mappedBy = "categorizedObject", fetch = FetchType.LAZY) @OneToMany(mappedBy = "categorizedObject", fetch = FetchType.LAZY)
@OrderBy("categoryOrder ASC")
@XmlElementWrapper(name = "categories", namespace = CORE_XML_NS) @XmlElementWrapper(name = "categories", namespace = CORE_XML_NS)
@XmlElement(name = "category", namespace = CORE_XML_NS) @XmlElement(name = "category", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -21,12 +21,19 @@ package org.libreccm.formbuilder;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -22,6 +22,7 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -29,6 +30,8 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.OrderBy;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
@ -52,6 +55,7 @@ public class Widget extends Component implements Serializable {
// private WidgetLabel label; // private WidgetLabel label;
@OneToMany(mappedBy = "widget") @OneToMany(mappedBy = "widget")
@OrderBy("className ASC")
private List<Listener> listeners; private List<Listener> listeners;
public String getParameterName() { public String getParameterName() {

View File

@ -69,9 +69,11 @@ public class Message extends CcmObject implements Serializable {
private Message inReplyTo; private Message inReplyTo;
@OneToMany(mappedBy = "inReplyTo") @OneToMany(mappedBy = "inReplyTo")
@OrderBy("sent ASC")
private List<Message> replies; private List<Message> replies;
@OneToMany(mappedBy = "message") @OneToMany(mappedBy = "message")
@OrderBy("title ASC")
private List<Attachment> attachments; private List<Attachment> attachments;
public User getSender() { public User getSender() {

View File

@ -47,6 +47,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
@ -240,6 +241,7 @@ public class PageModel implements Serializable {
* The components of the page described by this {@code PageModel}. * The components of the page described by this {@code PageModel}.
*/ */
@OneToMany(mappedBy = "pageModel") @OneToMany(mappedBy = "pageModel")
@OrderBy("key ASC")
private List<ComponentModel> components; private List<ComponentModel> components;
public PageModel() { public PageModel() {

View File

@ -24,6 +24,7 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -31,6 +32,8 @@ import java.util.List;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.OrderBy;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
@ -45,6 +48,7 @@ public class Portal extends Resource implements Serializable {
private boolean template; private boolean template;
@OneToMany(mappedBy = "portal") @OneToMany(mappedBy = "portal")
@OrderBy("cellNumber ASC, sortKey ASC")
private List<Portlet> portlets; private List<Portlet> portlets;
public Portal() { public Portal() {

View File

@ -46,6 +46,7 @@ public class Initalizer implements Serializable {
private String className; private String className;
@ManyToOne @ManyToOne
@OrderBy("className ASC")
@JoinColumn(name = "REQUIRED_BY_ID") @JoinColumn(name = "REQUIRED_BY_ID")
private Initalizer requiredBy; private Initalizer requiredBy;

View File

@ -23,19 +23,29 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static org.libreccm.core.CoreConstants.CORE_XML_NS; import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/** /**
* A group is basically a collection of users. * A group is basically a collection of users.
* *

View File

@ -172,6 +172,7 @@ public class Role implements Serializable, Portable {
* Permissions granted to the role. * Permissions granted to the role.
*/ */
@OneToMany(mappedBy = "grantee") @OneToMany(mappedBy = "grantee")
@OrderBy("grantedPrivilege ASC")
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS) @XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
@XmlElement(name = "permission", namespace = CORE_XML_NS) @XmlElement(name = "permission", namespace = CORE_XML_NS)
@JsonIgnore @JsonIgnore

View File

@ -33,6 +33,7 @@ import javax.persistence.Entity;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
@ -94,6 +95,7 @@ public class Site extends CcmObject {
* The applications mapped to this site. * The applications mapped to this site.
*/ */
@OneToMany(mappedBy = "site") @OneToMany(mappedBy = "site")
@OrderBy("primaryUrl")
private List<SiteAwareApplication> applications; private List<SiteAwareApplication> applications;
public Site() { public Site() {