<commit_before>/*
 * Created on Jul 26, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

package edu.wustl.catissuecore.bizlogic;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

import edu.wustl.catissuecore.dao.DAO;
import edu.wustl.catissuecore.tissuesite.TissueSiteTreeNode;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.cde.CDE;
import edu.wustl.common.cde.CDEImpl;
import edu.wustl.common.cde.CDEManager;
import edu.wustl.common.cde.PermissibleValue;
import edu.wustl.common.cde.PermissibleValueImpl;
import edu.wustl.common.security.exceptions.UserNotAuthorizedException;
import edu.wustl.common.util.dbManager.DAOException;

/**
 * @author gautam_shetty
 */
public class CDEBizLogic extends DefaultBizLogic implements TreeDataInterface
{

    /**
     * Saves the storageType object in the database.
     * @param obj The storageType object to be saved.
     * @param session The session in which the object is saved.
     * @throws DAOException
     */
    protected void insert(Object obj,DAO dao, SessionDataBean sessionDataBean) throws DAOException, UserNotAuthorizedException
    {
        CDEImpl cde = (CDEImpl) obj;
        dao.insert(cde, sessionDataBean, false,false);

        Iterator iterator = cde.getPermissibleValues().iterator();
        while (iterator.hasNext())
        {
            PermissibleValueImpl permissibleValue = (PermissibleValueImpl) iterator
                    .next();
            permissibleValue.setCde(cde);
            dao.insert(permissibleValue, sessionDataBean, false,false);
        }
    }
    
    public Vector getTreeViewData() throws DAOException
    {
        
        CDE cde = CDEManager.getCDEManager().getCDE(
                Constants.CDE_NAME_TISSUE_SITE);
        Set set = cde.getPermissibleValues();
        Vector vector = new Vector();
        Iterator iterator = set.iterator();
        while (iterator.hasNext())
        {
            PermissibleValueImpl permissibleValueImpl = (PermissibleValueImpl) iterator
                    .next();
            TissueSiteTreeNode treeNode = getTissueSiteTreeNode(permissibleValueImpl);
            vector.add(treeNode);
            List subPVList = getSubPermissibleValues(permissibleValueImpl);
			vector.addAll(subPVList);
        }
        return vector;
    }
    
	private List getSubPermissibleValues(PermissibleValue permissibleValue)
	{
		List pvList = new ArrayList();
		
		Iterator iterator = permissibleValue.getSubPermissibleValues().iterator();
		while(iterator.hasNext())
		{
			PermissibleValueImpl subPermissibleValueImpl = (PermissibleValueImpl)iterator.next();
			TissueSiteTreeNode tissueSiteTreeNode = getTissueSiteTreeNode(subPermissibleValueImpl);
			pvList.add(tissueSiteTreeNode);
			List subPVList = getSubPermissibleValues(subPermissibleValueImpl);
			pvList.addAll(subPVList);
		}
		return pvList;
	}
	
	private TissueSiteTreeNode getTissueSiteTreeNode(PermissibleValueImpl permissibleValueImpl)
	{
	    TissueSiteTreeNode treeNode = new TissueSiteTreeNode();
	    
        treeNode.setIdentifier(permissibleValueImpl.getIdentifier());
        treeNode.setValue(permissibleValueImpl.getValue());
        
        if (permissibleValueImpl.getParentPermissibleValue() != null)
        {
            PermissibleValueImpl parentPermissibleValue = (PermissibleValueImpl) permissibleValueImpl
                    .getParentPermissibleValue();

            treeNode.setParentIdentifier(parentPermissibleValue
                    .getIdentifier());
        }
        else
        {
            treeNode.setCdeLongName(permissibleValueImpl.getCde()
                    .getLongName());
            treeNode.setCdePublicId(permissibleValueImpl.getCde()
                    .getPublicId());
        }
        
        return treeNode; 
	}

