Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for cat and tag #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added ...
Empty file.
76 changes: 59 additions & 17 deletions src/ArtAround.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="7701" systemVersion="15A284" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic">
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="9525" systemVersion="15A284" minimumToolsVersion="Automatic">
<entity name="Art" representedClassName="Art">
<attribute name="artDescription" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="artist" optional="YES" attributeType="String">
<userInfo/>
</attribute>
<attribute name="commissioned" optional="YES" attributeType="Boolean" syncable="YES"/>
<attribute name="commissionedBy" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="commissionedByLink" optional="YES" attributeType="String" syncable="YES"/>
Expand Down Expand Up @@ -36,6 +33,7 @@
<attribute name="year" optional="YES" attributeType="Integer 32">
<userInfo/>
</attribute>
<relationship name="artists" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Artist" inverseName="arts" inverseEntity="Artist" syncable="YES"/>
<relationship name="categories" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Category" inverseName="arts" inverseEntity="Category">
<userInfo/>
</relationship>
Expand All @@ -52,6 +50,10 @@
<relationship name="tags" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Tag" inverseName="arts" inverseEntity="Tag" syncable="YES"/>
<userInfo/>
</entity>
<entity name="Artist" representedClassName="Artist" syncable="YES">
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="arts" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Art" inverseName="artists" inverseEntity="Art" syncable="YES"/>
</entity>
<entity name="Category" representedClassName="Category">
<attribute name="title" optional="YES" attributeType="String">
<userInfo/>
Expand Down Expand Up @@ -105,7 +107,7 @@
<userInfo/>
</entity>
<entity name="Photo" representedClassName="Photo">
<attribute name="dateAdded" optional="YES" attributeType="Date" defaultDateTimeInterval="315556200" defaultValueString="1/1/11" syncable="YES"/>
<attribute name="dateAdded" optional="YES" attributeType="Date" defaultDateTimeInterval="0" syncable="YES"/>
<attribute name="flickrID" optional="YES" attributeType="Integer 64" defaultValueString="0">
<userInfo/>
</attribute>
Expand Down Expand Up @@ -189,5 +191,6 @@
<element name="Neighborhood" positionX="-488" positionY="213" width="128" height="75"/>
<element name="Photo" positionX="-108" positionY="213" width="128" height="435"/>
<element name="Tag" positionX="-279" positionY="216" width="128" height="75"/>
<element name="Artist" positionX="-288" positionY="207" width="128" height="75"/>
</elements>
</model>
7 changes: 4 additions & 3 deletions src/ArtAround/Classes/AppDelegate/ArtAroundAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#import "MapViewController.h"
#import "FBConnect.h"
#import "IntroViewController.h"

#import <CoreLocation/CoreLocation.h>
#define kGoogleAnalyticsAccountID @"UA-41817858-1"
// Dispatch period in seconds
static const NSInteger kGANDispatchPeriodSec = 10;

@interface ArtAroundAppDelegate : NSObject <UIApplicationDelegate, FBSessionDelegate>
@interface ArtAroundAppDelegate : NSObject <UIApplicationDelegate, FBSessionDelegate,CLLocationManagerDelegate>
{
IntroViewController *_introVC;
}
Expand All @@ -27,7 +27,8 @@ static const NSInteger kGANDispatchPeriodSec = 10;
@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, retain) Facebook *facebook;

@property (nonatomic, retain) CLLocationManager *locationMgr;
@property (nonatomic, retain) CLLocation *lastLocation;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
- (void) closeIntro;
Expand Down
38 changes: 35 additions & 3 deletions src/ArtAround/Classes/AppDelegate/ArtAroundAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @implementation ArtAroundAppDelegate
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
@synthesize facebook = _facebook;
@synthesize mapViewController = _mapViewController;

@synthesize lastLocation;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

Expand Down Expand Up @@ -56,7 +56,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[navController release];

//add the nav controller view to the window
[self.window addSubview:self.navigationController.view];
self.window.rootViewController=navController;

