OSDN Git Service

進捗率未指定の場合の出力メッセージ修正
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / model / Target.java
1 package yukihane.inqubus.model;
2
3 import org.apache.commons.lang.StringUtils;
4 import yukihane.inqubus.manager.RequestProcess;
5 import yukihane.inqubus.manager.TaskKind;
6 import yukihane.inqubus.manager.TaskStatus;
7
8 public class Target {
9
10     private final RequestProcess requestProcess;
11     private Progress progress;
12
13     public Target(RequestProcess rp) {
14         this.requestProcess = rp;
15         this.progress = new Progress("待機中");
16     }
17
18     public int getRowId() {
19         return requestProcess.getRowId();
20     }
21
22     String getVideoId() {
23         return getRequestProcess().getVideoId();
24     }
25
26     boolean isVideoDownload() {
27         return getRequestProcess().getDownloadProfile().getVideoProfile().isDownload();
28     }
29
30     boolean isCommentDownload() {
31         return getRequestProcess().getDownloadProfile().getCommentProfile().isDownload();
32     }
33
34     boolean isConvert() {
35         return getRequestProcess().getConvertProfile().isConvert();
36     }
37
38     Progress getProgress() {
39         return progress;
40     }
41
42     void setProgress(TaskKind kind, TaskStatus status, double percent, String message) {
43         String text;
44         double p = -1.0;
45         if (status == TaskStatus.READY) {
46             text = status.toString();
47         } else if (status == TaskStatus.DOING || status == TaskStatus.DONE || status == TaskStatus.CANCELLED) {
48             if (StringUtils.isEmpty(message)) {
49                 text = kind.toString() + " " + status.toString();
50             } else {
51                 text = message;
52             }
53             p = percent;
54         } else {
55             text = message;
56         }
57         progress = new Progress(p, text);
58     }
59
60     private RequestProcess getRequestProcess() {
61         return requestProcess;
62     }
63 }