Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.orph2020.pst.common.json;

import jakarta.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;


@Embeddable
public class OpticalTelescopeDataId implements Serializable {

private String proposalID;
private String observationID;

public OpticalTelescopeDataId() {
}

public OpticalTelescopeDataId(String proposalID, String observationID) {
this.proposalID = proposalID;
this.observationID = observationID;
}

public String getProposalID() {
return proposalID;
}

public void setProposalID(String proposalID) {
this.proposalID = proposalID;
}

public String getObservationID() {
return observationID;
}

public void setObservationID(String observationID) {
this.observationID = observationID;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OpticalTelescopeDataId that = (OpticalTelescopeDataId) o;
return Objects.equals(proposalID, that.proposalID) &&
Objects.equals(observationID, that.observationID);
}

@Override
public int hashCode() {
return Objects.hash(proposalID, observationID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// data type for the loading of the optional telescope data.
public class OpticalTelescopeDataLoad {
// the proposal id.
public String proposalID;
private String proposalID;

// the observation id for the telescope data.
public String observationID;
private String observationID;

/**
* the constructor for the data saved within the database for a given
Expand All @@ -18,4 +18,29 @@ public OpticalTelescopeDataLoad(String proposalID, String observationID) {
this.proposalID = proposalID;
this.observationID = observationID;
}

/**
* the default constructor for the data saved within the database for a given
* observation.
*/
public OpticalTelescopeDataLoad() {
this.proposalID = null;
this.observationID = null;
}

public String getProposalID() {
return proposalID;
}

public void setProposalID(String proposalID) {
this.proposalID = proposalID;
}

public String getObservationID() {
return observationID;
}

public void setObservationID(String observationID) {
this.observationID = observationID;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,84 @@
package org.orph2020.pst.common.json;

import jakarta.persistence.*;
import java.util.HashMap;
import java.util.Map;

@Entity
@Table(name = "optical_telescope_data")
public class OpticalTelescopeDataSave {
@EmbeddedId
private OpticalTelescopeDataId primaryKey;

@ElementCollection
@CollectionTable(name = "telescope_choices", joinColumns = {
@JoinColumn(name = "proposal_id", referencedColumnName = "proposalID"),
@JoinColumn(name = "observation_id", referencedColumnName = "observationID")
})

public class OpticalTelescopeDataSave extends OpticalTelescopeDataLoad{
// the new states of the choices.
HashMap<String, String> choices;
@MapKeyColumn(name = "choice_key")
@Column(name = "choice_value")
private Map<String, String> choices;

// the telescope name.
public String telescopeName;
@Column(name = "telescope_name")
private String telescopeName;

// the instrument name.
@Column(name = "instrument_name")
private String instrumentName;

/**
* constructor for the telescope data for saving.
*
* @param proposalID: the proposal id.
* @param observationID: the observation id.
* @param telescopeName: the telescope name.
* @param instrumentName: the instrument name chosen for the choices.
* @param choices: the choices made.
*/
public OpticalTelescopeDataSave(
String proposalID, String observationID, String telescopeName,
HashMap<String, String> choices) {
super(proposalID, observationID);
String instrumentName, HashMap<String, String> choices) {
this.primaryKey = new OpticalTelescopeDataId(proposalID, observationID);
this.telescopeName = telescopeName;
this.instrumentName = instrumentName;
this.choices = choices;
}

public OpticalTelescopeDataSave() {
// No-argument constructor for Hibernate ORM
}

public Map<String, String> getChoices() {
return choices;
}

public void setChoices(Map<String, String> choices) {
this.choices = choices;
}

public void setTelescopeName(String telescopeName) {
this.telescopeName = telescopeName;
}

public void setInstrumentName(String instrumentName) {
this.instrumentName = instrumentName;
}

public String getTelescopeName() {
return telescopeName;
}

public String getInstrumentName() {
return instrumentName;
}

public OpticalTelescopeDataId getPrimaryKey() {
return primaryKey;
}

public void setPrimaryKey(OpticalTelescopeDataId primaryKey) {
this.primaryKey = primaryKey;
}
}