<commit_before>
package edu.wustl.catissuecore.applet.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.wustl.catissuecore.applet.AppletConstants;
import edu.wustl.catissuecore.applet.CopyPasteOperationValidatorModel;
import edu.wustl.catissuecore.util.global.Constants;

/**
 * This is table model for multiple specimen functionality.
 * 
 * @author  <NAME>
 * @version 1.1
 *
 */
public class MultipleSpecimenTableModel extends BaseTabelModel
{

	/**
	 * Default Serial Version ID
	 */
	private static final long serialVersionUID = 1L;

	private int lastCellColumn = 0;
	private int lastCellRow = 0;

	
	/**
	 * attributes of the specimen for which user can specify the values. 
	 */
	String[] specimenAttribute = {"SpecimenCollectionGroup_name", "parentSpecimen", "label",
			"barcode", "class", "type", "SpecimenCharacteristics_tissueSite",
			"SpecimenCharacteristics_tissueSide", "pathologicalStatus", "Quantity_value",
			"concentrationInMicrogramPerMicroliter", "StorageContainer_temp", "comments",
			"specimenEventCollection", "externalIdentifierCollection", "biohazardCollection",
			"derive"};

	/**
	 * Row headers for the attributes. This corrosponds to display value for each of the  specimenAttribute in that order.
	 */
	private static final String[]  rowHeaders = {"* Specimen Group Name", "* Parent", "* Label", "Barcode", "* Class", "* Type",
			"* Tissue Site", "* Tissue Side", "* Pathological Status", "* Quantity", "Concentration",
			"* Storage Position", "Comments", "* Events", "External Identifier(s)", "Biohazards",
			"Derive"};

	/**
	 * Data structure maintianed by the model. Its key format is as follows:
	 * 
	 * key = Specimen:[ColumnNo]_[SpecimenAttribute]
	 * e.g for specimen in column 3 if user enter "my specimen" value for specimen label
	 * then this map will contain value as "my specimen" for the key "Specimen:3_label"
	 * 
	 */
	Map specimenMap;

	int columnCount;

	/** This is a map that holds options to be displayed for various attributes of the specimen
	 *
	 * It contains 
	 * 
	 * 1. MAP - specimen class ->Array of values for specimen Type
	 * 1. Array of values for  Specimen class  
	 * 2. Array of values for Tissue site
	 * 3. Array of values for Tissue side
	 * 4. Array of values for Pathological
	 * */
	Map specimenAttributeOptions;

	/***/
	private int columnsPerPage = 5; 
	
	/**/
	private int currentPageIndex = 1;
	
	/**
	 * set default map. 
	 * @param specimenAttributeOptions  initialzation map.
	 */
	public MultipleSpecimenTableModel(int initialColumnCount, Map specimenAttributeOptions)
	{
		specimenMap = new HashMap();
		this.columnCount = initialColumnCount;
		this.specimenAttributeOptions = specimenAttributeOptions;
		
		for (int i=1;i<=initialColumnCount;i++) {
			putIdInMap(i);
		}
	}

	/**
	 * @param i
	 */
	private void putIdInMap(int colNo)
	{
		specimenMap.put(AppletConstants.SPECIMEN_PREFIX + (colNo) + "_" + "id" ,new Long(colNo));
	}

	/**
	 * @see javax.swing.table.DefaultTableModel#getValueAt(int, int)
	 */
	public Object getValueAt(int row, int column)
	{
/*		if (column == 0)
		{
			return rowHeaders[row];
		}
      System.out.println("getValueAt " + row + " " + column + ": " + getKey(row,column) + "  " + specimenMap.get(getKey(row,column)));
*/      
		return specimenMap.get(getKey(row,column));
	}

	/**
	 * @see javax.swing.table.DefaultTableModel#setValueAt(java.lang.Object, int, int)
	 */
	public void setValueAt(Object value, int row, int column)
	{
/*		if (column != 0)
		{
			specimenMap.put(getKey(row,column), value);
		}
       System.out.println("setValueAt " + row + " " + column + ": " + specimenMap.get(getKey(row,column)) + value);
*/
		/* Code to check the calling method. 
		try
		{
			throw new Exception("User Defined");
		}
		catch(Exception e){ e.printStackTrace();}
		*/ 
		specimenMap.put(getKey(row,column), value);
		System.out.println("In setValueAt : row : "+row + " Column : "+ column);
		System.out.println("setValueAt " + getKey(row,column)+ ": " + specimenMap.get(getKey(row,column))+" - " + value);
	}

	/**
	 * @see javax.swing.table.DefaultTableModel#getColumnCount()
	 */
	public int getColumnCount()
	{
		
		if(currentPageIndex > (columnCount / columnsPerPage)) {
			return columnCount % columnsPerPage;
		}
		
		return columnsPerPage;
	}

