From c4bff914004bf3964d92f455318908ae246c901d Mon Sep 17 00:00:00 2001 From: Aleksandr Dakhno Date: Tue, 5 May 2015 16:09:32 +0300 Subject: [PATCH 1/5] add separate class for 'reportUnit' entity --- Classes/Core/JSRESTBase+JSRESTResource.h | 14 +++++ Classes/Core/JSRESTBase+JSRESTResource.m | 49 ++++++++++++--- Classes/ObjectMappings/JSObjectMappings.h | 1 + Classes/ObjectMappings/JSResourceLookup.m | 9 ++- Classes/ObjectMappings/JSResourceReportUnit.h | 42 +++++++++++++ Classes/ObjectMappings/JSResourceReportUnit.m | 61 +++++++++++++++++++ JaspersoftSDK.xcodeproj/project.pbxproj | 8 +++ 7 files changed, 174 insertions(+), 10 deletions(-) create mode 100644 Classes/ObjectMappings/JSResourceReportUnit.h create mode 100644 Classes/ObjectMappings/JSResourceReportUnit.m diff --git a/Classes/Core/JSRESTBase+JSRESTResource.h b/Classes/Core/JSRESTBase+JSRESTResource.h index 4612898..f0dad86 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.h +++ b/Classes/Core/JSRESTBase+JSRESTResource.h @@ -82,6 +82,20 @@ - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType completionBlock:(JSRequestCompletionBlock)block; +/** +Gets resource lookup for resource. + +@param resourceURI The repository URI (i.e. /reports/samples/) +@param resourceType Type of required resource +@param modelClass expected model class +@param block The block to inform of the results + +@since 2.0 +*/ +- (void)resourceLookupForURI:(NSString *)resourceURI + resourceType:(NSString *)resourceType + modeClass:(Class)modelClass + completionBlock:(JSRequestCompletionBlock)block; /** Gets the list of resource lookups for the resources available in the specified diff --git a/Classes/Core/JSRESTBase+JSRESTResource.m b/Classes/Core/JSRESTBase+JSRESTResource.m index 0622a23..c2e8c0f 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.m +++ b/Classes/Core/JSRESTBase+JSRESTResource.m @@ -79,15 +79,18 @@ - (void)deleteResource:(NSString *)uri completionBlock:(JSRequestCompletionBlock #pragma mark - #pragma mark Public methods for REST V2 resources API -- (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType - completionBlock:(JSRequestCompletionBlock)block { +- (void)resourceLookupForURI:(NSString *)resourceURI + resourceType:(NSString *)resourceType + modeClass:(Class)modelClass + completionBlock:(JSRequestCompletionBlock)block +{ NSString *uri = [JSConstants sharedInstance].REST_RESOURCES_URI; if (resourceURI && ![resourceURI isEqualToString:@"/"]) { uri = [uri stringByAppendingString:resourceURI]; } JSRequest *request = [[JSRequest alloc] initWithUri:uri]; request.restVersion = JSRESTVersion_2; - request.expectedModelClass = [JSResourceLookup class]; + request.expectedModelClass = modelClass; request.completionBlock = block; NSString *responceType = @"application/json"; if (resourceType) { @@ -96,13 +99,43 @@ - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)re [self sendRequest:request additionalHTTPHeaderFields:@{kJSRequestResponceType : responceType}]; } -- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types - recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit completionBlock:(JSRequestCompletionBlock)block { - [self resourceLookups:folderUri query:query types:types sortBy:nil recursive:recursive offset:offset limit:limit completionBlock:block]; +- (void)resourceLookupForURI:(NSString *)resourceURI + resourceType:(NSString *)resourceType + completionBlock:(JSRequestCompletionBlock)block +{ + [self resourceLookupForURI:resourceURI + resourceType:resourceType + modeClass:[JSResourceLookup class] + completionBlock:block]; +} + +- (void)resourceLookups:(NSString *)folderUri + query:(NSString *)query + types:(NSArray *)types + recursive:(BOOL)recursive + offset:(NSInteger)offset + limit:(NSInteger)limit + completionBlock:(JSRequestCompletionBlock)block +{ + [self resourceLookups:folderUri + query:query + types:types + sortBy:nil + recursive:recursive + offset:offset + limit:limit + completionBlock:block]; } -- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types sortBy:(NSString *)sortBy - recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit completionBlock:(JSRequestCompletionBlock)block { +- (void)resourceLookups:(NSString *)folderUri + query:(NSString *)query + types:(NSArray *)types + sortBy:(NSString *)sortBy + recursive:(BOOL)recursive + offset:(NSInteger)offset + limit:(NSInteger)limit + completionBlock:(JSRequestCompletionBlock)block +{ JSRequest *request = [[JSRequest alloc] initWithUri:[JSConstants sharedInstance].REST_RESOURCES_URI]; request.restVersion = JSRESTVersion_2; request.expectedModelClass = [JSResourceLookup class]; diff --git a/Classes/ObjectMappings/JSObjectMappings.h b/Classes/ObjectMappings/JSObjectMappings.h index 9521068..be9e20c 100644 --- a/Classes/ObjectMappings/JSObjectMappings.h +++ b/Classes/ObjectMappings/JSObjectMappings.h @@ -30,6 +30,7 @@ #import "JSReportDescriptor.h" #import "JSResourceLookup.h" +#import "JSResourceReportUnit.h" #import "JSResourceDescriptor.h" #import "JSResourceParameter.h" #import "JSResourceProperty.h" diff --git a/Classes/ObjectMappings/JSResourceLookup.m b/Classes/ObjectMappings/JSResourceLookup.m index 7c8eddd..702bb85 100644 --- a/Classes/ObjectMappings/JSResourceLookup.m +++ b/Classes/ObjectMappings/JSResourceLookup.m @@ -32,13 +32,18 @@ @implementation JSResourceLookup ++ (NSString *)resourceRootKeyPath +{ + return @"resourceLookup"; +} + #pragma mark - JSSerializationDescriptorHolder + (NSArray *)rkRequestDescriptorsForServerProfile:(JSProfile *)serverProfile { NSMutableArray *descriptorsArray = [NSMutableArray array]; [descriptorsArray addObject:[RKRequestDescriptor requestDescriptorWithMapping:[[self classMappingForServerProfile:serverProfile] inverseMapping] objectClass:self - rootKeyPath:@"resourceLookup" + rootKeyPath:[self resourceRootKeyPath] method:RKRequestMethodAny]]; return descriptorsArray; } @@ -71,7 +76,7 @@ + (RKObjectMapping *)classMappingForServerProfile:(JSProfile *)serverProfile { } + (NSArray *)classMappingPathes { - return @[@"resourceLookup", @""]; + return @[[self resourceRootKeyPath], @""]; } @end diff --git a/Classes/ObjectMappings/JSResourceReportUnit.h b/Classes/ObjectMappings/JSResourceReportUnit.h new file mode 100644 index 0000000..a9ca26c --- /dev/null +++ b/Classes/ObjectMappings/JSResourceReportUnit.h @@ -0,0 +1,42 @@ +/* + * Jaspersoft Mobile SDK + * Copyright (C) 2011 - 2014 Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-ios + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile SDK for iOS. + * + * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile SDK for iOS. If not, see + * . + */ + +// +// JSResourceReportUnit.h +// Jaspersoft Corporation +// + +#import "JSResourceLookup.h" + +/** +Represents a reportUnit entity + +@author Olexander Dahno odahno@tibco.com +@since 2.0 +*/ + +@interface JSResourceReportUnit : JSResourceLookup +@property (nonatomic, assign) BOOL alwaysPromptControls; +@end \ No newline at end of file diff --git a/Classes/ObjectMappings/JSResourceReportUnit.m b/Classes/ObjectMappings/JSResourceReportUnit.m new file mode 100644 index 0000000..16a1d7c --- /dev/null +++ b/Classes/ObjectMappings/JSResourceReportUnit.m @@ -0,0 +1,61 @@ +/* + * Jaspersoft Mobile SDK + * Copyright (C) 2011 - 2014 Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-ios + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile SDK for iOS. + * + * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile SDK for iOS. If not, see + * . + */ + +// +// JSResourceReportUnit.m +// Jaspersoft Corporation +// + +#import "JSResourceReportUnit.h" + + +@implementation JSResourceReportUnit + ++ (NSString *)resourceRootKeyPath +{ + return @"reportUnit"; +} + +#pragma mark - JSSerializationDescriptorHolder + ++ (RKObjectMapping *)classMappingForServerProfile:(JSProfile *)serverProfile +{ + RKObjectMapping *classMapping = [RKObjectMapping mappingForClass:self]; + + [classMapping addAttributeMappingsFromDictionary:@{ + @"label": @"label", + @"uri": @"uri", + @"description": @"resourceDescription", + @"resourceType": @"resourceType", + @"version": @"version", + @"permissionMask": @"permissionMask", + @"creationDate": @"creationDate", + @"updateDate": @"updateDate", + @"alwaysPromptControls": @"alwaysPromptControls", + }]; + return classMapping; +} + +@end \ No newline at end of file diff --git a/JaspersoftSDK.xcodeproj/project.pbxproj b/JaspersoftSDK.xcodeproj/project.pbxproj index cae8c9b..a2949a0 100644 --- a/JaspersoftSDK.xcodeproj/project.pbxproj +++ b/JaspersoftSDK.xcodeproj/project.pbxproj @@ -18,6 +18,8 @@ 37455CF8BA142B8554AF5F9A /* JSReportExecutionResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 374558828353F4E8E6F29C17 /* JSReportExecutionResponse.m */; }; 37455EF10B05B5CAE7512A6F /* JSReportExecutionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 374555044AD45FB4F352A96F /* JSReportExecutionRequest.m */; }; 722EF964428E5B92861DCAC8 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AE65D84777378DA82ED7BA4 /* libPods.a */; }; + A147872F4B900E410C80D225 /* JSResourceReportUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = A1478B2D6D9EF0447765EBAA /* JSResourceReportUnit.m */; }; + A1478FC6A4EDD3F87E9A85CE /* JSResourceReportUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = A1478377B817F437E81E18F1 /* JSResourceReportUnit.h */; }; F520FF89196FEE53009435C2 /* JSMandatoryValidationRule.h in Headers */ = {isa = PBXBuildFile; fileRef = F520FF87196FEE53009435C2 /* JSMandatoryValidationRule.h */; settings = {ATTRIBUTES = (Public, ); }; }; F520FF8B196FEE53009435C2 /* JSMandatoryValidationRule.m in Sources */ = {isa = PBXBuildFile; fileRef = F520FF88196FEE53009435C2 /* JSMandatoryValidationRule.m */; }; F523D78518635EB000B93D3F /* JSExecutionStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D78318635EB000B93D3F /* JSExecutionStatus.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -85,6 +87,8 @@ 374558828353F4E8E6F29C17 /* JSReportExecutionResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSReportExecutionResponse.m; sourceTree = ""; }; 37455C26CA9D110D7CBD29A2 /* JSExportExecutionResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSExportExecutionResponse.m; sourceTree = ""; }; 9B199A7873E268BCFDF3074C /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + A1478377B817F437E81E18F1 /* JSResourceReportUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSResourceReportUnit.h; sourceTree = ""; }; + A1478B2D6D9EF0447765EBAA /* JSResourceReportUnit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSResourceReportUnit.m; sourceTree = ""; }; F520FF87196FEE53009435C2 /* JSMandatoryValidationRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMandatoryValidationRule.h; sourceTree = ""; }; F520FF88196FEE53009435C2 /* JSMandatoryValidationRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSMandatoryValidationRule.m; sourceTree = ""; }; F523D78318635EB000B93D3F /* JSExecutionStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExecutionStatus.h; sourceTree = ""; }; @@ -352,6 +356,8 @@ F597690F15E3C826004165A7 /* JSResourceProperty.m */, F5EA36AC18337B4A00E09E10 /* JSResourceLookup.h */, F5EA36AD18337B4A00E09E10 /* JSResourceLookup.m */, + A1478B2D6D9EF0447765EBAA /* JSResourceReportUnit.m */, + A1478377B817F437E81E18F1 /* JSResourceReportUnit.h */, ); name = Resource; sourceTree = ""; @@ -406,6 +412,7 @@ F5D0923818586E4E00C5AEFC /* JSErrorDescriptor.h in Headers */, F520FF89196FEE53009435C2 /* JSMandatoryValidationRule.h in Headers */, F523D78518635EB000B93D3F /* JSExecutionStatus.h in Headers */, + A1478FC6A4EDD3F87E9A85CE /* JSResourceReportUnit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -522,6 +529,7 @@ 3745523E7EE2CE8C64105A1D /* JSExportExecutionResponse.m in Sources */, 37455A556862C72B0B83193F /* JSReportOutputResource.m in Sources */, 37455EF10B05B5CAE7512A6F /* JSReportExecutionRequest.m in Sources */, + A147872F4B900E410C80D225 /* JSResourceReportUnit.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 2cea9f6ae43be27c63b9e60249d70cc000bf8818 Mon Sep 17 00:00:00 2001 From: Aleksandr Dakhno Date: Tue, 5 May 2015 17:06:06 +0300 Subject: [PATCH 2/5] change version since 'new feature' (reportUnit) was added --- Classes/Core/JSRESTBase+JSRESTResource.h | 2 +- Classes/ObjectMappings/JSResourceReportUnit.h | 2 +- Classes/ObjectMappings/JSResourceReportUnit.m | 11 +---------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Classes/Core/JSRESTBase+JSRESTResource.h b/Classes/Core/JSRESTBase+JSRESTResource.h index f0dad86..dcc5434 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.h +++ b/Classes/Core/JSRESTBase+JSRESTResource.h @@ -90,7 +90,7 @@ Gets resource lookup for resource. @param modelClass expected model class @param block The block to inform of the results -@since 2.0 +@since 2.1 */ - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType diff --git a/Classes/ObjectMappings/JSResourceReportUnit.h b/Classes/ObjectMappings/JSResourceReportUnit.h index a9ca26c..56dd624 100644 --- a/Classes/ObjectMappings/JSResourceReportUnit.h +++ b/Classes/ObjectMappings/JSResourceReportUnit.h @@ -34,7 +34,7 @@ Represents a reportUnit entity @author Olexander Dahno odahno@tibco.com -@since 2.0 +@since 2.1 */ @interface JSResourceReportUnit : JSResourceLookup diff --git a/Classes/ObjectMappings/JSResourceReportUnit.m b/Classes/ObjectMappings/JSResourceReportUnit.m index 16a1d7c..3670347 100644 --- a/Classes/ObjectMappings/JSResourceReportUnit.m +++ b/Classes/ObjectMappings/JSResourceReportUnit.m @@ -42,17 +42,8 @@ + (NSString *)resourceRootKeyPath + (RKObjectMapping *)classMappingForServerProfile:(JSProfile *)serverProfile { - RKObjectMapping *classMapping = [RKObjectMapping mappingForClass:self]; - + RKObjectMapping *classMapping = [super classMappingForServerProfile:serverProfile]; [classMapping addAttributeMappingsFromDictionary:@{ - @"label": @"label", - @"uri": @"uri", - @"description": @"resourceDescription", - @"resourceType": @"resourceType", - @"version": @"version", - @"permissionMask": @"permissionMask", - @"creationDate": @"creationDate", - @"updateDate": @"updateDate", @"alwaysPromptControls": @"alwaysPromptControls", }]; return classMapping; From 0a25d08ea267f84b97566e93fc87a39f6d9b3496 Mon Sep 17 00:00:00 2001 From: Alexey Gubarev Date: Thu, 4 Jun 2015 18:39:08 +0300 Subject: [PATCH 3/5] Added support for recent views. Added support for thumbnails. --- Classes/Core/JSConstants.h | 1 + Classes/Core/JSConstants.m | 2 + Classes/Core/JSRESTBase+JSRESTReport.h | 15 ------- Classes/Core/JSRESTBase+JSRESTReport.m | 10 ++--- Classes/Core/JSRESTBase+JSRESTResource.h | 51 +++++++++++++++--------- Classes/Core/JSRESTBase+JSRESTResource.m | 25 +++++++----- JaspersoftSDK.xcodeproj/project.pbxproj | 4 +- 7 files changed, 56 insertions(+), 52 deletions(-) diff --git a/Classes/Core/JSConstants.h b/Classes/Core/JSConstants.h index 114e9d6..0cdebfc 100644 --- a/Classes/Core/JSConstants.h +++ b/Classes/Core/JSConstants.h @@ -273,6 +273,7 @@ @property (nonatomic, readonly) NSString *REST_SERVICES_V2_URI; @property (nonatomic, readonly) NSString *REST_RESOURCE_URI; @property (nonatomic, readonly) NSString *REST_RESOURCES_URI; +@property (nonatomic, readonly) NSString *REST_RESOURCE_THUMBNAIL_URI; @property (nonatomic, readonly) NSString *REST_REPORT_URI; @property (nonatomic, readonly) NSString *REST_REPORTS_URI; @property (nonatomic, readonly) NSString *REST_INPUT_CONTROLS_URI; diff --git a/Classes/Core/JSConstants.m b/Classes/Core/JSConstants.m index 74730dd..ca1b5a3 100644 --- a/Classes/Core/JSConstants.m +++ b/Classes/Core/JSConstants.m @@ -151,6 +151,7 @@ @implementation JSConstants @synthesize REST_SERVICES_V2_URI; @synthesize REST_RESOURCE_URI; @synthesize REST_RESOURCES_URI; +@synthesize REST_RESOURCE_THUMBNAIL_URI; @synthesize REST_REPORT_URI; @synthesize REST_REPORTS_URI; @synthesize REST_INPUT_CONTROLS_URI; @@ -394,6 +395,7 @@ - (void)setRESTURIPrefixes { REST_SERVICES_V2_URI = @"rest_v2"; REST_RESOURCE_URI = @"/resource"; REST_RESOURCES_URI = @"/resources"; + REST_RESOURCE_THUMBNAIL_URI = @"/thumbnails"; REST_REPORT_URI = @"/report"; REST_REPORTS_URI = @"/reports"; REST_INPUT_CONTROLS_URI = @"/inputControls"; diff --git a/Classes/Core/JSRESTBase+JSRESTReport.h b/Classes/Core/JSRESTBase+JSRESTReport.h index b6ceefa..816c276 100644 --- a/Classes/Core/JSRESTBase+JSRESTReport.h +++ b/Classes/Core/JSRESTBase+JSRESTReport.h @@ -48,21 +48,6 @@ // The Report Service v2 //--------------------------------------------------------------------- -/** - Generates the report url according to specified parameters. The new v2/reports - service allows clients to receive report output in a single request-response - using this url. - - @param resourceDescriptor resource descriptor of this report with included list of - report parameter/input control values (list of JSResourceParameter inside descriptor) - @param page a positive integer value used to output a specific page or 0 to output all pages - @param format the format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, XML. - @return the report url - - @since 1.4 - */ -- (NSString *)generateReportUrl:(JSResourceDescriptor *)resourceDescriptor page:(NSInteger)page format:(NSString *)format; - /** Generates the report url to receive all pages report output in HTML format. diff --git a/Classes/Core/JSRESTBase+JSRESTReport.m b/Classes/Core/JSRESTBase+JSRESTReport.m index 9c5b772..ad782e9 100644 --- a/Classes/Core/JSRESTBase+JSRESTReport.m +++ b/Classes/Core/JSRESTBase+JSRESTReport.m @@ -54,7 +54,9 @@ @implementation JSRESTBase(JSRESTReport) #pragma mark - #pragma mark Public methods for REST V2 report API -- (NSString *)generateReportUrl:(JSResourceDescriptor *)resourceDescriptor page:(NSInteger)page format:(NSString *)format { +- (NSString *)generateReportUrl:(NSString *)uri reportParams:(NSDictionary *)reportParams page:(NSInteger)page format:(NSString *)format { + JSResourceDescriptor *resourceDescriptor = [self resourceDescriptorForUri:uri withReportParams:reportParams]; + JSConstants *constants = [JSConstants sharedInstance]; NSMutableDictionary *queryParams = [[NSMutableDictionary alloc] init]; @@ -75,7 +77,7 @@ - (NSString *)generateReportUrl:(JSResourceDescriptor *)resourceDescriptor page: NSString *url = [NSString stringWithFormat:@"%@/%@%@%@.%@", self.serverProfile.serverUrl, constants.REST_SERVICES_V2_URI, constants.REST_REPORTS_URI, resourceDescriptor.uriString, format]; - + NSString *queryString = RKURLEncodedStringFromDictionaryWithEncoding(queryParams, NSUTF8StringEncoding); url = [url stringByAppendingFormat:([url rangeOfString:@"?"].location == NSNotFound) ? @"?%@" : @"&%@" ,queryString]; @@ -90,10 +92,6 @@ - (NSString *)generateReportUrl:(JSResourceDescriptor *)resourceDescriptor page: return url; } -- (NSString *)generateReportUrl:(NSString *)uri reportParams:(NSDictionary *)reportParams page:(NSInteger)page format:(NSString *)format { - return [self generateReportUrl:[self resourceDescriptorForUri:uri withReportParams:reportParams] page:page format:format]; -} - - (void)inputControlsForReport:(NSString *)reportUri ids:(NSArray /**/ *)ids selectedValues:(NSArray /**/ *)selectedValues completionBlock:(JSRequestCompletionBlock)block { JSRequest *request = [[JSRequest alloc] initWithUri:[self fullReportsUriForIC:reportUri withInputControls:ids initialValuesOnly:NO]]; diff --git a/Classes/Core/JSRESTBase+JSRESTResource.h b/Classes/Core/JSRESTBase+JSRESTResource.h index dcc5434..20de649 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.h +++ b/Classes/Core/JSRESTBase+JSRESTResource.h @@ -70,6 +70,27 @@ // The Resources Service v2 //--------------------------------------------------------------------- +/** + Gets the list of resource lookups for the resources available in the specified + folder and matching the specified parameters + + @param folderUri The repository URI (i.e. /reports/samples/) + @param query Match only resources having the specified text in the name or + description (can be nil) + @param types Match only resources of the given types (can be nil) + @param sortBy Represents a field in the results to sort by: uri, label, description, + type, creationDate, updateDate, accessTime, or popularity (based on access events). + @param recursive Get the resources recursively (can be nil) + @param offset Start index for requested page + @param limit The maximum number of items returned to the client. The default + is 0 (can be nil), meaning no limit + @param block The block to inform of the results + + @since 1.8 + */ +- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types sortBy:(NSString *)sortBy + recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit completionBlock:(JSRequestCompletionBlock)block __attribute__((deprecated ("Use 'resourceLookups:query:types:sortBy:accessType:recursive:offset:limit:completionBlock:' method instead"))); + /** Gets resource lookup for resource. @@ -80,7 +101,7 @@ @since 1.9 */ - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType - completionBlock:(JSRequestCompletionBlock)block; + completionBlock:(JSRequestCompletionBlock)block __attribute__((deprecated ("Use 'resourceLookupForURI: resourceType: modeClass: completionBlock:' method instead"))); /** Gets resource lookup for resource. @@ -105,36 +126,28 @@ Gets resource lookup for resource. @param query Match only resources having the specified text in the name or description (can be nil) @param types Match only resources of the given types (can be nil) + @param sortBy Represents a field in the results to sort by: uri, label, description, + type, creationDate, updateDate, accessTime, or popularity (based on access events). + @param accessType Used if sortBy is equal to accessTime or popularity @param recursive Get the resources recursively (can be nil) @param offset Start index for requested page @param limit The maximum number of items returned to the client. The default is 0 (can be nil), meaning no limit @param block The block to inform of the results - @since 1.7 + @since 2.1 */ -- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types +- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types sortBy:(NSString *)sortBy accessType:(NSString *)accessType recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit completionBlock:(JSRequestCompletionBlock)block; /** - Gets the list of resource lookups for the resources available in the specified - folder and matching the specified parameters + Generates the resource thumbnail url - @param folderUri The repository URI (i.e. /reports/samples/) - @param query Match only resources having the specified text in the name or - description (can be nil) - @param types Match only resources of the given types (can be nil) - @param sortBy Represents a field in the results to sort by: uri, label, description, - type, creationDate, updateDate, accessTime, or popularity (based on access events). - @param recursive Get the resources recursively (can be nil) - @param offset Start index for requested page - @param limit The maximum number of items returned to the client. The default - is 0 (can be nil), meaning no limit - @param block The block to inform of the results + @param resourceURI A resourceURI for generating for thumbnail url for it + @return A generated recource thumbnail image url - @since 1.8 + @since 2.1 */ -- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types sortBy:(NSString *)sortBy - recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit completionBlock:(JSRequestCompletionBlock)block; +- (NSString *)generateThumbnailImageUrl:(NSString *)resourceURI; @end diff --git a/Classes/Core/JSRESTBase+JSRESTResource.m b/Classes/Core/JSRESTBase+JSRESTResource.m index c2e8c0f..43fb9b8 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.m +++ b/Classes/Core/JSRESTBase+JSRESTResource.m @@ -42,6 +42,7 @@ static NSString * const _parameterOffset = @"offset"; static NSString * const _parameterRecursive = @"recursive"; static NSString * const _parameterSortBy = @"sortBy"; +static NSString * const _parameterAccessType = @"accessType"; static NSString * const _parameterForceFullPage = @"forceFullPage"; // HTTP resources search parameters @@ -112,25 +113,20 @@ - (void)resourceLookupForURI:(NSString *)resourceURI - (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types + sortBy:(NSString *)sortBy recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit completionBlock:(JSRequestCompletionBlock)block { - [self resourceLookups:folderUri - query:query - types:types - sortBy:nil - recursive:recursive - offset:offset - limit:limit - completionBlock:block]; + [self resourceLookups:folderUri query:query types:types sortBy:sortBy accessType:@"viewed" recursive:recursive offset:offset limit:limit completionBlock:block]; } - (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types sortBy:(NSString *)sortBy + accessType:(NSString *)accessType recursive:(BOOL)recursive offset:(NSInteger)offset limit:(NSInteger)limit @@ -139,21 +135,28 @@ - (void)resourceLookups:(NSString *)folderUri JSRequest *request = [[JSRequest alloc] initWithUri:[JSConstants sharedInstance].REST_RESOURCES_URI]; request.restVersion = JSRESTVersion_2; request.expectedModelClass = [JSResourceLookup class]; - + [request addParameter:_parameterFolderUri withStringValue:folderUri]; [request addParameter:_parameterQuery withStringValue:query]; [request addParameter:_parameterType withArrayValue:types]; [request addParameter:_parameterSortBy withStringValue:sortBy]; - [request addParameter:_parameterLimit withIntegerValue:limit]; + [request addParameter:_parameterAccessType withStringValue:accessType]; [request addParameter:_parameterRecursive withStringValue:[JSConstants stringFromBOOL:recursive]]; [request addParameter:_parameterOffset withIntegerValue:offset]; [request addParameter:_parameterLimit withIntegerValue:limit]; [request addParameter:_parameterForceFullPage withStringValue:[JSConstants stringFromBOOL:YES]]; - + request.completionBlock = block; [self sendRequest:request]; } +- (NSString *)generateThumbnailImageUrl:(NSString *)resourceURI +{ + NSString *restURI = [JSConstants sharedInstance].REST_SERVICES_V2_URI; + NSString *thumbnailURI = [JSConstants sharedInstance].REST_RESOURCE_THUMBNAIL_URI; + return [NSString stringWithFormat:@"%@/%@%@%@?defaultAllowed=false", self.serverProfile.serverUrl, restURI, thumbnailURI, resourceURI]; +} + #pragma mark - #pragma mark Private methods diff --git a/JaspersoftSDK.xcodeproj/project.pbxproj b/JaspersoftSDK.xcodeproj/project.pbxproj index a2949a0..0d07368 100644 --- a/JaspersoftSDK.xcodeproj/project.pbxproj +++ b/JaspersoftSDK.xcodeproj/project.pbxproj @@ -444,7 +444,7 @@ F59768B415E3C75E004165A7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0610; + LastUpgradeCheck = 0630; }; buildConfigurationList = F59768B715E3C75E004165A7 /* Build configuration list for PBXProject "JaspersoftSDK" */; compatibilityVersion = "Xcode 3.2"; @@ -552,6 +552,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -594,6 +595,7 @@ COPY_PHASE_STRIP = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_THUMB_SUPPORT = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; From 0c72755bec26e240e2f5b554ff2b573b6b97e15a Mon Sep 17 00:00:00 2001 From: Alexey Gubarev Date: Thu, 4 Jun 2015 18:59:23 +0300 Subject: [PATCH 4/5] Corrected name of method --- Classes/Core/JSRESTBase+JSRESTResource.h | 4 ++-- Classes/Core/JSRESTBase+JSRESTResource.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/Core/JSRESTBase+JSRESTResource.h b/Classes/Core/JSRESTBase+JSRESTResource.h index 20de649..5a13be7 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.h +++ b/Classes/Core/JSRESTBase+JSRESTResource.h @@ -101,7 +101,7 @@ @since 1.9 */ - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType - completionBlock:(JSRequestCompletionBlock)block __attribute__((deprecated ("Use 'resourceLookupForURI: resourceType: modeClass: completionBlock:' method instead"))); + completionBlock:(JSRequestCompletionBlock)block __attribute__((deprecated ("Use 'resourceLookupForURI: resourceType: modelClass: completionBlock:' method instead"))); /** Gets resource lookup for resource. @@ -115,7 +115,7 @@ Gets resource lookup for resource. */ - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType - modeClass:(Class)modelClass + modelClass:(Class)modelClass completionBlock:(JSRequestCompletionBlock)block; /** diff --git a/Classes/Core/JSRESTBase+JSRESTResource.m b/Classes/Core/JSRESTBase+JSRESTResource.m index 43fb9b8..8421ea7 100644 --- a/Classes/Core/JSRESTBase+JSRESTResource.m +++ b/Classes/Core/JSRESTBase+JSRESTResource.m @@ -82,7 +82,7 @@ - (void)deleteResource:(NSString *)uri completionBlock:(JSRequestCompletionBlock - (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType - modeClass:(Class)modelClass + modelClass:(Class)modelClass completionBlock:(JSRequestCompletionBlock)block { NSString *uri = [JSConstants sharedInstance].REST_RESOURCES_URI; @@ -106,7 +106,7 @@ - (void)resourceLookupForURI:(NSString *)resourceURI { [self resourceLookupForURI:resourceURI resourceType:resourceType - modeClass:[JSResourceLookup class] + modelClass:[JSResourceLookup class] completionBlock:block]; } From ad38ca861d62809e147555440610c59e9a70d14b Mon Sep 17 00:00:00 2001 From: Alexey Gubarev Date: Fri, 12 Jun 2015 17:46:14 +0300 Subject: [PATCH 5/5] Corrected sending locale to server --- Classes/Core/JSRESTBase+JSRESTSession.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Core/JSRESTBase+JSRESTSession.m b/Classes/Core/JSRESTBase+JSRESTSession.m index edd5eb9..6052bab 100644 --- a/Classes/Core/JSRESTBase+JSRESTSession.m +++ b/Classes/Core/JSRESTBase+JSRESTSession.m @@ -65,7 +65,7 @@ - (BOOL)authenticationToken { // Add locale to session NSString *currentLanguage = [[NSLocale preferredLanguages] objectAtIndex:0]; - NSInteger dividerPosition = [currentLanguage rangeOfString:@"_"].location; + NSInteger dividerPosition = [currentLanguage rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"_-"]].location; if (dividerPosition != NSNotFound) { currentLanguage = [currentLanguage substringToIndex:dividerPosition]; }