Skip to main content

[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 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


Inactive hide details for Jad El-Khoury ---10/05/2013 06:57:40 PM---Hi, I am wondering if there are any documentation on how toJad 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

From:


Jad El-Khoury <jad@xxxxxx>

To:


"lyo-dev@xxxxxxxxxxx" <lyo-dev@xxxxxxxxxxx>

Date:


10/05/2013 06:57 PM

Subject:


[lyo-dev] How to use @OslcRange or @ OslcValueType appropriately?

Sent by:


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


Back to the top