//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.coreImpl.xpdl;

import org.huihoo.workflow.xpdl.WorkflowActivity;
import org.huihoo.workflow.xpdl.WorkflowCondition;
import org.huihoo.workflow.xpdl.WorkflowProcess;
import org.huihoo.workflow.xpdl.WorkflowTransition;

public class WorkflowTransitionImpl extends WorkflowTransition
{
	protected WorkflowProcess workflowProcess;
	
	protected WorkflowActivity fromActivity;
	protected WorkflowActivity toActivity;  
	protected WorkflowCondition condition;
	protected boolean  hidden = false;

	public WorkflowTransitionImpl()
	{
		super();
	}
	public WorkflowTransitionImpl(String uuid_, String name_)
	{
		super(uuid_, name_);
	}
	
	public WorkflowTransitionImpl(String uuid_, String name_, String description_)
	{
		super(uuid_, name_,description_);
	}
	
	
	public boolean   isHidden()
	{
		return this.hidden;
	}
	
	public void      setHidden(boolean hidden)
	{
		this.hidden = hidden;
	}
	
	public WorkflowProcess getWorkflowProcess()
	{
    return (this.workflowProcess);
	}

	public void setWorkflowProcess(WorkflowProcess workflowProcess_)
	{
    this.workflowProcess=workflowProcess_;
	}

	public WorkflowActivity getFromActivity()
	{
		return (this.fromActivity);
	}

	public void setFromActivity(WorkflowActivity fromActivity_)
	{	
		if(this.fromActivity!=null)
		{
			this.fromActivity.removeOutgoingTransition(this);
		}
		this.fromActivity=fromActivity_;
		
		if(this.fromActivity!=null)
		{
			this.fromActivity.addOutgoingTransition(this);
		}
	}
	
	public WorkflowActivity getToActivity()
	{
		return (this.toActivity);
	}

	public void setToActivity(WorkflowActivity toActivity_)
	{
		if(this.toActivity!=null)
		{
			this.toActivity.removeIncomingTransition(this);
		}
		
		this.toActivity=toActivity_;
		
		if(this.toActivity!=null)
		{
			this.toActivity.addIncomingTransition(this);
		}
	}
	
	public WorkflowCondition   getWorkflowCondition()
	{
		return this.condition;
	}
	public void                setWorkflowCondition(WorkflowCondition condition)
	{
		this.condition=condition;
	}
	
	public String getTagName()
	{
		return "Transition";
	}
	
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		
		sb.append("[");
		sb.append(getTagName()+":");
		sb.append("[uuid=");
		sb.append(uuid==null ? "?" : uuid);
		sb.append("],");
		sb.append("[name=");
		sb.append(name==null ? "?" : name);
		sb.append("]");
		sb.append("]");
		
		return sb.toString();
	}
}
