package gov.nih.nci.cananolab.dto.common;

import gov.nih.nci.cananolab.domain.common.Condition;
import gov.nih.nci.cananolab.domain.common.Datum;

/**
 * View bean for a cell in a table
 *
 * @author pansu
 *
 */
public class TableCell {
	private String value;
	private String datumOrCondition;
	private Datum datum=new Datum();
	private Condition condition=new Condition();

	public TableCell() {

	}

	public TableCell(Datum datum) {
		this.datumOrCondition = FindingBean.DATUM_TYPE;
		// Allow empty Datum (associated with a Condition).
		if (datum.getValue() != null) {
			this.value = datum.getValue().toString();
		}
		this.datum = datum;
		this.condition = null;
	}

	public TableCell(Condition condition) {
		this.datumOrCondition = "condition";
		this.value = condition.getValue();
		this.condition = condition;
		this.datum = null;
	}

	/**
	 * @return the datumOrCondition
	 */
	public String getDatumOrCondition() {
		return datumOrCondition;
	}

	/**
	 * @param datumOrCondition
	 *            the datumOrCondition to set
	 */
	public void setDatumOrCondition(String datumOrCondition) {
		this.datumOrCondition = datumOrCondition;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public Datum getDatum() {
		return datum;
	}

	public void setDatum(Datum datum) {
		this.datum = datum;
	}

	public Condition getCondition() {
		return condition;
	}

	public void setCondition(Condition condition) {
		this.condition = condition;
	}

}

@@ -139,16 +139,61 @@
 n.Datum;
+%0Aimport gov.nih.nci.cananolab.util.Constants;
 %0A%0A/**%0A *
@@ -354,17 +354,19 @@
 um datum
-=
+ = 
 new Datu
@@ -398,17 +398,19 @@
 ondition
-=
+ = 
 new Cond
@@ -538,56 +538,55 @@
 %09// 
-Allow empty D
+display bogus placeholder d
 atum 
-(
 as
-sociated with a Condition).
+ emtpy string
 %0A%09%09i
@@ -609,16 +609,168 @@
 e() 
-!
+=
 = null
-)
+%0A%09%09%09%09%7C%7C datum.getValue() == 0%0A%09%09%09%09&& datum.getCreatedBy().equals(%0A%09%09%09%09%09%09Constants.PLACEHOLDER_DATUM_CONDITION_CREATED_BY)) %7B%0A%09%09%09this.value = %22%22;%0A%09%09%7D else
  %7B%0A%09
@@ -948,16 +948,236 @@
 ition%22;%0A
+%09%09if (condition.getValue().equals(%0A%09%09%09%09Constants.PLACEHOLDER_DATUM_CONDITION_CREATED_BY)%0A%09%09%09%09&& condition.getCreatedBy().equals(%0A%09%09%09%09%09%09Constants.PLACEHOLDER_DATUM_CONDITION_CREATED_BY)) %7B%0A%09%09%09this.value = %22%22;%0A%09%09%7D else %7B%0A%09
 %09%09this.v
@@ -1205,16 +1205,20 @@
 alue();%0A
+%09%09%7D%0A
 %09%09this.c

set value to empty string if it's a place holder