package yukihane.inqubus.model;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
+import org.apache.commons.lang.StringUtils;
+import yukihane.inqubus.manager.RequestProcess;
+import yukihane.inqubus.manager.TaskKind;
+import yukihane.inqubus.manager.TaskStatus;
public class Target {
- public static Collection<Target> from(Collection<File> data) {
- Collection<Target> list = new ArrayList<Target>(data.size());
- for(File f : data){
- list.add(new Target(f));
- }
- return list;
- }
-
- public static Target fromId(String movieId) {
- return new Target(movieId);
- }
-
- private Location movie;
- private Location comment;
- private Location ownerComment;
- private Status status;
+ private final RequestProcess requestProcess;
+ private Progress progress;
- private Target(File f) {
- movie = new Location(f);
+ public Target(RequestProcess rp) {
+ this.requestProcess = rp;
+ this.progress = new Progress("待機中");
}
- private Target(String movieId) {
- movie = new Location(movieId);
+ public int getRowId() {
+ return requestProcess.getRowId();
}
- public Location getComment() {
- return comment;
+ public String getVideoId() {
+ return getRequestProcess().getVideoId();
}
- public void setComment(Location comment) {
- this.comment = comment;
+ boolean isVideoDownload() {
+ return getRequestProcess().getDownloadProfile().getVideoProfile().isDownload();
}
- public Location getMovie() {
- return movie;
+ boolean isCommentDownload() {
+ return getRequestProcess().getDownloadProfile().getCommentProfile().isDownload();
}
- public void setMovie(Location movie) {
- this.movie = movie;
+ boolean isConvert() {
+ return getRequestProcess().getConvertProfile().isConvert();
}
- public Location getOwnerComment() {
- return ownerComment;
+ Progress getProgress() {
+ return progress;
}
- public void setOwnerComment(Location ownerComment) {
- this.ownerComment = ownerComment;
- }
-
- public Status getStatus() {
- return status;
+ void setProgress(TaskKind kind, TaskStatus status, double percent, String message) {
+ String text;
+ double p = -1.0;
+ if (status == TaskStatus.READY) {
+ text = status.toString();
+ } else if (status == TaskStatus.DOING || status == TaskStatus.DONE || status == TaskStatus.CANCELLED) {
+ if (StringUtils.isEmpty(message)) {
+ text = kind.toString() + " " + status.toString();
+ } else {
+ text = message;
+ }
+ p = percent;
+ } else {
+ text = message;
+ }
+ progress = new Progress(p, text);
}
- public void setStatus(Status status) {
- this.status = status;
+ private RequestProcess getRequestProcess() {
+ return requestProcess;
}
-
}