Foros de discusión

iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

Riccardo Masini, modificado hace 10 años.

iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

New Member Mensajes: 6 Fecha de incorporación: 14/05/12 Mensajes recientes
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:


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


Then, with the vocabulary id, I'm trying to get the Categories for each vocabulary using the method:

LRAssetCategoryService_v62 *servizioCategory = [[LRAssetCategoryService_v62 alloc] initWithSession:session];

...

int vocabularyId = (int)[[arrayVocabulary objectAtIndex:i]valueForKey:@"vocabularyId"];
[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
thumbnail
Juan Fernández, modificado hace 9 años.

RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

Liferay Legend Mensajes: 1261 Fecha de incorporación: 2/10/08 Mensajes recientes
Riccardo Masini, modificado hace 9 años.

RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

New Member Mensajes: 6 Fecha de incorporación: 14/05/12 Mensajes recientes
Doesn't work

I'm trying doing this:
[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...
thumbnail
Bruno Farache, modificado hace 9 años.

RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

Liferay Master Mensajes: 603 Fecha de incorporación: 14/05/07 Mensajes recientes
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, modificado hace 9 años.

RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

New Member Mensajes: 6 Fecha de incorporación: 14/05/12 Mensajes recientes
FYI
I've managed to get the method working by modifying this code in LRAssetCategoryService_v62.m, from:

- (NSArray *)getVocabularyRootCategoriesWithVocabularyId:(long long)vocabularyId start:(int)start end:(int)end obc:(NSDictionary *)obc error:(NSError **)error {
	NSDictionary *_params = @{
		@"vocabularyId": @(vocabularyId),
		@"start": @(start),
		@"end": @(end),
		@"obc": obc
	};

	NSDictionary *_command = @{@"/assetcategory/get-vocabulary-root-categories": _params};

	return (NSArray *)[self.session invoke:_command error:error];
}


to:

- (NSArray *)getVocabularyRootCategoriesWithVocabularyId:(long long)vocabularyId start:(int)start end:(int)end obc:(NSDictionary *)obc error:(NSError **)error {
	NSDictionary *_params = @{
		@"vocabularyId": @(vocabularyId),
		@"start": @(start),
		@"end": @(end),
		@"-obc": obc
	};

	NSDictionary *_command = @{@"/assetcategory/get-vocabulary-root-categories": _params};

	return (NSArray *)[self.session invoke:_command error:error];
}


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:

- (NSArray *)getVocabularyRootCategoriesWithVocabularyId:(long long)vocabularyId start:(int)start end:(int)end obc:(NSDictionary *)obc error:(NSError **)error {
	NSDictionary *_params = @{
		@"vocabularyId": @(vocabularyId),
		@"start": @(start),
		@"end": @(end),
		@"+obc": @"com.liferay.portlet.journal.util.comparator.ArticleCreateDateComparator"
	};

	NSDictionary *_command = @{@"/assetcategory/get-vocabulary-root-categories": _params};

	return (NSArray *)[self.session invoke:_command error:error];
}
thumbnail
Bruno Farache, modificado hace 9 años.

RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

Liferay Master Mensajes: 603 Fecha de incorporación: 14/05/07 Mensajes recientes
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"
thumbnail
Bruno Farache, modificado hace 9 años.

RE: iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

Liferay Master Mensajes: 603 Fecha de incorporación: 14/05/07 Mensajes recientes
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.