Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Lyo » OSLCClient getEntity function
OSLCClient getEntity function [message #1587784] Tue, 27 January 2015 15:03 Go to next message
D. G. is currently offline D. G.Friend
Messages: 4
Registered: January 2015
Junior Member
Hello,

I have just one basic question:
Is there a way to see the declaration of response.getEntity() function in client project? I just want to debug but I can not go in to that function to see how it works. I was wondering if this is something happens to me may be because of missing files/environment or everyone have same difficulty.

Here is the code how I use getEntity() function to give you an idea:

OslcClient client = new OslcClient();
response = client.getResource(resourceURI, OSLCConstants.CT_RDF);
EntityB resource = response.getEntity(EntityB.class);

Thanks in advance
Re: OSLCClient getEntity function [message #1587995 is a reply to message #1587784] Tue, 27 January 2015 17:41 Go to previous messageGo to next message
Samuel Padgett is currently offline Samuel PadgettFriend
Messages: 30
Registered: July 2009
Member
ClientResponse.getEntity() is an Apache Wink Client method. You could set breakpoints in these methods in OSLC4J if you're still getting back null.

org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider.isReadable(Class<?>, MediaType, MediaType...)
org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.fromJenaModel(Model, Class<?>)

If you attach the RDF and the annotations on your EntityB.class, I might be able to help as well.
Re: OSLCClient getEntity function [message #1589574 is a reply to message #1587995] Wed, 28 January 2015 14:28 Go to previous message
D. G. is currently offline D. G.Friend
Messages: 4
Registered: January 2015
Junior Member
Hi Samuel,

Thank you very much for your reply. I am using client from ToolAAdaptor to receive entity from ToolBAdapter. respond looks fine actually, but as I mentioned before after calling respond.getEntity() it becomes null.

Can that be because of "ToolBAdaptor" initial in RDF? Since the call is from ToolAAdaptor maybe this needs to be ToolAadapter? Or am I making thing complicated?

I printed out response and this is the result I receive:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="somelink/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="somelink/dc/terms/"
xmlns:oslc_data="somelink/ns/servicemanagement/1.0/"
xmlns:oslc="somelink/ns/core#"
xmlns:rdfs="somelink/2000/01/rdf-schema#"
xmlns:ms="somelink/ToolBAdaptor"
xmlns:j.0="somelink/" >
<rdf:Description rdf:about="somelink:8282/ToolBAdaptor/services/serviceProviders/1/entitys/4">
<j.0:ToolBAdaptorEntityState>C</j.0:ToolBAdaptorEntityState>
<j.0:ToolBAdaptorEntityDescription>Description4</j.0:ToolBAdaptorEntityDescription>
<j.0:ToolBAdaptorEntityTitle>Title4</j.0:ToolBAdaptorEntityTitle>
<rdf:type rdf:resource="somelink/ToolBAdaptorentity"/>
</rdf:Description>
</rdf:RDF>


EntityB.java is:
@OslcNamespace(ToolBAdaptorConstants.TOOLBADAPTOR_NAMSPACE)
@OslcName(ToolBAdaptorConstants.ENTITY)
@OslcResourceShape(title = "Entity Resource Shape", describes = ToolBAdaptorConstants.TYPE_ENTITY)
public class EntityB
extends AbstractResource

{

public String EntityTitle;
public String EntityDescription;
public String EntityState;

public EntityB()
throws URISyntaxException
{
super();

// Start of user code constructor1
// End of user code
}

public EntityB(final URI about)
throws URISyntaxException
{
super(about);

// Start of user code constructor2
// End of user code
}

public EntityB(final String serviceProviderId, final String entityId)
throws URISyntaxException
{
this (constructURI(serviceProviderId, entityId));
// Start of user code constructor3
// End of user code
}

public static URI constructURI(final String serviceProviderId, final String entityId)
{
String basePath = ServletListener.getServicesBase();
Map<String, Object> pathParameters = new HashMap<String, Object>();
pathParameters.put("serviceProviderId", serviceProviderId);

pathParameters.put("entityId", entityId);
String instanceURI = "serviceProviders/{serviceProviderId}/entitys/{entityId}";

final UriBuilder builder = UriBuilder.fromUri(basePath);
return builder.path(instanceURI).buildFromMap(pathParameters);
}

public static Link constructLink(final String serviceProviderId, final String entityId , final String label)
{
return new Link(constructURI(serviceProviderId, entityId), label);
}

public static Link constructLink(final String serviceProviderId, final String entityId)
{
return new Link(constructURI(serviceProviderId, entityId));
}

public String toString()
{
return toString(false);
}

public String toString(boolean asLocalResource)
{
String result = "";
// Start of user code toString_init
// End of user code

if (asLocalResource) {
result = result + "{a Local Entity Resource} - update Entity.toString() to present resource as desired.";
// Start of user code toString_bodyForLocalResource
// End of user code
}
else {
result = getAbout().toString();
}

// Start of user code toString_finalize
// End of user code

return result;
}

public String toHtml()
{
return toHtml(false);
}

public String toHtml(boolean asLocalResource)
{
String result = "";
// Start of user code toHtml_init
// End of user code

if (asLocalResource) {
result = toString(true);
// Start of user code toHtml_bodyForLocalResource
// End of user code
}
else {
result = "<a href=\"" + getAbout() + "\">" + toString() + "</a>";
}

// Start of user code toHtml_finalize
// End of user code

return result;
}

public String toHtmlUpdate()
{
return toHtmlUpdate(false);
}

public String toHtmlUpdate(boolean asLocalResource)
{
String result = "";
// Start of user code toHtml_init
// End of user code

if (asLocalResource) {
result = toString(true);
// Start of user code toHtml_bodyForLocalResource
// End of user code
}
else {
result = "<a href=\"" + getAbout() + "/update"+"\">" + toString() + "/update</a>";
}

// Start of user code toHtml_finalize
// End of user code

return result;
}


@OslcName("EntityTitle")
@OslcPropertyDefinition(ToolBAdaptorConstants.TOOLBADAPTOR_NAMSPACE + "EntityTitle")
@OslcDescription("Entity Can be Anything... (e.g., block , Bug)")
@OslcOccurs(Occurs.ExactlyOne)
@OslcValueType(ValueType.String)


@OslcReadOnly(false)
@OslcTitle("EntityTitle")
public String getEntityTitle()
{
return EntityTitle;
}

@OslcName("EntityDescription")
@OslcPropertyDefinition(ToolBAdaptorConstants.TOOLBADAPTOR_NAMSPACE + "EntityDescription")
@OslcDescription("Description")
@OslcOccurs(Occurs.ExactlyOne)
@OslcValueType(ValueType.String)


@OslcReadOnly(false)
@OslcTitle("EntityDescription")
public String getEntityDescription()
{
return EntityDescription;
}

@OslcName("EntityState")
@OslcPropertyDefinition(ToolBAdaptorConstants.TOOLBADAPTOR_NAMSPACE + "EntityState")
@OslcDescription("Status of the entity")
@OslcOccurs(Occurs.ExactlyOne)
@OslcValueType(ValueType.String)


@OslcReadOnly(false)
@OslcTitle("EntityState")
public String getEntityState()
{
return EntityState;
}


public void setEntityTitle(final String EntityTitle )
{
this.EntityTitle = EntityTitle;
}
public void setEntityDescription(final String EntityDescription )
{
this.EntityDescription = EntityDescription;
}
public void setEntityState(final String EntityState )
{
this.EntityState = EntityState;
}

static public String EntityTitleToHtmlForCreation (final HttpServletRequest httpServletRequest, final String serviceProviderId)
{
String s = "";

// Start of user code EntityTitleasHtmlForCreation_init
// End of user code

s = s + "<label for=\"EntityTitle\">EntityTitle: </LABEL>";

// Start of user code EntityTitleasHtmlForCreation_mid
// End of user code

s= s + "<input name=\"EntityTitle\" type=\"text\" style=\"width: 400px\" id=\"EntityTitle\" >";

// Start of user code EntityTitleasHtmlForCreation_finalize
// End of user code

return s;
}
static public String EntityDescriptionToHtmlForCreation (final HttpServletRequest httpServletRequest, final String serviceProviderId)
{
String s = "";

// Start of user code EntityDescriptionasHtmlForCreation_init
// End of user code

s = s + "<label for=\"EntityDescription\">EntityDescription: </LABEL>";

// Start of user code EntityDescriptionasHtmlForCreation_mid
// End of user code

s= s + "<input name=\"EntityDescription\" type=\"text\" style=\"width: 400px\" id=\"EntityDescription\" >";

// Start of user code EntityDescriptionasHtmlForCreation_finalize
// End of user code

return s;
}
static public String EntityStateToHtmlForCreation (final HttpServletRequest httpServletRequest, final String serviceProviderId)
{
String s = "";

// Start of user code EntityStateasHtmlForCreation_init
// End of user code

s = s + "<label for=\"EntityState\">EntityState: </LABEL>";

// Start of user code EntityStateasHtmlForCreation_mid
// End of user code

s= s + "<input name=\"EntityState\" type=\"text\" style=\"width: 400px\" id=\"EntityState\" >";

// Start of user code EntityStateasHtmlForCreation_finalize
// End of user code

return s;
}


static public String EntityTitleToHtmlForUpdate (EntityB entity)
{
String s = "";

// Start of user code EntityTitleasHtmlForCreation_init
// End of user code

s = s + "<label for=\"EntityTitle\">EntityTitle: </LABEL>";

// Start of user code EntityTitleasHtmlForCreation_mid
// End of user code

s= s + "<input name=\"EntityTitle\" type=\"text\" style=\"width: 400px\" id=\"EntityName\""+ "value=\""+ entity.EntityTitle +"\" >";

// Start of user code EntityTitleasHtmlForCreation_finalize
// End of user code

return s;
}
static public String EntityDescriptionToHtmlForUpdate (EntityB entity)
{
String s = "";

// Start of user code EntityDescriptionasHtmlForCreation_init
// End of user code

s = s + "<label for=\"EntityDescription\">EntityDescription: </LABEL>";

// Start of user code EntityDescriptionasHtmlForCreation_mid
// End of user code

s= s + "<input name=\"EntityDescription\" type=\"text\" style=\"width: 400px\" id=\"EntityDescription\""+ "value=\""+ entity.EntityDescription +"\" >";

// Start of user code EntityDescriptionasHtmlForCreation_finalize
// End of user code

return s;
}
static public String EntityStateToHtmlForUpdate (EntityB entity)
{
String s = "";

// Start of user code EntityStateasHtmlForCreation_init
// End of user code

s = s + "<label for=\"EntityState\">EntityState: </LABEL>";

// Start of user code EntityStateasHtmlForCreation_mid
// End of user code

s= s + "<input name=\"EntityState\" type=\"text\" style=\"width: 400px\" id=\"EntityState\""+ "value=\""+ entity.EntityState +"\" >";

// Start of user code EntityStateasHtmlForCreation_finalize
// End of user code

return s;
}

public String EntityTitleToHtml()
{
String s = "";

// Start of user code EntityTitletoHtml_init
// End of user code

s = s + "<label for=\"EntityTitle\"><strong>EntityTitle</strong>: </LABEL>";

// Start of user code EntityTitletoHtml_mid
// End of user code

try {
if (EntityTitle == null) {
s= s + "<em>null</em>";
}
else {
s= s + EntityTitle.toString();
}
} catch (Exception e) {
e.printStackTrace();
}

// Start of user code EntityTitletoHtml_finalize
// End of user code

return s;
}
public String EntityDescriptionToHtml()
{
String s = "";

// Start of user code EntityDescriptiontoHtml_init
// End of user code

s = s + "<label for=\"EntityDescription\"><strong>EntityDescription</strong>: </LABEL>";

// Start of user code EntityDescriptiontoHtml_mid
// End of user code

try {
if (EntityDescription == null) {
s= s + "<em>null</em>";
}
else {
s= s + EntityDescription.toString();
}
} catch (Exception e) {
e.printStackTrace();
}

// Start of user code EntityDescriptiontoHtml_finalize
// End of user code

return s;
}
public String EntityStateToHtml()
{
String s = "";

// Start of user code EntityStatetoHtml_init
// End of user code

s = s + "<label for=\"EntityState\"><strong>EntityState</strong>: </LABEL>";

// Start of user code EntityStatetoHtml_mid
// End of user code

try {
if (EntityState == null) {
s= s + "<em>null</em>";
}
else {
s= s + EntityState.toString();
}
} catch (Exception e) {
e.printStackTrace();
}

// Start of user code EntityStatetoHtml_finalize
// End of user code

return s;
}
}
Previous Topic:OSLCClient receiving entity issue
Next Topic:Problem accessing /OSLC4JStockQuote/stockQuotes
Goto Forum:
  


Current Time: Sun Nov 18 11:12:04 GMT 2018

Powered by FUDForum. Page generated in 0.02824 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top