@ -3,6 +3,8 @@ package integratore;
import com.liferay.portal.kernel.dao.orm.QueryUtil ;
import com.liferay.portal.kernel.exception.PortalException ;
import com.liferay.portal.kernel.exception.SystemException ;
import com.liferay.portal.kernel.log.Log ;
import com.liferay.portal.kernel.log.LogFactoryUtil ;
import com.liferay.portal.kernel.messaging.Message ;
import com.liferay.portal.kernel.messaging.MessageListener ;
import com.liferay.portal.kernel.messaging.MessageListenerException ;
@ -16,9 +18,12 @@ import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil ;
import it.tref.liferay.portos.bo.model.Comune ;
import it.tref.liferay.portos.bo.model.DettPratica ;
import it.tref.liferay.portos.bo.model.IntPratica ;
import it.tref.liferay.portos.bo.model.Territorio ;
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil ;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil ;
import it.tref.liferay.portos.bo.service.DettPraticaServiceUtil ;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil ;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil ;
@ -32,20 +37,20 @@ import portos.nextmind.service.SportelloLocalServiceUtil;
public class IntegratoreSchedulato implements MessageListener {
private static final Log _log = LogFactoryUtil . getLog ( IntegratoreSchedulato . class ) ;
@Override
public void receive ( Message arg0 ) throws MessageListenerException {
// TODO Auto-generated method stub
try {
getPraticaInformation ( arg0 ) ;
} catch ( SystemException e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
_log . error ( e , e ) ;
} catch ( PortalException e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
_log . error ( e , e ) ; ;
} catch ( Exception e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
_log . error ( e , e ) ; ;
}
}
public enum RequestAction {
@ -55,15 +60,15 @@ public class IntegratoreSchedulato implements MessageListener {
List < Company > companies = CompanyLocalServiceUtil . getCompanies ( ) ;
for ( Company company : companies ) {
System . out . println ( "get information from db and create an obj" ) ;
_log . info ( "get information from db and create an obj" ) ;
List < ScheduledActions > listSA = ScheduledActionsLocalServiceUtil . findAzioniDaSvolgere ( "PAESAGGISTICA" , QueryUtil . ALL_POS , QueryUtil . ALL_POS ) ;
for ( ScheduledActions scheduledActions : listSA ) {
System . out . println ( "scheduledaction" + scheduledActions ) ;
_log . info ( "scheduledaction" + scheduledActions ) ;
Sportello sport = SportelloLocalServiceUtil . fetchSportello ( scheduledActions . getShopId ( ) ) ;
sport . getContext ( ) ;
if ( scheduledActions . getRequestAction ( ) = = 2 ) {
System . out . println ( "request action" + scheduledActions . getRequestAction ( ) ) ;
System . out . println ( "cadastral code" + sport . getCadastralCode ( ) ) ;
_log . info ( "request action" + scheduledActions . getRequestAction ( ) ) ;
_log . info ( "cadastral code" + sport . getCadastralCode ( ) ) ;
Comune comune = ComuneLocalServiceUtil . fetchByC_CI ( company . getCompanyId ( ) , sport . getCadastralCode ( ) ) ;
//TODO se non c'è il comune tornare errore specifico al wios
if ( comune = = null ) {
@ -84,13 +89,11 @@ public class IntegratoreSchedulato implements MessageListener {
}
Territorio territorio = terriList . get ( 0 ) ;
//TODO se non c'è il territorio tornare errore specifico al wios
System . out . println ( "Territorio" + territorio ) ;
_log . info ( "Territorio" + territorio ) ;
User user = UserLocalServiceUtil
. fetchUserByScreenName (
company . getCompanyId ( ) ,
sport . getDigitalHolderTaxCode ( ) ) ;
. fetchUserByScreenName ( company . getCompanyId ( ) , sport . getDigitalHolderTaxCode ( ) . trim ( ) . toLowerCase ( ) ) ;
if ( user = = null ) {
System . out . println ( "user null" ) ;
_log . info ( "user null" ) ;
long userIdAdmin = UserLocalServiceUtil . getRoleUsers (
RoleLocalServiceUtil . getRole ( company . getCompanyId ( ) , RoleConstants . ADMINISTRATOR ) . getRoleId ( )
) . get ( 0 ) . getUserId ( ) ;
@ -102,8 +105,8 @@ public class IntegratoreSchedulato implements MessageListener {
user = UserLocalServiceUtil . addUser ( userIdAdmin , company . getCompanyId ( ) , true , StringPool . BLANK , StringPool . BLANK ,
false , sport . getDigitalHolderTaxCode ( ) , emailAddress , 0l , StringPool . BLANK , Locale . ITALY , sport . getName ( ) ,
StringPool . BLANK , sport . getSurname ( ) , 0 , 0 , true , 0 ,
0 , 1980 , StringPool . BLANK , new long [ ] { territorio . getGroupId ( ) } , new long [ ] { } ,
StringPool . BLANK , sport . getSurname ( ) , 0 , 0 , true , 1 ,
1 , 1980 , StringPool . BLANK , new long [ ] { territorio . getGroupId ( ) } , new long [ ] { } ,
new long [ ] { } , new long [ ] { } , false , userServiceContext ) ;
}
@ -112,17 +115,21 @@ public class IntegratoreSchedulato implements MessageListener {
serviceContext . setCompanyId ( company . getCompanyId ( ) ) ;
serviceContext . setUserId ( user . getUserId ( ) ) ;
String tipoProcedura = sport . getProceedingType ( ) ;
IntPratica newIntestazione = IntPraticaLocalServiceUtil
. addIntPratica (
territorio . getTerritorioId ( ) , tipoProcedura , serviceContext
) ;
ScheduledActionsLocalServiceUtil
. updateIntPraticaId ( scheduledActions . getIntPraticaId ( ) ,
newIntestazione . getIntPraticaId ( ) ) ;
//TODO cercare se per caso la pratica con id specifico esiste già e non crearla e capire coem gestire al situazione, ma fare comunque agigiornamento sotto dela riga ScheduledActions
//se mail esiste già, non possibile creare utente con cod fisc diverso
DettPratica dettPratica = DettPraticaLocalServiceUtil . addDettPratica ( territorio . getTerritorioId ( ) , tipoProcedura ,
serviceContext ) ;
//come rileva la intpraticaid a cui appartiene la dettpratica?
ScheduledActionsLocalServiceUtil
. updateIntPraticaId ( scheduledActions . getPrimaryKey ( ) ,
dettPratica . getIntPraticaId ( ) ) ;
_log . info ( "sportel" + sport ) ;
//DettPraticaLocalServiceUtil.addDatiSuap(intpraicaId, codici vari di wios);
IntPraticaLocalServiceUtil . addDatiSuap (
newIntestazione . getIntPraticaId ( ) ,
dettPratica . getIntPraticaId ( ) ,
new long [ ] { } ) ;
// IntPratica intestazioneDaAggiornare = IntPraticaLocalServiceUtil
// .updateIntPratica(newIntestazione);
@ -130,10 +137,10 @@ public class IntegratoreSchedulato implements MessageListener {
// intestazioneDaAggiornare.setCreateDate(sport.getCreationDate());
// intestazioneDaAggiornare.set
// intestazioneDaAggiornare.setModifiedDate(sport.getLastUpdateDate());
System . out . println ( "intestazione creata" + newIntestazione ) ;
_log . info ( "dettPratica creata " + dettPratica ) ;
}
System . out . println ( scheduledActions . getRequestAction ( ) ) ;
System . out . println ( sport . getUrl ( ) ) ;
_log . info ( scheduledActions . getRequestAction ( ) ) ;
_log . info ( sport . getUrl ( ) ) ;
}
}
}