/*
 * The Gemma project.
 * 
 * Copyright (c) 2005 Columbia University
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package edu.columbia.gemma.expression.arrayDesign;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <hr>
 * <p>
 * Copyright (c) 2004-2005 Columbia University
 * 
 * @author pavlidis
 * @version $Id$
 * @see edu.columbia.gemma.expression.arrayDesign.ArrayDesign
 */
public class ArrayDesignDaoImpl extends edu.columbia.gemma.expression.arrayDesign.ArrayDesignDaoBase {

    private static Log log = LogFactory.getLog( ArrayDesignDaoImpl.class.getName() );

    @Override
    public ArrayDesign findOrCreate( ArrayDesign arrayDesign ) {
        if ( arrayDesign.getName() == null ) {
            log.debug( "Array design must have a name to use as comparison key" );
            return null;
        }
        ArrayDesign newArrayDesign = this.findByName( arrayDesign.getName() );
        if ( newArrayDesign != null ) {
            return newArrayDesign;
        }
        log.debug( "Creating new arrayDesign: " + arrayDesign.getName() );
        return ( ArrayDesign ) create( arrayDesign );
    }
}
@@ -768,16 +768,145 @@
 Factory;
+%0Aimport org.hibernate.Criteria;%0Aimport org.hibernate.criterion.Restrictions;%0A%0Aimport edu.columbia.gemma.common.protocol.Protocol;
 %0A%0A/**%0A *
@@ -1263,16 +1263,1050 @@
 e() );%0A%0A
+    @Override%0A    public ArrayDesign find( ArrayDesign arrayDesign ) %7B%0A        try %7B%0A            Criteria queryObject = super.getSession( false ).createCriteria( ArrayDesign.class );%0A            queryObject.add( Restrictions.eq( %22name%22, arrayDesign.getName() ) );%0A%0A            java.util.List results = queryObject.list();%0A            Object result = null;%0A            if ( results != null ) %7B%0A                if ( results.size() %3E 1 ) %7B%0A                    throw new org.springframework.dao.InvalidDataAccessResourceUsageException(%0A                            %22More than one instance of '%22 + ArrayDesign.class.getName()%0A                                    + %22' was found when executing query%22 );%0A%0A                %7D else if ( results.size() == 1 ) %7B%0A                    result = ( ArrayDesign ) results.iterator().next();%0A                %7D%0A            %7D%0A            return ( ArrayDesign ) result;%0A        %7D catch ( org.hibernate.HibernateException ex ) %7B%0A            throw super.convertHibernateAccessException( ex );%0A        %7D%0A    %7D%0A%0A
     @Ove

implement find