ItEr50S13AdaptacionServiciosRESTItEr49S18: Implementing calendars export service.
This commit is contained in:
parent
664a25ec8d
commit
fb3bd8bacf
18 changed files with 487 additions and 26 deletions
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.business.calendars.daos;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||||
|
import org.navalplanner.business.common.daos.IntegrationEntityDAO;
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DAO for {@link CalendarData}
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||||
|
public class CalendarDataDAO extends
|
||||||
|
IntegrationEntityDAO<CalendarData>
|
||||||
|
implements ICalendarDataDAO {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.business.calendars.daos;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||||
|
import org.navalplanner.business.common.daos.IntegrationEntityDAO;
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DAO for {@link CalendarException}
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||||
|
public class CalendarExceptionDAO extends
|
||||||
|
IntegrationEntityDAO<CalendarException> implements
|
||||||
|
ICalendarExceptionDAO {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.business.calendars.daos;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||||
|
import org.navalplanner.business.common.daos.IIntegrationEntityDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract for {@link CalendarDataDAO}
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
public interface ICalendarDataDAO extends
|
||||||
|
IIntegrationEntityDAO<CalendarData> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.business.calendars.daos;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||||
|
import org.navalplanner.business.common.daos.IIntegrationEntityDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract for {@link CalendarExceptionDAO}.
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
public interface ICalendarExceptionDAO extends
|
||||||
|
IIntegrationEntityDAO<CalendarException> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -25,19 +25,19 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.navalplanner.business.common.BaseEntity;
|
import org.navalplanner.business.calendars.daos.ICalendarDataDAO;
|
||||||
|
import org.navalplanner.business.common.IntegrationEntity;
|
||||||
|
import org.navalplanner.business.common.Registry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the information about the calendar that can change through time.
|
* Represents the information about the calendar that can change through time.
|
||||||
*
|
*
|
||||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
*/
|
*/
|
||||||
public class CalendarData extends BaseEntity {
|
public class CalendarData extends IntegrationEntity {
|
||||||
|
|
||||||
public static CalendarData create() {
|
public static CalendarData create() {
|
||||||
CalendarData calendarData = new CalendarData();
|
return create(new CalendarData());
|
||||||
calendarData.setNewObject(true);
|
|
||||||
return calendarData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Integer, Integer> hoursPerDay;
|
private Map<Integer, Integer> hoursPerDay;
|
||||||
|
|
@ -159,4 +159,9 @@ public class CalendarData extends BaseEntity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ICalendarDataDAO getIntegrationEntityDAO() {
|
||||||
|
return Registry.getCalendarDataDAO();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ import java.util.Date;
|
||||||
|
|
||||||
import org.hibernate.validator.NotNull;
|
import org.hibernate.validator.NotNull;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.navalplanner.business.common.BaseEntity;
|
import org.navalplanner.business.calendars.daos.ICalendarExceptionDAO;
|
||||||
|
import org.navalplanner.business.common.IntegrationEntity;
|
||||||
|
import org.navalplanner.business.common.Registry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an exceptional day that has a different number of hours. For
|
* Represents an exceptional day that has a different number of hours. For
|
||||||
|
|
@ -34,22 +36,16 @@ import org.navalplanner.business.common.BaseEntity;
|
||||||
*
|
*
|
||||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
*/
|
*/
|
||||||
public class CalendarException extends BaseEntity {
|
public class CalendarException extends IntegrationEntity {
|
||||||
|
|
||||||
public static CalendarException create(Date date, Integer hours,
|
public static CalendarException create(Date date, Integer hours,
|
||||||
CalendarExceptionType type) {
|
CalendarExceptionType type) {
|
||||||
CalendarException exceptionDay = new CalendarException(new LocalDate(
|
return create(new CalendarException(new LocalDate(date), hours, type));
|
||||||
date), hours, type);
|
|
||||||
exceptionDay.setNewObject(true);
|
|
||||||
return exceptionDay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CalendarException create(LocalDate date, Integer hours,
|
public static CalendarException create(LocalDate date, Integer hours,
|
||||||
CalendarExceptionType type) {
|
CalendarExceptionType type) {
|
||||||
CalendarException exceptionDay = new CalendarException(date, hours,
|
return create(new CalendarException(date, hours, type));
|
||||||
type);
|
|
||||||
exceptionDay.setNewObject(true);
|
|
||||||
return exceptionDay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate date;
|
private LocalDate date;
|
||||||
|
|
@ -85,4 +81,9 @@ public class CalendarException extends BaseEntity {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ICalendarExceptionDAO getIntegrationEntityDAO() {
|
||||||
|
return Registry.getCalendarExceptionDAO();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ package org.navalplanner.business.common;
|
||||||
|
|
||||||
import org.navalplanner.business.advance.daos.IAdvanceTypeDAO;
|
import org.navalplanner.business.advance.daos.IAdvanceTypeDAO;
|
||||||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||||
|
import org.navalplanner.business.calendars.daos.ICalendarDataDAO;
|
||||||
|
import org.navalplanner.business.calendars.daos.ICalendarExceptionDAO;
|
||||||
import org.navalplanner.business.calendars.daos.ICalendarExceptionTypeDAO;
|
import org.navalplanner.business.calendars.daos.ICalendarExceptionTypeDAO;
|
||||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||||
import org.navalplanner.business.costcategories.daos.ICostCategoryDAO;
|
import org.navalplanner.business.costcategories.daos.ICostCategoryDAO;
|
||||||
|
|
@ -154,6 +156,12 @@ public class Registry {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IHourCostDAO hourCostDAO;
|
private IHourCostDAO hourCostDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICalendarExceptionDAO calendarExceptionDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICalendarDataDAO calendarDataDAO;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICalendarExceptionTypeDAO calendarExceptionTypeDAO;
|
private ICalendarExceptionTypeDAO calendarExceptionTypeDAO;
|
||||||
|
|
||||||
|
|
@ -282,4 +290,12 @@ public class Registry {
|
||||||
return getInstance().calendarExceptionTypeDAO;
|
return getInstance().calendarExceptionTypeDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ICalendarExceptionDAO getCalendarExceptionDAO() {
|
||||||
|
return getInstance().calendarExceptionDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICalendarDataDAO getCalendarDataDAO() {
|
||||||
|
return getInstance().calendarDataDAO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +51,8 @@
|
||||||
</id>
|
</id>
|
||||||
<version name="version" access="property" type="long" />
|
<version name="version" access="property" type="long" />
|
||||||
|
|
||||||
|
<property name="code" access="property" not-null="true" unique="true"/>
|
||||||
|
|
||||||
<property name="date" access="field"
|
<property name="date" access="field"
|
||||||
type="org.joda.time.contrib.hibernate.PersistentLocalDate"/>
|
type="org.joda.time.contrib.hibernate.PersistentLocalDate"/>
|
||||||
<property name="hours" access="field"/>
|
<property name="hours" access="field"/>
|
||||||
|
|
@ -85,6 +87,8 @@
|
||||||
</id>
|
</id>
|
||||||
<version name="version" access="property" type="long" />
|
<version name="version" access="property" type="long" />
|
||||||
|
|
||||||
|
<property name="code" access="property" not-null="true" unique="true"/>
|
||||||
|
|
||||||
<map name="hoursPerDay">
|
<map name="hoursPerDay">
|
||||||
<key column="BASE_CALENDAR_ID"/>
|
<key column="BASE_CALENDAR_ID"/>
|
||||||
<index column="DAY_ID" type="integer" />
|
<index column="DAY_ID" type="integer" />
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,12 @@
|
||||||
|
|
||||||
package org.navalplanner.ws.calendars.api;
|
package org.navalplanner.ws.calendars.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
||||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||||
import org.navalplanner.ws.common.api.IntegrationEntityDTO;
|
import org.navalplanner.ws.common.api.IntegrationEntityDTO;
|
||||||
|
|
@ -37,16 +42,30 @@ public class BaseCalendarDTO extends IntegrationEntityDTO {
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "calendar-exception-list")
|
||||||
|
@XmlElement(name = "calendar-exception")
|
||||||
|
public List<CalendarExceptionDTO> calendarExceptions = new ArrayList<CalendarExceptionDTO>();
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "calendar-data-list")
|
||||||
|
@XmlElement(name = "calendar-data")
|
||||||
|
public List<CalendarDataDTO> calendarDatas = new ArrayList<CalendarDataDTO>();
|
||||||
|
|
||||||
public BaseCalendarDTO() {
|
public BaseCalendarDTO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseCalendarDTO(String code, String name) {
|
public BaseCalendarDTO(String code, String name,
|
||||||
|
List<CalendarExceptionDTO> calendarExceptions,
|
||||||
|
List<CalendarDataDTO> calendarDatas) {
|
||||||
super(code);
|
super(code);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.calendarExceptions = calendarExceptions;
|
||||||
|
this.calendarDatas = calendarDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseCalendarDTO(String name) {
|
public BaseCalendarDTO(String name,
|
||||||
this(generateCode(), name);
|
List<CalendarExceptionDTO> calendarExceptions,
|
||||||
|
List<CalendarDataDTO> calendarDatas) {
|
||||||
|
this(generateCode(), name, calendarExceptions, calendarDatas);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -54,4 +73,4 @@ public class BaseCalendarDTO extends IntegrationEntityDTO {
|
||||||
return ENTITY_TYPE;
|
return ENTITY_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -45,4 +45,4 @@ public class BaseCalendarListDTO {
|
||||||
this.baseCalendars = baseCalendars;
|
this.baseCalendars = baseCalendars;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.ws.calendars.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||||
|
import org.navalplanner.ws.common.api.IntegrationEntityDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DTO for {@link CalendarData} entity.
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
public class CalendarDataDTO extends IntegrationEntityDTO {
|
||||||
|
|
||||||
|
public final static String ENTITY_TYPE = "calendar-data";
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "hors-per-day-list")
|
||||||
|
@XmlElement(name = "hors-per-day")
|
||||||
|
public List<HoursPerDayDTO> hoursPerDays = new ArrayList<HoursPerDayDTO>();
|
||||||
|
|
||||||
|
@XmlAttribute(name = "expiring-date")
|
||||||
|
public Date expiringDate;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "parent-calendar")
|
||||||
|
public String parentCalendar;
|
||||||
|
|
||||||
|
public CalendarDataDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CalendarDataDTO(String code, List<HoursPerDayDTO> hoursPerDays,
|
||||||
|
Date expiringDate, String parentCalendar) {
|
||||||
|
super(code);
|
||||||
|
this.hoursPerDays = hoursPerDays;
|
||||||
|
this.expiringDate = expiringDate;
|
||||||
|
this.parentCalendar = parentCalendar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CalendarDataDTO(List<HoursPerDayDTO> hoursPerDays,
|
||||||
|
Date expiringDate, String parentCalendar) {
|
||||||
|
this(generateCode(), hoursPerDays, expiringDate, parentCalendar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEntityType() {
|
||||||
|
return ENTITY_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.ws.calendars.api;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||||
|
import org.navalplanner.ws.common.api.IntegrationEntityDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DTO for {@link CalendarException} entity.
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
public class CalendarExceptionDTO extends IntegrationEntityDTO {
|
||||||
|
|
||||||
|
public final static String ENTITY_TYPE = "calendar-exception";
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
public Date date;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
public Integer hours;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "calendar-exception-type-name")
|
||||||
|
public String calendarExceptionTypeName;
|
||||||
|
|
||||||
|
public CalendarExceptionDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CalendarExceptionDTO(String code, Date date, Integer hours,
|
||||||
|
String calendarExceptionTypeName) {
|
||||||
|
super(code);
|
||||||
|
this.date = date;
|
||||||
|
this.hours = hours;
|
||||||
|
this.calendarExceptionTypeName = calendarExceptionTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CalendarExceptionDTO(Date date, Integer hours,
|
||||||
|
String calendarExceptionTypeName) {
|
||||||
|
this(generateCode(), date, hours, calendarExceptionTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEntityType() {
|
||||||
|
return ENTITY_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* This file is part of NavalPlan
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||||
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
|
*
|
||||||
|
* 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.navalplanner.ws.calendars.api;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DTO for represent hours per day of {@link CalendarData} entity.
|
||||||
|
*
|
||||||
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||||
|
*/
|
||||||
|
public class HoursPerDayDTO {
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
public String day;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
public Integer hours;
|
||||||
|
|
||||||
|
public HoursPerDayDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public HoursPerDayDTO(String day, Integer hours) {
|
||||||
|
this.day = day;
|
||||||
|
this.hours = hours;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -31,4 +31,4 @@ public interface ICalendarService {
|
||||||
|
|
||||||
BaseCalendarListDTO getBaseCalendars();
|
BaseCalendarListDTO getBaseCalendars();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,8 +20,18 @@
|
||||||
|
|
||||||
package org.navalplanner.ws.calendars.impl;
|
package org.navalplanner.ws.calendars.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarException;
|
||||||
|
import org.navalplanner.business.calendars.entities.CalendarData.Days;
|
||||||
import org.navalplanner.ws.calendars.api.BaseCalendarDTO;
|
import org.navalplanner.ws.calendars.api.BaseCalendarDTO;
|
||||||
|
import org.navalplanner.ws.calendars.api.CalendarDataDTO;
|
||||||
|
import org.navalplanner.ws.calendars.api.CalendarExceptionDTO;
|
||||||
|
import org.navalplanner.ws.calendars.api.HoursPerDayDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converter from/to {@link BaseCalendar} related entities to/from DTOs.
|
* Converter from/to {@link BaseCalendar} related entities to/from DTOs.
|
||||||
|
|
@ -34,8 +44,46 @@ public final class CalendarConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static BaseCalendarDTO toDTO(BaseCalendar baseCalendar) {
|
public final static BaseCalendarDTO toDTO(BaseCalendar baseCalendar) {
|
||||||
|
List<CalendarExceptionDTO> calendarExceptionDTOs = new ArrayList<CalendarExceptionDTO>();
|
||||||
|
for (CalendarException calendarException : baseCalendar.getExceptions()) {
|
||||||
|
calendarExceptionDTOs.add(toDTO(calendarException));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CalendarDataDTO> calendarDataDTOs = new ArrayList<CalendarDataDTO>();
|
||||||
|
for (CalendarData calendarData : baseCalendar.getCalendarDataVersions()) {
|
||||||
|
calendarDataDTOs.add(toDTO(calendarData));
|
||||||
|
}
|
||||||
|
|
||||||
return new BaseCalendarDTO(baseCalendar.getCode(), baseCalendar
|
return new BaseCalendarDTO(baseCalendar.getCode(), baseCalendar
|
||||||
.getName());
|
.getName(), calendarExceptionDTOs, calendarDataDTOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private final static CalendarExceptionDTO toDTO(
|
||||||
|
CalendarException calendarException) {
|
||||||
|
return new CalendarExceptionDTO(calendarException.getCode(),
|
||||||
|
calendarException.getDate().toDateTimeAtStartOfDay().toDate(),
|
||||||
|
calendarException.getHours(), calendarException.getType()
|
||||||
|
.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static CalendarDataDTO toDTO(CalendarData calendarData) {
|
||||||
|
List<HoursPerDayDTO> hoursPerDayDTOs = new ArrayList<HoursPerDayDTO>();
|
||||||
|
Days[] days = CalendarData.Days.values();
|
||||||
|
for (Integer day : calendarData.getHoursPerDay().keySet()) {
|
||||||
|
String dayName = days[day].name();
|
||||||
|
Integer hours = calendarData.getHoursPerDay().get(day);
|
||||||
|
hoursPerDayDTOs.add(new HoursPerDayDTO(dayName, hours));
|
||||||
|
}
|
||||||
|
|
||||||
|
Date expiringDate = (calendarData.getExpiringDate() != null) ? calendarData
|
||||||
|
.getExpiringDate().toDateTimeAtStartOfDay().toDate()
|
||||||
|
: null;
|
||||||
|
String parentCalendar = (calendarData.getParent() != null) ? calendarData
|
||||||
|
.getParent().getCode()
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return new CalendarDataDTO(hoursPerDayDTOs, expiringDate,
|
||||||
|
parentCalendar);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -20,13 +20,14 @@
|
||||||
|
|
||||||
package org.navalplanner.ws.calendars.impl;
|
package org.navalplanner.ws.calendars.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||||
import org.navalplanner.business.common.daos.IIntegrationEntityDAO;
|
|
||||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||||
import org.navalplanner.ws.calendars.api.BaseCalendarDTO;
|
import org.navalplanner.ws.calendars.api.BaseCalendarDTO;
|
||||||
import org.navalplanner.ws.calendars.api.BaseCalendarListDTO;
|
import org.navalplanner.ws.calendars.api.BaseCalendarListDTO;
|
||||||
|
|
@ -54,7 +55,7 @@ public class CalendarServiceREST extends
|
||||||
private IBaseCalendarDAO baseCalendarDAO;
|
private IBaseCalendarDAO baseCalendarDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IIntegrationEntityDAO<BaseCalendar> getIntegrationEntityDAO() {
|
protected IBaseCalendarDAO getIntegrationEntityDAO() {
|
||||||
return baseCalendarDAO;
|
return baseCalendarDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +82,10 @@ public class CalendarServiceREST extends
|
||||||
@GET
|
@GET
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public BaseCalendarListDTO getBaseCalendars() {
|
public BaseCalendarListDTO getBaseCalendars() {
|
||||||
return new BaseCalendarListDTO(findAll());
|
// Avoid ResourceCalendar entities
|
||||||
|
List<BaseCalendar> justBaseCalendars = getIntegrationEntityDAO()
|
||||||
|
.getBaseCalendars();
|
||||||
|
return new BaseCalendarListDTO(toDTO(justBaseCalendars));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +82,10 @@
|
||||||
|
|
||||||
- export-calendar-exception-types.sh (authenticate with wsreader/wsreader)
|
- export-calendar-exception-types.sh (authenticate with wsreader/wsreader)
|
||||||
|
|
||||||
|
* Export calendars:
|
||||||
|
|
||||||
|
- export-calendars.sh (authenticate with wsreader/wsreader)
|
||||||
|
|
||||||
+ When working with the online demo add "--prod" argument to every command.
|
+ When working with the online demo add "--prod" argument to every command.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
|
||||||
21
scripts/rest-clients/export-calendars.sh
Executable file
21
scripts/rest-clients/export-calendars.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ./rest-common-env.sh
|
||||||
|
|
||||||
|
printf "Login name: "
|
||||||
|
read loginName
|
||||||
|
printf "Password: "
|
||||||
|
read password
|
||||||
|
|
||||||
|
if [ "$1" = "--prod" ]; then
|
||||||
|
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
|
||||||
|
certificate=$PRODUCTION_CERTIFICATE
|
||||||
|
else
|
||||||
|
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||||
|
certificate=$DEVELOPMENT_CERTIFICATE
|
||||||
|
fi
|
||||||
|
|
||||||
|
authorization=`./base64.sh $loginName:$password`
|
||||||
|
|
||||||
|
curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \
|
||||||
|
$baseServiceURL/calendars | tidy -xml -i -q -utf8
|
||||||
Loading…
Add table
Reference in a new issue