All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.api.model.firmware.FirmwareArchiveValidationModel Maven / Gradle / Ivy

There is a newer version: 2.0.29
Show newest version
package org.bidib.wizard.api.model.firmware;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.bidib.api.json.types.firmware.ChangeLog;
import org.bidib.jbidibc.exchange.firmware.DeviceNode;
import org.bidib.jbidibc.exchange.firmware.FilenameType;
import org.bidib.jbidibc.exchange.firmware.FirmwareStatusType;

import com.jgoodies.binding.beans.Model;

public class FirmwareArchiveValidationModel extends Model {
    private static final long serialVersionUID = 1L;

    public static final String PROPERTYNAME_LANGUAGE = "language";

    public static final String PROPERTYNAME_SELECTED_ARCHIVE = "firmwareArchivePath";

    public static final String PROPERTYNAME_SELECTED_ARCHIVE_NAME = "firmwareArchiveName";

    public static final String PROPERTYNAME_EXPERT_MODE = "expertMode";

    public static final String PROPERTYNAME_FIRMWARE_FILES = "firmwareFiles";

    public static final String PROPERTYNAME_CV_DEFINITION_FILES = "cvDefinitionFiles";

    public static final String PROPERTYNAME_DEFAULT_LABELS_FILES = "defaultLabelsFiles";

    public static final String PROPERTYNAME_VENDOR_IMAGE_FILES = "vendorImageFiles";

    public static final String PROPERTYNAME_CHANGELOG_FILE = "changeLogFile";

    public static final String PROPERTYNAME_CHANGELOG = "changeLog";

    public static final String PROPERTYNAME_UPDATE_VERSION = "updateVersion";

    public static final String PROPERTYNAME_FIRMWARE_STATUS = "firmwareStatus";

    public static final String PROPERTYNAME_DEVICE_NODES = "deviceNodes";

    public static final String PROPERTYNAME_VALIDATION_ERRORS = "validationErrors";

    public static final String PROPERTYNAME_VALIDATION_WARNINGS = "validationWarnings";

    private String language = "en-EN";

    private String firmwareArchivePath;

    private String firmwareArchiveName;

    private boolean expertMode;

    private final List firmwareFiles = new ArrayList<>();

    private final List cvDefinitionFiles = new ArrayList<>();

    private final List defaultLabelsFiles = new ArrayList<>();

    private final List vendorImageFiles = new ArrayList<>();

    private String changeLogFile;

    private ChangeLog changeLog;

    private String updateVersion;

    private FirmwareStatusType firmwareStatus;

    private final List deviceNodes = new ArrayList<>();

    private final List validationErrors = new ArrayList<>();

    private final List validationWarnings = new ArrayList<>();

    /**
     * @return the language
     */
    public String getLanguage() {
        return language;
    }

    /**
     * @param language
     *            the language to set
     */
    public void setLanguage(String language) {
        String oldValue = this.language;

        if (StringUtils.isNotBlank(language)) {
            this.language = language;
        }
        else {
            this.language = "en-EN";
        }

        firePropertyChange(PROPERTYNAME_LANGUAGE, oldValue, this.language);
    }

    /**
     * @return the firmwareArchive
     */
    public String getFirmwareArchivePath() {
        return firmwareArchivePath;
    }

    /**
     * @param firmwareArchivePath
     *            the firmwareArchive to set
     */
    public void setFirmwareArchivePath(String firmwareArchivePath) {
        String oldValue = this.firmwareArchivePath;
        this.firmwareArchivePath = firmwareArchivePath;
        firePropertyChange(PROPERTYNAME_SELECTED_ARCHIVE, oldValue, firmwareArchivePath);

        // update the name
        setFirmwareArchiveName(FilenameUtils.getName(firmwareArchivePath));
    }

    /**
     * @return the firmwareArchiveName
     */
    public String getFirmwareArchiveName() {
        return firmwareArchiveName;
    }

    /**
     * @param firmwareArchiveName
     *            the firmwareArchiveName to set
     */
    public void setFirmwareArchiveName(String firmwareArchiveName) {
        String oldValue = this.firmwareArchiveName;
        this.firmwareArchiveName = firmwareArchiveName;
        firePropertyChange(PROPERTYNAME_SELECTED_ARCHIVE_NAME, oldValue, firmwareArchiveName);
    }

