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