de.bund.bfr.knime.pmm.extendedtable.items.MDAgentXml.java Source code

Java tutorial

Introduction

Here is the source code for de.bund.bfr.knime.pmm.extendedtable.items.MDAgentXml.java

Source

/*******************************************************************************
 * Copyright (c) 2015 Federal Institute for Risk Assessment (BfR), Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contributors:
 *     Department Biological Safety - BfR
 *******************************************************************************/
package de.bund.bfr.knime.pmm.extendedtable.items;

import org.jdom2.Element;

import de.bund.bfr.knime.pmm.common.PmmXmlElementConvertable;
import de.bund.bfr.knime.pmm.common.XmlHelper;
import de.bund.bfr.knime.pmm.common.math.MathUtilities;

public class MDAgentXml implements AgentXmlI, PmmXmlElementConvertable {

    public static final String ELEMENT_AGENT = "mdAgent";

    private static final String ATT_ID = "id";
    private static final String ATT_NAME = "name";
    private static final String ATT_DETAIL = "detail";
    private static final String ATT_DBUUID = "dbuuid";

    private Integer id;
    private String name;
    private String detail;
    private String dbuuid;

    public MDAgentXml() {
        this(MathUtilities.getRandomNegativeInt(), null, null, null);
    }

    public MDAgentXml(Integer id, String name, String detail) {
        this(id, name, detail, null);
    }

    public MDAgentXml(AgentXmlI agent) {
        this(agent.getId(), agent.getName(), agent.getDetail(), agent.getDbuuid());
    }

    public MDAgentXml(Integer id, String name, String detail, String dbuuid) {
        this.id = id;
        this.name = name;
        this.detail = detail;
        this.dbuuid = dbuuid;
    }

    public MDAgentXml(Element el) {
        this(XmlHelper.getInt(el, ATT_ID), XmlHelper.getString(el, ATT_NAME), XmlHelper.getString(el, ATT_DETAIL),
                XmlHelper.getString(el, ATT_DBUUID));
    }

    public Element toXmlElement() {
        Element ret = new Element(ELEMENT_AGENT);

        ret.setAttribute(ATT_ID, XmlHelper.getNonNull(id));
        ret.setAttribute(ATT_NAME, XmlHelper.getNonNull(name));
        ret.setAttribute(ATT_DETAIL, XmlHelper.getNonNull(detail));
        ret.setAttribute(ATT_DBUUID, XmlHelper.getNonNull(dbuuid));

        return ret;
    }

    public String getElementName() {
        return "modelLiterature";
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getDbuuid() {
        return dbuuid;
    }

    public void setDbuuid(String dbuuid) {
        this.dbuuid = dbuuid;
    }
}