/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * published by the Free Software Foundation; either version 2.1 of
 * the license, or (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *  
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite
 * 330, Boston, MA  02111-1307, USA.
 * 
 */
package com.k_int.svc.custprops.util;

import java.util.Iterator;

import com.k_int.svc.custprops.datamodel.PropertyDefinitionHDO;
import com.k_int.svc.custprops.datamodel.SchemaDefinitionHDO;
import com.k_int.svc.custprops.datamodel.dto.PropertyDefinitionDTO;
import com.k_int.svc.custprops.datamodel.dto.SchemaDefinitionDTO;


/**
 * Title:		SchemaConverter
 * @author: 	rob
 * @version:	$Id: v Exp $ 
 * @since			
 * Copyright:	1999-2007 Knowledge Integration Ltd
 * Company:		Knowledge Integration Ltd
 * Description:
 *
 *
 *
 * Created:		15 Jan 2008
 *
 *
 * History:
 *				$Log: v $
 *
 * 
 */

public class SchemaConverter
{
  public static SchemaDefinitionDTO hdotoDTO(SchemaDefinitionHDO hdo)
  {
    SchemaDefinitionDTO retval = null;
    if(hdo!=null)
    {
      retval = new SchemaDefinitionDTO();
      
      retval.setURI(hdo.getSchemaURI());
      Iterator<PropertyDefinitionHDO> i = hdo.getProperties().iterator();
      while(i.hasNext())
      {
        PropertyDefinitionHDO prop_def = (PropertyDefinitionHDO) i.next();
        PropertyDefinitionDTO dto = new PropertyDefinitionDTO(prop_def.getDataType(),
                                                              prop_def.getPropertyURI(), 
                                                              prop_def.getDefaultName(), 
                                                              prop_def.getPropertyType());
        retval.getProperties().put(prop_def.getPropertyURI(),dto);
      }
    }
    return retval;
  }

}
