You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(39) |
May
(165) |
Jun
(164) |
Jul
(127) |
Aug
(81) |
Sep
(146) |
Oct
(375) |
Nov
(241) |
Dec
(77) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(42) |
Feb
(38) |
Mar
(30) |
Apr
(6) |
May
(17) |
Jun
|
Jul
(15) |
Aug
(59) |
Sep
(31) |
Oct
(44) |
Nov
(30) |
Dec
(12) |
| 2008 |
Jan
(9) |
Feb
(63) |
Mar
(18) |
Apr
(43) |
May
(28) |
Jun
(32) |
Jul
(61) |
Aug
(5) |
Sep
(72) |
Oct
(48) |
Nov
(6) |
Dec
|
|
From: <ha...@us...> - 2008-02-01 18:37:42
|
Revision: 1871
http://cogkit.svn.sourceforge.net/cogkit/?rev=1871&view=rev
Author: hategan
Date: 2008-02-01 10:37:39 -0800 (Fri, 01 Feb 2008)
Log Message:
-----------
updated list() to reuse data channels
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-gt2/CHANGES.txt
trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/FileResourceImpl.java
trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java
Modified: trunk/current/src/cog/modules/provider-gt2/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-gt2/CHANGES.txt 2008-01-27 23:42:24 UTC (rev 1870)
+++ trunk/current/src/cog/modules/provider-gt2/CHANGES.txt 2008-02-01 18:37:39 UTC (rev 1871)
@@ -1,3 +1,7 @@
+(02/01/2008)
+
+*** Missed some spots on the data channel reuse.
+
(12/03/2007)
*** Added data channel reuse mode for GridFTP if the server
Modified: trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/FileResourceImpl.java
===================================================================
--- trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/FileResourceImpl.java 2008-01-27 23:42:24 UTC (rev 1870)
+++ trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/FileResourceImpl.java 2008-02-01 18:37:39 UTC (rev 1871)
@@ -69,7 +69,7 @@
}
else {
try {
- this.getGridFTPClient().setPassiveMode(true);
+ initializeDataChannel();
Vector v = this.getGridFTPClient().mlsd();
ArrayList list = new ArrayList();
Iterator i = v.iterator();
@@ -126,7 +126,7 @@
}
else {
try {
- this.getGridFTPClient().setPassiveMode(true);
+ initializeDataChannel();
Vector v = this.getGridFTPClient().mlsd(directory);
ArrayList list = new ArrayList();
Iterator i = v.iterator();
@@ -155,7 +155,7 @@
* It's twice as fast as doing a cwd
*/
try {
- this.getGridFTPClient().setPassiveMode(false);
+ initializeDataChannel();
MlsxEntry me = this.getGridFTPClient().mlst(dirName);
return me.get("type").endsWith("dir");
}
Modified: trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java
===================================================================
--- trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java 2008-01-27 23:42:24 UTC (rev 1870)
+++ trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java 2008-02-01 18:37:39 UTC (rev 1871)
@@ -125,7 +125,7 @@
}
}
- private void initializeDataChannel() throws ClientException,
+ protected void initializeDataChannel() throws ClientException,
ServerException, IOException {
if (!dataChannelInitialized || !dataChannelReuse) {
gridFTPClient.setPassiveMode(true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-27 23:42:27
|
Revision: 1870
http://cogkit.svn.sourceforge.net/cogkit/?rev=1870&view=rev
Author: jenvor
Date: 2008-01-27 15:42:24 -0800 (Sun, 27 Jan 2008)
Log Message:
-----------
add support for workflow queue. A workflow queue can contain many workflows. A workflow can contain many jobs(described by Karajan language now).
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/handler.js
trunk/cyberaide/src/js/securelogin/cogkit/index.html
trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js
Modified: trunk/cyberaide/src/js/securelogin/cogkit/handler.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/handler.js 2008-01-21 04:23:44 UTC (rev 1869)
+++ trunk/cyberaide/src/js/securelogin/cogkit/handler.js 2008-01-27 23:42:24 UTC (rev 1870)
@@ -59,7 +59,7 @@
}catch(e){
alert( e );
}
- if( typeof rslt == "string" ) return rslt;
+ return rslt;
}
}
/*
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-21 04:23:44 UTC (rev 1869)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-27 23:42:24 UTC (rev 1870)
@@ -26,10 +26,11 @@
<script type='text/javascript'>
/* This piece of code adds visual widgets to ease workflow composition*/
Ext.onReady(function(){
- jg_doc = new jsGraphics("div_job_manage");
- clientJobQueue = new JobQueue();
- lines = new lineManager(jg_doc);
- jobDepend = new JobDependency(clientJobQueue, jg_doc, lines, 'div_job_manage2');
+ //jg_doc = new jsGraphics("canvasPlaceHolder");//div_job_manage");
+ //clientJobQueue = new JobQueue();
+ //jobDepend = new JobDependency(jg_doc, 'div_job_manage2');
+ //wfqueue = new WFQueue(jg_doc, 'div_job_manage2');
+ wfqueue = new WFQueue();
Ext.override(Ext.dd.DDProxy, {
endDrag: function() {
var dragEl = Ext.get(this.getDragEl());
@@ -37,13 +38,12 @@
if(this.lastTarget) {
Ext.get(this.lastTarget).appendChild(el);
el.applyStyles({position:'', width:''});
- }
- else {
+ } else {
el.applyStyles({position:'absolute'});
el.setXY(dragEl.getXY());
el.setWidth(dragEl.getWidth());
}
- lines.modifyLines(this.getEl().id);
+ wfqueue.modifyLines(this.getEl().id);
}
});
@@ -53,18 +53,25 @@
promptwin.hide();
tabpanel = new Ext.TabPanel({
renderTo: 'tabs',
- activeTab: 0,
+ activeTab: 1,
width:'100%',
height:'100%',
- activeTab: 0,
//defaults:{autoScroll: true},
items:[
+ {
+ contentEl: 'tab_help',
+ title:'Help',
+ height: 400
+ },
{ contentEl:'tab_wfsubmit',
- title:'Workflow Submit',
+ title:'Job Submit',
id: 'tab_wfsubmit',
listeners: {
deactivate: function(){
widgettoolbox.hide();
+ var hiddenOutputId = "hiddenOutputArea";
+ var hiddenele = document.getElementById(hiddenOutputId);
+ hiddenele.style.display = 'none';
},
activate: function(){
widgettoolbox.show();
@@ -73,26 +80,37 @@
}
},
{ contentEl:'tab_wfquery',
- title:'Status Query'
+ title:'Status Query',
+ listeners:{
+ deactivate: function(){
+ var hiddenOutputId = "hiddenOutputArea";
+ var hiddenele = document.getElementById(hiddenOutputId);
+ hiddenele.style.display = 'none';
+ }
+ }
},
+ /*
{
contentEl: 'tab_jobmanage',
id: 'tab_jobmanage',
title: 'Job Management',
- height: 1024,
listeners:{
activate: function(){
jobDepend.display('div_job_manage2', 50,30, 70);
}
}
- },
+ },*/
{
- contentEl: 'tab_help',
- title:'Help',
+ contentEl: 'tab_jobqueuemanage',
+ id: 'tab_jobqueuemanage',
+ title: 'Workflow Queue Management',
height: 400
}
]
});
+
+ updateWFComboList('wflistcombo');
+ updateWFComboList('wflistcombo2');
});
</script>
@@ -121,11 +139,11 @@
var workflow = document.getElementById( eleid );
if( workflow == null ){
alert("Element with id "+eleid+" does not exist.");
- return;
+ return false;
}
if( workflow.value == "" ){
- alert( 'Please input workflow description' );
- return;
+ alert( 'Please input corresponding content' );
+ return false;
}
return workflow.value;
}
@@ -419,51 +437,165 @@
return;
}
times --;
- setTimeout("blinkText()",250);
+ setTimeout("blinkText()",100);
}
+
+ function blinkWFName(){
+ var wfnameele = document.getElementById( 'wflistcombo2' );
+ if(times%2==0)
+ wfnameele.style.border='2px solid yellow';
+ else
+ wfnameele.style.border='';
+ if( times == 0 ) {
+ wfnameele.focus();
+ return;
+ }
+ times --;
+ setTimeout("blinkWFName()",100);
+ }
+
function overwriteExistJob(id){
if(id=='yes'){
var wf = getInput( 'workflow' );
var wfnameele = document.getElementById( 'wfname' );
var errorSpan = document.getElementById( 'wfnameprompt' );
+ var workflow = document.getElementById( 'wflistcombo2' );
+ var workflowQ = workflow.value;
var wf = getInput( 'workflow' );
var wfname = wfnameele.value;
- clientJobQueue.updateJob( wfname, wf );
- errorSpan.innerHTML = '';
+
+ var jobDepend = wfqueue.getByName(wfname);
+ jobDepend.updateJob( wfname, wf );
+ errorSpan.innerHTML = 'Done';
wfnameele.style.border = '';
}
}
function addAJob(){
var wf = getInput( 'workflow' );
+ if( wf == false ) return;
var wfnameele = document.getElementById( 'wfname' );
var errorSpan = document.getElementById( 'wfnameprompt' );
+ var workflow = document.getElementById( 'wflistcombo2' );
+ var workflowQ = workflow.value;
+
var wfname = wfnameele.value;
var isfailed = false;
if( wfname == "" ){
isfailed = true;
}
- if( clientJobQueue.isExist( wfname ) ){
- isfailed = true;
- Ext.MessageBox.confirm("Overwrite confirmation", 'A job with name "'+wfname+'" has existed already. Do you want to overwrite it?', overwriteExistJob);
- }
- if( isfailed ){
- errorSpan.innerHTML = ' <= Please correct it';
+ if( wfqueue.isExist( workflowQ ) == false ){
+ Ext.Msg.alert('incorrect workflow name', 'You have not specified name of the workflow or you specified wrong name.');
times = 6;
- blinkText();
+ blinkWFName();
return;
}else{
- wfnameele.style.border = '';
- errorSpan.innerHTML = "";
- clientJobQueue.addJob(wfname, wf);
+ var jobDepend = wfqueue.getByName( workflowQ );
+ if( jobDepend.isExist( wfname ) ){
+ isfailed = true;
+ Ext.MessageBox.confirm("Overwrite confirmation", 'A job with name "'+wfname+'" has existed already. Do you want to overwrite it?', overwriteExistJob);
+ }
+ if( isfailed ){
+ errorSpan.innerHTML = ' <= Please correct it';
+ times = 6;
+ blinkText();
+ return;
+ }else{
+ wfnameele.style.border = '';
+ errorSpan.innerHTML = "Done";
+ jobDepend.addJob(wfname, wf);
+ var wfele = document.getElementById( 'wflistcombo2' );
+ wfele.style.border ='';
+ }
}
- /* var result = COGHandler.executeMethods("JobQueue.addJob", "test", wf);
- if( result == false ){
- alert('add job failed');
- }*/
}
+
function switch2JobMgr(newtabid){
tabpanel.activate('tab_jobmanage');
}
+
+ function showAllJobsInWF( event, outputDivId ){
+ var curtab = tabpanel.getActiveTab();
+ var tabtitle = curtab.title;
+ var jobDepend = wfqueue.getByName( tabtitle );
+ var output = jobDepend.getJobList();
+ var ele = Ext.getDom( outputDivId );
+ ele.value = output;
+ adjustTextArea(event, outputDivId);
+ }
+
+ function createNewWF( wfnameinput ){
+ var ele = Ext.getDom( wfnameinput );
+ var wfname = ele.value;
+ if( wfname == "" ){
+ Ext.MessageBox.alert('incorrect workflow name', 'Name of a workflow should not be empty!!');
+ return;
+ }
+ if( wfqueue.isExist( wfname ) ){
+ var str = 'Workflow "'+wfname+'" exists already';
+ Ext.Msg.alert('incorrect workflow name', str);
+ return;
+ }
+ var wf = wfqueue.createNewWF( wfname );
+ var canvasid = wf._targetId+"_canvas";
+ var canvasdrawid = wf._targetId+"_canvasd";
+
+ var innerHtml = '<div id="'+canvasid+'"></div><div id="'+canvasdrawid+'"></div>';
+ innerHtml += '<div style="float:right;">';
+ innerHtml += '<input type="button" onclick=\'javascript:showAllJobsInWF(event, "WFOutputDiv");\' value="click to see all jobs"></input>';
+ innerHtml += "</div>";
+
+ var panel = new Ext.Panel({
+ title: wfname,
+ id: wf._targetId,
+ height: 1024,
+ html: innerHtml,
+ listeners:{
+ activate: function(){
+ if( wf._canvas == null ){
+ var canvas = new jsGraphics( canvasid );
+ wf.setCanvas( canvas );
+ }
+ var jobDepend = wfqueue.getByName( wfname );
+ //jobDepend.display(wf._targetId, 50,30, 70);
+ jobDepend.display(canvasdrawid, 50,30, 70);
+ }
+ }
+ });
+ tabpanel.add(panel);
+ tabpanel.doLayout();
+
+ updateWFComboList('wflistcombo');
+ updateWFComboList('wflistcombo2');
+ }
+ function updateWFComboList(comboid){
+ var ele = Ext.getDom( comboid );
+ var html = '<option value="_empty_item_">Please select</option>';
+ var nwfs = wfqueue.getCount();
+ for( var i = 0 ; i < nwfs ; i++ ){
+ var wfname = wfqueue.getByIndex(i)._name;
+ html += '<option value="';
+ html += wfname;
+ html += '">';
+ html += wfname;
+ html += "</option>";
+ }
+ ele.innerHTML = html;
+ }
+ function removeWorkflow(eleid){
+ var ele = Ext.getDom( eleid );
+ if( ele != null ){
+ var wfname = ele.value;
+ var jobDepend = wfqueue.getByName(wfname);
+ if( jobDepend != null ){
+ var id = jobDepend._targetId;
+ tabpanel.remove(id);
+ tabpanel.doLayout();
+ wfqueue.removeByName( wfname );
+ updateWFComboList('wflistcombo2');
+ updateWFComboList('wflistcombo');
+ }
+ }
+ }
</script>
<style>
.wfdesbutton{
@@ -476,6 +608,12 @@
opacity:0.85;
filter:alpha(opacity=85); /* IE's opacity*/
}
+ .adjustPanel{
+ background-color:#CEDFF5;
+ opacity:0.8;
+ filter:alpha(opacity=80); /* IE's opacity*/
+ border: 1px inset #cedff5;
+ }
.workflow_relation_icon{
height: 18px;
border: 1px solid #a0a0a0;
@@ -487,6 +625,7 @@
padding: 5px;
}
.mytitle{
+ color: blue;
font-size: 20px;
}
</style>
@@ -500,7 +639,7 @@
<!-- Sample window -->
<div>
- <span class='mytitle' style='padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
+ <span class='mytitle' style='padding-top:0.3em; padding-bottom:0.3em;'>Job Sample</span>
<input type="button" value="click to see sample" onClick="javascript:diagShow(event);"/>
<div><textarea rows=15 cols=100 wrap='off' id="wfsample" style="display:none;" onBlur="javascript:diagHide(event);" onkeypress='javascript:keypressed(event, "wfsample");'>
@@ -518,13 +657,23 @@
<!-- Input area -->
<div>
- <div class='mytitle' style='padding-top:0.3em; padding-bottom:0em; color:blue;'>
- Workflow description:
- <span style='margin-left:10em;'>Workflow Name: <input type='text' id='wfname' name='wfname'/></span><span id='wfnameprompt' style='color:red;'></span>
+ <div class='mytitle' style='padding-top:0.3em; padding-bottom:0em;'>
+ <table class='mytitle'>
+ <tr><td style='height:2em;'>Job Name:
+ <input type='text' id='wfname' name='wfname'/>
+ </td><td style='width:10em;'>
+ <span id='wfnameprompt' style='color:red;padding-left:15px;'></span>
+ </td><td>
+ Add to workflow:
+ <select id='wflistcombo2'> </select>
+ </td></tr>
+ </table>
+ Job description:
</div>
+
<table>
<tr><td>
- <textarea id='workflow' onblur='javascript:this.blur();' wrap='off' cols=100 rows=15></textarea>
+ <textarea id='workflow' onblur='javascript:this.blur();' wrap='off' cols=100 rows=18></textarea>
<!-- <div id='workflowdiv'></div> -->
</td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
@@ -559,12 +708,13 @@
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' class='wfdesbutton' value='Job Management' onclick='javascript:switch2JobMgr();'></input>
</div>
+
</td></tr>
</table>
</div>
<!-- Resposne -->
- <div class='mytitle' style='padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
+ <div class='mytitle' style='padding-top:0.2em; padding-bottom:0.1em;'>Response from server:</div>
<table>
<tr><td>
<textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'></textarea>
@@ -577,13 +727,12 @@
</td></tr>
</table>
- <textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';" onkeypress='javascript:keypressed(event, "hiddenOutputArea");'></textarea>
</div>
<!--################## Second Tab: Workflow Query ###################-->
<div id='tab_wfquery' class="x-hide-display">
<div>
- <div class='mytitle' style='padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow id input area:</div>
+ <div class='mytitle' style='padding-top:0.3em; padding-bottom:0.3em;'>Workflow id input area:</div>
<table>
<tr><td>
<textarea id='workflowids' onblur='javascript:this.blur();' onfocus='javascript:this.focus();' wrap='off' cols=100 rows=10 ></textarea>
@@ -600,7 +749,7 @@
</div>
<div>
- <div class='mytitle' style='padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
+ <div class='mytitle' style='padding-top:0.2em; padding-bottom:0.1em;'>Response from server:</div>
<table>
<tr><td>
<textarea WRAP='off' id='statusresp' cols=100 rows=20 readOnly='true'></textarea>
@@ -623,13 +772,39 @@
</div>
</div>
+<!--
<div id='tab_jobmanage' class='x-hide-display'>
<div id='div_job_manage' ></div>
- <div id='div_job_manage2' style='position:absolute;'></div>
+ <div id='div_job_manage2' style='height:600px;'>
+ <div style='float:right;'>
+ <input type='button' onclick='javascript:showAllJobsInWF(event, "WFOutputDiv");' value='click to see all jobs'></input></div>
+ </div>
+ <textarea WRAP='off' style='visibility:hidden;' id='WFOutputDiv' cols=100 rows=1 readOnly='true'></textarea>
</div>
+ -->
+ <div id='tab_jobqueuemanage' class='x-hide-display'>
+ <table style='margin-left:30px;'>
+ <tr><td height=30 colspan=2></td></tr>
+ <tr><td width=200>
+ <input type='text' size=24 id='wfname_input'/>
+ </td><td>
+ <input type='button' onclick='javascript: createNewWF("wfname_input");' value='Add a workflow'></input>
+ </td></tr>
+ <tr><td height=10></td><td></td></tr>
+ <tr><td>
+ <select id='wflistcombo'></select>
+ </td><td>
+ <input type='button' onclick='javascript:removeWorkflow("wflistcombo");' value='Remove this workflow'></input>
+ </td></tr>
+ </table>
+ </div>
+
</div>
+ <textarea class='adjustPanel' style="display:none;" id="hiddenOutputArea" onblur="javascript:this.style.display='none';" onkeypress='javascript:keypressed(event, "hiddenOutputArea");'></textarea>
<div id="prompt"></div>
+ <div id="canvasPlaceHolder" style="position:absolute;"></div>
+ <textarea WRAP='off' style='visibility:hidden;' id='WFOutputDiv' cols=100 rows=1 readOnly='true'></textarea>
</body>
</html>
Modified: trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js 2008-01-21 04:23:44 UTC (rev 1869)
+++ trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js 2008-01-27 23:42:24 UTC (rev 1870)
@@ -358,6 +358,21 @@
}
return false;
}
+
+ this.serialize = function() {
+ var len = this.size();
+ var output = "";
+ for(var i = 0 ; i < len; i ++){
+ var job = this._queue[i];
+ output += "job "+(i+1)+"\n";
+ output += "name:" + job._name +"\n";
+ output += "content:\n" + job._wf + "\n";
+ output += "-----------------------------------------------------------------------\n";
+ }
+ if( len == 0 )
+ output = "\nNo job in the workflow\n";
+ return output;
+ }
}
@@ -366,16 +381,21 @@
/**
* This class manages dependency among jobs
*/
-function JobDependency(jobq, canvas, linemanager, eleid){
- this._jobq = jobq;
- this._canvas = canvas;
- this._lineManager = linemanager;
+function JobDependency(canvas, eleid, name){
+ this._jobq = new JobQueue();
+ this._name = name;
+ this._canvas = null;
+ this._lineManager = new lineManager(null);
this._targetId = eleid;
this._startx = 0;
this._starty = 0;
this._endindex = 0;
this._endId = 0;
+ this.setCanvas = function( canvas ){
+ this._canvas = canvas;
+ this._lineManager._canvas = canvas;
+ }
/*
this.addJob = function(name, wf){
this._jobq.addJob( name, wf );
@@ -405,7 +425,7 @@
var job = this._jobq.getJob(i);
var tag = job._name;
if( job._id == "" ){
- var id = "workflow_"+j;
+ var id = this._targetId+'_'+j;
job._id = id;
}else{
var id = job_id;
@@ -417,6 +437,7 @@
this._endId = j;
ele.innerHTML += htm;
+ var self = this;
var oldid = "";
for( var i = 0; i < len ; i ++ ){
//var id = ids[i-this._endindex];
@@ -425,15 +446,19 @@
extElement.dd = new Ext.dd.DDProxy(id, 'canvas');
extElement.on('contextmenu', function(e){
var targetid = this.id;
+ var fromMItem = new Ext.menu.Item({text : 'from',host:targetid, jobClass:self, icon:''});
+ var toMItem = new Ext.menu.Item({text : 'to',host:targetid, jobClass:self, icon:''});
+ var deleteMItem = new Ext.menu.Item({text : 'delete',host:targetid, jobClass:self, icon:''});
+ var editMItem = new Ext.menu.Item({text : 'edit',host:targetid, jobClass:self,icon:''});
+ fromMItem.addListener('click', lineFrom, this);
+ toMItem.addListener('click', lineTo, this);
+ deleteMItem.addListener('click', deleteJob, this);
+ editMItem.addListener('click', editJob, this);
+
var contextMenu = new Ext.menu.Menu({
text: 'Menu',
id:'contextMenu',
- items:[
- {text : 'from', handler: lineFrom, host:targetid, icon:''},
- {text : 'to', handler:lineTo, host:targetid, icon:''},
- {text : 'delete', handler:deleteJob, host:targetid, icon:''},
- {text : 'edit', handler:editJob, host:targetid, icon:''}
- ]
+ items:[ fromMItem, toMItem, deleteMItem, editMItem ]
});
e.stopEvent();
var xy = e.getXY();
@@ -463,6 +488,35 @@
}
this._endindex = len;
};
+
+ /**
+ * When a rectangle is repositioned, related lines should be repositioned accordingly.
+ */
+ this.modifyLines = function(eleid){
+ this._lineManager.modifyLines(eleid);
+ }
+
+ this.updateJob = function(jobname, jobcontent){
+ this._jobq.updateJob(jobname, jobcontent);
+ }
+
+ this.addJob = function(jobname, jobcontent){
+ this._jobq.addJob(jobname, jobcontent);
+ }
+
+ this.isExist = function( jobname ){
+ return this._jobq.isExist(jobname);
+ }
+ this.removeJobById = function( jobid ){
+ return this._jobq.removeJobById(jobid);
+ }
+ this.getJobById = function( jobid ){
+ return this._jobq.getJobById(jobid);
+ }
+
+ this.getJobList = function( ){
+ return this._jobq.serialize();
+ }
}
from = null;
@@ -472,6 +526,7 @@
}
function lineTo(ele, e){
+ var lines = ele.jobClass._lineManager;
if( from != null ){
var lineid = from.host + '_' + ele.host;
lines.addLine(from.host, ele.host, lineid, true);
@@ -479,6 +534,7 @@
}
function deleteJob(ele, e){
+ var lines = ele.jobClass._lineManager;
var eleid = ele.host;
lines.eraseLineByEle( eleid );//remove related lines
@@ -486,17 +542,121 @@
jobEle.remove();
//remove job from job queue
- clientJobQueue.removeJobById( eleid );
- jobDepend._endindex--;
+ //clientJobQueue.removeJobById( eleid );
+ var index = eleid.lastIndexOf('_');
+ var tabid = eleid;
+ if( index != -1 )
+ tabid = eleid.substring(0, index);
+ var jobDepend = wfqueue.getById( tabid );
+ if( jobDepend == null ){
+ alert('Something impossible occurs');
+ return;
+ }else{
+ jobDepend.removeJobById( eleid );
+ jobDepend._endindex--;
+ }
}
+
function editJob(ele, e){
var eleid = ele.host;
- var job = clientJobQueue.getJobById( eleid );
- if( job != null ){
- var wfnameele = document.getElementById( 'wfname' );
- wfnameele.value = job._name;
- var wf= document.getElementById( 'workflow' );
- wf.value = job._wf;
- tabpanel.activate( 'tab_wfsubmit' );
+ var index = eleid.lastIndexOf('_');
+ var tabid = eleid;
+ if( index != -1 )
+ tabid = eleid.substring(0, index);
+ var jobDepend = wfqueue.getById( tabid );
+ if( jobDepend == null ){
+ alert('Something impossible occurs');
+ return;
+ }else{
+ var job = jobDepend.getJobById( eleid );
+ if( job != null ){
+ var wfnameele = document.getElementById( 'wfname' );
+ wfnameele.value = job._name;
+ var wf= document.getElementById( 'workflow' );
+ wf.value = job._wf;
+ var wfp = document.getElementById( 'wflistcombo2' );
+ wfp.value = jobDepend._name;
+ tabpanel.activate( 'tab_wfsubmit' );
+ }
}
}
+
+/**
+ * This class manages all workflow queues.
+ * The workflow in this queue can be executed in arbitrary order.
+ */
+function WFQueue(){
+ this._queue = [];
+ this._WFIDEnd = 0;
+ this._WFIDBase = 'wfworkflow';
+
+ this.createNewWF = function( wfname ){
+ if( this.isExist(wfname) == false ){
+ this._WFIDEnd ++;
+ var eleid = this._WFIDBase + this._WFIDEnd;
+ var wf = new JobDependency(this._canvas, eleid, wfname);
+ this._queue.push(wf);
+ return wf;
+ }
+ return null;
+ };
+
+ this.modifyLines = function( dragId ){
+ var index = dragId.lastIndexOf('_');
+ var tabid = dragId;
+ if( index != -1 )
+ tabid = dragId.substring(0, index);
+ var jobDepend = this.getById( tabid );
+ if( jobDepend == null ){
+ alert('Something impossible occurs');
+ return;
+ }else{
+ jobDepend.modifyLines( dragId );
+ }
+ };
+
+ this.isExist = function( wfname ){
+ var len = this._queue.length;
+ for( var i = 0 ; i < len ; i ++ ){
+ if( this._queue[i]._name == wfname )
+ return true;
+ }
+ return false;
+ };
+ this.removeByName = function( wfname ){
+ var len = this._queue.length;
+ var i = 0;
+ for( i = 0 ; i < len ; i ++ ){
+ if( this._queue[i]._name == wfname )
+ break;
+ }
+ if( i != len )
+ this._queue.splice(i,1);
+ };
+ this.removeByIndex = function(index){
+ //TODO
+ };
+ this.getCount = function(){
+ return this._queue.length;
+ };
+ this.getByIndex = function(index){
+ return this._queue[index];
+ };
+ this.getByName = function( wfname ){
+ var len = this._queue.length;
+ for( var i = 0 ; i < len ; i ++ ){
+ if( this._queue[i]._name == wfname )
+ return this._queue[i];
+ }
+ return null;
+ };
+
+ this.getById = function( id ){
+ var len = this._queue.length;
+ for( var i = 0 ; i < len ; i ++ ){
+ if( this._queue[i]._targetId == id )
+ return this._queue[i];
+ }
+ return null;
+ };
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-21 04:23:46
|
Revision: 1869
http://cogkit.svn.sourceforge.net/cogkit/?rev=1869&view=rev
Author: jenvor
Date: 2008-01-20 20:23:44 -0800 (Sun, 20 Jan 2008)
Log Message:
-----------
add code comment and add more user-friendly functionality
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/index.html
trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-20 22:31:52 UTC (rev 1868)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-21 04:23:44 UTC (rev 1869)
@@ -61,6 +61,7 @@
items:[
{ contentEl:'tab_wfsubmit',
title:'Workflow Submit',
+ id: 'tab_wfsubmit',
listeners: {
deactivate: function(){
widgettoolbox.hide();
@@ -420,6 +421,18 @@
times --;
setTimeout("blinkText()",250);
}
+ function overwriteExistJob(id){
+ if(id=='yes'){
+ var wf = getInput( 'workflow' );
+ var wfnameele = document.getElementById( 'wfname' );
+ var errorSpan = document.getElementById( 'wfnameprompt' );
+ var wf = getInput( 'workflow' );
+ var wfname = wfnameele.value;
+ clientJobQueue.updateJob( wfname, wf );
+ errorSpan.innerHTML = '';
+ wfnameele.style.border = '';
+ }
+ }
function addAJob(){
var wf = getInput( 'workflow' );
var wfnameele = document.getElementById( 'wfname' );
@@ -428,16 +441,13 @@
var isfailed = false;
if( wfname == "" ){
isfailed = true;
- //alert( 'Please input workflow name' );
}
if( clientJobQueue.isExist( wfname ) ){
isfailed = true;
- //alert('workflow with name "'+wfname+'" has existed already!');
+ Ext.MessageBox.confirm("Overwrite confirmation", 'A job with name "'+wfname+'" has existed already. Do you want to overwrite it?', overwriteExistJob);
}
if( isfailed ){
errorSpan.innerHTML = ' <= Please correct it';
- //wfnameele.style.border='2px solid yellow';
- //setTimeout("blinkText(3)",500);
times = 6;
blinkText();
return;
@@ -446,7 +456,6 @@
errorSpan.innerHTML = "";
clientJobQueue.addJob(wfname, wf);
}
- //jobDepend.addJob( 'wf', wf );
/* var result = COGHandler.executeMethods("JobQueue.addJob", "test", wf);
if( result == false ){
alert('add job failed');
@@ -457,6 +466,9 @@
}
</script>
<style>
+ .wfdesbutton{
+ height: 24px;
+ }
.widget{
background-image: url('images/1.jpg');
}
@@ -474,6 +486,9 @@
z-index: 1000;
padding: 5px;
}
+ .mytitle{
+ font-size: 20px;
+ }
</style>
</head>
<body>
@@ -485,7 +500,7 @@
<!-- Sample window -->
<div>
- <span style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
+ <span class='mytitle' style='padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
<input type="button" value="click to see sample" onClick="javascript:diagShow(event);"/>
<div><textarea rows=15 cols=100 wrap='off' id="wfsample" style="display:none;" onBlur="javascript:diagHide(event);" onkeypress='javascript:keypressed(event, "wfsample");'>
@@ -503,7 +518,7 @@
<!-- Input area -->
<div>
- <div style='font-size:large;padding-top:0.3em; padding-bottom:0em; color:blue;'>
+ <div class='mytitle' style='padding-top:0.3em; padding-bottom:0em; color:blue;'>
Workflow description:
<span style='margin-left:10em;'>Workflow Name: <input type='text' id='wfname' name='wfname'/></span><span id='wfnameprompt' style='color:red;'></span>
</div>
@@ -513,16 +528,16 @@
<!-- <div id='workflowdiv'></div> -->
</td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='Regular echo' onclick='javascript:echo();'></input>
+ <input type='button' class='wfdesbutton' value='Regular echo' onclick='javascript:echo();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='WS echo' onclick='javascript:wsecho();'></input>
+ <input type='button' class='wfdesbutton' value='WS echo' onclick='javascript:wsecho();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px;display:none'>
- <input type='button' value='Workflow Handle' onclick='javascript:wfhandle();'></input>
+ <input type='button' class='wfdesbutton' value='Workflow Handle' onclick='javascript:wfhandle();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='WS Workflow Submission' onclick='javascript:wswfhandle();'></input>
+ <input type='button' class='wfdesbutton' value='WS Workflow Submission' onclick='javascript:wswfhandle();'></input>
</div>
<!-- This two buttons are moved to another tab panel
<div style='padding-top:10px;padding-bottom:10px'>
@@ -533,23 +548,23 @@
</div>
-->
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='JSON2XML' onclick='javascript:zhguoj2x();'></input>
+ <input type='button' class='wfdesbutton' value='JSON2XML' onclick='javascript:zhguoj2x();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
+ <input type='button' class='wfdesbutton' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='Add to Queue' onclick='javascript:addAJob();'></input>
+ <input type='button' class='wfdesbutton' value='Add to Queue' onclick='javascript:addAJob();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='Job Management' onclick='javascript:switch2JobMgr();'></input>
+ <input type='button' class='wfdesbutton' value='Job Management' onclick='javascript:switch2JobMgr();'></input>
</div>
</td></tr>
</table>
</div>
<!-- Resposne -->
- <div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
+ <div class='mytitle' style='padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
<textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'></textarea>
@@ -568,7 +583,7 @@
<!--################## Second Tab: Workflow Query ###################-->
<div id='tab_wfquery' class="x-hide-display">
<div>
- <div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow id input area:</div>
+ <div class='mytitle' style='padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow id input area:</div>
<table>
<tr><td>
<textarea id='workflowids' onblur='javascript:this.blur();' onfocus='javascript:this.focus();' wrap='off' cols=100 rows=10 ></textarea>
@@ -585,7 +600,7 @@
</div>
<div>
- <div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
+ <div class='mytitle' style='padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
<textarea WRAP='off' id='statusresp' cols=100 rows=20 readOnly='true'></textarea>
Modified: trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js 2008-01-20 22:31:52 UTC (rev 1868)
+++ trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js 2008-01-21 04:23:44 UTC (rev 1869)
@@ -1,6 +1,6 @@
/* This is related to draw the relation between different workflows in a canvas */
- /** This class represents a line
+ /** This class represents a directed line.
* Note: a line must be drawn between two html div elements.
* fromele and toele are ids of elements that are connected by this line.
*/
@@ -14,6 +14,18 @@
this.id = id;
this.arrowid1 = id+'_arrow1';
this.arrowid2 = id+'_arrow2';
+
+ /**
+ * This function removes this line from screen.
+ */
+ this.remove = function(){
+ var extele = Ext.get(this.id);
+ extele.remove();
+ extele = Ext.get(this.arrowid1);
+ extele.remove();
+ extele = Ext.get(this.arrowid2);
+ extele.remove();
+ }
};
/**
@@ -21,70 +33,87 @@
function lineManager( canvas ){
this._lines = new Array();
this._canvas = canvas;
+
/** Add or remove a line.
- * If the line with the attributes specified by parameters has already existed,
- * then remove it and erase it from screen.
* If the line with the attributes specified by parameters doesn't exist,
* then add a new line and draw it on screen.
+ * If the line with the attributes specified by parameters has already existed,
+ * then whether to remove it is determined by parameter removeExist.
*
* @param fromele id of the element from which the line starts
* @param toele id of the element where the line ends.
+ * @param removeExist indicate whether to remove the existing line.
+ * @param id id of the line
* @param fromx, fromy, tox, toy
- * two end points of the line
- * @param id id of the line
+ * two end points of the line. These four parameters are optional.
*/
this.addLine = function (fromele, toele, id, removeExist, fromx, fromy, tox, toy ){
var lineid = id, isRemoveExist = removeExist;
if( arguments.length == 4 ){
+ //If coordinates of two end points are not specified, get them based on related elements.
var center = getTwoCenter(fromele, toele);
- //var center = getCenter(fromele);
var fromx = center[0], fromy = center[1];
- //center = getCenter(toele);
var tox = center[2], toy = center[3];
}
var len = this._lines.length;
for( var i = 0 ; i < len; i ++ ){
- if( this._lines[i].id == lineid ) {
+ if( this._lines[i].id == lineid ) {//a line with the id exists.
if( isRemoveExist ){
- var extele = Ext.get(lineid);
- extele.remove();
- extele = Ext.get(this._lines[i].arrowid1);
- extele.remove();
- extele = Ext.get(this._lines[i].arrowid2);
- extele.remove();
- this.removeByRange(i);
+ this._lines[i].remove();
+ this.removeLine(i);
}
return;
}
}
- //The line does not exist, create a new one and draw it.
+
+ //The line does not exist, add a new one
+ this.addALine(fromele, toele, fromx, fromy, tox, toy, lineid);
+ };
+
+ /**
+ * This function adds a new line.
+ * There are two steps:
+ * (1) add the line to line array.
+ * (2) draw the new line to screen.
+ */
+ this.addALine = function(fromele, toele, fromx, fromy, tox, toy, lineid){
var newline = new Line(fromele, toele, fromx, fromy, tox, toy, lineid);
this._lines.push(newline);
- this._canvas.drawLine(fromx, fromy, tox, toy, lineid);
- var arrows = this.getArrows(fromx, fromy, tox, toy);
- this._canvas.drawLine(arrows[0], arrows[1], tox, toy, newline.arrowid1);
- this._canvas.drawLine(arrows[2], arrows[3], tox, toy, newline.arrowid2);
+ this.drawALine(newline);
+ }
+
+ /**
+ * This function draws a line with arrow on screen.
+ */
+ this.drawALine = function(line){
+ this._canvas.drawLine(line.fromx, line.fromy, line.tox, line.toy, line.id);
+ var arrows = this.getArrows(line.fromx, line.fromy, line.tox, line.toy);
+ this._canvas.drawLine(arrows[0], arrows[1], line.tox, line.toy, line.arrowid1);
+ this._canvas.drawLine(arrows[2], arrows[3], line.tox, line.toy, line.arrowid2);
this._canvas.paint();
- };
+ }
- /** Add a new line */
+ /**
+ * Erase lines related to the element specified by parameter eleid.
+ * There are two kinds of related lines:
+ * (1) lines start from the element.
+ * (2) lines ends at the element.
+ */
this.eraseLineByEle = function ( eleid ){
var len = this._lines.length;
for( var i = len-1; i >= 0; i -- ){
var line = this._lines[i];
if( line.fromele==eleid || line.toele==eleid ){
- var linele = Ext.get( line.id );
- linele.remove();
- lineele = Ext.get(line.arrowid1);
- lineele.remove();
- lineele = Ext.get(line.arrowid2);
- lineele.remove();
- this.removeByRange( i );
+ line.remove();
+ this.removeLine( i );
}
}
};
- /***/
+ /**
+ * This function calculates the coordinates of arrows of the line specified
+ * by parameters.
+ */
this.getArrows = function(fromx, fromy, tox, toy){
var dx = fromx - tox;
var dy = toy - fromy;
@@ -104,17 +133,20 @@
arrow2y = -Math.sin(arrow2)*arrowLen + toy;
return [arrow1x, arrow1y, arrow2x, arrow2y];
}
+
/**
- * remove a line from the array _lines.
+ * remove lines from the line array.
* Range [from, to] specifies the indices of elements in array _lines that
- * will be removed.
+ * will be removed. To remove one line, users can just specify the first
+ * parameter from.
*/
- this.removeByRange = function(from, to){
+ this.removeLine = function(from, to){
var _lines = this._lines;
var rest = _lines.slice((to || from) + 1 || _lines.length);
_lines.length = from < 0 ? _lines.length + from : from;
_lines.push.apply(_lines, rest);
};
+
/**
* This function modifies those lines which are related to the element specified
* by parameter eleid. These lines either start from the element or ends at the
@@ -129,51 +161,30 @@
*/
this.modifyLines = function( eleid ){
var oldline = [];
- //var center = getCenter( eleid );
var center = [];
-
var _lines = this._lines;
var len = _lines.length;
for( var i = 0 ; i < len; i ++ ){
line = _lines[i];
- /*
- if( line.fromele==eleid ){//this line starts from the specified element.
- line.fromx = center[0];
- line.fromy = center[1];
-
- }else if( line.toele==eleid ){//this line ends at the specified element.
- line.tox = center[0];
- line.toy = center[1];
- }*/
- if( line.fromele == eleid || line.toele == eleid ){
+ if( line.fromele == eleid || line.toele == eleid ){//find a related line
+ //recalculate the coordinates of two end points of this line.
center = getTwoCenter(line.fromele, line.toele);
line.fromx = center[0];
line.fromy = center[1];
line.tox = center[2];
line.toy = center[3];
- }
- if( line.fromele == eleid || line.toele == eleid ){
//remove it from screen
- var extele = Ext.get(line.id);
- extele.remove();
- extele = Ext.get(line.arrowid1);
- extele.remove();
- extele = Ext.get(line.arrowid2);
- extele.remove();
+ line.remove();
//draw a new line
- this._canvas.drawLine(line.fromx, line.fromy, line.tox, line.toy, line.id);
- //draw arrows
- var arrows = this.getArrows(line.fromx, line.fromy, line.tox, line.toy);
- this._canvas.drawLine(arrows[0], arrows[1], line.tox, line.toy, line.arrowid1);
- this._canvas.drawLine(arrows[2], arrows[3], line.tox, line.toy, line.arrowid2);
-
- this._canvas.paint();
+ this.drawALine(line);
}
}
};
}
+
+
/**
* Get center of an element.
* @param eleid id of the element to be investigated.
@@ -197,6 +208,10 @@
return center;
}
+ /**
+ * Get center of an element.
+ * @param eleid id of the element to be investigated.
+ */
function getTwoCenter( fromele, toele ){
var center = [];
var target = Ext.get( fromele );
@@ -210,13 +225,6 @@
var totop = target.getTop(true);
var toheight = target.getHeight();
var towidth = target.getWidth();
-/*
- ref = Ext.get( target.parent() );
- var leftref = target.getLeft();
- var topref = target.getTop();
- center.push(left - leftref + Math.round(width/2));
- center.push(top - topref + Math.round(height/2));
-*/
var isSide = false;
var topdiff = Math.abs( fromtop - totop );
var leftdiff = Math.abs( fromleft - toleft );
@@ -250,25 +258,72 @@
return center;
}
+/**
+ * This class represents a job.
+ */
function Job(name, wf){
this._name = name;
this._wf = wf;
this._id = "";
}
+/**
+ * This class manages jobs of a user.
+ */
function JobQueue(){
this._queue = [];
+ /**
+ * This function adds a new job to the job queue no matter whether
+ * a job with the name has already existed.
+ */
this.addJob = function( name, wf ){
var job = new Job(name, wf);
this._queue.push( job );
}
+
+ /**
+ * This function updates an existing job in the job queue.
+ */
+ this.updateJob = function( name, wf ){
+ var len = this.size();
+ for(var i = 0 ; i < len; i ++){
+ if( this._queue[i]._name == name ){
+ this._queue[i]._wf = wf;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Get number of jobs in job queue
+ */
this.size = function(){
return this._queue.length;
}
+
+ /**
+ * Get a job by its index in the job queue.
+ */
this.getJob = function(index){
if( index < 0 || index >= this.size() ) return null;
return this._queue[index];
}
+
+ /**
+ * Get a job according to its id.
+ */
+ this.getJobById = function( jobid ){
+ var len = this.size();
+ for(var i = 0 ; i < len; i ++){
+ if( this._queue[i]._id == jobid ){
+ return this._queue[i];
+ }
+ }
+ }
+
+ /**
+ * Remove a job id of which is specified by parameter jobid.
+ */
this.removeJobById = function( jobid ){
var len = this.size();
for(var i = 0 ; i < len; i ++){
@@ -279,12 +334,21 @@
}
}
+
+ /**
+ * Remove those jobs index of which are between values specified
+ * by parameter from and parameter to.
+ */
this.removeByRange = function(from, to){
var _array = this._queue;
var rest = _array.slice((to || from) + 1 || _array.length);
_array.length = from < 0 ? _array.length + from : from;
_array.push.apply(_array, rest);
};
+
+ /**
+ * Judge whether a job with the name specified by wfname has existed.
+ */
this.isExist = function( wfname ){
var len = this.size();
for(var i = 0 ; i < len; i ++){
@@ -299,6 +363,9 @@
/*------------------------------------------------------------------------------------*/
+/**
+ * This class manages dependency among jobs
+ */
function JobDependency(jobq, canvas, linemanager, eleid){
this._jobq = jobq;
this._canvas = canvas;
@@ -308,7 +375,6 @@
this._starty = 0;
this._endindex = 0;
this._endId = 0;
-// this._ids = [];
/*
this.addJob = function(name, wf){
@@ -363,9 +429,10 @@
text: 'Menu',
id:'contextMenu',
items:[
- {text : 'from', handler: lineFrom, host:targetid},
- {text : 'to', handler:lineTo, host:targetid},
- {text : 'delete', handler:deleteJob, host:targetid}
+ {text : 'from', handler: lineFrom, host:targetid, icon:''},
+ {text : 'to', handler:lineTo, host:targetid, icon:''},
+ {text : 'delete', handler:deleteJob, host:targetid, icon:''},
+ {text : 'edit', handler:editJob, host:targetid, icon:''}
]
});
e.stopEvent();
@@ -405,8 +472,10 @@
}
function lineTo(ele, e){
- var lineid = from.host + '_' + ele.host;
- lines.addLine(from.host, ele.host, lineid, true);
+ if( from != null ){
+ var lineid = from.host + '_' + ele.host;
+ lines.addLine(from.host, ele.host, lineid, true);
+ }
}
function deleteJob(ele, e){
@@ -420,3 +489,14 @@
clientJobQueue.removeJobById( eleid );
jobDepend._endindex--;
}
+function editJob(ele, e){
+ var eleid = ele.host;
+ var job = clientJobQueue.getJobById( eleid );
+ if( job != null ){
+ var wfnameele = document.getElementById( 'wfname' );
+ wfnameele.value = job._name;
+ var wf= document.getElementById( 'workflow' );
+ wf.value = job._wf;
+ tabpanel.activate( 'tab_wfsubmit' );
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-20 22:32:10
|
Revision: 1868
http://cogkit.svn.sourceforge.net/cogkit/?rev=1868&view=rev
Author: jenvor
Date: 2008-01-20 14:31:52 -0800 (Sun, 20 Jan 2008)
Log Message:
-----------
add Job management and visual widget for workflow-level dependency edit
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/index.html
Added Paths:
-----------
trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js
trunk/cyberaide/src/js/securelogin/cogkit/wz_jsgraphics.js
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-12 03:59:51 UTC (rev 1867)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-20 22:31:52 UTC (rev 1868)
@@ -11,6 +11,12 @@
<script type='text/javascript' src='xml2json.js'></script>
<script type='text/javascript' src='json2xml.js'></script>
+ <!-- javascritp graphics -->
+ <script type='text/javascript' src="wz_jsgraphics.js"></script>
+
+ <!-- job queue management -->
+ <script type='text/javascript' src="jobmanage.js"></script>
+
<!-- add ext 2 -->
<link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/resources/css/ext-all.css"/>
<script src="http://extjs.com/deploy/dev/adapter/ext/ext-base.js"></script>
@@ -20,11 +26,32 @@
<script type='text/javascript'>
/* This piece of code adds visual widgets to ease workflow composition*/
Ext.onReady(function(){
+ jg_doc = new jsGraphics("div_job_manage");
+ clientJobQueue = new JobQueue();
+ lines = new lineManager(jg_doc);
+ jobDepend = new JobDependency(clientJobQueue, jg_doc, lines, 'div_job_manage2');
+ Ext.override(Ext.dd.DDProxy, {
+ endDrag: function() {
+ var dragEl = Ext.get(this.getDragEl());
+ var el = Ext.get(this.getEl());
+ if(this.lastTarget) {
+ Ext.get(this.lastTarget).appendChild(el);
+ el.applyStyles({position:'', width:''});
+ }
+ else {
+ el.applyStyles({position:'absolute'});
+ el.setXY(dragEl.getXY());
+ el.setWidth(dragEl.getWidth());
+ }
+ lines.modifyLines(this.getEl().id);
+ }
+ });
+
//createBasicDesktop('workflowdiv');
var widgettoolbox = createWidgetToolbox();
promptwin.render('prompt');
promptwin.hide();
- new Ext.TabPanel({
+ tabpanel = new Ext.TabPanel({
renderTo: 'tabs',
activeTab: 0,
width:'100%',
@@ -48,6 +75,17 @@
title:'Status Query'
},
{
+ contentEl: 'tab_jobmanage',
+ id: 'tab_jobmanage',
+ title: 'Job Management',
+ height: 1024,
+ listeners:{
+ activate: function(){
+ jobDepend.display('div_job_manage2', 50,30, 70);
+ }
+ }
+ },
+ {
contentEl: 'tab_help',
title:'Help',
height: 400
@@ -81,6 +119,10 @@
function getInput( eleid ){
var workflow = document.getElementById( eleid );
if( workflow == null ){
+ alert("Element with id "+eleid+" does not exist.");
+ return;
+ }
+ if( workflow.value == "" ){
alert( 'Please input workflow description' );
return;
}
@@ -357,6 +399,63 @@
hiddenele.value = ele.value;
}
</script>
+ <script type="text/javascript">
+ function addJobCB( response, exception ){
+ if ( exception != null )
+ alert( exception );
+ else
+ alert( response );
+ }
+ times = 0;
+ function blinkText(){
+ var wfnameele = document.getElementById( 'wfname' );
+ if(times%2==0)
+ wfnameele.style.border='2px solid yellow';
+ else
+ wfnameele.style.border='';
+ if( times == 0 ) {
+ wfnameele.focus();
+ return;
+ }
+ times --;
+ setTimeout("blinkText()",250);
+ }
+ function addAJob(){
+ var wf = getInput( 'workflow' );
+ var wfnameele = document.getElementById( 'wfname' );
+ var errorSpan = document.getElementById( 'wfnameprompt' );
+ var wfname = wfnameele.value;
+ var isfailed = false;
+ if( wfname == "" ){
+ isfailed = true;
+ //alert( 'Please input workflow name' );
+ }
+ if( clientJobQueue.isExist( wfname ) ){
+ isfailed = true;
+ //alert('workflow with name "'+wfname+'" has existed already!');
+ }
+ if( isfailed ){
+ errorSpan.innerHTML = ' <= Please correct it';
+ //wfnameele.style.border='2px solid yellow';
+ //setTimeout("blinkText(3)",500);
+ times = 6;
+ blinkText();
+ return;
+ }else{
+ wfnameele.style.border = '';
+ errorSpan.innerHTML = "";
+ clientJobQueue.addJob(wfname, wf);
+ }
+ //jobDepend.addJob( 'wf', wf );
+ /* var result = COGHandler.executeMethods("JobQueue.addJob", "test", wf);
+ if( result == false ){
+ alert('add job failed');
+ }*/
+ }
+ function switch2JobMgr(newtabid){
+ tabpanel.activate('tab_jobmanage');
+ }
+ </script>
<style>
.widget{
background-image: url('images/1.jpg');
@@ -365,6 +464,16 @@
opacity:0.85;
filter:alpha(opacity=85); /* IE's opacity*/
}
+ .workflow_relation_icon{
+ height: 18px;
+ border: 1px solid #a0a0a0;
+ background-color: #c4d0ff;
+ vertical-align: middle;
+ cursor: move;
+ padding: 2px;
+ z-index: 1000;
+ padding: 5px;
+ }
</style>
</head>
<body>
@@ -389,16 +498,18 @@
<readFile file="thedate"/>
</set>
<echo message="The date is {date}"/>
-</project>
- </textarea></div>
+</project></textarea></div>
</div>
<!-- Input area -->
<div>
- <div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow description:</div>
+ <div style='font-size:large;padding-top:0.3em; padding-bottom:0em; color:blue;'>
+ Workflow description:
+ <span style='margin-left:10em;'>Workflow Name: <input type='text' id='wfname' name='wfname'/></span><span id='wfnameprompt' style='color:red;'></span>
+ </div>
<table>
<tr><td>
- <textarea id='workflow' onblur='javascript:this.blur();' wrap='off' cols=100 rows=15 ></textarea>
+ <textarea id='workflow' onblur='javascript:this.blur();' wrap='off' cols=100 rows=15></textarea>
<!-- <div id='workflowdiv'></div> -->
</td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
@@ -427,6 +538,12 @@
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
</div>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Add to Queue' onclick='javascript:addAJob();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Job Management' onclick='javascript:switch2JobMgr();'></input>
+ </div>
</td></tr>
</table>
</div>
@@ -446,7 +563,6 @@
</table>
<textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';" onkeypress='javascript:keypressed(event, "hiddenOutputArea");'></textarea>
- <div id="prompt"></div>
</div>
<!--################## Second Tab: Workflow Query ###################-->
@@ -492,6 +608,13 @@
</div>
</div>
+ <div id='tab_jobmanage' class='x-hide-display'>
+ <div id='div_job_manage' ></div>
+ <div id='div_job_manage2' style='position:absolute;'></div>
+ </div>
+
</div>
+
+ <div id="prompt"></div>
</body>
</html>
Added: trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js (rev 0)
+++ trunk/cyberaide/src/js/securelogin/cogkit/jobmanage.js 2008-01-20 22:31:52 UTC (rev 1868)
@@ -0,0 +1,422 @@
+/* This is related to draw the relation between different workflows in a canvas */
+
+ /** This class represents a line
+ * Note: a line must be drawn between two html div elements.
+ * fromele and toele are ids of elements that are connected by this line.
+ */
+ function Line(fromele, toele, fromx, fromy, tox, toy, id ){
+ this.fromele = fromele;
+ this.toele = toele;
+ this.fromx = fromx;
+ this.fromy = fromy;
+ this.tox = tox;
+ this.toy = toy;
+ this.id = id;
+ this.arrowid1 = id+'_arrow1';
+ this.arrowid2 = id+'_arrow2';
+ };
+
+ /**
+ * This line manages all lines drawn */
+ function lineManager( canvas ){
+ this._lines = new Array();
+ this._canvas = canvas;
+ /** Add or remove a line.
+ * If the line with the attributes specified by parameters has already existed,
+ * then remove it and erase it from screen.
+ * If the line with the attributes specified by parameters doesn't exist,
+ * then add a new line and draw it on screen.
+ *
+ * @param fromele id of the element from which the line starts
+ * @param toele id of the element where the line ends.
+ * @param fromx, fromy, tox, toy
+ * two end points of the line
+ * @param id id of the line
+ */
+ this.addLine = function (fromele, toele, id, removeExist, fromx, fromy, tox, toy ){
+ var lineid = id, isRemoveExist = removeExist;
+ if( arguments.length == 4 ){
+ var center = getTwoCenter(fromele, toele);
+ //var center = getCenter(fromele);
+ var fromx = center[0], fromy = center[1];
+ //center = getCenter(toele);
+ var tox = center[2], toy = center[3];
+ }
+ var len = this._lines.length;
+ for( var i = 0 ; i < len; i ++ ){
+ if( this._lines[i].id == lineid ) {
+ if( isRemoveExist ){
+ var extele = Ext.get(lineid);
+ extele.remove();
+ extele = Ext.get(this._lines[i].arrowid1);
+ extele.remove();
+ extele = Ext.get(this._lines[i].arrowid2);
+ extele.remove();
+ this.removeByRange(i);
+ }
+ return;
+ }
+ }
+ //The line does not exist, create a new one and draw it.
+ var newline = new Line(fromele, toele, fromx, fromy, tox, toy, lineid);
+ this._lines.push(newline);
+ this._canvas.drawLine(fromx, fromy, tox, toy, lineid);
+ var arrows = this.getArrows(fromx, fromy, tox, toy);
+ this._canvas.drawLine(arrows[0], arrows[1], tox, toy, newline.arrowid1);
+ this._canvas.drawLine(arrows[2], arrows[3], tox, toy, newline.arrowid2);
+ this._canvas.paint();
+ };
+
+ /** Add a new line */
+ this.eraseLineByEle = function ( eleid ){
+ var len = this._lines.length;
+ for( var i = len-1; i >= 0; i -- ){
+ var line = this._lines[i];
+ if( line.fromele==eleid || line.toele==eleid ){
+ var linele = Ext.get( line.id );
+ linele.remove();
+ lineele = Ext.get(line.arrowid1);
+ lineele.remove();
+ lineele = Ext.get(line.arrowid2);
+ lineele.remove();
+ this.removeByRange( i );
+ }
+ }
+ };
+
+ /***/
+ this.getArrows = function(fromx, fromy, tox, toy){
+ var dx = fromx - tox;
+ var dy = toy - fromy;
+ var len = Math.sqrt( dx*dx + dy*dy );
+ var cos = dx / len;
+ var angle = Math.acos( cos );
+ if( dy < 0 ){
+ angle = -angle;
+ }
+ var arrowAngle = Math.PI/10;
+ var arrowLen = 15;
+ var arrow1 = angle + arrowAngle;
+ var arrow2 = angle - arrowAngle;
+ arrow1x = Math.cos(arrow1)*arrowLen + tox;
+ arrow1y = -Math.sin(arrow1)*arrowLen + toy;
+ arrow2x = Math.cos(arrow2)*arrowLen + tox;
+ arrow2y = -Math.sin(arrow2)*arrowLen + toy;
+ return [arrow1x, arrow1y, arrow2x, arrow2y];
+ }
+ /**
+ * remove a line from the array _lines.
+ * Range [from, to] specifies the indices of elements in array _lines that
+ * will be removed.
+ */
+ this.removeByRange = function(from, to){
+ var _lines = this._lines;
+ var rest = _lines.slice((to || from) + 1 || _lines.length);
+ _lines.length = from < 0 ? _lines.length + from : from;
+ _lines.push.apply(_lines, rest);
+ };
+ /**
+ * This function modifies those lines which are related to the element specified
+ * by parameter eleid. These lines either start from the element or ends at the
+ * element. Typically, this function should be called because the element specified
+ * by parameter eleid is moved so that related lines must be adjusted accordingly.
+ * These are several steps here:
+ * (1) search which lines should be adjusted.
+ * (2) remove these lines
+ * (3) draw new corresponding lines.
+ *
+ * @param eleid id of an element.
+ */
+ this.modifyLines = function( eleid ){
+ var oldline = [];
+ //var center = getCenter( eleid );
+ var center = [];
+
+ var _lines = this._lines;
+ var len = _lines.length;
+ for( var i = 0 ; i < len; i ++ ){
+ line = _lines[i];
+ /*
+ if( line.fromele==eleid ){//this line starts from the specified element.
+ line.fromx = center[0];
+ line.fromy = center[1];
+
+ }else if( line.toele==eleid ){//this line ends at the specified element.
+ line.tox = center[0];
+ line.toy = center[1];
+ }*/
+ if( line.fromele == eleid || line.toele == eleid ){
+ center = getTwoCenter(line.fromele, line.toele);
+ line.fromx = center[0];
+ line.fromy = center[1];
+ line.tox = center[2];
+ line.toy = center[3];
+ }
+
+ if( line.fromele == eleid || line.toele == eleid ){
+ //remove it from screen
+ var extele = Ext.get(line.id);
+ extele.remove();
+ extele = Ext.get(line.arrowid1);
+ extele.remove();
+ extele = Ext.get(line.arrowid2);
+ extele.remove();
+
+ //draw a new line
+ this._canvas.drawLine(line.fromx, line.fromy, line.tox, line.toy, line.id);
+ //draw arrows
+ var arrows = this.getArrows(line.fromx, line.fromy, line.tox, line.toy);
+ this._canvas.drawLine(arrows[0], arrows[1], line.tox, line.toy, line.arrowid1);
+ this._canvas.drawLine(arrows[2], arrows[3], line.tox, line.toy, line.arrowid2);
+
+ this._canvas.paint();
+ }
+ }
+ };
+ }
+ /**
+ * Get center of an element.
+ * @param eleid id of the element to be investigated.
+ */
+ function getCenter( eleid ){
+ var center = [];
+ var target = Ext.get( eleid );
+ var left = target.getLeft(true);
+ var top = target.getTop(true);
+ var height = target.getHeight();
+ var width = target.getWidth();
+/*
+ ref = Ext.get( target.parent() );
+ var leftref = target.getLeft();
+ var topref = target.getTop();
+ center.push(left - leftref + Math.round(width/2));
+ center.push(top - topref + Math.round(height/2));
+*/
+ center.push(left + Math.round(width/2));
+ center.push(top + Math.round(height/2));
+ return center;
+ }
+
+ function getTwoCenter( fromele, toele ){
+ var center = [];
+ var target = Ext.get( fromele );
+ var fromleft = target.getLeft(true);
+ var fromtop = target.getTop(true);
+ var fromheight = target.getHeight();
+ var fromwidth = target.getWidth();
+
+ target = Ext.get( toele );
+ var toleft = target.getLeft(true);
+ var totop = target.getTop(true);
+ var toheight = target.getHeight();
+ var towidth = target.getWidth();
+/*
+ ref = Ext.get( target.parent() );
+ var leftref = target.getLeft();
+ var topref = target.getTop();
+ center.push(left - leftref + Math.round(width/2));
+ center.push(top - topref + Math.round(height/2));
+*/
+ var isSide = false;
+ var topdiff = Math.abs( fromtop - totop );
+ var leftdiff = Math.abs( fromleft - toleft );
+ if( leftdiff/topdiff > 3 ) isSide = true;
+
+ if( isSide == false ){
+ if( totop > fromtop ){
+ center.push(fromleft + Math.round(fromwidth/2));
+ center.push(fromtop + Math.round(fromheight));
+ center.push(toleft + Math.round(towidth/2));
+ center.push(totop + Math.round(0));
+ }else{
+ center.push(fromleft + Math.round(fromwidth/2));
+ center.push(fromtop + Math.round(0));
+ center.push(toleft + Math.round(towidth/2));
+ center.push(totop + Math.round(toheight));
+ }
+ }else{
+ if( toleft > fromleft ){
+ center.push(fromleft + Math.round(fromwidth));
+ center.push(fromtop + Math.round(fromheight/2));
+ center.push(toleft + Math.round(0));
+ center.push(totop + Math.round(toheight/2));
+ }else{
+ center.push(fromleft + Math.round(0));
+ center.push(fromtop + Math.round(fromheight/2));
+ center.push(toleft + Math.round(towidth));
+ center.push(totop + Math.round(toheight/2));
+ }
+ }
+ return center;
+ }
+
+function Job(name, wf){
+ this._name = name;
+ this._wf = wf;
+ this._id = "";
+}
+
+function JobQueue(){
+ this._queue = [];
+ this.addJob = function( name, wf ){
+ var job = new Job(name, wf);
+ this._queue.push( job );
+ }
+ this.size = function(){
+ return this._queue.length;
+ }
+ this.getJob = function(index){
+ if( index < 0 || index >= this.size() ) return null;
+ return this._queue[index];
+ }
+ this.removeJobById = function( jobid ){
+ var len = this.size();
+ for(var i = 0 ; i < len; i ++){
+ if( this._queue[i]._id == jobid ){
+ this.removeByRange(i);
+ break;
+ }
+ }
+ }
+
+ this.removeByRange = function(from, to){
+ var _array = this._queue;
+ var rest = _array.slice((to || from) + 1 || _array.length);
+ _array.length = from < 0 ? _array.length + from : from;
+ _array.push.apply(_array, rest);
+ };
+ this.isExist = function( wfname ){
+ var len = this.size();
+ for(var i = 0 ; i < len; i ++){
+ if( this._queue[i]._name == wfname ){
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+
+/*------------------------------------------------------------------------------------*/
+
+function JobDependency(jobq, canvas, linemanager, eleid){
+ this._jobq = jobq;
+ this._canvas = canvas;
+ this._lineManager = linemanager;
+ this._targetId = eleid;
+ this._startx = 0;
+ this._starty = 0;
+ this._endindex = 0;
+ this._endId = 0;
+// this._ids = [];
+
+ /*
+ this.addJob = function(name, wf){
+ this._jobq.addJob( name, wf );
+ if( this._init ){ this._init=fasle; return; }
+ var ele = document.getElementById(this._targetId);
+ var tag = "workflow_" + (this._jobq.size()-1);
+ var htm = '<div id="'+tag+'" class="workflow_relation_icon" style="position:absolute;left:'+this._startx+'px;top:'+this._starty+'px;">'+tag+'</div>';
+ ele.innerHTML += htm;
+ }
+ */
+
+ /**
+ * This function displays those jobs contained in job queue onto the element specified
+ * by parameter eleid.
+ */
+ this.display = function(eleid, startx, starty, stride ){
+ this._canvas.paint();
+ this._startx = startx;
+ this._starty = starty;
+
+ var len = this._jobq.size();
+ var x = startx, y = starty;
+ var ele = document.getElementById(eleid);
+ var htm = "";
+ var j = this._endId;
+ for( var i = this._endindex ; i < len ; i ++ ){
+ var job = this._jobq.getJob(i);
+ var tag = job._name;
+ if( job._id == "" ){
+ var id = "workflow_"+j;
+ job._id = id;
+ }else{
+ var id = job_id;
+ }
+ htm += '<div id="'+id+'" class="workflow_relation_icon" style="position:absolute;left:'+x+'px;top:'+y+'px;">'+tag+'</div>';
+ y += stride;
+ j++;
+ }
+ this._endId = j;
+ ele.innerHTML += htm;
+
+ var oldid = "";
+ for( var i = 0; i < len ; i ++ ){
+ //var id = ids[i-this._endindex];
+ var id = this._jobq.getJob(i)._id;
+ var extElement = Ext.get( id );
+ extElement.dd = new Ext.dd.DDProxy(id, 'canvas');
+ extElement.on('contextmenu', function(e){
+ var targetid = this.id;
+ var contextMenu = new Ext.menu.Menu({
+ text: 'Menu',
+ id:'contextMenu',
+ items:[
+ {text : 'from', handler: lineFrom, host:targetid},
+ {text : 'to', handler:lineTo, host:targetid},
+ {text : 'delete', handler:deleteJob, host:targetid}
+ ]
+ });
+ e.stopEvent();
+ var xy = e.getXY();
+ contextMenu.showAt(xy);
+ });
+
+ var htm = this._jobq.getJob(i)._wf;
+ htm = htm.replace('<','<','g');
+ htm = htm.replace('>','>','g');
+ htm = htm.replace('\n','<br>','g');
+ htm = htm.replace(' ',' ','g');
+ htm ='<div style="color:blue;">'+htm+'</div>';
+ new Ext.ToolTip({
+ html: htm,
+ title: 'workflow content:',
+ border: true,
+ target: id,
+ maxWidth: 1000,
+ showDelay : 1000*2
+ });
+
+ //draw a line betwen adjacent two jobs
+ if( i > this._endindex ){
+ this._lineManager.addLine(oldid, id, oldid+'_'+id, false);
+ }
+ oldid = id;
+ }
+ this._endindex = len;
+ };
+}
+
+from = null;
+
+function lineFrom(ele, e){
+ from = ele;
+}
+
+function lineTo(ele, e){
+ var lineid = from.host + '_' + ele.host;
+ lines.addLine(from.host, ele.host, lineid, true);
+}
+
+function deleteJob(ele, e){
+ var eleid = ele.host;
+ lines.eraseLineByEle( eleid );//remove related lines
+
+ var jobEle = Ext.get( eleid );//remove the job element
+ jobEle.remove();
+
+ //remove job from job queue
+ clientJobQueue.removeJobById( eleid );
+ jobDepend._endindex--;
+}
Added: trunk/cyberaide/src/js/securelogin/cogkit/wz_jsgraphics.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/wz_jsgraphics.js (rev 0)
+++ trunk/cyberaide/src/js/securelogin/cogkit/wz_jsgraphics.js 2008-01-20 22:31:52 UTC (rev 1868)
@@ -0,0 +1,1106 @@
+/* This notice must be untouched at all times.
+
+wz_jsgraphics.js v. 3.02
+The latest version is available at
+http://www.walterzorn.com
+or http://www.devira.com
+or http://www.walterzorn.de
+
+Copyright (c) 2002-2004 Walter Zorn. All rights reserved.
+Created 3. 11. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
+Last modified: 26. 10. 2007
+
+Performance optimizations for Internet Explorer
+by Thomas Frank and John Holdsworth.
+fillPolygon method implemented by Matthieu Haller.
+
+High Performance JavaScript Graphics Library.
+Provides methods
+- to draw lines, rectangles, ellipses, polygons
+ with specifiable line thickness,
+- to fill rectangles, polygons, ellipses and arcs
+- to draw text.
+NOTE: Operations, functions and branching have rather been optimized
+to efficiency and speed than to shortness of source code.
+
+LICENSE: LGPL
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License (LGPL) as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
+or see http://www.gnu.org/copyleft/lesser.html
+*/
+
+
+var jg_ok, jg_ie, jg_fast, jg_dom, jg_moz;
+
+
+function _chkDHTM(x, i)
+{
+ x = document.body || null;
+ jg_ie = x && typeof x.insertAdjacentHTML != "undefined" && document.createElement;
+ jg_dom = (x && !jg_ie &&
+ typeof x.appendChild != "undefined" &&
+ typeof document.createRange != "undefined" &&
+ typeof (i = document.createRange()).setStartBefore != "undefined" &&
+ typeof i.createContextualFragment != "undefined");
+ jg_fast = jg_ie && document.all && !window.opera;
+ jg_moz = jg_dom && typeof x.style.MozOpacity != "undefined";
+ jg_ok = !!(jg_ie || jg_dom);
+}
+
+function _pntCnvDom()
+{
+ var x = this.wnd.document.createRange();
+ x.setStartBefore(this.cnv);
+ x = x.createContextualFragment(jg_fast? this._htmRpc() : this.htm);
+ if(this.cnv) this.cnv.appendChild(x);
+ this.htm = "";
+}
+
+function _pntCnvIe()
+{
+ if(this.cnv) this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this._htmRpc() : this.htm);
+ this.htm = "";
+}
+
+function _pntDoc()
+{
+ this.wnd.document.write(jg_fast? this._htmRpc() : this.htm);
+ this.htm = '';
+}
+
+function _pntN()
+{
+ ;
+}
+
+function _mkDiv(x, y, w, h)
+{
+ this.htm += '<div style="position:absolute;'+
+ 'left:' + x + 'px;'+
+ 'top:' + y + 'px;'+
+ 'width:' + w + 'px;'+
+ 'height:' + h + 'px;'+
+ 'clip:rect(0,'+w+'px,'+h+'px,0);'+
+ 'background-color:' + this.color +
+ (!jg_moz? ';overflow:hidden' : '')+
+ ';"><\/div>';
+}
+
+function _mkDivIe(x, y, w, h)
+{
+ this.htm += '%%'+this.color+';'+x+';'+y+';'+w+';'+h+';';
+}
+
+function _mkDivPrt(x, y, w, h)
+{
+ this.htm += '<div style="position:absolute;'+
+ 'border-left:' + w + 'px solid ' + this.color + ';'+
+ 'left:' + x + 'px;'+
+ 'top:' + y + 'px;'+
+ 'width:0px;'+
+ 'height:' + h + 'px;'+
+ 'clip:rect(0,'+w+'px,'+h+'px,0);'+
+ 'background-color:' + this.color +
+ (!jg_moz? ';overflow:hidden' : '')+
+ ';"><\/div>';
+}
+
+var _regex = /%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;
+function _htmRpc()
+{
+ return this.htm.replace(
+ _regex,
+ '<div style="overflow:hidden;position:absolute;background-color:'+
+ '$1;left:$2;top:$3;width:$4;height:$5"></div>\n');
+}
+
+function _htmPrtRpc()
+{
+ return this.htm.replace(
+ _regex,
+ '<div style="overflow:hidden;position:absolute;background-color:'+
+ '$1;left:$2;top:$3;width:$4;height:$5;border-left:$4px solid $1"></div>\n');
+}
+
+function _mkLin(x1, y1, x2, y2, divid)
+{
+ if(x1 > x2)
+ {
+ var _x2 = x2;
+ var _y2 = y2;
+ x2 = x1;
+ y2 = y1;
+ x1 = _x2;
+ y1 = _y2;
+ }
+ var dx = x2-x1, dy = Math.abs(y2-y1),
+ x = x1, y = y1,
+ yIncr = (y1 > y2)? -1 : 1;
+
+ if(dx >= dy)
+ {
+ var pr = dy<<1,
+ pru = pr - (dx<<1),
+ p = pr-dx,
+ ox = x;
+ while(dx > 0)
+ {--dx;
+ ++x;
+ if(p > 0)
+ {
+ this._mkDiv(ox, y, x-ox, 1);
+ y += yIncr;
+ p += pru;
+ ox = x;
+ }
+ else p += pr;
+ }
+ this._mkDiv(ox, y, x2-ox+1, 1);
+ }
+
+ else
+ {
+ var pr = dx<<1,
+ pru = pr - (dy<<1),
+ p = pr-dy,
+ oy = y;
+ if(y2 <= y1)
+ {
+ while(dy > 0)
+ {--dy;
+ if(p > 0)
+ {
+ this._mkDiv(x++, y, 1, oy-y+1);
+ y += yIncr;
+ p += pru;
+ oy = y;
+ }
+ else
+ {
+ y += yIncr;
+ p += pr;
+ }
+ }
+ this._mkDiv(x2, y2, 1, oy-y2+1);
+ }
+ else
+ {
+ while(dy > 0)
+ {--dy;
+ y += yIncr;
+ if(p > 0)
+ {
+ this._mkDiv(x++, oy, 1, y-oy);
+ p += pru;
+ oy = y;
+ }
+ else p += pr;
+ }
+ this._mkDiv(x2, oy, 1, y2-oy+1);
+ }
+ }
+ this.htm = '<div id="'+divid+'" style="position:absolute;z-index:9999;">' + this.htm + '</div>';
+}
+
+function _mkLin2D(x1, y1, x2, y2)
+{
+ if(x1 > x2)
+ {
+ var _x2 = x2;
+ var _y2 = y2;
+ x2 = x1;
+ y2 = y1;
+ x1 = _x2;
+ y1 = _y2;
+ }
+ var dx = x2-x1, dy = Math.abs(y2-y1),
+ x = x1, y = y1,
+ yIncr = (y1 > y2)? -1 : 1;
+
+ var s = this.stroke;
+ if(dx >= dy)
+ {
+ if(dx > 0 && s-3 > 0)
+ {
+ var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
+ _s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
+ }
+ else var _s = s;
+ var ad = Math.ceil(s/2);
+
+ var pr = dy<<1,
+ pru = pr - (dx<<1),
+ p = pr-dx,
+ ox = x;
+ while(dx > 0)
+ {--dx;
+ ++x;
+ if(p > 0)
+ {
+ this._mkDiv(ox, y, x-ox+ad, _s);
+ y += yIncr;
+ p += pru;
+ ox = x;
+ }
+ else p += pr;
+ }
+ this._mkDiv(ox, y, x2-ox+ad+1, _s);
+ }
+
+ else
+ {
+ if(s-3 > 0)
+ {
+ var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
+ _s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
+ }
+ else var _s = s;
+ var ad = Math.round(s/2);
+
+ var pr = dx<<1,
+ pru = pr - (dy<<1),
+ p = pr-dy,
+ oy = y;
+ if(y2 <= y1)
+ {
+ ++ad;
+ while(dy > 0)
+ {--dy;
+ if(p > 0)
+ {
+ this._mkDiv(x++, y, _s, oy-y+ad);
+ y += yIncr;
+ p += pru;
+ oy = y;
+ }
+ else
+ {
+ y += yIncr;
+ p += pr;
+ }
+ }
+ this._mkDiv(x2, y2, _s, oy-y2+ad);
+ }
+ else
+ {
+ while(dy > 0)
+ {--dy;
+ y += yIncr;
+ if(p > 0)
+ {
+ this._mkDiv(x++, oy, _s, y-oy+ad);
+ p += pru;
+ oy = y;
+ }
+ else p += pr;
+ }
+ this._mkDiv(x2, oy, _s, y2-oy+ad+1);
+ }
+ }
+}
+
+function _mkLinDott(x1, y1, x2, y2)
+{
+ if(x1 > x2)
+ {
+ var _x2 = x2;
+ var _y2 = y2;
+ x2 = x1;
+ y2 = y1;
+ x1 = _x2;
+ y1 = _y2;
+ }
+ var dx = x2-x1, dy = Math.abs(y2-y1),
+ x = x1, y = y1,
+ yIncr = (y1 > y2)? -1 : 1,
+ drw = true;
+ if(dx >= dy)
+ {
+ var pr = dy<<1,
+ pru = pr - (dx<<1),
+ p = pr-dx;
+ while(dx > 0)
+ {--dx;
+ if(drw) this._mkDiv(x, y, 1, 1);
+ drw = !drw;
+ if(p > 0)
+ {
+ y += yIncr;
+ p += pru;
+ }
+ else p += pr;
+ ++x;
+ }
+ }
+ else
+ {
+ var pr = dx<<1,
+ pru = pr - (dy<<1),
+ p = pr-dy;
+ while(dy > 0)
+ {--dy;
+ if(drw) this._mkDiv(x, y, 1, 1);
+ drw = !drw;
+ y += yIncr;
+ if(p > 0)
+ {
+ ++x;
+ p += pru;
+ }
+ else p += pr;
+ }
+ }
+ if(drw) this._mkDiv(x, y, 1, 1);
+}
+
+function _mkOv(left, top, width, height)
+{
+ var a = (++width)>>1, b = (++height)>>1,
+ wod = width&1, hod = height&1,
+ cx = left+a, cy = top+b,
+ x = 0, y = b,
+ ox = 0, oy = b,
+ aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
+ st = (aa2>>1)*(1-(b<<1)) + bb2,
+ tt = (bb2>>1) - aa2*((b<<1)-1),
+ w, h;
+ while(y > 0)
+ {
+ if(st < 0)
+ {
+ st += bb2*((x<<1)+3);
+ tt += bb4*(++x);
+ }
+ else if(tt < 0)
+ {
+ st += bb2*((x<<1)+3) - aa4*(y-1);
+ tt += bb4*(++x) - aa2*(((y--)<<1)-3);
+ w = x-ox;
+ h = oy-y;
+ if((w&2) && (h&2))
+ {
+ this._mkOvQds(cx, cy, x-2, y+2, 1, 1, wod, hod);
+ this._mkOvQds(cx, cy, x-1, y+1, 1, 1, wod, hod);
+ }
+ else this._mkOvQds(cx, cy, x-1, oy, w, h, wod, hod);
+ ox = x;
+ oy = y;
+ }
+ else
+ {
+ tt -= aa2*((y<<1)-3);
+ st -= aa4*(--y);
+ }
+ }
+ w = a-ox+1;
+ h = (oy<<1)+hod;
+ y = cy-oy;
+ this._mkDiv(cx-a, y, w, h);
+ this._mkDiv(cx+ox+wod-1, y, w, h);
+}
+
+function _mkOv2D(left, top, width, height)
+{
+ var s = this.stroke;
+ width += s+1;
+ height += s+1;
+ var a = width>>1, b = height>>1,
+ wod = width&1, hod = height&1,
+ cx = left+a, cy = top+b,
+ x = 0, y = b,
+ aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
+ st = (aa2>>1)*(1-(b<<1)) + bb2,
+ tt = (bb2>>1) - aa2*((b<<1)-1);
+
+ if(s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0))
+ {
+ var ox = 0, oy = b,
+ w, h,
+ pxw;
+ while(y > 0)
+ {
+ if(st < 0)
+ {
+ st += bb2*((x<<1)+3);
+ tt += bb4*(++x);
+ }
+ else if(tt < 0)
+ {
+ st += bb2*((x<<1)+3) - aa4*(y-1);
+ tt += bb4*(++x) - aa2*(((y--)<<1)-3);
+ w = x-ox;
+ h = oy-y;
+
+ if(w-1)
+ {
+ pxw = w+1+(s&1);
+ h = s;
+ }
+ else if(h-1)
+ {
+ pxw = s;
+ h += 1+(s&1);
+ }
+ else pxw = h = s;
+ this._mkOvQds(cx, cy, x-1, oy, pxw, h, wod, hod);
+ ox = x;
+ oy = y;
+ }
+ else
+ {
+ tt -= aa2*((y<<1)-3);
+ st -= aa4*(--y);
+ }
+ }
+ this._mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
+ this._mkDiv(cx+a+wod-s, cy-oy, s, (oy<<1)+hod);
+ }
+
+ else
+ {
+ var _a = (width-(s<<1))>>1,
+ _b = (height-(s<<1))>>1,
+ _x = 0, _y = _b,
+ _aa2 = (_a*_a)<<1, _aa4 = _aa2<<1, _bb2 = (_b*_b)<<1, _bb4 = _bb2<<1,
+ _st = (_aa2>>1)*(1-(_b<<1)) + _bb2,
+ _tt = (_bb2>>1) - _aa2*((_b<<1)-1),
+
+ pxl = new Array(),
+ pxt = new Array(),
+ _pxb = new Array();
+ pxl[0] = 0;
+ pxt[0] = b;
+ _pxb[0] = _b-1;
+ while(y > 0)
+ {
+ if(st < 0)
+ {
+ pxl[pxl.length] = x;
+ pxt[pxt.length] = y;
+ st += bb2*((x<<1)+3);
+ tt += bb4*(++x);
+ }
+ else if(tt < 0)
+ {
+ pxl[pxl.length] = x;
+ st += bb2*((x<<1)+3) - aa4*(y-1);
+ tt += bb4*(++x) - aa2*(((y--)<<1)-3);
+ pxt[pxt.length] = y;
+ }
+ else
+ {
+ tt -= aa2*((y<<1)-3);
+ st -= aa4*(--y);
+ }
+
+ if(_y > 0)
+ {
+ if(_st < 0)
+ {
+ _st += _bb2*((_x<<1)+3);
+ _tt += _bb4*(++_x);
+ _pxb[_pxb.length] = _y-1;
+ }
+ else if(_tt < 0)
+ {
+ _st += _bb2*((_x<<1)+3) - _aa4*(_y-1);
+ _tt += _bb4*(++_x) - _aa2*(((_y--)<<1)-3);
+ _pxb[_pxb.length] = _y-1;
+ }
+ else
+ {
+ _tt -= _aa2*((_y<<1)-3);
+ _st -= _aa4*(--_y);
+ _pxb[_pxb.length-1]--;
+ }
+ }
+ }
+
+ var ox = -wod, oy = b,
+ _oy = _pxb[0],
+ l = pxl.length,
+ w, h;
+ for(var i = 0; i < l; i++)
+ {
+ if(typeof _pxb[i] != "undefined")
+ {
+ if(_pxb[i] < _oy || pxt[i] < oy)
+ {
+ x = pxl[i];
+ this._mkOvQds(cx, cy, x, oy, x-ox, oy-_oy, wod, hod);
+ ox = x;
+ oy = pxt[i];
+ _oy = _pxb[i];
+ }
+ }
+ else
+ {
+ x = pxl[i];
+ this._mkDiv(cx-x, cy-oy, 1, (oy<<1)+hod);
+ this._mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
+ ox = x;
+ oy = pxt[i];
+ }
+ }
+ this._mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
+ this._mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
+ }
+}
+
+function _mkOvDott(left, top, width, height)
+{
+ var a = (++width)>>1, b = (++height)>>1,
+ wod = width&1, hod = height&1, hodu = hod^1,
+ cx = left+a, cy = top+b,
+ x = 0, y = b,
+ aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
+ st = (aa2>>1)*(1-(b<<1)) + bb2,
+ tt = (bb2>>1) - aa2*((b<<1)-1),
+ drw = true;
+ while(y > 0)
+ {
+ if(st < 0)
+ {
+ st += bb2*((x<<1)+3);
+ tt += bb4*(++x);
+ }
+ else if(tt < 0)
+ {
+ st += bb2*((x<<1)+3) - aa4*(y-1);
+ tt += bb4*(++x) - aa2*(((y--)<<1)-3);
+ }
+ else
+ {
+ tt -= aa2*((y<<1)-3);
+ st -= aa4*(--y);
+ }
+ if(drw && y >= hodu) this._mkOvQds(cx, cy, x, y, 1, 1, wod, hod);
+ drw = !drw;
+ }
+}
+
+function _mkRect(x, y, w, h)
+{
+ var s = this.stroke;
+ this._mkDiv(x, y, w, s);
+ this._mkDiv(x+w, y, s, h);
+ this._mkDiv(x, y+h, w+s, s);
+ this._mkDiv(x, y+s, s, h-s);
+}
+
+function _mkRectDott(x, y, w, h)
+{
+ this.drawLine(x, y, x+w, y);
+ this.drawLine(x+w, y, x+w, y+h);
+ this.drawLine(x, y+h, x+w, y+h);
+ this.drawLine(x, y, x, y+h);
+}
+
+function jsgFont()
+{
+ this.PLAIN = 'font-weight:normal;';
+ this.BOLD = 'font-weight:bold;';
+ this.ITALIC = 'font-style:italic;';
+ this.ITALIC_BOLD = this.ITALIC + this.BOLD;
+ this.BOLD_ITALIC = this.ITALIC_BOLD;
+}
+var Font = new jsgFont();
+
+function jsgStroke()
+{
+ this.DOTTED = -1;
+}
+var Stroke = new jsgStroke();
+
+function jsGraphics(cnv, wnd)
+{
+ this.setColor = function(x)
+ {
+ this.color = x.toLowerCase();
+ };
+
+ this.setStroke = function(x)
+ {
+ this.stroke = x;
+ if(!(x+1))
+ {
+ this.drawLine = _mkLinDott;
+ this._mkOv = _mkOvDott;
+ this.drawRect = _mkRectDott;
+ }
+ else if(x-1 > 0)
+ {
+ this.drawLine = _mkLin2D;
+ this._mkOv = _mkOv2D;
+ this.drawRect = _mkRect;
+ }
+ else
+ {
+ this.drawLine = _mkLin;
+ this._mkOv = _mkOv;
+ this.drawRect = _mkRect;
+ }
+ };
+
+ this.setPrintable = function(arg)
+ {
+ this.printable = arg;
+ if(jg_fast)
+ {
+ this._mkDiv = _mkDivIe;
+ this._htmRpc = arg? _htmPrtRpc : _htmRpc;
+ }
+ else this._mkDiv = arg? _mkDivPrt : _mkDiv;
+ };
+
+ this.setFont = function(fam, sz, sty)
+ {
+ this.ftFam = fam;
+ this.ftSz = sz;
+ this.ftSty = sty || Font.PLAIN;
+ };
+
+ this.drawPolyline = this.drawPolyLine = function(x, y)
+ {
+ for (var i=x.length - 1; i;)
+ {--i;
+ this.drawLine(x[i], y[i], x[i+1], y[i+1]);
+ }
+ };
+
+ this.fillRect = function(x, y, w, h)
+ {
+ this._mkDiv(x, y, w, h);
+ };
+
+ this.drawPolygon = function(x, y)
+ {
+ this.drawPolyline(x, y);
+ this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
+ };
+
+ this.drawEllipse = this.drawOval = function(x, y, w, h)
+ {
+ this._mkOv(x, y, w, h);
+ };
+
+ this.fillEllipse = this.fillOval = function(left, top, w, h)
+ {
+ var a = w>>1, b = h>>1,
+ wod = w&1, hod = h&1,
+ cx = left+a, cy = top+b,
+ x = 0, y = b, oy = b,
+ aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
+ st = (aa2>>1)*(1-(b<<1)) + bb2,
+ tt = (bb2>>1) - aa2*((b<<1)-1),
+ xl, dw, dh;
+ if(w) while(y > 0)
+ {
+ if(st < 0)
+ {
+ st += bb2*((x<<1)+3);
+ tt += bb4*(++x);
+ }
+ else if(tt < 0)
+ {
+ st += bb2*((x<<1)+3) - aa4*(y-1);
+ xl = cx-x;
+ dw = (x<<1)+wod;
+ tt += bb4*(++x) - aa2*(((y--)<<1)-3);
+ dh = oy-y;
+ this._mkDiv(xl, cy-oy, dw, dh);
+ this._mkDiv(xl, cy+y+hod, dw, dh);
+ oy = y;
+ }
+ else
+ {
+ tt -= aa2*((y<<1)-3);
+ st -= aa4*(--y);
+ }
+ }
+ this._mkDiv(cx-a, cy-oy, w, (oy<<1)+hod);
+ };
+
+ this.fillArc = function(iL, iT, iW, iH, fAngA, fAngZ)
+ {
+ var a = iW>>1, b = iH>>1,
+ iOdds = (iW&1) | ((iH&1) << 16),
+ cx = iL+a, cy = iT+b,
+ x = 0, y = b, ox = x, oy = y,
+ aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
+ st = (aa2>>1)*(1-(b<<1)) + bb2,
+ tt = (bb2>>1) - aa2*((b<<1)-1),
+ // Vars for radial boundary lines
+ xEndA, yEndA, xEndZ, yEndZ,
+ iSects = (1 << (Math.floor((fAngA %= 360.0)/180.0) << 3))
+ | (2 << (Math.floor((fAngZ %= 360.0)/180.0) << 3))
+ | ((fAngA >= fAngZ) << 16),
+ aBndA = new Array(b+1), aBndZ = new Array(b+1);
+
+ // Set up radial boundary lines
+ fAngA *= Math.PI/180.0;
+ fAngZ *= Math.PI/180.0;
+ xEndA = cx+Math.round(a*Math.cos(fAngA));
+ yEndA = cy+Math.round(-b*Math.sin(fAngA));
+ _mkLinVirt(aBndA, cx, cy, xEndA, yEndA);
+ xEndZ = cx+Math.round(a*Math.cos(fAngZ));
+ yEndZ = cy+Math.round(-b*Math.sin(fAngZ));
+ _mkLinVirt(aBndZ, cx, cy, xEndZ, yEndZ);
+
+ while(y > 0)
+ {
+ if(st < 0) // Advance x
+ {
+ st += bb2*((x<<1)+3);
+ tt += bb4*(++x);
+ }
+ else if(tt < 0) // Advance x and y
+ {
+ st += bb2*((x<<1)+3) - aa4*(y-1);
+ ox = x;
+ tt += bb4*(++x) - aa2*(((y--)<<1)-3);
+ this._mkArcDiv(ox, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
+ oy = y;
+ }
+ else // Advance y
+ {
+ tt -= aa2*((y<<1)-3);
+ st -= aa4*(--y);
+ if(y && (aBndA[y] != aBndA[y-1] || aBndZ[y] != aBndZ[y-1]))
+ {
+ this._mkArcDiv(x, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
+ ox = x;
+ oy = y;
+ }
+ }
+ }
+ this._mkArcDiv(x, 0, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
+ if(iOdds >> 16) // Odd height
+ {
+ if(iSects >> 16) // Start-angle > end-angle
+ {
+ var xl = (yEndA <= cy || yEndZ > cy)? (cx - x) : cx;
+ this._mkDiv(xl, cy, x + cx - xl + (iOdds & 0xffff), 1);
+ }
+ else if((iSects & 0x01) && yEndZ > cy)
+ this._mkDiv(cx - x, cy, x, 1);
+ }
+ };
+
+/* fillPolygon method, implemented by Matthieu Haller.
+This javascript function is an adaptation of the gdImageFilledPolygon for Walter Zorn lib.
+C source of GD 1.8.4 found at http://www.boutell.com/gd/
+
+THANKS to Kirsten Schulz for the polygon fixes!
+
+The intersection finding technique of this code could be improved
+by remembering the previous intertersection, and by using the slope.
+That could help to adjust intersections to produce a nice
+interior_extrema. */
+ this.fillPolygon = function(array_x, array_y)
+ {
+ var i;
+ var y;
+ var miny, maxy;
+ var x1, y1;
+ var x2, y2;
+ var ind1, ind2;
+ var ints;
+
+ var n = array_x.length;
+ if(!n) return;
+
+ miny = array_y[0];
+ maxy = array_y[0];
+ for(i = 1; i < n; i++)
+ {
+ if(array_y[i] < miny)
+ miny = array_y[i];
+
+ if(array_y[i] > maxy)
+ maxy = array_y[i];
+ }
+ for(y = miny; y <= maxy; y++)
+ {
+ var polyInts = new Array();
+ ints = 0;
+ for(i = 0; i < n; i++)
+ {
+ if(!i)
+ {
+ ind1 = n-1;
+ ind2 = 0;
+ }
+ else
+ {
+ ind1 = i-1;
+ ind2 = i;
+ }
+ y1 = array_y[ind1];
+ y2 = array_y[ind2];
+ if(y1 < y2)
+ {
+ x1 = array_x[ind1];
+ x2 = array_x[ind2];
+ }
+ else if(y1 > y2)
+ {
+ y2 = array_y[ind1];
+ y1 = array_y[ind2];
+ x2 = array_x[ind1];
+ x1 = array_x[ind2];
+ }
+ else continue;
+
+ // Modified 11. 2. 2004 Walter Zorn
+ if((y >= y1) && (y < y2))
+ polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
+
+ else if((y == maxy) && (y > y1) && (y <= y2))
+ polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
+ }
+ polyInts.sort(_CompInt);
+ for(i = 0; i < ints; i+=2)
+ this._mkDiv(polyInts[i], y, polyInts[i+1]-polyInts[i]+1, 1);
+ }
+ };
+
+ this.drawString = function(txt, x, y)
+ {
+ this.htm += '<div style="position:absolute;white-space:nowrap;'+
+ 'left:' + x + 'px;'+
+ 'top:' + y + 'px;'+
+ 'font-family:' + this.ftFam + ';'+
+ 'font-size:' + this.ftSz + ';'+
+ 'color:' + this.color + ';' + this.ftSty + '">'+
+ txt +
+ '<\/div>';
+ };
+
+/* drawStringRect() added by Rick Blommers.
+Allows to specify the size of the text rectangle and to align the
+text both horizontally (e.g. right) and vertically within that rectangle */
+ this.drawStringRect = function(txt, x, y, width, halign)
+ {
+ this.htm += '<div style="position:absolute;overflow:hidden;'+
+ 'left:' + x + 'px;'+
+ 'top:' + y + 'px;'+
+ 'width:'+width +'px;'+
+ 'text-align:'+halign+';'+
+ 'font-family:' + this.ftFam + ';'+
+ 'font-size:' + this.ftSz + ';'+
+ 'color:' + this.color + ';' + this.ftSty + '">'+
+ txt +
+ '<\/div>';
+ };
+
+ this.drawImage = function(imgSrc, x, y, w, h, a)
+ {
+ this.htm += '<div style="position:absolute;'+
+ 'left:' + x + 'px;'+
+ 'top:' + y + 'px;'+
+ 'width:' + w + 'px;'+
+ 'height:' + h + 'px;">'+
+ '<img src="' + imgSrc + '" width="' + w + '" height="' + h + '"' + (a? (' '+a) : '') + '>'+
+ '<\/div>';
+ };
+
+ this.clear = function()
+ {
+ this.htm = "";
+ if(this.cnv) this.cnv.innerHTML = "";
+ };
+
+ this._mkOvQds = function(cx, cy, x, y, w, h, wod, hod)
+ {
+ var xl = cx - x, xr = cx + x + wod - w, yt = cy - y, yb = cy + y + hod - h;
+ if(xr > xl+w)
+ {
+ this._mkDiv(xr, yt, w, h);
+ this._mkDiv(xr, yb, w, h);
+ }
+ else
+ w = xr - xl + w;
+ this._mkDiv(xl, yt, w, h);
+ this._mkDiv(xl, yb, w, h);
+ };
+
+ this._mkArcDiv = function(x, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects)
+ {
+ var xrDef = cx + x + (iOdds & 0xffff), y2, h = oy - y, xl, xr, w;
+
+ if(!h) h = 1;
+ x = cx - x;
+
+ if(iSects & 0xff0000) // Start-angle > end-angle
+ {
+ y2 = cy - y - h;
+ if(iSects & 0x00ff)
+ {
+ if(iSects & 0x02)
+ {
+ xl = Math.max(x, aBndZ[y]);
+ w = xrDef - xl;
+ if(w > 0) this._mkDiv(xl, y2, w, h);
+ }
+ if(iSects & 0x01)
+ {
+ xr = Math.min(xrDef, aBndA[y]);
+ w = xr - x;
+ if(w > 0) this._mkDiv(x, y2, w, h);
+ }
+ }
+ else
+ this._mkDiv(x, y2, xrDef - x, h);
+ y2 = cy + y + (iOdds >> 16);
+ if(iSects & 0xff00)
+ {
+ if(iSects & 0x0100)
+ {
+ xl = Math.max(x, aBndA[y]);
+ w = xrDef - xl;
+ if(w > 0) this._mkDiv(xl, y2, w, h);
+ }
+ if(iSects & 0x0200)
+ {
+ xr = Math.min(xrDef, aBndZ[y]);
+ w = xr - x;
+ if(w > 0) this._mkDiv(x, y2, w, h);
+ }
+ }
+ else
+ this._mkDiv(x, y2, xrDef - x, h);
+ }
+ else
+ {
+ if(iSects & 0x00ff)
+ {
+ if(iSects & 0x02)
+ xl = Math.max(x, aBndZ[y]);
+ else
+ xl = x;
+ if(iSects & 0x01)
+ xr = Math.min(xrDef, aBndA[y]);
+ else
+ xr = xrDef;
+ y2 = cy - y - h;
+ w = xr - xl;
+ if(w > 0) this._mkDiv(xl, y2, w, h);
+ }
+ if(iSects & 0xff00)
+ {
+ if(iSects & 0x0100)
+ xl = Math.max(x, aBndA[y]);
+ else
+ xl = x;
+ if(iSects & 0x0200)
+ xr = Math.min(xrDef, aBndZ[y]);
+ else
+ xr = xrDef;
+ y2 = cy + y + (iOdds >> 16);
+ w = xr - xl;
+ if(w > 0) this._mkDiv(xl, y2, w, h);
+ }
+ }
+ };
+
+ this.setStroke(1);
+ this.setFont("verdana,geneva,helvetica,sans-serif", "12px", Font.PLAIN);
+ this.color = "#000000";
+ this.htm = "";
+ this.wnd = wnd || window;
+
+ if(!jg_ok) _chkDHTM();
+ if(jg_ok)
+ {
+ if(cnv)
+ {
+ if(typeof(cnv) == "string")
+ this.cont = document.all? (this.wnd.document.all[cnv] || null)
+ : document.getElementById? (this.wnd.document.getElementById(cnv) || null)
+ : null;
+ else if(cnv == window.document)
+ this.cont = document.getElementsByTagName("body")[0];
+ // If cnv is a direct reference to a canvas DOM node
+ // (option suggested by Andreas Luleich)
+ else this.cont = cnv;
+ // Create new canvas inside container DIV. Thus the drawing and clearing
+ // methods won't interfere with the container's inner html.
+ // Solution suggested by Vladimir.
+ this.cnv = this.wnd.document.createElement("div");
+ this.cnv.style.fontSize=0;
+ this.cont.appendChild(this.cnv);
+ this.paint = jg_dom? _pntCnvDom : _pntCnvIe;
+ }
+ else
+ this.paint = _pntDoc;
+ }
+ else
+ this.paint = _pntN;
+
+ this.setPrintable(false);
+}
+
+function _mkLinVirt(aLin, x1, y1, x2, y2)
+{
+ var dx = Math.abs(x2-x1), dy = Math.abs(y2-y1),
+ x = x1, y = y1,
+ xIncr = (x1 > x2)? -1 : 1,
+ yIncr = (y1 > y2)? -1 : 1,
+ p,
+ i = 0;
+ if(dx >= dy)
+ {
+ var pr = dy<<1,
+ pru = pr - (dx<<1);
+ p = pr-dx;
+ while(dx > 0)
+ {--dx;
+ if(p > 0) // Increment y
+ {
+ aLin[i++] = x;
+ y += yIncr;
+ p += pru;
+ }
+ else p += pr;
+ x += xIncr;
+ }
+ }
+ else
+ {
+ var pr = dx<<1,
+ pru = pr - (dy<<1);
+ p = pr-dy;
+ while(dy > 0)
+ {--dy;
+ y += yIncr;
+ aLin[i++] = x;
+ if(p > 0) // Increment x
+ {
+ x += xIncr;
+ p += pru;
+ }
+ else p += pr;
+ }
+ }
+ for(var len = aLin.length, i = len-i; i;)
+ aLin[len-(i--)] = x;
+};
+
+function _CompInt(x, y)
+{
+ return(x - y);
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-12 03:59:52
|
Revision: 1867
http://cogkit.svn.sourceforge.net/cogkit/?rev=1867&view=rev
Author: jenvor
Date: 2008-01-11 19:59:51 -0800 (Fri, 11 Jan 2008)
Log Message:
-----------
Add help link and adjust the layout of UI
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/index.html
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-10 04:19:10 UTC (rev 1866)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-12 03:59:51 UTC (rev 1867)
@@ -29,6 +29,7 @@
activeTab: 0,
width:'100%',
height:'100%',
+ activeTab: 0,
//defaults:{autoScroll: true},
items:[
{ contentEl:'tab_wfsubmit',
@@ -44,7 +45,12 @@
}
},
{ contentEl:'tab_wfquery',
- title:'Status Query',
+ title:'Status Query'
+ },
+ {
+ contentEl: 'tab_help',
+ title:'Help',
+ height: 400
}
]
});
@@ -364,7 +370,11 @@
<body>
<div id="tabs">
- <div id="tab_wfsubmit">
+
+ <!--################## First Tab: Workflow submission ###################-->
+ <div id="tab_wfsubmit" class="x-hide-display">
+
+ <!-- Sample window -->
<div>
<span style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
@@ -380,27 +390,29 @@
</set>
<echo message="The date is {date}"/>
</project>
-</textarea></div>
+ </textarea></div>
</div>
+
+ <!-- Input area -->
<div>
<div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow description:</div>
<table>
<tr><td>
<textarea id='workflow' onblur='javascript:this.blur();' wrap='off' cols=100 rows=15 ></textarea>
<!-- <div id='workflowdiv'></div> -->
- <td><td valign=top>
- <div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='Regular echo' onclick='javascript:echo();'></input>
- </div>
- <div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='WS echo' onclick='javascript:wsecho();'></input>
- </div>
- <div style='padding-top:10px;padding-bottom:10px;display:none'>
- <input type='button' value='Workflow Handle' onclick='javascript:wfhandle();'></input>
- </div>
- <div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='WS Workflow Submission' onclick='javascript:wswfhandle();'></input>
- </div>
+ </td><td valign=top>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Regular echo' onclick='javascript:echo();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='WS echo' onclick='javascript:wsecho();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px;display:none'>
+ <input type='button' value='Workflow Handle' onclick='javascript:wfhandle();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='WS Workflow Submission' onclick='javascript:wswfhandle();'></input>
+ </div>
<!-- This two buttons are moved to another tab panel
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='Get State of All Workflows' onclick='javascript:stateRetrieve();'></input>
@@ -409,15 +421,18 @@
<input type='button' value='Get State of A Workflow' onclick='javascript:stateRetrieveAWF();'></input>
</div>
-->
- <div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='JSON2XML' onclick='javascript:zhguoj2x();'></input></div>
- <div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
- </div>
- </td></tr>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='JSON2XML' onclick='javascript:zhguoj2x();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
+ </div>
+ </td></tr>
</table>
</div>
- <div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
+
+ <!-- Resposne -->
+ <div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
<textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'></textarea>
@@ -429,12 +444,13 @@
</div>
</td></tr>
</table>
- </div>
+
<textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';" onkeypress='javascript:keypressed(event, "hiddenOutputArea");'></textarea>
<div id="prompt"></div>
- </div>
+ </div>
- <div id='tab_wfquery'>
+ <!--################## Second Tab: Workflow Query ###################-->
+ <div id='tab_wfquery' class="x-hide-display">
<div>
<div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow id input area:</div>
<table>
@@ -443,15 +459,16 @@
<!-- <div id='workflowdiv'></div> -->
<td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='Get State of All Workflows' onclick='javascript:stateRetrieve();'></input>
+ <input type='button' value='Get State of All Workflows' onclick='javascript:stateRetrieve();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='Get State of A Workflow' onclick='javascript:stateRetrieveAWF();'></input>
+ <input type='button' value='Get State of Workflows' onclick='javascript:stateRetrieveAWF();'></input>
</div>
</td></tr>
</table>
- </div>
+ </div>
+ <div>
<div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
@@ -465,6 +482,16 @@
</td></tr>
</table>
</div>
+ </div>
+
+ <!--################## Third Tab: Help Panel ###################-->
+ <div id='tab_help' class="x-hide-display">
+ <div>
+ <br>
+ This site(<a href="http://zhenhua-guo.blogspot.com/2008/01/tutorial.html">http://zhenhua-guo.blogspot.com/2008/01/tutorial.html</a>) contains a tutorial to show how to use the system.
+ </div>
</div>
+
+ </div>
</body>
</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-10 04:19:18
|
Revision: 1866
http://cogkit.svn.sourceforge.net/cogkit/?rev=1866&view=rev
Author: jenvor
Date: 2008-01-09 20:19:10 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
support to query status of more than one workflow in a single query request.
Modified Paths:
--------------
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
trunk/cyberaide/src/js/securelogin/cogkit/index.html
Modified: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2008-01-05 17:26:32 UTC (rev 1865)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2008-01-10 04:19:10 UTC (rev 1866)
@@ -186,8 +186,8 @@
StatusList sl = _db.getStatusByUID(uid);
String result = "{";
- if( sl == null){
- result = "No workflow found";
+ if( sl == null || sl.toJSON(strwfid).compareTo("[]") == 0 ){
+ result = "Workflow \"" + strwfid + "\" does not exist!";
}else{
result = "{";
result += "\""+TAGUID+"\":\""+struid+"\"";
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-05 17:26:32 UTC (rev 1865)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-10 04:19:10 UTC (rev 1866)
@@ -155,7 +155,7 @@
if ( exception != null )
alert( exception );
else {
- if( response == "No workflow found" ){
+ if( response.substr(0,8) == "Workflow" ){
output('statusresp', response);
}else{
var list = new StatusOfOneWF( response );
@@ -166,7 +166,13 @@
}
function stateRetrieveAWF(){
var wfid = getInput("workflowids");
- COGHandler.executeMethods("WSHandler.getStatusByUIDWFID", "test", wfid, stateRetrieveAWFCB);
+ var space = /\s+/;
+ var wfids = wfid.split(space);
+ space = /^\s*$/;
+ for( var i = 0 ; i < wfids.length ; i++ ){
+ if( wfids[i].match(space) )continue;
+ COGHandler.executeMethods("WSHandler.getStatusByUIDWFID", "test", wfids[i], stateRetrieveAWFCB);
+ }
}
/*
@@ -267,6 +273,24 @@
</script>
<script type="text/javascript">
+ /**
+ * If key 'esc' is pressed, the element corresponding to eleid is hidden.
+ */
+ function keypressed(e, eleid){
+ var evt = e;
+ var hiddenOutputId = eleid;
+ var hiddenele = document.getElementById(hiddenOutputId);
+ var ele = document.getElementById(eleid);
+
+ if( typeof( window.event ) != "undefined" ){//IE
+ evt = window.event;
+ }
+ var keycode = evt.keyCode;
+ if( keycode == 27 ){//key esc is pressed?
+ ele.style.display = 'none';//if so, hide it
+ }
+ }
+
/* When the output textarea is too small to display response from server,
* this function adjustes size of the textarea to contain more content.
* Note:
@@ -345,7 +369,7 @@
<span style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
<input type="button" value="click to see sample" onClick="javascript:diagShow(event);"/>
- <div><textarea rows=15 cols=100 wrap='off' id="wfsample" style="display:none;" onBlur="javascript:diagHide(event);">
+ <div><textarea rows=15 cols=100 wrap='off' id="wfsample" style="display:none;" onBlur="javascript:diagHide(event);" onkeypress='javascript:keypressed(event, "wfsample");'>
<project>
<include file="cogkit.xml"/>
<execute executable="/bin/rm" arguments="-f thedate" host="gf1.ucs.indiana.edu" provider="GT2" redirect="false"/>
@@ -362,7 +386,7 @@
<div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow description:</div>
<table>
<tr><td>
- <textarea id='workflow' wrap='off' cols=100 rows=15 ></textarea>
+ <textarea id='workflow' onblur='javascript:this.blur();' wrap='off' cols=100 rows=15 ></textarea>
<!-- <div id='workflowdiv'></div> -->
<td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
@@ -396,8 +420,7 @@
<div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
- <textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'>
- </textarea>
+ <textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'></textarea>
<td><td valign=top>
<input type='button' value='clear' onclick='javascript:clearoutput("resp");'></input>
@@ -407,7 +430,7 @@
</td></tr>
</table>
</div>
- <textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';"></textarea>
+ <textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';" onkeypress='javascript:keypressed(event, "hiddenOutputArea");'></textarea>
<div id="prompt"></div>
</div>
@@ -416,7 +439,7 @@
<div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow id input area:</div>
<table>
<tr><td>
- <textarea id='workflowids' wrap='off' cols=100 rows=10 ></textarea>
+ <textarea id='workflowids' onblur='javascript:this.blur();' onfocus='javascript:this.focus();' wrap='off' cols=100 rows=10 ></textarea>
<!-- <div id='workflowdiv'></div> -->
<td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
@@ -432,8 +455,7 @@
<div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
- <textarea WRAP='off' id='statusresp' cols=100 rows=20 readOnly='true'>
- </textarea>
+ <textarea WRAP='off' id='statusresp' cols=100 rows=20 readOnly='true'></textarea>
<td><td valign=top>
<input type='button' value='clear' onclick='javascript:clearoutput("statusresp");'></input>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-05 17:26:48
|
Revision: 1865
http://cogkit.svn.sourceforge.net/cogkit/?rev=1865&view=rev
Author: jenvor
Date: 2008-01-05 09:26:32 -0800 (Sat, 05 Jan 2008)
Log Message:
-----------
(1)add functionality that user can query status of a workflow based on the workflow id.;(2)modify user interface to separate submission panel and status query panel.(3)Modify the stuff returned after a workflow is submitted.;(4)Modify the location of configuration file.Modify the method by which configuration file is located(Absolute path -> relative path).
Modified Paths:
--------------
trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java
trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java
trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
trunk/cyberaide/src/js/securelogin/cogkit/handler.js
trunk/cyberaide/src/js/securelogin/cogkit/index.html
Added Paths:
-----------
trunk/cyberaide/src/js/securelogin/cogkit/wflist.js
Modified: trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java 2008-01-05 17:26:32 UTC (rev 1865)
@@ -47,40 +47,51 @@
import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.AddWorkflowFromString;
import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.GetJSONStatusByUID;
import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.GetJSONStatusByUIDResponse;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.GetJSONStatusByUIDWFID;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.GetJSONStatusByUIDWFIDResponse;
public class SimpleHandlerClient implements SimpleHandlerClientInterface{
private static String prefix = "(This is done by using Web service)\n";
//private static String propertiesFile = "/home/tomcat/apache-tomcat-6.0.14/webapps/webservice.properties";
- private static String propertiesFile = "/home/tomcat/apache-tomcat-6.0.14/webapps/agent.properties";
- private static String wsendpoint = "";
- private static StatusServiceNotifier _notifier = new StatusServiceNotifier();
- private static AgentWFDB _agentDb = null;
+ private static String agentConfigFile = "agent.properties";//"/home/tomcat/apache-tomcat-6.0.14/webapps/agent.properties";
+ private static String configFilename = "";
+ private static String executorEndpoint = "";
+ private static String statusserviceEndpoint = "";
+ private static StatusServiceNotifier _notifier = null;
+ private static AgentWFDB _agentDb = null;
private static SimpleHandlerInterfaceStub stub = null;
public SimpleHandlerClient(){
try{
+ configFilename = SimpleHandlerClient.class.getResource("/") + agentConfigFile;
+ configFilename = configFilename.substring(configFilename.indexOf(":")+1);
+
+ System.out.println("?" + configFilename + "?");
//open property file specified by propertiesFile
- File propfile = new File(propertiesFile);
+ File propfile = new File(configFilename);
if( propfile.exists() == false ){
- System.out.println("property file: "+propertiesFile+" does not exist!");
+ System.out.println("property file: "+configFilename+" does not exist!");
return ;
}
// get service end point
Properties prop = new Properties();
- prop.load( new FileInputStream( propertiesFile ) );
- String endpoint = prop.getProperty( "serviceendpoint" );
- if( endpoint == null ){
- System.out.println( "you must specify 'serviceendpoint' property in file service.properties" );
+ prop.load( new FileInputStream( propfile ) );
+ executorEndpoint = prop.getProperty( "executorservice.endpoint" );
+ statusserviceEndpoint = prop.getProperty( "statusservice.endpoint" );
+ if( executorEndpoint == null ){
+ System.out.println( "you must specify 'serviceendpoint' property in file " + configFilename );
}else{
- wsendpoint = endpoint;
- stub = new SimpleHandlerInterfaceStub(wsendpoint);
+ stub = new SimpleHandlerInterfaceStub(executorEndpoint);
}
if( _agentDb == null ){
String dbfile = prop.getProperty("agentdb");
_agentDb = new AgentWFDB(dbfile);
}
+ if( _notifier == null ){
+ _notifier = new StatusServiceNotifier( statusserviceEndpoint );
+ }
}catch( Exception e ){
System.out.println( e.toString() );
}
@@ -164,6 +175,11 @@
transformer.LoadFromString(workflow);
workflow = transformer.getNewWF();
+ String filename = "/tmp/workflow.xml";
+ File recordfile = new File(filename);
+ BufferedWriter br = new BufferedWriter(new FileWriter(recordfile));
+ br.write(workflow);
+ br.close();
//send this workflow to status server
_notifier.addWorkFlowFromString(username, wfid, oldWF);
@@ -184,6 +200,10 @@
public String getStatusByUID(String struid){
return _notifier.getStatusByUID(struid);
}
+
+ public String getStatusByUIDWFID(String struid, String wfid){
+ return _notifier.getStatusByUIDWFID(struid, wfid);
+ }
}
class WorkflowTransformer{
@@ -241,7 +261,7 @@
Element root = doc.getDocumentElement();
//transformSubTree(root, doc);
- transformSubTreeWithPath(root,doc,"");
+ transformSubTreeWithPath(root,doc,"/1", true);
/*
String newWF = "test.xml";
@@ -311,7 +331,7 @@
parent.appendChild(newChild);
}
- protected void transformSubTreeWithPath(Node root, Document doc, String path){
+ protected void transformSubTreeWithPath(Node root, Document doc, String path, boolean isRootNode ){
if(root.getChildNodes().getLength()==0)
return;
Node parent = root;
@@ -326,6 +346,17 @@
if( node.getNodeType() == Node.ELEMENT_NODE){
if( node.getNodeName().compareToIgnoreCase("include")==0){
childindex ++;
+ Element newChild = doc.createElement("echo");
+ echoMsg = path+"/"+childindex+"|job:include completed|2";
+ newChild.setAttribute("message", echoMsg);
+ Node nextSibling = node.getNextSibling();;
+ if( nextSibling != null ){
+ parent.insertBefore(newChild, nextSibling);
+ }else{
+ parent.appendChild( newChild );
+ break;
+ }
+ node = nextSibling;
continue;
}
childindex ++;
@@ -337,6 +368,14 @@
localpath = path+"/"+childindex;
if( isfirstChild ){
+ if( isRootNode ){
+ Element newChild = doc.createElement("echo");
+ echoMsg = "/1|project started|1";
+ newChild.setAttribute("message", echoMsg);
+ parent.insertBefore(newChild, node);
+ Node newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+ }
isfirstChild = false;
Element newChild = doc.createElement("echo");
echoMsg = localpath+"|job:"+nodename;
@@ -362,13 +401,22 @@
}
oldEchoMsg = echoMsg;
previousNode = nodename;
- transformSubTreeWithPath(node, doc, localpath);
+ transformSubTreeWithPath(node, doc, localpath, false);
}
}while( (node=node.getNextSibling())!=null);
Element newChild = doc.createElement("echo");
newChild.setAttribute("message", oldEchoMsg+" completed|2");
parent.appendChild(newChild);
+
+ if( isRootNode ){
+ newChild = doc.createElement("echo");
+ echoMsg = "/1|project completed|2";
+ newChild.setAttribute("message", echoMsg);
+ parent.appendChild(newChild);
+ Node newline = doc.createTextNode("\n");
+ parent.appendChild(newline);
+ }
}
}
@@ -376,9 +424,9 @@
private String _wsendpoint = "";
private StatusServiceInterfaceStub _stub = null;
- public StatusServiceNotifier(){
+ public StatusServiceNotifier(String statusserviceendp){
try{
- _wsendpoint = "http://156.56.104.196:8080/axis2/services/StatusServiceInterface";
+ _wsendpoint = statusserviceendp;//"http://156.56.104.196:8080/axis2/services/StatusServiceInterface";
_stub = new StatusServiceInterfaceStub(_wsendpoint);
} catch(Exception e){
System.out.println(e);
@@ -398,6 +446,20 @@
}
}
+ public String getStatusByUIDWFID(String struid, String wfid){
+ try{
+ if( _stub == null ) return "_stub is null";
+ GetJSONStatusByUIDWFID req = new GetJSONStatusByUIDWFID();
+ req.setParam0( struid );
+ req.setParam1( wfid );
+ GetJSONStatusByUIDWFIDResponse resp = new GetJSONStatusByUIDWFIDResponse();
+ resp = _stub.getJSONStatusByUIDWFID(req);
+ return resp.get_return();
+ }catch(Exception e){
+ return e.toString();
+ }
+ }
+
public void addWorkFlowFromString(String userid, String wfid, String workflow){
try{
if( _stub == null ) return ;
Modified: trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java 2008-01-05 17:26:32 UTC (rev 1865)
@@ -15,4 +15,7 @@
* Notice: the user who submits the workflow is identified by <b><i>uid</i></b>
*/
String WFSubmit(String uid, String workflow);
+
+ String getStatusByUID( String struid );
+ String getStatusByUIDWFID( String struid, String wfid );
}
Modified: trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java 2008-01-05 17:26:32 UTC (rev 1865)
@@ -37,23 +37,27 @@
import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub;
import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.*;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
+
/**
* SimpleHandlerInterfaceSkeleton java skeleton for the axisService
*/
public class SimpleHandlerInterfaceSkeleton implements SimpleHandlerInterfaceSkeletonInterface {
-
-/* private String _uid = "user1";
- private String _wfid = "file1";
- private String _workflow ="";
-*/
private static String _statusFilename = "/tmp/status.txt";
private static String _statusserviceendpoint = "";
- private static String _configFilename = "/home/tomcat/apache-tomcat-6.0.14/webapps/executor.properties";
+ private static String _executorConfigFile = "executor.properties";
+ private static String _configFilename = "";
private static StatusServiceClient _statusclient = null;
public SimpleHandlerInterfaceSkeleton(){
super();
try{
+ //Get the path of the configuration file. It should be under this directory:
+ // "${TOMCAT_ROOT}/webapps/axis2/WEB-INF/classes/".
+ _configFilename = SimpleHandlerInterfaceSkeleton.class.getResource("/") + _executorConfigFile;
+ _configFilename = _configFilename.substring(_configFilename.indexOf(":")+1);
+
//open property file specified by propertiesFile
File propfile = new File(_configFilename);
if( propfile.exists() == false ){
@@ -64,7 +68,7 @@
// get status service end point
Properties prop = new Properties();
prop.load( new FileInputStream( _configFilename ) );
- String endpoint = prop.getProperty( "statusserviceendpoint" );
+ String endpoint = prop.getProperty( "statusservice.endpoint" );
if( endpoint == null ){
System.out.println( "you must specify 'serviceendpoint' property in file service.properties" );
}else{
@@ -218,7 +222,7 @@
*/
private void getCertFromMyproxy(){//String host, int port, String user, String pwd, int lifetime){
try{
- String propertiesFile = "/home/tomcat/apache-tomcat-6.0.14/webapps/myproxy.properties";
+ String propertiesFile = _configFilename;
String host = "";
int port = -1;
String user = "";
@@ -227,11 +231,11 @@
Properties prop = new Properties();
prop.load( new FileInputStream(propertiesFile) );
- host = prop.getProperty("host");
- port = Integer.parseInt( prop.getProperty("port") );
- user = prop.getProperty("user");
- pwd = prop.getProperty("pwd");
- if( prop.getProperty("lifetime") != null ){
+ host = prop.getProperty("myproxy.host");
+ port = Integer.parseInt( prop.getProperty("myproxy.port") );
+ user = prop.getProperty("myproxy.user");
+ pwd = prop.getProperty("myproxy.pwd");
+ if( prop.getProperty("myproxy.lifetime") != null ){
lifetime = Integer.parseInt( prop.getProperty("lifetime") );
}
@@ -290,9 +294,9 @@
*/
public org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse cmdWFSubmit(
org.cogkit.cyberaide.axis2ws.CmdWFSubmit cmdWFSubmit0) {
- String uid = cmdWFSubmit0.getParam0();
- String wfid = cmdWFSubmit0.getParam1();
- String workflow = cmdWFSubmit0.getParam2();
+ final String uid = cmdWFSubmit0.getParam0();
+ final String wfid = cmdWFSubmit0.getParam1();
+ final String workflow = cmdWFSubmit0.getParam2();
/*
//internally, invoke cmdCogExecution
@@ -304,117 +308,121 @@
wfresp.set_return(resp.get_return());
*/
- Process wfproc = null;
- String output = "";
int exit = -1;
- try {
- //First, get the proxy certificate from the myproxy server
- getCertFromMyproxy();//"gf1.ucs.indiana.edu", 7512, "gerald", "....", 60*60*24*10);
+ new Thread( new Runnable(){
+ public void run(){
+ Process wfproc = null;
+ String output = "";
+ try{
+ //First, get the proxy certificate from the myproxy server
+ getCertFromMyproxy();//"gf1.ucs.indiana.edu", 7512, "gerald", "....", 60*60*24*10);
- //store the input(it is a workflow description actually) in a file
- String filename = "/tmp/workflow_WFSubmit.xml";
- File recordfile = new File(filename);
- BufferedWriter br = new BufferedWriter(new FileWriter(recordfile));
- br.write(workflow);
- br.close();
+ //store the input(it is a workflow description actually) in a file
+ String filename = "/tmp/workflow_WFSubmit.xml";
+ File recordfile = new File(filename);
+ BufferedWriter br = new BufferedWriter(new FileWriter(recordfile));
+ br.write(workflow);
+ br.close();
- //filename = "\"" + filename +"\"";
- //String cmd = "E:\\my_program\\cog-4_1_5\\bin\\cog-workflow.bat";// + filename;
- // get value of environment variable COG_INSTALL_PATH
- String cog_workflow = "";
- String getEnvVar = "printenv COG_INSTALL_PATH";
- String line = "";
+ //filename = "\"" + filename +"\"";
+ //String cmd = "E:\\my_program\\cog-4_1_5\\bin\\cog-workflow.bat";// + filename;
+ // get value of environment variable COG_INSTALL_PATH
+ String cog_workflow = "";
+ String getEnvVar = "printenv COG_INSTALL_PATH";
+ String line = "";
- wfproc = Runtime.getRuntime().exec(getEnvVar);
- BufferedReader input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
- while ((line = input.readLine()) != null) {
- cog_workflow += line;
- }
- input.close();
- wfproc.destroy();
- if( cog_workflow.equals("") ){
- throw new Exception("Environment variable COG_INSTALL_PATH is not set!!");
- }
+ wfproc = Runtime.getRuntime().exec(getEnvVar);
+ BufferedReader input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
+ while ((line = input.readLine()) != null) {
+ cog_workflow += line;
+ }
+ input.close();
+ wfproc.destroy();
+ if( cog_workflow.equals("") ){
+ throw new Exception("Environment variable COG_INSTALL_PATH is not set!!");
+ }
- wfproc = null;
- //call the cog command line tool to execute the workflow
- String cmd = cog_workflow+"/bin/cog-workflow";
- String []cmdarray = new String[2];
- cmdarray[0] = cmd; //command
- cmdarray[1] = filename;//argument
- long timeout = 1000 * 30;//30 seconds
- System.out.println("Execute a new command");
- wfproc = Runtime.getRuntime().exec(cmdarray);
+ wfproc = null;
+ //call the cog command line tool to execute the workflow
+ String cmd = cog_workflow+"/bin/cog-workflow";
+ String []cmdarray = new String[2];
+ cmdarray[0] = cmd; //command
+ cmdarray[1] = filename;//argument
+ long timeout = 1000 * 30;//30 seconds
+ System.out.println("Execute a new command");
+ wfproc = Runtime.getRuntime().exec(cmdarray);
- int statuscodeStarted = 1;
- int statuscodeCompleted = 2;
+ final int statuscodeStarted = 1;
+ final int statuscodeCompleted = 2;
- // notify status service that the workflow has started running
- _statusclient.notifyStatusOfWF(uid, wfid, statuscodeStarted, "workflow execution started");
+ // notify status service that the workflow has started running
+ _statusclient.notifyStatusOfWF(uid, wfid, statuscodeStarted, "workflow execution started");
- //get output from the executed tool
- line = "";
- input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
- boolean isfirstline = true;
- while ((line = input.readLine()) != null) {
- String msg = line;
- /**
- * Key point:
- * Every time a new message is generated during execution of workflow, the
- * message will be sent to status service based on web service.
- * First, we need to parse the generated message because it contains some
- * more information than pure message.
- * Note: this must correspond to the method used to transform the received
- * workflow by the agent server.
- *
- * Format:
- * Currently, the generated status message has the format like this:
- * /1/2/1/3|job:...|0
- * Note: /1/2/1/3 denotes path of the target element in the workflow.
- * The last number after '|' denotes status code. status code is
- * 0 in the example above. The meaning of status code MUST match the
- * definition in StatusService program!!
- * Our job is to extract this part.
- */
- int index = line.indexOf('|');
- if( index == -1 ){
- //this message is not status message, it is generated natively by
- //original workflow.
- }else{
- String path = line.substring(0, index);
- int endindex = line.lastIndexOf('|');
- String statuscodestr = line.substring(endindex+1);
- msg = msg.substring(index+1, endindex);
- int statuscode = Integer.parseInt(statuscodestr);
- _statusclient.notifyStatusOfElement(uid, wfid, path, statuscode, msg);
- }
+ //get output from the executed tool
+ input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
+ boolean isfirstline = true;
+ while ((line = input.readLine()) != null) {
+ String msg = line;
+ /**
+ * Key point:
+ * Every time a new message is generated during execution of workflow, the
+ * message will be sent to status service based on web service.
+ * First, we need to parse the generated message because it contains some
+ * more information than pure message.
+ * Note: this must correspond to the method used to transform the received
+ * workflow by the agent server.
+ *
+ * Format:
+ * Currently, the generated status message has the format like this:
+ * /1/2/1/3|job:...|0
+ * Note: /1/2/1/3 denotes path of the target element in the workflow.
+ * The last number after '|' denotes status code. status code is
+ * 0 in the example above. The meaning of status code MUST match the
+ * definition in StatusService program!!
+ * Our job is to extract this part.
+ */
+ int index = line.indexOf('|');
+ if( index == -1 ){
+ //this message is not status message, it is generated natively by
+ //original workflow.
+ }else{
+ String path = line.substring(0, index);
+ int endindex = line.lastIndexOf('|');
+ String statuscodestr = line.substring(endindex+1);
+ msg = msg.substring(index+1, endindex);
+ int statuscode = Integer.parseInt(statuscodestr);
+ _statusclient.notifyStatusOfElement(uid, wfid, path, statuscode, msg);
+ }
- if( isfirstline ){
- isfirstline = false;
- //output += "WFSubmit_Firstline:"+line;
- output += msg;
- }else{
- //output += "\nWFSubmit_Following line:"+line;
- output += "\n" + msg;
+ if( isfirstline ){
+ isfirstline = false;
+ //output += "WFSubmit_Firstline:"+line;
+ output += msg;
+ }else{
+ //output += "\nWFSubmit_Following line:"+line;
+ output += "\n" + msg;
+ }
+ }
+ input.close();
+
+ //notify status service that this workflow finishes executing
+ _statusclient.notifyStatusOfWF(uid, wfid, statuscodeCompleted, "workflow execution completed");
+
+ output = "succeeds!\nLog:\n"+output;
+ wfproc.destroy();
+ } catch (IllegalThreadStateException e) {
+ wfproc.destroy();
+ output = e.toString();
+ } catch (Exception e){
+ wfproc.destroy();
+ output = e.toString();
}
}
- input.close();
+ }).start();
- //notify status service that this workflow finishes executing
- _statusclient.notifyStatusOfWF(uid, wfid, statuscodeCompleted, "workflow execution completed");
-
- output = "succeeds!\nLog:\n"+output;
- wfproc.destroy();
- } catch (IllegalThreadStateException e) {
- wfproc.destroy();
- output = e.toString();
- } catch (Exception e){
- wfproc.destroy();
- output = e.toString();
- }
-
org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse wfresp = new org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse();
- wfresp.set_return( output );
+ // wfresp.set_return( output );
+ wfresp.set_return( "ID for the workflow you just submitted is:\n"+wfid+"\nYou can use it as a handle to check its status.");
return wfresp;
}
Modified: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java 2008-01-05 17:26:32 UTC (rev 1865)
@@ -29,6 +29,7 @@
*/
public String getJSONStatusByUID(String struid);
public String getXMLStatusByUID(String struid);
+ public String getJSONStatusByUIDWFID(String struid, String strwfid);
/**
* @deprecated
Modified: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2008-01-05 17:26:32 UTC (rev 1865)
@@ -176,6 +176,33 @@
}
}
+ public org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDWFIDResponse getJSONStatusByUIDWFID(
+ org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDWFID getJSONStatusByUIDWFID) {
+ try{
+ String struid = getJSONStatusByUIDWFID.getParam0();
+ String strwfid = getJSONStatusByUIDWFID.getParam1();
+
+ UID uid = new UIDUsername(struid);
+ StatusList sl = _db.getStatusByUID(uid);
+
+ String result = "{";
+ if( sl == null){
+ result = "No workflow found";
+ }else{
+ result = "{";
+ result += "\""+TAGUID+"\":\""+struid+"\"";
+ result += ",";
+ result += "\""+TAGWORKFLOWS+"\":";
+ result += sl.toJSON(strwfid);
+ result += "}";
+ }
+ org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDWFIDResponse resp = new org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDWFIDResponse();
+ resp.set_return(result);
+ return resp;
+ }catch(Exception e){
+ return null;
+ }
+ }
/**
* Auto generated method signature
* @param addWorkflowFromString5
@@ -654,6 +681,7 @@
/** contains list of nodes which are executed */
// private ArrayList<ITreeNode> _currentNodes = new ArrayList<ITreeNode>();
public KarajanTree(){
+ setRoot( new TreeNode() );
}
public void LoadFromFile(String filename) {
if(_isload)
@@ -684,7 +712,8 @@
}
}
protected void buildTree(ElementTree eletree){
- setRoot( addSubTree(eletree.getRoot()));
+ //setRoot( addSubTree(eletree.getRoot()) );
+ getRoot().addChild( addSubTree(eletree.getRoot()) );
// _currentNodes.add(getRoot());
}
private ITreeNode addSubTree(FlowElement fe){
@@ -709,7 +738,11 @@
return fullname;
}
public String toJSON(){
- return toJSON(getRoot());
+ String result = "";
+ for( int i = 0 ; i < getRoot().getChildren().length ; i ++ ){
+ result += toJSON(getRoot().getChildren()[i]);
+ }
+ return result;
}
private String toJSON(ITreeNode node){
if( node == null )
@@ -858,7 +891,26 @@
result += "]";
return result;
}
+
/**
+ * serialize status of a workflow into JSON format
+ */
+ public String toJSON( String wfid ){
+ Iterator it = _statuslist.iterator();
+ String result = "[";
+ WorkflowStatus wfs = null;
+ while(it.hasNext()){
+ wfs = (WorkflowStatus)it.next();
+ if( wfs.getWfid().compareTo(wfid) == 0 ){
+ result += wfs.toJSON();
+ break;
+ }
+ }
+ result += "]";
+ return result;
+ }
+
+ /**
* serialize status into XML format.
*/
public String toXML(){
Modified: trunk/cyberaide/src/js/securelogin/cogkit/handler.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/handler.js 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/js/securelogin/cogkit/handler.js 2008-01-05 17:26:32 UTC (rev 1865)
@@ -8,6 +8,7 @@
else
COGHandler = PlainCOGHandler;
+
function Handler( serviceurl ){
try{
this.url = serviceurl;
@@ -31,7 +32,8 @@
}
var callstr = "service."+methodname+"(";
- for( var i = 0; i < nargs; i++ ){//get and escape the arguments
+ var i = 0;
+ for( i = 0; i < nargs; i++ ){//get and escape the arguments
if( i > 0 ) callstr += ",";
if( typeof arguments[i+1] == "string" ){
var str = arguments[i+1];
@@ -46,8 +48,11 @@
if( cbfunc == null ){
callstr += ")";
}else{
- timer=setTimeout("alert('Timeout.');",20000);//10 seconds timeout
- callstr += ", " + cbfunc + ");";
+ //timer=setTimeout("alert('Time out');",30000);//30 seconds timeout
+ if( nargs > 0)
+ callstr += ", " + cbfunc + ");";
+ else
+ callstr += cbfunc + ");";
}
var rslt = eval( callstr );
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-05 02:43:28 UTC (rev 1864)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2008-01-05 17:26:32 UTC (rev 1865)
@@ -21,9 +21,33 @@
/* This piece of code adds visual widgets to ease workflow composition*/
Ext.onReady(function(){
//createBasicDesktop('workflowdiv');
- createWidgetToolbox();
+ var widgettoolbox = createWidgetToolbox();
promptwin.render('prompt');
promptwin.hide();
+ new Ext.TabPanel({
+ renderTo: 'tabs',
+ activeTab: 0,
+ width:'100%',
+ height:'100%',
+ //defaults:{autoScroll: true},
+ items:[
+ { contentEl:'tab_wfsubmit',
+ title:'Workflow Submit',
+ listeners: {
+ deactivate: function(){
+ widgettoolbox.hide();
+ },
+ activate: function(){
+ widgettoolbox.show();
+ widgettoolbox.collapse( false );
+ }
+ }
+ },
+ { contentEl:'tab_wfquery',
+ title:'Status Query',
+ }
+ ]
+ });
});
</script>
@@ -115,11 +139,11 @@
alert( exception );
else {
if( response == "No workflow found" ){
- output('resp', response);
+ output('statusresp', response);
}else{
var list = new WFList( response );
var str = list.format();
- output('resp', str);
+ output('statusresp', str);
}
}
}
@@ -127,6 +151,24 @@
COGHandler.executeMethods("WSHandler.getStatusByUID", "test", stateRetrieveCB);
}
+ function stateRetrieveAWFCB(response, exception){
+ if ( exception != null )
+ alert( exception );
+ else {
+ if( response == "No workflow found" ){
+ output('statusresp', response);
+ }else{
+ var list = new StatusOfOneWF( response );
+ var str = list.format();
+ output('statusresp', str);
+ }
+ }
+ }
+ function stateRetrieveAWF(){
+ var wfid = getInput("workflowids");
+ COGHandler.executeMethods("WSHandler.getStatusByUIDWFID", "test", wfid, stateRetrieveAWFCB);
+ }
+
/*
function wswfhandlewithstatus(){
var workflow = getInput("workflow");
@@ -139,8 +181,8 @@
}
*/
- function clearoutput(){
- var output = document.getElementById( 'resp' );
+ function clearoutput(eleid){
+ var output = document.getElementById( eleid );
output.value = "";
}
@@ -230,11 +272,11 @@
* Note:
* Currently, only IE and Firefox are supported.
*/
- function adjustTextArea(e){
+ function adjustTextArea(e, eleid){
var evt = e, xcord, ycord, rows;
var hiddenOutputId = "hiddenOutputArea";
var hiddenele = document.getElementById(hiddenOutputId);
- var ele = document.getElementById('resp');
+ var ele = document.getElementById(eleid);
var clientwidth = document.body.clientWidth;
var clientheight = document.body.clientHeight;
var leftMargin = 50, topMargin = 50;
@@ -297,6 +339,8 @@
</head>
<body>
+ <div id="tabs">
+ <div id="tab_wfsubmit">
<div>
<span style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
@@ -333,10 +377,15 @@
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='WS Workflow Submission' onclick='javascript:wswfhandle();'></input>
</div>
+ <!-- This two buttons are moved to another tab panel
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='Get State of All Workflows' onclick='javascript:stateRetrieve();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Get State of A Workflow' onclick='javascript:stateRetrieveAWF();'></input>
+ </div>
+ -->
+ <div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='JSON2XML' onclick='javascript:zhguoj2x();'></input></div>
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
@@ -344,22 +393,56 @@
</td></tr>
</table>
</div>
- <br>
- <div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Response from server:</div>
+ <div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
<table>
<tr><td>
<textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'>
</textarea>
<td><td valign=top>
- <input type='button' value='clear' onclick='javascript:clearoutput();'></input>
+ <input type='button' value='clear' onclick='javascript:clearoutput("resp");'></input>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='magnify' onclick='javascript:adjustTextArea(event);'></input>
+ <input type='button' value='magnify' onclick='javascript:adjustTextArea(event, "resp");'></input>
</div>
</td></tr>
</table>
</div>
<textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';"></textarea>
<div id="prompt"></div>
+ </div>
+
+ <div id='tab_wfquery'>
+ <div>
+ <div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow id input area:</div>
+ <table>
+ <tr><td>
+ <textarea id='workflowids' wrap='off' cols=100 rows=10 ></textarea>
+ <!-- <div id='workflowdiv'></div> -->
+ <td><td valign=top>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Get State of All Workflows' onclick='javascript:stateRetrieve();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Get State of A Workflow' onclick='javascript:stateRetrieveAWF();'></input>
+ </div>
+ </td></tr>
+ </table>
+ </div>
+
+ <div style='font-size:large; padding-top:0.2em; padding-bottom:0.1em; color:blue;'>Response from server:</div>
+ <table>
+ <tr><td>
+ <textarea WRAP='off' id='statusresp' cols=100 rows=20 readOnly='true'>
+ </textarea>
+ <td><td valign=top>
+ <input type='button' value='clear' onclick='javascript:clearoutput("statusresp");'></input>
+
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='magnify' onclick='javascript:adjustTextArea(event, "statusresp");'></input>
+ </div>
+ </td></tr>
+ </table>
+ </div>
+ </div>
</body>
</html>
Added: trunk/cyberaide/src/js/securelogin/cogkit/wflist.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/wflist.js (rev 0)
+++ trunk/cyberaide/src/js/securelogin/cogkit/wflist.js 2008-01-05 17:26:32 UTC (rev 1865)
@@ -0,0 +1,90 @@
+/**
+*/
+function WFList( wflist ){
+ var obj = eval('('+wflist+')');
+ this.username = obj.uid;
+ this.workflows = obj.workflows;
+ this.format = function(){
+ var output = "", nwfs = 0, indentunit = " ";
+ output += "user id: "+this.username;
+ output += "\n";
+ nwfs = this.workflows.length;
+ output += "# of workflow submitted: " + nwfs;
+ output += "\n";
+ for( var i = 0 ; i < nwfs ; i ++ ){
+ output += "workflow "+(i+1);
+ output += "\n";
+ var wf = this.workflows[i];
+ output += indentunit + "workflow id:" + wf.wfid;
+ output += "\n";
+ output += indentunit + "workflow status:" + wf.status;
+ output += "\n";
+ var project = wf.elements[0];
+ output += this.formatAWF( project, 2, indentunit );
+ }
+ return output;
+ }
+
+ this.formatAWF = function(wf,depth, indentunit){
+ var indent = "";
+ for( var i = 0 ; i < depth ; i ++ )
+ indent += indentunit;
+
+ var output = "";
+ output += indent + "subtask:";
+ output += wf.name+"; ";
+ output += "status:";
+ output += wf.status+"; ";
+ output += "\n";
+ var children = wf.children;
+ for( var i = 0 ; i < children.length ; i ++ ){
+ output += this.formatAWF(children[i], depth+1, indentunit);
+ }
+ return output;
+ }
+}
+
+function StatusOfOneWF( wflist ){
+ var obj = eval('('+wflist+')');
+ this.username = obj.uid;
+ this.workflows = obj.workflows;
+ this.format = function(){
+ var output = "", nwfs = 0, indentunit = " ";
+ output += "user id: "+this.username;
+ output += "\n";
+ nwfs = this.workflows.length;
+ if( nwfs == 0 ){
+ output += "no corresponding workflow.\n";
+ return output;
+ }
+ if( nwfs != 1 ){
+ output += "System error! More than one workflow is returned";
+ return output;
+ }
+ var wf = this.workflows[0];
+ output += indentunit + "workflow id:" + wf.wfid;
+ output += "\n";
+ output += indentunit + "workflow status:" + wf.status;
+ output += "\n";
+ var project = wf.elements[0];
+ output += this.formatAWF( project, 2, indentunit );
+ return output;
+ }
+ this.formatAWF = function(wf,depth, indentunit){
+ var indent = "";
+ for( var i = 0 ; i < depth ; i ++ )
+ indent += indentunit;
+
+ var output = "";
+ output += indent + "subtask:";
+ output += wf.name+"; ";
+ output += "status:";
+ output += wf.status+"; ";
+ output += "\n";
+ var children = wf.children;
+ for( var i = 0 ; i < children.length ; i ++ ){
+ output += this.formatAWF(children[i], depth+1, indentunit);
+ }
+ return output;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-01-05 02:43:29
|
Revision: 1864
http://cogkit.svn.sourceforge.net/cogkit/?rev=1864&view=rev
Author: hategan
Date: 2008-01-04 18:43:28 -0800 (Fri, 04 Jan 2008)
Log Message:
-----------
absence of a scheduler doesn't mean we can rely on preemptive threading
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java 2008-01-05 02:42:00 UTC (rev 1863)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/grid/AbstractGridNode.java 2008-01-05 02:43:28 UTC (rev 1864)
@@ -31,6 +31,7 @@
import org.globus.cog.abstraction.interfaces.TaskHandler;
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.scheduler.Scheduler;
+import org.globus.cog.karajan.scheduler.submitQueue.NonBlockingSubmit;
import org.globus.cog.karajan.stack.VariableNotFoundException;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.util.BoundContact;
@@ -197,7 +198,7 @@
tasks.put(task, stack);
}
try {
- handler.submit(task);
+ new NonBlockingSubmit(handler, task, null).go();
}
catch (Exception e) {
// avoid failing twice if status is already set
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-01-05 02:42:03
|
Revision: 1863
http://cogkit.svn.sourceforge.net/cogkit/?rev=1863&view=rev
Author: hategan
Date: 2008-01-04 18:42:00 -0800 (Fri, 04 Jan 2008)
Log Message:
-----------
async aborting
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/util/StateManager.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/util/StateManager.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/util/StateManager.java 2008-01-03 22:44:29 UTC (rev 1862)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/util/StateManager.java 2008-01-05 02:42:00 UTC (rev 1863)
@@ -104,7 +104,7 @@
if (te.getThread().isSubContext(context)) {
VariableStack stack = (VariableStack) executing.get(te);
if (stack != null) {
- EventBus.sendHooked(te.getElement(), new AbortEvent(null, context, stack.copy()));
+ EventBus.post(te.getElement(), new AbortEvent(null, context, stack.copy()));
synchronized(this) {
executing.remove(te);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2008-01-03 22:44:38
|
Revision: 1862
http://cogkit.svn.sourceforge.net/cogkit/?rev=1862&view=rev
Author: jenvor
Date: 2008-01-03 14:44:29 -0800 (Thu, 03 Jan 2008)
Log Message:
-----------
write a install script which can ease installation of the system
Added Paths:
-----------
trunk/cyberaide/src/axis2/INSTALL
trunk/cyberaide/src/axis2/scripts/install.sh
Added: trunk/cyberaide/src/axis2/INSTALL
===================================================================
--- trunk/cyberaide/src/axis2/INSTALL (rev 0)
+++ trunk/cyberaide/src/axis2/INSTALL 2008-01-03 22:44:29 UTC (rev 1862)
@@ -0,0 +1,63 @@
+How to install the whole CoGkit Javascript system
+
+Steps:
+(1) You should check out the install.sh which should be executed in bash.
+(2) Then run the script.
+After you run the script, three files should be generated:
+* SimpleHandlerInterface.aar
+* StatusServiceInterface.aar
+* SimpleHandlerInterface-test-client.jar
+
+SimpleHandlerInterface.aar
+ This is the package which provides executor service in our system.
+
+StatusServiceInterface.aar
+ This is the package which provides status service.
+
+SimpleHandlerInterface-test-client.jar
+ This is the package which provides agent service.
+
+Before further going on, you should have following requirements satisfied:
+(1) You should have a servlet/JSP container.
+ Currently, my system is only tested on Apache Tomcat.
+(2) Axis2 is deployed correctly in the container.
+(3) Apache Xmlrpc is correctly deployed in the container.
+
+Now, you are ready to deploy our system.
+(1) deploy SimpleHandlerInterface.arr into Axis2 at the machine which will
+ host executor service.
+
+ (1.1) You must create and edit the configuration file: executor.properties.
+ This file contains the address of the status service.
+ Typically, the content looks like this:
+ statusserviceendpoint=http://ip:port/axis2/services/StatusServiceInterface
+ (1.2) You must create and edit the configuration file: myproxy.properties.
+ This file contains the address and user account of a MyProxy server.
+ Typically, the content looks like this:
+ host=gf1.ucs.indiana.edu
+ port=7512
+ user=username
+ pwd=password
+
+(2) deploy StatusServiceInterface.aar into Axis2 at the machine which will
+ host status service.
+
+(3) Checkout all files and directories from:
+ http://cogkit.svn.sourceforge.net/svnroot/cogkit/trunk/cyberaide/src/js/securelogin
+ These files provide web-based interface for end users to submit workflows
+ and query status of workflows.
+ These files should be checked out into your Xmlrpc application directory at the
+ machine which will host the agent service.
+
+ Deploy SimpleHandlerInterface-test-client.jar. You should consult manual of Xmlrpc to see
+ exactly whether the .jar files should be positioned.
+ Xmlrpc must be configured correctly.
+
+ You must create and edit the configuration file: agent.properties.
+ This file contains address of executor service.
+ The content looks like this:
+ serviceendpoint=http://156.56.104.196:8080/axis2/services/SimpleHandlerInterface
+ agentdb=/tmp/agentdb.txt
+
+ Now address of the status service is hard-coded in the source code of agent service.
+ This will be modified later.
Added: trunk/cyberaide/src/axis2/scripts/install.sh
===================================================================
--- trunk/cyberaide/src/axis2/scripts/install.sh (rev 0)
+++ trunk/cyberaide/src/axis2/scripts/install.sh 2008-01-03 22:44:29 UTC (rev 1862)
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+############################################################################
+# This script is used to install the Web-based CoGKit.
+############################################################################
+#First get the source code from svn repository
+svn checkout http://cogkit.svn.sourceforge.net/svnroot/cogkit/trunk/cyberaide/src/axis2 cyberaide/src/axis2 > /dev/null
+
+basedir='cyberaide/src/axis2'
+cwd=`pwd`
+
+#this dir should contain the agent server related files
+clientsrcdir=${basedir}/axis2ws_client
+#interface file
+agentServicei='SimpleHandlerClientInterface.java'
+#implementation
+agentService='SimpleHandlerClient.java'
+
+#this dir should contain executor and state server related files
+serversrcdir=${basedir}/axis2ws_server
+#status service interface
+statusservicei='StatusServiceInterface.java'
+#Status service implementation
+statusservice='StatusServiceInterfaceSkeleton.java'
+#executor service interface
+executorservicei='SimpleHandlerInterface.java'
+#executor implementation
+executorservice='SimpleHandlerInterfaceSkeleton.java'
+
+#temporary directory where the compilation and building work of status service is done.
+statusservicedir='statusservice'
+executorservicedir='executor'
+
+#name of the makefile which will be used to build various service.
+makefile='makefile'
+#directory which contains bash scripts needed by the makefile
+scriptdir=${cwd}/${basedir}/scripts
+
+#package name of all these files
+packagename='org.cogkit.cyberaide.axis2ws'
+packagepath=`echo ${packagename//.//}`
+
+
+if [ ! -d ${serversrcdir} ]; then
+ echo "Directory ${serversrcdir} can not be found"
+ exit 1
+fi
+
+oldpwd1=`pwd`
+
+############################################################
+#
+# Build state service
+#
+############################################################
+cd ${serversrcdir}
+#create a new directory which will contain statu service related files
+mkdir ${statusservicedir}
+
+oldpwd2=`pwd`
+#copy files StatusServiceInterface.java and makefile to the new created directory.
+cp ${statusservicei} ${statusservicedir}/
+cp ${scriptdir}/${makefile} ${statusservicedir}/
+
+#build client and server stub
+cd ${statusservicedir}
+make csfromjava scriptdir=${scriptdir} java=${statusservicei}
+cd ${oldpwd2}
+
+#copy the server side skeleton file "StatusServiceInterfaceSkeleton.java" to the
+#corresponding path
+path=${statusservicedir}/server/src/${packagepath}
+cp ${statusservice} ${path}/
+
+#build final package (a .arr file for server side and a .jar file for client side)
+cd ${statusservicedir}
+make serverbuild scriptdir=${scriptdir}
+cd ${oldpwd2}
+
+aar=`echo ${statusservicei//.java/.aar}`
+cp ${statusservicedir}/${aar} ${oldpwd1}/
+
+############################################################
+#
+# Build executor service
+#
+############################################################
+mkdir ${executorservicedir}
+
+cp ${executorservicei} ${executorservicedir}/
+cp ${scriptdir}/${makefile} ${executorservicedir}/
+
+cd ${executorservicedir}
+make csfromjava scriptdir=${scriptdir} java=${executorservicei}
+cd ${oldpwd2}
+
+#copy the server side skeleton file "SimpleHandlerInterfaceSkeleton.java" to the
+#corresponding path
+exeserverpath=${executorservicedir}/server/src/${packagepath}
+cp ${executorservice} ${exeserverpath}/
+
+#copy client side stub file of Status service to server side of executor service
+staclientpath=${statusservicedir}/client/src/${packagepath}
+clientstub=`echo ${statusservicei//.java/Stub.java}`
+clientstub=${staclientpath}/${clientstub}
+cp ${clientstub} ${exeserverpath}/
+
+#build final package (a .arr file for server side and a .jar file for client side)
+cd ${executorservicedir}
+make serverbuild scriptdir=${scriptdir}
+cd ${oldpwd2}
+
+aar=`echo ${executorservicei//.java/.aar}`
+cp ${executorservicedir}/${aar} ${oldpwd1}/
+
+
+############################################################
+#
+# Build agent server
+#
+############################################################
+#copy client side stub file of Status service, interface of agent service and implementation
+#of agent service to client side of executor service
+execlientpath=${executorservicedir}/client/src/${packagepath}
+cp ${clientstub} ${execlientpath}/
+cd ${oldpwd1}
+cp ${clientsrcdir}/${agentService} ${serversrcdir}/${execlientpath}/
+cp ${clientsrcdir}/${agentServicei} ${serversrcdir}/${execlientpath}/
+cd ${oldpwd2}
+
+#build final package (a .jar file for client side)
+cd ${executorservicedir}
+make clientbuild scriptdir=${scriptdir}
+cd ${oldpwd2}
+
+cp ${executorservicedir}/client/build/lib/*.jar ${oldpwd1}/
+
+############################################################
+#
+# Clear
+#
+############################################################
+#rm -rf ${statusservicedir}
+#rm -rf ${executorservicedir}
+
+cd ${oldpwd1}
+
+cat<<EOF
+Now, you have successfully built the agent server, executor service and state service.
+(*) The files corresponding to txecutor service and state service are .aar files and you should
+deploy these files to Axis2 which is typically run in Apache Tomcat. The typical path is
+"${TOMCAT_ROOT}/webapps/axis2/WEB_INF/services".
+(**) The file corresponding to the agent service is a .jar file and you can deploy it in Tomcat
+directly. But, Apache Xmlrpc is used and you should consult the manual of Apache Xmlrpc to
+deploy it correctly. The typical path is "${TOMCAT_ROOT}/webapps/your_service_dir/WEB_INF/classes/".
+EOF
+
+rm -rf cyberaide
Property changes on: trunk/cyberaide/src/axis2/scripts/install.sh
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-30 03:19:23
|
Revision: 1861
http://cogkit.svn.sourceforge.net/cogkit/?rev=1861&view=rev
Author: jenvor
Date: 2007-12-29 19:19:22 -0800 (Sat, 29 Dec 2007)
Log Message:
-----------
some small changes(remove debug statements...)
Modified Paths:
--------------
trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
Modified: trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java 2007-12-30 00:29:27 UTC (rev 1860)
+++ trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java 2007-12-30 03:19:22 UTC (rev 1861)
@@ -186,7 +186,7 @@
statusbw.close();
//exit = wfproc.exitValue();
//output = Integer.toString( exit );
- output = "succeeds!\n"+output;
+ output = "succeeds!\nLog:\n"+output;
wfproc.destroy();
} catch (IllegalThreadStateException e) {
wfproc.destroy();
@@ -357,12 +357,7 @@
input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
boolean isfirstline = true;
while ((line = input.readLine()) != null) {
- if( isfirstline ){
- isfirstline = false;
- output += "WFSubmit_Firstline:"+line;
- }else{
- output += "\nWFSubmit_Following line:"+line;
- }
+ String msg = line;
/**
* Key point:
* Every time a new message is generated during execution of workflow, the
@@ -385,23 +380,30 @@
if( index == -1 ){
//this message is not status message, it is generated natively by
//original workflow.
- continue;
}else{
String path = line.substring(0, index);
- String msg = line.substring(index+1);
- int endindex = msg.lastIndexOf('|');
- String statuscodestr = msg.substring(endindex+1);
+ int endindex = line.lastIndexOf('|');
+ String statuscodestr = line.substring(endindex+1);
msg = msg.substring(index+1, endindex);
int statuscode = Integer.parseInt(statuscodestr);
_statusclient.notifyStatusOfElement(uid, wfid, path, statuscode, msg);
}
+
+ if( isfirstline ){
+ isfirstline = false;
+ //output += "WFSubmit_Firstline:"+line;
+ output += msg;
+ }else{
+ //output += "\nWFSubmit_Following line:"+line;
+ output += "\n" + msg;
+ }
}
input.close();
//notify status service that this workflow finishes executing
_statusclient.notifyStatusOfWF(uid, wfid, statuscodeCompleted, "workflow execution completed");
- output = "succeeds!\n"+output;
+ output = "succeeds!\nLog:\n"+output;
wfproc.destroy();
} catch (IllegalThreadStateException e) {
wfproc.destroy();
Modified: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2007-12-30 00:29:27 UTC (rev 1860)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2007-12-30 03:19:22 UTC (rev 1861)
@@ -127,14 +127,9 @@
int statuscode = modifyStatusOfWholeWF7.getParam2();
String statusmsg = modifyStatusOfWholeWF7.getParam3();
- writeLog("modifyStatusOfWholeWF:"+struid+":"+wfid+":"+statuscode+":"+statusmsg+"\n");
-
UID uid = new UIDUsername(struid);
if( false == _db.setStatusOfWF(uid, wfid, statuscode, statusmsg) )
_msgcache.insertMsg(struid, wfid, Msg.MSGWHOLEWF, "", statuscode, statusmsg );
-
- String json = _db.getStatusByUID(uid).toJSON();
- writeLog(json+"\n");
}
/**
* Auto generated method signature
@@ -159,12 +154,6 @@
try{
String struid = getJSONStatusByUID3.getParam0();
- File file = new File("/tmp/json_request.txt");
- file.createNewFile();
- BufferedWriter bw = new BufferedWriter( new FileWriter(file) );
- bw.write("user:"+struid);
- bw.close();
-
UID uid = new UIDUsername(struid);
StatusList sl = _db.getStatusByUID(uid);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-30 00:29:32
|
Revision: 1860
http://cogkit.svn.sourceforge.net/cogkit/?rev=1860&view=rev
Author: jenvor
Date: 2007-12-29 16:29:27 -0800 (Sat, 29 Dec 2007)
Log Message:
-----------
replace an interface file with another one
Added Paths:
-----------
trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java
Removed Paths:
-------------
trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java
Added: trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java (rev 0)
+++ trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClientInterface.java 2007-12-30 00:29:27 UTC (rev 1860)
@@ -0,0 +1,18 @@
+/**
+ * @version $Id v0.2$
+ * This is a simple interface definition which is used to generate WSDL document
+ * by using java2wsdl tool provided by Axis2.
+ */
+//package org.cogkit.cyberaide.axis2ws;
+
+package org.cogkit.cyberaide.axis2ws;
+
+interface SimpleHandlerClientInterface{
+ String echo( String input );
+ String cmdCOGExecute( String workflow );
+ /**
+ * This method acceptes submission of workflow from end user.
+ * Notice: the user who submits the workflow is identified by <b><i>uid</i></b>
+ */
+ String WFSubmit(String uid, String workflow);
+}
Deleted: trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java 2007-12-28 20:16:04 UTC (rev 1859)
+++ trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java 2007-12-30 00:29:27 UTC (rev 1860)
@@ -1,18 +0,0 @@
-/**
- * @version $Id v0.2$
- * This is a simple interface definition which is used to generate WSDL document
- * by using java2wsdl tool provided by Axis2.
- */
-package org.cogkit.cyberaide.axis2ws;
-
-interface SimpleHandlerInterface{
- String echo( String input );
- String cmdCOGExecute( String workflow );
- /**
- * This method submits a workflow to CogKit.
- * Notice: the user who submits the workflow is identified by <b><i>uid</i></b>
- * the workflow is uniquely identified by wfid so that different workflows
- * submitted by the same user can be distinguished.
- */
- String cmdWFSubmit(String uid, String wfid, String workflow);
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-12-28 20:16:38
|
Revision: 1859
http://cogkit.svn.sourceforge.net/cogkit/?rev=1859&view=rev
Author: hategan
Date: 2007-12-28 12:16:04 -0800 (Fri, 28 Dec 2007)
Log Message:
-----------
fixed empty args
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-ssh/CHANGES.txt
trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/JobSubmissionTaskHandler.java
Modified: trunk/current/src/cog/modules/provider-ssh/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-ssh/CHANGES.txt 2007-12-28 20:15:16 UTC (rev 1858)
+++ trunk/current/src/cog/modules/provider-ssh/CHANGES.txt 2007-12-28 20:16:04 UTC (rev 1859)
@@ -1,3 +1,7 @@
+(12/28/2007)
+
+*** Fixed passing of empty arguments
+
(11/23/2007)
*** Added connection caching and use of SSH channels, and their management
Modified: trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/JobSubmissionTaskHandler.java
===================================================================
--- trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/JobSubmissionTaskHandler.java 2007-12-28 20:15:16 UTC (rev 1858)
+++ trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/execution/JobSubmissionTaskHandler.java 2007-12-28 20:16:04 UTC (rev 1859)
@@ -166,6 +166,9 @@
}
private void append(StringBuffer sb, String str) {
+ if (str.length() == 0) {
+ sb.append("\"\"");
+ }
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c < 256 && c > 0 && ESCAPE[c]) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-12-28 20:15:25
|
Revision: 1858
http://cogkit.svn.sourceforge.net/cogkit/?rev=1858&view=rev
Author: hategan
Date: 2007-12-28 12:15:16 -0800 (Fri, 28 Dec 2007)
Log Message:
-----------
fixed some bad error reporting
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/file/FileResourceImpl.java
Modified: trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/file/FileResourceImpl.java
===================================================================
--- trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/file/FileResourceImpl.java 2007-12-28 00:24:14 UTC (rev 1857)
+++ trunk/current/src/cog/modules/provider-ssh/src/org/globus/cog/abstraction/impl/ssh/file/FileResourceImpl.java 2007-12-28 20:15:16 UTC (rev 1858)
@@ -72,12 +72,12 @@
public void start() throws InvalidSecurityContextException,
FileResourceException {
+ String host = getServiceContact().getHost();
+ int port = getServiceContact().getPort();
+ if (port == -1) {
+ port = 22;
+ }
try {
- String host = getServiceContact().getHost();
- int port = getServiceContact().getPort();
- if (port == -1) {
- port = 22;
- }
channel = SSHChannelManager.getDefault().getChannel(host, port,
getSecurityContext().getCredentials());
id = channel.getBundle().getId();
@@ -94,7 +94,8 @@
}
catch (Exception se) {
throw translateException(
- "Error while communicating with the SSH server on " + id, se);
+ "Error while communicating with the SSH server on " + host
+ + ":" + port, se);
}
}
@@ -381,7 +382,7 @@
}
else {
throw translateException(
- "Cannot determine the existence of the file", e);
+ "Cannot determine the existence of the file", e);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-28 00:24:15
|
Revision: 1857
http://cogkit.svn.sourceforge.net/cogkit/?rev=1857&view=rev
Author: jenvor
Date: 2007-12-27 16:24:14 -0800 (Thu, 27 Dec 2007)
Log Message:
-----------
Bug fix for disordered arrival of event messages to status server
Modified Paths:
--------------
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
Modified: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2007-12-27 22:33:40 UTC (rev 1856)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2007-12-28 00:24:14 UTC (rev 1857)
@@ -7,7 +7,7 @@
package org.cogkit.cyberaide.axis2ws;
-import java.util.ArrayList;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -49,6 +49,7 @@
private int serviceImplType = this.ECHODRIVEN;
private static StatusDB _db = new StatusDB();
+ private volatile static MsgCache _msgcache = new MsgCache();
private String _logfile = "/tmp/status_service.log";
private RandomAccessFile _log = null;
@@ -92,11 +93,49 @@
writeLog("modifyStatusByPathString "+struid+":"+wfid+":"+path+":"+statuscode+":"+statusmsg+"\n");
UID uid = new UIDUsername(struid);
- _db.setElementStatusByPathString(uid, wfid, path, statuscode, statusmsg);
+ if( false == _db.setElementStatusByPathString(uid, wfid, path, statuscode, statusmsg) ){
+ //the workflow which will be modified does not exist now
+ _msgcache.insertMsg(struid, wfid, Msg.MSGELEWF, path, statuscode, statusmsg );
+ }
String json = _db.getStatusByUID(uid).toJSON();
writeLog(json+"\n");
}
+
+ /**
+ * get pending messages and apply them to the corresponding workflows
+ */
+ private void redoMsg( String struid, String wfid ){
+ ArrayList<Msg> msgs = _msgcache.extractMsg( struid, wfid );
+ Msg msg = null;
+ if(msgs!=null){
+ UID uid = new UIDUsername(struid);
+ for(int i = 0; i < msgs.size(); i++){
+ msg = msgs.get(i);
+ if( msg.getMsgtype() == Msg.MSGWHOLEWF ){
+ _db.setElementStatusByPathString( uid, wfid, msg.getPath(), msg.getStatuscode(), msg.getStatusmsg() );
+ }else if ( msg.getMsgtype() == Msg.MSGWHOLEWF ){
+ _db.setStatusOfWF(uid, wfid, msg.getStatuscode(), msg.getStatusmsg());
+ }
+ }
+ }
+ }
+
+ public void modifyStatusOfWholeWF(org.cogkit.cyberaide.axis2ws.ModifyStatusOfWholeWF modifyStatusOfWholeWF7){
+ String struid = modifyStatusOfWholeWF7.getParam0();
+ String wfid = modifyStatusOfWholeWF7.getParam1();
+ int statuscode = modifyStatusOfWholeWF7.getParam2();
+ String statusmsg = modifyStatusOfWholeWF7.getParam3();
+
+ writeLog("modifyStatusOfWholeWF:"+struid+":"+wfid+":"+statuscode+":"+statusmsg+"\n");
+
+ UID uid = new UIDUsername(struid);
+ if( false == _db.setStatusOfWF(uid, wfid, statuscode, statusmsg) )
+ _msgcache.insertMsg(struid, wfid, Msg.MSGWHOLEWF, "", statuscode, statusmsg );
+
+ String json = _db.getStatusByUID(uid).toJSON();
+ writeLog(json+"\n");
+ }
/**
* Auto generated method signature
* @param getXMLStatusByUID1
@@ -167,6 +206,7 @@
WorkflowStatus wfs = new WorkflowStatus(tree);
wfs.setWfid(wfid);
_db.addStatus(uid, wfs);
+ redoMsg( struid, wfid );
}
/**
@@ -185,24 +225,62 @@
WorkflowStatus wfs = new WorkflowStatus(tree);
wfs.setWfid(wfid);
_db.addStatus(uid, wfs);
+ redoMsg( struid, wfid );
}
- public void modifyStatusOfWholeWF(org.cogkit.cyberaide.axis2ws.ModifyStatusOfWholeWF modifyStatusOfWholeWF7){
- String struid = modifyStatusOfWholeWF7.getParam0();
- String wfid = modifyStatusOfWholeWF7.getParam1();
- int statuscode = modifyStatusOfWholeWF7.getParam2();
- String statusmsg = modifyStatusOfWholeWF7.getParam3();
+}
- writeLog("modifyStatusOfWholeWF:"+struid+":"+wfid+":"+statuscode+":"+statusmsg+"\n");
+class Msg{
+ public static int MSGWHOLEWF = 0;
+ public static int MSGELEWF = 1;
+ private int _statuscode;
+ private String _statusmsg;
+ private String _path;
+ private int _msgtype;
+ public Msg(int msgtype, String path, int statuscode, String statusmsg){
+ _path = path;
+ _msgtype = msgtype;
+ _statuscode = statuscode;
+ _statusmsg = statusmsg;
+ }
+ public int getStatuscode(){ return _statuscode; }
+ public int getMsgtype(){ return _msgtype; }
+ public String getStatusmsg() { return _statusmsg; }
+ public String getPath(){ return _path; }
+}
- UID uid = new UIDUsername(struid);
- _db.setStatusOfWF(uid, wfid, statuscode, statusmsg);
-
- String json = _db.getStatusByUID(uid).toJSON();
- writeLog(json+"\n");
+class MsgCache{
+ private HashMap<String, HashMap<String, ArrayList<Msg>>> _msgcache = new HashMap<String, HashMap<String, ArrayList<Msg>>>();
+ public void insertMsg(String uid, String wfid, Msg msg){
+ HashMap<String, ArrayList<Msg>> userMap = _msgcache.get( uid );
+ if( userMap == null ){
+ userMap = new HashMap<String, ArrayList<Msg>>();
+ _msgcache.put(uid, userMap);
+ }
+ ArrayList<Msg> msgs = userMap.get(wfid);
+ if( msgs == null ){
+ msgs = new ArrayList<Msg>();
+ userMap.put(wfid, msgs);
+ }
+ msgs.add( msg );
}
+ public void insertMsg(String uid, String wfid, int msgtype, String path, int statuscode, String statusmsg){
+ Msg msg = new Msg(msgtype, path, statuscode, statusmsg);
+ insertMsg( uid, wfid, msg );
+ }
+ public ArrayList<Msg> extractMsg(String uid, String wfid){
+ HashMap<String, ArrayList<Msg>> userMap = _msgcache.get( uid );
+ if( userMap == null ){
+ return null;
+ }
+ ArrayList<Msg> msgs = userMap.get(wfid);
+ if( msgs == null ){
+ return null;
+ }
+ userMap.put(wfid, null);
+ return msgs;
+ }
}
-
/**
* Interface which all tree nodes must implement. Note: every node can contain
* its data which can be gotten by invoking method <b>getData()</b>.
@@ -827,7 +905,7 @@
*/
class StatusDB{
private HashMap<String, StatusList> _statusdb = new HashMap<String, StatusList>();
- public void addStatus(UID uid, WorkflowStatus wfs){
+ public synchronized void addStatus(UID uid, WorkflowStatus wfs){
if(_statusdb.containsKey(uid.toString())){
StatusList list = (StatusList)_statusdb.get(uid.toString());
if(!list.containsWF(wfs.getWfid()))
@@ -885,17 +963,20 @@
* status code
* @param statusmsg
* status message
+ * @return
+ * a boolean value which indicates whether the workflow exists.
*/
- public void setElementStatusByPathString(UID uid, String wfid, String path, int statuscode, String statusmsg){
+ public synchronized boolean setElementStatusByPathString(UID uid, String wfid, String path, int statuscode, String statusmsg){
StatusList list = _statusdb.get(uid.toString());
Iterator<WorkflowStatus> it = list.iterator();
while(it.hasNext()){
WorkflowStatus wfs = (WorkflowStatus)it.next();
if( wfs.getWfid().compareTo(wfid)==0 ){
wfs.setElementStatusByPathString(path, statuscode, statusmsg);
- break;
+ return true;
}
}
+ return false;
}
/**
@@ -905,7 +986,7 @@
* @param statuscode
* @param statusmsg
*/
- public void setStatusOfWF(UID uid, String wfid, int statuscode, String statusmsg){
+ public synchronized boolean setStatusOfWF(UID uid, String wfid, int statuscode, String statusmsg){
StatusList list = _statusdb.get(uid.toString());
Iterator<WorkflowStatus> it = list.iterator();
while(it.hasNext()){
@@ -913,9 +994,10 @@
if( wfs.getWfid().compareTo(wfid)==0 ){
wfs.setStatusMsg(statusmsg);
wfs.set_statusCode(statuscode);
- break;
+ return true;
}
}
+ return false;
}
}
class KarajanNodeJSON{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-27 22:33:45
|
Revision: 1856
http://cogkit.svn.sourceforge.net/cogkit/?rev=1856&view=rev
Author: jenvor
Date: 2007-12-27 14:33:40 -0800 (Thu, 27 Dec 2007)
Log Message:
-----------
bug fix of visual workflow composition for IE
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js
Modified: trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js 2007-12-27 22:01:55 UTC (rev 1855)
+++ trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js 2007-12-27 22:33:40 UTC (rev 1856)
@@ -898,21 +898,20 @@
return false;
}
function highlightEleIcon(e, pathJS, pathKarajan){
- var evt, ele, fromEle, toEle;
+ var evt, ele, fromEle;
var winH = promptwin.height, winW = promptwin.width;
var clientH, clientW;
if (typeof(window.event) != "undefined") {//IE
evt = window.event;
- //toEle = evt.toElement;
fromEle = evt.fromElement;
ele = evt.srcElement;
- clientH = document.documentElement.clientHeight;
+ //clientH = document.documentElement.clientHeight;
+ clientH = document.body.clientHeight;
clientW = document.body.clientWidth;
}
else {//FF
evt = e;
fromEle = evt.relatedTarget;
- //toEle = evt.relatedTarget;
ele = evt.target;
clientW = document.body.clientWidth;
clientH = document.documentElement.clientHeight;//window.innerHeight;
@@ -950,7 +949,8 @@
evt = window.event;
relatedEle = evt.toElement;
ele = evt.srcElement;
- clientH = document.documentElement.clientHeight;
+ //clientH = document.documentElement.clientHeight;
+ clientH = document.body.clientHeight;
clientW = document.body.clientWidth;
}
else {//FF
@@ -1368,4 +1368,4 @@
fullname = KarajanEleTree + ".namespaces." + ns + ".elements." + elename;
var ele = eval("(" + fullname + ")");
return ele;
-}
\ No newline at end of file
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-27 22:01:59
|
Revision: 1855
http://cogkit.svn.sourceforge.net/cogkit/?rev=1855&view=rev
Author: jenvor
Date: 2007-12-27 14:01:55 -0800 (Thu, 27 Dec 2007)
Log Message:
-----------
bug fix and improvement of visual workflow composition
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/index.html
trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2007-12-20 00:34:47 UTC (rev 1854)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2007-12-27 22:01:55 UTC (rev 1855)
@@ -22,6 +22,8 @@
Ext.onReady(function(){
//createBasicDesktop('workflowdiv');
createWidgetToolbox();
+ promptwin.render('prompt');
+ promptwin.hide();
});
</script>
@@ -283,6 +285,15 @@
hiddenele.value = ele.value;
}
</script>
+ <style>
+ .widget{
+ background-image: url('images/1.jpg');
+ }
+ .promptTextArea{
+ opacity:0.85;
+ filter:alpha(opacity=85); /* IE's opacity*/
+ }
+ </style>
</head>
<body>
@@ -349,5 +360,6 @@
</table>
</div>
<textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';"></textarea>
+ <div id="prompt"></div>
</body>
</html>
Modified: trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js 2007-12-20 00:34:47 UTC (rev 1854)
+++ trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js 2007-12-27 22:01:55 UTC (rev 1855)
@@ -4,30 +4,79 @@
* @author gerald
* @LastModified: Dec 19 2007
*/
-
+promptwin = new Ext.Window({
+ //title:"description",
+ width: 300,
+ height: 150,
+ collapsible :false,
+ closable :false,
+ border: false,
+ constrain : true,
+ constrainHeader: true,
+ header : false,
+ footer: false,
+ hideBorders : true,
+ resizable : false,
+ draggable: false,
+ layout: 'fit',
+ cls:'promptTextArea',
+ items:new Ext.form.TextArea({
+ readOnly: true,
+ border: false,
+ height: "100%",
+ width: "100%",
+// grow: true,
+// growMax: 500,
+// growMin: 50,
+ value : "test for description"
+ })
+ });
+
+/**
+ * This function is grabbed from internet. Later, I will add the original address.
+ */
function caret(node){
- if (node.selectionStart)
- return node.selectionStart;
+ if (typeof node.selectionStart != 'undefined'){//FireFox
+ return [node.selectionStart, node.selectionEnd];
+ }
else
if (!document.selection)
- return 0;
- //node.focus();
- var c = "\001";
- var sel = document.selection.createRange();
- var txt = sel.text;
- var dul = sel.duplicate();
- var len = 0;
- try {
- dul.moveToElementText(node);
- }
- catch (e) {
- return 0;
- }
- sel.text = txt + c;
- len = (dul.text.indexOf(c));
- sel.moveStart('character', -1);
- sel.text = "";
- return len;
+ return 0;
+
+ node.focus();
+ var txt = node.value;
+ var len = txt.length;
+ var pos = -1;
+ var range_sel = document.selection.createRange();
+ var sellen = range_sel.text.length;
+ if( sellen > 0) {//selection is not empty
+ var range_obj = node.createTextRange();
+ range_obj.moveToBookmark(range_sel.getBookmark());
+ range_obj.moveEnd('character',node.value.length);
+ pos = len - range_obj.text.length;
+ return [pos, pos+sellen];
+ }else{
+ /*
+ This piece of code just returns the current position because
+ no text is selected.
+ */
+ var c = "\001";
+ var sel = document.selection.createRange();
+ var txt = sel.text;
+ var dul = sel.duplicate();
+ var len = 0;
+ try {
+ dul.moveToElementText(node);
+ }
+ catch (e) {
+ return [0,0];
+ }
+ sel.text = txt + c;
+ len = (dul.text.indexOf(c));
+ sel.moveStart('character', -1);
+ sel.text = "";
+ return [len,len];
+ }
}
/**
@@ -36,6 +85,70 @@
var WFEleList = {
elements: {},
namespaces: {
+ kernel:{
+ namespaces:{
+
+ },
+ elements:{
+ project: {
+ properties:[],
+ widgetProps:{},
+ description: "The root element of a Karajan program"
+ },
+ import_: {
+ truename: "import",
+ properties:["file"],
+ widgetProps:{},
+ description: "Executes the file specified by the file argument"
+ },
+ export_: {
+ truename: "export",
+ properties:["name","value"],
+ widgetProps:{},
+ description:"Returns the pair (name, value). "
+ },
+ define: {
+ properties:["name", "value"],
+ widgetProps:{},
+ description:"Binds a lambda, specified by the value argument to the given name."
+ },
+ namespace: {
+ properties:["prefix"],
+ widgetProps:{},
+ description:"Allows the specification of a namespace prefix. Any elements defined in the scope of namespace will automatically have the prefix indicated by the prefix argument, unless another namespace is nested."
+ },
+ elementdef: {
+ properties:["type", "classname"],
+ widgetProps:{},
+ description:"Used by the current implementation to map element names to Java implementation classes."
+ },
+ named: {
+ properties:["name", "value"],
+ widgetProps:{},
+ description:"Used internally by the named argument form, but can be used by the user equally well. The following are equivalent:\nprint(\"Test\", nl = false()\nprint(\"Test\", kernel:named(name = nl, false())"
+ },
+ number: {
+ properties:["value"],
+ widgetProps:{},
+ description:"Can be used with the XML syntax to represent a number. There is no distinction between integral numbers and floating point numbers in Karajan."
+ },
+ string: {
+ properties:["value"],
+ widgetProps:{},
+ description:"Can be used with the XML syntax to represent a string value."
+ },
+ variable: {
+ properties:["name"],
+ widgetProps:{},
+ description:"Used to represent the value of a variable."
+ },
+ cache: {
+ properties:[],
+ widgetProps:{},
+ description:"Caches the evaluation of the arguments. Upon subsequent executions of cache, the arguments will not be re-evaluated. Instead, the cached values will be returned. Cache does not make any checks for the invariance of the evaluation of the arguments."
+ }
+ }
+ },
sys: {
namespaces: {
file: {
@@ -63,6 +176,182 @@
}
},
elements: {
+ sequential: {
+ properties: [],
+ widgetProps: { },
+ description:"Executes all arguments in sequence."
+ },
+ parallel: {
+ properties: [],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ },
+ description:"Executes all arguments in parallel."
+ },
+ unsynchronized: {
+ properties: [],
+ widgetProps: {},
+ description:"Asynchronously executes all arguments in sequence. Does not return any value. If return values from asynchronous computations is required, use either future or futureIterator"
+ },
+ choice: {
+ properties: [],
+ widgetProps: {},
+ description:"Executes arguments in succession. Terminates when one of the arguments completes successfully. "
+ },
+ catch_: {
+ truename:'catch',
+ properties: ["match"],
+ widgetProps: {},
+ description:"Catch will match the error variable against the regular expression in match. If successful, it will execute the rest of its arguments, otherwise it will fail with the last failure encountered. Catch can be used with choice to selectively handle specific failures:"
+ },
+ guard: {
+ properties: [],
+ widgetProps: {},
+ description:"Guard expects two sub-elements. It will execute the first, then the second, even if the first one fails. In other words, the second sub-element will always be executed. If the first element failed, after executing the second element, guard will also fail. If the second element fails, guard will fail with the same error, regardless of whether the first element failed or not. Guard can be used to implement clean-up actions, in a fashion similar to try/finally from C++, Java or Python."
+ },
+ race: {
+ properties: [],
+ widgetProps: {},
+ description:"Can be used to race a number of arguments. Race will execute all its arguments in parallel, buffer their return values, and wait for the first one that completes. It will then return all the values that the winner generated. The remaning threads are quietly aborted. If an any argument fails before any other argument completes, then race will fail. That is, failures occurring after the winner completes are silently ignored."
+ },
+ for_: {
+ truename:'for',
+ properties: ["name", "in"],
+ widgetProps: {},
+ description:"Can be used to iterate sequentially across a range of values. The name argument is an identifier that indicates the name of the variable that will be set to the successive values of the in argument, which Karajan will try to convert to an iterator before beginning the iteration process.\nAfter evaluating name and in, for will proceed and evaluate the rest of the arguments repeatedly, while setting the variable indicated by the name argument to each value produced by the iterator (in). "
+ },
+ parallelFor: {
+ properties: ["name", "in"],
+ widgetProps: {},
+ description:"Will behave in a similar way to for with the exception that iterations will occur in parallel. Each iteration will occur in a separate scope. Therefore variables set in one of the iterations will not be visible in the others (which is also the case with for). Each scope will have the variable indicated by the name argument set to one of the values obtained from the in argument."
+ },
+ while_: {
+ truename:"while",
+ properties: [],
+ widgetProps: {},
+ description:"Will repeatedly execute its arguments in sequence until a value of false is received on the condition channel. A convenience element that returns a boolean argument on the condition channel is condition (or ?). While will check for a condition every time an argument completes. It is therefore possible to exit the loop after the termination of any of the arguments."
+ },
+ condition: {
+ properties: ["value"],
+ widgetProps: {},
+ description:"Evaluates the value argument and returns its value on the condition channel."
+ },
+ break_: {
+ truename:"break",
+ properties: [],
+ widgetProps: {},
+ description:"Can be used to break out of a while loop. By contrast with using the condition channel, break will immediately exit the loop, no matter how deep the nesting level. It does that by generating a failure, which is intercepted by the enclosing while."
+ },
+ continue_: {
+ truename:"continue",
+ properties: [],
+ widgetProps: {},
+ description:"Can be used to skip the evaluation of the remaining arguments in an iteration in a while loop and jump to the next iteration. Similar to break, continue achieves its purpose by generating a failure which is intercepted by while."
+ },
+ if_: {
+ truename:"if",
+ properties: [],
+ widgetProps: {}
+ },
+ then: {
+ properties: [],
+ widgetProps: {}
+ },
+ exclusive: {
+ properties: [],
+ widgetProps: {}
+ },
+ set: {
+ properties: ["names"],
+ widgetProps: {}
+ },
+ default_: {
+ truename:"default",
+ properties: ["name","value"],
+ widgetProps: {}
+ },
+ maybe: {
+ properties: [],
+ widgetProps: {}
+ },
+ global: {
+ properties: ["name","value"],
+ widgetProps: {}
+ },
+ isDefined: {
+ properties: ["name"],
+ widgetProps: {}
+ },
+ quoted: {
+ properties: ["name"],
+ widgetProps: {}
+ },
+ discard: {
+ properties: [],
+ widgetProps: {}
+ },
+ future: {
+ properties: [],
+ widgetProps: {}
+ },
+ futureIterator: {
+ properties: [],
+ widgetProps: {}
+ },
+ each: {
+ properties: ["items"],
+ widgetProps: {}
+ },
+ element: {
+ properties: ["name", "arguments","vargs"],
+ widgetProps: {}
+ },
+ parallelElement: {
+ properties: ["name", "arguments","vargs"],
+ widgetProps: {}
+ },
+ channel: {
+ properties: [],
+ widgetProps: {}
+ },
+ optional: {
+ properties: [],
+ widgetProps: {}
+ },
+ self: {
+ properties: [],
+ widgetProps: {}
+ },
+ remote: {
+ properties: ["host"],
+ widgetProps: {}
+ },
+ and: {
+ properties: [],
+ widgetProps: {}
+ },
+ or: {
+ properties: [],
+ widgetProps: {}
+ },
+ not: {
+ properties: ["value"],
+ widgetProps: {}
+ },
+ equals: {
+ properties: ["value1", "value2"],
+ widgetProps: {}
+ },
+ true_: {
+ truename:"true",
+ properties: [],
+ widgetProps: {}
+ },
+ false_: {
+ truename:"false",
+ properties: [],
+ widgetProps: {}
+ },
execute: {
properties: ["executable", "host", "stdout", "provider", "redirect"],
widgetProps: {
@@ -77,7 +366,279 @@
widgetProps: {
iconUrl: "images/3.jpg"
}
+ }
+ }
+ },
+ list:{
+ elements:{
+ list: {
+ properties: ["items"],
+ widgetProps: {}
},
+ append : {
+ properties: ["list", "items"],
+ widgetProps: {}
+ },
+ prepend: {
+ properties: ["list"],
+ widgetProps: {}
+ },
+ join: {
+ properties: [],
+ widgetProps: {}
+ },
+ size: {
+ properties: ["list"],
+ widgetProps: {}
+ },
+ first: {
+ properties: ["list"],
+ widgetProps: {}
+ },
+ last: {
+ properties: ["list"],
+ widgetProps: {}
+ },
+ get: {
+ properties: ["list","index"],
+ widgetProps: {}
+ },
+ butFirst: {
+ properties: ["list"],
+ widgetProps: {}
+ },
+ butLast: {
+ properties: ["list"],
+ widgetProps: {}
+ },
+ isEmpty: {
+ properties: ["list"],
+ widgetProps: {}
+ }
+ },
+ namespaces:{
+
+ }
+ },
+ map:{
+ elements:{
+ map: {
+ properties: [],
+ widgetProps: {}
+ },
+ entry: {
+ properties: ["key", "value"],
+ widgetProps: {}
+ },
+ put: {
+ properties: ["map"],
+ widgetProps: {}
+ },
+ delete_: {
+ truename:"delete",
+ properties: ["map", "key"],
+ widgetProps: {}
+ },
+ get: {
+ properties: ["map", "key"],
+ widgetProps: {}
+ },
+ size: {
+ properties: ["map"],
+ widgetProps: {}
+ },
+ contains: {
+ properties: ["map", "key"],
+ widgetProps: {}
+ }
+ },
+ namespaces: {}
+ },
+ math:{
+ elements:{
+ sum: {
+ properties: [],
+ widgetProps: {}
+ },
+ product: {
+ properties: [],
+ widgetProps: {}
+ },
+ subtraction: {
+ properties: ["from", "value"],
+ widgetProps: {}
+ },
+ quotient: {
+ properties: ["divisor", "dividend"],
+ widgetProps: {}
+ },
+ remainder: {
+ properties: ["divisor", "dividend"],
+ widgetProps: {}
+ },
+ square: {
+ properties: ["value"],
+ widgetProps: {}
+ },
+ sqrt: {
+ properties: ["value"],
+ widgetProps: {}
+ },
+ equalsNumeric: {
+ properties: ["value1", "value2"],
+ widgetProps: {}
+ },
+ greaterThan: {
+ properties: ["value1", "value2"],
+ widgetProps: {}
+ },
+ lessThan: {
+ properties: ["value1", "value2"],
+ widgetProps: {}
+ },
+ greaterOrEqual: {
+ properties: ["value1", "value2"],
+ widgetProps: {}
+ },
+ lessOrEqual: {
+ properties: ["value1", "value2"],
+ widgetProps: {}
+ },
+ min: {
+ properties: [],
+ widgetProps: {}
+ },
+ max: {
+ properties: [],
+ widgetProps: {}
+ },
+ int_: {
+ truename:"int",
+ properties: ["value"],
+ widgetProps: {}
+ },
+ ln: {
+ properties: ["value"],
+ widgetProps: {}
+ },
+ exp: {
+ properties: ["value"],
+ widgetProps: {}
+ },
+ random: {
+ properties: [],
+ widgetProps: {}
+ }
+ },
+ namespaces:{
+
+ }
+ },
+ str:{
+ elements:{
+ concat: {
+ properties: [],
+ widgetProps: {}
+ },
+ split: {
+ properties: ["string", "separator"],
+ widgetProps: {}
+ },
+ strip: {
+ properties: ["value"],
+ widgetProps: {}
+ },
+ matches: {
+ properties: ["string", "regexp"],
+ widgetProps: {}
+ },
+ nl: {
+ properties: [],
+ widgetProps: {}
+ },
+ chr: {
+ properties: ["code"],
+ widgetProps: {}
+ },
+ substring: {
+ properties: ["string", "from", "to"],
+ widgetProps: {}
+ },
+ quote: {
+ properties: ["string"],
+ widgetProps: {}
+ }
+ },
+ namespaces:{}
+ },
+ task: {
+ elements: {
+ execute: {
+ properties: ["executable", "host", "stdout", "provider", "redirect"],
+ widgetProps: {
+ iconUrl: "images/10.jpg"
+ //other properties: id, height, width. all these properties can be
+ //generated automatically. In other words, you don't need to specify
+ //them. However, you can set them if you wish.
+ }
+ },
+ transfer: {
+ properties: ["srchost", "srcdir", "srcfile", "desthost", "destdir", "destfile", "provider"],
+ widgetProps: {
+ iconUrl: "images/2.jpg"
+ }
+ }
+ },
+ namespaces: {}
+ }
+ }
+};
+/*
+var WFEleList = {
+ elements: {},
+ namespaces: {
+ sys: {
+ namespaces: {
+ file: {
+ elements: {
+ read: {
+ properties: ["name"],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ },
+ write: {
+ properties: ["name", "append"],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ },
+ contains: {
+ properties: ["file", "value"],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ }
+ },
+ namespace: {}
+ }
+ },
+ elements: {
+ execute: {
+ properties: ["executable", "host", "stdout", "provider", "redirect"],
+ widgetProps: {
+ iconUrl: "images/1.jpg"
+ //other properties: id, height, width. all these properties can be
+ //generated automatically. In other words, you don't need to specify
+ //them. However, you can set them if you wish.
+ }
+ },
+ echo: {
+ properties: ["message", "nl"],
+ widgetProps: {
+ iconUrl: "images/3.jpg"
+ }
+ },
parallel: {
properties: [],
widgetProps: {
@@ -114,12 +675,47 @@
}
}
};
+*/
+function KarajanElementNode(name, obj){
+ this.name = name;
+ this.truename = name;
+ if( obj["truename"] != null )
+ this.truename = obj["truename"];
+ if( obj["description"] != null )
+ this.description = obj["description"];
+
+ this.properties = obj["properties"];
+ this.widgetProps = obj["widgetProps"];
+}
+function KarajanNSNode(name, obj){
+ this.name = name;
+ this.truename = name;
+ if( obj["truename"] != null )
+ this.truename = obj["truename"];
+ this.elements = {};
+ this.namespaces = {};
+ var elements = obj["elements"];
+ for( ele in elements){
+ eval( "(this.elements."+ele+"=new KarajanElementNode(ele, elements[ele]))" );
+ }
+ var nss = obj["namespaces"];
+ for( ns in nss ){
+ eval( "(this.namespaces."+ns+"=new KarajanNSNode(ns, nss[ns]))" );
+ }
+}
-WFEleList.toString = function(){
- return "WFEleList";
+function KarajanElementTree(obj){
+ this.root = new KarajanNSNode("root", obj);
}
+var KarajanEleTree = new KarajanElementTree(WFEleList);
+KarajanEleTree.toString = function(){ return "KarajanEleTree.root"; }
+//WFEleList.toString = function(){
+// return "WFEleList";
+//}
+
+
/********************************** Widget Toolbox window related functions ***********************************/
/**
* This function is used to add icons for elements specified by nsobj to panel widgetWin.
@@ -130,15 +726,16 @@
* Actually, this is part of WFEleList.
* @param {Object} base namespace we are working on. e.g. sys.file
*/
-function addNStoWidgetWin(widgetWin, nsobj, base){
+function addNStoWidgetWin(widgetWin, nsobj, baseKarajan, baseJS){
var namespaces = "namespaces", elements = "elements";
var nslist = nsobj[namespaces], elelist = nsobj[elements];
- var eletitle = base + " elements", nstitle = base + " namespace";
- if (base == "") {
+ var eletitle = baseKarajan + " elements", nstitle = baseKarajan + " namespace";
+ if (baseKarajan == "") {
eletitle = "root elements";
nstitle = "root namespace";
}
- var nslevel = getNSCount(base);
+
+ var nslevel = getNSCount(baseKarajan);
for (var i = 0; i < nslevel; i++) {
eletitle = "--" + eletitle;
nstitle = "--" + nstitle;
@@ -146,82 +743,118 @@
eletitle = "+" + eletitle;
nstitle = "+" + nstitle;
- /** First add elements in this namespace.
- * Step 1: create a accordion panel;
- * Step 2: add every element in this namespace to the newly created accordion panel
- */
- var accordionele = new Ext.Panel({
- title: eletitle,
- layout: 'table',
- layoutConfig: {
- columns: 3
- },
- border: false,
- defaults: {
- bodyStyle: 'margin:5px;'
- }
- });
- widgetWin.add(accordionele);
+ /**
+ * judge whether the "elements" is empty. If it is empty, we don't need to
+ * create an accordion window for it.
+ */
+ var iselementsEmpty = true;
+ for(prop in elelist){
+ iselementsEmpty = false;
+ break;
+ }
+ if (!iselementsEmpty) {
+ /** First add elements in this namespace.
+ * Step 1: create an accordion panel;
+ * Step 2: add every element in this namespace to the newly created accordion panel
+ */
+ var accordionele = new Ext.Panel({
+ title: eletitle,
+ autoScroll: true,
+ layout: 'table',
+ //height: 1000,
+ layoutConfig: {
+ columns: 3
+ },
+ border: false,
+ defaults: {
+ bodyStyle: 'margin:5px;'
+ }
+ });
+ widgetWin.add(accordionele);
+
+ for (elename in elelist) {
+ var ele = elelist[elename];
+ var eleid = "widget_" + ele.truename;
+ var widgetprops = ele.widgetProps;
+ var clickHandler = "";
+ var pathJS = "", pathKarajan = "";
+ if (baseKarajan == "") {
+ pathJS = elename;
+ pathKarajan = ele.truename;
+ clickHandler = "javascript:widgetClick('" + pathKarajan + "','" + pathJS + "');";
+ }
+ else {
+ pathJS = baseJS + "." + elename;
+ pathKarajan = baseKarajan + "." + ele.truename;
+ clickHandler = "javascript:widgetClick('" + pathKarajan + "','" + pathJS + "');";
+ }
+ var defaultConfig = {
+ height: "40px",
+ width: "60px",
+ id: eleid,
+ onClick: clickHandler
+ };
+ Ext.applyIf(widgetprops, defaultConfig);
+
+ //construct html markup based on the configuration
+ // var html = "<div style=\"background-image:url("+widgetprops.iconUrl+");width:40px;height:40px;\">"+elename+"</div>"
+ var html = "<div id='" + pathKarajan + "' style=\"border:1px solid yellow;";
+ html += "width:" + widgetprops.width + "; text-align:center;vertical-align:middle;line-height:2em;";
+ html += "height:" + widgetprops.height + ";";
+ html += "\"";
+ html += " onmouseover=\"" + "javascript:highlightEleIcon(event,'" +pathJS + "','"+pathKarajan+"');" + "\"";
+ html += " onmouseout=\"" + "javascript:restoreEleIcon(event);" + "\"";
+ html += " onmousemove=\""+ "javascript:positionTip(event);" + "\"";
+ html += " onClick=\"" + widgetprops.onClick + "\"";
+ html += ">";
+// html += "<a style=\"text-decoration:none;\"";
+// html += " id='" + pathKarajan +"A' href=\"#\"";
+// html += ">" + ele.truename + "</a>";
+ html += ele.truename;
+ html += "</div>";
+ // var html = "<input type=\"image\" alt=\"[*]\" style=\"";
+ // html += "height:" + widgetprops.height + ";";
+ // html += "width:" + widgetprops.width + ";";
+ // html += "\"";
+ // html += " src=\"" + widgetprops.iconUrl + "\"";
+ // html += "onmouseover=\""+"javascript:highlightEleIcon(event);"+"\"";
+ // html += " onmouseout=\""+"javascript:restoreEleIcon(event);"+"\"";
+ // html += " onClick=\"" + widgetprops.onClick + "\">" + "<br>"+elename + "</input>";
+ // var html = "<img src=\"";
+ // html += widgetprops.iconUrl;
+ // html += "\" id=\"";
+ // html += widgetprops.id;
+ // html += "\" height=\"";
+ // html += widgetprops.height;
+ // html += "\" width=\"";
+ // html += widgetprops.width;
+ // html += "\" onClick=\"";
+ // html += widgetprops.onClick;
+ // html += "\" >"
+ // html += elename;
+ // html = "<div style=\"border:1px solid;background-color:#abc;\">"+html+"</div>"
+ var iconPanel = new Ext.Panel({
+ html: html,
+ border: true,
+ bodyBorder: false,
+ height: "40px",
+ width: "80px"
+ });
+ accordionele.add(iconPanel);
+ }
+ }
- for (elename in elelist) {
- var eleid = "widget_" + elename;
- var ele = elelist[elename];
- var widgetprops = ele.widgetProps;
- var clickHandler = "";
- if (base == "")
- clickHandler = "javascript:widgetClick('" + elename + "');";
- else
- clickHandler = "javascript:widgetClick('" + base + "." + elename + "');";
- var defaultConfig = {
- height: "40px",
- width: "60px",
- id: eleid,
- onClick: clickHandler
- };
- Ext.applyIf(widgetprops, defaultConfig);
-
- //construct html markup based on the configuration
- // var html = "<div style=\"background-image:url("+widgetprops.iconUrl+");width:40px;height:40px;\">"+elename+"</div>"
- var html = "<div style=\"";
- html += "width:" + widgetprops.width + "; text-align:center;vertical-align:middle;line-height:2em;";
- html += "height:" + widgetprops.height + ";";
- html += "\"";
- html += " onmouseover=\""+"javascript:highlightEleIcon(event);"+"\"";
- html += " onmouseout=\""+"javascript:restoreEleIcon(event);"+"\"";
- html += " onClick=\"" + widgetprops.onClick + "\"";
- html += ">";
- html += "<a href=\"#\"";
- html += ">"+elename + "</a>";
- html += "</div>";
-// var html = "<input type=\"image\" alt=\"[*]\" style=\"";
-// html += "height:" + widgetprops.height + ";";
-// html += "width:" + widgetprops.width + ";";
-// html += "\"";
-// html += " src=\"" + widgetprops.iconUrl + "\"";
-// html += "onmouseover=\""+"javascript:highlightEleIcon(event);"+"\"";
-// html += " onmouseout=\""+"javascript:restoreEleIcon(event);"+"\"";
-// html += " onClick=\"" + widgetprops.onClick + "\">" + "<br>"+elename + "</input>";
- // var html = "<img src=\"";
- // html += widgetprops.iconUrl;
- // html += "\" id=\"";
- // html += widgetprops.id;
- // html += "\" height=\"";
- // html += widgetprops.height;
- // html += "\" width=\"";
- // html += widgetprops.width;
- // html += "\" onClick=\"";
- // html += widgetprops.onClick;
- // html += "\" >"
- // html += elename;
- // html = "<div style=\"border:1px solid;background-color:#abc;\">"+html+"</div>"
- var iconPanel = new Ext.Panel({
- html: html,
- border: true,
- bodyBorder: false
- });
- accordionele.add(iconPanel);
- }
-
+ /**
+ * judge whether the namespace is empty. If it is empty, we don't need to
+ * create an accordion window.
+ */
+ var isnamespaceEmpty = true;
+ for(prop in nslist){
+ isnamespaceEmpty = false;
+ break;
+ }
+ if( isnamespaceEmpty ) return;
+
/**
* Then handle inner namespace.
* Step 1: create a accordion panel for sub namespace.
@@ -232,6 +865,7 @@
layout: 'accordion',
collapsible: true,
shim: false,
+ autoScroll: true,
animCollapse: true,
layoutConfig: {
columns: 3
@@ -246,44 +880,124 @@
});
widgetWin.add(nsaccordionele);
+ var newbaseKarajan, newbaseJS;
for (ns in nslist) {
- var newbase = base + "." + ns;
- if (base == "")
- newbase = ns;
- arguments.callee(nsaccordionele, nslist[ns], newbase);
+ newbaseKarajan = baseKarajan + "." + nslist[ns].truename;
+ newbaseJS = baseJS + "." + ns;
+ if (baseKarajan == "") {
+ newbaseJS = ns;
+ newbaseKarajan = nslist[ns].truename;
+ }
+ arguments.callee(nsaccordionele, nslist[ns], newbaseKarajan, newbaseJS);
}
}
-function highlightEleIcon(e){
- var evt, ele;
- if (typeof(window.event) != "undefined") {
+function contains( ele1, ele2 ){
+ var id1 = ele1.id, id2 = ele2.id;
+ if( id2.charAt(id2.length-1)=='A' && id1 == id2.substr(0, id2.length-1) )
+ return true;
+ return false;
+}
+function highlightEleIcon(e, pathJS, pathKarajan){
+ var evt, ele, fromEle, toEle;
+ var winH = promptwin.height, winW = promptwin.width;
+ var clientH, clientW;
+ if (typeof(window.event) != "undefined") {//IE
evt = window.event;
+ //toEle = evt.toElement;
+ fromEle = evt.fromElement;
ele = evt.srcElement;
+ clientH = document.documentElement.clientHeight;
+ clientW = document.body.clientWidth;
}
- else {
+ else {//FF
evt = e;
+ fromEle = evt.relatedTarget;
+ //toEle = evt.relatedTarget;
ele = evt.target;
+ clientW = document.body.clientWidth;
+ clientH = document.documentElement.clientHeight;//window.innerHeight;
}
- if(ele.tagName =='A')
- ele = ele.parentNode;
- ele.style.border="1px inset yellow";
- ele.style.cursor="pointer";
+ try{
+ if (ele.tagName == 'A') {
+ if( contains(fromEle, ele) ) return;
+ ele = ele.parentNode;//get the parent div node
+ }else if( fromEle.tagName == 'A' ){
+ if( contains(ele, fromEle)) return;
+ }
+ }catch(err){
+ return;
+ }
+ var x = evt.clientX + 15, y = evt.clientY + 15;
+ var Karajanele = getEle(KarajanEleTree, pathJS);
+ if (Karajanele.description) {
+ promptwin.getComponent(0).setRawValue("Name:"+pathKarajan + "\nUsage:" + Karajanele["description"]);
+ promptwin.show();
+ }
+ if (x + winW > clientW - 20)//part of the window is beyond the client viewport
+ x = x - 30 - winW;
+ if (y + winH > clientH - 10)//part of the window is beyond the client viewport
+ y = y - 30 - winH ;
+ promptwin.setPagePosition(x, y);
+ ele.focus();
+ ele.style.border = "1px inset yellow";
+ ele.style.cursor = "pointer";
}
+function positionTip(e){
+ var evt, ele, relatedEle;
+ var clientH, clientW;
+ if (typeof(window.event) != "undefined") {//IE
+ evt = window.event;
+ relatedEle = evt.toElement;
+ ele = evt.srcElement;
+ clientH = document.documentElement.clientHeight;
+ clientW = document.body.clientWidth;
+ }
+ else {//FF
+ evt = e;
+ relatedEle = evt.relatedTarget;
+ ele = evt.target;
+ clientW = document.body.clientWidth;
+// clientH = window.innerHeight;
+ clientH = document.documentElement.clientHeight;
+ }
+ var winH = promptwin.height, winW = promptwin.width;
+ var x = evt.clientX + 15, y = evt.clientY + 15;
+ if (x + winW > clientW - 20)//part of the window is beyond the client viewport
+ x = x - 30 - winW;
+ if( y + winH > clientH -10 )
+ y = y - 30 - winH ;
+ promptwin.setPagePosition(x, y);
+}
+
function restoreEleIcon(e){
- var evt, ele;
- if (typeof(window.event) != "undefined") {
+ var evt, ele, toEle;
+ if (typeof(window.event) != "undefined") {//IE
evt = window.event;
+ toEle = evt.toElement;
ele = evt.srcElement;
}
- else {
+ else {//FF
evt = e;
+ toEle = evt.relatedTarget;
ele = evt.target;
}
- if(ele.tagName =='A')
- ele = ele.parentNode;
+ var fromATag = false;
+ try{
+ if (ele.tagName == 'A') {
+ fromATag = true;
+ if( contains(toEle, ele) ) return;
+ ele = ele.parentNode;
+ }else if (toEle.tagName == 'A'){
+ if( contains(ele, toEle) ) return;
+ }
+ }catch(err){
+ }
+ promptwin.hide();
+ if( ele.tagName != 'A' )
+ ele.style.border = "1px solid yellow";
+}
- ele.style.border="1px solid yellow";
-}
/**
* Create a widget window which provides toolbox used to ease composition of workflow.
* The layout is accordion.
@@ -309,21 +1023,25 @@
// bodyStyle: 'padding:5px;'
}
})
- addNStoWidgetWin(widgetWin, WFEleList, "");
+// addNStoWidgetWin(widgetWin, WFEleList, "","");
+ addNStoWidgetWin(widgetWin, KarajanEleTree.root, "","");
widgetWin.show();
widgetWin.collapse(false);
- widgetWin.setPosition( document.body.clientWidth-widgetWin.width,10);
+ widgetWin.setPosition( document.body.clientWidth-widgetWin.width-20,10);
return widgetWin;
}
/**
* When a user clicks a widget icon, this function is invoked.
- * @param {Object} fullelename name of the Karajan element (e.g. task.execute...)
+ * @param {Object} fullelename name of the Karajan element in the JS object(e.g. task.execute...)
* This is the full name which includes the namespace part.
+ * Note: this may be different from Karajan path.
+ * E.g. the parameter may be "sys.for_.each"
*/
-function widgetClick(fullelename){
- var win = createEditWin(fullelename, "myDiv");
- win.show();
+function widgetClick(fullelenameKarajan, fullelenameJS){
+ var win = createEditWin(fullelenameKarajan, fullelenameJS, "myDiv");
+ if( win != null )
+ win.show();
}
/********************************** End Widget Toolbox window related functions ***********************************/
@@ -336,18 +1054,18 @@
* @param {String} elename tag of the element(e.g. execute, transfer...).
* @param {Object} win parent window
*/
-function createEditPanel(elename, win){
- if (elename == null || elename == "")
+function createEditPanel(elenameKarajan, elenameJS, win){
+ if (elenameKarajan == null || elenameKarajan == "")
return;
- var wfele = getEle(WFEleList, elename);
+ var wfele = getEle(KarajanEleTree, elenameJS);
if (wfele == null)
return;
var panel = new Ext.FormPanel({
labelWidth: 75,
frame: true,
- title: 'Simple Form',
+ title: elenameKarajan,
bodyStyle: 'padding:5px 5px 0',
width: 350,
autoHeight: true,
@@ -377,7 +1095,7 @@
submit: function(){
//insert the element into the workflow description
var contentobj = panel.form.getValues();
- var resultxml = WFEleConstruct(elename, contentobj);
+ var resultxml = WFEleConstruct(elenameKarajan, contentobj);
insertEle2WF('workflow', resultxml);
win.hide();
}
@@ -405,16 +1123,30 @@
* @param {Object} resultxml xml content to be inserted.
*/
function insertEle2WF(eleid, resultxml){
+ var resultxmlpre = resultxml[0];
+ var resultxmlpost = resultxml[1];
+
node = document.getElementById(eleid);
if (node != null) {
- var len = caret(node);
+ var range = caret(node);
+ var start = range[0];
+ var end = range[1];
var text = node.value;
- var pre = text.substr(0, len);
- var post = text.substr(len);
+ var pre = text.substring(0, start);
+ var mid = text.substring(start, end);
+ var post = text.substring(end);
text = pre;
if (pre != "" && endWithNL(pre) == false)
text += "\n";
- text += resultxml;
+ text += resultxmlpre;
+
+ if (mid != "" && beginWithNL(mid) == false)
+ text += "\n";
+ text += mid;
+ if (mid != "" && endWithNL(mid) == false)
+ text += "\n";
+ text += resultxmlpost;
+
if (post != "" && beginWithNL(post) == false)
text += "\n";
text += post;
@@ -435,9 +1167,9 @@
* @param {Object} elename e.g. sys.echo, task.execute, sys.file.read
* @param {Object} renderEleId
*/
-function createEditWin(elename, renderEleId){
+function createEditWin(elenameKarajan, elenameJS, renderEleId){
//judge whether we have already had a window corresponding to this element
- var cache = eval("(EleWinList." + elename + ")");
+ var cache = eval("(EleWinList." + elenameJS + ")");
if (cache != null) {
return cache;
}
@@ -445,16 +1177,16 @@
/*If the element clicked does not have properties, just add the xml to output panel
*because it is not necessary to diaplay the edit panel.*/
- var wfele = getEle(WFEleList, elename);
+ var wfele = getEle(KarajanEleTree, elenameJS);
var props = wfele.properties;
if (props.length == 0) {
- var resultxml = WFEleConstruct(elename, {}, false);
+ var resultxml = WFEleConstruct(elenameKarajan, {}, false);
insertEle2WF('workflow', resultxml);
return;
}
var win = new Ext.Window({
- title: 'Grid Window',
+ title: 'Edit Window',
width: 350,
modal: true,
shim: false,
@@ -465,7 +1197,7 @@
layout: 'fit'
});
/* create a panel content of which depends on the element */
- var panel = createEditPanel(elename, win);
+ var panel = createEditPanel(elenameKarajan, elenameJS, win);
if (panel == null)
return win;
@@ -476,7 +1208,7 @@
});
//add it to global window list, so we don't need to create it next time.
- eval("(EleWinList." + elename + "=win)");
+ eval("(EleWinList." + elenameJS + "=win)");
return win;
}
/*************************** End Element property edit window related functions ****************************/
@@ -534,18 +1266,19 @@
*/
function WFEleConstruct(elefullname, obj, collaps){
var wffullname = elefullname.replace(".", ":", "g");//replace "." with ":"
- var result = "";
- result += "<" + wffullname;
+ var resultpre = "", resultpost = "";
+ resultpre += "<" + wffullname;
for (prop in obj) {
if (obj[prop] != "")
- result += " " + prop + "=\"" + obj[prop] + "\"";
+ resultpre += " " + prop + "=\"" + obj[prop] + "\"";
}
if (collaps == false) {
- result += ">\n</" + wffullname + ">";
+ resultpre += ">";
+ resultpost = "</" + wffullname + ">";
}
else
- result += "/>";
- return result;
+ resultpre += "/>";
+ return [resultpre, resultpost];
}
/**
@@ -557,7 +1290,7 @@
for (var i = 0; i < str.length; i++) {
if (str.charAt(i) == ' ' || str.charAt(i) == '\t')
continue;
- if (str.charAt(i) == '\n')
+ if (str.charAt(i) == '\n'||str.charAt(i) =='\r' )
return true;
else
return false;
@@ -610,7 +1343,7 @@
dump += result + "\n";
}
}
-buildEleWinList(WFEleList, "EleWinList");
+buildEleWinList(KarajanEleTree.root, "EleWinList");
// dumpAObj(EleWinList);
/**
@@ -622,17 +1355,17 @@
* Code here highly depends on the structure of object specified by parameter elelist.
* Now converts "sys.file.write" to "elelist.namespaces.sys.namespaces.file.elements.write".
*/
-function getEle(elelist, elename){
- var parts = elename.split(".");
+function getEle(KarajanEleTree, elenameJS){
+ var parts = elenameJS.split(".");
var len = parts.length;
var ns = parts.slice(0, len - 1).join(".namespaces.")
var elename = parts[len - 1];
var fullname = "";
if (ns == "") {
- fullname = elelist + ".elements." + elename;
+ fullname = KarajanEleTree + ".elements." + elename;
}
else
- fullname = elelist + ".namespaces." + ns + ".elements." + elename;
+ fullname = KarajanEleTree + ".namespaces." + ns + ".elements." + elename;
var ele = eval("(" + fullname + ")");
return ele;
-}
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-20 00:34:51
|
Revision: 1854
http://cogkit.svn.sourceforge.net/cogkit/?rev=1854&view=rev
Author: jenvor
Date: 2007-12-19 16:34:47 -0800 (Wed, 19 Dec 2007)
Log Message:
-----------
add visual widgets to east workflow composition
Modified Paths:
--------------
trunk/cyberaide/src/js/securelogin/cogkit/index.html
Added Paths:
-----------
trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js
Modified: trunk/cyberaide/src/js/securelogin/cogkit/index.html
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/index.html 2007-12-07 20:11:42 UTC (rev 1853)
+++ trunk/cyberaide/src/js/securelogin/cogkit/index.html 2007-12-20 00:34:47 UTC (rev 1854)
@@ -1,21 +1,51 @@
<html>
<head>
+ <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+ <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
+ <META HTTP-EQUIV="Expires" CONTENT="0">
+
<!---->
<script type='text/javascript' src='jsolait/jsolait.js'></script>
<script type='text/javascript' src='handler.js'></script>
+ <script type='text/javascript' src='wflist.js'></script>
<script type='text/javascript' src='xml2json.js'></script>
<script type='text/javascript' src='json2xml.js'></script>
+
+ <!-- add ext 2 -->
+ <link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/resources/css/ext-all.css"/>
+ <script src="http://extjs.com/deploy/dev/adapter/ext/ext-base.js"></script>
+ <script src="http://extjs.com/deploy/dev/ext-all.js"></script>
+
+ <script type='text/javascript' src="wfcomposition.js"> </script>
+ <script type='text/javascript'>
+ /* This piece of code adds visual widgets to ease workflow composition*/
+ Ext.onReady(function(){
+ //createBasicDesktop('workflowdiv');
+ createWidgetToolbox();
+ });
+ </script>
<script type='text/javascript'>
+ eof = 0;
function callback( response, exception ){
- clearTimeout(timer);
+ //clearTimeout(timer);
if ( exception != null )
alert( exception );
else {
output('resp', response);
}
}
-
+ function statuscallback( response, exception ){
+ //clearTimeout(timer);
+ if ( exception != null )
+ alert( exception );
+ else {
+ if(eof == 1){
+ response += "\n------- Job Completed -------\n";
+ }
+ output('resp', response);
+ }
+ }
function getInput( eleid ){
var workflow = document.getElementById( eleid );
if( workflow == null ){
@@ -30,44 +60,89 @@
alert( 'please specify an output element' );
return;
}
- res.value = result;
+ res.value = res.value+"\n-------------------------------------------------\n"+result;
}
function echo(){
var str = getInput("workflow");
var result = COGHandler.executeMethods( "Handler.echo", str, callback );
- if( result != undefined ){
- //display output to user
- output('resp', result);
- }
}
function wsecho(){
var str = getInput("workflow");
var result = COGHandler.executeMethods( "WSHandler.echo", str , callback );
- if( result != undefined ){
- //display output to user
- output('resp', result);
- }
}
function wfhandle(){
- var str = getInput("workflow");
- var result = COGHandler.executeMethods( "Handler.cmdCOGExecute", str, callback );
+ var workflow = getInput("workflow");
+ var result = COGHandler.executeMethods( "Handler.cmdCOGExecute", workflow, callback );
if( result != undefined ){
//display output to user
output('resp', result);
}
}
+
+ /*
+ * submit workflow to agent server
+ */
+ function statusquerycallback( response, exception ){
+ if ( exception != null )
+ alert( exception );
+ else {
+ output('resp', response);
+ }
+ }
function wswfhandle(){
- var str = getInput("workflow");
- var result = COGHandler.executeMethods( "WSHandler.cmdCOGExecute", str, callback );
+ var workflow = getInput("workflow");
+ var result = COGHandler.executeMethods( "WSHandler.WFSubmit", "test", workflow, statusquerycallback );
+
+ //after workflow is submitted, we periodically check state of the workflow.
+ eof = 0;
+ //setTimeout(checkStatus, 1000*3);
+ }
+
+ function checkStatus(){
+ //COGHandler.executeMethods("Handler.checkStatus", statuscallback);
+ COGHandler.executeMethods("WSHandler.getStatusByUID", "test", callback);
+ if( eof == 1 ) {
+ return;
+ }
+ //setTimeout(arguments.callee, 3*1000);
+ }
+
+ /** This function is used to get state of all workflows owned by a specified user */
+ function stateRetrieveCB(response, exception){
+ if ( exception != null )
+ alert( exception );
+ else {
+ if( response == "No workflow found" ){
+ output('resp', response);
+ }else{
+ var list = new WFList( response );
+ var str = list.format();
+ output('resp', str);
+ }
+ }
+ }
+ function stateRetrieve(){
+ COGHandler.executeMethods("WSHandler.getStatusByUID", "test", stateRetrieveCB);
+ }
+
+ /*
+ function wswfhandlewithstatus(){
+ var workflow = getInput("workflow");
+ var username = "testuser";
+ var result = COGHandler.executeMethods( "WSHandler.WFSubmit", username, workflow, callback );
if( result != undefined ){
//display output to user
output('resp', result);
}
}
+ */
+
function clearoutput(){
var output = document.getElementById( 'resp' );
output.value = "";
}
+
+ /* this function convert json to xml */
function zhguoj2x(){
var str = getInput("workflow");
//str = "a:{\"b\":\"bbb\"}}";
@@ -77,12 +152,14 @@
var xml = json2xml( json, " ");
output( 'resp', xml );
}
+ /* this function convert xml to json */
function zhguox2j(){
var str = getInput("workflow");
var dom = parseXml( str );
var json = xml2json( dom, " " );
output( 'resp', json );
}
+
function parseXml(xml) {
var dom = null;
if (window.DOMParser) {
@@ -96,7 +173,6 @@
dom = new ActiveXObject('Microsoft.XMLDOM');
dom.async = false;
if (!dom.loadXML(xml)) // parse error ..
-
window.alert(dom.parseError.reason + dom.parseError.srcText);
}
catch (e) { dom = null; }
@@ -106,13 +182,133 @@
return dom;
}
</script>
+ <script type="text/javascript">
+ // Following code display a window to display sample workflow
+ // currently, just support IE and Firefox.
+ function diagShow(e){
+ var wftextareaid = "wfsample";
+ var ele = document.getElementById(wftextareaid);
+ var evt = e, xcord, ycord;
+ //alert(typeof(e));
+ if( typeof( window.event ) != "undefined" ){
+ //IE
+ evt = window.event;
+ xcord = evt.clientX;
+ ycord = evt.clientY;
+ ele.style.display="block";
+ ele.style.position = "absolute";
+ ele.style.left = xcord+"px";
+ ele.style.top = ycord+"px";
+ //ele.value=sampleWF;
+ }else{//currently, I think it is Firefox
+ xcord = evt.clientX;
+ ycord = evt.clientY;
+ elestyle = "display:block;position:absolute;left:"+xcord+"px;top:"+ycord+";";
+ ele.setAttribute("style", elestyle);
+ //ele.value=sampleWF;
+ }
+ ele.focus();
+ }
+
+ function diagHide(e){
+ var wftextareaid = "wfsample";
+ var ele = document.getElementById(wftextareaid);
+ var evt = e;
+ if( typeof( window.event ) != "undefined" ){
+ ele.style.display = "none";
+ }else{
+ ele.setAttribute("style", "display:none;");
+ }
+ }
+ </script>
+
+ <script type="text/javascript">
+ /* When the output textarea is too small to display response from server,
+ * this function adjustes size of the textarea to contain more content.
+ * Note:
+ * Currently, only IE and Firefox are supported.
+ */
+ function adjustTextArea(e){
+ var evt = e, xcord, ycord, rows;
+ var hiddenOutputId = "hiddenOutputArea";
+ var hiddenele = document.getElementById(hiddenOutputId);
+ var ele = document.getElementById('resp');
+ var clientwidth = document.body.clientWidth;
+ var clientheight = document.body.clientHeight;
+ var leftMargin = 50, topMargin = 50;
+
+ if( typeof( window.event ) != "undefined" ){
+ //IE
+ evt = window.event;
+ //ele = evt.srcElement;
+ if(ele.clientHeight < ele.scrollHeight ){
+ //ele.style.posHeight = ele.scrollHeight+5;
+ hiddenele.style.display="block";
+ hiddenele.style.position = "absolute";
+ hiddenele.style.left = leftMargin+"px";
+
+ if( clientheight - topMargin < ele.scrollHeight ){
+ hiddenele.style.posHeight = clientheight - topMargin - 10;
+ hiddenele.style.posTop = topMargin;
+ }else{
+ hiddenele.style.posHeight = ele.scrollHeight+5;
+ hiddenele.style.posTop = (clientheight - ele.scrollHeight)/2;
+ }
+ hiddenele.style.posWidth = clientwidth - 2*leftMargin;
+ hiddenele.focus();
+ }
+ }else{//currently, I think it is Firefox
+ //ele = evt.target;
+ if( ele.clientHeight < ele.scrollHeight ){
+ //ele.style.height = ele.scrollHeight+5;
+ var style = "display:block;position:absolute;left:30px;top:80;";
+ //hiddenele.setAttribute("style",style);
+ hiddenele.style.height = ele.scrollHeight+5;
+
+ hiddenele.style.display="block";
+ hiddenele.style.position = "absolute";
+ hiddenele.style.left = leftMargin+"px";
+
+ if( clientheight - topMargin < ele.scrollHeight ){
+ hiddenele.style.height = clientheight - topMargin - 10;
+ hiddenele.style.top = topMargin;
+ }else{
+ hiddenele.style.height = ele.scrollHeight+5;
+ hiddenele.style.top = (clientheight - ele.scrollHeight)/2;
+ }
+ hiddenele.style.width = clientwidth - 2*leftMargin;
+ hiddenele.focus();
+ }
+ }
+ hiddenele.value = ele.value;
+ }
+ </script>
</head>
<body>
+
<div>
+ <span style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow Sample</span>
+
+ <input type="button" value="click to see sample" onClick="javascript:diagShow(event);"/>
+ <div><textarea rows=15 cols=100 wrap='off' id="wfsample" style="display:none;" onBlur="javascript:diagHide(event);">
+<project>
+ <include file="cogkit.xml"/>
+ <execute executable="/bin/rm" arguments="-f thedate" host="gf1.ucs.indiana.edu" provider="GT2" redirect="false"/>
+ <execute executable="/bin/date" stdout="thedate" host="gf1.ucs.indiana.edu" provider="GT2" redirect="false"/>
+ <transfer srchost="gf1.ucs.indiana.edu" srcfile="thedate" desthost="localhost" provider="gridftp"/>
+ <set name="date">
+ <readFile file="thedate"/>
+ </set>
+ <echo message="The date is {date}"/>
+</project>
+</textarea></div>
+ </div>
+ <div>
<div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Workflow description:</div>
<table>
<tr><td>
<textarea id='workflow' wrap='off' cols=100 rows=15 ></textarea>
+ <!-- <div id='workflowdiv'></div> -->
<td><td valign=top>
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='Regular echo' onclick='javascript:echo();'></input>
@@ -120,13 +316,16 @@
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='WS echo' onclick='javascript:wsecho();'></input>
</div>
- <div style='padding-top:10px;padding-bottom:10px'>
+ <div style='padding-top:10px;padding-bottom:10px;display:none'>
<input type='button' value='Workflow Handle' onclick='javascript:wfhandle();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
- <input type='button' value='WS Workflow Handle' onclick='javascript:wswfhandle();'></input>
+ <input type='button' value='WS Workflow Submission' onclick='javascript:wswfhandle();'></input>
</div>
<div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='Get State of All Workflows' onclick='javascript:stateRetrieve();'></input>
+ </div>
+ <div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='JSON2XML' onclick='javascript:zhguoj2x();'></input></div>
<div style='padding-top:10px;padding-bottom:10px'>
<input type='button' value='XML2JSON' onclick='javascript:zhguox2j();'></input>
@@ -138,11 +337,17 @@
<div style='font-size:large; padding-top:0.3em; padding-bottom:0.3em; color:blue;'>Response from server:</div>
<table>
<tr><td>
- <textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'></textarea>
+ <textarea WRAP='off' id='resp' cols=100 rows=15 readOnly='true'>
+ </textarea>
<td><td valign=top>
<input type='button' value='clear' onclick='javascript:clearoutput();'></input>
+
+ <div style='padding-top:10px;padding-bottom:10px'>
+ <input type='button' value='magnify' onclick='javascript:adjustTextArea(event);'></input>
+ </div>
</td></tr>
</table>
</div>
+ <textarea style="display:none" id="hiddenOutputArea" onblur="javascript:this.style.display='none';"></textarea>
</body>
</html>
Added: trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js
===================================================================
--- trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js (rev 0)
+++ trunk/cyberaide/src/js/securelogin/cogkit/wfcomposition.js 2007-12-20 00:34:47 UTC (rev 1854)
@@ -0,0 +1,638 @@
+/**
+ * This file contains javascript code to support Karajan workflow composition.
+ * The work is based on Ext2(http://extjs.com).
+ * @author gerald
+ * @LastModified: Dec 19 2007
+ */
+
+function caret(node){
+ if (node.selectionStart)
+ return node.selectionStart;
+ else
+ if (!document.selection)
+ return 0;
+ //node.focus();
+ var c = "\001";
+ var sel = document.selection.createRange();
+ var txt = sel.text;
+ var dul = sel.duplicate();
+ var len = 0;
+ try {
+ dul.moveToElementText(node);
+ }
+ catch (e) {
+ return 0;
+ }
+ sel.text = txt + c;
+ len = (dul.text.indexOf(c));
+ sel.moveStart('character', -1);
+ sel.text = "";
+ return len;
+}
+
+/**
+ * This object contains all elements that Karajan workflow supports.
+ */
+var WFEleList = {
+ elements: {},
+ namespaces: {
+ sys: {
+ namespaces: {
+ file: {
+ elements: {
+ read: {
+ properties: ["name"],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ },
+ write: {
+ properties: ["name", "append"],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ },
+ contains: {
+ properties: ["file", "value"],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ }
+ },
+ namespace: {}
+ }
+ },
+ elements: {
+ execute: {
+ properties: ["executable", "host", "stdout", "provider", "redirect"],
+ widgetProps: {
+ iconUrl: "images/1.jpg"
+ //other properties: id, height, width. all these properties can be
+ //generated automatically. In other words, you don't need to specify
+ //them. However, you can set them if you wish.
+ }
+ },
+ echo: {
+ properties: ["message", "nl"],
+ widgetProps: {
+ iconUrl: "images/3.jpg"
+ }
+ },
+ parallel: {
+ properties: [],
+ widgetProps: {
+ iconUrl: "images/5.jpg"
+ }
+ },
+ sequential: {
+ properties: [],
+ widgetProps: {
+ iconUrl: "images/6.jpg"
+ }
+ }
+ }
+ },
+ task: {
+ elements: {
+ execute: {
+ properties: ["executable", "host", "stdout", "provider", "redirect"],
+ widgetProps: {
+ iconUrl: "images/10.jpg"
+ //other properties: id, height, width. all these properties can be
+ //generated automatically. In other words, you don't need to specify
+ //them. However, you can set them if you wish.
+ }
+ },
+ transfer: {
+ properties: ["srchost", "srcdir", "srcfile", "desthost", "destdir", "destfile", "provider"],
+ widgetProps: {
+ iconUrl: "images/2.jpg"
+ }
+ }
+ },
+ namespaces: {}
+ }
+ }
+};
+
+WFEleList.toString = function(){
+ return "WFEleList";
+}
+
+
+/********************************** Widget Toolbox window related functions ***********************************/
+/**
+ * This function is used to add icons for elements specified by nsobj to panel widgetWin.
+ * @param {Object} widgetWin parent window
+ * @param {Object} nsobj contains the element information.
+ * It looks like: {elements:{ele1:{},ele2:{}},namespace:{ns1:{},ns2:{}}}.
+ * It contains two parts: elements and sub namespaces.
+ * Actually, this is part of WFEleList.
+ * @param {Object} base namespace we are working on. e.g. sys.file
+ */
+function addNStoWidgetWin(widgetWin, nsobj, base){
+ var namespaces = "namespaces", elements = "elements";
+ var nslist = nsobj[namespaces], elelist = nsobj[elements];
+ var eletitle = base + " elements", nstitle = base + " namespace";
+ if (base == "") {
+ eletitle = "root elements";
+ nstitle = "root namespace";
+ }
+ var nslevel = getNSCount(base);
+ for (var i = 0; i < nslevel; i++) {
+ eletitle = "--" + eletitle;
+ nstitle = "--" + nstitle;
+ }
+ eletitle = "+" + eletitle;
+ nstitle = "+" + nstitle;
+
+ /** First add elements in this namespace.
+ * Step 1: create a accordion panel;
+ * Step 2: add every element in this namespace to the newly created accordion panel
+ */
+ var accordionele = new Ext.Panel({
+ title: eletitle,
+ layout: 'table',
+ layoutConfig: {
+ columns: 3
+ },
+ border: false,
+ defaults: {
+ bodyStyle: 'margin:5px;'
+ }
+ });
+ widgetWin.add(accordionele);
+
+ for (elename in elelist) {
+ var eleid = "widget_" + elename;
+ var ele = elelist[elename];
+ var widgetprops = ele.widgetProps;
+ var clickHandler = "";
+ if (base == "")
+ clickHandler = "javascript:widgetClick('" + elename + "');";
+ else
+ clickHandler = "javascript:widgetClick('" + base + "." + elename + "');";
+ var defaultConfig = {
+ height: "40px",
+ width: "60px",
+ id: eleid,
+ onClick: clickHandler
+ };
+ Ext.applyIf(widgetprops, defaultConfig);
+
+ //construct html markup based on the configuration
+ // var html = "<div style=\"background-image:url("+widgetprops.iconUrl+");width:40px;height:40px;\">"+elename+"</div>"
+ var html = "<div style=\"";
+ html += "width:" + widgetprops.width + "; text-align:center;vertical-align:middle;line-height:2em;";
+ html += "height:" + widgetprops.height + ";";
+ html += "\"";
+ html += " onmouseover=\""+"javascript:highlightEleIcon(event);"+"\"";
+ html += " onmouseout=\""+"javascript:restoreEleIcon(event);"+"\"";
+ html += " onClick=\"" + widgetprops.onClick + "\"";
+ html += ">";
+ html += "<a href=\"#\"";
+ html += ">"+elename + "</a>";
+ html += "</div>";
+// var html = "<input type=\"image\" alt=\"[*]\" style=\"";
+// html += "height:" + widgetprops.height + ";";
+// html += "width:" + widgetprops.width + ";";
+// html += "\"";
+// html += " src=\"" + widgetprops.iconUrl + "\"";
+// html += "onmouseover=\""+"javascript:highlightEleIcon(event);"+"\"";
+// html += " onmouseout=\""+"javascript:restoreEleIcon(event);"+"\"";
+// html += " onClick=\"" + widgetprops.onClick + "\">" + "<br>"+elename + "</input>";
+ // var html = "<img src=\"";
+ // html += widgetprops.iconUrl;
+ // html += "\" id=\"";
+ // html += widgetprops.id;
+ // html += "\" height=\"";
+ // html += widgetprops.height;
+ // html += "\" width=\"";
+ // html += widgetprops.width;
+ // html += "\" onClick=\"";
+ // html += widgetprops.onClick;
+ // html += "\" >"
+ // html += elename;
+ // html = "<div style=\"border:1px solid;background-color:#abc;\">"+html+"</div>"
+ var iconPanel = new Ext.Panel({
+ html: html,
+ border: true,
+ bodyBorder: false
+ });
+ accordionele.add(iconPanel);
+ }
+
+ /**
+ * Then handle inner namespace.
+ * Step 1: create a accordion panel for sub namespace.
+ * Step 2: recursively add stuff to the newly created panel.
+ */
+ var nsaccordionele = new Ext.Panel({
+ title: nstitle,
+ layout: 'accordion',
+ collapsible: true,
+ shim: false,
+ animCollapse: true,
+ layoutConfig: {
+ columns: 3
+ },
+ defaults: { //bodyStyle: 'margin:5px;'
+ },
+ layoutConfig: {
+ animate: true,
+ activeOnTop: false,
+ titleCollapse: true
+ }
+ });
+
+ widgetWin.add(nsaccordionele);
+ for (ns in nslist) {
+ var newbase = base + "." + ns;
+ if (base == "")
+ newbase = ns;
+ arguments.callee(nsaccordionele, nslist[ns], newbase);
+ }
+}
+function highlightEleIcon(e){
+ var evt, ele;
+ if (typeof(window.event) != "undefined") {
+ evt = window.event;
+ ele = evt.srcElement;
+ }
+ else {
+ evt = e;
+ ele = evt.target;
+ }
+ if(ele.tagName =='A')
+ ele = ele.parentNode;
+ ele.style.border="1px inset yellow";
+ ele.style.cursor="pointer";
+}
+
+function restoreEleIcon(e){
+ var evt, ele;
+ if (typeof(window.event) != "undefined") {
+ evt = window.event;
+ ele = evt.srcElement;
+ }
+ else {
+ evt = e;
+ ele = evt.target;
+ }
+ if(ele.tagName =='A')
+ ele = ele.parentNode;
+
+ ele.style.border="1px solid yellow";
+}
+/**
+ * Create a widget window which provides toolbox used to ease composition of workflow.
+ * The layout is accordion.
+ */
+function createWidgetToolbox(){
+ var widgetWin = new Ext.Window({
+ title: 'Widget Toolbox',
+ height: 600,
+ width: 300,
+ collapsible: true,
+ closable: false,
+ shim: false,
+ animCollapse: true,
+ constrainHeader: true,
+
+ layout: 'accordion',
+ layoutConfig: {
+ animate: true,
+ activeOnTop: false,
+ titleCollapse: true
+ },
+ defaults: { // bodyStyle: 'margin:5px;'
+ // bodyStyle: 'padding:5px;'
+ }
+ })
+ addNStoWidgetWin(widgetWin, WFEleList, "");
+ widgetWin.show();
+ widgetWin.collapse(false);
+ widgetWin.setPosition( document.body.clientWidth-widgetWin.width,10);
+ return widgetWin;
+}
+
+/**
+ * When a user clicks a widget icon, this function is invoked.
+ * @param {Object} fullelename name of the Karajan element (e.g. task.execute...)
+ * This is the full name which includes the namespace part.
+ */
+function widgetClick(fullelename){
+ var win = createEditWin(fullelename, "myDiv");
+ win.show();
+}
+/********************************** End Widget Toolbox window related functions ***********************************/
+
+
+/********************************** Element property edit window related functions ***********************************/
+/**
+ * creae a edit panel for a certain Karajan workflow element. Content of the panel
+ * depends on the element specified by parameter elename.
+ * e.g. execute, transfer,...
+ * @param {String} elename tag of the element(e.g. execute, transfer...).
+ * @param {Object} win parent window
+ */
+function createEditPanel(elename, win){
+ if (elename == null || elename == "")
+ return;
+
+ var wfele = getEle(WFEleList, elename);
+ if (wfele == null)
+ return;
+
+ var panel = new Ext.FormPanel({
+ labelWidth: 75,
+ frame: true,
+ title: 'Simple Form',
+ bodyStyle: 'padding:5px 5px 0',
+ width: 350,
+ autoHeight: true,
+ defaults: {
+ width: 200
+ },
+ buttons: [{
+ text: 'Save',
+ type: 'submit',
+ handler: function(){
+ panel.form.submit();
+ }
+ }, {
+ text: 'clear',
+ type: 'reset',
+ handler: function(){
+ panel.form.reset();
+ }
+ }, {
+ text: 'cancel',
+ handler: function(){
+ win.hide();
+ }
+ }],
+
+ onSubmit: Ext.emptyFn,
+ submit: function(){
+ //insert the element into the workflow description
+ var contentobj = panel.form.getValues();
+ var resultxml = WFEleConstruct(elename, contentobj);
+ insertEle2WF('workflow', resultxml);
+ win.hide();
+ }
+ });
+
+ /**
+ * add a form field for every property of the element.
+ */
+ var props = wfele.properties;
+ Ext.each(props, function(prop, index){
+ var field = new Ext.form.Field({
+ fieldLabel: prop,
+ name: prop
+ });
+ panel.add(field);
+ });
+
+ return panel;
+}
+
+/**
+ * Insert a piece of xml document into a html element. The xml content is not simply appended
+ * to the html element. Instead, it is inserted into current position.
+ * @param {Object} eleid id of html element into which the xml content will be inserted.
+ * @param {Object} resultxml xml content to be inserted.
+ */
+function insertEle2WF(eleid, resultxml){
+ node = document.getElementById(eleid);
+ if (node != null) {
+ var len = caret(node);
+ var text = node.value;
+ var pre = text.substr(0, len);
+ var post = text.substr(len);
+ text = pre;
+ if (pre != "" && endWithNL(pre) == false)
+ text += "\n";
+ text += resultxml;
+ if (post != "" && beginWithNL(post) == false)
+ text += "\n";
+ text += post;
+ node.value = text;
+ node.focus();
+ }
+}
+
+/**
+ * Create a window for a certain element(e.g. task.execute) of Karajan workflow.
+ * This window is used by users to edit properties of the element.
+ * Internally, a panel is created by invoking function createPanel().
+ * Note:
+ * When the window is closed, it is hidden actually. In other words,
+ * the window is not removed from the dom tree. This is done to enhance
+ * performance so that in following invocation createEleWin we don't need
+ * to create a new window.
+ * @param {Object} elename e.g. sys.echo, task.execute, sys.file.read
+ * @param {Object} renderEleId
+ */
+function createEditWin(elename, renderEleId){
+ //judge whether we have already had a window corresponding to this element
+ var cache = eval("(EleWinList." + elename + ")");
+ if (cache != null) {
+ return cache;
+ }
+ //Here, cache miss, we need to create a new window.
+
+ /*If the element clicked does not have properties, just add the xml to output panel
+ *because it is not necessary to diaplay the edit panel.*/
+ var wfele = getEle(WFEleList, elename);
+ var props = wfele.properties;
+ if (props.length == 0) {
+ var resultxml = WFEleConstruct(elename, {}, false);
+ insertEle2WF('workflow', resultxml);
+ return;
+ }
+
+ var win = new Ext.Window({
+ title: 'Grid Window',
+ width: 350,
+ modal: true,
+ shim: false,
+ animCollapse: true,
+ constrainHeader: true,
+ collapsible: true,
+ closeAction: 'hide',
+ layout: 'fit'
+ });
+ /* create a panel content of which depends on the element */
+ var panel = createEditPanel(elename, win);
+ if (panel == null)
+ return win;
+
+ win.add(panel);
+ //we need to clear the content in the fields before hidding the element
+ win.on('beforehide', function(){
+ panel.getForm().reset();
+ });
+
+ //add it to global window list, so we don't need to create it next time.
+ eval("(EleWinList." + elename + "=win)");
+ return win;
+}
+/*************************** End Element property edit window related functions ****************************/
+
+function createBasicDesktop(htmleleid){
+ var desktop = new Ext.form.TextArea({
+ id: "workflow",
+ renderTo: htmleleid,
+ grow: true,
+ growMax: 300,
+ growMin: 150,
+ width: 500,
+ value: "hello,world"
+ });
+// new Ext.Panel({
+// // title: 'Border Layout',
+// layout: 'fit',
+// height: 300,
+// renderTo: 'myDiv',
+// items: [{
+// title: 'Main Content',
+// margins: '5 0 0 0',
+// items: new Ext.form.TextArea({
+// id: "workflow",
+// grow: true,
+// growMax: 300,
+// growMin: 150,
+// width: 500,
+// value: "hello,world"
+// })
+// }]
+// });
+}
+
+
+/*************************** Auxiliary functions ****************************/
+/**
+ * @param {Object} str fullname of an element. e.g. sys.file.write
+ */
+function getNSCount(str){
+ if (str == "")
+ return 0;
+ return str.split(".").length;
+}
+
+/**
+ * This function is used to construct a piece of xml document. If value of a certain
+ * property is empty, the property is not included.
+ * @param {Object} elefullname tag of the element. This is the full name. For example, task.execute
+ * @param {Object} obj it contains the properties and values of the element. Type is object, not string!!
+ * @param {Object} collaps indicates the format of generated xml element. If it is true, generated xml
+ * looks like "<ele prop=233/>"; else "<ele prop=233></ele>"
+ * Note:
+ * currently, all values of properties are enclosed by double quotation marks("). This is not correct always.
+ */
+function WFEleConstruct(elefullname, obj, collaps){
+ var wffullname = elefullname.replace(".", ":", "g");//replace "." with ":"
+ var result = "";
+ result += "<" + wffullname;
+ for (prop in obj) {
+ if (obj[prop] != "")
+ result += " " + prop + "=\"" + obj[prop] + "\"";
+ }
+ if (collaps == false) {
+ result += ">\n</" + wffullname + ">";
+ }
+ else
+ result += "/>";
+ return result;
+}
+
+/**
+ * judge whether a string begins with new line character.
+ * Blankspace and tabspace are both ignored.
+ * @param {String} str
+ */
+function beginWithNL(str){
+ for (var i = 0; i < str.length; i++) {
+ if (str.charAt(i) == ' ' || str.charAt(i) == '\t')
+ continue;
+ if (str.charAt(i) == '\n')
+ return true;
+ else
+ return false;
+ }
+ return false;
+}
+/**
+ * judge whether a string ends with new line character.
+ * Blankspace and tabspace are both ignored.
+ * @param {String} str
+ */
+function endWithNL(str){
+ for (var i = str.length - 1; i >= 0; i--) {
+ if (str.charAt(i) == ' ' || str.charAt(i) == '\t')
+ continue;
+ if (str.charAt(i) == '\n')
+ return true;
+ else
+ return false;
+ }
+ return false;
+}
+
+EleWinList = {};
+
+function buildEleWinList(list, base){
+ var nselename = "namespaces";
+ var elename = "elements";
+ var ns = list[nselename];
+ for (prop in ns) {
+ var newbase = base + "." + prop;
+ eval(newbase + "={}");
+ arguments.callee(ns[prop], newbase);
+ }
+}
+
+var dump = "";
+function dumpAObj(obj){
+ dumpObj(obj, "", "");
+}
+
+function dumpObj(obj, result, total){
+ var count = 0;
+ for (prop in obj) {
+ var str = result + "." + prop;
+ dumpObj(obj[prop], str, total);
+ count++;
+ }
+ if (count == 0) {
+ dump += result + "\n";
+ }
+}
+buildEleWinList(WFEleList, "EleWinList");
+// dumpAObj(EleWinList);
+
+/**
+ * Get the the element whose name is specified by parameter elename from elelist.
+ * @param {Object} Now, this parameter is WFEleList which contains all elements supported
+ * by Karajan.
+ * @param {String} elename full name of an element, e.g. sys.file.write, executefile
+ * Note:
+ * Code here highly depends on the structure of object specified by parameter elelist.
+ * Now converts "sys.file.write" to "elelist.namespaces.sys.namespaces.file.elements.write".
+ */
+function getEle(elelist, elename){
+ var parts = elename.split(".");
+ var len = parts.length;
+ var ns = parts.slice(0, len - 1).join(".namespaces.")
+ var elename = parts[len - 1];
+ var fullname = "";
+ if (ns == "") {
+ fullname = elelist + ".elements." + elename;
+ }
+ else
+ fullname = elelist + ".namespaces." + ns + ".elements." + elename;
+ var ele = eval("(" + fullname + ")");
+ return ele;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fug...@us...> - 2007-12-07 20:11:51
|
Revision: 1853
http://cogkit.svn.sourceforge.net/cogkit/?rev=1853&view=rev
Author: fugangwang
Date: 2007-12-07 12:11:42 -0800 (Fri, 07 Dec 2007)
Log Message:
-----------
add notes for the Dec 7 meeting
Added Paths:
-----------
trunk/cyberaide/doc/meetingDec7.doc
Added: trunk/cyberaide/doc/meetingDec7.doc
===================================================================
(Binary files differ)
Property changes on: trunk/cyberaide/doc/meetingDec7.doc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <je...@us...> - 2007-12-07 05:39:58
|
Revision: 1852
http://cogkit.svn.sourceforge.net/cogkit/?rev=1852&view=rev
Author: jenvor
Date: 2007-12-06 21:39:56 -0800 (Thu, 06 Dec 2007)
Log Message:
-----------
add state service, modify executor implementation
Modified Paths:
--------------
trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java
trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java
trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterface.java
trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java
Added Paths:
-----------
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java
trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
Modified: trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java 2007-12-05 05:06:57 UTC (rev 1851)
+++ trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerClient.java 2007-12-07 05:39:56 UTC (rev 1852)
@@ -14,30 +14,72 @@
import java.io.File;
import java.io.BufferedWriter;
+import java.io.BufferedReader;
import java.io.FileWriter;
+import java.io.FileReader;
+import java.io.FileOutputStream;
import java.io.FileInputStream;
+import java.io.StringWriter;
+
import java.util.Properties;
+import java.util.ArrayList;
+import java.util.HashMap;
import org.cogkit.cyberaide.axis2ws.SimpleHandlerInterfaceStub.Echo;
import org.cogkit.cyberaide.axis2ws.SimpleHandlerInterfaceStub.EchoResponse;
import org.cogkit.cyberaide.axis2ws.SimpleHandlerInterfaceStub.CmdCOGExecute;
import org.cogkit.cyberaide.axis2ws.SimpleHandlerInterfaceStub.CmdCOGExecuteResponse;
+import org.cogkit.cyberaide.axis2ws.SimpleHandlerInterfaceStub.CmdWFSubmit;
+import org.cogkit.cyberaide.axis2ws.SimpleHandlerInterfaceStub.CmdWFSubmitResponse;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
-public class SimpleHandlerClient{
- private String prefix = "(This is done by using Web servie)\n";
- private String propertiesFile = "webservice.properties";
- private String wsendpoint = "";
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.AddWorkflowFromString;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.GetJSONStatusByUID;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.GetJSONStatusByUIDResponse;
+
+public class SimpleHandlerClient implements SimpleHandlerClientInterface{
+ private static String prefix = "(This is done by using Web service)\n";
+ //private static String propertiesFile = "/home/tomcat/apache-tomcat-6.0.14/webapps/webservice.properties";
+ private static String propertiesFile = "/home/tomcat/apache-tomcat-6.0.14/webapps/agent.properties";
+ private static String wsendpoint = "";
+ private static StatusServiceNotifier _notifier = new StatusServiceNotifier();
+ private static AgentWFDB _agentDb = null;
+ private static SimpleHandlerInterfaceStub stub = null;
+
public SimpleHandlerClient(){
try{
- Properties prop = new Properties();
- prop.load( new FileInputStream( propertiesFile ) );
- String endpoint = prop.getProperty( "serviceendpoint" );
- if( endpoint == null ){
- System.out.println( "you must specify 'serviceendpoint' property in file service.properties" );
- }else{
- wsendpoint = endpoint;
+ //open property file specified by propertiesFile
+ File propfile = new File(propertiesFile);
+ if( propfile.exists() == false ){
+ System.out.println("property file: "+propertiesFile+" does not exist!");
+ return ;
+ }
+
+ // get service end point
+ Properties prop = new Properties();
+ prop.load( new FileInputStream( propertiesFile ) );
+ String endpoint = prop.getProperty( "serviceendpoint" );
+ if( endpoint == null ){
+ System.out.println( "you must specify 'serviceendpoint' property in file service.properties" );
+ }else{
+ wsendpoint = endpoint;
+ stub = new SimpleHandlerInterfaceStub(wsendpoint);
+ }
+
+ if( _agentDb == null ){
+ String dbfile = prop.getProperty("agentdb");
+ _agentDb = new AgentWFDB(dbfile);
}
}catch( Exception e ){
System.out.println( e.toString() );
@@ -57,9 +99,6 @@
br.write( input );
br.close();
- //call the corresponding web service
- //SimpleHandlerInterfaceStub stub = new SimpleHandlerInterfaceStub("http://localhost:8080/axis2/services/SimpleHandler");
- SimpleHandlerInterfaceStub stub = new SimpleHandlerInterfaceStub(wsendpoint);
Echo req = new Echo();
req.setParam0( input );
EchoResponse resp = new EchoResponse();
@@ -72,27 +111,33 @@
}
/**
- * @param input workflow description which is represented by a string
+ * @param workflow workflow description which is represented by a string
* This invokes remote 'cmdCOGExecute' web service which will return a string.
* <b>Note</b>: the workflow description from user is logged in file <b>/tmp/workflow.xml</b>.
*/
public String cmdCOGExecute( String workflow ){
String output = "";
try {
+ String oldWF = workflow;
+ WorkflowTransformer transformer = new WorkflowTransformer();
+ transformer.LoadFromString(workflow);
+ workflow = transformer.getNewWF();
+
String filename = "/tmp/workflow.xml";
File recordfile = new File(filename);
BufferedWriter br = new BufferedWriter(new FileWriter(recordfile));
br.write(workflow);
br.close();
- //call the corresponding web service
- //SimpleHandlerInterfaceStub stub = new SimpleHandlerInterfaceStub("http://localhost:8080/axis2/services/SimpleHandler");
- SimpleHandlerInterfaceStub stub = new SimpleHandlerInterfaceStub(wsendpoint);
+ //send this workflow to status server
+ _notifier.addWorkFlowFromString("user1", "file1", oldWF);
+
CmdCOGExecute req = new CmdCOGExecute();
req.setParam0( workflow );
CmdCOGExecuteResponse resp = new CmdCOGExecuteResponse();
resp = stub.cmdCOGExecute( req );
output = resp.get_return();
+
} catch (IllegalThreadStateException e) {
return e.toString();
} catch (Exception e){
@@ -100,4 +145,482 @@
}
return prefix + output;
}
+ /**
+ */
+ public String WFSubmit(String username, String workflow){
+ String result = "", myprefix = "(This is done by using web service with status monitoring enabled)\n";
+ if( username.compareTo("")==0 ){
+ result = "You must specify your username!!";
+ return result;
+ }
+ System.out.println("this id received by WFSubmit method");
+ //TODO
+ //check whether the user exists in the system
+ //how to generate the wfid
+ String output = "", wfid = _agentDb.addWF( username );
+ try {
+ String oldWF = workflow;
+ WorkflowTransformer transformer = new WorkflowTransformer();
+ transformer.LoadFromString(workflow);
+ workflow = transformer.getNewWF();
+
+ //send this workflow to status server
+ _notifier.addWorkFlowFromString(username, wfid, oldWF);
+
+ CmdWFSubmit req = new CmdWFSubmit();
+ req.setParam0( username );
+ req.setParam1( wfid );
+ req.setParam2( workflow );
+ CmdWFSubmitResponse resp = stub.cmdWFSubmit( req );
+ output = resp.get_return();
+ } catch (IllegalThreadStateException e) {
+ return e.toString();
+ } catch (Exception e){
+ return e.toString();
+ }
+ return myprefix + output;
+ }
+
+ public String getStatusByUID(String struid){
+ return _notifier.getStatusByUID(struid);
+ }
}
+
+class WorkflowTransformer{
+ private String newWorkflow = "";
+ public String getNewWF(){
+ return newWorkflow;
+ }
+
+ public void LoadFromFile(String filename) {
+ try {
+ File karajanfile = new File(filename);
+ if (karajanfile.exists() == false) {
+ System.out.println("The karajan workflow file " + filename
+ + " does not exist!!");
+ return;
+ }
+ String content = "", line ="";
+ BufferedReader br = new BufferedReader(new FileReader(karajanfile));
+ boolean isFirstLine = true;
+ while( (line=br.readLine())!=null ){
+ if( isFirstLine ){
+ isFirstLine = false;
+ }else
+ content +="\n";
+ content += line;
+ }
+// buildTree(content);
+ LoadFromString(content);
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+ public void LoadFromString(String strworkflow) {
+ String tempFilename = "_tempxx345";
+ File tempfile = new File(tempFilename);
+ BufferedWriter fw = null;
+ try {
+ fw = new BufferedWriter(new FileWriter(tempfile));
+ fw.write(strworkflow);
+ fw.close();
+ buildTree(tempFilename);
+ tempfile.delete();
+ } catch (Exception e) {
+ tempfile.delete();
+ System.out.println(e);
+ }
+ }
+ protected void buildTree(String workflowfilename){
+ try{
+ DocumentBuilderFactory domfactory = DocumentBuilderFactory.newInstance();
+ domfactory.setNamespaceAware(false);
+ DocumentBuilder builder = domfactory.newDocumentBuilder();
+
+ Document doc = builder.parse(new FileInputStream(workflowfilename));
+ Element root = doc.getDocumentElement();
+
+ //transformSubTree(root, doc);
+ transformSubTreeWithPath(root,doc,"");
+
+ /*
+ String newWF = "test.xml";
+ File newfile = new File(newWF);
+ if( newfile.exists() )
+ newfile.delete();
+ newfile.createNewFile();
+ */
+
+ DOMSource src = new DOMSource(doc);
+ TransformerFactory transformerfactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerfactory.newTransformer();
+ //transformer.transform(src, new StreamResult(new FileWriter(newfile)));
+ StringWriter sw = new StringWriter();
+ transformer.transform(src, new StreamResult(sw));
+ newWorkflow = sw.toString();
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+ protected void transformSubTree(Node root, Document doc){
+ if(root.getChildNodes().getLength()==0)
+ return;
+ Node parent = root;
+ Node node = root.getFirstChild();
+ boolean isfirstChild = true;
+ String previousNode ="";
+
+ do{
+ if( node.getNodeType() == Node.TEXT_NODE )
+ continue;
+ if( node.getNodeType() == Node.ELEMENT_NODE){
+ if( node.getNodeName().compareToIgnoreCase("include")==0)
+ continue;
+ String nodename = node.getNodeName();
+ if( nodename.trim().compareToIgnoreCase("execute")==0 ){
+ nodename = "job:"+nodename+"("+((Element)node).getAttribute("executable")+") ";
+ }else
+ nodename = "job:"+nodename;
+
+ if( isfirstChild ){
+ isfirstChild = false;
+ Element newChild = doc.createElement("echo");
+ newChild.setAttribute("message", nodename+" started");
+ parent.insertBefore(newChild, node);
+ Node newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+ }else{
+ Element newChild = doc.createElement("echo");
+ newChild.setAttribute("message", previousNode+" completed");
+ parent.insertBefore(newChild, node);
+ Node newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+ newChild = doc.createElement("echo");
+ newChild.setAttribute("message", nodename+" started");
+ parent.insertBefore(newChild, node);
+ newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+ }
+ previousNode = nodename;
+ transformSubTree(node, doc);
+ }
+ }while( (node=node.getNextSibling())!=null);
+
+ Element newChild = doc.createElement("echo");
+ newChild.setAttribute("message", previousNode+" completed");
+ parent.appendChild(newChild);
+ }
+
+ protected void transformSubTreeWithPath(Node root, Document doc, String path){
+ if(root.getChildNodes().getLength()==0)
+ return;
+ Node parent = root;
+ Node node = root.getFirstChild();
+ boolean isfirstChild = true;
+ String previousNode ="", basepath = path, localpath="", oldpath="", oldEchoMsg="";
+ String echoMsg = "";
+ int childindex = 0;
+ do{
+ if( node.getNodeType() == Node.TEXT_NODE )
+ continue;
+ if( node.getNodeType() == Node.ELEMENT_NODE){
+ if( node.getNodeName().compareToIgnoreCase("include")==0){
+ childindex ++;
+ continue;
+ }
+ childindex ++;
+
+ String nodename = node.getNodeName();
+ if( nodename.trim().compareToIgnoreCase("execute")==0 )
+ nodename = nodename+"("+((Element)node).getAttribute("executable")+") ";
+
+ localpath = path+"/"+childindex;
+
+ if( isfirstChild ){
+ isfirstChild = false;
+ Element newChild = doc.createElement("echo");
+ echoMsg = localpath+"|job:"+nodename;
+ newChild.setAttribute("message", echoMsg+" started|1");
+ parent.insertBefore(newChild, node);
+ Node newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+ }else{
+ Element newChild = doc.createElement("echo");
+ newChild.setAttribute("message", oldEchoMsg+" completed|2");
+ parent.insertBefore(newChild, node);
+
+ Node newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+
+ echoMsg = localpath+"|job:"+nodename;
+ newChild = doc.createElement("echo");
+ newChild.setAttribute("message", echoMsg+" started|1");
+ parent.insertBefore(newChild, node);
+
+ newline = doc.createTextNode("\n");
+ parent.insertBefore(newline, node);
+ }
+ oldEchoMsg = echoMsg;
+ previousNode = nodename;
+ transformSubTreeWithPath(node, doc, localpath);
+ }
+ }while( (node=node.getNextSibling())!=null);
+
+ Element newChild = doc.createElement("echo");
+ newChild.setAttribute("message", oldEchoMsg+" completed|2");
+ parent.appendChild(newChild);
+ }
+}
+
+class StatusServiceNotifier{
+ private String _wsendpoint = "";
+ private StatusServiceInterfaceStub _stub = null;
+
+ public StatusServiceNotifier(){
+ try{
+ _wsendpoint = "http://156.56.104.196:8080/axis2/services/StatusServiceInterface";
+ _stub = new StatusServiceInterfaceStub(_wsendpoint);
+ } catch(Exception e){
+ System.out.println(e);
+ }
+ }
+
+ public String getStatusByUID(String struid){
+ try{
+ if( _stub == null ) return "_stub is null";
+ GetJSONStatusByUID req = new GetJSONStatusByUID();
+ req.setParam0( struid );
+ GetJSONStatusByUIDResponse resp = new GetJSONStatusByUIDResponse();
+ resp = _stub.getJSONStatusByUID(req);
+ return resp.get_return();
+ }catch(Exception e){
+ return e.toString();
+ }
+ }
+
+ public void addWorkFlowFromString(String userid, String wfid, String workflow){
+ try{
+ if( _stub == null ) return ;
+
+ String filename = "/tmp/statusservice_agent_client.test";
+ File file = new File(filename);
+ file.createNewFile();
+ BufferedWriter bw = new BufferedWriter(new FileWriter(file));
+
+ bw.write("add a new workflow\n");
+ //add a workflow
+ /*
+ File currentDir = new File(".");
+ if( true )
+ return currentDir.getAbsolutePath();
+ */
+
+ AddWorkflowFromString addWF1 = new AddWorkflowFromString();
+ addWF1.setParam0(userid);
+ addWF1.setParam1(wfid);
+ addWF1.setParam2(workflow);
+ _stub.addWorkflowFromString(addWF1);
+
+ bw.close();
+ }catch(Exception e){
+ System.out.println(e);
+ }
+ }
+}
+
+/**
+ * Format of the db file:
+ * username1 workflow1
+ * username2 workflow1
+ * username1 workflow2
+ * ... ...
+ */
+class AgentWFDB{
+ private ArrayList<Pair> _db = new ArrayList<Pair>();
+ private HashMap<String, Integer> _userwf = new HashMap<String,Integer>();
+
+ private String _dbfilename = "";//source file
+ private BufferedWriter _bw = null;
+ private boolean _load = false;
+
+ public AgentWFDB(String dbfilename){
+ _dbfilename = dbfilename;
+ File dbfile = new File(dbfilename);
+ if( dbfile.exists() )
+ _load = loadFromFile(dbfilename);
+ }
+ private void addPair(StringPair pair){
+ _db.add(pair);
+ }
+ private void addPair(String first, String second){
+ _db.add( new StringPair(first, second) );
+ }
+ /**
+ * This function first generates a unique workflow id for the user
+ * and add the entry to db.
+ * @param userid
+ * @return
+ */
+ public String addWF(String userid){
+ try{
+ File file = new File("/tmp/client.test");
+ file.createNewFile();
+ BufferedWriter bw = new BufferedWriter( new FileWriter( file ) );
+ bw.write( userid );
+ bw.close();
+ }catch(Exception e){
+ }
+ Integer cn = _userwf.get(userid);
+ int count;
+ if( cn == null ){
+ _userwf.put(userid, 1);
+ count = 1;
+ }else{
+ count = cn+1;
+ _userwf.put(userid, count);
+ }
+ String wfid = userid+"_"+count;
+ addPair(userid, wfid);
+ serialize2file();
+ return wfid;
+ }
+ public boolean contains(String username, String wfid){
+ StringPair pair = new StringPair(username, wfid);
+ return this.contains(pair);
+ }
+ public boolean contains(StringPair pair){
+ for( int i = 0 ; i < _db.size(); i++ ){
+ if( _db.get(i).isEqual(pair) )
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * get workflow list owned by a specified user.
+ * @param userid
+ * @return JSON string
+ */
+ public String getJSONByUserID(String userid){
+ String output = "{\"user\":\""+userid+"\", \"workflow\":[";
+ boolean isfirst = true;
+ for(int i = 0 ; i < _db.size(); i++){
+ if( ((String)_db.get(i).getFirst()).compareTo(userid)==0 ){
+ if( isfirst ){
+ isfirst = false;
+ }else
+ output += ",";
+ output += "\""+(String)_db.get(i).getSecond()+"\"";
+ }
+ }
+ output += "]}";
+ return output;
+ }
+
+ private boolean loadFromFile(String filename){
+ BufferedReader br = null;
+ String line = "";
+ try {
+ br = new BufferedReader(new FileReader(filename));
+ while( (line = br.readLine()) != null){
+ StringPair pair = new StringPair(line);
+ Integer cn = _userwf.get(pair.getFirst());
+ int count;
+ if( cn == null )
+ count = 1;
+ else
+ count = cn + 1;
+ _userwf.put(pair.getFirst(), count);
+ _db.add( pair );
+ }
+ br.close();
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public String serialize2string(){
+ String output = "";
+ for(int i=0; i<_db.size(); i++){
+ output += _db.get(i).serialize() +"\n";
+ }
+ return output;
+ }
+ public void serialize2file(){
+ try {
+ if( !_load ){
+ File file = new File(_dbfilename);
+ if( !file.exists() )
+ file.createNewFile();
+ if (_bw == null) {
+ _bw = new BufferedWriter(new FileWriter(_dbfilename));
+ }
+ _load = true;
+ }
+ String output = serialize2string();
+ if (_bw == null) {
+ _bw = new BufferedWriter(new FileWriter(_dbfilename));
+ }
+ _bw.write(output);
+ _bw.close();
+ _bw = null;
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+}
+
+abstract class Pair{
+ abstract Object getFirst();
+ abstract Object getSecond();
+ abstract void setFirst(Object first);
+ abstract void setSecond(Object second);
+ abstract String serialize();
+ abstract void deserialize(String str);
+ abstract boolean isEqual(Pair pair);
+}
+
+class StringPair extends Pair{
+ private String _first = "";
+ private String _second = "";
+ public StringPair(String first, String second){
+ _first = first;
+ _second = second;
+ }
+ public StringPair(String str){
+ deserialize(str);
+ }
+ public void setFirst(Object first){
+ if( first instanceof String)
+ _first = (String)first;
+ }
+ public void setSecond(Object second){
+ if( second instanceof String)
+ _second = (String)second;
+ }
+ public String getFirst(){
+ return _first;
+ }
+ public String getSecond(){
+ return _second;
+ }
+ public String serialize(){
+ return _first+"\t"+_second;
+ }
+ public void deserialize(String str){
+ int index = str.indexOf('\t');
+ _first = str.substring( 0, index);
+ _second = str.substring(index+1);
+ }
+ public boolean isEqual( Pair p ){
+ if( p instanceof StringPair){
+ StringPair pair = (StringPair)p;
+ String first = pair.getFirst();
+ String second = pair.getSecond();
+ return (_first.compareTo(first)==0)&&(_second.compareTo(second)==0);
+ }else{
+ return false;
+ }
+ }
+}
Modified: trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java 2007-12-05 05:06:57 UTC (rev 1851)
+++ trunk/cyberaide/src/axis2/axis2ws_client/SimpleHandlerInterface.java 2007-12-07 05:39:56 UTC (rev 1852)
@@ -8,4 +8,11 @@
interface SimpleHandlerInterface{
String echo( String input );
String cmdCOGExecute( String workflow );
+ /**
+ * This method submits a workflow to CogKit.
+ * Notice: the user who submits the workflow is identified by <b><i>uid</i></b>
+ * the workflow is uniquely identified by wfid so that different workflows
+ * submitted by the same user can be distinguished.
+ */
+ String cmdWFSubmit(String uid, String wfid, String workflow);
}
Modified: trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterface.java 2007-12-05 05:06:57 UTC (rev 1851)
+++ trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterface.java 2007-12-07 05:39:56 UTC (rev 1852)
@@ -8,4 +8,11 @@
interface SimpleHandlerInterface{
String echo( String input );
String cmdCOGExecute( String workflow );
+ /**
+ * This method submits a workflow to CogKit.
+ * Notice: the user who submits the workflow is identified by <b><i>uid</i></b>
+ * the workflow is uniquely identified by wfid so that different workflows
+ * submitted by the same user can be distinguished.
+ */
+ String cmdWFSubmit(String uid, String wfid, String workflow);
}
Modified: trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java 2007-12-05 05:06:57 UTC (rev 1851)
+++ trunk/cyberaide/src/axis2/axis2ws_server/SimpleHandlerInterfaceSkeleton.java 2007-12-07 05:39:56 UTC (rev 1852)
@@ -32,11 +32,58 @@
import org.globus.common.CoGProperties;
import org.globus.util.Util;
+
+/* following imported packages are used by StatusService client */
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub;
+import org.cogkit.cyberaide.axis2ws.StatusServiceInterfaceStub.*;
+
/**
* SimpleHandlerInterfaceSkeleton java skeleton for the axisService
*/
-public class SimpleHandlerInterfaceSkeleton implements SimpleHandlerInterfaceSkeletonInterface {
+public class SimpleHandlerInterfaceSkeleton implements SimpleHandlerInterfaceSkeletonInterface {
+/* private String _uid = "user1";
+ private String _wfid = "file1";
+ private String _workflow ="";
+*/
+ private static String _statusFilename = "/tmp/status.txt";
+ private static String _statusserviceendpoint = "";
+ private static String _configFilename = "/home/tomcat/apache-tomcat-6.0.14/webapps/executor.properties";
+ private static StatusServiceClient _statusclient = null;
+
+ public SimpleHandlerInterfaceSkeleton(){
+ super();
+ try{
+ //open property file specified by propertiesFile
+ File propfile = new File(_configFilename);
+ if( propfile.exists() == false ){
+ System.out.println("property file: "+_configFilename+" does not exist!");
+ return ;
+ }
+
+ // get status service end point
+ Properties prop = new Properties();
+ prop.load( new FileInputStream( _configFilename ) );
+ String endpoint = prop.getProperty( "statusserviceendpoint" );
+ if( endpoint == null ){
+ System.out.println( "you must specify 'serviceendpoint' property in file service.properties" );
+ }else{
+ _statusserviceendpoint = endpoint;
+ if( _statusclient == null )
+ _statusclient = new StatusServiceClient(_statusserviceendpoint);
+ }
+ }catch(Exception e){
+ System.out.println(e);
+ }
+ }
+ /**
+ * Currently, the events generated by CoGKit during workflow execution is
+ * written into a file specified by variable _statusFilename. When end users
+ * check status, a routine reads this file and sends the content to clients.
+ * If the workflow is finished, another file is created to indicate it.
+ * I can not think of a better way now to tell status checker the completion
+ * of execution of workflow.
+ */
/**
* Auto generated method signature
* @param cmdCOGExecute0
@@ -44,20 +91,39 @@
public org.cogkit.cyberaide.axis2ws.CmdCOGExecuteResponse cmdCOGExecute(
org.cogkit.cyberaide.axis2ws.CmdCOGExecute cmdCOGExecute0) {
String workflow = cmdCOGExecute0.getParam0();
+ /* actually we invoke cmdWFSubmit !!! */
+ if( true ){
+ String result = "";
+ CmdWFSubmit req = new CmdWFSubmit();
+ req.setParam0("user1");
+ req.setParam1("file1");
+ req.setParam2(workflow);
+ CmdWFSubmitResponse resp = cmdWFSubmit( req );
+ CmdCOGExecuteResponse reply = new CmdCOGExecuteResponse();
+ reply.set_return( resp.get_return() );
+ return reply;
+ }
+
Process wfproc = null;
String output = "";
int exit = -1;
try {
- //First, get the proxy certificate from the myproxy server
- getCertFromMyproxy();//"gf1.ucs.indiana.edu", 7512, "gerald", "....", 60*60*24*10);
-
+ String tempEOFFilename = "/tmp/status_end";
+ File tempEOFFile = new File(tempEOFFilename);
+ tempEOFFile.delete();
+
//store the input(it is a workflow description actually) in a file
- String filename = "/tmp/workflow.xml";
+ String filename = "/tmp/workflow_ws.xml";
File recordfile = new File(filename);
- BufferedWriter br = new BufferedWriter(new FileWriter(recordfile));
- br.write(workflow);
- br.close();
+ BufferedWriter bw = new BufferedWriter(new FileWriter(recordfile));
+ bw.write(workflow);
+ bw.flush();
+ //First, get the proxy certificate from the myproxy server
+ getCertFromMyproxy();//"gf1.ucs.indiana.edu", 7512, "gerald", "....", 60*60*24*10);
+
+ bw.write("get proxy\n");
+
//filename = "\"" + filename +"\"";
//String cmd = "E:\\my_program\\cog-4_1_5\\bin\\cog-workflow.bat";// + filename;
// get value of environment variable COG_INSTALL_PATH
@@ -86,16 +152,41 @@
System.out.println("Execute a new command");
wfproc = Runtime.getRuntime().exec(cmdarray);
+ //open status file
+ int count = 0;
+ File statusFile = new File(_statusFilename);
+ BufferedWriter statusbw = new BufferedWriter( new FileWriter(statusFile) );
+
//get output from the executed tool
line = "";
input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
+ boolean isfirstline = true;
while ((line = input.readLine()) != null) {
- output += line;
+ //create a new status file
+// File statusFile = new File(statusFilename+count);
+// BufferedWriter statusbw = new BufferedWriter( new FileWriter(statusFile) );
+
+ if( isfirstline ){
+ isfirstline = false;
+ output += "Firstline:"+line;
+ statusbw.write(line,0,line.length());
+ statusbw.flush();
+ }else{
+ output += "\nFollowing line:"+line;
+ String newline = "\n"+line;
+ statusbw.write(newline,0,newline.length());
+ statusbw.flush();
+ }
+ count ++;
+// statusbw.close();
}
input.close();
+
+ tempEOFFile.createNewFile();
+ statusbw.close();
//exit = wfproc.exitValue();
//output = Integer.toString( exit );
- output = "succeeds!"+output;
+ output = "succeeds!\n"+output;
wfproc.destroy();
} catch (IllegalThreadStateException e) {
wfproc.destroy();
@@ -127,7 +218,7 @@
*/
private void getCertFromMyproxy(){//String host, int port, String user, String pwd, int lifetime){
try{
- String propertiesFile = "myproxy.properties";
+ String propertiesFile = "/home/tomcat/apache-tomcat-6.0.14/webapps/myproxy.properties";
String host = "";
int port = -1;
String user = "";
@@ -192,4 +283,191 @@
}
}
+ /**
+ * Auto generated method signature
+ * This method will be used by agent to submit a workflow.
+ * @param cmdWFSubmit0
+ */
+ public org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse cmdWFSubmit(
+ org.cogkit.cyberaide.axis2ws.CmdWFSubmit cmdWFSubmit0) {
+ String uid = cmdWFSubmit0.getParam0();
+ String wfid = cmdWFSubmit0.getParam1();
+ String workflow = cmdWFSubmit0.getParam2();
+
+ /*
+ //internally, invoke cmdCogExecution
+ org.cogkit.cyberaide.axis2ws.CmdCOGExecute execution = new org.cogkit.cyberaide.axis2ws.CmdCOGExecute();
+ execution.setParam0(_workflow);
+ org.cogkit.cyberaide.axis2ws.CmdCOGExecuteResponse resp = new org.cogkit.cyberaide.axis2ws.CmdCOGExecuteResponse();
+ resp = cmdCOGExecute(execution);
+ org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse wfresp = new org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse();
+ wfresp.set_return(resp.get_return());
+ */
+
+ Process wfproc = null;
+ String output = "";
+ int exit = -1;
+ try {
+ //First, get the proxy certificate from the myproxy server
+ getCertFromMyproxy();//"gf1.ucs.indiana.edu", 7512, "gerald", "....", 60*60*24*10);
+
+ //store the input(it is a workflow description actually) in a file
+ String filename = "/tmp/workflow_WFSubmit.xml";
+ File recordfile = new File(filename);
+ BufferedWriter br = new BufferedWriter(new FileWriter(recordfile));
+ br.write(workflow);
+ br.close();
+
+ //filename = "\"" + filename +"\"";
+ //String cmd = "E:\\my_program\\cog-4_1_5\\bin\\cog-workflow.bat";// + filename;
+ // get value of environment variable COG_INSTALL_PATH
+ String cog_workflow = "";
+ String getEnvVar = "printenv COG_INSTALL_PATH";
+ String line = "";
+
+ wfproc = Runtime.getRuntime().exec(getEnvVar);
+ BufferedReader input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
+ while ((line = input.readLine()) != null) {
+ cog_workflow += line;
+ }
+ input.close();
+ wfproc.destroy();
+ if( cog_workflow.equals("") ){
+ throw new Exception("Environment variable COG_INSTALL_PATH is not set!!");
+ }
+
+ wfproc = null;
+ //call the cog command line tool to execute the workflow
+ String cmd = cog_workflow+"/bin/cog-workflow";
+ String []cmdarray = new String[2];
+ cmdarray[0] = cmd; //command
+ cmdarray[1] = filename;//argument
+ long timeout = 1000 * 30;//30 seconds
+ System.out.println("Execute a new command");
+ wfproc = Runtime.getRuntime().exec(cmdarray);
+
+ int statuscodeStarted = 1;
+ int statuscodeCompleted = 2;
+
+ // notify status service that the workflow has started running
+ _statusclient.notifyStatusOfWF(uid, wfid, statuscodeStarted, "workflow execution started");
+
+ //get output from the executed tool
+ line = "";
+ input = new BufferedReader (new InputStreamReader(wfproc.getInputStream()));
+ boolean isfirstline = true;
+ while ((line = input.readLine()) != null) {
+ if( isfirstline ){
+ isfirstline = false;
+ output += "WFSubmit_Firstline:"+line;
+ }else{
+ output += "\nWFSubmit_Following line:"+line;
+ }
+ /**
+ * Key point:
+ * Every time a new message is generated during execution of workflow, the
+ * message will be sent to status service based on web service.
+ * First, we need to parse the generated message because it contains some
+ * more information than pure message.
+ * Note: this must correspond to the method used to transform the received
+ * workflow by the agent server.
+ *
+ * Format:
+ * Currently, the generated status message has the format like this:
+ * /1/2/1/3|job:...|0
+ * Note: /1/2/1/3 denotes path of the target element in the workflow.
+ * The last number after '|' denotes status code. status code is
+ * 0 in the example above. The meaning of status code MUST match the
+ * definition in StatusService program!!
+ * Our job is to extract this part.
+ */
+ int index = line.indexOf('|');
+ if( index == -1 ){
+ //this message is not status message, it is generated natively by
+ //original workflow.
+ continue;
+ }else{
+ String path = line.substring(0, index);
+ String msg = line.substring(index+1);
+ int endindex = msg.lastIndexOf('|');
+ String statuscodestr = msg.substring(endindex+1);
+ msg = msg.substring(index+1, endindex);
+ int statuscode = Integer.parseInt(statuscodestr);
+ _statusclient.notifyStatusOfElement(uid, wfid, path, statuscode, msg);
+ }
+ }
+ input.close();
+
+ //notify status service that this workflow finishes executing
+ _statusclient.notifyStatusOfWF(uid, wfid, statuscodeCompleted, "workflow execution completed");
+
+ output = "succeeds!\n"+output;
+ wfproc.destroy();
+ } catch (IllegalThreadStateException e) {
+ wfproc.destroy();
+ output = e.toString();
+ } catch (Exception e){
+ wfproc.destroy();
+ output = e.toString();
+ }
+
+ org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse wfresp = new org.cogkit.cyberaide.axis2ws.CmdWFSubmitResponse();
+ wfresp.set_return( output );
+
+ return wfresp;
+ }
}
+
+
+class StatusServiceClient{
+// public static void main(String []args){
+ private StatusServiceInterfaceStub _stub = null;
+
+ public StatusServiceClient( String wsendpoint ){
+ // currently, the wsendpoint should be
+ // "http://156.56.104.196:8080/axis2/services/StatusServiceInterface";
+ try{
+ _stub = new StatusServiceInterfaceStub(wsendpoint);
+ }catch(Exception e){
+ System.out.println("in constructor of class StatusServiceClient in file SimpleHandlerInterfaceSkeleton.java"+e);
+ }
+ }
+
+ public void notifyStatusOfWF( String userid, String wfid, int statuscode, String statusmsg ){
+ try{
+ if( _stub == null ){
+ System.out.println("In method StatusServiceClient#StatusOfElement, _stub has not been set");
+ return ;
+ }
+ ModifyStatusOfWholeWF req = new ModifyStatusOfWholeWF();
+ req.setParam0(userid);
+ req.setParam1(wfid);
+ req.setParam2(statuscode);
+ req.setParam3(statusmsg);
+ _stub.modifyStatusOfWholeWF(req);
+ }catch(Exception e){
+ System.out.println(e);
+ }
+ }
+
+ public void notifyStatusOfElement(String userid, String wfid, String path, int statuscode, String statusmsg){
+ try{
+ if( _stub == null ){
+ System.out.println("In method StatusServiceClient#StatusOfElement, _stub has not been set");
+ return ;
+ }
+
+ //modify status of an element
+ ModifyStatusByPathString modifyReq = new ModifyStatusByPathString();
+ modifyReq.setParam0(userid);
+ modifyReq.setParam1(wfid);
+ modifyReq.setParam2(path);
+ modifyReq.setParam3(statuscode);
+ modifyReq.setParam4(statusmsg);
+ _stub.modifyStatusByPathString(modifyReq);
+
+ }catch(Exception e){
+ System.out.println(e);
+ }
+ }
+}
Added: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java (rev 0)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterface.java 2007-12-07 05:39:56 UTC (rev 1852)
@@ -0,0 +1,66 @@
+package org.cogkit.cyberaide.axis2ws;
+
+/**
+ * This interface provides functionality needed by external entities.
+ */
+interface StatusServiceInterface {
+ /**
+ * This method is used to add a new workflow from a string passed as an
+ * argument.
+ *
+ * @param struid
+ * @param wfid
+ * @param workflow
+ */
+ public void addWorkflowFromString(String struid, String wfid, String workflow);
+ /**
+ * This method is used to add a new workflow from a workflow file.
+ *
+ * @param struid
+ * @param wfid
+ * @param filename
+ */
+ public void addWorkflowFromFile(String struid, String wfid, String filename);
+ /**
+ * get status of all workflows submitted by a user.
+ *
+ * @param struid
+ * @return a string in JSON format
+ */
+ public String getJSONStatusByUID(String struid);
+ public String getXMLStatusByUID(String struid);
+
+ /**
+ * @deprecated
+ * modify status of an element in the workflow.
+ *
+ * @param struid
+ * identify a user
+ * @param wfid
+ * identify a workflow
+ * @param element
+ * identify an element
+ * @param statusmsg
+ * status message
+ */
+ // public void modifyStatus(String struid, String wfid, String element, int statuscode, String statusmsg);
+ /**
+ * modify status of an element. The element of which status to be modified is located by parameter
+ * <i>path</i>. The from of path is not defined here. It depends on implementation.
+ * @param struid identify a user
+ * @param wfid identify a workflow
+ * @param path identify an element
+ * @param statuscode status code
+ * @param statusmsg status message
+ */
+ public void modifyStatusByPathString(String struid, String wfid, String path, int statuscode, String statusmsg);
+
+ /**
+ * modify status of a whole workflow.
+ * @param struid
+ * @param wfid
+ * @param statuscode
+ * @param statusmsg
+ */
+ public void modifyStatusOfWholeWF(String struid, String wfid, int statuscode, String statusmsg);
+}
Added: trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java
===================================================================
--- trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java (rev 0)
+++ trunk/cyberaide/src/axis2/axis2ws_server/StatusServiceInterfaceSkeleton.java 2007-12-07 05:39:56 UTC (rev 1852)
@@ -0,0 +1,942 @@
+/**
+ * StatusServiceInterfaceSkeleton.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: 1.3 Built on : Aug 10, 2007 (04:45:47 LKT)
+ */
+
+package org.cogkit.cyberaide.axis2ws;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.io.*;
+
+import org.globus.cog.karajan.workflow.ElementTree;
+import org.globus.cog.karajan.workflow.nodes.FlowElement;
+import org.globus.cog.karajan.Loader;
+
+/**
+ * StatusServiceInterfaceSkeleton java skeleton for the axisService
+ */
+public class StatusServiceInterfaceSkeleton
+ implements StatusServiceInterfaceSkeletonInterface {
+
+ private static String TAGUID = "uid";
+ private static String TAGWORKFLOWS = "workflows";
+
+ /**
+ * following three variables represent three ways to implement the
+ * status service.
+ * (1)event driven
+ * this means we base on the event model of cogkit.
+ * This does not work well because events generated by CoGKit are out of
+ * order. This may result from underlying Globus event model.
+ * (2)echo driven
+ * This is the default method.
+ * echo elements are added to original workflow automatically to
+ * record progress.
+ * (3)workflow element overwriting
+ * overwrite original workflow element, such as task:execution, task:transfer
+ * so that additional log/debug information is generated besides execution of
+ * tasks.
+ */
+ private static int EVENTDRIVEN = 1;
+ private static int ECHODRIVEN = 2;
+ private static int WFELEOVERWRITE = 3;
+
+ private int serviceImplType = this.ECHODRIVEN;
+
+ private static StatusDB _db = new StatusDB();
+
+ private String _logfile = "/tmp/status_service.log";
+ private RandomAccessFile _log = null;
+
+ private void writeLog(String log){
+ try{
+ if( _log == null ){
+ _log = new RandomAccessFile(_logfile, "rws");
+ _log.seek( _log.length() );
+ }
+ _log.writeChars(log);
+ }catch(Exception e){
+ System.out.println(e);
+ }
+ }
+ /**
+ * Auto generated method signature
+ * @param modifyStatus0
+ */
+ /*
+ public void modifyStatus(
+ org.cogkit.cyberaide.axis2ws.ModifyStatus modifyStatus0) {
+ String struid = modifyStatus0.getParam0();
+ String wfid = modifyStatus0.getParam1();
+ String element = modifyStatus0.getParam2();
+ int statuscode = modifyStatus0.getParam3();
+ String statusmsg = modifyStatus0.getParam4();
+ UID uid = new UIDUsername(struid);
+ _db.setElementStatus(uid, wfid, element, statuscode, statusmsg);
+ }
+ */
+
+ public void modifyStatusByPathString(
+ org.cogkit.cyberaide.axis2ws.ModifyStatusByPathString modifyStatusByPathString0) {
+ String struid = modifyStatusByPathString0.getParam0();
+ String wfid = modifyStatusByPathString0.getParam1();
+ String path = modifyStatusByPathString0.getParam2();
+ int statuscode = modifyStatusByPathString0.getParam3();
+ String statusmsg= modifyStatusByPathString0.getParam4();
+
+ writeLog("modifyStatusByPathString "+struid+":"+wfid+":"+path+":"+statuscode+":"+statusmsg+"\n");
+
+ UID uid = new UIDUsername(struid);
+ _db.setElementStatusByPathString(uid, wfid, path, statuscode, statusmsg);
+
+ String json = _db.getStatusByUID(uid).toJSON();
+ writeLog(json+"\n");
+ }
+ /**
+ * Auto generated method signature
+ * @param getXMLStatusByUID1
+ */
+ public org.cogkit.cyberaide.axis2ws.GetXMLStatusByUIDResponse getXMLStatusByUID(
+ org.cogkit.cyberaide.axis2ws.GetXMLStatusByUID getXMLStatusByUID1) {
+ String struid = getXMLStatusByUID1.getParam0();
+ UID uid = new UIDUsername(struid);
+ String result = _db.getStatusByUID(uid).toXML();
+ org.cogkit.cyberaide.axis2ws.GetXMLStatusByUIDResponse resp = new org.cogkit.cyberaide.axis2ws.GetXMLStatusByUIDResponse();
+ resp.set_return(result);
+ return resp;
+ }
+
+ /**
+ * Auto generated method signature
+ * @param getJSONStatusByUID3
+ */
+ public org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDResponse getJSONStatusByUID(
+ org.cogkit.cyberaide.axis2ws.GetJSONStatusByUID getJSONStatusByUID3) {
+ try{
+ String struid = getJSONStatusByUID3.getParam0();
+
+ File file = new File("/tmp/json_request.txt");
+ file.createNewFile();
+ BufferedWriter bw = new BufferedWriter( new FileWriter(file) );
+ bw.write("user:"+struid);
+ bw.close();
+
+ UID uid = new UIDUsername(struid);
+ StatusList sl = _db.getStatusByUID(uid);
+
+ String result = "{";
+ if( sl == null){
+ result = "No workflow found";
+ }else{
+ result = "{";
+ result += "\""+TAGUID+"\":\""+struid+"\"";
+ result += ",";
+ result += "\""+TAGWORKFLOWS+"\":";
+ result += sl.toJSON();
+ result += "}";
+ }
+ org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDResponse resp = new org.cogkit.cyberaide.axis2ws.GetJSONStatusByUIDResponse();
+ resp.set_return(result);
+ return resp;
+ }catch(Exception e){
+ return null;
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ * @param addWorkflowFromString5
+ */
+ public void addWorkflowFromString(
+ org.cogkit.cyberaide.axis2ws.AddWorkflowFromString addWorkflowFromString5) {
+ writeLog("addWorkflowFromString:");
+ String struid = addWorkflowFromString5.getParam0();
+ String wfid = addWorkflowFromString5.getParam1();
+ String workflow = addWorkflowFromString5.getParam2();
+
+ writeLog("addWorkflowFromString:"+struid+":"+wfid+":"+workflow+"\n");
+
+ UID uid = new UIDUsername(struid);
+ KarajanTree tree = new KarajanTree();
+ tree.LoadFromString(workflow);
+ WorkflowStatus wfs = new WorkflowStatus(tree);
+ wfs.setWfid(wfid);
+ _db.addStatus(uid, wfs);
+ }
+
+ /**
+ * Auto generated method signature
+ * @param addWorkflowFromFile6
+ */
+ public void addWorkflowFromFile(
+ org.cogkit.cyberaide.axis2ws.AddWorkflowFromFile addWorkflowFromFile6) {
+ String struid = addWorkflowFromFile6.getParam0();
+ String wfid = addWorkflowFromFile6.getParam1();
+ String filename = addWorkflowFromFile6.getParam2();
+
+ UIDUsername uid = new UIDUsername(struid);
+ KarajanTree tree = new KarajanTree();
+ tree.LoadFromFile(filename);
+ WorkflowStatus wfs = new WorkflowStatus(tree);
+ wfs.setWfid(wfid);
+ _db.addStatus(uid, wfs);
+ }
+
+ public void modifyStatusOfWholeWF(org.cogkit.cyberaide.axis2ws.ModifyStatusOfWholeWF modifyStatusOfWholeWF7){
+ String struid = modifyStatusOfWholeWF7.getParam0();
+ String wfid = modifyStatusOfWholeWF7.getParam1();
+ int statuscode = modifyStatusOfWholeWF7.getParam2();
+ String statusmsg = modifyStatusOfWholeWF7.getParam3();
+
+ writeLog("modifyStatusOfWholeWF:"+struid+":"+wfid+":"+statuscode+":"+statusmsg+"\n");
+
+ UID uid = new UIDUsername(struid);
+ _db.setStatusOfWF(uid, wfid, statuscode, statusmsg);
+
+ String json = _db.getStatusByUID(uid).toJSON();
+ writeLog(json+"\n");
+ }
+}
+
+/**
+ * Interface which all tree nodes must implement. Note: every node can contain
+ * its data which can be gotten by invoking method <b>getData()</b>.
+ */
+interface ITreeNode {
+ // TreeNode getParent(); //I am not sure currently whether parent pointer
+ // needs to be maintained.
+ // ITreeNode getFirstChild();
+ ITreeNode[] getChildren();
+
+ void addChild(ITreeNode child);
+
+ /**
+ * remove all children. Note: actually this will remove all direct and
+ * indirect children. In other words, a subtree of which root is current
+ * node will be removed.
+ */
+ void removeAllChildren();
+
+ ITreeNodeData getData();
+ void setData(ITreeNodeData data);
+ ITreeNode searchNode(ITreeNodeData criteria); // return one node
+ ITreeNode getNodeByPath(String path,String delimiter);
+ ITreeNode getNodeByPath(int []path);
+ ITreeNode getChildByIndex(int index);
+}
+
+/**
+ * In my case, the tree does not contain duplicate nodes, which means only a
+ * result node can be returned by function <b>searchXXX()</b>.
+ *
+ * @author gerald
+ *
+ */
+interface ITree {
+ ITreeNode getRoot();
+
+ /**
+ * Search. Actually criteria will be compared with data contained in every
+ * node.
+ */
+ ITreeNode searchNode(ITreeNodeData criteria);
+ ITreeNode getNodeByPath(String path, String delimiter);
+}
+
+/**
+ * This interface represents the data contained in tree node.
+ *
+ * @author gerald
+ *
+ */
+interface ITreeNodeData {
+ boolean isEqual(ITreeNodeData data);
+}
+
+class TreeNode implements ITreeNode {
+ private ArrayList<ITreeNode> _children = new ArrayList<ITreeNode>();
+ private ITreeNodeData _data = null;
+
+ public ITreeNodeData getData() {
+ return _data;
+ }
+
+ public ITreeNode[] getChildren() {
+ ITreeNode[] children =(ITreeNode[]) _children.toArray(new ITreeNode[0]);
+ return children;
+ }
+
+ public void addChild(ITreeNode child) {
+ _children.add(child);
+ }
+
+ public void removeAllChildren() {
+ Iterator it = _children.iterator();
+ while (it.hasNext()) {
+ ITreeNode node = (ITreeNode) it.next();
+ node.removeAllChildren();
+ }
+ _children.clear();
+ }
+
+ public void setData(ITreeNodeData data) {
+ _data = data;
+ }
+ public ITreeNode getChildByIndex(int index){
+ if( index < _children.size() )
+ return _children.get(index);
+ return null;
+ }
+ public ITreeNode searchNode(ITreeNodeData criteria){
+ return internalSearch(this, criteria);
+ }
+ private ITreeNode internalSearch(ITreeNode root, ITreeNodeData criteria) {
+ ITreeNodeData data = root.getData();
+ if (data.isEqual(criteria)){
+// System.out.println("to find:"+((KarajanTreeNodeData)criteria).getNodeType());
+// System.out.println("find:"+((KarajanTreeNodeData)data).getNodeType()+","+((KarajanTreeNodeData)data).getStatus());
+ return root;
+ }
+ else {
+ ITreeNode node;
+ ITreeNode[] children = root.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ node = children[i];
+ node = internalSearch(node, criteria);
+ if ( node != null)
+ return node;
+ }
+ return null;
+ }
+ }
+ /**
+ * Path format is like this:
+ * /1/2/3/4
+ */
+ public ITreeNode getNodeByPath(String path, String delimiter){
+ String pathstr = path;
+ if(pathstr.indexOf(delimiter)==0){
+ pathstr = pathstr.substring(delimiter.length());
+ }
+ String pathSeg[] = pathstr.split(delimiter);
+ int indexArr[] = new int[pathSeg.length];
+ for(int i = 0 ; i < pathSeg.length; i++){
+ int childindex = Integer.valueOf(pathSeg[i]);
+ indexArr[i] = childindex;
+ }
+ //find node along the path
+ return getNodeByPath(indexArr);
+ }
+
+ public ITreeNode getNodeByPath(int []path){
+ ITreeNode currentNode = this;
+ for( int i = 0 ; i < path.length; i++){
+ currentNode = currentNode.getChildByIndex(path[i]-1);
+ }
+ return currentNode;
+ }
+}
+
+/**
+ * This class is closely related to flow element in Karajan.
+ *
+ * @author gerald
+ *
+ */
+class KarajanTreeNodeData implements ITreeNodeData {
+ private String _nodeType = "";
+ private String _status = "";
+ private int _statuscode = StatusConstant.IDLE;
+ // Currently, just compare the node type and statuscode.
+ // Maybe in the future, some more
+ // comparisons need to be added.
+ public boolean isEqual(ITreeNodeData data) {
+ if(_nodeType.compareTo(((KarajanTreeNodeData)data).getNodeType())==0 &&
+ _statuscode == ((KarajanTreeNodeData)data).getStatuscode() ){
+// System.out.println("I find it:"+_nodeType);
+ return true;
+ }
+ return false;
+ }
+ public KarajanTreeNodeData(String nodeType, String status){
+ _nodeType = nodeType;
+ _status = status;
+ }
+ public KarajanTreeNodeData(String nodeType){
+ _nodeType = nodeType;
+ // TODO set initial status here
+ _status = "idle";
+ }
+ public String getNodeType(){
+ return _nodeType;
+ }
+ public String getStatus(){
+ return _status;
+ }
+ public void setStatus(String status) {
+ _status = status;
+ }
+ public int getStatuscode() {
+ return _statuscode;
+ }
+ public void setStatuscode(int _statuscode) {
+ this._statuscode = _statuscode;
+ }
+}
+
+
+class Tree implements ITree {
+ private ITreeNode _root = null;
+
+ public ITreeNode getRoot() {
+ return _root;
+ }
+
+ public void setRoot(ITreeNode root) {
+ if (_root != null) {
+ System.out.println("Root of the tree has been set!!");
+ return;
+ }
+ _root = root;
+ }
+
+ public ITreeNode searchNode(ITreeNodeData criteria) {
+ if (_root == null) {
+ System.out.println("You have not built your tree yet!!");
+ return null;
+ }
+ return _root.searchNode(criteria);
+ }
+ public ITreeNode getNodeByPath(String path, String delimiter){
+ return _root.getNodeByPath(path, delimiter);
+ }
+}
+
+/**
+ * This interface provides necessary method which can be used to represent a
+ * unique user. Note: we don't specify the internal data structure. All we need
+ * is that the returned value must be a <b>String</b>.
+ */
+interface UID {
+ String getUID();
+ boolean isEqual(UID uid2);
+}
+
+interface IStatus {
+ boolean isEqual(IStatus obj);
+}
+
+/**
+ * This class uses user name as uid. My assumption is that user name is unique
+ * for every user.
+ */
+class UIDUsername implements UID {
+ private String _uid = "";
+
+ public UIDUsername(String uid) {
+ _uid = uid;
+ }
+
+ public String getUID() {
+ return _uid;
+ }
+
+ public boolean isEqual(UID uid) {
+ return _uid.compareTo(uid.getUID()) == 0;
+ }
+ public String toString(){
+ return _uid;
+ }
+}
+/**
+ * This class represents status of execution of a workflow. Two kinds of
+ * information are provided here: (1) status about whole workflow (2) status
+ * about a certain step in the workflow. <b>Layout:</b>
+ * ___________________________________________ | message | | code | | | - step 1
+ * (information) | | flowtree -- | - step 2 (information) | | | - step 3
+ * (information) | |___________________________________________|
+ */
+class WorkflowStatus {
+ private static String WFID = "wfid";
+ private static String STATUS = "status";
+ private static String ELEMENTS = "elements";
+ /**
+ * following two variables represent the status of the whole workflow. If
+ * you need information about a certain sub task in the workflow, you should
+ * consult <b><i>_flowtree</i></b> variable.
+ */
+ private String _statusMsg = "";
+ private int _statusCode;
+ /**
+ * This variable represents the logic structure of the karajan workflow.
+ */
+ private KarajanTree _flowtree = null;
+
+ /**
+ * This variable uniquely identifies a workflow so that we can distinguish
+ * different workflows submitted by a single user.
+ */
+ private String _wfid = "";
+
+ //private static int COMPLETED = 1;
+ //private static int FAILED = 2;
+ private static String[] MSG= {
+ "idle", // corresponding to idle
+ "started", // corresponding to started
+ "completed" // corresponding to completed
+ };
+ public WorkflowStatus(KarajanTree tree){
+ _flowtree = tree;
+ _statusCode = StatusConstant.IDLE;
+ _statusMsg = this.MSG[_statusCode];
+ }
+
+ public String getStatusMsg() {
+ return _statusMsg;
+ }
+
+ public void setStatusMsg(String msg) {
+ _statusMsg = msg;
+ }
+ public int get_statusCode() {
+ return _statusCode;
+ }
+ public void set_statusCode(int code) {
+ _statusCode = code;
+ }
+ /*
+ public void onCompleted(){
+ setStatusMsg(MSG[COMPLETED]);
+ }
+ public void onFailed(){
+ setStatusMsg(MSG[FAILED]);
+ }*/
+ /**
+ * This class can modify status of a certain element in the workflow.
+ *
+ * @param element
+ * @param statusmsg
+ */
+ /*
+ public void setElementStatus(String element, int statuscode, String statusmsg){
+ try {
+ _flowtree.modifyStatus(element, statuscode, statusmsg);
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }*/
+
+ public void setElementStatusByPathString(String path, int statuscode, String statusmsg){
+ try {
+ _flowtree.modifyStatusByPathString(path, statuscode, statusmsg);
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ public String getWfid() {
+ return _wfid;
+ }
+ public void setWfid(String wfid) {
+ _wfid = wfid;
+ }
+ public String toJSON(){
+ String result = "{";
+ result += "\""+WFID+"\":\""+_wfid+"\"";
+ result += ",";
+ result += "\""+STATUS+"\":\""+_statusMsg+"\"";
+ result += ",";
+ result += "\""+this.ELEMENTS+"\":[";
+ result += _flowtree.toJSON();
+ result += "]}";
+ return result;
+ }
+}
+
+class StatusData implements ITreeNodeData{
+
+ public boolean isEqual(ITreeNodeData data) {
+ return true;
+ }
+}
+
+/**
+ * This class represents an entry in the status database. Layout:
+ * _________________________________ | | | | user id | WorkflowStatus |
+ * |___________|_____________________|
+ *
+ */
+/*
+ * class StatusEntry { private UID _uid; private WorkflowStatus _status;
+ *
+ * public UID getUID() { return _uid; }
+ *
+ * public WorkflowStatus getStatus() { return _status; }
+ *
+ * public boolean isEqual(ITreeNodeData data) { StatusEntry entry =
+ * (StatusEntry) data; return _uid.isEqual(entry.getUID()); } }
+ */
+
+class KarajanTree extends Tree {
+ private boolean _isload = false;
+ /** contains list of nodes which are executed */
+// private ArrayList<ITreeNode> _currentNodes = new ArrayList<ITreeNode>();
+ public KarajanTree(){
+ }
+ public void LoadFromFile(String filename) {
+ if(_isload)
+ return;
+ try {
+ File karajanfile = new File(filename);
+ if (karajanfile.exists() == false) {
+ System.out.println("The karajan workflow file " + filename
+ + " does not exist!!");
+ return;
+ }
+ ElementTree tree = Loader.load(filename);
+ buildTree(tree);
+ _isload = true;
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+ public void LoadFromString(String strworkflow) {
+ if(_isload)
+ return;
+ try {
+ ElementTree tree = Loader.loadFromString(strworkflow);
+ buildTree(tree);
+ _isload = true;
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+ protected void buildTree(ElementTree eletree){
+ setRoot( addSubTree(eletree.getRoot()));
+// _currentNodes.add(getRoot());
+ }
+ private ITreeNode addSubTree(FlowElement fe){
+ ITreeNode root = new TreeNode();
+ KarajanTreeNodeData nodeData = new KarajanTreeNodeData(getPureName(fe.getElementType()));
+ root.setData(nodeData);
+
+ List clist = fe.elements();
+ Iterator it = clist.iterator();
+ while( it.hasNext() ){
+ FlowElement flowele = (FlowElement)it.next();
+ ITreeNode child = addSubTree(flowele);
+ root.addChild( child );
+ }
+ return root;
+ }
+ private String getPureName(String fullname){
+ int npos = fullname.indexOf(':');
+ if( npos != -1 ){
+ return fullname.substring(npos+1);
+ }
+ return fullname;
+ }
+ public String toJSON(){
+ return toJSON(getRoot());
+ }
+ private String toJSON(ITreeNode node){
+ if( node == null )
+ return "";
+ KarajanTreeNodeData data = (KarajanTreeNodeData)node.getData();
+ ITreeNode []children = node.getChildren();
+ String result = "{";
+ result += "\""+KarajanNodeJSON.NODENAME+"\":\""+data.getNodeType()+"\"";
+ result += ",";
+ result += "\""+KarajanNodeJSON.STATUS+"\":\""+data.getStatus()+"\"";
+ result += ",";
+ result += "\""+KarajanNodeJSON.STATUSCODE+"\":"+data.getStatuscode()+"";
+ result += ",";
+ result += "\""+KarajanNodeJSON.CHILDREN+"\":[";
+ for( int i = 0 ; i < children.length ; i ++ ){
+ result += toJSON(children[i]);
+ if( i < children.length-1 )
+ result +=",";
+ }
+ result += "]}";
+ return result;
+ }
+ /**
+ * This function is used to modify status of an element.
+ * The destination node is found by following the path specified by parameter
+ * <i>path</i>
+ * Note: StatusContant.PATHDELIMITER specifies the delimiter between path parts.
+ * Currently, the delimiter is "/". This must accord with the format of event
+ * generated by backend grid service because the parameter <i>path</i> actually is
+ * passed from that part(backend grid service).
+ * @param path specifies path of the node of which status will be modified
+ * @param statuscode status code
+ * @param statusmsg status message
+ */
+ public synchronized void modifyStatusByPathString(String path, int statuscode, String statusmsg){
+ ITreeNode node = getRoot().getNodeByPath(path, StatusConstant.PATHDELIMITER);
+ if(node!=null){
+ KarajanTreeNodeData data = (KarajanTreeNodeData)node.getData();
+ data.setStatuscode(statuscode);
+ data.setStatus(statusmsg);
+ }
+ }
+
+ public synchronized void modifyStatusByPathIndex(int []path, int statuscode, String statusmsg){
+ ITreeNode node = getRoot().getNodeByPath(path);
+ if(node!=null){
+ KarajanTreeNodeData data = (KarajanTreeNodeData)node.getData();
+ data.setStatuscode(statuscode);
+ data.setStatus(statusmsg);
+ }
+ }
+ /**
+ * This function must be synchronized because concurrent access is possible.
+ *
+ * @param strele
+ * name of the element, e.g. transfer, execution, echo ...
+ * @param statusmsg
+ * description about the status corresponding to the element.
+ */
+ /*
+ public synchronized void modifyStatus(String eleType, int statuscode, String statusmsg) throws Exception{
+ eleType = getPureName(eleType);
+ switch (statuscode){
+ case StatusConstant.STARTED:
+/* for(int i = 0 ; i < _currentNodes.size(); i++){
+ ITreeNode node = _currentNodes.get(i);
+ KarajanTreeNodeData data = (KarajanTreeNodeData)node.getData();
+ if( data.getNodeType().compareTo(eleType) == 0 ){
+ data.setStatus(statusmsg);
+ data.setStatuscode(statuscode);
+ return;
+ }
+ }* /
+// System.out.println(eleType);
+ ITreeNode newnode = null;
+ KarajanTreeNodeData criteria = new KarajanTreeNodeData(eleType);
+ criteria.setStatuscode(StatusConstant.IDLE);
+
+ for(int i = 0 ; i < _currentNodes.size(); i++){
+ newnode = _currentNodes.get(i).searchNode(criteria);
+ if( newnode != null ){
+// System.out.println("---find it!!!!!!!!!!!!!"+((KarajanTreeNodeData)newnode.getData()).getNodeType());
+ ((KarajanTreeNodeData)newnode.getData()).setStatus(statusmsg);
+ ((KarajanTreeNodeData)newnode.getData()).setStatuscode(statuscode);
+ _currentNodes.add(newnode);
+ break;
+ }
+ }
+ break;
+
+ case StatusConstant.COMPLETED:
+ case StatusConstant.FAILED:
+ for(int i = 0 ; i < _currentNodes.size(); i++){
+ ITreeNode node = _currentNodes.get(i);
+ KarajanTreeNodeData data = (KarajanTreeNodeData)node.getData();
+ if( data.getNodeType().compareTo(eleType) == 0 ){
+ data.setStatus(statusmsg);
+ data.setStatuscode(statuscode);
+ _currentNodes.remove(...
[truncated message content] |
|
From: <ha...@us...> - 2007-12-05 05:06:59
|
Revision: 1851
http://cogkit.svn.sourceforge.net/cogkit/?rev=1851&view=rev
Author: hategan
Date: 2007-12-04 21:06:57 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
updated jglobus
Modified Paths:
--------------
trunk/current/src/cog/modules/jglobus/project.properties
Added Paths:
-----------
trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071203.jar
trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071203.jar
Removed Paths:
-------------
trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071125.jar
trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071125.jar
Deleted: trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071125.jar
===================================================================
(Binary files differ)
Added: trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071203.jar
===================================================================
(Binary files differ)
Property changes on: trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071203.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071125.jar
===================================================================
(Binary files differ)
Added: trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071203.jar
===================================================================
(Binary files differ)
Property changes on: trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071203.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/current/src/cog/modules/jglobus/project.properties
===================================================================
--- trunk/current/src/cog/modules/jglobus/project.properties 2007-12-03 17:47:00 UTC (rev 1850)
+++ trunk/current/src/cog/modules/jglobus/project.properties 2007-12-05 05:06:57 UTC (rev 1851)
@@ -1,6 +1,6 @@
module.name = jglobus
long.name = JGlobus
-version = dev-071125
+version = dev-071203
project = Java CoG Kit
no.javadoc.compile = true
lib.deps = cog-jglobus-*.*,cryptix.*,cryptix32.*,jgss.*,jce-jdk13-131.*,cryptix-asn1.*,junit.*,puretls.*,log4j*.*,commons-logging*.*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-12-03 17:47:03
|
Revision: 1850
http://cogkit.svn.sourceforge.net/cogkit/?rev=1850&view=rev
Author: hategan
Date: 2007-12-03 09:47:00 -0800 (Mon, 03 Dec 2007)
Log Message:
-----------
data channel reuse
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-gt2/CHANGES.txt
trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java
trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java
Modified: trunk/current/src/cog/modules/provider-gt2/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/provider-gt2/CHANGES.txt 2007-11-30 19:47:29 UTC (rev 1849)
+++ trunk/current/src/cog/modules/provider-gt2/CHANGES.txt 2007-12-03 17:47:00 UTC (rev 1850)
@@ -1,3 +1,9 @@
+(12/03/2007)
+
+*** Added data channel reuse mode for GridFTP if the server
+ version is 2.3. Presumably more versions support this and
+ they should eventually be added.
+
(10/30/2007)
*** Added totalSize implementation to data sources such that
Modified: trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java
===================================================================
--- trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java 2007-11-30 19:47:29 UTC (rev 1849)
+++ trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/execution/gt2/GlobusSecurityContextImpl.java 2007-12-03 17:47:00 UTC (rev 1850)
@@ -19,7 +19,7 @@
public void setAuthorization(Authorization authorization) {
setAttribute("authorization", authorization);
}
-
+
public Authorization getAuthorization() {
Authorization authorization = (Authorization) getAttribute("authorization");
if (authorization == null) {
Modified: trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java
===================================================================
--- trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java 2007-11-30 19:47:29 UTC (rev 1849)
+++ trunk/current/src/cog/modules/provider-gt2/src/org/globus/cog/abstraction/impl/file/gridftp/old/FileResourceImpl.java 2007-12-03 17:47:00 UTC (rev 1850)
@@ -49,7 +49,9 @@
import org.globus.ftp.MarkerListener;
import org.globus.ftp.MlsxEntry;
import org.globus.ftp.Session;
+import org.globus.ftp.exception.ClientException;
import org.globus.ftp.exception.ServerException;
+import org.globus.ftp.vanilla.Reply;
import org.ietf.jgss.GSSCredential;
/**
@@ -67,6 +69,8 @@
public static final int MAX_REPLY_WAIT_TIME = 30000; // ms
private GridFTPClient gridFTPClient;
+ private boolean dataChannelReuse;
+ private boolean dataChannelInitialized;
/** throws InvalidProviderException */
public FileResourceImpl() throws Exception {
@@ -96,12 +100,21 @@
port = 2811;
}
gridFTPClient = new GridFTPClient(host, port);
+ Reply r = gridFTPClient.getLastReply();
+
+ if (r != null && r.getMessage().indexOf("GridFTP Server 2.3") != -1) {
+ dataChannelReuse = true;
+ logger.debug("GridFTP version is 2.3. Enabling data channel reuse.");
+ }
gridFTPClient.setClientWaitParams(MAX_REPLY_WAIT_TIME,
Session.DEFAULT_WAIT_DELAY);
GSSCredential proxy = (GSSCredential) getSecurityContext()
.getCredentials();
gridFTPClient.authenticate(proxy);
gridFTPClient.setType(Session.TYPE_IMAGE);
+ if (dataChannelReuse) {
+ gridFTPClient.setMode(GridFTPSession.MODE_EBLOCK);
+ }
setSecurityOptions(gridFTPClient);
setStarted(true);
@@ -112,6 +125,14 @@
}
}
+ private void initializeDataChannel() throws ClientException,
+ ServerException, IOException {
+ if (!dataChannelInitialized || !dataChannelReuse) {
+ gridFTPClient.setPassiveMode(true);
+ dataChannelInitialized = true;
+ }
+ }
+
protected void setSecurityOptions(GridFTPClient client)
throws ServerException, IOException {
DataChannelAuthenticationType dcau = GridFTPSecurityContext
@@ -193,7 +214,7 @@
Vector gridFileList = new Vector();
try {
- gridFTPClient.setPassiveMode(true);
+ this.initializeDataChannel();
Enumeration list = gridFTPClient.list().elements();
while (list.hasMoreElements()) {
gridFileList.add(createGridFile((FileInfo) list.nextElement()));
@@ -288,7 +309,7 @@
public void get(String remoteFileName, DataSink sink,
MarkerListener mListener) throws FileResourceException {
try {
- gridFTPClient.setPassiveMode(true);
+ initializeDataChannel();
gridFTPClient.get(remoteFileName, sink, mListener);
}
catch (Exception e) {
@@ -300,7 +321,7 @@
public void get(String remoteFileName, File localFile)
throws FileResourceException {
try {
- gridFTPClient.setPassiveMode(true);
+ initializeDataChannel();
gridFTPClient.get(remoteFileName, localFile);
}
catch (Exception e) {
@@ -320,7 +341,7 @@
final ProgressMonitor progressMonitor) throws FileResourceException {
File localFile = new File(localFileName);
try {
- gridFTPClient.setPassiveMode(true);
+ initializeDataChannel();
final long size = localFile.length();
DataSink sink;
if (progressMonitor != null) {
@@ -353,7 +374,7 @@
final File localFile = new File(localFileName);
try {
- gridFTPClient.setPassiveMode(true);
+ initializeDataChannel();
final long size = localFile.length();
DataSource source;
if (progressMonitor != null) {
@@ -362,7 +383,7 @@
progressMonitor.progress(totalRead, size);
return super.read();
}
-
+
public long totalSize() {
return localFile.length();
}
@@ -387,7 +408,7 @@
throws FileResourceException {
try {
- gridFTPClient.setPassiveMode(true);
+ initializeDataChannel();
gridFTPClient.put(localFile, remoteFileName, append);
}
catch (Exception e) {
@@ -403,7 +424,7 @@
public void put(DataSource source, String remoteFileName,
MarkerListener mListener) throws FileResourceException {
try {
- gridFTPClient.setPassiveMode(true);
+ initializeDataChannel();
gridFTPClient.put(remoteFileName, source, mListener);
}
catch (Exception e) {
@@ -487,7 +508,8 @@
return createGridFile(e);
}
catch (Exception e) {
- throw translateException("Failed to retrieve file information about " + fileName, e);
+ throw translateException(
+ "Failed to retrieve file information about " + fileName, e);
}
}
@@ -552,7 +574,7 @@
return gridFile;
}
-
+
private GridFile createGridFile(MlsxEntry e) throws FileResourceException {
GridFile gridFile = new GridFileImpl();
@@ -571,7 +593,8 @@
if (MlsxEntry.TYPE_FILE.equals(type)) {
gridFile.setFileType(GridFile.FILE);
}
- if (MlsxEntry.TYPE_DIR.equals(type) || MlsxEntry.TYPE_PDIR.equals(type) || MlsxEntry.TYPE_CDIR.equals(type)) {
+ if (MlsxEntry.TYPE_DIR.equals(type) || MlsxEntry.TYPE_PDIR.equals(type)
+ || MlsxEntry.TYPE_CDIR.equals(type)) {
gridFile.setFileType(GridFile.DIRECTORY);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fug...@us...> - 2007-11-30 19:47:32
|
Revision: 1849
http://cogkit.svn.sourceforge.net/cogkit/?rev=1849&view=rev
Author: fugangwang
Date: 2007-11-30 11:47:29 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
add notes for meeting 2
Added Paths:
-----------
trunk/cyberaide/doc/meeting2.doc
Added: trunk/cyberaide/doc/meeting2.doc
===================================================================
(Binary files differ)
Property changes on: trunk/cyberaide/doc/meeting2.doc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-11-29 20:47:27
|
Revision: 1848
http://cogkit.svn.sourceforge.net/cogkit/?rev=1848&view=rev
Author: hategan
Date: 2007-11-29 12:47:15 -0800 (Thu, 29 Nov 2007)
Log Message:
-----------
collapsed sync blocks
Modified Paths:
--------------
trunk/current/src/cog/modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java
Modified: trunk/current/src/cog/modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java
===================================================================
--- trunk/current/src/cog/modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java 2007-11-26 19:27:13 UTC (rev 1847)
+++ trunk/current/src/cog/modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceCache.java 2007-11-29 20:47:15 UTC (rev 1848)
@@ -12,7 +12,6 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -72,9 +71,9 @@
if (logger.isDebugEnabled()) {
logger.debug("Got request for resource for " + service);
}
- checkTimer();
FileResource fileResource;
synchronized (this) {
+ checkTimer();
if (fileResources.containsKey(service)) {
List resources = (List) fileResources.get(service);
Iterator i = resources.iterator();
@@ -230,7 +229,7 @@
this.maxIdleTime = maxIdleTime;
}
- private synchronized void checkTimer() {
+ private void checkTimer() {
if (timer == null) {
timer = new Timer(true);
timer.schedule(new ResourceSwipe(this), 60000, 60000);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-11-26 19:27:27
|
Revision: 1847
http://cogkit.svn.sourceforge.net/cogkit/?rev=1847&view=rev
Author: hategan
Date: 2007-11-26 11:27:13 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
updated jglobus jars
Modified Paths:
--------------
trunk/current/src/cog/modules/jglobus/project.properties
Added Paths:
-----------
trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071125.jar
trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071125.jar
Removed Paths:
-------------
trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-1.4-dev-071030.jar
trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-1.4-dev-071030.jar
Deleted: trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-1.4-dev-071030.jar
===================================================================
(Binary files differ)
Added: trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071125.jar
===================================================================
(Binary files differ)
Property changes on: trunk/current/src/cog/modules/jglobus/lib/cog-jglobus-dev-071125.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-1.4-dev-071030.jar
===================================================================
(Binary files differ)
Added: trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071125.jar
===================================================================
(Binary files differ)
Property changes on: trunk/current/src/cog/modules/jglobus/lib/cog-jobmanager-dev-071125.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/current/src/cog/modules/jglobus/project.properties
===================================================================
--- trunk/current/src/cog/modules/jglobus/project.properties 2007-11-25 04:27:55 UTC (rev 1846)
+++ trunk/current/src/cog/modules/jglobus/project.properties 2007-11-26 19:27:13 UTC (rev 1847)
@@ -1,6 +1,6 @@
module.name = jglobus
long.name = JGlobus
-version = 1.2-060802
+version = dev-071125
project = Java CoG Kit
no.javadoc.compile = true
lib.deps = cog-jglobus-*.*,cryptix.*,cryptix32.*,jgss.*,jce-jdk13-131.*,cryptix-asn1.*,junit.*,puretls.*,log4j*.*,commons-logging*.*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|