001/* 002 * (C) Copyright 2012 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 * Thomas Roger ([email protected]) 018 */ 019 020package org.nuxeo.ecm.activity; 021 022import org.nuxeo.common.xmap.annotation.XNode; 023import org.nuxeo.common.xmap.annotation.XObject; 024import org.nuxeo.ecm.core.api.NuxeoException; 025 026/** 027 * Descriptor object for registering {@link org.nuxeo.ecm.activity.ActivityUpgrader}s. 028 * 029 * @author <a href="mailto:[email protected]">Thomas Roger</a> 030 * @since 5.7 031 */ 032@XObject("activityUpgrader") 033public class ActivityUpgraderDescriptor { 034 035 @XNode("@enabled") 036 protected boolean enabled = true; 037 038 @XNode("@name") 039 protected String name; 040 041 @XNode("@order") 042 protected int order = 0; 043 044 @XNode("@class") 045 protected Class<? extends ActivityUpgrader> activityUpgraderClass; 046 047 public String getName() { 048 return name; 049 } 050 051 public void setName(String name) { 052 this.name = name; 053 } 054 055 public int getOrder() { 056 return order; 057 } 058 059 public void setOrder(int order) { 060 this.order = order; 061 } 062 063 public ActivityUpgrader getActivityUpgrader() { 064 try { 065 ActivityUpgrader upgrader = activityUpgraderClass.newInstance(); 066 upgrader.setName(name); 067 upgrader.setOrder(order); 068 return upgrader; 069 } catch (ReflectiveOperationException e) { 070 throw new NuxeoException(e); 071 } 072 } 073 074 public boolean isEnabled() { 075 return enabled; 076 } 077 078 public void setEnabled(boolean enabled) { 079 this.enabled = enabled; 080 } 081 082 public Class<? extends ActivityUpgrader> getActivityUpgraderClass() { 083 return activityUpgraderClass; 084 } 085 086 public void setActivityUpgraderClass(Class<? extends ActivityUpgrader> activityUpgraderClass) { 087 this.activityUpgraderClass = activityUpgraderClass; 088 } 089 090 @Override 091 public ActivityUpgraderDescriptor clone() { 092 ActivityUpgraderDescriptor clone = new ActivityUpgraderDescriptor(); 093 clone.setName(name); 094 clone.setOrder(order); 095 clone.setActivityUpgraderClass(activityUpgraderClass); 096 clone.setEnabled(enabled); 097 return clone; 098 } 099 100}