<commit_before>package policycompass.fcmmanager.models;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import policycompass.fcmmanager.hibernate.HibernateUtil;

public class FCMModelDetail {

	FCMModel model;
	List<FCMModelInDomain> domains;
	List<FCMConcept> concepts;
	List<FCMConnection> connections;
	List<FCMConceptIndividual> conceptindividuals;

	public FCMModel getModel() {
		return model;
	}

	public void setModel(FCMModel model) {
		this.model = model;
	}

	public List<FCMModelInDomain> getDomains() {
		return domains;
	}

	public void setDomains(List<FCMModelInDomain> domain) {
		this.domains = domain;
	}

	public List<FCMConcept> getConcepts() {
		return concepts;
	}

	public void setConcepts(List<FCMConcept> concepts) {
		this.concepts = concepts;
	}

	public List<FCMConnection> getConnections() {
		return connections;
	}

	public void setConnections(List<FCMConnection> connections) {
		this.connections = connections;
	}

	public List<FCMConceptIndividual> getConceptindividuals() {
		return conceptindividuals;
	}

	public void setConceptindividuals(List<FCMConceptIndividual> conceptindividuals) {
		this.conceptindividuals = conceptindividuals;
	}
/*
	public FCMModelDetail(int modelID) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		Query query = session.createQuery("from fcmmanager_models where id= :id");
		query.setInteger("id", modelID);
		model = (FCMModel) query.uniqueResult();

		Query queryDomain = session.createQuery("from fcmmanager_modelindomain where fcmmodel_id= :id");
		queryDomain.setInteger("id", modelID);
		@SuppressWarnings("unchecked")
		List<FCMModelInDomain> domain = queryDomain.list();
		domains = domain;

		Query queryConcept = session.createQuery("from fcmmanager_concepts where fcmmodel_id= :id");
		queryConcept.setInteger("id", modelID);
		@SuppressWarnings("unchecked")
		List<FCMConcept> concept = queryConcept.list();
		concepts = concept;

		List<Integer> ConceptIDs = new ArrayList<Integer>();
		for (FCMConcept con : concept) {
			ConceptIDs.add(con.getId());
		}

		Query queryConceptIndividual = session
				.createQuery("from fcmmanager_conceptindividuals where concept_id in ( :mId)");
		queryConceptIndividual.setParameterList("mId", ConceptIDs);
		@SuppressWarnings("unchecked")
		List<FCMConceptIndividual> conceptIndividual = queryConceptIndividual.list();
		conceptindividuals = conceptIndividual;

		Query queryConnection = session.createQuery("from fcmmanager_connections where fcmmodel_id= :id");
		queryConnection.setParameter("id", modelID);
		@SuppressWarnings("unchecked")
		List<FCMConnection> connection = queryConnection.list();
		connections = connection;
		session.clear();
		session.close();
	}
        */

