@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 long create(ServiceRecord record) throws IOException { record.setInstrument(instrumentService.get(record.getInstrument().getId())); return serviceRecordDao.save(record); }
@Override public void update(Instrument instrument) throws IOException { authorizationManager.throwIfNonAdmin(); Instrument managed = get(instrument.getId()); applyChanges(managed, instrument); loadChildEntities(managed); save(managed); }
private void loadChildEntities(Instrument instrument) throws IOException { if (instrument.getUpgradedInstrument() != null) { instrument.setUpgradedInstrument(get(instrument.getUpgradedInstrument().getId())); } else { instrument.setUpgradedInstrument(null); } }
private List<InstrumentStatus> map(List<InstrumentPositionStatus> positions) { Map<Long, InstrumentStatus> statusByInstrumentId = new HashMap<>(); for (InstrumentPositionStatus position : positions) { if (!statusByInstrumentId.containsKey(position.getInstrument().getId())) { InstrumentStatus status = new InstrumentStatus(); status.setInstrument(position.getInstrument()); statusByInstrumentId.put(position.getInstrument().getId(), status); } InstrumentStatus existing = statusByInstrumentId.get(position.getInstrument().getId()); if (position.getPosition() == null) { InstrumentPosition nullPosition = new InstrumentPosition(); nullPosition.setAlias("n/a"); nullPosition.setInstrumentModel(position.getInstrument().getInstrumentModel()); position.setPosition(nullPosition); } if (existing.getPositions().containsKey(position.getPosition())) { // there are likely multiple runs with the same start date Run moreRecent = getMoreRecentRun(existing.getPositions().get(position.getPosition()), position.getRun()); existing.getPositions().put(position.getPosition(), moreRecent); } else { existing.getPositions().put(position.getPosition(), position.getRun()); } } return new ArrayList<>(statusByInstrumentId.values()); }
@Override public void update(ServiceRecord record) throws IOException { ServiceRecord managed = get(record.getId()); record.setInstrument(instrumentService.get(managed.getInstrument().getId())); validateChange(record, managed); applyRecordChanges(managed, record); serviceRecordDao.save(managed); }
/** * Loads persisted objects into run fields. Should be called before saving or updating. Loads all fields except for: * <ul> * <li>creator/lastModifier User objects</li> * </ul> * * @param run the Run to load entities into. Must contain at least the IDs of the objects to load. * @throws IOException */ private void loadChildEntities(Run run) throws IOException { if (run.getSequencingParameters() != null) { run.setSequencingParameters(sequencingParametersService.get(run.getSequencingParameters().getId())); } run.setSequencer(instrumentService.get(run.getSequencer().getId())); }
private void loadChildEntities(ArrayRun arrayRun) throws IOException { if (arrayRun.getInstrument() != null) { arrayRun.setInstrument(instrumentService.get(arrayRun.getInstrument().getId())); } if (arrayRun.getArray() != null) { Array array = arrayService.get(arrayRun.getArray().getId()); if (array == null) { // providing a way to detect "array not found" in validation arrayRun.getArray().setAlias(null); } else { arrayRun.setArray(array); } } }
public static InstrumentDto asDto(@Nonnull Instrument from) { InstrumentDto dto = new InstrumentDto(); dto.setId(from.getId()); dto.setDateCommissioned(formatDate(from.getDateCommissioned())); dto.setDateDecommissioned(formatDate(from.getDateDecommissioned())); dto.setName(from.getName()); dto.setInstrumentModel(asDto(from.getInstrumentModel())); dto.setSerialNumber(from.getSerialNumber()); if (from.getDateDecommissioned() == null) { if (from.isOutOfService()) { dto.setStatus("Out of Service"); } else { dto.setStatus("Production"); } } else if (from.getUpgradedInstrument() != null) { dto.setStatus("Upgraded"); } else { dto.setStatus("Retired"); } return dto; }
public static ContainerDto asDto(@Nonnull SequencerPartitionContainer from, boolean includePartitions, boolean includePoolContents) { ContainerDto dto = new ContainerDto(); dto.setId(from.getId()); dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setModel(asDto(from.getModel())); Run lastRun = from.getLastRun(); if (lastRun != null) { dto.setLastRunAlias(lastRun.getAlias()); dto.setLastRunId(lastRun.getId()); dto.setLastSequencerId(lastRun.getSequencer().getId()); dto.setLastSequencerName(lastRun.getSequencer().getName()); } if (from.getLastModified() != null) { dto.setLastModified(formatDateTime(from.getLastModified())); } if (from.getClusteringKit() != null) { dto.setClusteringKit(asDto(from.getClusteringKit())); } if (from.getMultiplexingKit() != null) { dto.setMultiplexingKit(asDto(from.getMultiplexingKit())); } if (includePartitions) { dto.setPartitions(asPartitionDtos(from.getPartitions(), includePoolContents)); } return dto; }
public static ArrayRunDto asDto(@Nonnull ArrayRun from) { ArrayRunDto dto = new ArrayRunDto(); dto.setId(from.getId()); dto.setAlias(from.getAlias()); dto.setDescription(from.getDescription()); dto.setFilePath(from.getFilePath()); if (from.getInstrument() != null) { dto.setInstrumentId(from.getInstrument().getId()); dto.setInstrumentName(from.getInstrument().getName()); } if (from.getArray() != null) { dto.setArray(asDto(from.getArray())); } dto.setStatus(from.getHealth().getKey()); if (from.getStartDate() != null) { dto.setStartDate(formatDate(from.getStartDate())); } if (from.getCompletionDate() != null) { dto.setCompletionDate(formatDate(from.getCompletionDate())); } if (from.getLastModified() != null) { dto.setLastModified(formatDate(from.getLastModified())); } return dto; }