|
|
@ -1,9 +1,13 @@ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. This library is free software; you can redistribute it |
|
|
|
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. |
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software |
|
|
|
* |
|
|
|
* Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in |
|
|
|
* This library is free software; you can redistribute it and/or modify it under the terms of the |
|
|
|
* the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
|
|
* GNU Lesser General Public License as published by the Free Software Foundation; either version |
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|
|
|
* 2.1 of the License, or (at your option) any later version. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* This library 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 |
|
|
|
|
|
|
|
* Lesser General Public License for more details. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package it.tref.portos.calendar.appointments.service.impl; |
|
|
|
package it.tref.portos.calendar.appointments.service.impl; |
|
|
@ -42,23 +46,28 @@ import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The implementation of the disponibilita local service. |
|
|
|
* The implementation of the disponibilita local service. |
|
|
|
|
|
|
|
* |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy |
|
|
|
* All custom service methods should be put in this class. Whenever methods are added, rerun |
|
|
|
* their definitions into the {@link it.tref.portos.calendar.appointments.service.DisponibilitaLocalService} interface. |
|
|
|
* ServiceBuilder to copy their definitions into the |
|
|
|
|
|
|
|
* {@link it.tref.portos.calendar.appointments.service.DisponibilitaLocalService} interface. |
|
|
|
|
|
|
|
* |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* This is a local service. Methods of this service will not have security checks based on the propagated JAAS |
|
|
|
* This is a local service. Methods of this service will not have security checks based on the |
|
|
|
* credentials because this service can only be accessed from within the same VM. |
|
|
|
* propagated JAAS credentials because this service can only be accessed from within the same VM. |
|
|
|
* </p> |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @author 3F Consulting + Manifattura Web Group s.r.l. |
|
|
|
* @author 3F Consulting |
|
|
|
* @see it.tref.portos.calendar.appointments.service.base.DisponibilitaLocalServiceBaseImpl |
|
|
|
* @see it.tref.portos.calendar.appointments.service.base.DisponibilitaLocalServiceBaseImpl |
|
|
|
* @see it.tref.portos.calendar.appointments.service.DisponibilitaLocalServiceUtil |
|
|
|
* @see it.tref.portos.calendar.appointments.service.DisponibilitaLocalServiceUtil |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBaseImpl { |
|
|
|
public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBaseImpl { |
|
|
|
/* |
|
|
|
/* |
|
|
|
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link |
|
|
|
* NOTE FOR DEVELOPERS: |
|
|
|
* it.tref.portos.calendar.appointments.service.DisponibilitaLocalServiceUtil} to access the disponibilita local |
|
|
|
* |
|
|
|
* service. |
|
|
|
* Never reference this interface directly. Always use {@link |
|
|
|
|
|
|
|
* it.tref.portos.calendar.appointments.service.DisponibilitaLocalServiceUtil} to access the |
|
|
|
|
|
|
|
* disponibilita local service. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
private static Log _log = LogFactoryUtil.getLog(DisponibilitaLocalServiceImpl.class); |
|
|
|
private static Log _log = LogFactoryUtil.getLog(DisponibilitaLocalServiceImpl.class); |
|
|
@ -67,8 +76,11 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
public long checkDisponibilitaExist(long funzionarioId, Date startDate, Date endDate) throws SystemException{ |
|
|
|
public long checkDisponibilitaExist(long funzionarioId, Date startDate, Date endDate) throws SystemException{ |
|
|
|
|
|
|
|
|
|
|
|
long exist = 0L; |
|
|
|
long exist = 0L; |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDate))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDate))); |
|
|
|
|
|
|
|
|
|
|
@ -80,14 +92,18 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
if(!results.isEmpty()){ |
|
|
|
if(!results.isEmpty()){ |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return exist; |
|
|
|
return exist; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public long checkDisponibilitaExist(long funzionarioId, Date startDate, Date endDate, long presidio) throws SystemException{ |
|
|
|
public long checkDisponibilitaExist(long funzionarioId, Date startDate, Date endDate, long presidio) throws SystemException{ |
|
|
|
|
|
|
|
|
|
|
|
long exist = 0L; |
|
|
|
long exist = 0L; |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDate))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDate))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("presidio",presidio)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("presidio",presidio)); |
|
|
@ -100,6 +116,7 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
if(!results.isEmpty()){ |
|
|
|
if(!results.isEmpty()){ |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return exist; |
|
|
|
return exist; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -107,17 +124,23 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
|
|
|
|
|
|
|
|
Organization organization = OrganizationLocalServiceUtil.fetchOrganization(presidio); |
|
|
|
Organization organization = OrganizationLocalServiceUtil.fetchOrganization(presidio); |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
|
|
Disponibilita disponibilita = |
|
|
|
Disponibilita disponibilita = |
|
|
|
disponibilitaPersistence.create(counterLocalService.increment(Disponibilita.class.getName())); |
|
|
|
disponibilitaPersistence.create(counterLocalService.increment(Disponibilita.class.getName())); |
|
|
|
|
|
|
|
|
|
|
|
User user = userPersistence.findByPrimaryKey(userId); |
|
|
|
User user = userPersistence.findByPrimaryKey(userId); |
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
disponibilita.setCompanyId(serviceContext.getCompanyId()); |
|
|
|
disponibilita.setCompanyId(serviceContext.getCompanyId()); |
|
|
|
disponibilita.setUserId(user.getUserId()); |
|
|
|
disponibilita.setUserId(user.getUserId()); |
|
|
|
disponibilita.setUserName(user.getFullName()); |
|
|
|
disponibilita.setUserName(user.getFullName()); |
|
|
|
disponibilita.setCreateDate(serviceContext.getCreateDate(now)); |
|
|
|
disponibilita.setCreateDate(serviceContext.getCreateDate(now)); |
|
|
|
disponibilita.setModifiedDate(serviceContext.getModifiedDate(now)); |
|
|
|
disponibilita.setModifiedDate(serviceContext.getModifiedDate(now)); |
|
|
|
disponibilita.setGroupId(organization.getGroupId()); |
|
|
|
disponibilita.setGroupId(organization.getGroupId()); |
|
|
|
|
|
|
|
|
|
|
|
disponibilita.setFunzionarioId(funzionarioId); |
|
|
|
disponibilita.setFunzionarioId(funzionarioId); |
|
|
|
disponibilita.setStartDate(startDate); |
|
|
|
disponibilita.setStartDate(startDate); |
|
|
|
disponibilita.setEndDate(endDate); |
|
|
|
disponibilita.setEndDate(endDate); |
|
|
@ -135,17 +158,23 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
|
|
|
|
|
|
|
|
Organization organization = OrganizationLocalServiceUtil.fetchOrganization(presidio); |
|
|
|
Organization organization = OrganizationLocalServiceUtil.fetchOrganization(presidio); |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
|
|
Disponibilita disponibilita = |
|
|
|
Disponibilita disponibilita = |
|
|
|
disponibilitaPersistence.create(counterLocalService.increment(Disponibilita.class.getName())); |
|
|
|
disponibilitaPersistence.create(counterLocalService.increment(Disponibilita.class.getName())); |
|
|
|
|
|
|
|
|
|
|
|
User user = userPersistence.findByPrimaryKey(userId); |
|
|
|
User user = userPersistence.findByPrimaryKey(userId); |
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
disponibilita.setCompanyId(serviceContext.getCompanyId()); |
|
|
|
disponibilita.setCompanyId(serviceContext.getCompanyId()); |
|
|
|
disponibilita.setUserId(user.getUserId()); |
|
|
|
disponibilita.setUserId(user.getUserId()); |
|
|
|
disponibilita.setUserName(user.getFullName()); |
|
|
|
disponibilita.setUserName(user.getFullName()); |
|
|
|
disponibilita.setCreateDate(serviceContext.getCreateDate(now)); |
|
|
|
disponibilita.setCreateDate(serviceContext.getCreateDate(now)); |
|
|
|
disponibilita.setModifiedDate(serviceContext.getModifiedDate(now)); |
|
|
|
disponibilita.setModifiedDate(serviceContext.getModifiedDate(now)); |
|
|
|
disponibilita.setGroupId(organization.getGroupId()); |
|
|
|
disponibilita.setGroupId(organization.getGroupId()); |
|
|
|
|
|
|
|
|
|
|
|
disponibilita.setFunzionarioId(funzionarioId); |
|
|
|
disponibilita.setFunzionarioId(funzionarioId); |
|
|
|
disponibilita.setStartDate(startDate); |
|
|
|
disponibilita.setStartDate(startDate); |
|
|
|
disponibilita.setEndDate(endDate); |
|
|
|
disponibilita.setEndDate(endDate); |
|
|
@ -163,13 +192,16 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
String oraInizio, String oraFine, int giornoSettimana, ServiceContext serviceContext) throws SystemException, PortalException, ParseException{ |
|
|
|
String oraInizio, String oraFine, int giornoSettimana, ServiceContext serviceContext) throws SystemException, PortalException, ParseException{ |
|
|
|
|
|
|
|
|
|
|
|
Organization organization = OrganizationLocalServiceUtil.fetchOrganization(presidioId); |
|
|
|
Organization organization = OrganizationLocalServiceUtil.fetchOrganization(presidioId); |
|
|
|
|
|
|
|
|
|
|
|
List<User> userDefinitivo = new ArrayList<User>(); |
|
|
|
List<User> userDefinitivo = new ArrayList<User>(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
if(organization != null){ |
|
|
|
if(organization != null){ |
|
|
|
List<User> users = UserLocalServiceUtil.getOrganizationUsers(presidioId); |
|
|
|
List<User> users = UserLocalServiceUtil.getOrganizationUsers(presidioId); |
|
|
|
|
|
|
|
|
|
|
|
for (User user : users) { |
|
|
|
for (User user : users) { |
|
|
|
|
|
|
|
|
|
|
|
Role portosSupporto = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_supporto"); |
|
|
|
Role portosSupporto = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_supporto"); |
|
|
|
|
|
|
|
|
|
|
|
Role portosIstruttore = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_calendario"); |
|
|
|
Role portosIstruttore = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_calendario"); |
|
|
@ -185,20 +217,29 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (NumberFormatException | SystemException e) { |
|
|
|
} catch (NumberFormatException | SystemException e) { |
|
|
|
_log.error(e,e); |
|
|
|
_log.error(e,e); |
|
|
|
} catch (PortalException e) { |
|
|
|
} catch (PortalException e) { |
|
|
|
_log.error(e,e); |
|
|
|
_log.error(e,e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Calendar calendarStartDate = Calendar.getInstance(); |
|
|
|
Calendar calendarStartDate = Calendar.getInstance(); |
|
|
|
calendarStartDate.setTime(startDate); |
|
|
|
calendarStartDate.setTime(startDate); |
|
|
|
|
|
|
|
|
|
|
|
if(calendarStartDate.get(Calendar.DAY_OF_WEEK) == giornoSettimana){ |
|
|
|
if(calendarStartDate.get(Calendar.DAY_OF_WEEK) == giornoSettimana){ |
|
|
|
|
|
|
|
|
|
|
|
Date startDateToInsert = formatDateTime(oraInizio, startDate); |
|
|
|
Date startDateToInsert = formatDateTime(oraInizio, startDate); |
|
|
|
Date endDateToInsert = formatDateTime(oraFine, startDate); |
|
|
|
Date endDateToInsert = formatDateTime(oraFine, startDate); |
|
|
|
|
|
|
|
|
|
|
|
for (User user : userDefinitivo) { |
|
|
|
for (User user : userDefinitivo) { |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", user.getUserId())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", user.getUserId())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDateToInsert))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDateToInsert))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", organization.getGroupId())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", organization.getGroupId())); |
|
|
@ -222,25 +263,35 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
addDayForDisponibilita(startDate, endDate, oraInizio, oraFine, giornoSettimana, userDefinitivo, |
|
|
|
|
|
|
|
organization.getOrganizationId(), serviceContext); |
|
|
|
addDayForDisponibilita(startDate, endDate, oraInizio, oraFine, giornoSettimana, |
|
|
|
|
|
|
|
userDefinitivo, organization.getOrganizationId(), serviceContext); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void addDayForDisponibilita(Date date, Date endDate, String oraInizio, String oraFine, int giornoSettimana, |
|
|
|
private void addDayForDisponibilita(Date date, Date endDate, String oraInizio, String oraFine,int giornoSettimana,List<User> users, |
|
|
|
List<User> users, long presidioId, ServiceContext serviceContext) throws ParseException, SystemException, |
|
|
|
long presidioId, ServiceContext serviceContext) |
|
|
|
PortalException { |
|
|
|
throws ParseException, SystemException, PortalException{ |
|
|
|
|
|
|
|
|
|
|
|
Organization org = OrganizationLocalServiceUtil.fetchOrganization(presidioId); |
|
|
|
Organization org = OrganizationLocalServiceUtil.fetchOrganization(presidioId); |
|
|
|
|
|
|
|
|
|
|
|
Date datePlus = datePlusOneDay(date); |
|
|
|
Date datePlus = datePlusOneDay(date); |
|
|
|
if(date.before(datePlus) && (endDate.after(datePlus) || isSameDate(endDate, datePlus))){ |
|
|
|
if(date.before(datePlus) && (endDate.after(datePlus) || isSameDate(endDate, datePlus))){ |
|
|
|
|
|
|
|
|
|
|
|
Calendar calendarStartDate = Calendar.getInstance(); |
|
|
|
Calendar calendarStartDate = Calendar.getInstance(); |
|
|
|
calendarStartDate.setTime(datePlus); |
|
|
|
calendarStartDate.setTime(datePlus); |
|
|
|
|
|
|
|
|
|
|
|
if(calendarStartDate.get(Calendar.DAY_OF_WEEK) == giornoSettimana){ |
|
|
|
if(calendarStartDate.get(Calendar.DAY_OF_WEEK) == giornoSettimana){ |
|
|
|
|
|
|
|
|
|
|
|
Date startDateToInsert = formatDateTime(oraInizio, datePlus); |
|
|
|
Date startDateToInsert = formatDateTime(oraInizio, datePlus); |
|
|
|
Date endDateToInsert = formatDateTime(oraFine, datePlus); |
|
|
|
Date endDateToInsert = formatDateTime(oraFine, datePlus); |
|
|
|
|
|
|
|
|
|
|
|
for (User user : users) { |
|
|
|
for (User user : users) { |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", user.getUserId())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", user.getUserId())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDateToInsert))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("exactDate", sdf.format(startDateToInsert))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", org.getGroupId())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", org.getGroupId())); |
|
|
@ -262,12 +313,15 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
disponibilitaLocalService.updateDisponibilita(disponibilita); |
|
|
|
disponibilitaLocalService.updateDisponibilita(disponibilita); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
addDayForDisponibilita(datePlus, endDate, oraInizio, oraFine, giornoSettimana, users, presidioId, |
|
|
|
|
|
|
|
serviceContext); |
|
|
|
addDayForDisponibilita(datePlus, endDate, oraInizio, oraFine, giornoSettimana, users, |
|
|
|
|
|
|
|
presidioId, serviceContext); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
addDayForDisponibilita(datePlus, endDate, oraInizio, oraFine, giornoSettimana, users, presidioId, |
|
|
|
addDayForDisponibilita(datePlus, endDate, oraInizio, oraFine, giornoSettimana, users, |
|
|
|
serviceContext); |
|
|
|
presidioId, serviceContext); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -276,7 +330,9 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(date); |
|
|
|
calendar.setTime(date); |
|
|
|
|
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, 1); |
|
|
|
calendar.add(Calendar.DATE, 1); |
|
|
|
|
|
|
|
|
|
|
|
return calendar.getTime(); |
|
|
|
return calendar.getTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -291,24 +347,27 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); |
|
|
|
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); |
|
|
|
|
|
|
|
|
|
|
|
return sameDay; |
|
|
|
return sameDay; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<Disponibilita> findByStartDate(Date date) throws SystemException { |
|
|
|
public List<Disponibilita> findByStartDate(Date date) throws SystemException { |
|
|
|
|
|
|
|
|
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date end = DateUtils.addDays(start, 1); |
|
|
|
Date end = DateUtils.addDays(start, 1); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.between("startDate", start, end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.between("startDate", start, end)); |
|
|
|
dynamicQuery.addOrder(OrderFactoryUtil.desc("funzionarioId")); |
|
|
|
dynamicQuery.addOrder(OrderFactoryUtil.desc("funzionarioId")); |
|
|
|
|
|
|
|
|
|
|
|
return disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
return disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<Disponibilita> findByFunzionarioStartAndPresidio(long funzionarioId, Date date, long presidio) throws SystemException { |
|
|
|
public List<Disponibilita> findByFunzionarioStartAndPresidio(long funzionarioId, Date date, long presidio) throws SystemException { |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date end = DateUtils.addHours(start, 22); |
|
|
|
Date end = DateUtils.addHours(start, 22); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
@ -316,13 +375,15 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
return results; |
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Disponibilita> findByFunzionario_StartDate(long funzionarioId, Date date, long presidio) throws SystemException { |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date end = DateUtils.addHours(start, 22); |
|
|
|
Date end = DateUtils.addHours(start, 22); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
@ -339,8 +400,10 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
Date end = DateUtils.addHours(start, 22); |
|
|
|
Date end = DateUtils.addHours(start, 22); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
|
|
|
|
|
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
|
|
|
|
|
|
|
@ -352,9 +415,12 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
public int countByFunzionarioStartDate(long funzionarioId, Date date) throws SystemException { |
|
|
|
public int countByFunzionarioStartDate(long funzionarioId, Date date) throws SystemException { |
|
|
|
|
|
|
|
|
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
|
|
|
|
|
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
|
|
|
|
|
|
|
@ -368,34 +434,44 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
if(isDirigenteGenerale){ |
|
|
|
if(isDirigenteGenerale){ |
|
|
|
List<Organization> orgs = |
|
|
|
|
|
|
|
OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS, QueryUtil.ALL_POS); |
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getOrganizations(-1, -1); |
|
|
|
for (Organization organization : orgs) { |
|
|
|
for (Organization organization : orgs) { |
|
|
|
if(organization.getParentOrganization() != null){ |
|
|
|
if(organization.getParentOrganization() != null){ |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
for (Organization organization : orgs) { |
|
|
|
for (Organization organization : orgs) { |
|
|
|
|
|
|
|
|
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
boolean isPO = |
|
|
|
|
|
|
|
UserGroupRoleLocalServiceUtil.hasUserGroupRole(funzionarioId, organization.getGroupId(), |
|
|
|
boolean isPO = UserGroupRoleLocalServiceUtil.hasUserGroupRole( |
|
|
|
portosPO.getRoleId()); |
|
|
|
funzionarioId, organization.getGroupId(), portosPO.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
if(isPO){ |
|
|
|
if(isPO){ |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (PortalException e) { |
|
|
|
} catch (PortalException e) { |
|
|
|
_log.error(e,e); |
|
|
|
_log.error(e,e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
if(!provinciaFilter.equals("-1") && !provinciaFilter.equals("")){ |
|
|
|
if(!provinciaFilter.equals("-1") && !provinciaFilter.equals("")){ |
|
|
@ -409,7 +485,9 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
|
|
|
|
|
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
|
|
|
|
|
|
|
@ -423,34 +501,44 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
if(isDirigenteGenerale){ |
|
|
|
if(isDirigenteGenerale){ |
|
|
|
List<Organization> orgs = |
|
|
|
|
|
|
|
OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS, QueryUtil.ALL_POS); |
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getOrganizations(-1, -1); |
|
|
|
for (Organization organization : orgs) { |
|
|
|
for (Organization organization : orgs) { |
|
|
|
if(organization.getParentOrganization() != null){ |
|
|
|
if(organization.getParentOrganization() != null){ |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
for (Organization organization : orgs) { |
|
|
|
for (Organization organization : orgs) { |
|
|
|
|
|
|
|
|
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
boolean isPO = |
|
|
|
|
|
|
|
UserGroupRoleLocalServiceUtil.hasUserGroupRole(funzionarioId, organization.getGroupId(), |
|
|
|
boolean isPO = UserGroupRoleLocalServiceUtil.hasUserGroupRole( |
|
|
|
portosPO.getRoleId()); |
|
|
|
funzionarioId, organization.getGroupId(), portosPO.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
if(isPO){ |
|
|
|
if(isPO){ |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (PortalException e) { |
|
|
|
} catch (PortalException e) { |
|
|
|
_log.error(e,e); |
|
|
|
_log.error(e,e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
if(!provinciaFilter.equals("-1") && !provinciaFilter.equals("")){ |
|
|
|
if(!provinciaFilter.equals("-1") && !provinciaFilter.equals("")){ |
|
|
@ -464,7 +552,9 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
|
|
|
|
|
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
|
|
|
|
|
|
|
@ -478,7 +568,9 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
@ -490,26 +582,36 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
for (Organization organization : orgs) { |
|
|
|
for (Organization organization : orgs) { |
|
|
|
|
|
|
|
|
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
boolean isPO = |
|
|
|
|
|
|
|
UserGroupRoleLocalServiceUtil.hasUserGroupRole(funzionarioId, organization.getGroupId(), |
|
|
|
boolean isPO = UserGroupRoleLocalServiceUtil.hasUserGroupRole( |
|
|
|
portosPO.getRoleId()); |
|
|
|
funzionarioId, organization.getGroupId(), portosPO.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
if(isPO){ |
|
|
|
if(isPO){ |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (PortalException e) { |
|
|
|
} catch (PortalException e) { |
|
|
|
_log.error(e,e); |
|
|
|
_log.error(e,e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
|
|
|
|
|
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
|
|
|
|
|
|
|
@ -523,7 +625,9 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
List<Long> orgIds = new ArrayList<Long>(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
Role dirigenteGenerale = RoleLocalServiceUtil.getRole(user.getCompanyId(), "dirigente_generale"); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
@ -535,26 +639,36 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(funzionarioId); |
|
|
|
for (Organization organization : orgs) { |
|
|
|
for (Organization organization : orgs) { |
|
|
|
|
|
|
|
|
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
Role portosPO = RoleLocalServiceUtil.getRole(organization.getCompanyId(), "portos_po"); |
|
|
|
boolean isPO = |
|
|
|
|
|
|
|
UserGroupRoleLocalServiceUtil.hasUserGroupRole(funzionarioId, organization.getGroupId(), |
|
|
|
boolean isPO = UserGroupRoleLocalServiceUtil.hasUserGroupRole( |
|
|
|
portosPO.getRoleId()); |
|
|
|
funzionarioId, organization.getGroupId(), portosPO.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
if(isPO){ |
|
|
|
if(isPO){ |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
orgIds.add(organization.getOrganizationId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (PortalException e) { |
|
|
|
} catch (PortalException e) { |
|
|
|
_log.error(e,e); |
|
|
|
_log.error(e,e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
Date start = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
|
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
DynamicQuery dynamicQuery = dynamicQuery(); |
|
|
|
|
|
|
|
|
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
|
|
|
|
|
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
Order defaultOrder = OrderFactoryUtil.asc("startDate"); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
dynamicQuery.addOrder(defaultOrder); |
|
|
|
|
|
|
|
|
|
|
@ -564,13 +678,14 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Date formatDateTime(String orario, Date day) throws ParseException { |
|
|
|
private Date formatDateTime(String orario, Date day) throws ParseException { |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
|
|
|
Date data = sdf.parse(orario); |
|
|
|
Date data = sdf.parse(orario); |
|
|
|
Calendar calendar = GregorianCalendar.getInstance(); |
|
|
|
Calendar calendar = GregorianCalendar.getInstance(); |
|
|
|
calendar.setTime(data); |
|
|
|
calendar.setTime(data); |
|
|
|
Date date = DateUtils.addHours(day, calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
Date date = DateUtils.addHours(day, calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
date = DateUtils.addMinutes(date, calendar.get(Calendar.MINUTE)); |
|
|
|
date = DateUtils.addMinutes(date, calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
|
|
|
|
return date; |
|
|
|
return date; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|