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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

ConfigurationTable in ThingShapes / Where does it show up?

atondorf
14-Alexandrite

ConfigurationTable in ThingShapes / Where does it show up?

Hello,

 

I started to develop some Java-Extensions to solve some issues, that we where not able to solve with pure javascript. For some of these functional modules it would be interesting to have them as ThingShape to enable reuse on different Things.

The Eclipse-Plugin allows me to add a ConfigurationTable to the ThingShape and everything compiles properly.

But when I use this ThingShape, I can not see my ConfigurationTable entries anywhere?

 

Ok my first use example, we would like to have a TimerShape that behaves similar like TimerTemplate:

@ThingworxConfigurationTableDefinitions(tables = {
		@ThingworxConfigurationTableDefinition(name = "Settings", description = "General Settings", isMultiRow = false, ordinal = 0, dataShape = @ThingworxDataShapeDefinition( fields = {
				@com.thingworx.metadata.annotations.ThingworxFieldDefinition(name="updateRate", description="Update rate", baseType="NUMBER", aspects={"defaultValue:60000"}), 
				@com.thingworx.metadata.annotations.ThingworxFieldDefinition(name="enabled", description="Automatically enable timer on startup", baseType="BOOLEAN", aspects={"defaultValue:true"}), 
				@com.thingworx.metadata.annotations.ThingworxFieldDefinition(name="runAsUser", description="User context in which to run event handlers", baseType="USERNAME") 
			}))
		})
public class TimerTS {

//	private static Logger _logger = LogUtilities.getInstance().getApplicationLogger(TimerTS.class);

	public TimerTS() {
		// TODO Auto-generated constructor stub
	}

	@ThingworxServiceDefinition(name = "OnTimerTick", description = "Called by timer each time the it is triggered ...", category = "Timer", isAllowOverride = true )
	@ThingworxServiceResult(name = "Result", description = "", baseType = "NOTHING", aspects = {})
	public void OnTimerTick(
			@ThingworxServiceParameter(name = "Timestamp", description = "\t", baseType = "DATETIME") DateTime Timestamp) {
	}

}

 

 

 

ACCEPTED SOLUTION

Accepted Solutions

@atondorf 

 

On the second thought it looks like I found a workable solution -- you can define configuration via in the metadata / entity XML where you reference your class name. The easiest way to do this would be to add it on some dummy thing shape in the Composer, then export it for source control, pick ConfigurationTableDefinitions / ConfigurationTables blocks from this XML file and paste it into your XML where you define ThingShapes (metadata.xml in my case, even though it's not recommended).

 

I've just tried it in 8.4.3 -- and it worked, my Java thing shape got a configuration.

 

/ Constantine

View solution in original post

15 REPLIES 15
slangley
23-Emerald II
(To:atondorf)

Hi @atondorf.

 

Which version of ThingWorx are you running?  It appears this issue was corrected in ThingWorx 8.4.4.

 

Regards.

 

--Sharon

atondorf
14-Alexandrite
(To:slangley)

Hi Sharon,

 

we have 8.4.4 and after your comment I tested it with a ThingShape created in the Composer .. it's working.

But still not with my shape created as a JavaExtension in Eclipse. So there must be something wrong with the source code. But it is just blank code created by the eclipse thingworx assistant. 

slangley
23-Emerald II
(To:slangley)

Hi @atondorf.

 

These guides may help in determining the cause of your issue:

 

Create a Mashup Widget Extension

Create an Extension

 

Regards.

 

--Sharon

 

atondorf
14-Alexandrite
(To:slangley)

Hi Sharon,

 

thanks a lot, but I already know these tutorials and I followed them. That's how I get this far, but like most documentation on thingworx, these are on a very basic level. If you go deeper into some details you will mostly hit the wall.

In my special case I want to add the ConfigurationTable to a ThingShape and I already did it in Eclipse, but it does not show up in Thingworx. So there must be something missing in code or the Eclipse Plugin does not do the job correclty.

 

Greetings

 

Andreas

Hello,

 

Just a thought -- what if you try to inherit from Thing or ThingShape class?

 

/ Constantine

atondorf
14-Alexandrite
(To:Constantine)

Dear Constantine,

 

is there a Java ThingShape Class??
The eclipse plugin implements ThingShapes as Baseclass without any base class.

 

Greetings

 

Andreas

Hello Andreas,

 

There are com.thingworx.thingshape.ThingShape and com.thingworx.things.Thing classes. Without a better solution I just suggested doing a quick check to see if inheriting one of those might help in your situation.

 

/ Constantine

atondorf
14-Alexandrite
(To:Constantine)

Dear Constantine,

 

sorry was quite busy with other stuff, but right now back to my issue...
I tried your suggestion and 
I created an Test Project in Eclipse that has two classes:

1) a shape:

