001/* 002 * (C) Copyright 2006-2010 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 * Dragos Mihalache 016 * Florent Guillaume 017 */ 018 019package org.nuxeo.ecm.platform.versioning.api; 020 021import java.io.Serializable; 022 023import org.nuxeo.ecm.core.api.VersioningOption; 024import org.nuxeo.ecm.core.api.facet.VersioningDocument; 025 026/** 027 * Defines actions to be taken in a document versioning increment process. 028 * <p> 029 * Used by UI. 030 */ 031public enum VersioningActions implements Serializable { 032 033 ACTION_NO_INCREMENT("no_inc", VersioningOption.NONE), // 034 ACTION_INCREMENT_MINOR("inc_minor", VersioningOption.MINOR), // 035 ACTION_INCREMENT_MAJOR("inc_major", VersioningOption.MAJOR); 036 037 public static final String KEY_FOR_INC_OPTION = VersioningDocument.KEY_FOR_INC_OPTION; 038 039 /** 040 * @deprecated use {@link org.nuxeo.ecm.core.versioning.VersioningService#SKIP_VERSIONING} instead 041 */ 042 @Deprecated 043 public static final String SKIP_VERSIONING = "SKIP_VERSIONING"; 044 045 private final String name; 046 047 /** 048 * Equivalent core increment option. 049 * 050 * @since 5.7.3 051 */ 052 private final VersioningOption vo; 053 054 VersioningActions(String name, VersioningOption vo) { 055 this.name = name; 056 this.vo = vo; 057 } 058 059 @Override 060 public String toString() { 061 return name; 062 } 063 064 public VersioningOption getVersioningOption() { 065 return vo; 066 } 067 068 public static VersioningActions getByActionName(String actionName) { 069 for (VersioningActions va : VersioningActions.values()) { 070 if (va.toString().equals(actionName)) { 071 return va; 072 } 073 } 074 return null; 075 } 076 077 /** 078 * Returns the corresponding core versioning option for this UI versioning action. 079 * 080 * @since 5.7.3 081 */ 082 public static VersioningActions getByVersioningOption(VersioningOption vo) { 083 for (VersioningActions va : VersioningActions.values()) { 084 if (va.getVersioningOption().equals(vo)) { 085 return va; 086 } 087 } 088 return null; 089 } 090 091}