//----------------------------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/god4j
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : god4j@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.god4j.editor.elements;

import org.huihoo.god4j.editor.XPDLAttribute;
import org.huihoo.god4j.editor.XPDLComplexComponent;
import org.huihoo.god4j.editor.elements.atoms.XPDLCreated;
import org.huihoo.god4j.editor.elements.atoms.XPDLDescription;
import org.huihoo.god4j.editor.elements.atoms.XPDLLimit;
import org.huihoo.god4j.editor.elements.atoms.XPDLValidFrom;
import org.huihoo.god4j.editor.elements.atoms.XPDLValidTo;
import org.huihoo.workflow.WorkflowComponent;

/**
* Represents a WfMC DTD element that has the similar name.
*
* @see XPDL
*/
public class XPDLProcessHeader extends XPDLComplexComponent
{
	private XPDLCreated refCreated = null; // min=0
	private XPDLDescription refDescription = null; // min=0
	private XPDLLimit refLimit = null; // min=0
	private XPDLValidFrom refValidFrom = null; // min=0
	private XPDLValidTo refValidTo = null; // min=0

	private XPDLAttribute attrDurationUnit = null;

	/**
	* Creates a new instance of the class.
	*
	*/
	public XPDLProcessHeader(XPDLComplexComponent parent)
	{
		super(parent);
	}
//==================================================================
	public void initComponent()
	{
//	-----------------------------------------------
		super.initComponent();
//	-----------------------------------------------
		refCreated = new XPDLCreated(this); // min=0
		refCreated.initComponent();
		
		refDescription = new XPDLDescription(this); // min=0
		refDescription.initComponent();
		
		refLimit = new XPDLLimit(this); // min=0
		refLimit.initComponent();
		
		refValidFrom = new XPDLValidFrom(this); // min=0
		refValidFrom.initComponent();
		
		refValidTo = new XPDLValidTo(this); // min=0
		refValidTo.initComponent();
		
		attrDurationUnit = new XPDLAttribute( this, "DurationUnit",new String[] { "", "Y", "M", "D", "h", "m", "s" }, 3);
		attrDurationUnit.initComponent();

	}

	public void structComponent()
	{
		//	-----------------------------------------------
		super.structComponent();
		//	-----------------------------------------------
		refCreated.structComponent();		
		refDescription.structComponent();		
		refLimit.structComponent();		
		refValidFrom.structComponent();		
		refValidTo.structComponent();		
		attrDurationUnit.structComponent();		
		
		complexChildren.add(attrDurationUnit);		
		complexChildren.add(refCreated);
		complexChildren.add(refDescription);
		complexChildren.add(refLimit);
		complexChildren.add(refValidFrom);
		complexChildren.add(refValidTo);
	
		attributes.add(attrDurationUnit);
	}

	public void loadComponent() 
	{
//	-----------------------------------------------
		super.loadComponent();
//	-----------------------------------------------
		attrDurationUnit.loadComponent();
		
		refCreated.loadComponent();
		refDescription.loadComponent();
		refValidFrom.loadComponent();
		refValidTo.loadComponent();		
	}


	public void saveComponent() 
	{
    if(isReadOnly())
    {
      return;
    }
    
//	-----------------------------------------------
		super.saveComponent();
//	-----------------------------------------------
		attrDurationUnit.saveComponent();
		
		refCreated.saveComponent();
		refDescription.saveComponent();
		refValidFrom.saveComponent();
		refValidTo.saveComponent();
	}
	
	public void saveComponent(WorkflowComponent workflow_component)
	{
		//	-----------------------------------------------
		super.saveComponent(workflow_component);
		//	-----------------------------------------------	
		
		attrDurationUnit.saveComponent();	
		
		refCreated.saveComponent(workflow_component);
		refDescription.saveComponent(workflow_component);
		refValidFrom.saveComponent(workflow_component);
		refValidTo.saveComponent(workflow_component);
	}
//==================================================================
}
