SiLeBAT/FSK-Lab

View on GitHub
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/pmfwriter/PMFWriterNodeSettings.java

Summary

Maintainability
C
7 hrs
Test Coverage
/*******************************************************************************
 * Copyright (c) 2017 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.pmfwriter;

import org.knime.core.node.InvalidSettingsException;
import org.knime.core.node.NodeSettingsRO;
import org.knime.core.node.NodeSettingsWO;

/**
 * Node settings helper class for the
 * {@link de.bund.bfr.knime.pmm.PMFWriterNodeFactory} node.
 * 
 * @author Miguel de Alba
 */
class PMFWriterNodeSettings {

    // Configuration keys
    private static final String CFG_OUT_PATH = "outPath";
    private static final String CFG_MODEL_NAME = "modelName";
    private static final String CFG_CREATOR_GIVEN_NAME = "CreatorGivenName";
    private static final String CFG_CREATOR_FAMILY_NAME = "CreatorFamilyName";
    private static final String CFG_CREATOR_CONTACT = "CreatorContact";
    private static final String CFG_CREATION_DATE = "CreationDateVALUEKEYSETTINGS";
    private static final String CFG_MODIFICATION_DATE = "ModifiedDateVALUEKEYSETTINGS";
    private static final String CFG_IS_SECONDARY = "isSecondary";
    private static final String CFG_OVERWRITE = "overwrite";
    private static final String CFG_SPLIT_MODELS = "splitModels";
    private static final String CFG_REFERENCE_LINK = "referenceLink";
    private static final String CFG_LICENSE = "license";
    private static final String CFG_NOTES = "notes";

    public String outPath = "";
    public String modelName = "";
    public String creatorGivenName = "";
    public String creatorFamilyName = "";
    public String creatorContact = "";

    /** Creation date in milliseconds since 1970 in UTC time. */
    public long createdDate;

    /** Last modification date in milliseconds since 1970 in UTC time. */
    public long modifiedDate;

    public boolean isSecondary = false;
    public boolean overwrite = false;
    public boolean splitModels = false;
    public String referenceDescriptionLink = "";
    public String license = "";
    public String notes = "";

    public void load(final NodeSettingsRO settings) throws InvalidSettingsException {
        outPath = settings.getString(CFG_OUT_PATH);
        modelName = settings.getString(CFG_MODEL_NAME);
        creatorGivenName = settings.getString(CFG_CREATOR_GIVEN_NAME);
        creatorFamilyName = settings.getString(CFG_CREATOR_FAMILY_NAME);
        creatorContact = settings.getString(CFG_CREATOR_CONTACT);
        createdDate = settings.getLong(CFG_CREATION_DATE);
        modifiedDate = settings.getLong(CFG_MODIFICATION_DATE);
        isSecondary = settings.getBoolean(CFG_IS_SECONDARY);
        overwrite = settings.getBoolean(CFG_OVERWRITE);
        splitModels = settings.getBoolean(CFG_SPLIT_MODELS);
        referenceDescriptionLink = settings.getString(CFG_REFERENCE_LINK);
        license = settings.getString(CFG_LICENSE);
        notes = settings.getString(CFG_NOTES);
    }

    public void save(final NodeSettingsWO settings) {
        settings.addString(CFG_OUT_PATH, outPath);
        settings.addString(CFG_MODEL_NAME, modelName);
        settings.addString(CFG_CREATOR_GIVEN_NAME, creatorGivenName);
        settings.addString(CFG_CREATOR_FAMILY_NAME, creatorFamilyName);
        settings.addString(CFG_CREATOR_CONTACT, creatorContact);
        settings.addLong(CFG_CREATION_DATE, createdDate);
        settings.addLong(CFG_MODIFICATION_DATE, modifiedDate);
        settings.addBoolean(CFG_IS_SECONDARY, isSecondary);
        settings.addBoolean(CFG_OVERWRITE, overwrite);
        settings.addBoolean(CFG_SPLIT_MODELS, splitModels);
        settings.addString(CFG_REFERENCE_LINK, referenceDescriptionLink);
        settings.addString(CFG_LICENSE, license);
        settings.addString(CFG_NOTES, notes);
    }
}