Back to project page openpomo.
The source code is released under:
GNU General Public License
If you think the Android project openpomo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * This file is part of Pomodroid.// w w w . java2 s . c o m * * Pomodroid 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. * * Pomodroid 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 Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid.factories; import java.util.Date; import java.util.HashMap; import java.util.Vector; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; /** * A class that saves all information about tickets it into the * database. Each ticket taken from a Service is checked. If some information * is empty, the class provides some auto-generated values. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <thomas.schievenin@stud-inf.unibz.it> */ public class ActivityFactory { /** * String that represent a default value for empty fields in Activities */ final private static String autogen = "Autogenerated value"; /** * @param id trac identifier * @param deadLine date within the work has be done * @param attributes list containing all information about one ticket * @param dbHelper reference to the database */ public int produce(Vector<HashMap<String, Object>> tickets, DBHelper dbHelper) throws PomodroidException { int ticketsNumber = 0; for (HashMap<String, Object> ticket : tickets) { fillEmptyFields(ticket); Activity activity = new Activity(0, 0, new Date(), (Date) ticket .get("deadLine"), ticket.get("summary").toString(), ticket .get("description").toString(), ticket.get("origin") .toString(), (Integer) ticket.get("originId"), ticket.get( "priority").toString(), ticket.get("reporter").toString(), ticket.get("type").toString()); if (!Activity.isPresent(activity.getOrigin(), activity .getOriginId(), dbHelper)) { activity.save(dbHelper); ticketsNumber++; } } return ticketsNumber; } /** * @param id trac identifier * @param deadLine date within the work has be done * @param attributes list containing all information about one ticket * @param dbHelper reference to the database */ public int produceTest(Vector<HashMap<String, Object>> tickets, DBHelper dbHelper) throws PomodroidException { int ticketsNumber = 0; for (HashMap<String, Object> ticket : tickets) { fillEmptyFields(ticket); Activity activity = new Activity(0, 0, new Date(), (Date) ticket .get("deadLine"), ticket.get("summary").toString(), ticket .get("description").toString(), ticket.get("origin") .toString(), (Integer) ticket.get("originId"), ticket.get( "priority").toString(), ticket.get("reporter").toString(), ticket.get("type").toString()); if (!Activity.isPresent(activity.getOrigin(), activity .getOriginId(), dbHelper)) { ticketsNumber++; } } return ticketsNumber; } /** * Checks if there are empty fields and fills them with a default value * * @param ticket * @return ticket * @throws PomodroidException */ private HashMap<String, Object> fillEmptyFields( HashMap<String, Object> ticket) throws PomodroidException { for (String key : ticket.keySet()) { if (isEmpty(ticket.get(key).toString())) ticket.put(key, autogen); } return ticket; } /** * Checks whether a string is null or empty * * @param string * @return * @throws PomodroidException */ private boolean isEmpty(String string) throws PomodroidException { return (string.equals("") || string.equals(null)); } }