//download static config items
[self performSelectorInBackground:@selector(downloadConfig) withObject:nil];
Expand Down Expand Up @@ -86,9 +86,41 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}];

}

self.locationMgr = [[CLLocationManager alloc] init];
self.locationMgr.delegate = self;
self.locationMgr.desiredAccuracy = kCLLocationAccuracyBest; // 100 m

if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0)
{
[self.locationMgr requestAlwaysAuthorization];
}

[self.locationMgr startUpdatingLocation];
return YES;
}
// For Map Current Location
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
if([CLLocationManager locationServicesEnabled])
{
NSLog(@"Location Services Enabled");

if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"App Permission Denied"
message:@"To re-enable, please go to Settings and turn on Location Service for this app."delegate:nil
cancelButtonTitle:@"OK"otherButtonTitles:nil];
[alert show];
}
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if (!self.lastLocation)
{
self.lastLocation = newLocation;
}
}

- (void) closeIntro
{
Expand Down
4 changes: 4 additions & 0 deletions src/ArtAround/Classes/DataManagement/AAAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
static AAAPIManager *_sharedInstance = nil;
static const NSString *_kAPIRoot = @"http://theartaround.us/api/v1/";
static const NSString *_kFlagAPIRoot = @"http://theartaround.us/arts";

////Local
//static const NSString *_kAPIRoot = @"http://192.168.0.51:3000/api/v1/";
//static const NSString *_kFlagAPIRoot = @"http://192.168.0.51:3000/arts";
//static const NSString *_kAPIRoot = @"http://staging.theartaround.us/api/v1/";
//static const NSString *_kFlagAPIRoot = @"http://staging.theartaround.us/arts";
static const NSString *_kAPIFormat = @"json";
Expand Down
27 changes: 17 additions & 10 deletions src/ArtAround/Classes/DataManagement/ArtParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#import "EventParser.h"
#import <MapKit/MapKit.h>
#import "TagParser.h"
#import "ArtistParser.h"
#import "Artist.h"
@implementation ArtParser

#pragma mark - Instance Methods
Expand Down Expand Up @@ -86,7 +88,8 @@ + (Art *)artForDict:(NSDictionary *)artDict inContext:(NSManagedObjectContext *)
art.slug = slug;
art.locationDescription = [AAAPIManager clean:[artDict objectForKey:@"location_description"]];
art.artDescription = [AAAPIManager clean:[artDict objectForKey:@"description"]];
art.artist = [AAAPIManager clean:[artDict objectForKey:@"artist"]];
NSLog(@"%@",artDict);
//art.artist = [AAAPIManager clean:[artDict objectForKey:@"artist"]];
art.website = [AAAPIManager clean:[artDict objectForKey:@"website"]];
art.title = [AAAPIManager clean:[artDict objectForKey:@"title"]];
if ([artDict objectForKey:@"year"] && ![[artDict objectForKey:@"year"] isKindOfClass:[NSNull class]])
Expand Down Expand Up @@ -157,15 +160,19 @@ + (Art *)artForDict:(NSDictionary *)artDict inContext:(NSManagedObjectContext *)


//make sure we don't have empty artist
if (art.artist) {
art.artist = [art.artist stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
} else {
art.artist = @"";
}
if ([art.artist isEqualToString:@""] || [art.artist isEqualToString:@"?"]) {
art.artist = @"Unknown";
}

// if (art.artist) {
// art.artist = [art.artist stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// } else {
// art.artist = @"";
// }
// if ([art.artist isEqualToString:@""] || [art.artist isEqualToString:@"?"]) {
// art.artist = @"Unknown";
// }
if ([artDict objectForKey:@"artist"] && [[artDict objectForKey:@"artist"] isKindOfClass:[NSArray class]])
art.artists = [ArtistParser setForTitles:[artDict objectForKey:@"artist"] inContext:context];
else if ([artDict objectForKey:@"artist"] && [[artDict objectForKey:@"artist"] isKindOfClass:[NSString class]]) {
art.artists = [ArtistParser setForTitles:[[artDict objectForKey:@"artist"] componentsSeparatedByString:@","] inContext:context];
}

//location
NSArray *location = [artDict objectForKey:@"location"];
Expand Down
18 changes: 18 additions & 0 deletions src/ArtAround/Classes/DataManagement/ArtistParser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ArtistParser.h
// ArtAround
//
// Created by samosys on 20/02/16.
// Copyright © 2016 ArtAround. All rights reserved.
//

#import "ItemParser.h"
#import "Artist.h"

@interface ArtistParser : ItemParser
+ (NSSet *)setForTitles:(NSArray *)artistTitles inContext:(NSManagedObjectContext *)context;
+ (Artist *)artistForTitle:(NSString *)title inContext:(NSManagedObjectContext *)context;

+ (NSArray *)arrayFortagRequest:(ASIHTTPRequest *)tagRequest;

@end
57 changes: 57 additions & 0 deletions src/ArtAround/Classes/DataManagement/ArtistParser.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// ArtistParser.m
// ArtAround
//
// Created by samosys on 20/02/16.
// Copyright © 2016 ArtAround. All rights reserved.
//

#import "ArtistParser.h"
#import "JSONKit.h"
@implementation ArtistParser

+ (NSSet *)setForTitles:(NSArray *)artistTitles inContext:(NSManagedObjectContext *)context
{
NSMutableSet *tages = [NSMutableSet set];
for (NSString *title in artistTitles) {

//get the category for the given title
//add cateogry to the set
Artist *tag = [ArtistParser artistForTitle:title inContext:context];
[tages addObject:tag];

}
return tages;
}

+ (Artist *)artistForTitle:(NSString *)title inContext:(NSManagedObjectContext *)context{
//get or create a category with the given title.
Artist *tag = [ItemParser existingEntity:@"Artist" inContext:context uniqueKey:@"title" uniqueValue:title];
if (!tag) {
tag = (Artist *)[NSEntityDescription insertNewObjectForEntityForName:@"Artist" inManagedObjectContext:context];

NSString *arrayTitle = @"";
if ([title isKindOfClass:[NSArray class]])
arrayTitle = [(NSArray*)title componentsJoinedByString:@", "];
else
arrayTitle = title;

tag.title = [AAAPIManager clean:arrayTitle];
}
return tag;
}

+ (NSArray *)arrayFortagRequest:(ASIHTTPRequest *)tagRequest
{
//deserialize the json response
NSError *error = nil;
NSArray *tages = [[tagRequest responseData] objectFromJSONDataWithParseOptions:JKParseOptionNone error:&error];

//check for an error
if (error || !tages) {
DebugLog(@"arrayForCategoryRequest error: %@", error);
}

return tages;
}
@end
90 changes: 51 additions & 39 deletions src/ArtAround/Classes/Models/Art.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,79 @@
// Art.h
// ArtAround
//
// Created by Brian Singer on 7/9/13.
// Copyright (c) 2013 ArtAround. All rights reserved.
// Created by samosys on 20/02/16.
// Copyright © 2016 ArtAround. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Category, Comment, Event, Neighborhood, Photo,Tag;
@class Artist, Category, Comment, Event, Neighborhood, Photo;

NS_ASSUME_NONNULL_BEGIN

@interface Art : NSManagedObject

@property (nonatomic, retain) NSString * artDescription;
@property (nonatomic, retain) NSString * artist;
@property (nonatomic, retain) NSString * commissionedBy;
@property (nonatomic, retain) NSNumber * commissioned;
@property (nonatomic, retain) NSDate * createdAt;
@property (nonatomic, retain) NSDecimalNumber * distance;
@property (nonatomic, retain) NSNumber * favorite;
@property (nonatomic, retain) NSDecimalNumber * latitude;
@property (nonatomic, retain) NSString * locationDescription;
@property (nonatomic, retain) NSDecimalNumber * longitude;
@property (nonatomic, retain) NSNumber * rank;
@property (nonatomic, retain) NSString * slug;
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * website;
@property (nonatomic, retain) NSNumber * ward;
@property (nonatomic, retain) NSNumber * year;
@property (nonatomic, retain) NSString * commissionedByLink;
@property (nonatomic, retain) NSSet *categories;
@property (nonatomic, retain) NSSet *comments;
@property (nonatomic, retain) Event *event;
@property (nonatomic, retain) Neighborhood *neighborhood;
@property (nonatomic, retain) NSSet *photos;
@property (nonatomic, retain) NSSet *tags;
@property (nullable, nonatomic, retain) NSString *artDescription;
@property (nullable, nonatomic, retain) NSNumber *commissioned;
@property (nullable, nonatomic, retain) NSString *commissionedBy;
@property (nullable, nonatomic, retain) NSString *commissionedByLink;
@property (nullable, nonatomic, retain) NSDate *createdAt;
@property (nullable, nonatomic, retain) NSDecimalNumber *distance;
@property (nullable, nonatomic, retain) NSNumber *favorite;
@property (nullable, nonatomic, retain) NSDecimalNumber *latitude;
@property (nullable, nonatomic, retain) NSString *locationDescription;
@property (nullable, nonatomic, retain) NSDecimalNumber *longitude;
@property (nullable, nonatomic, retain) NSNumber *rank;
@property (nullable, nonatomic, retain) NSString *slug;
@property (nullable, nonatomic, retain) NSString *title;
@property (nullable, nonatomic, retain) NSNumber *ward;
@property (nullable, nonatomic, retain) NSString *website;
@property (nullable, nonatomic, retain) NSNumber *year;
@property (nullable, nonatomic, retain) NSSet<Category *> *categories;
@property (nullable, nonatomic, retain) NSSet<Comment *> *comments;
@property (nullable, nonatomic, retain) Event *event;
@property (nullable, nonatomic, retain) Neighborhood *neighborhood;
@property (nullable, nonatomic, retain) NSSet<Photo *> *photos;
@property (nullable, nonatomic, retain) NSSet<NSManagedObject *> *tags;
@property (nullable, nonatomic, retain) NSSet<Artist *> *artists;

// Insert code here to declare functionality of your managed object subclass

@end

@interface Art (CoreDataGeneratedAccessors)

- (void)addCategoriesObject:(Category *)value;
- (void)removeCategoriesObject:(Category *)value;
- (void)addCategories:(NSSet *)values;
- (void)removeCategories:(NSSet *)values;
- (void)addCategories:(NSSet<Category *> *)values;
- (void)removeCategories:(NSSet<Category *> *)values;

- (void)addCommentsObject:(Comment *)value;
- (void)removeCommentsObject:(Comment *)value;
- (void)addComments:(NSSet *)values;
- (void)removeComments:(NSSet *)values;
- (void)addComments:(NSSet<Comment *> *)values;
- (void)removeComments:(NSSet<Comment *> *)values;

- (void)addPhotosObject:(Photo *)value;
- (void)removePhotosObject:(Photo *)value;
- (void)addPhotos:(NSSet *)values;
- (void)removePhotos:(NSSet *)values;
- (void)addPhotos:(NSSet<Photo *> *)values;
- (void)removePhotos:(NSSet<Photo *> *)values;

- (void)addTagsObject:(NSManagedObject *)value;
- (void)removeTagsObject:(NSManagedObject *)value;
- (void)addTags:(NSSet<NSManagedObject *> *)values;
- (void)removeTags:(NSSet<NSManagedObject *> *)values;

- (void)addTagsObject:(Tag *)value;
- (void)removeTagsObject:(Tag *)value;
- (void)addTags:(NSSet *)values;
- (void)removeTags:(NSSet *)values;
- (void)addArtistsObject:(Artist *)value;
- (void)removeArtistsObject:(Artist *)value;
- (void)addArtists:(NSSet<Artist *> *)values;
- (void)removeArtists:(NSSet<Artist *> *)values;

- (NSString*)categoriesString;
- (NSString*)Singlecategories;
- (NSString*)tagString;



- (NSString*)Singletag;
-(NSString *)ArtistString;
@end

NS_ASSUME_NONNULL_END
Loading