	/**
	 * @return Returns the currentPageIndex.
	 */
	public int getCurrentPageIndex() {
		return currentPageIndex;
	}
	/**
	 * @param currentPageIndex The currentPageIndex to set.
	 */
	public void setCurrentPageIndex(int currentPageIndex) {
		this.currentPageIndex = currentPageIndex;<commit_msg>*** empty log message ***<commit_after>
package edu.wustl.catissuecore.applet.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.wustl.catissuecore.applet.AppletConstants;
import edu.wustl.catissuecore.applet.CopyPasteOperationValidatorModel;
import edu.wustl.catissuecore.util.global.Constants;

/**
 * This is table model for multiple specimen functionality.
 * 
 * @author  <NAME>er
 * @version 1.1
 *
 */
public class MultipleSpecimenTableModel extends BaseTabelModel
{

	/**
	 * Default Serial Version ID
	 */
	private static final long serialVersionUID = 1L;

	private int lastCellColumn = 0;
	private int lastCellRow = 0;

	
	/**
	 * attributes of the specimen for which user can specify the values. 
	 */
	String[] specimenAttribute = {"SpecimenCollectionGroup_name", "parentSpecimen", "label",
			"barcode", "class", "type", "SpecimenCharacteristics_tissueSite",
			"SpecimenCharacteristics_tissueSide", "pathologicalStatus", "Quantity_value",
			"concentrationInMicrogramPerMicroliter", "StorageContainer_temp", "comments",
			"specimenEventCollection", "externalIdentifierCollection", "biohazardCollection",
			"derive"};

	/**
	 * Row headers for the attributes. This corrosponds to display value for each of the  specimenAttribute in that order.
	 */
	private static final String[]  rowHeaders = {"* Specimen Group Name", "* Parent", "* Label", "Barcode", "* Class", "* Type",
			"* Tissue Site", "* Tissue Side", "* Pathological Status", "* Quantity", "Concentration",
			"* Storage Position", "Comments", "* Events", "External Identifier(s)", "Biohazards",
			"Derive"};

	/**
	 * Data structure maintianed by the model. Its key format is as follows:
	 * 
	 * key = Specimen:[ColumnNo]_[SpecimenAttribute]
	 * e.g for specimen in column 3 if user enter "my specimen" value for specimen label
	 * then this map will contain value as "my specimen" for the key "Specimen:3_label"
	 * 
	 */
	Map specimenMap;

	int columnCount;

	/** This is a map that holds options to be displayed for various attributes of the specimen
	 *
	 * It contains 
	 * 
	 * 1. MAP - specimen class ->Array of values for specimen Type
	 * 1. Array of values for  Specimen class  
	 * 2. Array of values for Tissue site
	 * 3. Array of values for Tissue side
	 * 4. Array of values for Pathological
	 * */
	Map specimenAttributeOptions;

	/***/
	private int columnsPerPage = 5; 
	
	/**/
	private int currentPageIndex = 1;
	
	/**
	 * set default map. 
	 * @param specimenAttributeOptions  initialzation map.
	 */
	public MultipleSpecimenTableModel(int initialColumnCount, Map specimenAttributeOptions)
	{
		specimenMap = new HashMap();
		this.columnCount = initialColumnCount;
		this.specimenAttributeOptions = specimenAttributeOptions;
		
		for (int i=1;i<=initialColumnCount;i++) {
			putIdInMap(i);
		}
	}

	/**
	 * @param i
	 */
	private void putIdInMap(int colNo)
	{
		specimenMap.put(AppletConstants.SPECIMEN_PREFIX + (colNo) + "_" + "id" ,new Long(colNo));
	}

	/**
	 * @see javax.swing.table.DefaultTableModel#getValueAt(int, int)
	 */
	public Object getValueAt(int row, int column)
	{
/*		if (column == 0)
		{
			return rowHeaders[row];
		}
      System.out.println("getValueAt " + row + " " + column + ": " + getKey(row,column) + "  " + specimenMap.get(getKey(row,column)));
*/      
		return specimenMap.get(getKey(row,column));
	}

	/**
	 * @see javax.swing.table.DefaultTableModel#setValueAt(java.lang.Object, int, int)
	 */
	public void setValueAt(Object value, int row, int column)
	{
/*		if (column != 0)
		{
			specimenMap.put(getKey(row,column), value);
		}
       System.out.println("setValueAt " + row + " " + column + ": " + specimenMap.get(getKey(row,column)) + value);
*/
		/* Code to check the calling method.
		try
		{
			throw new Exception("User Defined");
		}
		catch(Exception e){ e.printStackTrace();}
		 */
		specimenMap.put(getKey(row,column), value);
		System.out.println("In setValueAt : row : "+row + " Column : "+ column);
		System.out.println("setValueAt " + getKey(row,column)+ ": " + specimenMap.get(getKey(row,column))+" - " + value);
	}

	/**
	 * @see javax.swing.table.DefaultTableModel#getColumnCount()
	 */
	public int getColumnCount()
	{
		
		if(currentPageIndex > (columnCount / columnsPerPage)) {
			return columnCount % columnsPerPage;
		}
		
		return columnsPerPage;
	}

	/**
	 * @return Returns the currentPageIndex.
	 */
	public int getCurrentPageIndex() {
		return currentPageIndex;
	}
	/**
	 * @param currentPageIndex The currentPageIndex to set.
	 */
	public void setCurrentPageIndex(int currentPageIndex) {
		this.currentPageIndex = currentPageIndex;
{'fraction_non_alphanumeric': 0.12874798495432563, 'fraction_numerical': 0.0036539494895217626, 'mean_word_length': 3.987138263665595, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 9, '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': '5454724', 'n_tokens_mistral': 3172, 'n_tokens_neox': 2835, 'n_words': 757}