|
|
@ -26,13 +26,11 @@ import com.liferay.portal.kernel.dao.orm.DynamicQuery; |
|
|
|
import com.liferay.portal.kernel.dao.orm.Order; |
|
|
|
import com.liferay.portal.kernel.dao.orm.Order; |
|
|
|
import com.liferay.portal.kernel.dao.orm.OrderFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.dao.orm.OrderFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.dao.orm.QueryUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.exception.PortalException; |
|
|
|
import com.liferay.portal.kernel.exception.PortalException; |
|
|
|
import com.liferay.portal.kernel.exception.SystemException; |
|
|
|
import com.liferay.portal.kernel.exception.SystemException; |
|
|
|
import com.liferay.portal.kernel.log.Log; |
|
|
|
import com.liferay.portal.kernel.log.Log; |
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.util.StringPool; |
|
|
|
|
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
import com.liferay.portal.model.Role; |
|
|
|
import com.liferay.portal.model.Role; |
|
|
|
import com.liferay.portal.model.User; |
|
|
|
import com.liferay.portal.model.User; |
|
|
@ -40,6 +38,7 @@ import com.liferay.portal.service.OrganizationLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.RoleLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.RoleLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The implementation of the disponibilita local service. |
|
|
|
* The implementation of the disponibilita local service. |
|
|
@ -64,17 +63,19 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
|
|
|
|
|
|
|
|
private static Log _log = LogFactoryUtil.getLog(DisponibilitaLocalServiceImpl.class); |
|
|
|
private static Log _log = LogFactoryUtil.getLog(DisponibilitaLocalServiceImpl.class); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
//Bug 32935
|
|
|
|
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))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate", startDate)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate", endDate)); |
|
|
|
//Bug 32935
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate",startDate)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate",endDate)); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
if (!results.isEmpty()) { |
|
|
|
if (!results.isEmpty()) { |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
@ -82,19 +83,19 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
return exist; |
|
|
|
return exist; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
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)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate", startDate)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate", endDate)); |
|
|
|
//Bug 32935
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate",startDate)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate",endDate)); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
if (!results.isEmpty()) { |
|
|
|
if (!results.isEmpty()) { |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
|
exist = results.get(0).getDisponibilitaId(); |
|
|
@ -102,7 +103,6 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
return exist; |
|
|
|
return exist; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Disponibilita addDisponibilita(long userId, long funzionarioId, Date startDate, Date endDate, long presidio, |
|
|
|
public Disponibilita addDisponibilita(long userId, long funzionarioId, Date startDate, Date endDate, long presidio, |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
|
|
|
|
|
|
|
@ -124,13 +124,15 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
disponibilita.setPresidio(presidio); |
|
|
|
disponibilita.setPresidio(presidio); |
|
|
|
disponibilita.setExactDate(sdf.format(startDate)); |
|
|
|
disponibilita.setExactDate(sdf.format(startDate)); |
|
|
|
disponibilita.setDisponibile(true); |
|
|
|
disponibilita.setDisponibile(true); |
|
|
|
disponibilita = updateDisponibilita(disponibilita); |
|
|
|
|
|
|
|
|
|
|
|
disponibilita = disponibilitaLocalService.updateDisponibilita(disponibilita); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return disponibilita; |
|
|
|
return disponibilita; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Disponibilita addIndisponibilita(long userId, long funzionarioId, Date startDate, Date endDate, long presidio, |
|
|
|
public Disponibilita addIndisponibilita(long userId, long funzionarioId, Date startDate, Date endDate, |
|
|
|
ServiceContext serviceContext) throws SystemException, PortalException { |
|
|
|
long presidio, 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"); |
|
|
@ -150,29 +152,35 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
disponibilita.setPresidio(presidio); |
|
|
|
disponibilita.setPresidio(presidio); |
|
|
|
disponibilita.setExactDate(sdf.format(startDate)); |
|
|
|
disponibilita.setExactDate(sdf.format(startDate)); |
|
|
|
disponibilita.setDisponibile(false); |
|
|
|
disponibilita.setDisponibile(false); |
|
|
|
disponibilita = updateDisponibilita(disponibilita); |
|
|
|
|
|
|
|
|
|
|
|
disponibilita = disponibilitaLocalService.updateDisponibilita(disponibilita); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return disponibilita; |
|
|
|
return disponibilita; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void addDisponibilitaGenerale(long userId, Date startDate, Date endDate, long presidioId, |
|
|
|
public void addDisponibilitaGenerale(long userId, Date startDate, Date endDate, long presidioId, String oraInizio, |
|
|
|
String oraInizio, String oraFine, int giornoSettimana, ServiceContext serviceContext) throws SystemException, PortalException, ParseException{ |
|
|
|
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) { |
|
|
|
|
|
|
|
List<User> users = userLocalService.getOrganizationUsers(presidioId); |
|
|
|
if(organization != null){ |
|
|
|
|
|
|
|
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"); |
|
|
|
if (!userLocalService.hasRoleUser(portosSupporto.getRoleId(), user.getUserId())) { |
|
|
|
|
|
|
|
boolean isIstruttore = |
|
|
|
if(!UserLocalServiceUtil.hasRoleUser(portosSupporto.getRoleId(), user.getUserId())){ |
|
|
|
UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), |
|
|
|
|
|
|
|
organization.getGroupId(), portosIstruttore.getRoleId()); |
|
|
|
boolean isIstruttore = UserGroupRoleLocalServiceUtil.hasUserGroupRole( |
|
|
|
if (isIstruttore) { |
|
|
|
user.getUserId(), organization.getGroupId(), portosIstruttore.getRoleId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isIstruttore){ |
|
|
|
userDefinitivo.add(user); |
|
|
|
userDefinitivo.add(user); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -194,18 +202,22 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
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())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate", startDateToInsert)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate", endDateToInsert)); |
|
|
|
//Bug 32935
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate",startDateToInsert)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate",endDateToInsert)); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
if (results.isEmpty()) { |
|
|
|
if (results.isEmpty()) { |
|
|
|
addDisponibilita(serviceContext.getUserId(), user.getUserId(), startDateToInsert, endDateToInsert, |
|
|
|
addDisponibilita(serviceContext.getUserId(), user.getUserId(), startDateToInsert, endDateToInsert, |
|
|
|
organization.getOrganizationId(), serviceContext); |
|
|
|
organization.getOrganizationId(), serviceContext); |
|
|
|
} else { |
|
|
|
} |
|
|
|
for (Iterator<Disponibilita> iterator = results.iterator(); iterator.hasNext();) { |
|
|
|
//Bug 32935
|
|
|
|
Disponibilita disponibilita = iterator.next(); |
|
|
|
else{ |
|
|
|
|
|
|
|
for (Iterator iterator = results.iterator(); iterator.hasNext();) { |
|
|
|
|
|
|
|
Disponibilita disponibilita = (Disponibilita) iterator.next(); |
|
|
|
disponibilita.setDisponibile(true); |
|
|
|
disponibilita.setDisponibile(true); |
|
|
|
updateDisponibilita(disponibilita); |
|
|
|
disponibilitaLocalService.updateDisponibilita(disponibilita); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -232,18 +244,22 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
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())); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate", startDateToInsert)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate", endDateToInsert)); |
|
|
|
//Bug 32935
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("startDate",startDateToInsert)); |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("endDate",endDateToInsert)); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
if (results.isEmpty()) { |
|
|
|
if(results.isEmpty()){ |
|
|
|
addDisponibilita(serviceContext.getUserId(), user.getUserId(), startDateToInsert, |
|
|
|
addDisponibilita(serviceContext.getUserId(), user.getUserId(), startDateToInsert, endDateToInsert, |
|
|
|
endDateToInsert, presidioId, serviceContext); |
|
|
|
presidioId, serviceContext); |
|
|
|
} else { |
|
|
|
} |
|
|
|
for (Iterator<Disponibilita> iterator = results.iterator(); iterator.hasNext();) { |
|
|
|
//Bug 32935
|
|
|
|
Disponibilita disponibilita = iterator.next(); |
|
|
|
else{ |
|
|
|
|
|
|
|
for (Iterator iterator = results.iterator(); iterator.hasNext();) { |
|
|
|
|
|
|
|
Disponibilita disponibilita = (Disponibilita) iterator.next(); |
|
|
|
disponibilita.setDisponibile(true); |
|
|
|
disponibilita.setDisponibile(true); |
|
|
|
updateDisponibilita(disponibilita); |
|
|
|
disponibilitaLocalService.updateDisponibilita(disponibilita); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -276,8 +292,6 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
return sameDay; |
|
|
|
return sameDay; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
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); |
|
|
@ -288,10 +302,9 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
return disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
return disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
} |
|
|
|
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(); |
|
|
@ -299,15 +312,12 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", presidio)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", presidio)); |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
return results; |
|
|
|
return results; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
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); |
|
|
@ -316,24 +326,28 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ge("startDate", start)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.lt("endDate", end)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", presidio)); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("groupId", presidio)); |
|
|
|
return disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaPersistence.findWithDynamicQuery(dynamicQuery); |
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
public List<Disponibilita> findByFunzionarioStartDate(long funzionarioId, Date date, int startRow, int endRow) throws SystemException { |
|
|
|
@Override |
|
|
|
|
|
|
|
public List<Disponibilita> findByFunzionarioStartDate(long funzionarioId, Date date, int startRow, int endRow) |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
return dynamicQuery(dynamicQuery, startRow, endRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaLocalService.dynamicQuery(dynamicQuery, startRow, endRow); |
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
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); |
|
|
@ -342,15 +356,16 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
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); |
|
|
|
return dynamicQuery(dynamicQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS).size(); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaLocalService.dynamicQuery(dynamicQuery, -1, -1); |
|
|
|
|
|
|
|
return results.size(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
public List<Disponibilita> findByPOStartDateAndFilters(long funzionarioId, Date date, int startRow, int endRow, String provinciaFilter, String funzionarioIdFilter) throws SystemException { |
|
|
|
@Override |
|
|
|
|
|
|
|
public List<Disponibilita> findByPOStartDateAndFilters(long funzionarioId, Date date, int startRow, int endRow, |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
String provinciaFilter, String funzionarioIdFilter) throws SystemException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User user = userLocalService.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"); |
|
|
@ -381,27 +396,31 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} |
|
|
|
} |
|
|
|
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(StringPool.BLANK)) { |
|
|
|
|
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
if(!provinciaFilter.equals("-1") && !provinciaFilter.equals("")){ |
|
|
|
} else { |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("presidio", Long.valueOf(provinciaFilter))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("presidio", Long.valueOf(provinciaFilter))); |
|
|
|
} |
|
|
|
|
|
|
|
if (funzionarioIdFilter.equals("-1") || funzionarioIdFilter.equals(StringPool.BLANK)) { |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!funzionarioIdFilter.equals("-1") && !funzionarioIdFilter.equals("")){ |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", Long.valueOf(funzionarioIdFilter))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", Long.valueOf(funzionarioIdFilter))); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
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); |
|
|
|
return dynamicQuery(dynamicQuery, startRow, endRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaLocalService.dynamicQuery(dynamicQuery, startRow, endRow); |
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public int countByPOStartDateAndFilters(long funzionarioId, Date date, String provinciaFilter, String funzionarioIdFilter) throws SystemException { |
|
|
|
public int countByPOStartDateAndFilters(long funzionarioId, Date date, String provinciaFilter, |
|
|
|
|
|
|
|
String funzionarioIdFilter) throws SystemException { |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
|
|
|
|
|
|
|
|
User user = userLocalService.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"); |
|
|
@ -432,36 +451,39 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
} |
|
|
|
} |
|
|
|
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(StringPool.BLANK)) { |
|
|
|
|
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
if(!provinciaFilter.equals("-1") && !provinciaFilter.equals("")){ |
|
|
|
} else { |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("presidio", Long.valueOf(provinciaFilter))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("presidio", Long.valueOf(provinciaFilter))); |
|
|
|
} |
|
|
|
|
|
|
|
if (funzionarioIdFilter.equals("-1") || funzionarioIdFilter.equals(StringPool.BLANK)) { |
|
|
|
|
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.ne("funzionarioId", funzionarioId)); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
dynamicQuery.add(PropertyFactoryUtil.forName("presidio").in(orgIds.toArray())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!funzionarioIdFilter.equals("-1") && !funzionarioIdFilter.equals("")){ |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", Long.valueOf(funzionarioIdFilter))); |
|
|
|
dynamicQuery.add(RestrictionsFactoryUtil.eq("funzionarioId", Long.valueOf(funzionarioIdFilter))); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
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); |
|
|
|
return dynamicQuery(dynamicQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS).size(); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaLocalService.dynamicQuery(dynamicQuery, -1, -1); |
|
|
|
|
|
|
|
return results.size(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
public List<Disponibilita> findByPOStartDate(long funzionarioId, Date date, int startRow, int endRow) throws SystemException { |
|
|
|
@Override |
|
|
|
|
|
|
|
public List<Disponibilita> findByPOStartDate(long funzionarioId, Date date, int startRow, int endRow) |
|
|
|
User user = UserLocalServiceUtil.fetchUser(funzionarioId); |
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User user = userLocalService.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 = |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
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()); |
|
|
@ -489,23 +511,26 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
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); |
|
|
|
return dynamicQuery(dynamicQuery, startRow, endRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaLocalService.dynamicQuery(dynamicQuery, startRow, endRow); |
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public int countByPOStartDate(long funzionarioId, Date date) throws SystemException { |
|
|
|
public int countByPOStartDate(long funzionarioId, Date date) throws SystemException { |
|
|
|
|
|
|
|
|
|
|
|
User user = userLocalService.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 = |
|
|
|
boolean isDirigenteGenerale = RoleLocalServiceUtil.hasUserRole(user.getUserId(), dirigenteGenerale.getRoleId()); |
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -531,7 +556,10 @@ public class DisponibilitaLocalServiceImpl extends DisponibilitaLocalServiceBase |
|
|
|
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); |
|
|
|
return dynamicQuery(dynamicQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS).size(); |
|
|
|
|
|
|
|
|
|
|
|
List<Disponibilita> results = disponibilitaLocalService.dynamicQuery(dynamicQuery, -1, -1); |
|
|
|
|
|
|
|
return results.size(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Date formatDateTime(String orario, Date day) throws ParseException { |
|
|
|
private Date formatDateTime(String orario, Date day) throws ParseException { |
|
|
|