<commit_before><commit_msg>Adding print functionality for SCG<commit_after>package edu.wustl.catissuecore.print;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;

import edu.wustl.catissuecore.domain.Specimen;
import edu.wustl.catissuecore.domain.SpecimenCollectionGroup;
import edu.wustl.common.domain.AbstractDomainObject;
import gov.nih.nci.security.authorization.domainobjects.User;
/**
 * This Class is used to define method for Specimen label printing
 * @author falguni_sachde
 */
public class SpecimenCollectionGroupLabelPrinterImpl implements LabelPrinter {


	public boolean printLabel(AbstractDomainObject abstractDomainObject, String ipAddress, User userObj) {
		
		ArrayList listMap = (ArrayList) createObjectMap(abstractDomainObject);
		
		try
		{
			  PrintServiceInputParserInterface objParser = new PrintServiceInputXMLParser();
			  return objParser.callPrintWebService(listMap);
			
		}
		catch(Exception exp)
		{
			return false;
			
		}
		
	}
	

	/* (non-Javadoc)
	 * @see edu.wustl.catissuecore.print.LabelPrinter#printLabel(java.util.List, java.lang.String, gov.nih.nci.security.authorization.domainobjects.User)
	 */
	public boolean printLabel(List<AbstractDomainObject> abstractDomainObjectList, String ipAddress, User userObj) {
		
		//No list of scg
		return false;
		
	}
	
	
	/**
	 * @param abstractDomainObject
	 * @return
	 */
	List createObjectMap(AbstractDomainObject abstractDomainObject)
	{
		ArrayList listMap = new ArrayList ();
		if(abstractDomainObject instanceof SpecimenCollectionGroup)
		{
			
			SpecimenCollectionGroup objSCG = (SpecimenCollectionGroup)abstractDomainObject;
			Collection specimenCollection = objSCG.getSpecimenCollection();
			Iterator itr = specimenCollection.iterator();
			ArrayList specimenList = new ArrayList();
			while(itr.hasNext())
			{
				Specimen objSpecimen = (Specimen)itr.next();
				specimenList.add(objSpecimen);				
				
			}
			
			for(int cnt=0;cnt < specimenList.size();cnt++)
			{
				Specimen obj = (Specimen)specimenList.get(cnt);
				LinkedHashMap dataMap = new LinkedHashMap();
				String label= obj.getLabel();
				String barcode = obj.getBarcode();
//			
				dataMap.put("class", obj.getClassName());
				dataMap.put("id",obj.getId().toString());
				dataMap.put("label", label);
				dataMap.put("barcode",barcode);
				listMap.add(dataMap);
			}

		}
		return listMap;
	}	
	
}
{'fraction_non_alphanumeric': 0.10496338486574451, 'fraction_numerical': 0.0004068348250610252, 'mean_word_length': 4.4402654867256635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4234253', 'n_tokens_mistral': 860, 'n_tokens_neox': 738, 'n_words': 140}