001/** 002 * Copyright 2015 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.video; 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.AbstractTaskDetails; 024import service.tut.pori.contentanalysis.AsyncTask.TaskType; 025 026/** 027 * An implementation of AbstractTaskDetails, which can be used to define a video analysis task, or a feedback task. 028 * 029 * <h2>Conditional Elements</h2> 030 * <ul> 031 * <li>{@value service.tut.pori.contentanalysis.video.Definitions#ELEMENT_DELETED_VIDEOLIST}</li> 032 * <li>{@value service.tut.pori.contentanalysis.video.Definitions#ELEMENT_VIDEOLIST}</li> 033 * </ul> 034 * 035 * One of {@value service.tut.pori.contentanalysis.video.Definitions#ELEMENT_VIDEOLIST} or {@value service.tut.pori.contentanalysis.video.Definitions#ELEMENT_DELETED_VIDEOLIST} must be present in a task. 036 * 037 * If no analysis options have been given, the default options should be used : {@link service.tut.pori.contentanalysis.video.VideoParameters.SequenceType#FULL}. 038 * 039 * <h3>XML Example - Analysis Task</h3> 040 * 041 * {@doc.restlet service="[service.tut.pori.contentanalysis.video.reference.Definitions#SERVICE_VCA_REFERENCE_EXAMPLE]" method="[service.tut.pori.contentanalysis.Definitions#ELEMENT_TASK_DETAILS]" type="GET" query="[service.tut.pori.contentanalysis.video.reference.Definitions#PARAMETER_TASK_TYPE]=[service.tut.pori.contentanalysis.AsyncTask$TaskType#ANALYSIS]" body_uri=""} 042 * 043 * <h3>XML Example - Feedback Task</h3> 044 * 045 * {@doc.restlet service="[service.tut.pori.contentanalysis.video.reference.Definitions#SERVICE_VCA_REFERENCE_EXAMPLE]" method="[service.tut.pori.contentanalysis.Definitions#ELEMENT_TASK_DETAILS]" type="GET" query="[service.tut.pori.contentanalysis.video.reference.Definitions#PARAMETER_TASK_TYPE]=[service.tut.pori.contentanalysis.AsyncTask$TaskType#FEEDBACK]" body_uri=""} 046 * 047 */ 048@XmlRootElement(name=service.tut.pori.contentanalysis.Definitions.ELEMENT_TASK_DETAILS) 049@XmlAccessorType(XmlAccessType.NONE) 050public final class VideoTaskDetails extends AbstractTaskDetails { 051 @XmlElement(name = Definitions.ELEMENT_DELETED_VIDEOLIST) 052 private DeletedVideoList _deletedVideoList = null; 053 @XmlElement(name = Definitions.ELEMENT_VIDEOLIST) 054 private VideoList _videoList = null; 055 private VideoParameters _videoParameters = null; 056 057 /** 058 * 059 * @param taskType 060 */ 061 public VideoTaskDetails(TaskType taskType) { 062 setTaskType(taskType); 063 } 064 065 /** 066 * 067 */ 068 public VideoTaskDetails() { 069 super(); 070 } 071 072 /** 073 * @return the deletedVideoList 074 * @see #setDeletedVideoList(DeletedVideoList) 075 */ 076 public DeletedVideoList getDeletedVideoList() { 077 return _deletedVideoList; 078 } 079 080 /** 081 * @param deletedVideoList the deletedVideoList to set 082 * @see #getDeletedVideoList() 083 */ 084 public void setDeletedVideoList(DeletedVideoList deletedVideoList) { 085 _deletedVideoList = deletedVideoList; 086 } 087 088 /** 089 * @return the videoList 090 * @see #setVideoList(VideoList) 091 */ 092 public VideoList getVideoList() { 093 return _videoList; 094 } 095 096 /** 097 * @param videoList the videoList to set 098 * @see #getDeletedVideoList() 099 */ 100 public void setVideoList(VideoList videoList) { 101 _videoList = videoList; 102 } 103 104 /** 105 * Add video to the video list 106 * 107 * @param video 108 * @see #getVideoList() 109 */ 110 public void addVideo(Video video) { 111 if(_videoList == null){ 112 _videoList = new VideoList(); 113 } 114 _videoList.addVideo(video); 115 } 116 117 /** 118 * add video to the deleted video list 119 * 120 * @param video 121 * @see #getDeletedVideoList() 122 */ 123 public void addDeletedVideo(Video video) { 124 if(_deletedVideoList == null){ 125 _deletedVideoList = new DeletedVideoList(); 126 } 127 _deletedVideoList.addVideo(video); 128 } 129 130 /** 131 * 132 * @return true if the task has no content 133 */ 134 public boolean isEmpty() { 135 return (VideoList.isEmpty(_videoList) && DeletedVideoList.isEmpty(_deletedVideoList)); 136 } 137 138 @Override 139 public VideoParameters getTaskParameters() { 140 return _videoParameters; 141 } 142 143 @Override 144 public void setTaskParameters(TaskParameters parameters) { 145 if(parameters == null){ 146 _videoParameters = null; 147 }else if(parameters instanceof VideoParameters){ 148 setTaskParameters((VideoParameters) parameters); 149 }else{ 150 _videoParameters = new VideoParameters(); 151 } 152 } 153 154 /** 155 * 156 * @param parameters 157 */ 158 public void setTaskParameters(VideoParameters parameters) { 159 _videoParameters = parameters; 160 } 161}