Skip to content

Commit

Permalink
add link for credential back to hub/peripheral
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidd authored and mcalmer committed Jan 31, 2025
1 parent 22380e1 commit 65a3614
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@

package com.redhat.rhn.domain.credentials;

import com.suse.manager.model.hub.IssPeripheral;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToOne;
import javax.persistence.Transient;

@Entity
@DiscriminatorValue(CredentialsType.Label.HUB_SCC)
public class HubSCCCredentials extends PasswordBasedCredentials {


private IssPeripheral issPeripheral;
private String peripheralUrl;

// No args constructor for hibernate
Expand All @@ -37,6 +43,15 @@ protected HubSCCCredentials(String usernameIn, String passwordIn, String periphe
this.peripheralUrl = peripheralUrlIn;
}

@OneToOne(mappedBy = "mirrorCredentials", fetch = FetchType.LAZY)
public IssPeripheral getIssPeripheral() {
return issPeripheral;
}

public void setIssPeripheral(IssPeripheral issPeripheralIn) {
this.issPeripheral = issPeripheralIn;
}

@Override
@Transient
public CredentialsType getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@

package com.redhat.rhn.domain.credentials;

import com.suse.manager.model.hub.IssHub;

import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToOne;
import javax.persistence.Transient;

@Entity
@DiscriminatorValue(CredentialsType.Label.SCC)
public class SCCCredentials extends RemoteCredentials {

private IssHub issHub;

// No args constructor for hibernate
protected SCCCredentials() {
}
Expand All @@ -41,6 +47,15 @@ public CredentialsType getType() {
return CredentialsType.SCC;
}

@OneToOne(mappedBy = "mirrorCredentials", fetch = FetchType.LAZY)
public IssHub getIssHub() {
return issHub;
}

public void setIssHub(IssHub issHubIn) {
this.issHub = issHubIn;
}

/**
* @return if this credential is the current primary scc credential which
* is at the moment denoted by having the url field set.
Expand Down
4 changes: 2 additions & 2 deletions java/code/src/com/suse/manager/model/hub/IssHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

Expand Down Expand Up @@ -96,7 +96,7 @@ public String getRootCa() {
* Get the mirror credentials.
* @return the credentials
*/
@ManyToOne(targetEntity = SCCCredentials.class)
@OneToOne(targetEntity = SCCCredentials.class)
@JoinColumn(name = "mirror_creds_id")
public SCCCredentials getMirrorCredentials() {
return mirrorCredentials;
Expand Down
4 changes: 2 additions & 2 deletions java/code/src/com/suse/manager/model/hub/IssPeripheral.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

Expand Down Expand Up @@ -105,7 +105,7 @@ public String getRootCa() {
* Get the mirror credentials.
* @return the credentials
*/
@ManyToOne(targetEntity = HubSCCCredentials.class)
@OneToOne(targetEntity = HubSCCCredentials.class)
@JoinColumn(name = "mirror_creds_id")
public HubSCCCredentials getMirrorCredentials() {
return mirrorCredentials;
Expand Down

0 comments on commit 65a3614

Please sign in to comment.