[kepler-dev] Adding actors programmatically ......

Chad Berkley berkley at nceas.ucsb.edu
Tue Feb 14 14:36:25 PST 2006


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
>>>
>>>
>>>
>>>
> 


More information about the Kepler-dev mailing list