/*
 * This file is part of DebGen Biobank Software developed by ASTRID Research.
 * All rights reserved. Reproduction, modification, use or disclosure
 * to third parties without express authority is forbidden.
 *
 * Copyright ASTRID Research Inc., Hungary, 2009-2011.
 *
 * ASTRID Research
 * Headquaters: Csapo utca 42. Debrecen H-4029 HUNGARY
 * Phone: +36-52-533-173        Fax: +36-52-533-174
 * Web: http://www.astrid.hu    E-mail: info@astrid.hu
 *
 * Project name: DebGen Biobank Software project.
 * URLS:
 * Developers: Istvan Zoltan Nagy (istvan.nagy@astrid.hu)
 */
package hu.astrid.debgen.patientmanagement.domain.modules;

import hu.astrid.debgen.localization.service.LocalizationService;
import hu.astrid.xmltools.beantoxml.XmlToBeanConverter;
import java.util.Date;
import javax.persistence.Entity;
import javax.servlet.http.HttpServletRequest;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * Class of citogenetical results
 * @author inagy
 */
@Entity
public class ResultCitogenetics extends Result {

    private static final long serialVersionUID = 1L;

    protected String citTenyesztesiIdo;
    protected int citAnalysedMetaPhases;
    protected int citCountedMetaPhases;
    protected String citTrackingTechnique;
    protected String citKaryotype;
    protected String citResultInformation;
    private String citNumberOfMetaPhases;

    // <editor-fold defaultstate="collapsed" desc="Getters and Setters">
    /**
     * Get the value of citResultInformation
     *
     * @return the value of citResultInformation
     */
    public String getCitResultInformationForWeb() {
        try {
            return citResultInformation.replaceAll("\r\n", "<br />").replaceAll("\n", "<br />").replaceAll("\r", "<br />");
        } catch (Exception e) {
            return citResultInformation;
        }
    }

    /**
     * Get the value of citResultInformation
     *
     * @return the value of citResultInformation
     */
    public String getCitResultInformation() {
        return citResultInformation;
    }

    /**
     * Set the value of citResultInformation
     *
     * @param citResultInformation new value of citResultInformation
     */
    public void setCitResultInformation(String citResultInformation) {
        this.citResultInformation = citResultInformation;
    }
   

    public String getCitNumberOfMetaPhases() {
		return citNumberOfMetaPhases;
	}

	public void setCitNumberOfMetaPhases(String citNumberOfMetaPhases) {
		this.citNumberOfMetaPhases = citNumberOfMetaPhases;
	}

	/**
     * Get the value of citKaryotype
     *
     * @return the value of citKaryotype
     */
    public String getCitKaryotype() {
        return citKaryotype;
    }

    /**
     * Set the value of citKaryotype
     *
     * @param citKaryotype new value of citKaryotype
     */
    public void setCitKaryotype(String citKaryotype) {
        this.citKaryotype = citKaryotype;
    }

    /**
     * Get the value of citTrackingTechnique
     *
     * @return the value of citTrackingTechnique
     */
    public String getCitTrackingTechnique() {
        return citTrackingTechnique;
    }

    /**
     * Set the value of citTrackingTechnique
     *
     * @param citTrackingTechnique new value of citTrackingTechnique
     */
    public void setCitTrackingTechnique(String citTrackingTechnique) {
        this.citTrackingTechnique = citTrackingTechnique;
    }

    /**
     * Get the value of citCountedMetaPhases
     *
     * @return the value of citCountedMetaPhases
     */
    public int getCitCountedMetaPhases() {
        return citCountedMetaPhases;
    }

    /**
     * Set the value of citCountedMetaPhases
     *
     * @param citCountedMetaPhases new value of citCountedMetaPhases
     */
    public void setCitCountedMetaPhases(int citCountedMetaPhases) {
        this.citCountedMetaPhases = citCountedMetaPhases;
    }

    /**
     * Get the value of citAnalysedMetaPhases
     *
     * @return the value of citAnalysedMetaPhases
     */
    public int getCitAnalysedMetaPhases() {
        return citAnalysedMetaPhases;
    }

    /**
     * Set the value of citAnalysedMetaPhases
     *
     * @param citAnalysedMetaPhases new value of citAnalysedMetaPhases
     */
    public void setCitAnalysedMetaPhases(int citAnalysedMetaPhases) {
        this.citAnalysedMetaPhases = citAnalysedMetaPhases;
    }

    /**
     * Get the value of citTenyesztesiIdo
     *
     * @return the value of citTenyesztesiIdo
     */
    public String getCitTenyesztesiIdo() {
        return citTenyesztesiIdo;
    }

    /**
     * Set the value of citTenyesztesiIdo
     *
     * @param citTenyesztesiIdo new value of citTenyesztesiIdo
     */
    public void setCitTenyesztesiIdo(String citTenyesztesiIdo) {
        this.citTenyesztesiIdo = citTenyesztesiIdo;
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Toucan request processing">
    @Override
    public void convert(HttpServletRequest request) throws Exception {
        super.convert(request);
        requestParser.parseRequest(ResultCitogenetics.class, this);
        if (this.createdOn == null) {
            this.createdOn = new Date();
        }
    }// </editor-fold>

    @Override
    public String getType() {
        return "citogen";
    }

    // <editor-fold defaultstate="collapsed" desc="XML conversion">
    @Override
    public void buildFromXml(Node node) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void buildFromXml(Node node, String string) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Node toXml(Document doc) throws Exception {
        return toXml(doc, "");
    }

    @Override
    public Node toXml(Document doc, String nameSpace) throws Exception {
        try {
            String prefix = nameSpace == null || nameSpace.isEmpty() ? "" : nameSpace + ":";
            Element module = doc.createElement(prefix + "module");
            module.setAttribute("objectType", this.objectType);
            this.setXmlCommonValues(doc, module);
            Element citogen = doc.createElement("citogenModule");
            module.appendChild(citogen);
            citogen.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citTenyesztesiIdo", new LocalizationService().getMessage(this.citTenyesztesiIdo, languageIsoCode)));
            citogen.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citAnalysedMetaPhases", this.citAnalysedMetaPhases + ""));
            citogen.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citCountedMetaPhases", this.citCountedMetaPhases + ""));
            citogen.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citTrackingTechnique", new LocalizationService().getMessage(this.citTrackingTechnique, languageIsoCode)));
            citogen.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citKaryotype", this.citKaryotype));
            citogen.appendChild(XmlToBeanConverter.getNodeWithValue(doc, "citResultInformation", this.citResultInformation));
            return module;
        } catch (Exception ex) {
            ex.printStackTrace();
            throw ex;
        }
    }// </editor-fold>
}
