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
14 changes: 7 additions & 7 deletions src/main/java/uk/ac/sanger/sccp/stan/GraphQLMutation.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public class GraphQLMutation extends BaseGraphQLResource {
Logger log = LoggerFactory.getLogger(GraphQLMutation.class);
final AuthService authService;
final IRegisterService<RegisterRequest> registerService;
final IRegisterService<BlockRegisterRequest> blockRegisterService;
final IRegisterService<SectionRegisterRequest> sectionRegisterService;
final PlanService planService;
final LabelPrintService labelPrintService;
Expand Down Expand Up @@ -115,7 +115,7 @@ public class GraphQLMutation extends BaseGraphQLResource {
@Autowired
public GraphQLMutation(ObjectMapper objectMapper, AuthenticationComponent authComp,
AuthService authService,
IRegisterService<RegisterRequest> registerService,
IRegisterService<BlockRegisterRequest> blockRegisterService,
IRegisterService<SectionRegisterRequest> sectionRegisterService,
PlanService planService, LabelPrintService labelPrintService,
ConfirmOperationService confirmOperationService,
Expand Down Expand Up @@ -150,7 +150,7 @@ public GraphQLMutation(ObjectMapper objectMapper, AuthenticationComponent authCo
ProteinPanelAdminService proteinPanelAdminService) {
super(objectMapper, authComp, userRepo);
this.authService = authService;
this.registerService = registerService;
this.blockRegisterService = blockRegisterService;
this.sectionRegisterService = sectionRegisterService;
this.planService = planService;
this.labelPrintService = labelPrintService;
Expand Down Expand Up @@ -245,12 +245,12 @@ public DataFetcher<LoginResult> userSelfRegister(final User.Role role) {
};
}

public DataFetcher<RegisterResult> register() {
public DataFetcher<RegisterResult> blockRegister() {
return dfe -> {
User user = checkUser(dfe, User.Role.normal);
RegisterRequest request = arg(dfe, "request", RegisterRequest.class);
logRequest("Register", user, request);
return registerService.register(user, request);
BlockRegisterRequest request = arg(dfe, "request", BlockRegisterRequest.class);
logRequest("Block register", user, request);
return blockRegisterService.register(user, request);
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/uk/ac/sanger/sccp/stan/GraphQLProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private RuntimeWiring buildWiring() {
.dataFetcher("registerAsEndUser", graphQLMutation.userSelfRegister(User.Role.enduser)) // internal transaction
.dataFetcher("login", graphQLMutation.logIn())
.dataFetcher("logout", graphQLMutation.logOut())
.dataFetcher("register", transact(graphQLMutation.register()))
.dataFetcher("registerBlocks", transact(graphQLMutation.blockRegister()))
.dataFetcher("plan", transact(graphQLMutation.recordPlan()))
.dataFetcher("printLabware", graphQLMutation.printLabware()) // not transacted
.dataFetcher("confirmOperation", transact(graphQLMutation.confirmOperation()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public Validator<String> externalNameValidator() {
Set<CharacterType> charTypes = EnumSet.of(
CharacterType.ALPHA, CharacterType.DIGIT, CharacterType.HYPHEN,
CharacterType.UNDERSCORE, CharacterType.FULL_STOP
) ;
);
return new StringValidator("External identifier", 3, 64, charTypes);
}

@Bean
public Validator<String> externalBarcodeValidator() {
Set<CharacterType> charTypes = EnumSet.of(
CharacterType.ALPHA, CharacterType.DIGIT, CharacterType.HYPHEN,
CharacterType.UNDERSCORE
) ;
CharacterType.UNDERSCORE, CharacterType.FULL_STOP
);
return new StringValidator("External barcode", 3, 32, charTypes);
}

Expand Down
24 changes: 23 additions & 1 deletion src/main/java/uk/ac/sanger/sccp/stan/model/Sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Sample {
private Tissue tissue;
@ManyToOne
private BioState bioState;
private Integer blockHighestSection;

public Sample() {}

Expand Down Expand Up @@ -62,6 +63,24 @@ public void setBioState(BioState bioState) {
this.bioState = bioState;
}

public Integer getBlockHighestSection() {
return this.blockHighestSection;
}

public void setBlockHighestSection(Integer blockHighestSection) {
this.blockHighestSection = blockHighestSection;
}

public boolean isBlock() {
return blockHighestSection != null;
}

public static Sample newBlock(Integer id, Tissue tissue, BioState bs, Integer blockHighestSection) {
Sample sample = new Sample(id, null, tissue, bs);
sample.setBlockHighestSection(blockHighestSection);
return sample;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -70,7 +89,9 @@ public boolean equals(Object o) {
return (Objects.equals(this.id, that.id)
&& Objects.equals(this.section, that.section)
&& Objects.equals(this.tissue, that.tissue)
&& Objects.equals(this.bioState, that.bioState));
&& Objects.equals(this.bioState, that.bioState)
&& Objects.equals(this.blockHighestSection, that.blockHighestSection)
);
}

@Override
Expand All @@ -85,6 +106,7 @@ public String toString() {
.addRepr("section", section)
.add("tissue", tissue)
.add("bioState", bioState)
.addIfNotNull("blockHighestSection", blockHighestSection)
.toString();
}
}
34 changes: 3 additions & 31 deletions src/main/java/uk/ac/sanger/sccp/stan/model/Slot.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @author dr6
*/
@Entity
@SecondaryTable(name = "block_info", pkJoinColumns = @PrimaryKeyJoinColumn(name = "slot_id"))
public class Slot {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -25,22 +24,14 @@ public class Slot {
@JoinTable(name = "slot_sample", inverseJoinColumns = @JoinColumn(name="sample_id"))
private List<Sample> samples;

@Column(table = "block_info", name = "sample_id")
private Integer blockSampleId;
@Column(table = "block_info", name = "highest_section")
private Integer blockHighestSection;

public Slot() {
this.samples = new ArrayList<>();
}

public Slot(Integer id, Integer labwareId, Address address, List<Sample> samples, Integer blockSampleId,
Integer blockHighestSection) {
public Slot(Integer id, Integer labwareId, Address address, List<Sample> samples) {
this.id = id;
this.labwareId = labwareId;
this.address = address;
this.blockSampleId = blockSampleId;
this.blockHighestSection = blockHighestSection;
setSamples(samples);
}

Expand Down Expand Up @@ -83,24 +74,8 @@ public void addSample(Sample sample) {
this.samples.add(sample);
}

public Integer getBlockSampleId() {
return this.blockSampleId;
}

public void setBlockSampleId(Integer blockSampleId) {
this.blockSampleId = blockSampleId;
}

public Integer getBlockHighestSection() {
return this.blockHighestSection;
}

public void setBlockHighestSection(Integer blockHighestSection) {
this.blockHighestSection = blockHighestSection;
}

public boolean isBlock() {
return (this.blockSampleId != null);
return (this.samples.stream().anyMatch(Sample::isBlock));
}

@Override
Expand All @@ -112,8 +87,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.address, that.address)
&& Objects.equals(this.labwareId, that.labwareId)
&& Objects.equals(this.samples, that.samples)
&& Objects.equals(this.blockSampleId, that.blockSampleId)
&& Objects.equals(this.blockHighestSection, that.blockHighestSection));
);
}

@Override
Expand All @@ -128,8 +102,6 @@ public String toString() {
.add("labwareId", labwareId)
.add("address", address)
.add("samples", samples)
.add("blockSampleId", blockSampleId)
.add("blockHighestSection", blockHighestSection)
.toString();
}
}
3 changes: 3 additions & 0 deletions src/main/java/uk/ac/sanger/sccp/stan/repo/LabwareRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ default Labware getByBarcode(final String barcode) throws EntityNotFoundExceptio
@Query("select barcode from Labware where barcode in (?1)")
Set<String> findBarcodesByBarcodeIn(Collection<String> barcodes);

@Query("select externalBarcode from Labware where externalBarcode in (?1)")
Set<String> findExternalBarcodesIn(Collection<String> barcodes);

default Labware getById(final Integer id) throws EntityNotFoundException {
return findById(id).orElseThrow(() -> new EntityNotFoundException("No labware found with id "+id));
}
Expand Down
Loading
Loading