cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How can we read the thingname of thing from a thingshape which is attached to it using eclipse?

Highlighted
Level 7

How can we read the thingname of thing from a thingshape which is attached to it using eclipse?

I want to get the thingname for a thing through a thingshape attached to it. using eclipse I can't fetch the particular thing name for getting the properties of the thing.

 for example in thingworx we use "me.name"  to fetch the thingname, what will be the suitable alternative for that in java eclipse.

 

thanks in advance.

 

5 REPLIES

Re: How can we read the thingname of thing from a thingshape which is attached to it using eclipse?

Hi Sugmar,

 

In thingworx for ThingShapes and templates a use the services:

 

- GetIncomingDependencies

- GetOutgoingDependencies

 

To list the child and the parents.

 

I believe is just call this services in eclipse.

 

Thanks,

Vinicius.

Re: How can we read the thingname of thing from a thingshape which is attached to it using eclipse?

Hai Xavier.

                  I tried this one, it is listing the parent and child relationships as you mentioned. but my requirement is to read the thingname through the thingshape service which is attached to it. 

 

generally in javascript we use "me.name". i just need the equivalent code of this one in java .

 

thanks and regards

Sugumar  

Re: How can we read the thingname of thing from a thingshape which is attached to it using eclipse?

StringPrimitive name =
(StringPrimitive)this.getPropertyValue("name");

 

Does this work?

Re: How can we read the thingname of thing from a thingshape which is attached to it using eclipse?

Thanks @vxavier for your response. It is throwing an error like "com.thingworx.common.exceptions.InvalidRequestException: Property [name] not found in []"

 

Thanks & Regards,

Sathishkumar C.

public class MyShape extends Thing {
	private static Logger _logger = LogUtilities.getInstance().getApplicationLogger(MyShape.class);

	public MyShape() {
		// TODO Auto-generated constructor stub
	}
	@ThingworxServiceDefinition(name = "myName", description = "", category = "", isAllowOverride = false, aspects = {
			"isAsync:false" })
	@ThingworxServiceResult(name = "result", description = "", baseType = "STRING", aspects = {})
	public String myName() {
		_logger.trace("Entering Service: myName");
		String s = "SSS";
		try 
{ StringPrimitive name = (StringPrimitive) this.getPropertyValue("name"); s = name.toString(); }
catch(Exception e)
{ s = e.toString(); } _logger.trace("Exiting Service: myName"); return s; } }

 

Re: How can we read the thingname of thing from a thingshape which is attached to it using eclipse?