    /**
     * @return the expertMode
     */
    public boolean isExpertMode() {
        return expertMode;
    }

    /**
     * @param expertMode
     *            the expertMode to set
     */
    public void setExpertMode(boolean expertMode) {
        boolean oldValue = this.expertMode;
        this.expertMode = expertMode;
        firePropertyChange(PROPERTYNAME_EXPERT_MODE, oldValue, expertMode);
    }

    /**
     * @return the firmwareFiles
     */
    public List getFirmwareFiles() {
        return Collections.unmodifiableList(firmwareFiles);
    }

    /**
     * @param firmwareFiles
     *            the firmwareFiles to set
     */
    public void setFirmwareFiles(List firmwareFiles) {
        List oldValue = new ArrayList<>(this.firmwareFiles);

        this.firmwareFiles.clear();
        if (firmwareFiles != null) {
            this.firmwareFiles.addAll(firmwareFiles);
        }

        firePropertyChange(PROPERTYNAME_FIRMWARE_FILES, oldValue, this.firmwareFiles);
    }

    /**
     * @return the cvDefinitionFiles
     */
    public List getCvDefinitionFiles() {
        return Collections.unmodifiableList(cvDefinitionFiles);
    }

    /**
     * @param cvDefinitionFiles
     *            the cvDefinitionFiles to set
     */
    public void setCvDefinitionFiles(List cvDefinitionFiles) {
        List oldValue = new ArrayList<>(this.cvDefinitionFiles);

        this.cvDefinitionFiles.clear();
        if (cvDefinitionFiles != null) {
            this.cvDefinitionFiles.addAll(cvDefinitionFiles);
        }

        firePropertyChange(PROPERTYNAME_CV_DEFINITION_FILES, oldValue, this.cvDefinitionFiles);
    }

    /**
     * @return the defaultLabelsFiles
     */
    public List getDefaultLabelsFiles() {
        return Collections.unmodifiableList(defaultLabelsFiles);
    }

    /**
     * @param defaultLabelsFiles
     *            the defaultLabelsFiles to set
     */
    public void setDefaultLabelsFiles(List defaultLabelsFiles) {
        List oldValue = new ArrayList<>(this.defaultLabelsFiles);

        this.defaultLabelsFiles.clear();
        if (defaultLabelsFiles != null) {
            this.defaultLabelsFiles.addAll(defaultLabelsFiles);
        }

        firePropertyChange(PROPERTYNAME_DEFAULT_LABELS_FILES, oldValue, this.defaultLabelsFiles);
    }

    /**
     * @return the vendorImageFiles
     */
    public List getVendorImageFiles() {
        return Collections.unmodifiableList(vendorImageFiles);
    }

    /**
     * @param vendorImageFiles
     *            the vendorImageFiles to set
     */
    public void setVendorImageFiles(List vendorImageFiles) {
        List oldValue = new ArrayList<>(this.vendorImageFiles);
        this.vendorImageFiles.clear();
        if (vendorImageFiles != null) {
            this.vendorImageFiles.addAll(vendorImageFiles);
        }

        firePropertyChange(PROPERTYNAME_VENDOR_IMAGE_FILES, oldValue, this.vendorImageFiles);
    }

    /**
     * @return the changeLogFile
     */
    public String getChangeLogFile() {
        return changeLogFile;
    }

    /**
     * @param changeLogFile
     *            the changeLogFile to set
     */
    public void setChangeLogFile(String changeLogFile) {
        String oldValue = this.changeLogFile;
        this.changeLogFile = changeLogFile;

        firePropertyChange(PROPERTYNAME_CHANGELOG_FILE, oldValue, this.changeLogFile);
    }

    /**
     * @return the changeLog
     */
    public ChangeLog getChangeLog() {
        return changeLog;
    }

    /**
     * @param changeLog
     *            the changeLog to set
     */
    public void setChangeLog(ChangeLog changeLog) {
        ChangeLog oldValue = this.changeLog;
        this.changeLog = changeLog;

        firePropertyChange(PROPERTYNAME_CHANGELOG, oldValue, this.changeLog);
    }

    /**
     * @return the updateVersion
     */
    public String getUpdateVersion() {
        return updateVersion;
    }

