View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.workflow.api;
23  
24  import javax.xml.bind.annotation.XmlAccessType;
25  import javax.xml.bind.annotation.XmlAccessorType;
26  import javax.xml.bind.annotation.XmlAttribute;
27  import javax.xml.bind.annotation.XmlRootElement;
28  import javax.xml.bind.annotation.XmlType;
29  import javax.xml.bind.annotation.XmlValue;
30  import javax.xml.bind.annotation.adapters.XmlAdapter;
31  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
32  
33  @XmlType(name = "state-mapping", namespace = "http://workflow.opencastproject.org")
34  @XmlRootElement(name = "state-mapping", namespace = "http://workflow.opencastproject.org")
35  @XmlAccessorType(XmlAccessType.FIELD)
36  public class WorkflowStateMappingImpl implements WorkflowStateMapping {
37  
38    @XmlJavaTypeAdapter(WorkflowInstance.WorkflowState.Adapter.class)
39    @XmlAttribute(name = "state")
40    protected WorkflowInstance.WorkflowState state;
41  
42    @XmlValue
43    protected String value;
44  
45  
46    /** A no-arg constructor is needed by JAXB */
47    public WorkflowStateMappingImpl() {
48    }
49  
50    /**
51     * @param state
52     *          The state to map
53     * @param value
54     *          The value to use for the state
55     */
56    public WorkflowStateMappingImpl(WorkflowInstance.WorkflowState state, String value) {
57      this.state = state;
58      this.value = value;
59    }
60  
61    public WorkflowInstance.WorkflowState getState() {
62      return state;
63    }
64  
65    public void setState(WorkflowInstance.WorkflowState state) {
66      this.state = state;
67    }
68  
69    public String getValue() {
70      return value;
71    }
72  
73    public void setValue(String value) {
74      this.value = value;
75    }
76  
77    static class Adapter extends XmlAdapter<WorkflowStateMappingImpl, WorkflowStateMapping> {
78      public WorkflowStateMappingImpl marshal(WorkflowStateMapping mapping) throws Exception {
79        return (WorkflowStateMappingImpl) mapping;
80      }
81  
82      public WorkflowStateMapping unmarshal(WorkflowStateMappingImpl mapping) throws Exception {
83        return mapping;
84      }
85    }
86  
87    @Override
88    public String toString() {
89      return "state mapping:'" + state.name() + " : " + value + "'";
90    }
91  
92  }