Skip to content
Merged
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
102 changes: 102 additions & 0 deletions src/main/java/uk/ac/sanger/sccp/stan/model/SlotGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package uk.ac.sanger.sccp.stan.model;

import javax.persistence.*;
import java.util.Objects;

import static uk.ac.sanger.sccp.utils.BasicUtils.describe;

/**
* A record that a slot is part of a particular group in a plan.
* @author dr6
*/
@Entity
public class SlotGroup {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

private Integer groupIndex;
@ManyToOne
private Slot slot;
private Integer planId;
private Integer operationId;

public SlotGroup() {} // required by JPA

public SlotGroup(Integer groupIndex, Slot slot, Integer planId) {
this.groupIndex = groupIndex;
this.slot = slot;
this.planId = planId;
}

public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getGroupIndex() {
return this.groupIndex;
}

public void setGroupIndex(Integer groupIndex) {
this.groupIndex = groupIndex;
}

public Slot getSlot() {
return this.slot;
}

public Integer getSlotId() {
return (slot==null ? null : slot.getId());
}

public void setSlot(Slot slot) {
this.slot = slot;
}

public Integer getPlanId() {
return this.planId;
}

public void setPlanId(Integer planId) {
this.planId = planId;
}

public Integer getOperationId() {
return this.operationId;
}

public void setOperationId(Integer operationId) {
this.operationId = operationId;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
SlotGroup that = (SlotGroup) o;
return (Objects.equals(this.id, that.id)
&& Objects.equals(this.groupIndex, that.groupIndex)
&& Objects.equals(this.slot, that.slot)
&& Objects.equals(this.planId, that.planId)
&& Objects.equals(this.operationId, that.operationId));
}

@Override
public int hashCode() {
return (id != null ? id.hashCode() : Objects.hash(groupIndex, slot, planId, operationId));
}

@Override
public String toString() {
return describe(this)
.add("id", id)
.add("groupIndex", groupIndex)
.add("slotId", getSlotId())
.add("planId", planId)
.add("operationId", operationId)
.toString();
}
}
10 changes: 10 additions & 0 deletions src/main/java/uk/ac/sanger/sccp/stan/repo/SlotGroupRepo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package uk.ac.sanger.sccp.stan.repo;

import org.springframework.data.repository.CrudRepository;
import uk.ac.sanger.sccp.stan.model.SlotGroup;

import java.util.List;

public interface SlotGroupRepo extends CrudRepository<SlotGroup, Integer> {
List<SlotGroup> findByPlanId(Integer planId);
}
21 changes: 18 additions & 3 deletions src/main/java/uk/ac/sanger/sccp/stan/request/PlanData.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package uk.ac.sanger.sccp.stan.request;

import uk.ac.sanger.sccp.stan.model.Address;
import uk.ac.sanger.sccp.stan.model.PlanOperation;
import uk.ac.sanger.sccp.utils.BasicUtils;

import java.util.List;
import java.util.Objects;

import static uk.ac.sanger.sccp.utils.BasicUtils.newArrayList;
import static uk.ac.sanger.sccp.utils.BasicUtils.nullToEmpty;

