<commit_before>package edu.wustl.cab2b.client.ui.viewresults;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.jdesktop.swingx.JXPanel;

import edu.common.dynamicextensions.domaininterface.AssociationInterface;
import edu.common.dynamicextensions.domaininterface.AttributeInterface;
import edu.common.dynamicextensions.domaininterface.EntityInterface;
import edu.wustl.cab2b.client.ui.controls.Cab2bLabel;
import edu.wustl.cab2b.client.ui.controls.Cab2bPanel;
import edu.wustl.cab2b.client.ui.query.Utility;
import edu.wustl.cab2b.client.ui.util.CommonUtils;
import edu.wustl.cab2b.common.datalist.DataRow;
import edu.wustl.cab2b.common.datalist.IDataRow;
import edu.wustl.cab2b.common.ejb.path.PathFinderBusinessInterface;
import edu.wustl.cab2b.common.ejb.path.PathFinderHomeInterface;
import edu.wustl.cab2b.common.queryengine.result.I3DDataRecord;
import edu.wustl.cab2b.common.queryengine.result.ICategorialClassRecord;
import edu.wustl.cab2b.common.queryengine.result.IQueryResult;
import edu.wustl.cab2b.common.queryengine.result.IRecord;
import edu.wustl.common.querysuite.metadata.associations.IAssociation;
import edu.wustl.common.querysuite.metadata.associations.IInterModelAssociation;

/**
 * @author rahul_ner
 *
 */
public class ResultPanelFactory {

    private ResultPanelFactory() {

    }

    /**
     * @param queryResult
     */
    public static JXPanel getResultPanel(SimpleSearchResultBreadCrumbPanel searchPanel,
                                         IQueryResult<IRecord> queryResult, IDataRow parentDataRow,
                                         IAssociation association) {
        ResultPanel resultPanel = null;
        int recordNo = Utility.getRecordNum(queryResult);

        if (recordNo == 0) {
            return getNoResultFoundPopup(queryResult);
        }

        Map<String, List<IRecord>> allRecords = queryResult.getRecords();
        IRecord record = null;
        String urlKey = null;

        for (String key : allRecords.keySet()) {
            List<IRecord> recordList = allRecords.get(key);
            if (!recordList.isEmpty()) {
                urlKey = key;
                record = recordList.get(0);
                break;
            }
        }

        Collection<AssociationInterface> incomingAssociationCollection = null;
        List<IInterModelAssociation> intraModelAssociationCollection = null;

        PathFinderBusinessInterface busInt = (PathFinderBusinessInterface) CommonUtils.getBusinessInterface(
                                                                                                            "edu.wustl.cab2b.server.ejb.path.PathFinderBean",
                                                                                                            PathFinderHomeInterface.class,
                                                                                                            null);

        EntityInterface entity = null;
        if (record instanceof ICategorialClassRecord) {
            entity = ((ICategorialClassRecord) record).getCategorialClass().getCategorialClassEntity();
        } else {
            entity = queryResult.getOutputEntity();
        }

        try {
            incomingAssociationCollection = busInt.getIncomingIntramodelAssociations(entity.getId());

            intraModelAssociationCollection = busInt.getInterModelAssociations(entity.getId());
        } catch (RemoteException re) {
            CommonUtils.handleException(re, searchPanel, true, true, false, false);
        }<commit_msg>getting Incoming Intramodel Associations from utility<commit_after>package edu.wustl.cab2b.client.ui.viewresults;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.jdesktop.swingx.JXPanel;

import edu.common.dynamicextensions.domaininterface.AssociationInterface;
import edu.common.dynamicextensions.domaininterface.AttributeInterface;
import edu.common.dynamicextensions.domaininterface.EntityInterface;
import edu.wustl.cab2b.client.ui.controls.Cab2bLabel;
import edu.wustl.cab2b.client.ui.controls.Cab2bPanel;
import edu.wustl.cab2b.client.ui.query.Utility;
import edu.wustl.cab2b.client.ui.util.CommonUtils;
import edu.wustl.cab2b.common.datalist.DataRow;
import edu.wustl.cab2b.common.datalist.IDataRow;
import edu.wustl.cab2b.common.ejb.EjbNamesConstants;
import edu.wustl.cab2b.common.ejb.path.PathFinderBusinessInterface;
import edu.wustl.cab2b.common.ejb.path.PathFinderHomeInterface;
import edu.wustl.cab2b.common.ejb.utility.UtilityBusinessInterface;
import edu.wustl.cab2b.common.ejb.utility.UtilityHomeInterface;
import edu.wustl.cab2b.common.queryengine.result.I3DDataRecord;
import edu.wustl.cab2b.common.queryengine.result.ICategorialClassRecord;
import edu.wustl.cab2b.common.queryengine.result.IQueryResult;
import edu.wustl.cab2b.common.queryengine.result.IRecord;
import edu.wustl.common.querysuite.metadata.associations.IAssociation;
import edu.wustl.common.querysuite.metadata.associations.IInterModelAssociation;

/**
 * @author rahul_ner
 *
 */
public class ResultPanelFactory {

    private ResultPanelFactory() {

    }

    /**
     * @param queryResult
     */
    public static JXPanel getResultPanel(SimpleSearchResultBreadCrumbPanel searchPanel,
                                         IQueryResult<IRecord> queryResult, IDataRow parentDataRow,
                                         IAssociation association) {
        ResultPanel resultPanel = null;
        int recordNo = Utility.getRecordNum(queryResult);

        if (recordNo == 0) {
            return getNoResultFoundPopup(queryResult);
        }

        Map<String, List<IRecord>> allRecords = queryResult.getRecords();
        IRecord record = null;
        String urlKey = null;

        for (String key : allRecords.keySet()) {
            List<IRecord> recordList = allRecords.get(key);
            if (!recordList.isEmpty()) {
                urlKey = key;
                record = recordList.get(0);
                break;
            }
        }

        PathFinderBusinessInterface pathFinder = (PathFinderBusinessInterface) CommonUtils.getBusinessInterface(EjbNamesConstants.PATH_FINDER_BEAN,
                                                                                                            PathFinderHomeInterface.class,
                                                                                                            null);
        UtilityBusinessInterface utilityBean = (UtilityBusinessInterface) CommonUtils.getBusinessInterface(EjbNamesConstants.UTILITY_BEAN,
                                                                                                          UtilityHomeInterface.class,
                                                                                                            null);
        Collection<AssociationInterface> incomingAssociationCollection = null;
        List<IInterModelAssociation> intraModelAssociationCollection = null;
        EntityInterface entity = null;
        if (record instanceof ICategorialClassRecord) {
            entity = ((ICategorialClassRecord) record).getCategorialClass().getCategorialClassEntity();
        } else {
            entity = queryResult.getOutputEntity();
        }

        try {
            incomingAssociationCollection = utilityBean.getIncomingIntramodelAssociations(entity.getId());
            intraModelAssociationCollection = pathFinder.getInterModelAssociations(entity.getId());
        } catch (RemoteException re) {
            CommonUtils.handleException(re, searchPanel, true, true, false, false);
        }
{'fraction_non_alphanumeric': 0.08313968499870901, 'fraction_numerical': 0.005163955589981926, 'mean_word_length': 2.3594969644405897, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 43, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6819607', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2100, 'n_words': 302}