#import "PPRecipe.h"

NSString *kPPImagePath = @"kPPImagePath";
NSString *kPPObjectID = @"kPPObjectID";
NSString *kPPServes = @"kPPServes";

//START:UTH_DynamicProperties
@implementation PPRecipe

@dynamic desc;
@dynamic name;
@dynamic type;
@dynamic author;
@dynamic lastUsed;
//END:UTH_DynamicProperties

//START:metadataMethod
- (NSDictionary*)metadata;
{
  NSMutableDictionary *metadataDict = [NSMutableDictionary dictionary];
  
  [metadataDict setValue:[self name] 
                  forKey:(id)kMDItemTitle];
  [metadataDict setValue:[self desc] 
                  forKey:(id)kMDItemTextContent];
  [metadataDict setValue:[[self author] valueForKey:@"name"] 
                  forKey:(id)kMDItemAuthors];
  [metadataDict setValue:[self valueForKey:@"imagePath"] 
                  forKey:kPPImagePath];
  [metadataDict setValue:[self lastUsed] forKey:(id)kMDItemLastUsedDate];
  [metadataDict setValue:[self valueForKey:@"serves"] forKey:kPPServes];
  [metadataDict setValue:[NSString stringWithFormat:@"Recipe: %@", [self name]] 
                  forKey:(id)kMDItemDisplayName];
  [metadataDict setValue:[[[self objectID] URIRepresentation] absoluteString] 
                  forKey:kPPObjectID];
  return metadataDict;
}
//END:metadataMethod

//START:metadataNameMethod
- (NSString*)metadataFilename;
{
  return [[self name] stringByAppendingPathExtension:@"grokkingrecipe"];
}
//END:metadataNameMethod

@end
