<commit_before>/**
 * 
 * $Id: XenograftManagerImpl.java,v 1.28 2006-05-22 15:02:27 pandyas Exp $
 * 
 * $Log: not supported by cvs2svn $
 * Revision 1.27  2006/05/19 18:50:37  pandyas
 * defect #225 - Add clearOrgan functionality to Xenograft screen
 *
 * Revision 1.26  2006/05/19 16:39:43  pandyas
 * Defect #249 - add other to species on the Xenograft screen
 *
 * Revision 1.25  2006/04/20 18:11:30  pandyas
 * Cleaned up Species or Strain save of Other in DB
 *
 * Revision 1.24  2006/04/19 17:38:26  pandyas
 * Removed TODO text
 *
 * Revision 1.23  2006/04/17 19:11:05  pandyas
 * caMod 2.1 OM changes
 *
 * Revision 1.22  2005/12/12 17:33:37  georgeda
 * Defect #265, store host/origin species in correct places
 *
 * Revision 1.21  2005/12/01 13:43:36  georgeda
 * Defect #226, reuse Taxon objects and do not delete them from Database
 *
 * Revision 1.20  2005/11/28 22:54:11  pandyas
 * Defect #186: Added organ/tissue to Xenograft page, modified search page to display multiple Xenografts with headers, modified XenograftManagerImpl so it does not create or save an organ object if not organ is selected
 *
 * Revision 1.19  2005/11/28 13:46:53  georgeda
 * Defect #207, handle nulls for pages w/ uncontrolled vocab
 *
 * Revision 1.18  2005/11/16 15:31:05  georgeda
 * Defect #41. Clean up of email functionality
 *
 * Revision 1.17  2005/11/14 14:19:37  georgeda
 * Cleanup
 *
 * Revision 1.16  2005/11/11 16:27:44  pandyas
 * added javadocs
 *
 * 
 */
package gov.nih.nci.camod.service.impl;

import gov.nih.nci.camod.Constants;
import gov.nih.nci.camod.domain.AnimalModel;
import gov.nih.nci.camod.domain.Organ;
import gov.nih.nci.camod.domain.Strain;
import gov.nih.nci.camod.domain.Xenograft;
import gov.nih.nci.camod.service.XenograftManager;
import gov.nih.nci.camod.util.MailUtil;
import gov.nih.nci.camod.webapp.form.XenograftData;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.util.TreeMap;

/**
 * @author rajputs
 */
public class XenograftManagerImpl extends BaseManager implements XenograftManager
{

    /**
     * Get all Xenograft objects
     * 
     * 
     * @return the matching Xenograft objects, or null if not found.
     * 
     * @exception Exception
     *                when anything goes wrong.
     */    
    public List getAll() throws Exception
    {
        log.trace("In XenograftManagerImpl.getAll");
        return super.getAll(Xenograft.class);
    }

    /**
     * Get a specific Xenograft by id
     * 
     * @param id
     *            the unique id for a Xenograft
     * 
     * @return the matching Xenograft object, or null if not found.
     * 
     * @exception Exception
     *                when anything goes wrong.
     */    
    public Xenograft get(String id) throws Exception
    {
        log.trace("In XenograftManagerImpl.get");
        return (Xenograft) super.get(id, Xenograft.class);
    }

    public void save(Xenograft xenograft) throws Exception
    {
        log.trace("In XenograftManagerImpl.save");
        super.save(xenograft);
    }

    public void remove(String id,
                       AnimalModel inAnimalModel) throws Exception
    {
        log.trace("In XenograftManagerImpl.remove");

        inAnimalModel.getXenograftCollection().remove(get(id));
        super.save(inAnimalModel);
    }

