F46F104918ABAC910063E503 /* KCD.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F46F104718ABAC910063E503 /* KCD.xcdatamodeld */; };
F47B78B218A7B42B0011386E /* HMJSONViewWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F47B78B018A7B42B0011386E /* HMJSONViewWindowController.m */; };
F47B78B318A7B42B0011386E /* HMJSONViewWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F47B78B118A7B42B0011386E /* HMJSONViewWindowController.xib */; };
+ F4B414E918B09A4B00468DAF /* HMMasterMapAreaCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B414E818B09A4B00468DAF /* HMMasterMapAreaCommand.m */; };
F4BDEB47187252F30069D0CE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4BDEB46187252F30069D0CE /* Cocoa.framework */; };
F4BDEB51187252F30069D0CE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F4BDEB4F187252F30069D0CE /* InfoPlist.strings */; };
F4BDEB53187252F30069D0CE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4BDEB52187252F30069D0CE /* main.m */; };
F47B78AF18A7B42B0011386E /* HMJSONViewWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMJSONViewWindowController.h; sourceTree = "<group>"; };
F47B78B018A7B42B0011386E /* HMJSONViewWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMJSONViewWindowController.m; sourceTree = "<group>"; };
F47B78B118A7B42B0011386E /* HMJSONViewWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HMJSONViewWindowController.xib; sourceTree = "<group>"; };
+ F4B414E718B09A4B00468DAF /* HMMasterMapAreaCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMasterMapAreaCommand.h; sourceTree = "<group>"; };
+ F4B414E818B09A4B00468DAF /* HMMasterMapAreaCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMasterMapAreaCommand.m; sourceTree = "<group>"; };
F4BDEB43187252F30069D0CE /* KCD.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KCD.app; sourceTree = BUILT_PRODUCTS_DIR; };
F4BDEB46187252F30069D0CE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
F4BDEB49187252F30069D0CE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
F4D2CBC118AD0E1A000EBC59 /* HMMasterSTypeCommand.m */,
F4D2CBC918B05E58000EBC59 /* HMMaserShipCommand.h */,
F4D2CBCA18B05E58000EBC59 /* HMMaserShipCommand.m */,
+ F4B414E718B09A4B00468DAF /* HMMasterMapAreaCommand.h */,
+ F4B414E818B09A4B00468DAF /* HMMasterMapAreaCommand.m */,
);
name = Command;
sourceTree = "<group>";
F4D2CBCB18B05E58000EBC59 /* HMMaserShipCommand.m in Sources */,
F46F104118A9B85E0063E503 /* HMJSONNode.m in Sources */,
F4C1190818A746EB005D5B25 /* HMJSONTracker.m in Sources */,
+ F4B414E918B09A4B00468DAF /* HMMasterMapAreaCommand.m in Sources */,
F4C118FB18A67B1C005D5B25 /* CanonicalRequest.m in Sources */,
F4BDEB5A187252F30069D0CE /* HMAppDelegate.m in Sources */,
F46F104918ABAC910063E503 /* KCD.xcdatamodeld in Sources */,
--- /dev/null
+//
+// HMMasterMapAreaCommand.h
+// KCD
+//
+// Created by Hori,Masaki on 2014/02/16.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMJSONCommand.h"
+
+@interface HMMasterMapAreaCommand : HMJSONCommand
+
+@end
--- /dev/null
+//
+// HMMasterMapAreaCommand.m
+// KCD
+//
+// Created by Hori,Masaki on 2014/02/16.
+// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMMasterMapAreaCommand.h"
+
+@implementation HMMasterMapAreaCommand
++ (void)load
+{
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ [HMJSONCommand registerClass:self];
+ });
+}
+
++ (BOOL)canExcuteAPI:(NSString *)api
+{
+ return [api isEqualToString:@"/kcsapi/api_get_master/maparea"];
+}
+- (void)execute
+{
+ NSArray *api_data = [self.json objectForKey:@"api_data"];
+ if(![api_data isKindOfClass:[NSArray class]]) {
+ [self log:@"api_data is NOT NSArray."];
+ return;
+ }
+
+ NSManagedObjectContext *managedObjectContext = [[NSApp delegate] managedObjectContext];
+
+ for(NSDictionary *type in api_data) {
+ NSString *stypeID = type[@"api_id"];
+ NSFetchRequest *req = [NSFetchRequest fetchRequestWithEntityName:@"MasterMapArea"];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id = %@", stypeID];
+ [req setPredicate:predicate];
+ NSError *error = nil;
+ id result = [managedObjectContext executeFetchRequest:req
+ error:&error];
+ if(error) {
+ [self log:@"Fetch error: %@", error];
+ continue;
+ }
+ NSManagedObject *object = nil;
+ if(!result || [result count] == 0) {
+ object = [NSEntityDescription insertNewObjectForEntityForName:@"MasterMapArea"
+ inManagedObjectContext:managedObjectContext];
+ } else {
+ object = result[0];
+ }
+
+ for(NSString *key in type) {
+ id value = type[key];
+ if([object validateValue:&value forKey:key error:NULL]) {
+ [object setValue:value forKey:key];
+ }
+ }
+ }
+}
+@end
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="3401" systemVersion="13B42" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
+ <entity name="MasterMapArea" representedClassName="HMKCManagedObject" syncable="YES">
+ <attribute name="id" attributeType="Integer 32" syncable="YES"/>
+ <attribute name="name" attributeType="String" syncable="YES"/>
+ <attribute name="type" optional="YES" attributeType="Integer 32" syncable="YES"/>
+ </entity>
<entity name="MasterShip" representedClassName="HMKCManagedObject" syncable="YES">
<attribute name="afterbull" attributeType="Integer 32" syncable="YES"/>
<attribute name="afterfuel" attributeType="Integer 32" syncable="YES"/>
<relationship name="ships" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MasterShip" inverseName="stype" inverseEntity="MasterShip" syncable="YES"/>
</entity>
<elements>
- <element name="MasterSType" positionX="0" positionY="0" width="0" height="0"/>
<element name="MasterShip" positionX="0" positionY="0" width="0" height="0"/>
+ <element name="MasterSType" positionX="0" positionY="0" width="0" height="0"/>
+ <element name="MasterMapArea" positionX="0" positionY="0" width="0" height="0"/>
</elements>
</model>
\ No newline at end of file