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

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


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 
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 
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
SemanticType semanticType = new SemanticType(wss, "semanticType00");
    // update the actor library
KSWBuilder ksw = new KSWBuilder(wss , false , 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 
These entries are as follows
<property name="command" class="org.kepler.moml.PortAttribute">
<property name="direction" value="input" 
<property name="dataType" value="unknown" 
<property name="isMultiport" value="false" 
   <property name="_showName" class="ptolemy.data.expr.Parameter" 
<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.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 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.monash.griddles.JGridletCreater.fire(JGridletCreater.java:188)

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


   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.
>jagan wrote:
>>Hi Chad,
>>I am able to add actor programmitically but I can able to see on the 
>>I have followed the following steps in adding actors,
>>      GriddlesExec wss = null;             _actorNameStr = 
>>     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) 
>>       System.out.println( key );
>>       }
>>      System.out.println("Printing Ontologies");
>>      for ( Iterator iter = index.ontologies(); iter.hasNext(); )
>>       {
>>       LibraryIndexOntologyItem key = (LibraryIndexOntologyItem) 
>>       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 
>>      try
>>      {
>>      actorLSIDs = kco.getActors();
>>      }
>>      catch(LSIDException lside)
>>      {
>>        System.out.println("Error getting actor lsid: " + 
>>        return;
>>      }
>>          if(actorLSIDs != null)
>>      {
>>        System.out.println("processing kar file: " + 
>>        //AnnotationEngine AEngine = AnnotationEngine.instance();
>>        for(int j=0; j<actorLSIDs.length; j++)
>>        {                   ActorCacheObject aco = 
>>ActorMetadata am = aco.getMetadata();                try
>>         { //build an entity for each actor in the ksw and add it to the 
>>         System.out.println("processing " + am.getLSID());
>>         LibraryIndexItem subtree = 
>>         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 = 
>>                -> 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 
>>     [java] karLSID: urn:lsid:kepler-project.org:actor1:1:1
>>     [java] done writing KAR file to 
>>     [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" 
>>     [java] actor  loaded into the library in category gridlets with id 
>>     [java] Printing Component Items
>>     [java] <component name="CT Director" 
>>    [java] <component name="JGridlet Creater" 
>>     [java] <component name="JGridlet Remote Creater" 
>>     [java] <component name="localActorName" 
>>     [java] <component name="Convert Image To String" 
>>   [java] Printing Ontologies
>>     [java] <ontology name="Kepler Actor Ontology" 
>>     [java] <concept name="Director" 
>>     [java] <component name="CT Director" 
>>     [java] <component name="DE Director" 
>>     [java] <component name="PN Director" 
>>     [java] <component name="SDF Director" 
>>     [java] </concept>
>>     [java] <concept name="Griddles" 
>>     [java] <component name="Griddles Exec" 
>>     [java] <component name="Griddles Remote Exec" 
>>     [java] <component name="Griddles Remote File" 
>>     [java] <component name="JCOGGridFTP" 
>>     [java] <component name="JCOGPROXYExec" 
>>     [java] <component name="JCOGWorkflowEditor" 
>>     [java] <component name="JCOGWorkflowExec" 
>>     [java] <component name="JGridlet Creater" 
>>     [java] <component name="JGridlet Remote Creater" 
>>     [java] <concept name="gridlets" 
>>     [java] <component name="localActorName" 
>>     [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