[kepler-dev] Adding actors programmatically ......
jagan
Jagan.Kommineni at infotech.monash.edu.au
Mon Feb 20 22:40:39 PST 2006
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
Chad Berkley wrote:
>Hmm, I'm not sure what's wrong. Have you looked at what I did in the
>CreateKSWDialog class? It works in there so you must be missing
>something. If you're getting an NPE, you should look and see exactly
>which object is being returned as Null. That might lead you to the
>place where you are missing info or where something isn't getting cached.
>
>chad
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: localActorName.kar
Type: audio/mid
Size: 977 bytes
Desc: not available
URL: <http://mercury.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20060221/e49034ec/attachment.bin>
More information about the Kepler-dev
mailing list