diff --git a/SOPE/GDLContentStore/ChangeLog b/SOPE/GDLContentStore/ChangeLog index fda01529f..d570302cb 100644 --- a/SOPE/GDLContentStore/ChangeLog +++ b/SOPE/GDLContentStore/ChangeLog @@ -1,3 +1,9 @@ +2011-05-30 Wolfgang Sourdeau + + * GCSFolder.m (-lastModificationDate): new method that returns the + last modification date based on the higher value of the + "c_lastmodified" column. + 2010-12-30 Wolfgang Sourdeau * EOQualifier+GCS.m (_appendNotQualifier:toString:): new method diff --git a/SOPE/GDLContentStore/GCSFolder.h b/SOPE/GDLContentStore/GCSFolder.h index b1370b6e2..d10185a7e 100644 --- a/SOPE/GDLContentStore/GCSFolder.h +++ b/SOPE/GDLContentStore/GCSFolder.h @@ -140,6 +140,8 @@ - (unsigned int) recordsCountByExcludingDeleted: (BOOL) includeDeleted; +- (NSCalendarDate *) lastModificationDate; + @end #endif /* __GDLContentStore_GCSFolder_H__ */ diff --git a/SOPE/GDLContentStore/GCSFolder.m b/SOPE/GDLContentStore/GCSFolder.m index 4b26a124a..95eca6f52 100644 --- a/SOPE/GDLContentStore/GCSFolder.m +++ b/SOPE/GDLContentStore/GCSFolder.m @@ -1368,6 +1368,36 @@ static NSArray *contentFieldNames = nil; return count; } +- (NSCalendarDate *) lastModificationDate +{ + NSArray *records; + EOFetchSpecification *lmSpec; + EOSortOrdering *ordering; + NSNumber *lastModified; + NSCalendarDate *lastModificationDate = nil; + + ordering = [EOSortOrdering sortOrderingWithKey: @"c_lastmodified" + selector: EOCompareDescending]; + lmSpec = [EOFetchSpecification + fetchSpecificationWithEntityName: [self folderName] + qualifier: nil + sortOrderings: [NSArray arrayWithObject: ordering]]; + + records = [self fetchFields: [NSArray arrayWithObject: @"c_lastmodified"] + fetchSpecification: lmSpec + ignoreDeleted: NO]; + if ([records count]) + { + lastModified + = [[records objectAtIndex: 0] objectForKey: @"c_lastmodified"]; + lastModificationDate + = [NSCalendarDate dateWithTimeIntervalSince1970: + (NSTimeInterval) [lastModified intValue]]; + } + + return lastModificationDate; +} + /* description */ - (NSString *)description {