Today's Menu  Portugal
journal and plan nutrition
Instance Methods | Class Methods | Properties | List of all members
MenuItem Class Reference

#import <MenuItem+CoreDataClass.h>

Inheritance diagram for MenuItem:
Inheritance graph
[legend]
Collaboration diagram for MenuItem:
Collaboration graph
[legend]

Instance Methods

(void) - addMealContainingObject:
 
(void) - removeMealContainingObject:
 
(void) - addMealContaining:
 
(void) - removeMealContaining:
 

Class Methods

(MenuItem *) + findMenuItemWithRandomkey:context:
 
(MenuItem *) + findOrCreateMenuItemWithRandomkey:context:
 
(MenuItem *) + findMenuItemWithFileIdentification:context:
 
(MenuItem *) + findOrCreateMenuItemWithFileIdentification:context:
 
(MenuItem *) + findNextMenuItemForGallery:afterPosition:context:
 
(NSArray< MenuItem * > *) + retrieveAllMenuItemsForGallery:context:
 
(NSArray *) + menuItemWithKey:context:
 
(NSArray *) + menuItemWithFileid:context:
 
(NSArray *) + menuItemWithUID:context: [implementation]
 
(NSFetchRequest< MenuItem * > *) + fetchRequest
 

Properties

NSString * bodytext
 
NSNumber * galleryNumber
 
NSNumber * galleryPositionNo
 
NSString * name
 
NSData * photo
 
NSString * randomkey
 
NSString * recipe
 
NSString * uid
 
NSString * usdaNumbers
 
NSString * remoteUniqueIID
 
NSSet< Meal * > * mealContaining
 

Detailed Description

Definition at line 18 of file MenuItem+CoreDataClass.h.

Method Documentation

◆ addMealContaining:()

- (void) addMealContaining: (NSSet< Meal * > *)  values

Provided by category MenuItem(CoreDataGeneratedAccessors).

◆ addMealContainingObject:()

- (void) addMealContainingObject: (Meal *)  value

Provided by category MenuItem(CoreDataGeneratedAccessors).

◆ fetchRequest()

+ (NSFetchRequest< MenuItem * > *) fetchRequest

Provided by category MenuItem(CoreDataProperties).

Definition at line 14 of file MenuItem+CoreDataProperties.m.

14  {
15  return [NSFetchRequest fetchRequestWithEntityName:@"MenuItem"];
16 }

◆ findMenuItemWithFileIdentification:context:()

+ (MenuItem *) findMenuItemWithFileIdentification: (NSString *)  googlefileid
context: (NSManagedObjectContext *)  moc 

Definition at line 39 of file MenuItem+CoreDataClass.m.

39  :(NSString *)googlefileid
40  context:(NSManagedObjectContext *) moc
41 {
42  NSArray *dupDoctorN = [self menuItemWithFileid:googlefileid context:moc];
43  MenuItem *result = [dupDoctorN lastObject];
44  // if (result) { NSLog(@"Reuse MenuItem with file-id: %@", googlefileid); }
45  return result;
46 }

◆ findMenuItemWithRandomkey:context:()

+ (MenuItem *) findMenuItemWithRandomkey: (NSString *)  randomkey
context: (NSManagedObjectContext *)  moc 

Definition at line 14 of file MenuItem+CoreDataClass.m.

14  :(NSString *)randomkey context:(NSManagedObjectContext *)moc
15 {
16  NSArray *dupDoctorN = [self menuItemWithKey:randomkey context:moc];
17  MenuItem *result = [dupDoctorN lastObject];
18  if (result) {
19  // NSLog(@"MenuItem+CoreDataClass.findOrCreate: Reuse MenuItem with randomkey: %@ name: %@", randomkey, [result name]);
20  }
21  return result;
22 }

◆ findNextMenuItemForGallery:afterPosition:context:()

+ (NSArray< MenuItem * > *) findNextMenuItemForGallery: (NSNumber *)  galleryNo
afterPosition: (NSNumber *)  positionInGallery
context: (NSManagedObjectContext *)  moc 

Definition at line 85 of file MenuItem+CoreDataClass.m.

85  : (NSNumber *) galleryNo afterPosition: (NSNumber *) positionInGallery context:(NSManagedObjectContext *)moc
86 {
87  NSManagedObjectModel *mom = moc.persistentStoreCoordinator.managedObjectModel;
88 
89  NSFetchRequest *menuItemKeyFetchRequest =
90  [mom fetchRequestFromTemplateWithName:@"MenuItemByGalleryAndPosition" substitutionVariables:@{@"x" : galleryNo, @"y" : positionInGallery} ];
91 
92  menuItemKeyFetchRequest.fetchBatchSize = 1;
93 
94  NSError *error = nil;
95  NSArray *results = [moc executeFetchRequest:menuItemKeyFetchRequest error:&error];
96  if (!results) {
97  NSLog(@"MenuItem+CoreDataClass.findNextMenuItemForGallery: error.localizedDescription: %@", [error localizedDescription]);
98  }
99 
100  return results;
101 
102 }

