Skip to content

Commit

Permalink
annotation for Config* class
Browse files Browse the repository at this point in the history
  • Loading branch information
mbussolotto committed Feb 28, 2025
1 parent de2f2ab commit 31c83fe
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -230,6 +231,7 @@ private AnnotationRegistry() {
ConfigChannel.class,
ConfigChannelType.class,
ConfigFile.class,
ConfigFileType.class,
ContentEnvironment.class,
ContentFilter.class,
ContentProject.class,
Expand Down
37 changes: 0 additions & 37 deletions java/code/src/com/redhat/rhn/domain/config/ConfigChannel.hbm.xml

This file was deleted.

34 changes: 32 additions & 2 deletions java/code/src/com/redhat/rhn/domain/config/ConfigChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConfigFile> configFiles;
@OneToMany(mappedBy = "configChannel", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("fileType ASC")
private SortedSet<ConfigFile> configFiles = new TreeSet<>();


/**
* Protected constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.redhat.rhn.domain.config.ConfigChannelType"
table="rhnConfigChannelType" mutable="false">
<cache usage="read-only"/>
<id name="id" type="long" column="id">
<meta attribute="scope-set">protected</meta>
<generator class="assigned" />
</id>
<property name="label" column="label" type="string" length="64" />
<property name="name" column="name" type="string" length="64" />
<property name="priority" column="priority" type="long" />
<property name="created" column="created" type="timestamp" />
<property name="modified" column="modified" type="timestamp" />
</class>

<query name="ConfigChannelType.findByLabel">
<![CDATA[from com.redhat.rhn.domain.config.ConfigChannelType as t where t.label = :label]]>
</query>
Expand Down
30 changes: 27 additions & 3 deletions java/code/src/com/redhat/rhn/domain/config/ConfigChannelType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
26 changes: 0 additions & 26 deletions java/code/src/com/redhat/rhn/domain/config/ConfigFile.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,6 @@
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.redhat.rhn.domain.config.ConfigFile" table="rhnConfigFile"
>
<id name="id" type="long" column="id">
<meta attribute="scope-set">protected</meta>
<generator class="assigned" />
</id>
<property name="created" column="created" type="timestamp" />
<property name="modified" column="modified" type="timestamp" />
<many-to-one name="latestConfigRevision"
class="com.redhat.rhn.domain.config.ConfigRevision"
column="latest_config_revision_id" cascade="none" />
<!-- "cascade=none??" you say? Config Revisions, Config Channels
and Config Files all use stored procedures for insertions
meaning that hibernate doesn't do it intelligently -->
<many-to-one name="configChannel"
class="com.redhat.rhn.domain.config.ConfigChannel"
column="config_channel_id" cascade="none" />
<many-to-one name="configFileName"
class="com.redhat.rhn.domain.config.ConfigFileName"
column="config_file_name_id" cascade="none" />
<many-to-one name="configFileState"
class="com.redhat.rhn.domain.config.ConfigFileState"
column="state_id"/>

</class>

<query name="ConfigFile.findByChannelAndName">
<![CDATA[from com.redhat.rhn.domain.config.ConfigFile as c
where c.configChannel.id = :channel_id
Expand Down
20 changes: 19 additions & 1 deletion java/code/src/com/redhat/rhn/domain/config/ConfigFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,33 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
* ConfigFile - Class representation of the table rhnConfigFile.
*/
@Entity
@Table(name = "rhnConfigFile")
public class ConfigFile extends BaseDomainHelper {

@Id
@Column(name = "id")
private Long id;
@ManyToOne
@JoinColumn(name = "config_channel_id")
private ConfigChannel configChannel;
@ManyToOne
@JoinColumn(name = "config_file_name_id")
private ConfigFileName configFileName;
@ManyToOne
@JoinColumn(name = "state_id")
private ConfigFileState configFileState;
@ManyToOne
@JoinColumn(name = "latest_config_revision_id")
private ConfigRevision latestConfigRevision;
private static Logger log = LogManager.getLogger(ConfigFile.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.redhat.rhn.domain.config.ConfigFileType" table="RHNCONFIGFILETYPE">
<id column="ID" name="id" type="long">
<generator class="native"/>
</id>
<property column="LABEL" length="64" name="label" not-null="true" type="string"/>
<property column="NAME" length="256" name="name" not-null="true" type="string"/>
<property column="CREATED" length="7" name="created" not-null="true" type="timestamp"/>
<property column="MODIFIED" length="7" name="modified" not-null="true" type="timestamp"/>
</class>
<query name="ConfigFileType.findByLabel">
<![CDATA[from com.redhat.rhn.domain.config.ConfigFileType as s where s.label = :label]]>
</query>
Expand Down
70 changes: 22 additions & 48 deletions java/code/src/com/redhat/rhn/domain/config/ConfigFileType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>serialVersionUID</code>
*/
private static final long serialVersionUID = 3816155923541633076L;

/** identifier field */
private long id;

/** persistent field */
private String label;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) // Equivalent to <generator class="native"/>
@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";
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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}
*/
Expand Down

0 comments on commit 31c83fe

Please sign in to comment.