/**
* The data about a previously recorded plan
Expand All @@ -16,15 +18,17 @@ public class PlanData {
private PlanOperation plan;
private List<LabwareFlagged> sources;
private LabwareFlagged destination;
private List<List<Address>> groups;

public PlanData(PlanOperation plan, Iterable<LabwareFlagged> sources, LabwareFlagged destination) {
public PlanData(PlanOperation plan, Iterable<LabwareFlagged> sources, LabwareFlagged destination, List<List<Address>> groups) {
setPlan(plan);
setSources(sources);
setDestination(destination);
setGroups(groups);
}

public PlanData() {
this(null, null, null);
this(null, null, null, null);
}

public PlanOperation getPlan() {
Expand All @@ -51,14 +55,24 @@ public void setDestination(LabwareFlagged destination) {
this.destination = destination;
}

public List<List<Address>> getGroups() {
return this.groups;
}

public void setGroups(List<List<Address>> groups) {
this.groups = nullToEmpty(groups);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PlanData that = (PlanData) o;
return (Objects.equals(this.plan, that.plan)
&& Objects.equals(this.sources, that.sources)
&& Objects.equals(this.destination, that.destination));
&& Objects.equals(this.destination, that.destination)
&& Objects.equals(this.groups, that.groups)
);
}

@Override
Expand All @@ -72,6 +86,7 @@ public String toString() {
.add("plan", plan)
.add("sources", sources)
.add("destination", destination)
.add("groups", groups)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,44 @@
import java.util.Objects;

import static uk.ac.sanger.sccp.utils.BasicUtils.coalesce;
import static uk.ac.sanger.sccp.utils.BasicUtils.nullToEmpty;

/**
* The information about a particular section in a confirmed operation
* @author dr6
*/
public class ConfirmSection {
private Address destinationAddress;
private List<Address> destinationAddresses = List.of();
private Integer sampleId;
private Integer newSection;
private List<Integer> commentIds = List.of();
private String region;
private String thickness;

public ConfirmSection() {}

public ConfirmSection(Address destinationAddress, Integer sampleId, Integer newSection,
List<Integer> commentIds, String region) {
this.destinationAddress = destinationAddress;
this.sampleId = sampleId;
this.newSection = newSection;
public ConfirmSection(List<Address> destinationAddresses, Integer sampleId, Integer newSection,
List<Integer> commentIds) {
setDestinationAddress(destinationAddresses);
setSampleId(sampleId);
setNewSection(newSection);
setCommentIds(commentIds);
this.region = region;
}

public ConfirmSection(Address destinationAddress, Integer sampleId, Integer newSection,
List<Integer> commentIds) {
this(destinationAddress==null ? null : List.of(destinationAddress), sampleId, newSection, commentIds);
}

public ConfirmSection(Address destinationAddress, Integer sampleId, Integer newSection) {
this(destinationAddress, sampleId, newSection, null, null);
this(destinationAddress, sampleId, newSection, null);
}

public Address getDestinationAddress() {
return this.destinationAddress;
public List<Address> getDestinationAddresses() {
return this.destinationAddresses;
}

public void setDestinationAddress(Address destinationAddress) {
this.destinationAddress = destinationAddress;
public void setDestinationAddress(List<Address> destinationAddresses) {
this.destinationAddresses = nullToEmpty(destinationAddresses);
}

public Integer getSampleId() {
Expand All @@ -67,14 +71,6 @@ public void setCommentIds(List<Integer> commentIds) {
this.commentIds = coalesce(commentIds, List.of());
}

public String getRegion() {
return this.region;
}

public void setRegion(String region) {
this.region = region;
}

public String getThickness() {
return this.thickness;
}
Expand All @@ -88,28 +84,26 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConfirmSection that = (ConfirmSection) o;
return (Objects.equals(this.destinationAddress, that.destinationAddress)
return (Objects.equals(this.destinationAddresses, that.destinationAddresses)
&& Objects.equals(this.sampleId, that.sampleId)
&& Objects.equals(this.newSection, that.newSection)
&& Objects.equals(this.commentIds, that.commentIds)
&& Objects.equals(this.region, that.region)
&& Objects.equals(this.thickness, that.thickness)
);
}

@Override
public int hashCode() {
return Objects.hash(destinationAddress, sampleId, newSection);
return Objects.hash(destinationAddresses, sampleId, newSection);
}

@Override
public String toString() {
return BasicUtils.describe("ConfirmSection")
.add("destinationAddress", destinationAddress)
.add("destinationAddresses", destinationAddresses)
.add("sampleId", sampleId)
.add("newSection", newSection)
.add("commentIds", commentIds)
.addRepr("region", region)
.addRepr("thickness", thickness)
.toString();
}
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/uk/ac/sanger/sccp/stan/request/plan/PlanGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package uk.ac.sanger.sccp.stan.request.plan;

import uk.ac.sanger.sccp.stan.model.Address;

import java.util.List;
import java.util.Objects;

import static uk.ac.sanger.sccp.utils.BasicUtils.nullToEmpty;

/**
* @author dr6
*/
public class PlanGroup {
private List<Address> addresses;

public PlanGroup() {
this(null);
}

public PlanGroup(List<Address> addresses) {
setAddresses(addresses);
}

public List<Address> getAddresses() {
return this.addresses;
}

public void setAddresses(List<Address> addresses) {
this.addresses = nullToEmpty(addresses);
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
PlanGroup that = (PlanGroup) o;
return Objects.equals(this.addresses, that.addresses);
}

@Override
public int hashCode() {
return Objects.hash(addresses);
}

@Override
public String toString() {
return this.addresses.toString();
}
}
Loading
Loading