◆ findOrCreateMenuItemWithFileIdentification:context:()

+ (MenuItem *) findOrCreateMenuItemWithFileIdentification: (NSString *)  googlefileid
context: (NSManagedObjectContext *)  moc 

Definition at line 48 of file MenuItem+CoreDataClass.m.

48  :(NSString *)googlefileid context:(NSManagedObjectContext *)moc
49 {
50  NSArray *dupDoctorN = [self menuItemWithFileid:googlefileid context:moc];
51  MenuItem *result = [dupDoctorN lastObject];
52  if (result) {
53  // NSLog(@"MenuItem+CoreDataClass.findOrCreate: Reuse MenuItem with file-id: %@ name: %@", googlefileid, [result name]);
54  } else {
55  // NSLog(@"MenuItem+CoreDataClass.findOrCreate: Create new MenuItem with file-id: %@", googlefileid);
56  result = [NSEntityDescription insertNewObjectForEntityForName:@"MenuItem" inManagedObjectContext:moc];
57  NSAssert(result, @"MenuItem insert failed");
58  result.remoteUniqueIID = googlefileid;
59  }
60  return result;
61 }
NSString * remoteUniqueIID

◆ findOrCreateMenuItemWithRandomkey:context:()

+ (MenuItem *) findOrCreateMenuItemWithRandomkey: (NSString *)  key
context: (NSManagedObjectContext *)  moc 

Definition at line 24 of file MenuItem+CoreDataClass.m.

24  :(NSString *)key context:(NSManagedObjectContext *)moc
25 {
26  NSArray *dupDoctorN = [self menuItemWithKey:key context:moc];
27  MenuItem *result = [dupDoctorN lastObject];
28  if (result) {
29  // NSLog(@"MenuItem+CoreDataClass.findOrCreate: Reuse MenuItem with randomkey: %@ name: %@", key, [result name]);
30  } else {
31  // NSLog(@"MenuItem+CoreDataClass.findOrCreate: Create new MenuItem with randomkey: %@", key);
32  result = [NSEntityDescription insertNewObjectForEntityForName:@"MenuItem" inManagedObjectContext:moc];
33  NSAssert(result, @"MenuItem insert failed");
34  result.randomkey = key;
35  }
36  return result;
37 }

◆ menuItemWithFileid:context:()

+ (NSArray *) menuItemWithFileid: (NSString *)  googlefileid
context: (NSManagedObjectContext *)  moc 

Definition at line 153 of file MenuItem+CoreDataClass.m.

153  :(NSString *)googlefileid context:(NSManagedObjectContext *)moc
154 {
155  if (nil == googlefileid) {
156  NSLog(@"MenuItem+CoreDataClass.menuItemWithKey: ERROR: nil googlefileid at MenuItem.menuItemWithFileid");
157  return nil;
158  }
159  NSManagedObjectModel *mom = moc.persistentStoreCoordinator.managedObjectModel;
160 
161  NSFetchRequest *menuItemKeyFetchRequest =
162  [mom fetchRequestFromTemplateWithName:@"MenuItemByFileId" substitutionVariables:@{@"x" : googlefileid} ];
163 
164  menuItemKeyFetchRequest.fetchBatchSize = 1;
165 
166  NSError *error = nil;
167  NSArray *results = [moc executeFetchRequest:menuItemKeyFetchRequest error:&error];
168  if (!results) {
169  NSLog(@"%@", error.localizedDescription);
170  }
171 
172  return results;
173 }

◆ menuItemWithKey:context:()

+ (NSArray *) menuItemWithKey: (NSString *)  randomkey
context: (NSManagedObjectContext *)  moc 

Definition at line 131 of file MenuItem+CoreDataClass.m.

131  :(NSString *)randomkey context:(NSManagedObjectContext *)moc
132 {
133  if (nil == randomkey) {
134  // NSLog(@"ERROR: nil randomkey at MenuItem.menuItemWithKey");
135  return nil;
136  }
137  NSManagedObjectModel *mom = moc.persistentStoreCoordinator.managedObjectModel;
138 
139  NSFetchRequest *menuItemKeyFetchRequest =
140  [mom fetchRequestFromTemplateWithName:@"MenuItemByKey" substitutionVariables:@{@"x" : randomkey} ];
141 
142  menuItemKeyFetchRequest.fetchBatchSize = 1;
143 
144  NSError *error = nil;
145  NSArray *results = [moc executeFetchRequest:menuItemKeyFetchRequest error:&error];
146  if (!results) {
147  NSLog(@"MenuItem+CoreDataClass.menuItemWithKey: error.localizedDescription: %@", [error localizedDescription]);
148  }
149 
150  return results;
151 }

