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

kommineni jagan jaganmk at hotmail.com
Thu Feb 23 02:11:21 PST 2006


Hi,

When I try to add actors to Kepler User Interface, I am facing property 
duplication error. This happens whenever the PortParameter is specified. 
There are similar actors in the CVS repository for example 
($KEPLER/src/actors/GriddlesExec) and the files for this actor has been 
developed and stored in cvs repository (GriddlesExec.xml  MANIFEST.MF).

The command property has been entered only once. I wonder whether these have 
been
developed by an automation process.

I followed the following steps for creating actors programmatically. Chad 
also noticed a similar problem.

==============================================================
I am having  duplication in property "command" when  I generate kar file 
programmitically.
Here is the code I used for generating actor programmitically.
================================================================================
   GriddlesExec wss = null;
_actorNameStr = actorName.getExpression();
container = new EntityLibrary();
wss = new GriddlesExec(container, _actorNameStr);
File kswFile = new File("kar/actors/"+_actorNameStr+".kar");

LSIDGenerator lsidGenerator = LSIDGenerator.getInstance();
KeplerLSID lsid = lsidGenerator.getNewLSID("actor1");
NamedObjId objId = new NamedObjId(wss, "entityId");
// update the actor library
objId.setContainer(wss);
objId.setExpression(lsid.toString());
SemanticType semanticType = new SemanticType(wss, "semanticType00");
    // update the actor library
semanticType.setContainer(wss);
semanticType.setExpression("urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor");
KSWBuilder ksw = new KSWBuilder(wss , false , kswFile);     
processKSW(kswFile);
==============================================================
I am facing one more problem here that the GriddlesExec is the subclass 
standard Exec class with execution termination at the end of first loop.

The PortParameter (command) of this actor is creating two entries in the xml 
file.
These entries are as follows
--------------------------------------------------------------------------
<property name="command" class="org.kepler.moml.PortAttribute">
<property name="direction" value="input" 
class="ptolemy.kernel.util.StringAttribute"/>
<property name="dataType" value="unknown" 
class="ptolemy.kernel.util.StringAttribute"/>
<property name="isMultiport" value="false" 
class="ptolemy.kernel.util.StringAttribute"/>
   <property name="_showName" class="ptolemy.data.expr.Parameter" 
value="true">
</property>
</property>
<property name="command" class="ptolemy.actor.parameters.PortParameter" 
value="echo &quot;Hello, world.&quot;"></property>
---------------------------------------------------------------------------
At runtime because of name duplication error, I think, the actor is not able 
to load onto kepler canvas.  The exception is as shown below,
-----------------------------------------------------------
After removing  the line <property name="command" 
class="ptolemy.actor.parameters.PortParameter" value="echo &quot;Hello, 
world.&quot;"></property>, I am able to see this actor on the kepler canvas.

I am here with enclosing kar file of this actor.

Could you mind to advise me to fix this error?

============================================================================================
ptolemy.kernel.util.NameDuplicationException: Attempt to insert object named 
"command" into a container that already contains an object with that name.

   at ptolemy.kernel.util.NamedList.append(NamedList.java:125)

   at ptolemy.kernel.util.NamedObj._addAttribute(NamedObj.java:1988)

   at ptolemy.kernel.util.Attribute.setContainer(Attribute.java:348)

   at ptolemy.data.expr.Variable.setContainer(Variable.java:767)

   at ptolemy.kernel.util.Attribute.<init>(Attribute.java:87)

   at 
ptolemy.kernel.util.AbstractSettableAttribute.<init>(AbstractSettableAttribute.java:88)

   at ptolemy.data.expr.Variable.<init>(Variable.java:255)

   at ptolemy.data.expr.Parameter.<init>(Parameter.java:124)

   at ptolemy.actor.parameters.PortParameter.<init>(PortParameter.java:137)

   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

   at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

   at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

   at java.lang.reflect.Constructor.newInstance(Constructor.java:274)

   at ptolemy.moml.MoMLParser._createInstance(MoMLParser.java:3673)

   at ptolemy.moml.MoMLParser._handlePropertyElement(MoMLParser.java:4755)

   at ptolemy.moml.MoMLParser.startElement(MoMLParser.java:2560)

   at com.microstar.xml.XmlParser.parseElement(XmlParser.java:918)

   at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1101)

   at com.microstar.xml.XmlParser.parseElement(XmlParser.java:921)

   at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:479)

   at com.microstar.xml.XmlParser.doParse(XmlParser.java:157)

   at com.microstar.xml.XmlParser.parse(XmlParser.java:130)

   at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1273)

   at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1246)

   at org.kepler.objectmanager.ActorMetadata.<init>(ActorMetadata.java:157)

   at 
org.kepler.objectmanager.cache.ActorCacheObject.<init>(ActorCacheObject.java:74)

   at 
org.kepler.objectmanager.cache.KARCacheObject.handleKSWItem(KARCacheObject.java:227)

   at 
org.kepler.objectmanager.cache.KARCacheObject.<init>(KARCacheObject.java:118)

   at 
