001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Laurent Doguin 018 */ 019package org.nuxeo.ecm.core.versioning; 020 021import static org.nuxeo.ecm.core.api.VersioningOption.MAJOR; 022import static org.nuxeo.ecm.core.api.VersioningOption.MINOR; 023import static org.nuxeo.ecm.core.api.VersioningOption.NONE; 024 025import java.io.Serializable; 026import java.util.LinkedList; 027import java.util.List; 028 029import org.nuxeo.common.xmap.annotation.XNode; 030import org.nuxeo.common.xmap.annotation.XObject; 031import org.nuxeo.ecm.core.api.VersioningOption; 032 033/** 034 * Descriptor to contribute incrementation options. 035 * 036 * @author Laurent Doguin 037 * @since 5.4.2 038 */ 039@XObject("options") 040public class SaveOptionsDescriptor implements Serializable { 041 042 private static final long serialVersionUID = 1L; 043 044 @XNode("@lifeCycleState") 045 private String lifeCycleState; 046 047 @XNode("none") 048 private OptionDescriptor none; 049 050 @XNode("minor") 051 private OptionDescriptor minor; 052 053 @XNode("major") 054 private OptionDescriptor major; 055 056 public String getLifeCycleState() { 057 return lifeCycleState; 058 } 059 060 public List<VersioningOption> getVersioningOptionList() { 061 List<VersioningOption> opts = new LinkedList<VersioningOption>(); 062 if (none != null) { 063 if (none.isDefault()) { 064 opts.add(0, NONE); 065 } else { 066 opts.add(NONE); 067 } 068 } 069 if (minor != null) { 070 if (minor.isDefault()) { 071 opts.add(0, MINOR); 072 } else { 073 opts.add(MINOR); 074 } 075 } 076 if (major != null) { 077 if (major.isDefault()) { 078 opts.add(0, MAJOR); 079 } else { 080 opts.add(MAJOR); 081 } 082 } 083 return opts; 084 } 085}