1 package jp.ymir.taskReporter.core
2 import java.util.Calendar
3 import java.util.GregorianCalendar
4 import scala.util.matching.Regex
6 class Task(tsvLine: String) {
7 sealed abstract class Status
9 case object NoProgress extends Status
10 case object DoingFine extends Status
11 case object Lagging extends Status
12 case object WillDelay extends Status
13 case object DeadlinePostponed extends Status
14 case object Completed extends Status
17 class InvalidNumberOfColumnsException private(e: RuntimeException) extends RuntimeException(e) {
18 def this(msg: String) = this(new RuntimeException(msg))
19 def this(msg: String, cause: Throwable) = this(new RuntimeException(msg, cause))
22 private val cols = tsvLine.split("\\t")
23 if (cols.length != 7) {
24 throw new InvalidNumberOfColumnsException(tsvLine)
27 val date : Calendar = {
28 val pattern = """^(?:報告日:)?(\d{4})/(\d{2})/(\d{2})$""".r
30 case pattern(year, month, day) =>
31 new GregorianCalendar(year.toInt, month.toInt, day.toInt)
35 val ticketID : Int = {
36 val pattern = """^(?:チケットID:)?(\d+)$""".r
38 case pattern(id) => id.toInt
42 val title : String = {
43 val pattern = """^(?:作業名:)?(.*)$""".r
45 case pattern(title) => title