-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9375 from mcalmer/issv3-hibernate-schema
Issv3 hibernate schema
- Loading branch information
Showing
6 changed files
with
730 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* This software is licensed to you under the GNU General Public License, | ||
* version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
* implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
* along with this software; if not, see | ||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
*/ | ||
package com.suse.manager.model.hub; | ||
|
||
import com.redhat.rhn.common.hibernate.HibernateFactory; | ||
import com.redhat.rhn.domain.channel.Channel; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class HubFactory extends HibernateFactory { | ||
|
||
private static final Logger LOG = LogManager.getLogger(HubFactory.class); | ||
|
||
@Override | ||
protected Logger getLogger() { | ||
return LOG; | ||
} | ||
|
||
/** | ||
* Save a {@link IssHub} object | ||
* @param issHubIn object to save | ||
*/ | ||
public void save(IssHub issHubIn) { | ||
saveObject(issHubIn); | ||
} | ||
|
||
/** | ||
* Save a {@link IssPeripheral} object | ||
* @param issPeripheralIn object to save | ||
*/ | ||
public void save(IssPeripheral issPeripheralIn) { | ||
saveObject(issPeripheralIn); | ||
} | ||
|
||
/** | ||
* Save a {@link IssPeripheralChannels} object | ||
* @param issPeripheralChannelsIn object to save | ||
*/ | ||
public void save(IssPeripheralChannels issPeripheralChannelsIn) { | ||
saveObject(issPeripheralChannelsIn); | ||
} | ||
|
||
/** | ||
* Lookup {@link IssHub} object by its FQDN | ||
* @param fqdnIn the fqdn | ||
* @return return {@link IssHub} with the given FQDN or empty | ||
*/ | ||
public Optional<IssHub> lookupIssHubByFqdn(String fqdnIn) { | ||
return getSession().createQuery("FROM IssHub WHERE fqdn = :fqdn", IssHub.class) | ||
.setParameter("fqdn", fqdnIn) | ||
.uniqueResultOptional(); | ||
} | ||
|
||
/** | ||
* Lookup {@link IssPeripheral} object by its FQDN | ||
* @param fqdnIn the fqdn | ||
* @return return {@link IssPeripheral} with the given FQDN or empty | ||
*/ | ||
public Optional<IssPeripheral> lookupIssPeripheralByFqdn(String fqdnIn) { | ||
return getSession().createQuery("FROM IssPeripheral WHERE fqdn = :fqdn", IssPeripheral.class) | ||
.setParameter("fqdn", fqdnIn) | ||
.uniqueResultOptional(); | ||
} | ||
|
||
/** | ||
* List {@link IssPeripheralChannels} objects which reference the given {@link Channel} | ||
* @param channelIn the channel | ||
* @return return the list of {@link IssPeripheralChannels} objects | ||
*/ | ||
public List<IssPeripheralChannels> listIssPeripheralChannelsByChannels(Channel channelIn) { | ||
return getSession() | ||
.createQuery("FROM IssPeripheralChannels WHERE channel = :channel", IssPeripheralChannels.class) | ||
.setParameter("channel", channelIn) | ||
.list(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* This software is licensed to you under the GNU General Public License, | ||
* version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
* implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
* along with this software; if not, see | ||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
*/ | ||
package com.suse.manager.model.hub; | ||
|
||
import com.redhat.rhn.domain.BaseDomainHelper; | ||
import com.redhat.rhn.domain.credentials.SCCCredentials; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "suseISSHub") | ||
public class IssHub extends BaseDomainHelper { | ||
private Long id; | ||
private String fqdn; | ||
private String rootCa; | ||
private SCCCredentials mirrorCredentials; | ||
|
||
protected IssHub() { | ||
// Default empty Constructor for Hibernate | ||
} | ||
|
||
/** | ||
* Constructor | ||
* @param fqdnIn the FQDN of the Hub Server | ||
*/ | ||
public IssHub(String fqdnIn) { | ||
this (fqdnIn, null); | ||
} | ||
|
||
/** | ||
* Constructor | ||
* @param fqdnIn the FQDN of the Hub Server | ||
* @param rootCaIn the root CA used by the Hub Server | ||
*/ | ||
public IssHub(String fqdnIn, String rootCaIn) { | ||
fqdn = fqdnIn; | ||
rootCa = rootCaIn; | ||
mirrorCredentials = null; | ||
} | ||
|
||
/** | ||
* @return return the ID | ||
*/ | ||
@Id | ||
@Column(name = "id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Get the FQDN of the Hub Server | ||
* @return return the FQDN of the Hub Server | ||
*/ | ||
@Column(name = "fqdn", unique = true) | ||
public String getFqdn() { | ||
return fqdn; | ||
} | ||
|
||
/** | ||
* Get the configured Root CA | ||
* @return return the root ca | ||
*/ | ||
@Column(name = "root_ca") | ||
public String getRootCa() { | ||
return rootCa; | ||
} | ||
|
||
/** | ||
* Get the mirror credentials. | ||
* @return the credentials | ||
*/ | ||
@ManyToOne(targetEntity = SCCCredentials.class) | ||
@JoinColumn(name = "mirror_creds_id") | ||
public SCCCredentials getMirrorCredentials() { | ||
return mirrorCredentials; | ||
} | ||
|
||
/* | ||
* will be autogenerated | ||
*/ | ||
protected void setId(Long idIn) { | ||
id = idIn; | ||
} | ||
|
||
/** | ||
* @param fqdnIn the FQDN | ||
*/ | ||
public void setFqdn(String fqdnIn) { | ||
fqdn = fqdnIn; | ||
} | ||
|
||
/** | ||
* @param rootCaIn the root ca | ||
*/ | ||
public void setRootCa(String rootCaIn) { | ||
rootCa = rootCaIn; | ||
} | ||
|
||
/** | ||
* @param mirrorCredentialsIn the mirror credentials | ||
*/ | ||
public void setMirrorCredentials(SCCCredentials mirrorCredentialsIn) { | ||
mirrorCredentials = mirrorCredentialsIn; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object oIn) { | ||
if (this == oIn) { | ||
return true; | ||
} | ||
if (!(oIn instanceof IssHub issHub)) { | ||
return false; | ||
} | ||
return Objects.equals(getFqdn(), issHub.getFqdn()) && | ||
Objects.equals(getRootCa(), issHub.getRootCa()) && | ||
Objects.equals(getMirrorCredentials(), issHub.getMirrorCredentials()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getFqdn(), getRootCa(), getMirrorCredentials()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "IssHub{" + | ||
"id=" + id + | ||
", fqdn='" + fqdn + '\'' + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.