/*
* Copyright (C) 2012 FiveHT Media Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.fiveht.tick.api.parser;
import com.fiveht.tick.api.Task;
import java.beans.PropertyVetoException;
import org.w3c.dom.Element;
/**
*
* @author Nathan Crause
*/
public class TaskParser extends Parser<Task> {
@Override
public Task parse(Element element) {
Task task = new Task();
try {
task.setId(getInt(element, "id"));
task.setName(get(element, "name"));
task.setPosition(getInt(element, "position"));
task.setProjectId(getInt(element, "project_id"));
task.setOpenedOn(getDate(element, "opened_on"));
task.setBudget(getDecimal(element, "budget"));
task.setBillable(getBoolean(element, "billable"));
task.setSumHours(getDecimal(element, "sum_hours"));
task.setUserCount(getInt(element, "user_count"));
}
catch (PropertyVetoException ex) {
throw new RuntimeException(
"PANIC! This is a new object - there should be no vetoing",
ex);
}
// System.out.println(">>>>>>>" + task);
return task;
}
}