Welcome, Guest. Please Login or Register
WebLab - An SOA Platform for media mining. News:
Documentation has been updated, see here for more information
  HomeHelpSearchLoginRegister
 
Pages: 1
Send Topic Print
[Resolved] SourceReader GetResourceArgs issue (Read 44 times)
Thomas Menard
WebLab Newbies
*
Offline

I Loeb WebLab

Posts: 4

[Resolved] SourceReader GetResourceArgs issue
02.02.2010 at 10:15:24
 
Hi,
I have to develop a service which implements the SourceReader interface.
I want to call the method GetResource but in argument we have to pass a GetResourceArgs which is a collection of resources.
I tried that :
Code:
GetResourceArgs args = new GetResourceArgs();

ResourceCollection resCol = ResourceFactory.createResource("Test", "tempCollection-"+ System.currentTimeMillis(),  ResourceCollection.class);

resCol.getResource().add(document);

args.setUsageContext((UsageContext) resCol.getResource());

Exemple.getResource(args); 


But it doesn't work, it says that it can't cast a Resource to UsageContext... but when i look at the javadoc a UsageContext is a Resource.

Regards.
Back to top
 
« Last Edit: 03.02.2010 at 09:30:39 by Thomas Menard »  
  IP Logged
Yann Mombrun
WebLab Administrator
*****
Offline

I Love WebLab

Posts: 58
Val de Reuil, France
Gender: male
Re: SourceReader GetResourceArgs issue
Reply #1 - 02.02.2010 at 16:10:07
 
I'm not sure to understand what you want.

You want to develop the service implementing SourceReader ; or you want to call a SourceReader as a client ?

Anyway what you are doing is wrong :
A usageContext is a Resource OK but a resource is not always a usageContext.
Here you creates a Document (Subclass of ComposedUnit, subclass of MediaUnit, subclass of Resource) and you try to cast it into a usageContext...

If you want to create an instanceOf usageContext change the last argument of the method ResourceFactory.createResource(...).
Back to top
 
« Last Edit: 03.02.2010 at 09:18:34 by Yann Mombrun »  
WWW   IP Logged
Jérémie Doucy
WebLab Administrator
*****
Offline

Every nights I dream
about WebLab ...

Posts: 89
Elancourt
Gender: male
Re: SourceReader GetResourceArgs issue
Reply #2 - 02.02.2010 at 19:09:15
 
If you want to test your service, you can use SOAPUI.
Back to top
 
 
  IP Logged
Thomas Menard
WebLab Newbies
*
Offline

I Loeb WebLab

Posts: 4

Re: SourceReader GetResourceArgs issue
Reply #3 - 03.02.2010 at 09:29:59
 
Thanks for your help but i found the solution by myself.

The following code is working fine:
Code:
GetResourceArgs args = new GetResourceArgs();
UsageContext uc = ResourceFactory.createResource("master", "res1", UsageContext.class);
Annotation annotDoc = AnnotationFactory.createAndLinkAnnotation(uc);
annotDoc.setData("PIN");
args.setUsageContext(uc);
exemple.getResource(args); 



We already tested it with our own portlet, in order to crawl LinkedIn.
Back to top
 
 
  IP Logged
Yann Mombrun
WebLab Administrator
*****
Offline

I Love WebLab

Posts: 58
Val de Reuil, France
Gender: male
Re: [Resolved] SourceReader GetResourceArgs issue
Reply #4 - 03.02.2010 at 09:40:57
 
For sure it will work better when using a usageContext as usageContext Wink

Anyway, why are you annotating your usageContext ? I think you don't need to do that.

Moreover, the way you are inserting data into you annotation is wrong. The data field of an Annotation must be a valid RDF/XML DOM object and not a String as you did.
Back to top
 
 
WWW   IP Logged
Thomas Menard
WebLab Newbies
*
Offline

I Loeb WebLab

Posts: 4

Re: [Resolved] SourceReader GetResourceArgs issue
Reply #5 - 03.02.2010 at 10:22:25
 
I'm totally agree with you by saying that i'm doing it in the wrong way but i don't know how to do better.
I do that :
Code:
UsageContext uc = ResourceFactory.createResource("master", "res1", UsageContext.class);
Annotation annotDoc = AnnotationFactory.createAndLinkAnnotation(uc);
PoKHelper pokHelper = RDFHelperFactory.getPoKHelper(annotDoc);
pokHelper.createLitStat(uc.getUri(), "Ontology/PINCODE", "12345");




But to do that i need an ontology  Sad
Have you any idea??
Back to top
 
 
  IP Logged
Jérémie Doucy
WebLab Administrator
*****
Offline

Every nights I dream
about WebLab ...

Posts: 89
Elancourt
Gender: male
Re: [Resolved] SourceReader GetResourceArgs issue
Reply #6 - 03.02.2010 at 10:43:18
 
It depends, you need a valid URI, and this URI have to be fixed.
For example, http://joker/ontology/pinode.

But why did you want to annote a usageContext ?

Because usageContext is used for the configuration mechanism,

For example, if your service need to be configured with a pincode, first call the configure method, with a usageContext and a PoK. The PoK will contain the pincode information. After the configuration, you only have to pass the same context to the getResource method, and you service will be able to get the pincode previously configured.  
Back to top
 
 
  IP Logged
Thomas Menard
WebLab Newbies
*
Offline

I Loeb WebLab

Posts: 4

Re: [Resolved] SourceReader GetResourceArgs issue
Reply #7 - 03.02.2010 at 10:55:50
 
I configure my service cause it has to return an url to the portlet in order to log on Linkedin before being authorized to crawl.

I'll try by implementing Configurable but how can i know that my URI is valide?
For example http: //joker/ontology/pincode?
Or how can i make it valide?

When i'm doing this :
Code:
pokHelper.createLitStat(uc.getUri(), "http: //JOKER/ontology/PINCODE", "12345"); 


I have as a result :
Code:
<rdf:Description rdf:about="weblab: //master/res1">
			  <j.0:PINCODE>12345</j.0:PINCODE> 


...
It appears not to be valide  Wink
Back to top
 
 
  IP Logged
Jérémie Doucy
WebLab Administrator
*****
Offline

Every nights I dream
about WebLab ...

Posts: 89
Elancourt
Gender: male
Re: [Resolved] SourceReader GetResourceArgs issue
Reply #8 - 03.02.2010 at 11:08:36
 
In fact you need a valid URI (not URL sorry, my mistake) and it's just an unique identifier, so what you show to us is valid.

For information here is the URI definition ; http://labs.apache.org/webarch/uri/rfc/rfc3986.html
You can have a look at examples on this page.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print