package gov.nih.nci.calab.dto.search;

import gov.nih.nci.calab.dto.particle.ParticleBean;
import gov.nih.nci.calab.service.util.StringUtils;

import org.displaytag.decorator.TableDecorator;

/**
 * This decorator is used to for decorate different properties of a nanoparticle
 * to be shown properly in the view page using display tag lib.
 * 
 * @author pansu
 * 
 */
public class NanoparticleDecorator extends TableDecorator {
	public String getEditParticleURL() {
		ParticleBean particle = (ParticleBean) getCurrentRowObject();
		// replace space with special char
		String particleType = particle.getSampleType().replace(" ", "%20");
		String particleName = particle.getSampleName();
		String editParticleURL = "nanoparticleGeneralInfo.do?dispatch=setupUpdate&particleType="
				+ particleType + "&particleName=" + particleName;
		String link = "<a href=" + editParticleURL + ">"
				+ particle.getSortableName() + "</a>";
		return link;
	}

	public String getViewParticleURL() {
		ParticleBean particle = (ParticleBean) getCurrentRowObject();
		// replace space with special char
		String particleType = particle.getSampleType().replace(" ", "%20");
		String particleName = particle.getSampleName();
		String viewParticleURL = "nanoparticleGeneralInfo.do?dispatch=setupView&particleType="
				+ particleType + "&particleName=" + particleName;
		String link = "<a href=" + viewParticleURL + ">"
				+ particle.getSortableName() + "</a>";
		return link;
	}

	public String getKeywordsStr() {
		ParticleBean particle = (ParticleBean) getCurrentRowObject();
		return StringUtils.join(particle.getKeywords(), "<br>");
	}

	public String getFunctionTypesStr() {
		ParticleBean particle = (ParticleBean) getCurrentRowObject();
		return StringUtils.join(particle.getFunctionTypes(), "<br>");
	}

	public String getCharacterizationsStr() {
		ParticleBean particle = (ParticleBean) getCurrentRowObject();
		return StringUtils.join(particle.getCharacterizations(), "<br>");
	}
}

@@ -32,16 +32,66 @@
 earch;%0A%0A
+import gov.nih.nci.calab.dto.common.SortableName;%0A
 import g
@@ -478,29 +478,35 @@
  %7B%0A%09public S
-tring
+ortableName
  getEditPart
@@ -945,37 +945,35 @@
 %09+ particle.getS
-ortab
+amp
 leName() + %22%3C/a%3E
@@ -973,32 +973,118 @@
 + %22%3C/a%3E%22;%0A%09%09
-return l
+SortableName sortableLink=new SortableName(particle.getSampleName(), link);%0A%09%09return sortableL
 ink;%0A%09%7D%0A%0A%09pu
@@ -1085,29 +1085,35 @@
 %7D%0A%0A%09public S
-tring
+ortableName
  getViewPart
@@ -1558,21 +1558,19 @@
 cle.getS
-ortab
+amp
 leName()
@@ -1586,20 +1586,108 @@
 ;%0A%09%09
-return l
+SortableName sortableLink=new SortableName(particle.getSampleName(), link);%0A%09%09return sortableL
 ink;
+%09%09
 %0A%09%7D%0A

return SortableName for the particle URLs