Skip to content

Commit

Permalink
Merge pull request #2 from Jaspersoft/v_2_0_1
Browse files Browse the repository at this point in the history
Version 2.0.1
  • Loading branch information
Alexey committed Jul 13, 2015
2 parents 6bc98b8 + ad38ca8 commit 8e0418e
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 54 deletions.
1 change: 1 addition & 0 deletions Classes/Core/JSConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Classes/Core/JSConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
15 changes: 0 additions & 15 deletions Classes/Core/JSRESTBase+JSRESTReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 4 additions & 6 deletions Classes/Core/JSRESTBase+JSRESTReport.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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];

Expand All @@ -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 /*<NSString>*/ *)ids
selectedValues:(NSArray /*<JSReportParameter>*/ *)selectedValues completionBlock:(JSRequestCompletionBlock)block {
JSRequest *request = [[JSRequest alloc] initWithUri:[self fullReportsUriForIC:reportUri withInputControls:ids initialValuesOnly:NO]];
Expand Down
63 changes: 45 additions & 18 deletions Classes/Core/JSRESTBase+JSRESTResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@
// The Resources Service v2
//---------------------------------------------------------------------

/**
Gets resource lookup for resource.
@param resourceURI The repository URI (i.e. /reports/samples/)
@param resourceType Type of required resource
@param block The block to inform of the results
@since 1.9
*/
- (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType
completionBlock:(JSRequestCompletionBlock)block;


/**
Gets the list of resource lookups for the resources available in the specified
folder and matching the specified parameters
Expand All @@ -91,16 +78,45 @@
@param query Match only resources having the specified text in the name or
description (can be <code>nil</code>)
@param types Match only resources of the given types (can be <code>nil</code>)
@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 <code>nil</code>)
@param offset Start index for requested page
@param limit The maximum number of items returned to the client. The default
is 0 (can be <code>nil</code>), meaning no limit
@param block The block to inform of the results
@since 1.7
@since 1.8
*/
- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types
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 __attribute__((deprecated ("Use 'resourceLookups:query:types:sortBy:accessType:recursive:offset:limit:completionBlock:' method instead")));

/**
Gets resource lookup for resource.
@param resourceURI The repository URI (i.e. /reports/samples/)
@param resourceType Type of required resource
@param block The block to inform of the results
@since 1.9
*/
- (void)resourceLookupForURI:(NSString *)resourceURI resourceType:(NSString *)resourceType
completionBlock:(JSRequestCompletionBlock)block __attribute__((deprecated ("Use 'resourceLookupForURI: resourceType: modelClass: completionBlock:' method instead")));

/**
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.1
*/
- (void)resourceLookupForURI:(NSString *)resourceURI
resourceType:(NSString *)resourceType
modelClass:(Class)modelClass
completionBlock:(JSRequestCompletionBlock)block;

/**
Gets the list of resource lookups for the resources available in the specified
Expand All @@ -112,15 +128,26 @@
@param types Match only resources of the given types (can be <code>nil</code>)
@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 <code>nil</code>)
@param offset Start index for requested page
@param limit The maximum number of items returned to the client. The default
is 0 (can be <code>nil</code>), meaning no limit
@param block The block to inform of the results
@since 1.8
@since 2.1
*/
- (void)resourceLookups:(NSString *)folderUri query:(NSString *)query types:(NSArray *)types sortBy:(NSString *)sortBy
- (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;

/**
Generates the resource thumbnail url
@param resourceURI A resourceURI for generating for thumbnail url for it
@return A generated recource thumbnail image url
@since 2.1
*/
- (NSString *)generateThumbnailImageUrl:(NSString *)resourceURI;

@end
58 changes: 47 additions & 11 deletions Classes/Core/JSRESTBase+JSRESTResource.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -79,15 +80,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
modelClass:(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) {
Expand All @@ -96,31 +100,63 @@ - (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
modelClass:[JSResourceLookup class]
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
{
[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
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
accessType:(NSString *)accessType
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];

[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

Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/JSRESTBase+JSRESTSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
1 change: 1 addition & 0 deletions Classes/ObjectMappings/JSObjectMappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#import "JSReportDescriptor.h"
#import "JSResourceLookup.h"
#import "JSResourceReportUnit.h"
#import "JSResourceDescriptor.h"
#import "JSResourceParameter.h"
#import "JSResourceProperty.h"
Expand Down
9 changes: 7 additions & 2 deletions Classes/ObjectMappings/JSResourceLookup.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -71,7 +76,7 @@ + (RKObjectMapping *)classMappingForServerProfile:(JSProfile *)serverProfile {
}

+ (NSArray *)classMappingPathes {
return @[@"resourceLookup", @""];
return @[[self resourceRootKeyPath], @""];
}

@end
42 changes: 42 additions & 0 deletions Classes/ObjectMappings/JSResourceReportUnit.h
Original file line number Diff line number Diff line change
@@ -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
* <http://www.gnu.org/licenses/lgpl>.
*/

//
// JSResourceReportUnit.h
// Jaspersoft Corporation
//

#import "JSResourceLookup.h"

/**
Represents a reportUnit entity
@author Olexander Dahno [email protected]
@since 2.1
*/

@interface JSResourceReportUnit : JSResourceLookup
@property (nonatomic, assign) BOOL alwaysPromptControls;
@end
Loading

0 comments on commit 8e0418e

Please sign in to comment.