◆ menuItemWithUID:context:()

+ (NSArray *) menuItemWithUID: (NSString *)  uidkey
context: (NSManagedObjectContext *)  moc 
implementation

Definition at line 63 of file MenuItem+CoreDataClass.m.

63  :(NSString *)uidkey context:(NSManagedObjectContext *)moc
64 {
65  if (nil == uidkey) {
66  // NSLog(@"ERROR: nil randomkey at MenuItem.menuItemWithKey");
67  return nil;
68  }
69  NSManagedObjectModel *mom = moc.persistentStoreCoordinator.managedObjectModel;
70 
71  NSFetchRequest *menuItemKeyFetchRequest =
72  [mom fetchRequestFromTemplateWithName:@"MenuItemByUID" substitutionVariables:@{@"x" : uidkey} ];
73 
74  menuItemKeyFetchRequest.fetchBatchSize = 1;
75 
76  NSError *error = nil;
77  NSArray *results = [moc executeFetchRequest:menuItemKeyFetchRequest error:&error];
78  if (!results) {
79  // NSLog(@"MenuItem+CoreDataClass.menuItemWithKey: error.localizedDescription: %@", [error localizedDescription]);
80  }
81 
82  return results;
83 }

◆ removeMealContaining:()

- (void) removeMealContaining: (NSSet< Meal * > *)  values

Provided by category MenuItem(CoreDataGeneratedAccessors).

◆ removeMealContainingObject:()

- (void) removeMealContainingObject: (Meal *)  value

Provided by category MenuItem(CoreDataGeneratedAccessors).

◆ retrieveAllMenuItemsForGallery:context:()

+ (NSArray< MenuItem * > *) retrieveAllMenuItemsForGallery: (NSNumber *)  galleryNo
context: (NSManagedObjectContext *)  moc 

Definition at line 103 of file MenuItem+CoreDataClass.m.

103  :(NSNumber *) galleryNo
104  context:(NSManagedObjectContext *)moc
105 {
106  // NSLog(@"MenuItem+CoreDataClass.retrieveAllMenuItemsForGallery: %@", galleryNo);
107  NSManagedObjectModel *mom = moc.persistentStoreCoordinator.managedObjectModel;
108 
109  NSFetchRequest *galleryFetchRequest =
110  [mom fetchRequestFromTemplateWithName:@"AllMenuItemsInGallery" substitutionVariables:@{@"x" : galleryNo} ];
111  NSSortDescriptor *modelDescriptor = [NSSortDescriptor
112  sortDescriptorWithKey:@"galleryPositionNo"
113  ascending:YES
114  selector:@selector(compare:)];
115  NSArray<NSSortDescriptor *> *descriptors = @[modelDescriptor];
116 
117  [galleryFetchRequest setSortDescriptors:descriptors];
118 
119  galleryFetchRequest.fetchBatchSize = 30;
120 
121  NSError *error = nil;
122  NSArray *results = [moc executeFetchRequest:galleryFetchRequest error:&error];
123  if (!results) {
124  NSLog(@"MenuItem+CoreDataClass.retrieveAllMenuItemsForGallery: error.localizedDescription: %@", [error localizedDescription]);
125  }
126 
127  return results;
128 
129 }

Property Documentation

◆ bodytext

- (NSString*) bodytext
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 19 of file MenuItem+CoreDataProperties.h.

◆ galleryNumber

- (NSNumber*) galleryNumber
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 20 of file MenuItem+CoreDataProperties.h.

◆ galleryPositionNo

- (NSNumber*) galleryPositionNo
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 21 of file MenuItem+CoreDataProperties.h.

◆ mealContaining

- (NSSet<Meal *>*) mealContaining
readwritenonatomicretain

Provided by category MenuItem(CoreDataProperties).

Definition at line 29 of file MenuItem+CoreDataProperties.h.

◆ name

- (NSString*) name
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 22 of file MenuItem+CoreDataProperties.h.

◆ photo

- (NSData*) photo
readwritenonatomicretain

Provided by category MenuItem(CoreDataProperties).

Definition at line 23 of file MenuItem+CoreDataProperties.h.

◆ randomkey

- (NSString*) randomkey
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 24 of file MenuItem+CoreDataProperties.h.

◆ recipe

- (NSString*) recipe
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 25 of file MenuItem+CoreDataProperties.h.

◆ remoteUniqueIID

- (NSString*) remoteUniqueIID
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 28 of file MenuItem+CoreDataProperties.h.

◆ uid

- (NSString*) uid
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 26 of file MenuItem+CoreDataProperties.h.

◆ usdaNumbers

- (NSString*) usdaNumbers
readwritenonatomiccopy

Provided by category MenuItem(CoreDataProperties).

Definition at line 27 of file MenuItem+CoreDataProperties.h.


The documentation for this class was generated from the following files: