From 31c83feda77a9ac7432a4f887ae46fd52e81fada Mon Sep 17 00:00:00 2001 From: mbussolotto Date: Fri, 28 Feb 2025 13:41:04 +0100 Subject: [PATCH] annotation for Config* class --- .../common/hibernate/AnnotationRegistry.java | 2 + .../rhn/domain/config/ConfigChannel.hbm.xml | 37 ---------- .../rhn/domain/config/ConfigChannel.java | 34 ++++++++- .../domain/config/ConfigChannelType.hbm.xml | 14 ---- .../rhn/domain/config/ConfigChannelType.java | 30 +++++++- .../rhn/domain/config/ConfigFile.hbm.xml | 26 ------- .../redhat/rhn/domain/config/ConfigFile.java | 20 +++++- .../rhn/domain/config/ConfigFileType.hbm.xml | 9 --- .../rhn/domain/config/ConfigFileType.java | 70 ++++++------------- 9 files changed, 102 insertions(+), 140 deletions(-) delete mode 100644 java/code/src/com/redhat/rhn/domain/config/ConfigChannel.hbm.xml diff --git a/java/code/src/com/redhat/rhn/common/hibernate/AnnotationRegistry.java b/java/code/src/com/redhat/rhn/common/hibernate/AnnotationRegistry.java index 17cf4cf6407d..24ca260db6dd 100644 --- a/java/code/src/com/redhat/rhn/common/hibernate/AnnotationRegistry.java +++ b/java/code/src/com/redhat/rhn/common/hibernate/AnnotationRegistry.java @@ -41,6 +41,7 @@ import com.redhat.rhn.domain.config.ConfigChannel; import com.redhat.rhn.domain.config.ConfigChannelType; import com.redhat.rhn.domain.config.ConfigFile; +import com.redhat.rhn.domain.config.ConfigFileType; import com.redhat.rhn.domain.contentmgmt.ContentEnvironment; import com.redhat.rhn.domain.contentmgmt.ContentFilter; import com.redhat.rhn.domain.contentmgmt.ContentProject; @@ -230,6 +231,7 @@ private AnnotationRegistry() { ConfigChannel.class, ConfigChannelType.class, ConfigFile.class, + ConfigFileType.class, ContentEnvironment.class, ContentFilter.class, ContentProject.class, diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.hbm.xml b/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.hbm.xml deleted file mode 100644 index 97a8f320fe9b..000000000000 --- a/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.hbm.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - protected - - - - - - - - - - - - - - - - - - diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.java b/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.java index 3641a164f15c..4b3ec1b2700e 100644 --- a/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.java +++ b/java/code/src/com/redhat/rhn/domain/config/ConfigChannel.java @@ -23,21 +23,51 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Date; +import java.util.Set; import java.util.SortedSet; +import java.util.TreeSet; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; /** * ConfigChannel - Class representation of the table rhnConfigChannel. */ +@Entity +@Table(name = "rhnConfigChannel") public class ConfigChannel extends BaseDomainHelper implements Identifiable { + @Id + @Column(name = "id") private Long id; - private Org org; + + @Column(name = "name", length = 128) private String name; + + @Column(name = "label", length = 64) private String label; + + @Column(name = "description", length = 1024) private String description; + @ManyToOne + @JoinColumn(name = "org_id") + private Org org; + + @ManyToOne + @JoinColumn(name = "confchan_type_id") private ConfigChannelType configChannelType; - private SortedSet configFiles; + @OneToMany(mappedBy = "configChannel", cascade = CascadeType.ALL, orphanRemoval = true) + @OrderBy("fileType ASC") + private SortedSet configFiles = new TreeSet<>(); + /** * Protected constructor diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.hbm.xml b/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.hbm.xml index 17ae8cfaf0bb..c73448ae7565 100644 --- a/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.hbm.xml @@ -3,20 +3,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - - - - protected - - - - - - - - - diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.java b/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.java index 2ea706f0291a..25cc3a0f4915 100644 --- a/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.java +++ b/java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.java @@ -18,19 +18,43 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; import java.util.Map; import java.util.TreeMap; +import javax.persistence.Cacheable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + + /** * ConfigChannelType - Class representation of the table rhnConfigChannelType. */ +@Entity +@Table(name = "rhnConfigChannelType") +@Cacheable +@Cache(usage = CacheConcurrencyStrategy.READ_ONLY) public class ConfigChannelType extends BaseDomainHelper { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") private Long id; - private String label; - private String name; - private Long priority; + + @Column(name = "label", length = 64) + private String label = ""; + + @Column(name = "name", length = 64) + private String name = ""; + + @Column(name = "priority") + private Long priority = 0L; public static final String NORMAL = "normal"; public static final String LOCAL = "local_override"; diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigFile.hbm.xml b/java/code/src/com/redhat/rhn/domain/config/ConfigFile.hbm.xml index f2083ab76474..b8c07ff53336 100644 --- a/java/code/src/com/redhat/rhn/domain/config/ConfigFile.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/config/ConfigFile.hbm.xml @@ -3,32 +3,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - - - protected - - - - - - - - - - - - - - - - - - - - - diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigFileType.java b/java/code/src/com/redhat/rhn/domain/config/ConfigFileType.java index aa7a5ecf4617..0f3187855210 100644 --- a/java/code/src/com/redhat/rhn/domain/config/ConfigFileType.java +++ b/java/code/src/com/redhat/rhn/domain/config/ConfigFileType.java @@ -14,38 +14,44 @@ */ package com.redhat.rhn.domain.config; +import com.redhat.rhn.domain.BaseDomainHelper; + import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; -import java.io.Serializable; import java.util.Map; import java.util.TreeMap; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + /** * @author Hibernate CodeGenerator */ -public class ConfigFileType implements Serializable { +@Entity +@Table(name = "RHNCONFIGFILETYPE") +public class ConfigFileType extends BaseDomainHelper { /** * Comment for serialVersionUID */ private static final long serialVersionUID = 3816155923541633076L; - /** identifier field */ - private long id; - - /** persistent field */ - private String label; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) // Equivalent to + @Column(name = "ID") + private Long id; - /** persistent field */ - private String name; + @Column(name = "LABEL", length = 64, nullable = false) + private String label; - /** persistent field */ - private java.util.Date created; - - /** persistent field */ - private java.util.Date modified; + @Column(name = "NAME", length = 256, nullable = false) + private String name; public static final String FILE = "file"; public static final String DIR = "directory"; @@ -131,8 +137,8 @@ protected ConfigFileType(java.lang.String inLabel, java.lang.String inName, java.util.Date inCreated, java.util.Date inModified) { this.label = inLabel; this.name = inName; - this.created = inCreated; - this.modified = inModified; + this.setCreated(inCreated); + this.setModified(inModified); } /** @@ -189,38 +195,6 @@ public void setName(java.lang.String inName) { this.name = inName; } - /** - * Get the created date - * @return Date of creation (~4800 BCE, I think) - */ - public java.util.Date getCreated() { - return this.created; - } - - /** - * Set creation date - * @param inCreated new creation date - */ - public void setCreated(java.util.Date inCreated) { - this.created = inCreated; - } - - /** - * Get last modified date - * @return time of last modification - */ - public java.util.Date getModified() { - return this.modified; - } - - /** - * Set date of last modification - * @param inModified modification date - */ - public void setModified(java.util.Date inModified) { - this.modified = inModified; - } - /** * {@inheritDoc} */