From 70c9080766baeba6ec88529126fda28867f0d344 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 18 Apr 2022 20:14:16 -0700 Subject: [PATCH] rename cordata entities --- .../CoreDataModel.xcdatamodel/contents | 94 +++++++++---------- .../Models/DataModels/HighlightDep.swift | 52 +++++----- .../Services/DataService/DataService.swift | 2 +- .../CachedPDFHighlights.swift | 12 +-- 4 files changed, 80 insertions(+), 80 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents b/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents index 568d9d5e3..c15b134f4 100644 --- a/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents +++ b/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents @@ -1,5 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -31,49 +74,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -86,11 +86,11 @@ - - - - + + + + \ No newline at end of file diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/HighlightDep.swift b/apple/OmnivoreKit/Sources/Models/DataModels/HighlightDep.swift index 8e2c43c5f..affd5863b 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/HighlightDep.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/HighlightDep.swift @@ -37,35 +37,35 @@ public struct HighlightDep: Identifiable, Hashable, Codable { self.createdByMe = createdByMe } - public func toManagedObject(context: NSManagedObjectContext, associatedItemID: String) -> PersistedHighlight { - let persistedHighlight = PersistedHighlight(context: context) - persistedHighlight.associatedItemId = associatedItemID - persistedHighlight.markedForDeletion = false - persistedHighlight.id = id - persistedHighlight.shortId = shortId - persistedHighlight.quote = quote - persistedHighlight.prefix = prefix - persistedHighlight.suffix = suffix - persistedHighlight.patch = patch - persistedHighlight.annotation = annotation - persistedHighlight.createdAt = createdAt - persistedHighlight.updatedAt = updatedAt - persistedHighlight.createdByMe = createdByMe - return persistedHighlight + public func toManagedObject(context: NSManagedObjectContext, associatedItemID: String) -> Highlight { + let highlight = Highlight(context: context) + highlight.associatedItemId = associatedItemID + highlight.markedForDeletion = false + highlight.id = id + highlight.shortId = shortId + highlight.quote = quote + highlight.prefix = prefix + highlight.suffix = suffix + highlight.patch = patch + highlight.annotation = annotation + highlight.createdAt = createdAt + highlight.updatedAt = updatedAt + highlight.createdByMe = createdByMe + return highlight } - public static func make(from persistedHighlight: PersistedHighlight) -> HighlightDep { + public static func make(from highlight: Highlight) -> HighlightDep { HighlightDep( - id: persistedHighlight.id ?? "", - shortId: persistedHighlight.shortId ?? "", - quote: persistedHighlight.quote ?? "", - prefix: persistedHighlight.prefix, - suffix: persistedHighlight.suffix, - patch: persistedHighlight.patch ?? "", - annotation: persistedHighlight.annotation, - createdByMe: persistedHighlight.createdByMe, - createdAt: persistedHighlight.createdAt, - updatedAt: persistedHighlight.updatedAt + id: highlight.id ?? "", + shortId: highlight.shortId ?? "", + quote: highlight.quote ?? "", + prefix: highlight.prefix, + suffix: highlight.suffix, + patch: highlight.patch ?? "", + annotation: highlight.annotation, + createdByMe: highlight.createdByMe, + createdAt: highlight.createdAt, + updatedAt: highlight.updatedAt ) } } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift index 08e39f1aa..e88b97434 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift @@ -37,7 +37,7 @@ public final class DataService: ObservableObject { public func clearHighlights() { deletedHighlightsIDs.removeAll() - let fetchRequest: NSFetchRequest = PersistedHighlight.fetchRequest() + let fetchRequest: NSFetchRequest = Highlight.fetchRequest() let highlights = (try? persistentContainer.viewContext.fetch(fetchRequest)) ?? [] diff --git a/apple/OmnivoreKit/Sources/Services/Persistence/PersistableModels/CachedPDFHighlights.swift b/apple/OmnivoreKit/Sources/Services/Persistence/PersistableModels/CachedPDFHighlights.swift index 415be2bb1..f4b7ae9da 100644 --- a/apple/OmnivoreKit/Sources/Services/Persistence/PersistableModels/CachedPDFHighlights.swift +++ b/apple/OmnivoreKit/Sources/Services/Persistence/PersistableModels/CachedPDFHighlights.swift @@ -5,7 +5,7 @@ import Models public extension DataService { func cachedHighlights(pdfID: String) -> [HighlightDep] { - let fetchRequest: NSFetchRequest = PersistedHighlight.fetchRequest() + let fetchRequest: NSFetchRequest = Highlight.fetchRequest() fetchRequest.predicate = NSPredicate( format: "associatedItemId = %@ AND markedForDeletion = %@", pdfID, false ) @@ -22,10 +22,10 @@ public extension DataService { do { try persistentContainer.viewContext.save() - print("PersistedHighlight saved succesfully") + print("Highlight saved succesfully") } catch { persistentContainer.viewContext.rollback() - print("Failed to save PersistedHighlight: \(error)") + print("Failed to save Highlight: \(error)") } } @@ -34,7 +34,7 @@ public extension DataService { deletedHighlightsIDs.insert(highlightID) } - let fetchRequest: NSFetchRequest = PersistedHighlight.fetchRequest() + let fetchRequest: NSFetchRequest = Highlight.fetchRequest() fetchRequest.predicate = NSPredicate(format: "id IN %@", highlightIds) guard let highlights = try? persistentContainer.viewContext.fetch(fetchRequest) else { return } @@ -44,10 +44,10 @@ public extension DataService { do { try persistentContainer.viewContext.save() - print("PersistedHighlight(s) updated succesfully") + print("Highlight(s) updated succesfully") } catch { persistentContainer.viewContext.rollback() - print("Failed to update PersistedHighlight(s): \(error)") + print("Failed to update Highlight(s): \(error)") } } }