	public FCMModelDetail(String userPath, int modelID) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		//Only show draft model to the user who created this model
		Query query = session.createQuery("from fcmmanager_models where id= :id and (isdraft=false or isdraft=null or userpath='' or ''=:userPath or userpath= :userPath)");
		query.setInteger("id", modelID);
		query.setString("userPath", userPath);
		model = (FCMModel) query.uniqueResult();
		if(model!=null){
			Query queryDomain = session.createQuery("from fcmmanager_modelindomain where fcmmodel_id= :id");
			queryDomain.setInteger("id", modelID);
			@SuppressWarnings("unchecked")
			List<FCMModelInDomain> domain = queryDomain.list();
			domains = domain;

			Query queryConcept = session.createQuery("from fcmmanager_concepts where fcmmodel_id= :id");
			queryConcept.setInteger("id", modelID);
			@SuppressWarnings("unchecked")
			List<FCMConcept> concept = queryConcept.list();
			concepts = concept;

			List<Integer> ConceptIDs = new ArrayList<Integer>();
			for (FCMConcept con : concept) {
				ConceptIDs.add(con.getId());
			}

			Query queryConceptIndividual = session
					.createQuery("from fcmmanager_conceptindividuals where concept_id in ( :mId)");
			queryConceptIndividual.setParameterList("mId", ConceptIDs);
			@SuppressWarnings("unchecked")
			List<FCMConceptIndividual> conceptIndividual = queryConceptIndividual.list();
			conceptindividuals = conceptIndividual;

			Query queryConnection = session.createQuery("from fcmmanager_connections where fcmmodel_id= :id");
			queryConnection.setParameter("id", modelID);<commit_msg>show draft model to the all users policycompass/policycompass#659<commit_after>package policycompass.fcmmanager.models;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import policycompass.fcmmanager.hibernate.HibernateUtil;

public class FCMModelDetail {

	FCMModel model;
	List<FCMModelInDomain> domains;
	List<FCMConcept> concepts;
	List<FCMConnection> connections;
	List<FCMConceptIndividual> conceptindividuals;

	public FCMModel getModel() {
		return model;
	}

	public void setModel(FCMModel model) {
		this.model = model;
	}

	public List<FCMModelInDomain> getDomains() {
		return domains;
	}

	public void setDomains(List<FCMModelInDomain> domain) {
		this.domains = domain;
	}

	public List<FCMConcept> getConcepts() {
		return concepts;
	}

	public void setConcepts(List<FCMConcept> concepts) {
		this.concepts = concepts;
	}

	public List<FCMConnection> getConnections() {
		return connections;
	}

	public void setConnections(List<FCMConnection> connections) {
		this.connections = connections;
	}

	public List<FCMConceptIndividual> getConceptindividuals() {
		return conceptindividuals;
	}

	public void setConceptindividuals(List<FCMConceptIndividual> conceptindividuals) {
		this.conceptindividuals = conceptindividuals;
	}
/*
	public FCMModelDetail(int modelID) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		Query query = session.createQuery("from fcmmanager_models where id= :id");
		query.setInteger("id", modelID);
		model = (FCMModel) query.uniqueResult();

		Query queryDomain = session.createQuery("from fcmmanager_modelindomain where fcmmodel_id= :id");
		queryDomain.setInteger("id", modelID);
		@SuppressWarnings("unchecked")
		List<FCMModelInDomain> domain = queryDomain.list();
		domains = domain;

		Query queryConcept = session.createQuery("from fcmmanager_concepts where fcmmodel_id= :id");
		queryConcept.setInteger("id", modelID);
		@SuppressWarnings("unchecked")
		List<FCMConcept> concept = queryConcept.list();
		concepts = concept;

		List<Integer> ConceptIDs = new ArrayList<Integer>();
		for (FCMConcept con : concept) {
			ConceptIDs.add(con.getId());
		}

		Query queryConceptIndividual = session
				.createQuery("from fcmmanager_conceptindividuals where concept_id in ( :mId)");
		queryConceptIndividual.setParameterList("mId", ConceptIDs);
		@SuppressWarnings("unchecked")
		List<FCMConceptIndividual> conceptIndividual = queryConceptIndividual.list();
		conceptindividuals = conceptIndividual;

		Query queryConnection = session.createQuery("from fcmmanager_connections where fcmmodel_id= :id");
		queryConnection.setParameter("id", modelID);
		@SuppressWarnings("unchecked")
		List<FCMConnection> connection = queryConnection.list();
		connections = connection;
		session.clear();
		session.close();
	}
        */

	public FCMModelDetail(String userPath, int modelID) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		//Only show draft model to the user who created this model
		//Query query = session.createQuery("from fcmmanager_models where id= :id and (isdraft=false or isdraft=null or userpath='' or ''=:userPath or userpath= :userPath)");

		//show draft model to the all users
		Query query = session.createQuery("from fcmmanager_models where id= :id");
		query.setInteger("id", modelID);
		//query.setString("userPath", userPath);
		model = (FCMModel) query.uniqueResult();
		if(model!=null){
			Query queryDomain = session.createQuery("from fcmmanager_modelindomain where fcmmodel_id= :id");
			queryDomain.setInteger("id", modelID);
			@SuppressWarnings("unchecked")
			List<FCMModelInDomain> domain = queryDomain.list();
			domains = domain;

			Query queryConcept = session.createQuery("from fcmmanager_concepts where fcmmodel_id= :id");
			queryConcept.setInteger("id", modelID);
			@SuppressWarnings("unchecked")
			List<FCMConcept> concept = queryConcept.list();
			concepts = concept;

			List<Integer> ConceptIDs = new ArrayList<Integer>();
			for (FCMConcept con : concept) {
				ConceptIDs.add(con.getId());
			}

			Query queryConceptIndividual = session
					.createQuery("from fcmmanager_conceptindividuals where concept_id in ( :mId)");
			queryConceptIndividual.setParameterList("mId", ConceptIDs);
			@SuppressWarnings("unchecked")
			List<FCMConceptIndividual> conceptIndividual = queryConceptIndividual.list();
			conceptindividuals = conceptIndividual;

			Query queryConnection = session.createQuery("from fcmmanager_connections where fcmmodel_id= :id");
			queryConnection.setParameter("id", modelID);
{'fraction_non_alphanumeric': 0.11038384734856889, 'fraction_numerical': 0.0003328156201464389, 'mean_word_length': 5.850303951367781, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '1693769', 'n_tokens_mistral': 3057, 'n_tokens_neox': 2721, 'n_words': 582}