java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml | 18 -
java/code/src/com/redhat/rhn/domain/channel/Channel.java | 96 +++-------
java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml | 10 -
java/code/src/com/redhat/rhn/domain/channel/ContentSource.java | 28 ++
4 files changed, 75 insertions(+), 77 deletions(-)
New commits:
commit 9be16c6e51ee04b455d706a74e5c0f9f703a6807
Author: Shannon Hughes <shughes(a)redhat.com>
Date: Wed May 5 15:59:48 2010 -0400
initial hibernate changes to support many2many relationships of channel to repos
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
index a73cef7..b235027 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml
@@ -70,15 +70,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<one-to-one name="comps" property-ref="channel"
class="com.redhat.rhn.domain.channel.Comps" cascade="all"
lazy="proxy"/>
-
- <set name="contentSources" lazy="true"
table="rhnChannelContentSource"
- cascade="all-delete-orphan" inverse="true">
- <key column="channel_id"/>
- <one-to-many
- class="com.redhat.rhn.domain.channel.ContentSource" />
- </set>
-
-
+
<set name="trustedOrgs" lazy="true"
table="rhnChannelTrust"
cascade="save-update">
<key column="channel_id"/>
@@ -104,6 +96,14 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
column="package_id"/>
</set>
+ <set name="sources" lazy="true"
table="rhnChannelContentSource"
+ cascade="save-update">
+ <key column="channel_id"/>
+ <many-to-many
+ class="com.redhat.rhn.domain.channel.ContentSource"
+ column="source_id"/>
+ </set>
+
<many-to-one name="product"
column="channel_product_id"
class="com.redhat.rhn.domain.channel.ChannelProduct"/>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java
b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
index 7eca2ef..62c89a7 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java
@@ -14,31 +14,30 @@
*/
package com.redhat.rhn.domain.channel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.log4j.Logger;
+
import com.redhat.rhn.domain.BaseDomainHelper;
+import com.redhat.rhn.domain.common.ChecksumType;
import com.redhat.rhn.domain.errata.Errata;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.rhnpackage.Package;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
-import com.redhat.rhn.domain.common.ChecksumType;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.system.IncompatibleArchException;
import com.redhat.rhn.manager.system.SystemManager;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.log4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* Channel
* @version $Rev$
@@ -81,15 +80,14 @@ public class Channel extends BaseDomainHelper implements Comparable {
private String summary;
private Set erratas = new HashSet();
private Set packages = new HashSet();
+ private Set<ContentSource> sources = new HashSet<ContentSource>();
private Set channelFamilies = new HashSet();
private Set distChannelMaps = new HashSet();
private Set trustedOrgs = new HashSet();
private String maintainerName;
private String maintainerEmail;
private String maintainerPhone;
- private String supportPolicy;
- private Set<ContentSource> contentSources = new HashSet();
-
+ private String supportPolicy;
/**
* @param orgIn what org you want to know if it is globally subscribable in
@@ -416,6 +414,23 @@ public class Channel extends BaseDomainHelper implements Comparable
{
public void setPackages(Set packagesIn) {
this.packages = packagesIn;
}
+
+ /**
+ *
+ * @param sourcesIn The set of yum repo sources
+ */
+ public void setSources(Set<ContentSource> sourcesIn) {
+ this.sources = sourcesIn;
+ }
+
+ /**
+ *
+ * @return set of yum repos for this channel
+ */
+ public Set<ContentSource> getSources() {
+ return sources;
+ }
+
/**
* Adds a single package to the channel
@@ -831,49 +846,10 @@ public class Channel extends BaseDomainHelper implements Comparable
{
public boolean containsDistributions() {
return ChannelFactory.containsDistributions(this);
}
-
- /**
- * @return Returns the contentSources.
- */
- public Set<ContentSource> getContentSources() {
- return contentSources;
- }
+
-
- /**
- * @param contentSourcesIn The contentSources to set.
- */
- public void setContentSources(Set<ContentSource> contentSourcesIn) {
- this.contentSources = contentSourcesIn;
- }
-
- /**
- * Set the yum content source, if one is already set, it will be replaced
- * if null or '' is passed in, all content sources will be removed.
- * @param url the url of the yum repo
- * @param labelIn the label of the content source
- */
- public void setYumContentSource(String url, String labelIn) {
- if (StringUtils.isEmpty(url)) {
- if (!this.getContentSources().isEmpty()) {
- this.getContentSources().clear();
- }
- }
- else {
- if (this.getContentSources().isEmpty()) {
- ContentSource cs = new ContentSource();
- cs.setChannel(this);
- cs.setSourceUrl(url);
- cs.setLabel(labelIn);
- cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM);
- this.getContentSources().add(cs);
- }
- else {
- ContentSource cs = this.getContentSources().iterator().next();
- cs.setSourceUrl(url);
- cs.setLabel(labelIn);
- }
- }
+ public void addYumContentSource(ContentSource sourceIn) {
+
ChannelFactory.save(this);
}
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
index 5cfaa97..b17bed7 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
@@ -23,7 +23,15 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<many-to-one
name="type"
class="com.redhat.rhn.domain.channel.ContentSourceType"
- column="type_id"/>
+ column="type_id"/>
+
+ <set name="channels" lazy="true"
table="rhnChannelContentSource"
+ cascade="save-update">
+ <key column="source_id"/>
+ <many-to-many
+ class="com.redhat.rhn.domain.channel.Channel"
+ column="channel_id"/>
+ </set>
</class>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
index 6624c05..44e0e92 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java
@@ -14,9 +14,11 @@
*/
package com.redhat.rhn.domain.channel;
-import com.redhat.rhn.domain.BaseDomainHelper;
-
import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.redhat.rhn.domain.BaseDomainHelper;
/**
* ContentSourceType
@@ -30,9 +32,7 @@ public class ContentSource extends BaseDomainHelper {
private String sourceUrl;
private Date lastSynced;
private String label;
-
-
-
+ private Set<Channel> channels = new HashSet<Channel>();
/**
* @return Returns the label.
*/
@@ -125,7 +125,21 @@ public class ContentSource extends BaseDomainHelper {
public void setLastSynced(Date lastSyncedIn) {
this.lastSynced = lastSyncedIn;
}
-
-
+
+ /**
+ *
+ * @param set of channels this repo is pushed to
+ */
+ public void setChannels(Set<Channel> channelsIn) {
+ this.channels = channelsIn;
+ }
+
+ /**
+ *
+ * @return set of channels that this repo will be pushed to
+ */
+ public Set<Channel> getChannels() {
+ return channels;
+ }
}