留言板

iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

Riccardo Masini,修改在10 年前。

iOS mobile SDK, problem with OBC while retreiving Vocabulary categories

New Member 帖子: 6 加入日期: 12-5-14 最近的帖子
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,修改在10 年前。

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

Liferay Legend 帖子: 1261 加入日期: 08-10-2 最近的帖子
Riccardo Masini,修改在10 年前。

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

New Member 帖子: 6 加入日期: 12-5-14 最近的帖子
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,修改在10 年前。

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

Liferay Master 帖子: 603 加入日期: 07-5-14 最近的帖子
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,修改在9 年前。

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

New Member 帖子: 6 加入日期: 12-5-14 最近的帖子
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,修改在9 年前。

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

Liferay Master 帖子: 603 加入日期: 07-5-14 最近的帖子
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,修改在9 年前。

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

Liferay Master 帖子: 603 加入日期: 07-5-14 最近的帖子
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.