    /**
     * @param updateVersion
     *            the updateVersion to set
     */
    public void setUpdateVersion(String updateVersion) {
        String oldValue = this.updateVersion;

        this.updateVersion = updateVersion;
        firePropertyChange(PROPERTYNAME_UPDATE_VERSION, oldValue, updateVersion);
    }

    /**
     * @return the firmwareStatus
     */
    public FirmwareStatusType getFirmwareStatus() {
        return firmwareStatus;
    }

    /**
     * @param firmwareStatus
     *            the firmwareStatus to set
     */
    public void setFirmwareStatus(FirmwareStatusType firmwareStatus) {
        FirmwareStatusType oldValue = this.firmwareStatus;

        this.firmwareStatus = firmwareStatus;
        firePropertyChange(PROPERTYNAME_FIRMWARE_STATUS, oldValue, firmwareStatus);
    }

    /**
     * @return the deviceNodes
     */
    public List getDeviceNodes() {
        return Collections.unmodifiableList(deviceNodes);
    }

    /**
     * @param deviceNodes
     *            the deviceNodes to set
     */
    public void setDeviceNodes(List deviceNodes) {
        List oldValue = new ArrayList<>(this.deviceNodes);
        this.deviceNodes.clear();
        if (deviceNodes != null) {
            this.deviceNodes.addAll(deviceNodes);
        }
        firePropertyChange(PROPERTYNAME_DEVICE_NODES, oldValue, this.deviceNodes);
    }

    /**
     * @param deviceNode
     *            the deviceNode to add
     */
    public void addDeviceNode(final DeviceNode deviceNode) {
        List oldValue = new ArrayList<>(this.deviceNodes);
        if (deviceNode != null) {
            this.deviceNodes.add(deviceNode);
        }
        firePropertyChange(PROPERTYNAME_DEVICE_NODES, oldValue, this.deviceNodes);
    }

    /**
     * @return the validationErrors
     */
    public List getValidationErrors() {
        return Collections.unmodifiableList(validationErrors);
    }

    /**
     * @param validationErrors
     *            the validationErrors to set
     */
    public void setValidationErrors(List validationErrors) {
        List oldValue = new ArrayList<>(this.validationErrors);
        this.validationErrors.clear();
        if (validationErrors != null) {
            this.validationErrors.addAll(validationErrors);
        }
        firePropertyChange(PROPERTYNAME_VALIDATION_ERRORS, oldValue, this.validationErrors);
    }

    /**
     * @param validationError
     *            the validationError to add
     */
    public void addValidationError(final String validationError) {
        List oldValue = new ArrayList<>(this.validationErrors);
        if (validationError != null) {
            this.validationErrors.add(validationError);
        }
        firePropertyChange(PROPERTYNAME_VALIDATION_ERRORS, oldValue, this.validationErrors);
    }

    /**
     * @return the validationWarnings
     */
    public List getValidationWarnings() {
        return Collections.unmodifiableList(validationWarnings);
    }

    /**
     * @param validationWarnings
     *            the validationWarnings to set
     */
    public void setValidationWarnings(List validationWarnings) {
        List oldValue = new ArrayList<>(this.validationWarnings);
        this.validationWarnings.clear();
        if (validationWarnings != null) {
            this.validationWarnings.addAll(validationWarnings);
        }
        firePropertyChange(PROPERTYNAME_VALIDATION_WARNINGS, oldValue, this.validationWarnings);
    }

    /**
     * @param validationWarning
     *            the validationWarning to add
     */
    public void addValidationWarning(final String validationWarning) {
        List oldValue = new ArrayList<>(this.validationWarnings);
        if (validationWarning != null) {
            this.validationWarnings.add(validationWarning);
        }
        firePropertyChange(PROPERTYNAME_VALIDATION_WARNINGS, oldValue, this.validationWarnings);
    }

    public void clear() {
        changeLogFile = null;
        changeLog = null;
        cvDefinitionFiles.clear();
        defaultLabelsFiles.clear();
        deviceNodes.clear();
        firmwareArchiveName = null;
        firmwareArchivePath = null;
        firmwareStatus = null;
        updateVersion = null;
        validationErrors.clear();
        validationWarnings.clear();
        vendorImageFiles.clear();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy