@Override public Long getId() { return run.getId(); }
@Override public boolean isSaved() { return getId() != UNSAVED_ID; }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof Run)) return false; Run them = (Run) obj; // If not saved, then compare resolved actual objects. Otherwise // just compare IDs. if (getId() == UNSAVED_ID || them.getId() == UNSAVED_ID) { return getAlias().equals(them.getAlias()); } else { return getId() == them.getId(); } }
@Override public void saveRuns(Collection<Run> runs) throws IOException { for (Run run : runs) { if (run.getId() == Run.UNSAVED_ID) { create(run); } else { update(run); } } }
@Override public PartitionQC get(Run run, Partition partition) throws IOException { Run managedRun = runService.get(run.getId()); authorizationManager.throwIfNotReadable(managedRun); return partitionQcDao.get(managedRun, partition); }
@Override public void deleteNote(Run run, Long noteId) throws IOException { if (noteId == null || noteId.equals(Note.UNSAVED_ID)) { throw new IllegalArgumentException("Cannot delete an unsaved Note"); } Run managed = runDao.get(run.getId()); authorizationManager.throwIfNotWritable(managed); Note deleteNote = null; for (Note note : managed.getNotes()) { if (note.getNoteId().equals(noteId)) { deleteNote = note; break; } } if (deleteNote == null) { throw new IOException("Note " + noteId + " not found for Run " + run.getId()); } authorizationManager.throwIfNonAdminOrMatchingOwner(deleteNote.getOwner()); managed.getNotes().remove(deleteNote); runDao.save(managed); }
sourceMetrics = mapper.readValue(source.getMetrics(), ArrayNode.class); } catch (IOException e) { log.error("Impossible junk metrics were passed in for run " + target.getId(), e); return false; targetMetrics = mapper.readValue(target.getMetrics(), ArrayNode.class); } catch (IOException e) { log.error("The database is full of garbage metrics for run " + target.getId(), e); return false;
@Override public void addNote(Run run, Note note) throws IOException { Run managed = runDao.get(run.getId()); authorizationManager.throwIfNotWritable(managed); note.setCreationDate(new Date()); note.setOwner(authorizationManager.getCurrentUser()); managed.addNote(note); managed.setLastModifier(authorizationManager.getCurrentUser()); runDao.save(managed); }
@Override public void update(Run run) throws IOException { Run managed = get(run.getId()); authorizationManager.throwIfNotWritable(managed); loadChildEntities(run); saveContainers(run); applyChanges(managed, run); managed.setChangeDetails(authorizationManager.getCurrentUser()); save(managed); }
@Override public Long create(Run run) throws IOException { authorizationManager.throwIfNotWritable(run); validateChanges(null, run); saveContainers(run); run.setChangeDetails(authorizationManager.getCurrentUser()); loadChildEntities(run); run.setSecurityProfile(securityProfileStore.get(securityProfileStore.save(run.getSecurityProfile()))); run.setName(generateTemporaryName()); Run saved = save(run); makeContainerChangesChangeLog(saved, Collections.emptyList(), saved.getSequencerPartitionContainers()); return saved.getId(); }
private Run save(Run run) throws IOException { try { Long id = runDao.save(run); Run saved = runDao.get(id); // post-save field generation boolean needsUpdate = false; if (hasTemporaryName(run)) { saved.setName(namingScheme.generateNameFor(saved)); validateNameOrThrow(saved, namingScheme); needsUpdate = true; } if (needsUpdate) { runDao.save(saved); saved = runDao.get(saved.getId()); } return saved; } catch (MisoNamingException e) { throw new IllegalArgumentException("Name generator failed to generate a valid name", e); } catch (ConstraintViolationException e) { // Send the nested root cause message to the user, since it contains the actual error. throw new ConstraintViolationException(e.getMessage() + " " + ExceptionUtils.getRootCauseMessage(e), e.getSQLException(), e.getConstraintName()); } }
to.setExperiment(experiment); to.setPartition(containerService.getPartition(from.getPartition().getId())); to.setRun(runService.get(from.getRun().getId())); return to; })).collect(
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; }
@Override public void save(PartitionQC qc) throws IOException { PartitionQC managedQc = get(qc.getRun(), qc.getPartition()); Run managedRun = runService.get(qc.getRun().getId()); authorizationManager.throwIfNotWritable(managedRun); Partition managedPartition = containerService.getPartition(qc.getPartition().getId()); // update run and container for accurate lastModified and lastModifier (used in changelogs) runService.update(managedRun); containerService.update(managedPartition.getSequencerPartitionContainer()); if (managedQc == null) { qc.setRun(managedRun); qc.setPartition(managedPartition); qc.setType(getType(qc.getType().getId())); partitionQcDao.create(qc); } else { managedQc.setType(getType(qc.getType().getId())); managedQc.setNotes(qc.getNotes()); partitionQcDao.update(managedQc); } } }
public static RunDto asDto(@Nonnull Run from, boolean includeContainers, boolean includeContainerPartitions, boolean includePoolContents) { RunDto dto = new RunDto(); dto.setId(from.getId()); dto.setName(from.getName()); dto.setAlias(from.getAlias());