/*
 * myLazyClock
 *
 * Copyright (C) 2014
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.myLazyClock.services.bean;

import org.myLazyClock.model.model.AlarmClock;

import java.io.Serializable;

/**
 * Created on 04/12/14.
 *
 * @author dralagen
 */
public class AlarmClockBean implements Serializable {

    private Long id;

    private String user;

    private String name;

    private String ringstone;

    private String address;

    private String color;

    private int preparationTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRingstone () {
        return ringstone;
    }

    public void setRingstone (String ringstone) {
        this.ringstone = ringstone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getPreparationTime() {
        return preparationTime;
    }

    public String getPreparationTimeString() {
        int h = preparationTime/3600;
        int m = (preparationTime-(h*3600))/60;
        int s = preparationTime-(h*3600+m*60);
        if (h != 0)
            return h+" heure(s) et "+m+" minute(s)";
        else {
            return m+" minute(s)";
        }
    }

    public void setPreparationTime(int preparationTime) {
        this.preparationTime = preparationTime;
    }

    public AlarmClock toEntity() {
        AlarmClock alarmClock = new AlarmClock();

        alarmClock.setId(getId());
        alarmClock.setUser(getUser());
        alarmClock.setName(getName());
        alarmClock.setRingstone(getRingstone());
        alarmClock.setAddress(getAddress());
        alarmClock.setColor(getColor());
        alarmClock.setPreparationTime(getPreparationTime());

        return alarmClock;
    }

    public void fromEntity(AlarmClock alarmClock) {
        setId(alarmClock.getId());
        setUser(alarmClock.getUser());
        setName(alarmClock.getName());
        setRingstone(alarmClock.getRingstone());
        setAddress(alarmClock.getAddress());
        setColor(alarmClock.getColor());
        setPreparationTime(alarmClock.getPreparationTime());
    }

    public static AlarmClockBean EntityToBean(AlarmClock alarmClock) {
        AlarmClockBean newBean = new AlarmClockBean();

        newBean.fromEntity(alarmClock);

        return newBean;
    }
}

@@ -1032,25 +1032,24 @@
  String ring
-s
 tone;%0A%0A    p
@@ -1528,25 +1528,24 @@
 ring getRing
-s
 tone () %7B%0A  
@@ -1557,25 +1557,24 @@
  return ring
-s
 tone;%0A    %7D%0A
@@ -1593,25 +1593,24 @@
 void setRing
-s
 tone (String
@@ -1610,25 +1610,24 @@
 (String ring
-s
 tone) %7B%0A    
@@ -1635,25 +1635,24 @@
    this.ring
-s
 tone = rings
@@ -1650,17 +1650,16 @@
 e = ring
-s
 tone;%0A  
@@ -2677,25 +2677,24 @@
 lock.setRing
-s
 tone(getRing
@@ -2689,25 +2689,24 @@
 tone(getRing
-s
 tone());%0A   
@@ -3060,25 +3060,24 @@
      setRing
-s
 tone(alarmCl
@@ -3087,17 +3087,16 @@
 .getRing
-s
 tone());

fix ringstone -> ringtone