Skip to main content
17-Peridot
July 5, 2018
Solved

Enable thing() and Restart thing() from Eclipse Extension

  • July 5, 2018
  • 1 reply
  • 4876 views

Hi All,

I want to make a thing to Enable and Restart within Eclipse Extension.

How can i do this?

 

Thing things = new Thing();

things.Enable Thing();

things.RestartThing();

 

Above code is not working.

 

Thanks & Regards,

Sathishkumar C.

Best answer by supandey

@Sathishkumar_C In that case I think the issue might be that you are attempting start / enable of thing on template level and that's not possible. You need to attempt that on the object , something like this 

 

@ThingworxServiceDefinition(name = "CreateAThing", description = "", category = "", isAllowOverride = false, aspects = {
			"isAsync:false" })
	@ThingworxServiceResult(name = "Result", description = "", baseType = "BOOLEAN", aspects = {})
	public void CreateAThing() throws Exception {
		_logger.trace("Entering Service: CreateAThing");
		_logger.trace("Exiting Service: CreateAThing");

		EntityServices newThingService = new EntityServices();

		String name = "UniqueThingName";
		String desc = "Static Thing from Custom Extension";
		TagCollection myTag = null;

		try {
			newThingService.CreateThing(name, desc, myTag, "ExtensionStandardNew");
		} catch (Exception e) {
			System.out.println("Failed to create Thing");
			e.printStackTrace();
		}

		Thing mything = (Thing) EntityUtilities.findEntity(name, ThingworxRelationshipTypes.Thing);
		_logger.trace("Failed to find thing", mything.getName());

		try {
			mything.EnableThing();
		} catch (Exception e) {
			System.out.println("Failed to enable thing" + mything.getName());
			e.printStackTrace();
		}

1 reply

5-Regular Member
July 9, 2018

Hi @Sathishkumar_C could you share exactly what sort of error / issue you are running into?

17-Peridot
July 9, 2018

I can't able to enable and restart the thing after creation.

5-Regular Member
July 9, 2018

Do you mean once you import the extension you can't enable and restart those Entities? could you please share any screenshot or template detail you are working with?