public void SetData(WorkspaceData data, WorkspaceData savedData) { if (Equals(Data, data) && Equals(SavedData, savedData)) { return; } var workspaceChange = new WorkspaceChangeArgs(Data, SavedData); _data = data; _savedWorkspaceData = savedData; _tracerDefList = null; RetentionTimeAlignments.SetData(Data); Settings.Update(workspaceChange); Modifications.Update(workspaceChange); TracerDefs.Update(workspaceChange); Peptides.Update(workspaceChange); MsDataFiles.Update(workspaceChange); PeptideAnalyses.Update(workspaceChange); var changeHandlers = Change; if (null != changeHandlers) { changeHandlers(this, workspaceChange); } }
public void Save(LongOperationBroker longOperationBroker) { longOperationBroker.UpdateStatusMessage("Synchronizing with database changes"); int reconcileAttempt = 1; while (true) { var dirtyPeptideAnalyses = PeptideAnalyses.ListDirty() .ToDictionary(pa => pa.Id, pa => pa.ChromatogramsWereLoaded); if (DatabasePoller.TryLoadAndMergeChanges(dirtyPeptideAnalyses)) { break; } reconcileAttempt++; longOperationBroker.UpdateStatusMessage("Synchronizing with database changes attempt #" + reconcileAttempt); } using (var session = OpenWriteSession()) { session.BeginTransaction(); UpdateWorkspaceVersion(longOperationBroker, session, SavedWorkspaceChange); bool workspaceChanged = false; var dbWorkspace = LoadDbWorkspace(session); longOperationBroker.UpdateStatusMessage("Saving tracer definitions"); workspaceChanged = TracerDefs.Save(session, dbWorkspace) || workspaceChanged; longOperationBroker.UpdateStatusMessage("Saving modifications"); workspaceChanged = Modifications.Save(session, dbWorkspace) || workspaceChanged; longOperationBroker.UpdateStatusMessage("Saving settings"); workspaceChanged = Settings.Save(session, dbWorkspace) || workspaceChanged; longOperationBroker.UpdateStatusMessage("Saving data files"); foreach (var msDataFile in MsDataFiles.ListDirty()) { msDataFile.Save(session); } longOperationBroker.UpdateStatusMessage("Saving peptides"); foreach (var peptide in Peptides.ListDirty()) { peptide.Save(session); } longOperationBroker.UpdateStatusMessage("Saving peptide analyses"); foreach (var peptideAnalysis in PeptideAnalyses.ListDirty()) { if (longOperationBroker.WasCancelled) { return; } peptideAnalysis.Save(session); } if (workspaceChanged) { session.Save(new DbChangeLog(this)); } longOperationBroker.SetIsCancelleable(false); session.Transaction.Commit(); } }
private Workspace() { _data = _savedWorkspaceData = new WorkspaceData(); Modifications = new Modifications(this); Settings = new WorkspaceSettings(this); TracerDefs = new TracerDefs(this); PeptideAnalyses = new PeptideAnalyses(this); Peptides = new Peptides(this); MsDataFiles = new MsDataFiles(this); RetentionTimeAlignments = new RetentionTimeAlignments(Data); }
public void Merge(WorkspaceData newData) { var newSavedData = newData; newData = Settings.Merge(newData); newData = Modifications.Merge(newData); newData = TracerDefs.Merge(newData); newData = Peptides.Merge(newData); newData = MsDataFiles.Merge(newData); newData = PeptideAnalyses.Merge(newData); SetData(newData, newSavedData); }
public IList <PeptideAnalysis> ListOpenPeptideAnalyses() { return(PeptideAnalyses.Where(peptideAnalysis => peptideAnalysis.GetChromatogramRefCount() > 0).ToArray()); }
public bool HasAnyChromatograms() { return(PeptideAnalyses.Any( peptideAnalysis => peptideAnalysis.FileAnalyses.Any( fileAnalysis => fileAnalysis.ChromatogramSetId.HasValue))); }