001/**
002 * Copyright 2014 Tampere University of Technology, Pori Department
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 */
016package service.tut.pori.contentanalysis;
017
018import javax.xml.bind.annotation.XmlAccessType;
019import javax.xml.bind.annotation.XmlAccessorType;
020import javax.xml.bind.annotation.XmlElement;
021import javax.xml.bind.annotation.XmlRootElement;
022
023import service.tut.pori.contentanalysis.AsyncTask.TaskStatus;
024
025
026/**
027 * Status details of a single analysis back-end.
028 * 
029 * <h2>Optional Elements</h2>
030 * <ul>
031 *  <li>{@value service.tut.pori.contentanalysis.Definitions#ELEMENT_MESSAGE}</li>
032 * </ul>
033 * 
034 * <h3>XML Example</h3>
035 * 
036 * {@doc.restlet service="[service.tut.pori.contentanalysis.reference.Definitions#SERVICE_CA_REFERENCE_EXAMPLE]" method="[service.tut.pori.contentanalysis.Definitions#ELEMENT_BACKEND_STATUS]" type="GET" query="" body_uri=""}
037 * 
038 * @see service.tut.pori.contentanalysis.AnalysisBackend
039 */
040@XmlRootElement(name=Definitions.ELEMENT_BACKEND_STATUS)
041@XmlAccessorType(XmlAccessType.NONE)
042public class BackendStatus{
043  private AnalysisBackend _backend = null;
044  @XmlElement(name = Definitions.ELEMENT_MESSAGE)
045  private String _message = null;  
046  @XmlElement(name = Definitions.ELEMENT_STATUS)
047  private AsyncTask.TaskStatus _status = null;
048
049  /**
050   * 
051   * @param backend
052   * @param status
053   */
054  public BackendStatus(AnalysisBackend backend, TaskStatus status){
055    _backend= backend;
056    _status = status;
057  }
058  
059  /**
060   * for serialization
061   */
062  protected BackendStatus(){
063    // nothing needed
064  }
065
066  /**
067   * 
068   * @return Status of this back-end
069   * @see #setStatus(service.tut.pori.contentanalysis.AsyncTask.TaskStatus)
070   */
071  public AsyncTask.TaskStatus getStatus() {
072    return _status;
073  }
074
075  /**
076   * 
077   * @param status
078   * @see #getStatus()
079   */
080  public void setStatus(AsyncTask.TaskStatus status) {
081    _status = status;
082  }
083
084  /**
085   * 
086   * @return status message or null if not available
087   * @see #setMessage(String)
088   */
089  public String getMessage() {
090    return _message;
091  }
092
093  /**
094   * 
095   * @param message
096   * @see #getMessage()
097   */
098  public void setMessage(String message) {
099    _message = message;
100  }
101
102  /**
103   * @return the back-end
104   * @see #setBackend(AnalysisBackend)
105   */
106  public AnalysisBackend getBackend() {
107    return _backend;
108  }
109
110  /**
111   * @param backend the backend to set
112   * @see #getBackend()
113   */
114  public void setBackend(AnalysisBackend backend) {
115    _backend = backend;
116  }
117  
118  /**
119   * for serialization
120   * 
121   * @param backendId
122   * @see #setBackend(AnalysisBackend)
123   */
124  @SuppressWarnings("unused")
125  private void setBackendId(Integer backendId) {
126    if(backendId == null){
127      _backend = null;
128    }else{
129      _backend = new AnalysisBackend(backendId);
130    }
131  }
132  
133  /**
134   * 
135   * @return back-end id
136   * @see #getBackend()
137   */
138  @XmlElement(name=Definitions.ELEMENT_BACKEND_ID)
139  public Integer getBackendId() {
140    return (_backend == null ? null : _backend.getBackendId());
141  }
142}
143