001/*
002 * (C) Copyright 2006-2013 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     ldoguin
016 *
017 */
018package org.nuxeo.template.api.descriptor;
019
020import java.io.Serializable;
021
022import org.apache.commons.logging.Log;
023import org.apache.commons.logging.LogFactory;
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026
027@XObject("outputFormat")
028public class OutputFormatDescriptor implements Serializable {
029
030    private static final long serialVersionUID = 1L;
031
032    protected static final Log log = LogFactory.getLog(OutputFormatDescriptor.class);
033
034    @XNode("@id")
035    protected String id;
036
037    @XNode("@label")
038    protected String label;
039
040    @XNode("@enabled")
041    protected boolean enabled = true;
042
043    @XNode("@chainId")
044    protected String chainId;
045
046    @XNode("@mimetype")
047    protected String mimeType;
048
049    public String getId() {
050        return id;
051    }
052
053    public String getLabel() {
054        return label;
055    }
056
057    public boolean isEnabled() {
058        return enabled;
059    }
060
061    public String getChainId() {
062        return chainId;
063    }
064
065    public String getMimeType() {
066        return mimeType;
067    }
068
069    public OutputFormatDescriptor clone() {
070        OutputFormatDescriptor clone = new OutputFormatDescriptor();
071        clone.enabled = enabled;
072        clone.chainId = chainId;
073        clone.mimeType = mimeType;
074        clone.label = label;
075        clone.id = id;
076        return clone;
077    }
078
079    public void merge(OutputFormatDescriptor srcOutFormat) {
080        if (srcOutFormat.mimeType != null) {
081            mimeType = srcOutFormat.mimeType;
082        }
083        if (srcOutFormat.chainId != null) {
084            chainId = srcOutFormat.chainId;
085        }
086        if (srcOutFormat.label != null) {
087            label = srcOutFormat.label;
088        }
089    }
090}