public static InstrumentModelDto asDto(@Nonnull InstrumentModel from) { InstrumentModelDto dto = new InstrumentModelDto(); dto.setId(from.getId()); dto.setPlatformType(from.getPlatformType().name()); dto.setDescription(from.getDescription()); dto.setAlias(from.getAlias()); dto.setNumContainers(from.getNumContainers()); dto.setInstrumentType(from.getInstrumentType().name()); if (from.getPositions() != null) { dto.setPositions(from.getPositions().stream().map(InstrumentPosition::getAlias).collect(Collectors.toList())); } return dto; }
@Override public int hashCode() { if (getId() != InstrumentModel.UNSAVED_ID) { return getId().intValue(); } else { final int PRIME = 37; int hashcode = -1; if (getPlatformType() != null) hashcode = PRIME * hashcode + getPlatformType().hashCode(); if (getDescription() != null) hashcode = PRIME * hashcode + getDescription().hashCode(); return hashcode; } }
InstrumentPosition position = null; if (!isStringEmptyOrNull(positionName)) { position = target.getSequencer().getInstrumentModel().getPositions().stream() .filter(pos -> positionName.equals(pos.getAlias())) .findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("Unknown position '%s' for platform '%s'", positionName, target.getSequencer().getInstrumentModel().getAlias())));
if (experiment.getInstrumentModel() != null && experiment.getInstrumentModel().getPlatformType().getSraName() != null) { Element platform = xml.getOwnerDocument().createElementNS(null, "PLATFORM"); Element type = xml.getOwnerDocument().createElementNS(null, experiment.getInstrumentModel().getPlatformType().getSraName()); platform.appendChild(type); model.setTextContent(experiment.getInstrumentModel().getAlias()); type.appendChild(model); xml.appendChild(platform);
private InstrumentPosition findPosition(long id, Instrument instrument) { return instrument.getInstrumentModel().getPositions().stream() .filter(p -> p.getId() == id) .findFirst().orElse(null); }
public boolean isFull() { return getRunPositions().size() >= sequencer.getInstrumentModel().getNumContainers(); }
} else if (arrayRun.getInstrument().getInstrumentModel().getInstrumentType() != InstrumentType.ARRAY_SCANNER) { errors.add(new ValidationError("instrument", "Instrument must be an array scanner"));
dto.setPlatformType(from.getSequencer().getInstrumentModel().getPlatformType().getKey()); } else { dto.setPlatformType("");
/** * Equivalency is based on id if set, otherwise on name, description and creation date. */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof InstrumentModel)) return false; InstrumentModel them = (InstrumentModel) obj; // If not saved, then compare resolved actual objects. Otherwise // just compare IDs. if (getId() == InstrumentModel.UNSAVED_ID || them.getId() == InstrumentModel.UNSAVED_ID) { return getPlatformType().equals(them.getPlatformType()) && getDescription().equals(them.getDescription()); } else { return getId().longValue() == them.getId().longValue(); } }
@Override public String toString() { return "AbstractInstrument [id=" + id + ", name=" + name + ", instrumentModel=" + instrumentModel.getId() + ", serialNumber=" + serialNumber + ", dateCommissioned=" + dateCommissioned + ", dateDecommissioned=" + dateDecommissioned + ", upgradedInstrument=" + (upgradedInstrument == null ? null : upgradedInstrument.getId()) + "]"; }
private void validateChanges(Run before, Run changed) throws IOException { List<ValidationError> errors = new ArrayList<>(); if (!changed.getHealth().isDone()) { changed.setCompletionDate(null); } else if (changed.getCompletionDate() == null) { errors.add(new ValidationError("completionDate", "Completion date must be provided for finished run")); } if (before != null) { if (before.getCompletionDate() != null && changed.getCompletionDate() != null && !changed.getCompletionDate().equals(before.getCompletionDate()) && !authorizationManager.isAdminUser()) { errors.add(new ValidationError("completionDate", "Only admin may change completion date")); } if (before.getStartDate() != null && changed.getStartDate() != null && !changed.getStartDate().equals(before.getStartDate()) && !authorizationManager.isAdminUser()) { errors.add(new ValidationError("completionDate", "Only admin may change start date")); } } InstrumentModel platform = changed.getSequencer().getInstrumentModel(); for (RunPosition position : changed.getRunPositions()) { if (position.getPosition() != null && !platform.getPositions().contains(position.getPosition())) { errors.add(new ValidationError( String.format("Platform %s does not have a position %s", platform.getAlias(), position.getPosition()))); } } if (!errors.isEmpty()) { throw new ValidationException(errors); } }
@Override public Set<InstrumentPosition> getOutOfServicePositions() { if (isOutOfService()) { return getInstrumentModel().getPositions(); } return getInstrumentModel().getPositions().stream() .filter(pos -> getServiceRecords().stream().anyMatch(sr -> sr.isOutOfService() && sr.getEndTime() == null && sr.getStartTime() != null && sr.getStartTime().before(new Date()) && sr.getPosition().getAlias().equals(pos.getAlias()))) .collect(Collectors.toSet()); }
@Override public Collection<SequencingParameters> getForInstrumentModel(Long instrumentModelId) throws IOException { if (instrumentModelId == null) { return Collections.emptyList(); } Collection<SequencingParameters> results = new ArrayList<>(); for (SequencingParameters sp : sequencingParametersDao.getSequencingParameters()) { if (sp.getInstrumentModel().getId() == instrumentModelId) { results.add(sp); } } return results; }
@Override public SequencingContainerModel find(InstrumentModel instrumentModel, String search, int partitionCount) { SequencingContainerModel model; Criteria criteria = currentSession().createCriteria(SequencingContainerModel.class); criteria.createAlias("instrumentModels", "instrumentModel"); criteria.add(Restrictions.eq("instrumentModel.id", instrumentModel.getId())); criteria.add(Restrictions.eq("partitionCount", partitionCount)); if (LimsUtils.isStringEmptyOrNull(search)) { criteria.add(Restrictions.eq("fallback", true)); model = (SequencingContainerModel) criteria.uniqueResult(); } else { criteria.add(Restrictions.or(Restrictions.eq("alias", search), Restrictions.eq("identificationBarcode", search))); model = (SequencingContainerModel) criteria.uniqueResult(); if (model == null) { // remove search restriction and get fallback option if search did not retrieve anything Criteria fallback = currentSession().createCriteria(SequencingContainerModel.class); fallback.createAlias("instrumentModels", "instrumentModel"); fallback.add(Restrictions.eq("instrumentModel.id", instrumentModel.getId())); fallback.add(Restrictions.eq("partitionCount", partitionCount)); fallback.add(Restrictions.eq("fallback", true)); model = (SequencingContainerModel) fallback.uniqueResult(); } } return model; }
private boolean updateSequencingParameters(final Run target, User user, Predicate<SequencingParameters> filterParameters, final Instrument sequencer) throws IOException { // If the sequencing parameters haven't been updated by a human, see if we can find exactly one that matches. if (!target.didSomeoneElseChangeColumn("parameters", user)) { List<SequencingParameters> possibleParameters = sequencingParametersService.getForInstrumentModel(sequencer.getInstrumentModel().getId()).stream() .filter(parameters -> !parameters.getName().startsWith("Custom")).filter(filterParameters).collect(Collectors.toList()); if (possibleParameters.size() == 1) { if (target.getSequencingParameters() == null || possibleParameters.get(0).getId() != target.getSequencingParameters().getId()) { target.setSequencingParameters(possibleParameters.get(0)); return true; } } } return false; }
experiment.setInstrumentModel(platformService.get(experiment.getInstrumentModel().getId())); experiment.setLibrary(libraryService.get(experiment.getLibrary().getId())); experiment.setStudy(studyService.get(experiment.getStudy().getId())); original.setDescription(experiment.getDescription()); original.setName(experiment.getName()); original.setInstrumentModel(platformService.get(experiment.getInstrumentModel().getId())); original.setLibrary(libraryService.get(experiment.getLibrary().getId())); original.setStudy(studyService.get(experiment.getStudy().getId()));