/*
 * Copyright 2009 Lari Natri <lari.natri@gmail.com>
 *
 *  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/>.
 */

package compid.data.tuples;

import java.util.HashMap;

/**
 *
 * @author Lari Natri
 */
public class Setting extends Tuple {

    public static final String TABLELABEL = "SETTINGS"; //NOI18N
    
    private final String name;
    private final String value;
    private final String description;
    private final int active;
    private final int userEditable;
    private final int flags;

    public Setting(String name, String value, String description) {
        this(name, value, description, 1, 0, 0);
    }

    public Setting(String name, String value, String description,
                   boolean active, boolean userEditable, int flags) {
        this(name, value, description,
             active ? 1 : 0, userEditable ? 1 : 0, flags);
    }

    public Setting(String name, String value, String description,
                   int active, int userEditable, int flags) {
        this.name = name;
        this.value = value;
        this.description = description;
        this.active = active;
        this.userEditable = userEditable;
        this.flags = flags;
        this.setTupleHasNoForeignKeys();
    }

    public String getName() { return this.name; }

    public String getValue() { return this.value; }

    public String getDescription() { return this.description; }

    public int getActive() { return this.active; }

    public int getUserEditable() { return this.userEditable; }

    public int getFlags() { return this.flags; }

    @Override
    public String getTableLabel() {
        return TABLELABEL;
    }

    @Override
    public HashMap<String, Object> getColsAndValues() {
        HashMap<String,Object> map = new HashMap<String,Object>(6,1);
        map.put("SETNAME", this.name); //NOI18N
        map.put("SETVALUE", this.value); //NOI18N
        map.put("SETDESCR", this.description); //NOI18N
        map.put("SETACTIVE", this.active); //NOI18N
        map.put("SETUSEREDITABLE", this.userEditable); //NOI18N
        map.put("SETFLAGS", this.flags); //NOI18N
        return map;
    }

    @Override
    public HashMap<String,Object> getKeysAndValuesForExistenceCheck() {
        HashMap<String,Object> map = new HashMap<String,Object>(1,1);
        map.put("SETNAME", this.name); //NOI18N
        return map;
    }



}
