[kepler-dev] Adding actors programmatically ......
jagan
Jagan.Kommineni at infotech.monash.edu.au
Tue Feb 14 18:02:02 PST 2006
Hi Chad,
I have added the following lines of code to add actor programitically,
------------------------------------------------------------------------------------
LibraryIndex index = LibraryIndex.getInstance();
KeplerLSID lsid = new
KeplerLSID("urn:lsid:kepler-project.org:actor:701:1");
LibraryIndexComponentItem itemToAdd = new
LibraryIndexComponentItem(_actorNameStr, lsid);
System.out.println("itemtoAdd="+itemToAdd);
LibraryIndexItem subtree = index.findItem(new
KeplerLSID("urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor"));
System.out.println("subtreeitem="+subtree);
index.add(itemToAdd, subtree);
LibraryIndex.getInstance().refresh();
-------------------------------------------------------------------------------------
I am getting the following error messages, by somehow it is not able to
resolve lsid.
Could you mind to look into it?
============================================================
[java] itemtoAdd=<component name="localActorName"
lsid="urn:lsid:kepler-pro
ject.org:actor:701:1"/>
[java] subtreeitem=<concept name="gridlets"
lsid="urn:lsid:localhost:onto:1
:1#PreConfiguredGridletActor"/>
[java] Could not resolve lsid urn:lsid:kepler-project.org:actor:701:1
[java] java.lang.NullPointerException
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:647)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.getLibrary(Libr
aryIndex.java:552)
[java] at
org.kepler.objectmanager.library.LibraryIndex.refresh(Library
Index.java:563)
[java] at
org.monash.griddles.JGridletCreater.fire(JGridletCreater.java
:164)
[java] at
ptolemy.actor.process.ProcessThread.run(ProcessThread.java:18
6)
[java] ptolemy.kernel.util.IllegalActionException: Error building
tree mode
l: null
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:670)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.getLibrary(Libr
aryIndex.java:552)
[java] at
org.kepler.objectmanager.library.LibraryIndex.refresh(Library
Index.java:563)
[java] at
org.monash.griddles.JGridletCreater.fire(JGridletCreater.java
:164)
[java] at
ptolemy.actor.process.ProcessThread.run(ProcessThread.java:18
6)
[java] ptolemy.kernel.util.IllegalActionException: Error building
tree mode
l: Error building tree model: null
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:670)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.getLibrary(Libr
aryIndex.java:552)
[java] at
org.kepler.objectmanager.library.LibraryIndex.refresh(Library
Index.java:563)
[java] at
org.monash.griddles.JGridletCreater.fire(JGridletCreater.java
:164)
[java] at
ptolemy.actor.process.ProcessThread.run(ProcessThread.java:18
6)
[java] ptolemy.kernel.util.IllegalActionException: Error building
tree mode
l: Error building tree model: Error building tree model: null
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:670)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.getLibrary(Libr
aryIndex.java:552)
[java] at
org.kepler.objectmanager.library.LibraryIndex.refresh(Library
Index.java:563)
[java] at
org.monash.griddles.JGridletCreater.fire(JGridletCreater.java
:164)
[java] at
ptolemy.actor.process.ProcessThread.run(ProcessThread.java:18
6)
[java] ptolemy.kernel.util.IllegalActionException: Error building
tree mode
l: Error building tree model: Error building tree model: Error building
tree mod
el: null
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:670)
[java] at
org.kepler.objectmanager.library.LibraryIndex.buildTreeModel(
LibraryIndex.java:642)
[java] at
org.kepler.objectmanager.library.LibraryIndex.getLibrary(Libr
aryIndex.java:552)
[java] at
org.kepler.objectmanager.library.LibraryIndex.refresh(Library
Index.java:563)
[java] at
org.monash.griddles.JGridletCreater.fire(JGridletCreater.java
:164)
[java] at
ptolemy.actor.process.ProcessThread.run(ProcessThread.java:18
6)
[java] ptolemy.kernel.util.IllegalActionException: Error building
tree mode
l: Error building tree model: Error building tree model: Error building
tree mod
el: Error building tree model: null
[java] 1722 ms. Memory: 76372K Free: 12558K (16%)
with regards,
Jagan Kommineni
Chad Berkley wrote:
>Hi Jagan,
>
>This seems to now be working. You can see some sample code in
>CreateKSWDialog around line 420. It basically looks like this:
>
>LibraryIndex.getInstance().add(
> new LibraryIndexComponentItem(am.getName(), am.getLSID()), subtree);
>LibraryIndex.getInstance().refresh();
>util.EmptyChangeRequest request = new
> util.EmptyChangeRequest(actorEntity, "request change");
>actorEntity.requestChange(request);
>
>I'm not even sure if the changerequest is needed. I'll probably remove
>those lines. The LibraryIndex calls should do the trick. If you don't
>see the tree refresh right away, trying hitting the 'reset' button. If
>you are viewing a resultset from a search you will not see the actor appear.
>
>hope that works for you.
>
>chad
>
>jagan wrote:
>
>
>>Hello Chad,
>>
>>Could you mind to update me whether there is any progress about the
>>adding actors dynamically?
>>
>>with regards,
>>
>>Jagan Kommineni
>>
>>Chad Berkley wrote:
>>
>>
>>
>>>Hey Jagan,
>>>
>>>I was trying to do something similar yesterday and it wasn't working.
>>>I'll keep working on it today and when i figure it out, i'll let you
>>>know. I think it's something to do with the LibraryIndex, but I'm not
>>>quite sure yet.
>>>
>>>chad
>>>
>>>jagan wrote:
>>>
>>>
>>>
>>>>Hello Chad,
>>>>
>>>> While creating actor programmitically I have followed the
>>>>following steps,
>>>>===================================================================================================================
>>>>
>>>> public void fire() throws IllegalActionException {
>>>> super.fire();
>>>> try { GriddlesExec wss = null;
>>>> _actorNameStr = actorName.getExpression();
>>>> wss = new GriddlesExec(new EntityLibrary(),
>>>>_actorNameStr); LibraryIndex index =
>>>>LibraryIndex.getInstance();
>>>> KeplerLSID lsid = new
>>>>KeplerLSID("urn:lsid:kepler-project.org:actor:500:1");
>>>> LibraryIndexItem itemToAdd = new LibraryIndexItem(_actorNameStr,
>>>>lsid);
>>>> System.out.println("itemtoAdd="+itemToAdd);
>>>> LibraryIndexItem subtree = index.findItem(new
>>>>KeplerLSID("urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor"));
>>>> System.out.println("subtreeitem="+subtree);
>>>> index.add(itemToAdd, subtree);
>>>> System.out.println("Printing Component Items");
>>>> for ( Iterator iter = index.items(); iter.hasNext(); )
>>>> {
>>>> LibraryIndexComponentItem key = (LibraryIndexComponentItem)
>>>>iter.next();
>>>> System.out.println( key );
>>>> }
>>>> System.out.println("Printing Ontologies");
>>>> for ( Iterator iter = index.ontologies(); iter.hasNext(); )
>>>> {
>>>> LibraryIndexOntologyItem key = (LibraryIndexOntologyItem)
>>>>iter.next();
>>>> System.out.println( key );
>>>> } }
>>>> catch (Exception e) {
>>>> System.out.println(e);
>>>> }
>>>> } // end of fire
>>>>===================================================================================
>>>>
>>>>
>>>>The output corresponding to above print statements relating new item
>>>>is as follows,
>>>>
>>>>==================================================================================
>>>>
>>>>
>>>> [java] itemtoAdd=<name="localActorName"
>>>>lsid="urn:lsid:kepler-project.org:actor:500:1"/>
>>>>
>>>> [java] subtreeitem=<concept name="gridlets"
>>>>lsid="urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor"/>
>>>>
>>>> [java] Printing Component Items
>>>> [java] <component name="CT Director"
>>>>lsid="urn:lsid:kepler-project.org:director:4:1"/>
>>>> ..............
>>>> ...............
>>>> [java] <concept name="gridlets"
>>>>lsid="urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor">
>>>> [java] <name="localActorName"
>>>>lsid="urn:lsid:kepler-project.org:actor:500:1"/>
>>>> [java] </concept>
>>>>
>>>>=========================================================================================
>>>>
>>>>
>>>> It seems to me that the actor has been added to the library but I
>>>>can't see the actor on the user inter face.
>>>>And als I haven't seen any items relating to the new actor on the
>>>>$HOME/.kepler directory.
>>>>
>>>> Do I need to do something else to create kar file for the new
>>>>actor (may be some committing)?
>>>>
>>>>with regards,
>>>>
>>>>Jagan Kommineni
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>_______________________________________________
>Kepler-dev mailing list
>Kepler-dev at ecoinformatics.org
>http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercury.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20060215/007c943b/attachment.html>
More information about the Kepler-dev
mailing list