@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()) + "]"; }
@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; }
/** * 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 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; } }
@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; }
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; }
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()));