	/* (non-Javadoc)
	 * @see edu.wustl.catissuecore.bizlogic.TreeDataInterface#getTreeViewData(edu.wustl.common.beans.SessionDataBean, java.util.Map)
	 */
	public Vector getTreeViewData(SessionDataBean sessionData, Map map) throws DAOException {

		return null;
	}
}<commit_msg>Removed dependency of CDE info while creating the tissue site tree.<commit_after>/*
 * Created on Jul 26, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

package edu.wustl.catissuecore.bizlogic;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

import edu.wustl.catissuecore.dao.DAO;
import edu.wustl.catissuecore.tissuesite.TissueSiteTreeNode;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.cde.CDE;
import edu.wustl.common.cde.CDEImpl;
import edu.wustl.common.cde.CDEManager;
import edu.wustl.common.cde.PermissibleValue;
import edu.wustl.common.cde.PermissibleValueImpl;
import edu.wustl.common.security.exceptions.UserNotAuthorizedException;
import edu.wustl.common.util.dbManager.DAOException;

/**
 * @author gautam_shetty
 */
public class CDEBizLogic extends DefaultBizLogic implements TreeDataInterface
{

    /**
     * Saves the storageType object in the database.
     * @param obj The storageType object to be saved.
     * @param session The session in which the object is saved.
     * @throws DAOException
     */
    protected void insert(Object obj,DAO dao, SessionDataBean sessionDataBean) throws DAOException, UserNotAuthorizedException
    {
        CDEImpl cde = (CDEImpl) obj;
        dao.insert(cde, sessionDataBean, false,false);

        Iterator iterator = cde.getPermissibleValues().iterator();
        while (iterator.hasNext())
        {
            PermissibleValueImpl permissibleValue = (PermissibleValueImpl) iterator
                    .next();
            permissibleValue.setCde(cde);
            dao.insert(permissibleValue, sessionDataBean, false,false);
        }
    }
    
    public Vector getTreeViewData() throws DAOException
    {
        CDE cde = CDEManager.getCDEManager().getCDE(Constants.CDE_NAME_TISSUE_SITE);
        Set set = cde.getPermissibleValues();
        Vector vector = new Vector();
        Iterator iterator = set.iterator();
        while (iterator.hasNext())
        {
            PermissibleValueImpl permissibleValueImpl = (PermissibleValueImpl) iterator
                    .next();
            TissueSiteTreeNode treeNode = getTissueSiteTreeNode(permissibleValueImpl);
            vector.add(treeNode);
            List subPVList = getSubPermissibleValues(permissibleValueImpl);
			vector.addAll(subPVList);
        }
        return vector;
    }
    
	private List getSubPermissibleValues(PermissibleValue permissibleValue)
	{
		List pvList = new ArrayList();
		
		Iterator iterator = permissibleValue.getSubPermissibleValues().iterator();
		while(iterator.hasNext())
		{
			PermissibleValueImpl subPermissibleValueImpl = (PermissibleValueImpl)iterator.next();
			TissueSiteTreeNode tissueSiteTreeNode = getTissueSiteTreeNode(subPermissibleValueImpl);
			pvList.add(tissueSiteTreeNode);
			List subPVList = getSubPermissibleValues(subPermissibleValueImpl);
			pvList.addAll(subPVList);
		}
		return pvList;
	}
	
	private TissueSiteTreeNode getTissueSiteTreeNode(PermissibleValueImpl permissibleValueImpl)
	{
	    String id = permissibleValueImpl.getIdentifier();
	    String val = permissibleValueImpl.getValue();
	    String parentId = null;
	        
	    if (permissibleValueImpl.getParentPermissibleValue() != null)
        {
            PermissibleValueImpl parentPermissibleValue = (PermissibleValueImpl) permissibleValueImpl
                    .getParentPermissibleValue();
            parentId = parentPermissibleValue.getIdentifier();
        }
	    
	    TissueSiteTreeNode treeNode = new TissueSiteTreeNode(id,val,parentId);
        return treeNode; 
	}

	/* (non-Javadoc)
	 * @see edu.wustl.catissuecore.bizlogic.TreeDataInterface#getTreeViewData(edu.wustl.common.beans.SessionDataBean, java.util.Map)
	 */
	public Vector getTreeViewData(SessionDataBean sessionData, Map map) throws DAOException {

		return null;
	}
}
{'fraction_non_alphanumeric': 0.08634897886062343, 'fraction_numerical': 0.0014331780723754925, 'mean_word_length': 3.347871235721703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6034507', 'n_tokens_mistral': 2627, 'n_tokens_neox': 2473, 'n_words': 469}