Skip to content
Open
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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package uk.ac.sanger.sccp.stan.request.register;

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

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

/**
* A request to register in a piece of labware containing one or more block-samples.
* @author dr6
*/
public class BlockRegisterLabware {
private String labwareType;
private String medium;
private String fixative;
private String externalBarcode;
private List<BlockRegisterSample> samples = List.of();

/** The name of the type of labware containing the block. */
public String getLabwareType() {
return this.labwareType;
}

public void setLabwareType(String labwareType) {
this.labwareType = labwareType;
}

/** The medium used for the tissue. */
public String getMedium() {
return this.medium;
}

public void setMedium(String medium) {
this.medium = medium;
}

/** The fixative used for the tissue. */
public String getFixative() {
return this.fixative;
}

public void setFixative(String fixative) {
this.fixative = fixative;
}

/** The external barcode of the labware. */
public String getExternalBarcode() {
return this.externalBarcode;
}

public void setExternalBarcode(String externalBarcode) {
this.externalBarcode = externalBarcode;
}

/** The samples in this block. */
public List<BlockRegisterSample> getSamples() {
return this.samples;
}

public void setSamples(List<BlockRegisterSample> samples) {
this.samples = nullToEmpty(samples);
}

@Override
public String toString() {
return describe(this)
.add("labwareType", labwareType)
.add("medium", medium)
.add("fixative", fixative)
.add("externalBarcode", externalBarcode)
.add("samples", samples)
.reprStringValues()
.toString();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || o.getClass() != this.getClass()) return false;
BlockRegisterLabware that = (BlockRegisterLabware) o;
return (Objects.equals(this.labwareType, that.labwareType)
&& Objects.equals(this.medium, that.medium)
&& Objects.equals(this.fixative, that.fixative)
&& Objects.equals(this.externalBarcode, that.externalBarcode)
&& Objects.equals(this.samples, that.samples)
);
}

@Override
public int hashCode() {
return Objects.hash(labwareType, medium, fixative, externalBarcode, samples);
}
}
Loading