package test.extension;
import com.thingworx.metadata.annotations.ThingworxConfigurationTableDefinition;
import com.thingworx.metadata.annotations.ThingworxConfigurationTableDefinitions;
import com.thingworx.metadata.annotations.ThingworxDataShapeDefinition;
import com.thingworx.metadata.annotations.ThingworxFieldDefinition;
import com.thingworx.thingshape.ThingShape;
@ThingworxConfigurationTableDefinitions(tables = {
		@ThingworxConfigurationTableDefinition(name = "Settings", description = "General Settings", isMultiRow = false, ordinal = 0, dataShape = @ThingworxDataShapeDefinition(fields = {
				@ThingworxFieldDefinition(name = "name", description = "", baseType = "STRING", ordinal = 0),
				@ThingworxFieldDefinition(name = "enabled", description = "", baseType = "BOOLEAN", ordinal = 1, aspects = {"defaultValue:false" })})) })
public class TestJavaConfigThingTS extends ThingShape {
	public TestJavaConfigThingTS() {
		// TODO Auto-generated constructor stub
	}
}

2) a template:

package test.extension;

import com.thingworx.metadata.annotations.ThingworxBaseTemplateDefinition;
import com.thingworx.metadata.annotations.ThingworxConfigurationTableDefinition;
import com.thingworx.metadata.annotations.ThingworxConfigurationTableDefinitions;
import com.thingworx.metadata.annotations.ThingworxDataShapeDefinition;
import com.thingworx.metadata.annotations.ThingworxFieldDefinition;
import com.thingworx.things.Thing;

@ThingworxBaseTemplateDefinition(name = "GenericThing")
@ThingworxConfigurationTableDefinitions(tables = {
		@ThingworxConfigurationTableDefinition(name = "Settings", description = "General Settings", isMultiRow = false, ordinal = 0, dataShape = @ThingworxDataShapeDefinition(fields = {
				@ThingworxFieldDefinition(name = "name", description = "\t\t", baseType = "STRING", ordinal = 0),
				@ThingworxFieldDefinition(name = "enabled", description = "", baseType = "BOOLEAN", ordinal = 1, aspects = {"defaultValue:false" }) })) })
public class TestJavaConfigThingTT extends Thing {

	public TestJavaConfigThingTT() {
		// TODO Auto-generated constructor stub
	}

}

Both should have the same Configuration settings and I created them using the Eclipse-Plugin. This plugin does not add the base class ThingShape for ThingShapes and so I added this manually.

 

Everything compiles well and also the import was without any issu, but ...

The Configuration of the Template shows up in Thingworx as expected. The config of the ThingShape does not!

 

So there must be something wrong or missing in the code created by the eclipse wizards.

 

Greetings

 

Andreas

 

 

Hello Andreas,

 

I'm sorry it didn't help. To me it looks like it's time to contact tech support.

 

Regards,
Constantine

slangley
23-Emerald II
(To:atondorf)

Hi @atondorf.

 

Were you able to find a solution to your problem?  If so, we encourage you to post it here for the benefit of others on the community.

 

Regards.

 

--Sharon

atondorf
14-Alexandrite
(To:slangley)

No solution, yet ... do you have any idea?

@atondorf 

 

On the second thought it looks like I found a workable solution -- you can define configuration via in the metadata / entity XML where you reference your class name. The easiest way to do this would be to add it on some dummy thing shape in the Composer, then export it for source control, pick ConfigurationTableDefinitions / ConfigurationTables blocks from this XML file and paste it into your XML where you define ThingShapes (metadata.xml in my case, even though it's not recommended).

 

I've just tried it in 8.4.3 -- and it worked, my Java thing shape got a configuration.

 

/ Constantine

atondorf
14-Alexandrite
(To:Constantine)

Dear Constantine,

 

thanks for the idea. I also tried it and it's working for me, too.

PTC please add some more details on this (and much other stuff) to the documentation.

 

Greetings

 

Andreas

slangley
23-Emerald II
(To:atondorf)

Hi @atondorf.

 

Did you review this documentation available in the Help Center?

 

If you can provide a list of elements/concepts for which documentation is needed, I will be happy to open an internal case.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @atondorf.

 

If Constantine's last response resolved your issue, please mark it as the Accepted Solution for the benefit of others on the community.

 

Regards.

 

--Sharon

Announcements


Top Tags