Index: /gssim/trunk/src/gssim/schedframe/scheduling/queues/TaskQueue.java
===================================================================
--- /gssim/trunk/src/gssim/schedframe/scheduling/queues/TaskQueue.java	(revision 5)
+++ /gssim/trunk/src/gssim/schedframe/scheduling/queues/TaskQueue.java	(revision 1048)
@@ -4,4 +4,5 @@
 import grms.shared.constants.BrokerConstants;
 import org.qcg.broker.schemas.resreqs.ParentType;
+import org.qcg.broker.schemas.resreqs.Workflow;
 import org.qcg.broker.schemas.resreqs.types.TaskStatesName;
 //import org.qcg.broker.schemas.resreqs.types.WorkflowParentStatesType;
@@ -60,43 +61,81 @@
 			int previousTaskReadyCnt = 0;
 			Task task = this.get(i);
+			
 			if(task.getStatus() != (int)BrokerConstants.TASK_STATUS_UNSUBMITTED)
 				continue;
-			try{		
-				parCnt = task.getDescription().getWorkflow().getParentCount();
-			} catch(Exception e){
-				parCnt = 0;
-				//e.printStackTrace();
+			//the following procedure supports only one nested structure
+			Workflow w = task.getDescription().getWorkflow();
+			if (w == null){
+				readyTasks.add(task);
+				continue;
 			}
-			if(parCnt == 0)
-			{
-				readyTasks.add(task);
+			if(w.getAnd() != null) {
+				parCnt = w.getAnd().getParentOpTypeItemCount();
+				if(parCnt == 0)
+				{
+					readyTasks.add(task);
+				}
+				else
+				{
+					for(int j = 0; j < parCnt; j++){
+						ParentType par = w.getAnd().getParentOpTypeItem(j).getParent();
+						if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){
+							if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){
+								break;
+							}
+						}
+						previousTaskReadyCnt++;
+					}
+
+					if(previousTaskReadyCnt == parCnt)
+						readyTasks.add(task);
+				}
+			} 
+			else if(w.getOr() != null) {
+				parCnt = w.getOr().getParentOpTypeItemCount();
+				if(parCnt == 0)
+				{
+					readyTasks.add(task);
+				}
+				else
+				{
+					for(int j = 0; j < parCnt; j++){
+						ParentType par = w.getOr().getParentOpTypeItem(j).getParent();
+						if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){
+							if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){
+								continue;
+							}
+						}
+						previousTaskReadyCnt++;
+					}
+
+					if(previousTaskReadyCnt > 0)
+						readyTasks.add(task);
+				}
 			}
-			else
-			{
-				for(int j = 0; j < parCnt; j++){
-					ParentType par = task.getDescription().getWorkflow().getParent(j);
-					if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){
-						if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){
-							break;
+			
+			else {
+				parCnt = w.getParentCount();
+				if(parCnt == 0)
+				{
+					readyTasks.add(task);
+				}
+				else
+				{
+					for(int j = 0; j < parCnt; j++){
+						ParentType par = w.getParent(j);
+						if(par.getTriggerState().compareTo(TaskStatesName.FINISHED) == 0){
+							if(!checkTaskCompletion(jobRegistry, task.getJobId(), par.getContent())){
+								continue;
+							}
 						}
+						previousTaskReadyCnt++;
 					}
-					previousTaskReadyCnt++;
+
+					if(previousTaskReadyCnt == parCnt)
+						readyTasks.add(task);
 				}
-				
-/*				
- 				if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getParentStates() == WorkflowParentStatesType.AND)
-					readyTasks.add(task);
-				else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getParentStates() == WorkflowParentStatesType.OR)
-					readyTasks.add(task);
-					
-				Because of schama changes above commented code was replaced by the following one. 
-				I strongly believe that this new solution is equivalent.
-				
-	*/		
-				if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null)
-					readyTasks.add(task);
-				else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getOr() != null)
-					readyTasks.add(task);
 			}
+
 		}		
 		return readyTasks;
