|
|
|
@ -37,211 +37,173 @@ import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
|
|
|
|
* The implementation of the richiesta accesso atti local service. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link it.tref.liferay.portos.accesso.atti.service.RichiestaAccessoAttiLocalService} interface. |
|
|
|
|
* All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy |
|
|
|
|
* their definitions into the {@link it.tref.liferay.portos.accesso.atti.service.RichiestaAccessoAttiLocalService} |
|
|
|
|
* interface. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM. |
|
|
|
|
* This is a local service. Methods of this service will not have security checks based on the propagated JAAS |
|
|
|
|
* credentials because this service can only be accessed from within the same VM. |
|
|
|
|
* </p> |
|
|
|
|
* |
|
|
|
|
* @author 3F Consulting |
|
|
|
|
* @see it.tref.liferay.portos.accesso.atti.service.base.RichiestaAccessoAttiLocalServiceBaseImpl |
|
|
|
|
* @see it.tref.liferay.portos.accesso.atti.service.RichiestaAccessoAttiLocalServiceUtil |
|
|
|
|
*/ |
|
|
|
|
public class RichiestaAccessoAttiLocalServiceImpl |
|
|
|
|
extends RichiestaAccessoAttiLocalServiceBaseImpl { |
|
|
|
|
public class RichiestaAccessoAttiLocalServiceImpl extends RichiestaAccessoAttiLocalServiceBaseImpl { |
|
|
|
|
/* |
|
|
|
|
* NOTE FOR DEVELOPERS: |
|
|
|
|
* |
|
|
|
|
* Never reference this interface directly. Always use {@link it.tref.liferay.portos.accesso.atti.service.RichiestaAccessoAttiLocalServiceUtil} to access the richiesta accesso atti local service. |
|
|
|
|
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link |
|
|
|
|
* it.tref.liferay.portos.accesso.atti.service.RichiestaAccessoAttiLocalServiceUtil} to access the richiesta accesso |
|
|
|
|
* atti local service. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
public List<RichiestaAccessoAtti> findByGestita(boolean gestita, int start, int end) throws SystemException{ |
|
|
|
|
@Override |
|
|
|
|
public List<RichiestaAccessoAtti> findByGestita(boolean gestita, int start, int end) throws SystemException { |
|
|
|
|
return richiestaAccessoAttiPersistence.findByGestita(gestita, start, end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<RichiestaAccessoAtti> findCompletate(String numeroProgetto, String protocollo, String dataDal, String dataAl, int start, int end) throws SystemException, ParseException{ |
|
|
|
|
@Override |
|
|
|
|
public List<RichiestaAccessoAtti> findCompletate(String numeroProgetto, String protocollo, String dataDal, |
|
|
|
|
String dataAl, int start, int end) throws SystemException, ParseException { |
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
DynamicQuery dq = richiestaAccessoAttiLocalService.dynamicQuery(); |
|
|
|
|
dq.add(RestrictionsFactoryUtil.eq("gestita", true)); |
|
|
|
|
|
|
|
|
|
if(!numeroProgetto.equals("")){ |
|
|
|
|
if (!numeroProgetto.equals("")) { |
|
|
|
|
dq.add(RestrictionsFactoryUtil.eq("numeroProgetto", numeroProgetto)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!protocollo.equals("")){ |
|
|
|
|
|
|
|
|
|
if (!protocollo.equals("")) { |
|
|
|
|
Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); |
|
|
|
|
disjunction.add(PropertyFactoryUtil.forName("protocolloEntrata").eq(protocollo)); |
|
|
|
|
disjunction.add(PropertyFactoryUtil.forName("protocolloUscita").eq(protocollo)); |
|
|
|
|
dq.add(disjunction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!dataDal.equals("") && !dataAl.equals("")){ |
|
|
|
|
|
|
|
|
|
if (!dataDal.equals("") && !dataAl.equals("")) { |
|
|
|
|
Date dateDal = sdf.parse(dataDal); |
|
|
|
|
Calendar calDal = Calendar.getInstance(); |
|
|
|
|
calDal.setTime(dateDal); |
|
|
|
|
calDal.set(Calendar.HOUR_OF_DAY, 00); |
|
|
|
|
calDal.set(Calendar.MINUTE, 00); |
|
|
|
|
dateDal = calDal.getTime(); |
|
|
|
|
|
|
|
|
|
Date dateAl = sdf.parse(dataAl); |
|
|
|
|
Calendar calAl = Calendar.getInstance(); |
|
|
|
|
calAl.setTime(dateAl); |
|
|
|
|
calAl.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
calAl.set(Calendar.MINUTE, 59); |
|
|
|
|
dateAl = calAl.getTime(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Property createDateProperty = PropertyFactoryUtil.forName("dtAccettazione"); |
|
|
|
|
dq.add(createDateProperty.between(dateDal, dateAl)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!dataDal.equals("") && dataAl.equals("")){ |
|
|
|
|
|
|
|
|
|
if (!dataDal.equals("") && dataAl.equals("")) { |
|
|
|
|
Date dateDal = sdf.parse(dataDal); |
|
|
|
|
Calendar calDal = Calendar.getInstance(); |
|
|
|
|
calDal.setTime(dateDal); |
|
|
|
|
calDal.set(Calendar.HOUR_OF_DAY, 00); |
|
|
|
|
calDal.set(Calendar.MINUTE, 00); |
|
|
|
|
dateDal = calDal.getTime(); |
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
Property createDateProperty = PropertyFactoryUtil.forName("dtAccettazione"); |
|
|
|
|
dq.add(createDateProperty.between(dateDal, now)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(dataDal.equals("") && !dataAl.equals("")){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dataDal.equals("") && !dataAl.equals("")) { |
|
|
|
|
Date now = new Date("01/01/2018"); |
|
|
|
|
|
|
|
|
|
Date dateAl = sdf.parse(dataAl); |
|
|
|
|
Calendar calAl = Calendar.getInstance(); |
|
|
|
|
calAl.setTime(dateAl); |
|
|
|
|
calAl.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
calAl.set(Calendar.MINUTE, 59); |
|
|
|
|
dateAl = calAl.getTime(); |
|
|
|
|
|
|
|
|
|
Property createDateProperty = PropertyFactoryUtil.forName("dtAccettazione"); |
|
|
|
|
dq.add(createDateProperty.between(now, dateAl)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return richiestaAccessoAttiLocalService.dynamicQuery(dq, start, end); |
|
|
|
|
return richiestaAccessoAttiLocalService.dynamicQuery(dq, start, end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int countCompletate(String numeroProgetto, String protocollo, String dataDal, String dataAl) throws SystemException, ParseException{ |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int countCompletate(String numeroProgetto, String protocollo, String dataDal, String dataAl) |
|
|
|
|
throws SystemException, ParseException { |
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
DynamicQuery dq = richiestaAccessoAttiLocalService.dynamicQuery(); |
|
|
|
|
dq.add(RestrictionsFactoryUtil.eq("gestita", true)); |
|
|
|
|
|
|
|
|
|
if(!numeroProgetto.equals("")){ |
|
|
|
|
if (!numeroProgetto.equals("")) { |
|
|
|
|
dq.add(RestrictionsFactoryUtil.eq("numeroProgetto", numeroProgetto)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!protocollo.equals("")){ |
|
|
|
|
|
|
|
|
|
if (!protocollo.equals("")) { |
|
|
|
|
Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); |
|
|
|
|
disjunction.add(PropertyFactoryUtil.forName("protocolloEntrata").eq(protocollo)); |
|
|
|
|
disjunction.add(PropertyFactoryUtil.forName("protocolloUscita").eq(protocollo)); |
|
|
|
|
dq.add(disjunction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!dataDal.equals("") && !dataAl.equals("")){ |
|
|
|
|
|
|
|
|
|
if (!dataDal.equals("") && !dataAl.equals("")) { |
|
|
|
|
Date dateDal = sdf.parse(dataDal); |
|
|
|
|
Calendar calDal = Calendar.getInstance(); |
|
|
|
|
calDal.setTime(dateDal); |
|
|
|
|
calDal.set(Calendar.HOUR_OF_DAY, 00); |
|
|
|
|
calDal.set(Calendar.MINUTE, 00); |
|
|
|
|
dateDal = calDal.getTime(); |
|
|
|
|
|
|
|
|
|
Date dateAl = sdf.parse(dataAl); |
|
|
|
|
Calendar calAl = Calendar.getInstance(); |
|
|
|
|
calAl.setTime(dateAl); |
|
|
|
|
calAl.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
calAl.set(Calendar.MINUTE, 59); |
|
|
|
|
dateAl = calAl.getTime(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Property createDateProperty = PropertyFactoryUtil.forName("dtAccettazione"); |
|
|
|
|
dq.add(createDateProperty.between(dateDal, dateAl)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!dataDal.equals("") && dataAl.equals("")){ |
|
|
|
|
|
|
|
|
|
if (!dataDal.equals("") && dataAl.equals("")) { |
|
|
|
|
Date dateDal = sdf.parse(dataDal); |
|
|
|
|
Calendar calDal = Calendar.getInstance(); |
|
|
|
|
calDal.setTime(dateDal); |
|
|
|
|
calDal.set(Calendar.HOUR_OF_DAY, 00); |
|
|
|
|
calDal.set(Calendar.MINUTE, 00); |
|
|
|
|
dateDal = calDal.getTime(); |
|
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
Property createDateProperty = PropertyFactoryUtil.forName("dtAccettazione"); |
|
|
|
|
dq.add(createDateProperty.between(dateDal, now)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(dataDal.equals("") && !dataAl.equals("")){ |
|
|
|
|
|
|
|
|
|
if (dataDal.equals("") && !dataAl.equals("")) { |
|
|
|
|
Date now = new Date("01/01/2018"); |
|
|
|
|
|
|
|
|
|
Date dateAl = sdf.parse(dataAl); |
|
|
|
|
Calendar calAl = Calendar.getInstance(); |
|
|
|
|
calAl.setTime(dateAl); |
|
|
|
|
calAl.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
calAl.set(Calendar.MINUTE, 59); |
|
|
|
|
dateAl = calAl.getTime(); |
|
|
|
|
|
|
|
|
|
Property createDateProperty = PropertyFactoryUtil.forName("dtAccettazione"); |
|
|
|
|
dq.add(createDateProperty.between(now, dateAl)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<RichiestaAccessoAtti> lista = richiestaAccessoAttiLocalService.dynamicQuery(dq); |
|
|
|
|
|
|
|
|
|
return lista.size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public RichiestaAccessoAtti findByAccessToken(String accessToken) throws SystemException{ |
|
|
|
|
@Override |
|
|
|
|
public RichiestaAccessoAtti findByAccessToken(String accessToken) throws SystemException { |
|
|
|
|
|
|
|
|
|
DynamicQuery dq = richiestaAccessoAttiLocalService.dynamicQuery(); |
|
|
|
|
dq.add(RestrictionsFactoryUtil.eq("accessToken", accessToken)); |
|
|
|
|
|
|
|
|
|
List<RichiestaAccessoAtti> lista = richiestaAccessoAttiLocalService.dynamicQuery(dq); |
|
|
|
|
if(lista != null && !lista.isEmpty()){ |
|
|
|
|
if (lista != null && !lista.isEmpty()) { |
|
|
|
|
return lista.get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<RichiestaAccessoAtti> findRichiesteByGroup(long userId, int start, int end) throws SystemException{ |
|
|
|
|
@Override |
|
|
|
|
public List<RichiestaAccessoAtti> findRichiesteByGroup(long userId, int start, int end) throws SystemException { |
|
|
|
|
|
|
|
|
|
List<Long> listaLong = new ArrayList<Long>(); |
|
|
|
|
|
|
|
|
|
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(userId); |
|
|
|
|
if(organizationList != null && !organizationList.isEmpty()){ |
|
|
|
|
if (organizationList != null && !organizationList.isEmpty()) { |
|
|
|
|
for (Organization organization : organizationList) { |
|
|
|
|
listaLong.add(organization.getGroupId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
listaLong.add(0L); |
|
|
|
|
|
|
|
|
|
DynamicQuery dq = richiestaAccessoAttiLocalService.dynamicQuery(); |
|
|
|
|
dq.add(RestrictionsFactoryUtil.eq("gestita", false)); |
|
|
|
|
dq.add(RestrictionsFactoryUtil.in("groupId", listaLong)); |
|
|
|
|
|
|
|
|
|
return richiestaAccessoAttiLocalService.dynamicQuery(dq, start, end); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |