/**
 * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or 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
 *
 * Component of: Red Hat Application Server
 * 
 * Initial Developers: Greg Lapouchnian
 *                     Patrick Smith
 *
 */

package olstore.domain.manager;

import java.util.Collection;

import olstore.dto.TypeValue;
import olstore.entity.TypeLocalHome;
import olstore.session.helper.TypeHelper;

/**
 * A wrapper class for type actions so that there is no need to reference the
 * beans directly, allowing us to swap out the backend beans for a different
 * implementation.
 */
public class TypeManager {
   
   /** A reference to the LocalHome interface for the Type EJB */
   private TypeLocalHome home;
   /** A reference to the TypeHelper */
   private TypeHelper helper;
   
   /**
    * Constructor for the manager which is populated by Spring.
    * @param home a reference to the LocalHome interface
    * @param helper a helper object
    */
   public TypeManager(TypeLocalHome home, TypeHelper helper) {
       this.home = home;
       this.helper = helper;
   }
    
   /**
    * Returns all types in the store.
    * @return a collection of TypeValue objects that exist in the store
    * @throws Exception if an error occurs during lookup
    */
   public Collection findAll() throws Exception {
       return home.findAll();
   }
   
   /**
    * Saves a new type.
    * @param type the TypeValue object that contains the name of the new type.
    * @throws Exception if an error occurs during the creation of the new type
    */
   public void saveType(TypeValue type) throws Exception {
       helper.saveType(type);
   }

}
