Forums

Home » Mobile » Liferay Mobile SDK

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Riccardo Masini
iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
April 18, 2014 2:29 AM
Answer

Riccardo Masini

Rank: New Member

Posts: 6

Join Date: May 14, 2012

Recent Posts

Hi,
I'm trying to develop my first app using Liferay Mobile SDK.
I was trying to retrieve Vocabularies and Categories.
I managed to retrieve Vocabularies with this code:

1
2LRAssetVocabularyService_v62 *servizioVocabulary = [[LRAssetVocabularyService_v62 alloc] initWithSession:session];
3NSArray *arrayVocabulary = [servizioVocabulary getCompanyVocabulariesWithCompanyId:10157 error:&error];


Then, with the vocabulary id, I'm trying to get the Categories for each vocabulary using the method:
1
2LRAssetCategoryService_v62 *servizioCategory = [[LRAssetCategoryService_v62 alloc] initWithSession:session];
3
4...
5
6int vocabularyId = (int)[[arrayVocabulary objectAtIndex:i]valueForKey:@"vocabularyId"];
7[servizioCategory getVocabularyRootCategoriesWithVocabularyId:vocabularyId start:-1 end:-1 obc:??? error:&error];


But I don't know what to pass at the 'obc' parameter. I've tried with NULL but the app crashes, I've tried with @"asc", @{@"orderByType":@"asc"}, but I always get an error from liferay:
Problem while instantiating class com.liferay.portal.kernel.util.OrderByComparator

Can someone help me on how to use the obc parameter?
Thanks
Juan Fernández
RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
April 21, 2014 12:19 AM
Answer

Juan Fernández

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1227

Join Date: October 2, 2008

Recent Posts

This might help - JSON Web Services API get-vocabulary-categories
Riccardo Masini
RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
April 22, 2014 2:42 AM
Answer

Riccardo Masini

Rank: New Member

Posts: 6

Join Date: May 14, 2012

Recent Posts

Doesn't work

I'm trying doing this:
1[categorySerivce getVocabularyRootCategoriesWithVocabularyId:vocabularyId start:-1 end:-1 obc:@{@"-obc":@""} error:&error];


But I get this error:
Error Domain=com.liferay.mobile.sync.ErrorDomain Code=-1 "Missing value at character 6"


I saw in the json ws of my Liferay instance ( http://localhost:8080/api/jsonws ) that the type of this parameter is com.liferay.portal.kernel.util.OrderByComparator but the iOS api asks for a NSDictionary...I really can't figure out what I have to pass as parameter...
Bruno Farache
RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
April 22, 2014 6:01 AM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 502

Join Date: May 14, 2007

Recent Posts

Hi Riccardo,

I will take a look into this issue. I created a ticket for that: MOBILESDK-15, you can receive updates about it by clicking on "watch" in the ticket.
Riccardo Masini
RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
April 30, 2014 2:44 AM
Answer

Riccardo Masini

Rank: New Member

Posts: 6

Join Date: May 14, 2012

Recent Posts

FYI
I've managed to get the method working by modifying this code in LRAssetCategoryService_v62.m, from:

 1- (NSArray *)getVocabularyRootCategoriesWithVocabularyId:(long long)vocabularyId start:(int)start end:(int)end obc:(NSDictionary *)obc error:(NSError **)error {
 2    NSDictionary *_params = @{
 3        @"vocabularyId": @(vocabularyId),
 4        @"start": @(start),
 5        @"end": @(end),
 6        @"obc": obc
 7    };
 8
 9    NSDictionary *_command = @{@"/assetcategory/get-vocabulary-root-categories": _params};
10
11    return (NSArray *)[self.session invoke:_command error:error];
12}


to:
 1
 2- (NSArray *)getVocabularyRootCategoriesWithVocabularyId:(long long)vocabularyId start:(int)start end:(int)end obc:(NSDictionary *)obc error:(NSError **)error {
 3    NSDictionary *_params = @{
 4        @"vocabularyId": @(vocabularyId),
 5        @"start": @(start),
 6        @"end": @(end),
 7        @"-obc": obc
 8    };
 9
10    NSDictionary *_command = @{@"/assetcategory/get-vocabulary-root-categories": _params};
11
12    return (NSArray *)[self.session invoke:_command error:error];
13}


So, as suggested by the link in Juan Fernández's answer, the parameter obc is taken by Liferay as null.


The method also gives the result by modifying the method like this:
 1
 2- (NSArray *)getVocabularyRootCategoriesWithVocabularyId:(long long)vocabularyId start:(int)start end:(int)end obc:(NSDictionary *)obc error:(NSError **)error {
 3    NSDictionary *_params = @{
 4        @"vocabularyId": @(vocabularyId),
 5        @"start": @(start),
 6        @"end": @(end),
 7        @"+obc": @"com.liferay.portlet.journal.util.comparator.ArticleCreateDateComparator"
 8    };
 9
10    NSDictionary *_command = @{@"/assetcategory/get-vocabulary-root-categories": _params};
11
12    return (NSArray *)[self.session invoke:_command error:error];
13}
Bruno Farache
RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
April 30, 2014 3:29 AM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 502

Join Date: May 14, 2007

Recent Posts

Thanks for sharing, Riccardo. We are fixing it right now, see last commits:

https://github.com/brunofarache/liferay-mobile-sdk/commits/master

Fixed for Android and now working on iOS.

If you want to pass the comparator, you can do:

"+obc": "com.liferay.OrderByComparatorImplementation"
Bruno Farache
RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories
May 7, 2014 12:47 PM
Answer

Bruno Farache

LIFERAY STAFF

Rank: Liferay Master

Posts: 502

Join Date: May 14, 2007

Recent Posts

Riccardo,

We just released a new version (6.2.0.2) with this fix, check the release page. It is published to Cocoapods as well. Check out the docs.

Thank you letting us know about the bug.