<commit_before>/*
 * The Gemma project.
 * 
 * Copyright (c) 2006-2007 University of British Columbia
 * 
 * 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.
 *
 */
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package ubic.gemma.model.common.description;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import ubic.gemma.model.expression.biomaterial.BioMaterialImpl;
import ubic.gemma.model.expression.experiment.ExpressionExperimentImpl;
import ubic.gemma.model.expression.experiment.FactorValueImpl;

/**
 * @see ubic.gemma.model.common.description.CharacteristicService
 */
public class CharacteristicServiceImpl extends ubic.gemma.model.common.description.CharacteristicServiceBase {

    private static final Class[] CLASSES_WITH_CHARACTERISTICS = new Class[] {
        ExpressionExperimentImpl.class, BioMaterialImpl.class, FactorValueImpl.class
    };
    
    /**
     * @see ubic.gemma.model.common.description.CharacteristicService#findByValue(java.lang.String)
     */
    @Override
    protected java.util.Collection handleFindByValue( java.lang.String search ) throws java.lang.Exception {
        return handleFindByValue( search, 0, 0 );
    }
    
    /**
     * @see ubic.gemma.model.common.description.CharacteristicService#findByValue(java.lang.String)
     */
    @Override
    protected java.util.Collection handleFindByValue( java.lang.String search, int firstResult, int maxResults ) throws java.lang.Exception {
        return this.getCharacteristicDao().findByValue( search + '%', 0, 0 );
    }

    /**
     * @see ubic.gemma.model.common.description.CharacteristicServiceBase#handleFindByParentClass(java.lang.Object)
     */
    @Override
    protected Map handleFindByParentClass( java.lang.Class parentClass ) {
        return this.getCharacteristicDao().findByParentClass( parentClass );
    }

    /* (non-Javadoc)
     * @see ubic.gemma.model.common.description.CharacteristicServiceBase#handleGetParent(ubic.gemma.model.common.description.Characteristic)
     */
    @Override
    protected Object handleGetParent( Characteristic characteristic ) throws Exception {
        Collection chars = Arrays.asList( new Characteristic[] { characteristic } );
        for ( Class parentClass : CLASSES_WITH_CHARACTERISTICS ) {
           Map<Characteristic, Object> charToParent = this.getCharacteristicDao().getParents( parentClass, chars );
           if ( charToParent.containsKey( characteristic ) )
               return charToParent.get( characteristic );<commit_msg>Bug fix.<commit_after>/*
 * The Gemma project.
 * 
 * Copyright (c) 2006-2007 University of British Columbia
 * 
 * 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.
 *
 */
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package ubic.gemma.model.common.description;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import ubic.gemma.model.expression.biomaterial.BioMaterialImpl;
import ubic.gemma.model.expression.experiment.ExpressionExperimentImpl;
import ubic.gemma.model.expression.experiment.FactorValueImpl;

/**
 * @see ubic.gemma.model.common.description.CharacteristicService
 */
public class CharacteristicServiceImpl extends ubic.gemma.model.common.description.CharacteristicServiceBase {

    private static final Class[] CLASSES_WITH_CHARACTERISTICS = new Class[] {
        ExpressionExperimentImpl.class, BioMaterialImpl.class, FactorValueImpl.class
    };
    
    /**
     * @see ubic.gemma.model.common.description.CharacteristicService#findByValue(java.lang.String)
     */
    @Override
    protected java.util.Collection handleFindByValue( java.lang.String search ) throws java.lang.Exception {
        return handleFindByValue( search, 0, 0 );
    }
    
    /**
     * @see ubic.gemma.model.common.description.CharacteristicService#findByValue(java.lang.String)
     */
    @Override
    protected java.util.Collection handleFindByValue( java.lang.String search, int firstResult, int maxResults ) throws java.lang.Exception {
        return this.getCharacteristicDao().findByValue( search + '%', firstResult, maxResults );
    }

    /**
     * @see ubic.gemma.model.common.description.CharacteristicServiceBase#handleFindByParentClass(java.lang.Object)
     */
    @Override
    protected Map handleFindByParentClass( java.lang.Class parentClass ) {
        return this.getCharacteristicDao().findByParentClass( parentClass );
    }

    /* (non-Javadoc)
     * @see ubic.gemma.model.common.description.CharacteristicServiceBase#handleGetParent(ubic.gemma.model.common.description.Characteristic)
     */
    @Override
    protected Object handleGetParent( Characteristic characteristic ) throws Exception {
        Collection chars = Arrays.asList( new Characteristic[] { characteristic } );
        for ( Class parentClass : CLASSES_WITH_CHARACTERISTICS ) {
           Map<Characteristic, Object> charToParent = this.getCharacteristicDao().getParents( parentClass, chars );
           if ( charToParent.containsKey( characteristic ) )
               return charToParent.get( characteristic );
{'fraction_non_alphanumeric': 0.09465478841870824, 'fraction_numerical': 0.004772510340439071, 'mean_word_length': 3.8029029793735676, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3407716', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1693, 'n_words': 441}