protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var entry = base.CreateEntry(docPair); if (RenamedReplicates.Count != 0) { entry = entry.AppendAllInfo(RenamedReplicates.Select(r => DetailLogMessage.FromLogMessage(r.ToMessage(LogLevel.all_info)))); } if (_removedAllLibraryRuns) { entry = entry.AppendAllInfo(new[] { new MessageInfo(MessageType.removed_all_libraries, docPair.OldDocumentType) }); } else { entry = entry.AppendAllInfo(RemovedLibraryRuns.Select(run => new MessageInfo(MessageType.removed_library_run, docPair.OldDocumentType, run)).ToList()); } if (_removedAllReplicates) { entry = entry.AppendAllInfo(new[] { new MessageInfo(MessageType.removed_all_replicates, docPair.OldDocumentType) }); } else { entry = entry.AppendAllInfo(RemovedReplicates.Select(repl => new MessageInfo(MessageType.removed_replicate, docPair.OldDocumentType, repl)).ToList()); } return(entry); }
protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var entry = AuditLogEntry.CreateCountChangeEntry(MessageType.imported_result, MessageType.imported_results, docPair.NewDocumentType, FileNames, MessageArgs.DefaultSingular, null); return(entry.Merge(base.CreateEntry(docPair), false)); }
protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var entry = AuditLogEntry.CreateCountChangeEntry( MessageType.associated_peptides_with_protein, MessageType.associated_peptides_with_proteins, docPair.NewDocumentType, Proteins); return(entry.Merge(base.CreateEntry(docPair))); }
protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var entry = AuditLogEntry.CreateCountChangeEntry(docPair.OldDoc, MessageType.accepted_peptide, MessageType.accept_peptides, AcceptedPeptides) .ChangeAllInfo(new LogMessage[0]); // TODO: if this happens more often, consider adding something like "reverse merge" entry = entry.Merge(base.CreateEntry(docPair)); return(entry.ChangeExtraInfo(entry.ExtraInfo + Environment.NewLine + Environment.NewLine + PeptidesText)); }
protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var entry = AuditLogEntry.CreateCountChangeEntry(MessageType.accepted_protein, MessageType.accepted_proteins, docPair.NewDocumentType, AcceptedProteins) .ClearAllInfo(); // TODO: if this happens more often, consider adding something like "reverse merge" entry = entry.Merge(base.CreateEntry(docPair)); return(entry.ChangeExtraInfo(entry.ExtraInfo + Environment.NewLine + Environment.NewLine + ProteinsText)); }
protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var baseEntry = base.CreateEntry(docPair); var entry = AuditLogEntry.CreateCountChangeEntry(docPair.OldDoc, MessageType.renamed_single_protein, MessageType.renamed_proteins, RenamedProteins, rename => MessageArgs.Create(rename.CurrentName, rename.NewName), null); return(entry.Merge(baseEntry, false)); }
/// <summary> /// Compares the settings objects of the given documents and creates an entry /// for the differences /// </summary> /// <param name="documentPair">The pair of documents to compare</param> /// <returns>A log entry containing the changes</returns> public static AuditLogEntry SettingsLogFunction(SrmDocumentPair documentPair) { var property = RootProperty.Create(typeof(SrmSettings), "Settings"); // Not L10N var objInfo = new ObjectInfo <object>(documentPair.OldDoc.Settings, documentPair.NewDoc.Settings, documentPair.OldDoc, documentPair.NewDoc, documentPair.OldDoc, documentPair.NewDoc); var tree = DiffTree.FromEnumerator(Reflector <SrmSettings> .EnumerateDiffNodes(objInfo, property, false)); return(tree.Root != null?CreateSettingsChangeEntry(documentPair.OldDoc, tree) : null); }
public IEnumerable <AuditLogEntry> CreateEntries(SrmDocumentPair docPair) { foreach (var entryCreator in EntryCreators) { var entry = entryCreator.Create(docPair); if (entry != null) { yield return(entry); } } }
/// <summary> /// Updates the document with the given AuditLogEntry. If the entry is non-null and logging is enabled, /// it is added to the document. If audit logging changed from being disabled to enabled and the document is different /// from the default document(no children, default settings) a "start from existing document" entry is added. If audit logging /// changes from being enabled to disabled, the log is cleared. /// </summary> /// <param name="entry">The entry to add</param> /// <param name="docPair">Document pair containing the new document the entry should get added to</param> /// <returns>A new document with this entry added</returns> public static SrmDocument UpdateDocument(AuditLogEntry entry, SrmDocumentPair docPair) { var newDoc = docPair.NewDoc; /*if (Settings.Default.AuditLogging || CountEntryType == MessageType.log_cleared) * { * newDoc = newDoc.ChangeAuditLog(ChangeParent(docPair.NewDoc.AuditLog.AuditLogEntries)); * } * else * { * var entry = CreateUnloggedEntry(document, out var replace); * * // This is the only property we have to copy over, since we don't care about the content of the log message * // but still want the ability to undo unlogged entries. We only change the undo action for the first * // unlogged message entry, otherwise clicking the undo button in the grid would undo the unlogged changes one-by-one * // instead of in a single "batch undo." TODO: Is this how it should be? * // (This one-by-one behavior can still be achieved by using the undo redo buffer) * if (!replace) * entry = entry.ChangeUndoAction(_undoAction); * * var oldEntries = document.AuditLog.AuditLogEntries; * var newEntries = replace * ? entry.ChangeParent(oldEntries?.Parent) * : entry.ChangeParent(oldEntries); * * newDoc = document.ChangeAuditLog(newEntries); * }*/ var oldLogging = docPair.OldDoc.Settings.DataSettings.AuditLogging; var newLogging = docPair.NewDoc.Settings.DataSettings.AuditLogging; if (oldLogging && !newLogging) { return(newDoc.ChangeAuditLog(ROOT)); } else if (!oldLogging && newLogging) { var startEntry = GetAuditLoggingStartExistingDocEntry(newDoc); if (startEntry != null && entry != null) { startEntry = startEntry.ChangeParent(entry); } entry = startEntry ?? entry; } if (newLogging) { newDoc = entry?.AppendEntryToDocument(newDoc) ?? newDoc; } return(newDoc); }
public static AuditLogEntry DiffDocNodes(MessageType action, SrmDocumentPair documentPair, params object[] actionParameters) { var property = RootProperty.Create(typeof(Targets)); var objInfo = new ObjectInfo <object>(documentPair.OldDoc.Targets, documentPair.NewDoc.Targets, documentPair.OldDoc, documentPair.NewDoc, documentPair.OldDoc, documentPair.NewDoc); var diffTree = DiffTree.FromEnumerator(Reflector <Targets> .EnumerateDiffNodes(objInfo, property, false), DateTime.Now); if (diffTree.Root != null) { var message = new MessageInfo(action, actionParameters); var entry = CreateSettingsChangeEntry(documentPair.OldDoc, diffTree) .ChangeUndoRedo(message); return(entry); } return(null); }
protected virtual AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var baseEntry = CreateBaseEntry(docPair); var rootProp = RootProperty.Create(typeof(T)); var objectInfo = new ObjectInfo <object>() .ChangeObjectPair(ObjectPair <object> .Create(null, this)) .ChangeRootObjectPair(docPair.ToObjectType()); var diffTree = DiffTree.FromEnumerator(Reflector <T> .EnumerateDiffNodes(docPair.ToObjectType(), rootProp, (T)this), DateTime.Now); if (diffTree.Root == null) { return(baseEntry); } var settingsString = Reflector <T> .ToString(objectInfo.RootObjectPair, diffTree.Root, ToStringState.DEFAULT.ChangeFormatWhitespace(true)); var entry = AuditLogEntry.CreateSettingsChangeEntry(docPair.OldDoc, diffTree, settingsString); return(baseEntry.Merge(entry)); }
public static AuditLogEntry GetAuditLoggingStartExistingDocEntry(SrmDocument doc) { // Don't want to have these entries in tests (except for the AuditLogSaving test which actually tests this type of entry) if (Program.FunctionalTest && !AuditLogList.IgnoreTestChecks) { return(null); } var defaultDoc = new SrmDocument(SrmSettingsList.GetDefault()); var docPair = SrmDocumentPair.Create(defaultDoc, doc); var changeFromDefaultSettings = SettingsLogFunction(docPair); var initialNodeCounts = doc.Children.Count > 0 ? new DocumentNodeCounts(doc).EntryCreator.Create(docPair) : null; var entry = CreateSimpleEntry(doc, MessageType.start_log_existing_doc) .Merge(initialNodeCounts).Merge(changeFromDefaultSettings); if (changeFromDefaultSettings != null || initialNodeCounts != null) { return(entry); } return(null); }
public AuditLogEntry LogEntryFromEditDescription(EditDescription editDescription, SrmDocumentPair docPair) { if (EqualExceptAuditLog(docPair.OldDoc, docPair.NewDoc)) { return(AuditLogEntry.SKIP); } return(AuditLogEntry.CreateSimpleEntry(MessageType.set_to_in_document_grid, docPair.NewDocumentType, editDescription.AuditLogParseString, editDescription.ElementRefName, CellValueToString(editDescription.Value))); }
private AuditLogEntry CreateRemoveNodesEntry(SrmDocumentPair docPair, MessageType singular, MessageType plural) { var count = SkylineWindow.CountNodeDiff(docPair); return(AuditLogEntry.CreateSimpleEntry(count == 1 ? singular : plural, docPair.NewDocumentType, count)); }
public static AuditLogEntry DiffDocNodes(MessageType action, SrmDocumentPair documentPair, params object[] actionParameters) { return(DiffDocNodes(action, documentPair, false, actionParameters)); }
protected virtual AuditLogEntry CreateBaseEntry(SrmDocumentPair docPair) { return(MessageInfo.Type == MessageType.none ? AuditLogEntry.CreateEmptyEntry(docPair.OldDoc).ChangeAllInfo(new LogMessage[0]) : AuditLogEntry.CreateSingleMessageEntry(docPair.OldDoc, MessageInfo)); }
/// <summary> /// Merges the entries created by the given creator list into the current entry /// </summary> /// <param name="docPair">Documents used to construct new entries</param> /// <param name="creatorList">Entries to be constructed</param> /// <param name="append">see <see cref="Merge(pwiz.Skyline.Model.AuditLog.AuditLogEntry,bool)"/></param> /// <returns>A new, merged entry</returns> public AuditLogEntry Merge(SrmDocumentPair docPair, AuditLogEntryCreatorList creatorList, bool append = true) { return(creatorList.EntryCreators.Aggregate(this, (e, c) => e.Merge(c.Create(docPair), append))); }
public AuditLogEntry GetAuditLogEntry(SrmDocumentPair docPair, StaticMod isotopeModification, bool simple) { return(AuditLogEntry.CreateSimpleEntry( simple ? MessageType.permuted_isotope_label_simple : MessageType.permuted_isotope_label_complete, docPair.NewDocumentType, isotopeModification.Name)); }