org.monash.griddles.JGridletCreater.processKSW(JGridletCreater.java:295)

   at org.monash.griddles.JGridletCreater.fire(JGridletCreater.java:188)

   at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:309)

   at 
ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:171)

   at ptolemy.actor.CompositeActor.fire(CompositeActor.java:331)

   at ptolemy.actor.Manager.iterate(Manager.java:600)

   at ptolemy.actor.Manager.execute(Manager.java:318)

   at ptolemy.actor.Manager.run(Manager.java:968)

   at ptolemy.actor.Manager$3.run(Manager.java:1020)

========================================================



Chad Berkley wrote:

>I opened your kar file and found that the localActorName.xml file does not 
>have a semanticType property.  It can't be placed in the tree without a 
>semantic type.  you need to tell the system where it should be placed in 
>the tree by adding that attribute.
>
>Also, in the manifest file, you're giving the kar file the same lsid as the 
>actorMetadata file.
>
>Manifest-Version: 1.4.2
>lsid: urn:lsid:kepler-project.org:actor1:1:1
>KAR-Version: 1.0
>
>Name: localActorName.xml
>lsid: urn:lsid:kepler-project.org:actor1:1:1
>type: actorMetadata
>
>They should be different.  maybe kar1:1:1 for the kar file.
>
>chad
>
>jagan wrote:
>
>>Hi Chad,
>>
>>I am able to add actor programmitically but I can able to see on the 
>>canvas.
>>
>>I have followed the following steps in adding actors,
>>
>>============================================
>>      GriddlesExec wss = null;             _actorNameStr = 
>>actorName.getExpression();
>>     container = new EntityLibrary();
>>     wss = new GriddlesExec(container, _actorNameStr);                     
>>      -> creates dynamic actor                      File kswFile = new 
>>File("kar/actors/"+_actorNameStr+".kar");             KSWBuilder ksw = new 
>>KSWBuilder(wss , false , kswFile);             -> created kar archive file
>>
>>     processKSW(kswFile);                                                  
>>                    -> processed to insert object in cache and build tree 
>>with refresh method
>>      System.out.println("Printing Component Items");                      
>>            -> printed output to see whether entries exist in lib
>>     LibraryIndex index = LibraryIndex.getInstance();
>>     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 );
>>       }
>>==================================================================
>>The following code is very similar to your code in CreateKSWDialog.java 
>>file with minor changes
>>--------------------------------------------------------------------------------------------------
>>  private void processKSW(File kswFile)
>>  {
>>    try
>>    {
>>      KeplerLSID[] actorLSIDs;
>>      CacheManager cache = CacheManager.getInstance();
>>      KARCacheObject kco = new KARCacheObject(kswFile);
>>      //cache.insertObject(kco);                                           
>>                   -> I have commented out because previous step did this 
>>activity
>>      try
>>      {
>>      actorLSIDs = kco.getActors();
>>      }
>>      catch(LSIDException lside)
>>      {
>>        System.out.println("Error getting actor lsid: " + 
>>lside.getMessage());
>>        return;
>>      }
>>          if(actorLSIDs != null)
>>      {
>>        System.out.println("processing kar file: " + 
>>kswFile.getAbsolutePath());
>>        //AnnotationEngine AEngine = AnnotationEngine.instance();
>>        for(int j=0; j<actorLSIDs.length; j++)
>>        {                   ActorCacheObject aco = 
>>(ActorCacheObject)cache.getObject(actorLSIDs[j]);                          
>>ActorMetadata am = aco.getMetadata();                try
>>         { //build an entity for each actor in the ksw and add it to the 
>>actorLibrary
>>         System.out.println("processing " + am.getLSID());
>>
>>         LibraryIndexItem subtree = 
>>LibraryIndex.getInstance().findItem(new 
>>KeplerLSID("urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor"));
>>         System.out.println("subtreeitem="+subtree);
>>                   LibraryIndex.getInstance().add(new 
>>LibraryIndexComponentItem(am.getName(), am.getLSID()), subtree);
>>         LibraryIndex.getInstance().refresh();
>>         System.out.println("actor " + " loaded into the library in 
>>category " + subtree.getName() + " with id " +am.getId());
>>                   //  NamedObj actorEntity = 
>>am.getActorAsNamedObj(container);                                          
>>                -> I have commented out this because
>>         //  util.EmptyChangeRequest request = new 
>>util.EmptyChangeRequest(actorEntity, "request change");     ->  I am 
>>getting duplication error
>>          //  actorEntity.requestChange(request);
>>          }
>>          catch(Exception e)
>>          {
>>            e.printStackTrace();
>>            System.out.println("Error creating ComponentEntity from actor 
>>" + "metadata: " + e.getMessage());
>>            return;
>>          }
>>        }
>>      }
>>    }
>>    catch(CacheException ce)
>>    {
>>      System.out.println("Error with the cache: " + ce.getMessage());
>>      return;
>>    }
>>  }  
>>============================================================================================
>>I have used your class for KSWBuilder except minor change to reflect name 
>>of the xml file to be name of newly created actor name.
>>
>>===============================================================================================
>>The output statements are as follows:
>>=============================
>>     [java] Creating transport KAR file at 
>>C:\kepler\kar\actors\localActorName.kar
>>     [java] karLSID: urn:lsid:kepler-project.org:actor1:1:1
>>     [java] done writing KAR file to 
>>C:\kepler\kar\actors\localActorName.kar
>>     [java] processing kar file: C:\kepler\kar\actors\localActorName.kar
>>     [java] processing urn:lsid:kepler-project.org:actor1:1:1
>>     [java] subtreeitem=<concept name="gridlets" 
>>lsid="urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor"/>
>>
>>     [java] actor  loaded into the library in category gridlets with id 
>>urn:lsid:kepler-project.org:actor1:1:1
>>     [java] Printing Component Items
>>     [java] <component name="CT Director" 
>>lsid="urn:lsid:kepler-project.org:director:4:1"/>
>>-----------------------
>>-----------------------
>>-----------------------
>>    [java] <component name="JGridlet Creater" 
>>lsid="urn:lsid:kepler-project.org:actor:445:1"/>
>>
>>     [java] <component name="JGridlet Remote Creater" 
>>lsid="urn:lsid:kepler-project.org:actor:444:1"/>
>>
>>     [java] <component name="localActorName" 
>>lsid="urn:lsid:kepler-project.org:actor1:1:1"/>
>>
>>     [java] <component name="Convert Image To String" 
>>lsid="urn:lsid:kepler-project.org:actor:106:1"/>
>>-------------------
>>------------------
>>-------------------
>>   [java] Printing Ontologies
>>     [java] <ontology name="Kepler Actor Ontology" 
>>lsid="urn:lsid:localhost:onto:1:1">
>>     [java] <concept name="Director" 
>>lsid="urn:lsid:localhost:onto:1:1#Director">
>>     [java] <component name="CT Director" 
>>lsid="urn:lsid:kepler-project.org:director:4:1"/>
>>     [java] <component name="DE Director" 
>>lsid="urn:lsid:kepler-project.org:director:3:1"/>
>>     [java] <component name="PN Director" 
>>lsid="urn:lsid:kepler-project.org:director:2:1"/>
>>     [java] <component name="SDF Director" 
>>lsid="urn:lsid:kepler-project.org:director:1:1"/>
>>     [java] </concept>
>>----------------------
>>------------------------
>>-------------------------
>>     [java] <concept name="Griddles" 
>>lsid="urn:lsid:localhost:onto:1:1#GriddlesActor">
>>     [java] <component name="Griddles Exec" 
>>lsid="urn:lsid:kepler-project.org:actor:442:1"/>
>>     [java] <component name="Griddles Remote Exec" 
>>lsid="urn:lsid:kepler-project.org:actor:441:1"/>
>>     [java] <component name="Griddles Remote File" 
>>lsid="urn:lsid:kepler-project.org:actor:443:1"/>
>>     [java] <component name="JCOGGridFTP" 
>>lsid="urn:lsid:kepler-project.org:actor:451:1"/>
>>     [java] <component name="JCOGPROXYExec" 
>>lsid="urn:lsid:kepler-project.org:actor:450:1"/>
>>     [java] <component name="JCOGWorkflowEditor" 
>>lsid="urn:lsid:kepler-project.org:actor:453:1"/>
>>     [java] <component name="JCOGWorkflowExec" 
>>lsid="urn:lsid:kepler-project.org:actor:452:1"/>
>>     [java] <component name="JGridlet Creater" 
>>lsid="urn:lsid:kepler-project.org:actor:445:1"/>
>>     [java] <component name="JGridlet Remote Creater" 
>>lsid="urn:lsid:kepler-project.org:actor:444:1"/>
>>     [java] <concept name="gridlets" 
>>lsid="urn:lsid:localhost:onto:1:1#PreConfiguredGridletActor">
>>     [java] <component name="localActorName" 
>>lsid="urn:lsid:kepler-project.org:actor1:1:1"/>
>>     [java] </concept>
>>     [java] </concept>
>>
>>======================================================================
>>I have serailized the library index and I saw entries relating to the 
>>newly added actors.
>>
>>I have also seen building the tree with new entries in it.
>>
>>I am not able to see the newly added actors on the canvas. I have even 
>>tried by reastart Kepler but no luck.
>>
>>I have seen a file  ( ~/Documents and Settings/jagan/.kepler/actorLibrary) 
>>  which was created at the time of starting (ant run).
>>I am not able to see newly added actors in this file even after adding 
>>actors programmatically.
>>
>>Could you mind to tell me whether I am missing anything?
>>
>>I am here with enclosing kar file generated at runtime for the newly 
>>created actor.
>>
>>I haven't put these things in cvs repository as I have changed few of 
>>original files that may cause problems to other people.
>>
>>Once I test my additions, I will put back in cvs repository.
>>
>>
>>with regards,
>>
>>Jagan Kommineni
>>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: localActorName.kar
Type: audio/mid
Size: 1085 bytes
Desc: not available
Url : http://mercury.nceas.ucsb.edu/ecoinformatics/pipermail/kepler-dev/attachments/20060223/21433f97/localActorName-0001.bin


More information about the Kepler-dev mailing list