001/* 002 * (C) Copyright 2006-2016 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 * Dragos Mihalache 018 * Florent Guillaume 019 */ 020package org.nuxeo.ecm.platform.versioning.api; 021 022import java.io.Serializable; 023 024import org.nuxeo.ecm.core.api.VersioningOption; 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 private final String name; 038 039 /** 040 * Equivalent core increment option. 041 * 042 * @since 5.7.3 043 */ 044 private final VersioningOption vo; 045 046 VersioningActions(String name, VersioningOption vo) { 047 this.name = name; 048 this.vo = vo; 049 } 050 051 @Override 052 public String toString() { 053 return name; 054 } 055 056 public VersioningOption getVersioningOption() { 057 return vo; 058 } 059 060 public static VersioningActions getByActionName(String actionName) { 061 for (VersioningActions va : VersioningActions.values()) { 062 if (va.toString().equals(actionName)) { 063 return va; 064 } 065 } 066 return null; 067 } 068 069 /** 070 * Returns the corresponding core versioning option for this UI versioning action. 071 * 072 * @since 5.7.3 073 */ 074 public static VersioningActions getByVersioningOption(VersioningOption vo) { 075 for (VersioningActions va : VersioningActions.values()) { 076 if (va.getVersioningOption().equals(vo)) { 077 return va; 078 } 079 } 080 return null; 081 } 082 083}