Groovy Scripting

User 9aa4619393

16-03-2012 11:56:27

Hi,


I am trying to learn how to use Groovy scripting.


I have found examples of scriplets on your site and I am having troubles running them...this one for example:


http://www.chemaxon.com/instantjchem/ijc_latest/docs/developer/scriptlets/create_new_field.html


I created a new script in my schema, copy-pasted the code and it gives me this error:


groovy.lang.MissingPropertyException: No such property: dataTree for class: script1331898630366715701113
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
    at script1331898630366715701113.run(script1331898630366715701113.groovy:8)
    at com.im.ijc.groovy.impl.AbstractScriptContext.executeScript(AbstractScriptContext.java:144)
    at com.im.ijc.groovy.impl.AbstractScriptContext$1.phase1InRequestProcessor(AbstractScriptContext.java:98)
    at com.im.commons.progress.BackgroundRunner.processTheTask(BackgroundRunner.java:128)
    at com.im.commons.progress.BackgroundRunner$1.run(BackgroundRunner.java:91)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1957)


Same thing for the script to create a new entity.  Are these supposed to work as they are or do I need to adjust them?


Also, if I have two data trees (I have tried with either one or two) how do I specify which datatree and which entity?


Thanks


Anna

ChemAxon 37bb34e128

16-03-2012 13:55:09

Hi Anna,


just briefly - you can create a script either for a schema or for a datatree. The examples you picked are the datatree scripts. You should copy-paste them into a script that resides under a datatree. Please read more in http://www.chemaxon.com/instantjchem/ijc_latest/docs/developer/#scripts which describes what variables are injected into a script depending on where it resides.


Cheers,
-vita