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


GIF image

GIF image


Back to the top