[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [lyo-dev] How to use	@OslcRange	or	@	OslcValueType	appropriately? | 
Hi, Jad. Sorry for taking a few days to get back.
> >ValueType.Resource - The resource is represented by a URI, not inline.
> I would have thought that @OslcRepresentation controls whether a 
> Resource is represented as inlined or by a URI.
This is a good question. I always see OslcRepresentation.INLINE used together with ValueType.LocalResource in Lyo. It seems the OSLC Core spec has both in its ResourceShape:
http://open-services.net/bin/view/Main/OSLCCoreSpecAppendixA?sortcol=table;up=#oslc_ResourceShape_Resource
> >We do some validation of what's returned against the annotations, 
> but not everything is checked. Today, the 
> >annotations are mainly there to generate resource shapes. We do 
> have an enhancement open to add more validation:
>  
> This check is performed at run-time, right? I was hoping that 
> setting the return value to be Block (in my case) can make sure the 
> return value is as expected at compile-time. Don’t you think there 
> will be a value in that?
Yes, I agree it'd be extremely valuable to catch these problems at compile time. I opened a bug to look at it.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419395
-- 
Samuel Padgett | IBM Rational | spadgett@xxxxxxxxxx
Eclipse Lyo: Enabling tool integration with OSLC
lyo-dev-bounces@xxxxxxxxxxx wrote on 10/09/2013 10:05:37 AM:
> From:
> 
> Jad El-Khoury <jad@xxxxxx>
> 
> To:
> 
> Lyo project developer discussions <lyo-dev@xxxxxxxxxxx>
> 
> Date:
> 
> 10/09/2013 10:06 AM
> 
> Subject:
> 
> Re: [lyo-dev] How to use @OslcRange or @ OslcValueType appropriately?
> 
> Sent by:
> 
> lyo-dev-bounces@xxxxxxxxxxx
> 
> Hi Samuel,
>  
> FYI, I now managed to define both @OslcValueType & @OslcRange as 
> desired. The compromise was to have URI as the return value of the 
> get method. (Originally, I claimed that I was not able to define 
> @OSLCRange once I also set @OslcValueType - which is still the case 
> if the return value is the Block Class). So, the following works:
>                 @OslcValueType(ValueType.Resource)
>                 @OslcRange("http://ti.md.kth.se/sim#Block")
>                 public HashSet<URI> getChildren() 
>  
> Just some further questions based on what you said earlier:
>  
> >ValueType.Resource - The resource is represented by a URI, not inline.
> I would have thought that @OslcRepresentation controls whether a 
> Resource is represented as inlined or by a URI.
>  
> >So I think you want LocalResource with the method signature you have.
>  
> Shouldn’t the choice of LocalResource vs. Resource be controlled by 
> whether the resource is stand-alone (Resource) vs only defined 
> within the context of another resource (Resource)? Or did I 
> misunderstand the meaning of these 2 terms?
>  
> >We do some validation of what's returned against the annotations, 
> but not everything is checked. Today, the 
> >annotations are mainly there to generate resource shapes. We do 
> have an enhancement open to add more validation:
>  
> This check is performed at run-time, right? I was hoping that 
> setting the return value to be Block (in my case) can make sure the 
> return value is as expected at compile-time. Don’t you think there 
> will be a value in that?
>  
> Regards
> ----
> Jad El-khoury, PhD
> Mechatronics Lab, Department of Machine Design
> Royal Institute of Technology (KTH)
> S-100 44 Stockholm, Sweden
> e-mail: jad@xxxxxx
> Phone: +46(0)8 790 6877
> Mobile: +46(0)70 773 93 45
>  
> From: lyo-dev-bounces@xxxxxxxxxxx [mailto:lyo-dev-bounces@xxxxxxxxxxx] 
> On Behalf Of Samuel Padgett
> Sent: 08 October 2013 02:54
> To: Lyo project developer discussions
> Cc: Lyo project developer discussions; lyo-dev-bounces@xxxxxxxxxxx
> Subject: Re: [lyo-dev] How to use @OslcRange or @ OslcValueType appropriately?
>  
> Hi, Jad.
> 
> The names are a bit confusing.
> 
> ValueType.Resource - The resource is represented by a URI, not inline.
> ValueType.LocalResource - The resource is inlined in the response. 
> It can be a blank node or a resource with a URI.
> 
> So I think you want LocalResource with the method signature you have.
> 
> We do some validation of what's returned against the annotations, 
> but not everything is checked. Today, the annotations are mainly 
> there to generate resource shapes. We do have an enhancement open to
> add more validation:
> 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=377512
> 
> -- 
> Samuel Padgett | IBM Rational | spadgett@xxxxxxxxxx
> Eclipse Lyo: Enabling tool integration with OSLC
> 
> 
> [image removed] Jad El-Khoury ---10/07/2013 06:30:01 PM---Hi Samuel,
> Thanks for your reply. I was already using @OslcNamespace and 
> @OslcResourceShape annotati
> 
> [image removed] 
> From:
> 
> [image removed] 
> Jad El-Khoury <jad@xxxxxx>
> 
> [image removed] 
> To:
> 
> [image removed] 
> Lyo project developer discussions <lyo-dev@xxxxxxxxxxx>
> 
> [image removed] 
> Date:
> 
> [image removed] 
> 10/07/2013 06:30 PM
> 
> [image removed] 
> Subject:
> 
> [image removed] 
> Re: [lyo-dev] How to use @OslcRange or @ OslcValueType appropriately?
> 
> [image removed] 
> Sent by:
> 
> [image removed] 
> lyo-dev-bounces@xxxxxxxxxxx
> 
> 
> 
> 
> Hi Samuel,
>  
> Thanks for your reply. I was already using @OslcNamespace and 
> @OslcResourceShape annotations, but missed the @OslcSchema.  Anyway,
> even with @OslcSchema, I still have the problem.
>  
> Testing with valueType = “ValueType.LocalResource”, I won´t get the 
> exception. 
> But I do need a “proper” resource, and not just a local one.
>  
> So, is it so that choosing “ValueType.Resource”, implies that the 
> return value of the get method should be java.net.URI? That is, 
> @OslcRange does not work with “ValueType.Resource”?
> It would have been nice if one can ensure that the return value of 
> the get method is an object of the expected resource type.
> Regards
> ----
> Jad El-khoury, PhD
> Mechatronics Lab, Department of Machine Design
> Royal Institute of Technology (KTH)
> S-100 44 Stockholm, Sweden
> e-mail: jad@xxxxxx
> Phone: +46(0)8 790 6877
> Mobile: +46(0)70 773 93 45
>  
> From: lyo-dev-bounces@xxxxxxxxxxx [mailto:lyo-dev-bounces@xxxxxxxxxxx] 
> On Behalf Of Samuel Padgett
> Sent: 07 October 2013 14:50
> To: Lyo project developer discussions
> Cc: lyo-dev@xxxxxxxxxxx; lyo-dev-bounces@xxxxxxxxxxx
> Subject: Re: [lyo-dev] How to use @OslcRange or @ OslcValueType appropriately?
>   
> Hi, Jad. You can definitely define your own Java classes. Make sure 
> your classes have @OslcNamespace and @OslcResourceShape annotations 
> on them. I'd also recommend using @OslcSchema in package-info.java 
> in the same package to define your namespaces.
> 
> For @OslcValueType, can you try ValueType.LocalResource? With 
> ValueType.Resource, it expects the resource to just be a reference 
> and return java.net.URI.
> 
> We could do a better job documenting these annotations. You might 
> look at org.eclipse.lyo.client.oslc.resources for some examples.
> 
> Let us know how it goes. Thanks!
> -- 
> Samuel Padgett | IBM Rational | spadgett@xxxxxxxxxx
> Eclipse Lyo: Enabling tool integration with OSLC
> 
> 
> [image removed] Jad El-Khoury ---10/05/2013 06:57:40 PM---Hi, I am 
> wondering if there are any documentation on how to annotate java 
> class/resource attributes 
> 
> [image removed] 
> From:
> 
> [image removed] 
> Jad El-Khoury <jad@xxxxxx>
> 
> [image removed] 
> To:
> 
> [image removed] 
> "lyo-dev@xxxxxxxxxxx" <lyo-dev@xxxxxxxxxxx>
> 
> [image removed] 
> Date:
> 
> [image removed] 
> 10/05/2013 06:57 PM
> 
> [image removed] 
> Subject:
> 
> [image removed] 
> [lyo-dev] How to use @OslcRange or @ OslcValueType appropriately?
> 
> [image removed] 
> Sent by:
> 
> [image removed] 
> lyo-dev-bounces@xxxxxxxxxxx
> 
> 
> 
> 
> 
> Hi,
> 
> I am wondering if there are any documentation on how to annotate 
> java class/resource attributes properly.
> 
> when launching my application, I get the following exception. It 
> seems that I am not setting the  @OslcRange or @ OslcValueType appropriately.
> 
> javax.servlet.UnavailableException: 
> org.eclipse.lyo.oslc4j.core.exception.OslcCoreInvalidValueTypeException:
> OSLC007: Invalid value type http://open-services.net/ns/core#Resource
> defined for method getChildren of class se.kth.md.it.ms.resources.Block
>                at 
> org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:111)
>                at javax.servlet.GenericServlet.init(GenericServlet.java:244)
>                ...
> 
> The guilty method seems to be the following:
>                @OslcName("children")
>                @OslcPropertyDefinition
> (SimulinkAdaptorConstants.SIMULINK_NAMSPACE + "children")
>                @OslcDescription("the child blocks")
>                @OslcOccurs(Occurs.ZeroOrMany)
>                @OslcValueType(ValueType.Resource)
>                @OslcRange("http://ti.md.kth.se/sim#Block")
>                @OslcReadOnly(false)
>                @OslcTitle("Children")
>    public HashSet<Block> getChildren() {
>        return children;
>    }
> 
> After a few trials, I can only get it to work, if I do the following:
> 1. remove the @OslcRange annotation
> 2. redefine  the "children" property to be HashSet<Link>. (that is 
> the function signature becomes "public HashSet<Link> getChildren()")
> 
> I also tried to only remove the @OslcRange, but that did not help. 
> One does not seem to be able to define properties other than String,
> Date, Link, etc. 
> Is it not possible maybe to define own java classes?
> 
> Any hints are appreciated
> ----
> Jad El-khoury, PhD
> Mechatronics Lab, Department of Machine Design
> Royal Institute of Technology (KTH)
> S-100 44 Stockholm, Sweden
> e-mail: jad@xxxxxx
> Phone: +46(0)8 790 6877
> Mobile: +46(0)70 773 93 45
> _______________________________________________
> lyo-dev mailing list
> lyo-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/lyo-dev
> _______________________________________________
> lyo-dev mailing list
> lyo-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/lyo-dev
> _______________________________________________
> lyo-dev mailing list
> lyo-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/lyo-dev