001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Laurent Doguin 011 */ 012package org.nuxeo.ecm.core.versioning; 013 014import static org.nuxeo.ecm.core.api.VersioningOption.MAJOR; 015import static org.nuxeo.ecm.core.api.VersioningOption.MINOR; 016import static org.nuxeo.ecm.core.api.VersioningOption.NONE; 017 018import java.io.Serializable; 019import java.util.LinkedList; 020import java.util.List; 021 022import org.nuxeo.common.xmap.annotation.XNode; 023import org.nuxeo.common.xmap.annotation.XObject; 024import org.nuxeo.ecm.core.api.VersioningOption; 025 026/** 027 * Descriptor to contribute incrementation options. 028 * 029 * @author Laurent Doguin 030 * @since 5.4.2 031 */ 032@XObject("options") 033public class SaveOptionsDescriptor implements Serializable { 034 035 private static final long serialVersionUID = 1L; 036 037 @XNode("@lifeCycleState") 038 private String lifeCycleState; 039 040 @XNode("none") 041 private OptionDescriptor none; 042 043 @XNode("minor") 044 private OptionDescriptor minor; 045 046 @XNode("major") 047 private OptionDescriptor major; 048 049 public String getLifeCycleState() { 050 return lifeCycleState; 051 } 052 053 public List<VersioningOption> getVersioningOptionList() { 054 List<VersioningOption> opts = new LinkedList<VersioningOption>(); 055 if (none != null) { 056 if (none.isDefault()) { 057 opts.add(0, NONE); 058 } else { 059 opts.add(NONE); 060 } 061 } 062 if (minor != null) { 063 if (minor.isDefault()) { 064 opts.add(0, MINOR); 065 } else { 066 opts.add(MINOR); 067 } 068 } 069 if (major != null) { 070 if (major.isDefault()) { 071 opts.add(0, MAJOR); 072 } else { 073 opts.add(MAJOR); 074 } 075 } 076 return opts; 077 } 078}