    public Xenograft create(XenograftData inXenograftData,
                            AnimalModel inAnimalModel) throws Exception
    {

        log.trace("<XenograftManagerImpl> Entering XenograftManagerImpl.create");

        Xenograft theXenograft = new Xenograft();
        populateSpeciesStrain(inXenograftData, theXenograft, inAnimalModel);
        populateOrgan(inXenograftData, theXenograft);
        populateXenograft(inXenograftData, theXenograft, inAnimalModel);

        log.info("<XenograftManagerImpl> Exiting XenograftManagerImpl.create");

        return theXenograft;
    }

    public void update(XenograftData inXenograftData,
                       Xenograft inXenograft,
                       AnimalModel inAnimalModel) throws Exception
    {
        log.info("Entering XenograftManagerImpl.update XenograftId: " + inXenograft.getId());

        // Populate w/ the new values and save
        populateSpeciesStrain(inXenograftData, inXenograft, inAnimalModel);
        populateOrgan(inXenograftData, inXenograft);
        populateXenograft(inXenograftData, inXenograft, inAnimalModel);
        save(inXenograft);

        log.info("Exiting XenograftManagerImpl.update");
    }

    private void populateXenograft(XenograftData inXenograftData,
                                   Xenograft inXenograft,
                                   AnimalModel inAnimalModel) throws Exception
    {

        log.info("Entering XenograftManagerImpl.populateXenograft");

        /* Set xenograftName */
        inXenograft.setXenograftName(inXenograftData.getXenograftName());

        /* Set other adminstrative site or selected adminstrative site */
        // save directly in administrativeSite column of table
        if (inXenograftData.getAdministrativeSite().equals(Constants.Dropdowns.OTHER_OPTION))
        {
            inXenograft.setAdministrativeSite(inXenograftData.getOtherAdministrativeSite());

            // Send e-mail for other administrativeSite
            sendEmail(inAnimalModel, inXenograftData.getOtherAdministrativeSite(), "AdministrativeSite");<commit_msg>Fixed otherAdminSite so text is not saved in correct column<commit_after>/**
 * 
 * $Id: XenograftManagerImpl.java,v 1.29 2006-05-22 18:14:36 pandyas Exp $
 * 
 * $Log: not supported by cvs2svn $
 * Revision 1.28  2006/05/22 15:02:27  pandyas
 * Fixed Xenograft so organ is reused/created each time
 *
 * Revision 1.27  2006/05/19 18:50:37  pandyas
 * defect #225 - Add clearOrgan functionality to Xenograft screen
 *
 * Revision 1.26  2006/05/19 16:39:43  pandyas
 * Defect #249 - add other to species on the Xenograft screen
 *
 * Revision 1.25  2006/04/20 18:11:30  pandyas
 * Cleaned up Species or Strain save of Other in DB
 *
 * Revision 1.24  2006/04/19 17:38:26  pandyas
 * Removed TODO text
 *
 * Revision 1.23  2006/04/17 19:11:05  pandyas
 * caMod 2.1 OM changes
 *
 * Revision 1.22  2005/12/12 17:33:37  georgeda
 * Defect #265, store host/origin species in correct places
 *
 * Revision 1.21  2005/12/01 13:43:36  georgeda
 * Defect #226, reuse Taxon objects and do not delete them from Database
 *
 * Revision 1.20  2005/11/28 22:54:11  pandyas
 * Defect #186: Added organ/tissue to Xenograft page, modified search page to display multiple Xenografts with headers, modified XenograftManagerImpl so it does not create or save an organ object if not organ is selected
 *
 * Revision 1.19  2005/11/28 13:46:53  georgeda
 * Defect #207, handle nulls for pages w/ uncontrolled vocab
 *
 * Revision 1.18  2005/11/16 15:31:05  georgeda
 * Defect #41. Clean up of email functionality
 *
 * Revision 1.17  2005/11/14 14:19:37  georgeda
 * Cleanup
 *
 * Revision 1.16  2005/11/11 16:27:44  pandyas
 * added javadocs
 *
 * 
 */
package gov.nih.nci.camod.service.impl;

import gov.nih.nci.camod.Constants;
import gov.nih.nci.camod.domain.AnimalModel;
import gov.nih.nci.camod.domain.Organ;
import gov.nih.nci.camod.domain.Strain;
import gov.nih.nci.camod.domain.Xenograft;
import gov.nih.nci.camod.service.XenograftManager;
import gov.nih.nci.camod.util.MailUtil;
import gov.nih.nci.camod.webapp.form.XenograftData;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.util.TreeMap;

/**
 * @author rajputs
 */
public class XenograftManagerImpl extends BaseManager implements XenograftManager
{

    /**
     * Get all Xenograft objects
     * 
     * 
     * @return the matching Xenograft objects, or null if not found.
     * 
     * @exception Exception
     *                when anything goes wrong.
     */    
    public List getAll() throws Exception
    {
        log.trace("In XenograftManagerImpl.getAll");
        return super.getAll(Xenograft.class);
    }

    /**
     * Get a specific Xenograft by id
     * 
     * @param id
     *            the unique id for a Xenograft
     * 
     * @return the matching Xenograft object, or null if not found.
     * 
     * @exception Exception
     *                when anything goes wrong.
     */    
    public Xenograft get(String id) throws Exception
    {
        log.trace("In XenograftManagerImpl.get");
        return (Xenograft) super.get(id, Xenograft.class);
    }

    public void save(Xenograft xenograft) throws Exception
    {
        log.trace("In XenograftManagerImpl.save");
        super.save(xenograft);
    }

    public void remove(String id,
                       AnimalModel inAnimalModel) throws Exception
    {
        log.trace("In XenograftManagerImpl.remove");

        inAnimalModel.getXenograftCollection().remove(get(id));
        super.save(inAnimalModel);
    }

    public Xenograft create(XenograftData inXenograftData,
                            AnimalModel inAnimalModel) throws Exception
    {

        log.trace("<XenograftManagerImpl> Entering XenograftManagerImpl.create");

        Xenograft theXenograft = new Xenograft();
        populateSpeciesStrain(inXenograftData, theXenograft, inAnimalModel);
        populateOrgan(inXenograftData, theXenograft);
        populateXenograft(inXenograftData, theXenograft, inAnimalModel);

        log.info("<XenograftManagerImpl> Exiting XenograftManagerImpl.create");

        return theXenograft;
    }

    public void update(XenograftData inXenograftData,
                       Xenograft inXenograft,
                       AnimalModel inAnimalModel) throws Exception
    {
        log.info("Entering XenograftManagerImpl.update XenograftId: " + inXenograft.getId());

        // Populate w/ the new values and save
        populateSpeciesStrain(inXenograftData, inXenograft, inAnimalModel);
        populateOrgan(inXenograftData, inXenograft);
        populateXenograft(inXenograftData, inXenograft, inAnimalModel);
        save(inXenograft);

        log.info("Exiting XenograftManagerImpl.update");
    }

    private void populateXenograft(XenograftData inXenograftData,
                                   Xenograft inXenograft,
                                   AnimalModel inAnimalModel) throws Exception
    {

        log.info("Entering XenograftManagerImpl.populateXenograft");

        /* Set xenograftName */
        inXenograft.setXenograftName(inXenograftData.getXenograftName());

        /* Set other adminstrative site or selected adminstrative site */
        // save directly in administrativeSite column of table
        if (inXenograftData.getAdministrativeSite().equals(Constants.Dropdowns.OTHER_OPTION))
        {
            // Do not save other in the DB
            inXenograft.setAdminSiteUnctrlVocab(inXenograftData.getOtherAdministrativeSite());

            // Send e-mail for other administrativeSite
            sendEmail(inAnimalModel, inXenograftData.getOtherAdministrativeSite(), "AdministrativeSite");
{'fraction_non_alphanumeric': 0.08692134831460674, 'fraction_numerical': 0.045393258426966294, 'mean_word_length': 2.8089695309825404, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2651130', 'n_tokens_mistral': 4031, 'n_tokens_neox': 3365, 'n_words': 848}