<commit_before>
package edu.wustl.query.flex.dag;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;

import edu.wustl.cab2b.client.ui.util.ClientConstants;
import edu.wustl.cab2b.client.ui.util.CommonUtils;
import edu.wustl.common.querysuite.queryobject.ICondition;
import edu.wustl.common.querysuite.queryobject.IExpression;
import edu.wustl.common.querysuite.queryobject.IRule;
import edu.wustl.common.querysuite.queryobject.RelationalOperator;
import edu.wustl.query.htmlprovider.HtmlUtility;

public class DAGNode implements Externalizable, Comparable<DAGNode>
{

	private String nodeName = "";
	private int expressionId = 0;
	private String toolTip = "";
	private String operatorBetweenAttrAndAssociation = "";
	private String nodeType = DAGConstant.CONSTRAINT_VIEW_NODE;
	public List<DAGNode> associationList = new ArrayList<DAGNode>();
	public List<String> operatorList = new ArrayList<String>();
	//private List<String> pathList  = new ArrayList<String>();
	public List<DAGPath> dagpathList = new ArrayList<DAGPath>();
	private String errorMsg = "";

	private int x;
	private int y;

	public int getX()
	{
		return x;
	}

	public void setX(int x)
	{
		this.x = x;
	}

	public int getY()
	{
		return y;
	}

	public void setY(int y)
	{
		this.y = y;
	}

	public DAGNode()
	{
		setOperatorBetweenAttrAndAssociation(ClientConstants.OPERATOR_AND);
	}

	public String getNodeName()
	{
		return nodeName;
	}

	public void setNodeName(String nodeName)
	{
		this.nodeName = nodeName;
	}

	/**
	 * @param expression
	 *            Expression to set
	 */
	public void setExpressionId(int expressionId)
	{
		this.expressionId = expressionId;

	}

	public int getExpressionId()
	{
		return expressionId;
	}

	public void setToolTip(IExpression expression)
	{
		StringBuffer sb = new StringBuffer(128);
		IRule rule = null;
		if (!(expression).containsRule())
		{
			return;
		}
		else
		{
			rule = (IRule) expression.getOperand(0);
		}
		int totalConditions = rule.size();

		sb.append("Condition(s) on  \n");
		generateFormattedString(sb, rule, totalConditions);
		this.toolTip = sb.toString();
	}

	private void generateFormattedString(StringBuffer sb, IRule rule, int totalConditions)
	{
		int condnctr =0;
		for (int i = 0; i < totalConditions; i++)
		{
			ICondition condition = rule.getCondition(i);
			if(!HtmlUtility.isAttrHidden(condition.getAttribute()))
			{
				sb.append((condnctr + 1) + ") ");
				String formattedAttributeName = CommonUtils.getFormattedString(condition.getAttribute()
						.getName());
				sb.append(formattedAttributeName).append(' ');
				List<String> values = condition.getValues();
				RelationalOperator operator = condition.getRelationalOperator();
				sb.append(
						edu.wustl.cab2b.client.ui.query.Utility
								.displayStringForRelationalOperator(operator)).append(' ');
				checkEquality(sb, values);
				sb.append('\n');
				condnctr++;
			}
		}
	}

	private void checkEquality(StringBuffer sb, List<String> values)<commit_msg>Changes related to tooltip on adding node without condition<commit_after>
package edu.wustl.query.flex.dag;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;

import edu.wustl.cab2b.client.ui.util.ClientConstants;
import edu.wustl.cab2b.client.ui.util.CommonUtils;
import edu.wustl.common.querysuite.queryobject.ICondition;
import edu.wustl.common.querysuite.queryobject.IExpression;
import edu.wustl.common.querysuite.queryobject.IRule;
import edu.wustl.common.querysuite.queryobject.RelationalOperator;
import edu.wustl.query.htmlprovider.HtmlUtility;

public class DAGNode implements Externalizable, Comparable<DAGNode>
{

	private String nodeName = "";
	private int expressionId = 0;
	private String toolTip = "";
	private String operatorBetweenAttrAndAssociation = "";
	private String nodeType = DAGConstant.CONSTRAINT_VIEW_NODE;
	public List<DAGNode> associationList = new ArrayList<DAGNode>();
	public List<String> operatorList = new ArrayList<String>();
	//private List<String> pathList  = new ArrayList<String>();
	public List<DAGPath> dagpathList = new ArrayList<DAGPath>();
	private String errorMsg = "";

	private int x;
	private int y;

	public int getX()
	{
		return x;
	}

	public void setX(int x)
	{
		this.x = x;
	}

	public int getY()
	{
		return y;
	}

	public void setY(int y)
	{
		this.y = y;
	}

	public DAGNode()
	{
		setOperatorBetweenAttrAndAssociation(ClientConstants.OPERATOR_AND);
	}

	public String getNodeName()
	{
		return nodeName;
	}

	public void setNodeName(String nodeName)
	{
		this.nodeName = nodeName;
	}

	/**
	 * @param expression
	 *            Expression to set
	 */
	public void setExpressionId(int expressionId)
	{
		this.expressionId = expressionId;

	}

	public int getExpressionId()
	{
		return expressionId;
	}

	public void setToolTip(IExpression expression)
	{
		StringBuffer sb = new StringBuffer(128);
		IRule rule = null;
		if (!(expression).containsRule())
		{
			return;
		}
		else
		{
			rule = (IRule) expression.getOperand(0);
		}
		int totalConditions = rule.size();

		if(totalConditions >0)
		{
			sb.append("Condition(s) on  \n");
			generateFormattedString(sb, rule, totalConditions);
		}
		else
		{
			sb.append("No Condition Added \n");
		}
		
		this.toolTip = sb.toString();
	}

	private void generateFormattedString(StringBuffer sb, IRule rule, int totalConditions)
	{
		int condnctr =0;
		for (int i = 0; i < totalConditions; i++)
		{
			ICondition condition = rule.getCondition(i);
			if(!HtmlUtility.isAttrHidden(condition.getAttribute()))
			{
				sb.append((condnctr + 1) + ") ");
				String formattedAttributeName = CommonUtils.getFormattedString(condition.getAttribute()
						.getName());
				sb.append(formattedAttributeName).append(' ');
				List<String> values = condition.getValues();
				RelationalOperator operator = condition.getRelationalOperator();
				sb.append(
						edu.wustl.cab2b.client.ui.query.Utility
								.displayStringForRelationalOperator(operator)).append(' ');
				checkEquality(sb, values);
				sb.append('\n');
				condnctr++;
			}
		}
	}

	private void checkEquality(StringBuffer sb, List<String> values)
{'fraction_non_alphanumeric': 0.11716276124129196, 'fraction_numerical': 0.003641545281823939, 'mean_word_length': 4.264166666666667, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 26, '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': '971999', 'n_tokens_mistral': 2301, 'n_tokens_neox': 2093, 'n_words': 434}