Skip to content
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
@@ -1,12 +1,10 @@
package org.orph2020.pst.common.json;

// data type for the loading of the optional telescope data.
public class OpticalTelescopeDataLoad {
// the proposal id.
public String proposalID;
public class OpticalTelescopeDataLoad extends OpticalTelescopeDataProposal {

// 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 @@ -15,7 +13,24 @@ public class OpticalTelescopeDataLoad {
* @param observationID: the observation id.
*/
public OpticalTelescopeDataLoad(String proposalID, String observationID) {
this.proposalID = proposalID;
super(proposalID);
this.observationID = observationID;
}

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

public String getObservationID() {
return observationID;
}

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

/**
* creates a holder for the proposal id only.
*/
public class OpticalTelescopeDataProposal {
// the proposal id
private String proposalID;

// default constructor.
public OpticalTelescopeDataProposal() {
}

/**
* constructor.
*
* @param proposalID the proposal id.
*/
public OpticalTelescopeDataProposal(String proposalID) {
this.proposalID = proposalID;
}

public String getProposalID() {
return proposalID;
}

public void setProposalID(String proposalID) {
this.proposalID = proposalID;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,131 @@
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",
foreignKey = @ForeignKey(
foreignKeyDefinition = "ON DELETE CASCADE")),
@JoinColumn(name = "observation_id",
referencedColumnName = "observationID",
foreignKey = @ForeignKey(
foreignKeyDefinition = "ON DELETE CASCADE"))
})

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;

// the time value
@Column(name = "telescope_time_value")
private String telescopeTimeValue;

@Column(name = "telescope_time_unit")
private String telescopeTimeUnit;

@Column(name = "user_type")
private String userType;

/**
* 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 telescopeTimeValue: the telescope time value.
* @param telescopeTimeUnit: the telescope time unit.
* @param userType: the user type.
* @param choices: the choices made.
*/
public OpticalTelescopeDataSave(
String proposalID, String observationID, String telescopeName,
String instrumentName, String telescopeTimeValue,
String telescopeTimeUnit, String userType,
HashMap<String, String> choices) {
super(proposalID, observationID);
this.primaryKey = new OpticalTelescopeDataId(proposalID, observationID);
this.telescopeName = telescopeName;
this.instrumentName = instrumentName;
this.telescopeTimeUnit = telescopeTimeUnit;
this.telescopeTimeValue = telescopeTimeValue;
this.userType = userType;
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;
}

public String getTelescopeTimeValue() {
return telescopeTimeValue;
}

public void setTelescopeTimeValue(String telescopeTimeValue) {
this.telescopeTimeValue = telescopeTimeValue;
}

public String getTelescopeTimeUnit() {
return telescopeTimeUnit;
}

public void setTelescopeTimeUnit(String telescopeTimeUnit) {
this.telescopeTimeUnit = telescopeTimeUnit;
}

public String getUserType() {
return userType;
}

public void setUserType(String userType) {
this.userType = userType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.orph2020.pst.common.json;

public class OpticalTelescopeDataTableReturn {
// the telescope name.
private String telescopeName;

// the instrument name.
private String instrumentName;

/**
* constructor for the telescope data for saving.
*
* @param telescopeName: the telescope name.
* @param instrumentName: the instrument name chosen for the choices.
*/
public OpticalTelescopeDataTableReturn(
String telescopeName, String instrumentName) {
this.telescopeName = telescopeName;
this.instrumentName = instrumentName;
}

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


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;
}
}