Salvatore La Manna
3 anni fa
58 ha cambiato i file con 2714 aggiunte e 3370 eliminazioni
@ -0,0 +1,196 @@
|
||||
package it.mwg.sismica.bo.indexer; |
||||
|
||||
import it.mwg.sismica.bo.shared.util.IndexField; |
||||
import it.tref.liferay.portos.bo.model.Comune; |
||||
import it.tref.liferay.portos.bo.model.ControlloPratica; |
||||
import it.tref.liferay.portos.bo.model.IntPratica; |
||||
import it.tref.liferay.portos.bo.model.ParereGeologo; |
||||
import it.tref.liferay.portos.bo.model.Soggetto; |
||||
import it.tref.liferay.portos.bo.model.Territorio; |
||||
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil; |
||||
import it.tref.liferay.portos.bo.service.ParereGeologoLocalServiceUtil; |
||||
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil; |
||||
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; |
||||
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
||||
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil; |
||||
|
||||
import java.text.Format; |
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
import com.liferay.portal.kernel.dao.orm.QueryUtil; |
||||
import com.liferay.portal.kernel.exception.SystemException; |
||||
import com.liferay.portal.kernel.search.Document; |
||||
import com.liferay.portal.kernel.search.Field; |
||||
import com.liferay.portal.kernel.util.FastDateFormatFactoryUtil; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.kernel.workflow.WorkflowException; |
||||
import com.liferay.portal.kernel.workflow.WorkflowInstance; |
||||
import com.liferay.portal.kernel.workflow.WorkflowInstanceManagerUtil; |
||||
import com.liferay.portal.kernel.workflow.WorkflowTask; |
||||
import com.liferay.portal.kernel.workflow.WorkflowTaskAssignee; |
||||
import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil; |
||||
import com.liferay.portal.model.Role; |
||||
import com.liferay.portal.model.User; |
||||
import com.liferay.portal.model.WorkflowInstanceLink; |
||||
import com.liferay.portal.service.UserLocalServiceUtil; |
||||
import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; |
||||
|
||||
public class IndexerUtil { |
||||
|
||||
public static final Format DATE_FORMAT = FastDateFormatFactoryUtil.getSimpleDateFormat("yyyyMMdd"); |
||||
|
||||
// Manifattura Web Group per Regione Siciliana Modifiche per rendere i campi di testo ricercabili per parole
|
||||
// contenute e non per corrispondenza esatta.
|
||||
public static Document fillDocument(Document document, IntPratica ip, ControlloPratica cp) throws SystemException, |
||||
WorkflowException { |
||||
|
||||
document.addKeyword(Field.USER_ID, ip.getUserId()); |
||||
User titolare = UserLocalServiceUtil.fetchUser(ip.getUserId()); |
||||
if (Validator.isNotNull(titolare)) { |
||||
document.addText(IndexField.TITOLARE, new String[] { titolare.getFullName().toLowerCase(), |
||||
titolare.getScreenName().toLowerCase() }); |
||||
} |
||||
document.addKeyword(IndexField.TIPO_PROCEDURA, ip.getTipoProcedura()); |
||||
document.addKeyword(IndexField.IN_LAVORAZIONE_SUE, ip.getInLavorazioneSue()); |
||||
switch (ip.getStatoPratica()) { |
||||
case StatoPraticaConstants.ANNULLATA: |
||||
document.addKeyword(IndexField.PRATICA_APERTA, false); |
||||
break; |
||||
default: |
||||
document.addKeyword(IndexField.PRATICA_APERTA, true); |
||||
} |
||||
document.addKeyword(IndexField.IN_COMPILAZIONE, Validator.isNull(ip.getStatoPratica())); |
||||
Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(ip.getTerritorioId()); |
||||
if (Validator.isNull(territorio)) { |
||||
document.addKeyword(Field.GROUP_ID, ip.getGroupId()); |
||||
} else { |
||||
document.addKeyword(Field.GROUP_ID, territorio.getGroupId()); |
||||
Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); |
||||
if (Validator.isNotNull(comune)) { |
||||
document.addKeyword(IndexField.COMUNE_ID, comune.getComuneId()); |
||||
document.addKeyword(IndexField.CODICE_PROVINCIA, comune.getCodiceProvincia()); |
||||
} |
||||
} |
||||
if (Validator.isNotNull(ip.getStatoPratica())) { |
||||
document.addKeyword(IndexField.STATO_PRATICA, ip.getStatoPratica()); |
||||
} |
||||
if (Validator.isNotNull(ip.getDtPratica())) { |
||||
document.addKeywordSortable(IndexField.DATA_RICHIESTA, DATE_FORMAT.format(ip.getDtPratica())); |
||||
} |
||||
if (Validator.isNotNull(ip.getNumeroProgetto())) { |
||||
document.addKeywordSortable(IndexField.NUMERO_PROGETTO, ip.getNumeroProgetto()); |
||||
} |
||||
document.addKeyword(IndexField.UNITA_OPERATIVA, ip.getUnitaOperativa()); |
||||
List<ParereGeologo> pareri = ParereGeologoLocalServiceUtil.findByIntPraticaId(ip.getIntPraticaId(), |
||||
QueryUtil.ALL_POS, QueryUtil.ALL_POS); |
||||
List<Long> idGeologi = new ArrayList<>(); |
||||
boolean pareriForniti = false; |
||||
for (ParereGeologo geo : pareri) { |
||||
idGeologi.add(geo.getGeologoUserId()); |
||||
if (((Validator.isNull(geo.getDtAssegnazione()) && Validator.isNotNull(geo.getDtCompilazione())) || (Validator |
||||
.isNotNull(geo.getDtAssegnazione()) && Validator.isNotNull(geo.getDtApprovazione()))) |
||||
&& Validator.isNull(geo.getDtAnnullamento())) { |
||||
pareriForniti = true; |
||||
} |
||||
} |
||||
document.addKeyword(IndexField.PARERI_FORNITI, pareriForniti); |
||||
if (idGeologi.size() > 0) { |
||||
document.addKeyword(IndexField.GEOLOGO_ID, idGeologi.toArray(new Long[0])); |
||||
} |
||||
User istruttore = UserLocalServiceUtil.fetchUser(ip.getStatusByUserId()); |
||||
if (Validator.isNotNull(istruttore)) { |
||||
document.addKeyword(IndexField.ISTRUTTORE, new String[] { istruttore.getFullName().toLowerCase(), |
||||
istruttore.getScreenName().toLowerCase() }); |
||||
} |
||||
document.addNumber(IndexField.ISTRUTTORE_ID, ip.getStatusByUserId()); |
||||
List<Soggetto> listaCommittenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto( |
||||
ip.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); |
||||
if (Validator.isNotNull(listaCommittenti) && listaCommittenti.size() > 0) { |
||||
Set<String> committenti = new HashSet<>(); |
||||
for (Soggetto committente : listaCommittenti) { |
||||
if (Validator.isNotNull(committente.getCognome())) { |
||||
committenti.add(committente.getNome().toLowerCase() + ' ' + committente.getCognome().toLowerCase()); |
||||
} |
||||
if (Validator.isNotNull(committente.getDenominazione())) { |
||||
committenti.add(committente.getDenominazione().toLowerCase()); |
||||
} |
||||
if (Validator.isNotNull(committente.getCodiceFiscale())) { |
||||
committenti.add(committente.getCodiceFiscale().toLowerCase()); |
||||
} |
||||
if (Validator.isNotNull(committente.getCodiceFiscaleDelegato())) { |
||||
committenti.add(committente.getCodiceFiscaleDelegato().toLowerCase()); |
||||
} |
||||
} |
||||
document.addText(IndexField.COMMITTENTE, committenti.toArray(new String[0])); |
||||
} |
||||
// Soggetti connessi alla intPratica
|
||||
List<Soggetto> listaSoggetti = SoggettoLocalServiceUtil.getSoggettiByIntPraticaId_DtRimozioneNull(ip |
||||
.getIntPraticaId()); |
||||
if (!listaSoggetti.isEmpty()) { |
||||
Set<String> soggetti = new HashSet<>(); |
||||
for (Soggetto soggetto : listaSoggetti) { |
||||
if (Validator.isNotNull(soggetto.getCognome())) { |
||||
soggetti.add(soggetto.getNome().toLowerCase() + ' ' + soggetto.getCognome().toLowerCase()); |
||||
} |
||||
if (Validator.isNotNull(soggetto.getDenominazione())) { |
||||
soggetti.add(soggetto.getDenominazione().toLowerCase()); |
||||
} |
||||
if (Validator.isNotNull(soggetto.getCodiceFiscale())) { |
||||
soggetti.add(soggetto.getCodiceFiscale().toLowerCase()); |
||||
} |
||||
if (Validator.isNotNull(soggetto.getCodiceFiscaleDelegato())) { |
||||
soggetti.add(soggetto.getCodiceFiscaleDelegato().toLowerCase()); |
||||
} |
||||
} |
||||
document.addText(IndexField.SOGGETTO, soggetti.toArray(new String[0])); |
||||
} |
||||
// Indicizzazione campi da Kaleo
|
||||
if (Validator.isNotNull(cp)) { |
||||
document.addNumber(IndexField.STATUS, cp.getStatus()); |
||||
if (Validator.isNotNull(cp.getStatusDate())) { |
||||
document.addKeyword(IndexField.DATA_ESITO, DATE_FORMAT.format(cp.getStatusDate())); |
||||
} |
||||
WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil.fetchWorkflowInstanceLink( |
||||
cp.getCompanyId(), cp.getGroupId(), ControlloPratica.class.getName(), cp.getPrimaryKey()); |
||||
if (Validator.isNotNull(workflowInstanceLink)) { |
||||
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(cp.getCompanyId(), |
||||
workflowInstanceLink.getWorkflowInstanceId()); |
||||
if (Validator.isNotNull(workflowInstance)) { |
||||
document.addKeyword(IndexField.WORKFLOW_STATE, workflowInstance.getState()); |
||||
List<WorkflowTask> tasks = WorkflowTaskManagerUtil.getWorkflowTasksByWorkflowInstance( |
||||
cp.getCompanyId(), null, workflowInstance.getWorkflowInstanceId(), false, |
||||
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); |
||||
if (Validator.isNotNull(tasks) && !tasks.isEmpty()) { |
||||
WorkflowTask task = tasks.get(0); |
||||
if (task.getAssigneeUserId() != 0L && task.getAssigneeUserId() != -1) { |
||||
document.addKeyword(IndexField.TASK_ASSIGNEE_USER_ID, task.getAssigneeUserId()); |
||||
} |
||||
if (Validator.isNotNull(task.getWorkflowTaskAssignees()) |
||||
&& !task.getWorkflowTaskAssignees().isEmpty()) { |
||||
List<String> roleIdsAssignee = new ArrayList<String>(); |
||||
for (WorkflowTaskAssignee taskAssignee : task.getWorkflowTaskAssignees()) { |
||||
if (taskAssignee.getAssigneeClassName().equals(Role.class.getName())) { |
||||
roleIdsAssignee |
||||
.add("R" + taskAssignee.getAssigneeClassPK() + "G" + cp.getGroupId()); |
||||
} |
||||
} |
||||
document.addKeyword(IndexField.TASK_ASSIGNEE_ROLE_IDS, |
||||
roleIdsAssignee.toArray(new String[0])); |
||||
} |
||||
document.addKeyword(IndexField.TASK, task.getName()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
// Prendo l'ultimo DettPratica legato a IntPratica
|
||||
// DettPratica dp = DettPraticaLocalServiceUtil.getLastCompletedByIntPraticaAndProtocolloNotEmpty(ip
|
||||
// .getIntPraticaId());
|
||||
// if (Validator.isNull(dp)) {
|
||||
// dp = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(ip.getIntPraticaId());
|
||||
// }
|
||||
return document; |
||||
} |
||||
} |
@ -0,0 +1,272 @@
|
||||
package it.mwg.sismica.bo.search; |
||||
|
||||
import it.mwg.sismica.bo.shared.util.IndexField; |
||||
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
||||
|
||||
import java.text.DateFormat; |
||||
import java.text.Format; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Arrays; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
import com.liferay.portal.kernel.log.Log; |
||||
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||
import com.liferay.portal.kernel.search.BooleanClauseOccur; |
||||
import com.liferay.portal.kernel.search.BooleanQuery; |
||||
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.ParseException; |
||||
import com.liferay.portal.kernel.search.SearchContext; |
||||
import com.liferay.portal.kernel.search.Sort; |
||||
import com.liferay.portal.kernel.search.TermQuery; |
||||
import com.liferay.portal.kernel.search.TermQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.TermRangeQuery; |
||||
import com.liferay.portal.kernel.search.TermRangeQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.util.FastDateFormatFactoryUtil; |
||||
import com.liferay.portal.kernel.util.ParamUtil; |
||||
import com.liferay.portal.kernel.util.StringPool; |
||||
import com.liferay.portal.kernel.util.StringUtil; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.model.User; |
||||
|
||||
public class BaseSearch { |
||||
|
||||
private static final Format DATE_FORMAT_LUCENE = FastDateFormatFactoryUtil.getSimpleDateFormat("yyyyMMdd"); |
||||
private static final DateFormat DATE_FORMAT_STRING = new SimpleDateFormat("dd/MM/yyyy"); |
||||
private static final Log _log = LogFactoryUtil.getLog(BaseSearch.class); |
||||
|
||||
public static List<String> getFields() { |
||||
|
||||
return Arrays.asList(IndexField.NUMERO_PROGETTO, IndexField.TIPO_PROCEDURA, IndexField.CODICE_PROVINCIA, |
||||
IndexField.COMUNE_ID, IndexField.TITOLARE, IndexField.ISTRUTTORE, IndexField.ISTRUTTORE_ID, |
||||
IndexField.COMMITTENTE, IndexField.SOGGETTO, IndexField.UNITA_OPERATIVA, IndexField.GEOLOGO_ID, |
||||
IndexField.PARERI_FORNITI, IndexField.TASK, IndexField.DATA_RICHIESTA_DA, IndexField.DATA_RICHIESTA_A, |
||||
IndexField.DATA_ESITO_DA, IndexField.DATA_ESITO_A, IndexField.STATO_PRATICA, IndexField.WORKFLOW_STATE); |
||||
} |
||||
|
||||
protected static Sort[] getOrderedQuery(HttpServletRequest request) { |
||||
|
||||
Sort[] sortes = new Sort[1]; |
||||
String orderField = ParamUtil.getString(request, "orderByCol", "numeroProgetto"); |
||||
String orderType = ParamUtil.getString(request, "orderByType", "dec"); |
||||
sortes[0] = new Sort(); |
||||
if (Validator.isNotNull(orderField)) { |
||||
sortes[0].setFieldName(orderField + "_sortable"); |
||||
} |
||||
switch (orderField) { |
||||
case IndexField.NUMERO_PROGETTO: |
||||
sortes[0].setType(Sort.LONG_TYPE); |
||||
break; |
||||
default: |
||||
sortes[0].setType(Sort.STRING_TYPE); |
||||
} |
||||
sortes[0].setReverse(!"asc".equals(orderType)); |
||||
return sortes; |
||||
} |
||||
|
||||
protected static void fullQuery(HttpServletRequest request, User user, BooleanQuery query, |
||||
SearchContext searchContext) throws ParseException, java.text.ParseException { |
||||
|
||||
queryComune(request, query, searchContext); |
||||
queryDate(request, query, searchContext); |
||||
queryGeologo(request, query, searchContext); |
||||
queryIstruttoreId(request, query, searchContext); |
||||
queryKeywords(query, request, IndexField.COMMITTENTE); |
||||
queryKeywords(query, request, IndexField.ISTRUTTORE); |
||||
queryKeywords(query, request, IndexField.SOGGETTO); |
||||
queryKeywords(query, request, IndexField.TITOLARE); |
||||
queryNumeroProgetto(request, query, searchContext); |
||||
queryPareriForniti(request, query, searchContext); |
||||
queryPraticaAperta(request, query, searchContext); |
||||
queryProvincia(request, query, searchContext); |
||||
queryStatoPratica(request, query, searchContext); |
||||
queryTipoProcedura(request, query, searchContext); |
||||
queryUnitaOperativa(request, query, searchContext); |
||||
queryWorkflowState(request, query, searchContext); |
||||
} |
||||
|
||||
private static void queryComune(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String comune = ParamUtil.getString(request, IndexField.COMUNE_ID); |
||||
if (Validator.isNotNull(comune) && !comune.equals("0")) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.COMUNE_ID, comune); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* Manifattura Web Group per Regione Siciliana Rimosse numerose righe di codice che trattavano separatamente i 3 |
||||
* casi: entrambe le date inserite, inserita solo la data iniziale, inserita solo la data finale. Le funzioni |
||||
* seguenti sono state create per ridurre la duplicazione di codice. |
||||
*/ |
||||
private static void queryDate(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException, java.text.ParseException { |
||||
|
||||
String daReq = ParamUtil.getString(request, IndexField.DATA_RICHIESTA_DA); |
||||
String aReq = ParamUtil.getString(request, IndexField.DATA_RICHIESTA_A); |
||||
if (Validator.isNotNull(daReq) || Validator.isNotNull(aReq)) { |
||||
String da = Validator.isNull(daReq) ? "00000000" : DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING |
||||
.parse(daReq)); |
||||
String a = DATE_FORMAT_LUCENE.format(Validator.isNull(aReq) ? new Date() : DATE_FORMAT_STRING.parse(aReq)); |
||||
TermRangeQuery termRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, IndexField.DATA_RICHIESTA, |
||||
da, a, true, true); |
||||
query.add(termRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
daReq = ParamUtil.getString(request, IndexField.DATA_ESITO_DA); |
||||
aReq = ParamUtil.getString(request, IndexField.DATA_ESITO_A); |
||||
if (Validator.isNotNull(daReq) || Validator.isNotNull(aReq)) { |
||||
String da = Validator.isNull(daReq) ? "00000000" : DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING |
||||
.parse(daReq)); |
||||
String a = DATE_FORMAT_LUCENE.format(Validator.isNull(aReq) ? new Date() : DATE_FORMAT_STRING.parse(aReq)); |
||||
TermRangeQuery termRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, IndexField.DATA_ESITO, |
||||
da, a, true, true); |
||||
query.add(termRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryGeologo(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
long geologo = ParamUtil.getLong(request, IndexField.GEOLOGO_ID); |
||||
if (geologo != 0) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.GEOLOGO_ID, geologo); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryIstruttoreId(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
long istruttoreId = ParamUtil.getLong(request, IndexField.ISTRUTTORE_ID); |
||||
if (istruttoreId != 0) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.ISTRUTTORE_ID, istruttoreId); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* Manifattura Web Group per Regione Siciliana Modifiche per rendere i campi di testo ricercabili per parole |
||||
* contenute e non per corrispondenza esatta. |
||||
*/ |
||||
private static void queryKeywords(BooleanQuery query, HttpServletRequest request, String field) { |
||||
|
||||
String terms = ParamUtil.getString(request, field); |
||||
if (Validator.isNotNull(terms)) { |
||||
for (String term : StringUtil.split(terms, ' ')) { |
||||
if (Validator.isNotNull(term)) { |
||||
query.addRequiredTerm(field, term); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void |
||||
queryNumeroProgetto(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String numeroProgetto = ParamUtil.getString(request, IndexField.NUMERO_PROGETTO); |
||||
if (Validator.isNotNull(numeroProgetto)) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.NUMERO_PROGETTO, numeroProgetto); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryPareriForniti(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String pareriForniti = ParamUtil.getString(request, IndexField.PARERI_FORNITI); |
||||
if (Validator.isNotNull(pareriForniti)) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.PARERI_FORNITI, pareriForniti); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryPraticaAperta(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String praticaAperta = ParamUtil.getString(request, IndexField.PRATICA_APERTA); |
||||
if (Validator.isNotNull(praticaAperta)) { |
||||
TermQuery term = null; |
||||
if (praticaAperta.equals("aperta")) { |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.PRATICA_APERTA, StringPool.TRUE); |
||||
} else if (praticaAperta.equals("chiusa")) { |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.PRATICA_APERTA, StringPool.FALSE); |
||||
} |
||||
if (Validator.isNotNull(term)) { |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void queryProvincia(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String provincia = ParamUtil.getString(request, IndexField.CODICE_PROVINCIA); |
||||
if (Validator.isNotNull(provincia) && !provincia.equals("0")) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.CODICE_PROVINCIA, provincia); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryStatoPratica(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String statoPratica = ParamUtil.getString(request, IndexField.STATO_PRATICA); |
||||
if (Validator.isNotNull(statoPratica)) { |
||||
TermQuery term = null; |
||||
if (statoPratica.equals("IC")) { |
||||
term = TermQueryFactoryUtil.create(searchContext, "dtPratica", "0"); |
||||
} else if (statoPratica.equals(StatoPraticaConstants.VARIATA)) { |
||||
term = TermQueryFactoryUtil.create(searchContext, "variata", StringPool.TRUE); |
||||
} else if (!statoPratica.equals("-1")) { |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.STATO_PRATICA, statoPratica); |
||||
} |
||||
if (Validator.isNotNull(term)) { |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void queryTipoProcedura(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String tipoProcedura = ParamUtil.getString(request, IndexField.TIPO_PROCEDURA); |
||||
if (Validator.isNotNull(tipoProcedura)) { |
||||
String[] procSplit = StringUtils.split(tipoProcedura, "|"); |
||||
if (procSplit.length > 0) { |
||||
for (String proc : procSplit) { |
||||
BooleanQuery bq = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.TIPO_PROCEDURA, proc); |
||||
bq.add(term, BooleanClauseOccur.SHOULD); |
||||
query.add(bq, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void |
||||
queryUnitaOperativa(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
int unitaOperativa = ParamUtil.getInteger(request, IndexField.UNITA_OPERATIVA); |
||||
if (unitaOperativa != 0) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.UNITA_OPERATIVA, unitaOperativa); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryWorkflowState(HttpServletRequest request, BooleanQuery query, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String state = ParamUtil.getString(request, IndexField.WORKFLOW_STATE); |
||||
if (Validator.isNotNull(state)) { |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.WORKFLOW_STATE, state); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
} |
@ -1,707 +0,0 @@
|
||||
package it.mwg.sismica.bo.search; |
||||
|
||||
import it.mwg.sismica.bo.shared.util.PortosIndexField; |
||||
import it.mwg.sismica.bo.shared.util.UserUtil; |
||||
import it.mwg.sismica.bo.shared.util.WorkflowConstants; |
||||
import it.tref.liferay.portos.bo.model.ControlloPratica; |
||||
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
||||
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
||||
|
||||
import java.text.DateFormat; |
||||
import java.text.Format; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Properties; |
||||
import java.util.Set; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
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.search.BooleanClauseOccur; |
||||
import com.liferay.portal.kernel.search.BooleanQuery; |
||||
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.Document; |
||||
import com.liferay.portal.kernel.search.Hits; |
||||
import com.liferay.portal.kernel.search.ParseException; |
||||
import com.liferay.portal.kernel.search.SearchContext; |
||||
import com.liferay.portal.kernel.search.SearchContextFactory; |
||||
import com.liferay.portal.kernel.search.SearchEngineUtil; |
||||
import com.liferay.portal.kernel.search.SearchException; |
||||
import com.liferay.portal.kernel.search.Sort; |
||||
import com.liferay.portal.kernel.search.TermQuery; |
||||
import com.liferay.portal.kernel.search.TermQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.TermRangeQuery; |
||||
import com.liferay.portal.kernel.search.TermRangeQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.util.FastDateFormatFactoryUtil; |
||||
import com.liferay.portal.kernel.util.GetterUtil; |
||||
import com.liferay.portal.kernel.util.ParamUtil; |
||||
import com.liferay.portal.kernel.util.PropsKeys; |
||||
import com.liferay.portal.kernel.util.PropsUtil; |
||||
import com.liferay.portal.kernel.util.StringPool; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.model.Organization; |
||||
import com.liferay.portal.model.Role; |
||||
import com.liferay.portal.model.User; |
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
||||
import com.liferay.portal.service.RoleLocalServiceUtil; |
||||
|
||||
public class ControlloPraticaAdvancedSearch { |
||||
|
||||
private static final Log _log = LogFactoryUtil.getLog(ControlloPraticaAdvancedSearch.class); |
||||
|
||||
public static final String[] OVERRIDE_KEYWORDS = { "controlloPraticaId", "numeroProgetto", "tipoPratica", |
||||
"statoPratica", "dataRichiesta", "committente", "soggettiInteressati", "status", "entryClassName", |
||||
"userId", "descIntervento", "tipoProcedura" }; |
||||
|
||||
public static final Format DATE_FORMAT_LUCENE = FastDateFormatFactoryUtil.getSimpleDateFormat("yyyyMMdd"); |
||||
|
||||
public static final DateFormat DATE_FORMAT_STRING = new SimpleDateFormat("dd/MM/yyyy"); |
||||
|
||||
public static Hits searchMieiTask(HttpServletRequest request, User user, int start, int end) { |
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
|
||||
if (ParamUtil.getBoolean(request, "searchForExport", false)) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca : entryClassName=ControlloPratica & userId=taskAssigneeUserId
|
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery userIdTermQuery = TermQueryFactoryUtil.create(searchContext, "taskAssigneeUserId", |
||||
user.getUserId()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_PENDING); |
||||
|
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(userIdTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
long ufficio = ParamUtil.getLong(request, "ufficio"); |
||||
if (ufficio != 0 && ufficio != -1) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", ufficio); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList) && !organizationList.isEmpty()) { |
||||
for (Organization org : organizationList) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
||||
org.getGroupId()); |
||||
groupIdsQuery.add(singleGroupIdQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
booleanQuery.add(groupIdsQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
// Condizioni aggiuntive
|
||||
retrieveQuery(request, user, booleanQuery, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchTaskMieiRuoli(HttpServletRequest request, User user, int start, int end) { |
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
if (ParamUtil.getBoolean(request, "searchForExport", false)) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=ControlloPratica & roleIds tra i taskAssigneeIds
|
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQueryRoleIds = BooleanQueryFactoryUtil.create(searchContext); |
||||
List<Organization> organizationUserList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
List<Role> organizationRoleList = null; |
||||
for (Organization org : organizationUserList) { |
||||
organizationRoleList = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), org.getGroupId()); |
||||
for (Role role : organizationRoleList) { |
||||
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, "taskAssigneeRoleIds", ("R" |
||||
+ role.getRoleId() + "G" + org.getGroupId())); |
||||
booleanQueryRoleIds.add(roleIdTerm, BooleanClauseOccur.SHOULD); |
||||
} |
||||
} |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
|
||||
if (organizationUserList != null && !organizationUserList.isEmpty() && organizationRoleList != null |
||||
&& !organizationRoleList.isEmpty()) { |
||||
booleanQuery.add(booleanQueryRoleIds, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, "taskAssigneeRoleIds", "R0G0"); |
||||
booleanQueryRoleIds.add(roleIdTerm, BooleanClauseOccur.SHOULD); |
||||
booleanQuery.add(booleanQueryRoleIds, BooleanClauseOccur.MUST); |
||||
} |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
long ufficio = ParamUtil.getLong(request, "ufficio"); |
||||
if (ufficio != 0 && ufficio != -1) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", ufficio); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList) && !organizationList.isEmpty()) { |
||||
for (Organization org : organizationList) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
||||
org.getGroupId()); |
||||
groupIdsQuery.add(singleGroupIdQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
booleanQuery.add(groupIdsQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
Set<Integer> uos = UserUtil.getUnitaOperative(user); |
||||
if ((uos.size() > 0) && !uos.contains(0)) { |
||||
BooleanQuery uoQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
for (int uo : uos) { |
||||
TermQuery tq = TermQueryFactoryUtil.create(searchContext, PortosIndexField.UNITA_OPERATIVA, uo); |
||||
uoQuery.add(tq, BooleanClauseOccur.SHOULD); |
||||
} |
||||
booleanQuery.add(uoQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
// Condizioni aggiuntive
|
||||
retrieveQuery(request, user, booleanQuery, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchAltriTask(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
||||
if (searchForExport) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=ControlloPratica & roleIds non e tra i
|
||||
// taskAssigneeIds userId non e tra taskAssigneeId
|
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery userIdTermQuery = TermQueryFactoryUtil.create(searchContext, "taskAssigneeUserId", |
||||
user.getUserId()); |
||||
BooleanQuery booleanQueryRoleIds = BooleanQueryFactoryUtil.create(searchContext); |
||||
List<Organization> organizationUserList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
List<Role> organizationRoleList = null; |
||||
for (Organization org : organizationUserList) { |
||||
organizationRoleList = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), org.getGroupId()); |
||||
for (Role role : organizationRoleList) { |
||||
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, "taskAssigneeRoleIds", |
||||
(role.getRoleId() + StringPool.DASH + org.getGroupId())); |
||||
booleanQueryRoleIds.add(roleIdTerm, BooleanClauseOccur.SHOULD); |
||||
} |
||||
} |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
if (organizationUserList != null && !organizationUserList.isEmpty() && organizationRoleList != null |
||||
&& !organizationRoleList.isEmpty()) { |
||||
booleanQuery.add(booleanQueryRoleIds, BooleanClauseOccur.MUST_NOT); |
||||
} |
||||
booleanQuery.add(userIdTermQuery, BooleanClauseOccur.MUST_NOT); |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
long ufficio = ParamUtil.getLong(request, "ufficio"); |
||||
if (ufficio != 0 && ufficio != -1) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", ufficio); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList) && !organizationList.isEmpty()) { |
||||
for (Organization org : organizationList) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
||||
org.getGroupId()); |
||||
groupIdsQuery.add(singleGroupIdQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
booleanQuery.add(groupIdsQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
// Condizioni aggiuntive
|
||||
retrieveQuery(request, user, booleanQuery, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static List<ControlloPratica> searchTaskPerEsportazioneDirigente(HttpServletRequest request, User user, |
||||
int start, int end) { |
||||
|
||||
List<ControlloPratica> lista = new ArrayList<ControlloPratica>(); |
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
String dataDa = ParamUtil.getString(request, "dataRichiestaInizio"); |
||||
String dataAl = ParamUtil.getString(request, "dataRichiestaFine"); |
||||
if (Validator.isNotNull(dataDa) || Validator.isNotNull(dataAl)) { |
||||
if (Validator.isNull(dataDa)) { |
||||
dataDa = "00000000"; |
||||
} else { |
||||
dataDa = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataDa)); |
||||
} |
||||
if (Validator.isNull(dataAl)) { |
||||
dataAl = DATE_FORMAT_LUCENE.format(new Date()); |
||||
} else { |
||||
dataAl = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataAl)); |
||||
} |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", dataDa, dataAl, true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hints found : " + hits.getLength()); |
||||
} |
||||
for (Document doc : hits.toList()) { |
||||
String controlloPraticaId = doc.get("controlloPraticaId"); |
||||
if (Validator.isNotNull(controlloPraticaId)) { |
||||
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil |
||||
.fetchControlloPratica(GetterUtil.getLong(controlloPraticaId)); |
||||
if (Validator.isNotNull(controlloPratica)) { |
||||
lista.add(controlloPratica); |
||||
} |
||||
} |
||||
} |
||||
} catch (ParseException | SearchException | SystemException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return lista; |
||||
} |
||||
|
||||
public static List<ControlloPratica> searchTaskPerEsportazionePO(HttpServletRequest request, User user, int start, |
||||
int end) { |
||||
|
||||
List<ControlloPratica> lista = new ArrayList<ControlloPratica>(); |
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery userIdTermQuery = TermQueryFactoryUtil.create(searchContext, "taskAssigneeUserId", |
||||
user.getUserId()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(userIdTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
String dataDa = ParamUtil.getString(request, "dataRichiestaInizio"); |
||||
String dataAl = ParamUtil.getString(request, "dataRichiestaFine"); |
||||
if (Validator.isNotNull(dataDa) || Validator.isNotNull(dataAl)) { |
||||
if (Validator.isNull(dataDa)) { |
||||
dataDa = "00000000"; |
||||
} else { |
||||
dataDa = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataDa)); |
||||
} |
||||
if (Validator.isNull(dataAl)) { |
||||
dataAl = DATE_FORMAT_LUCENE.format(new Date()); |
||||
} else { |
||||
dataAl = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataAl)); |
||||
} |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", dataDa, dataAl, true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
for (Document doc : hits.toList()) { |
||||
String controlloPraticaId = doc.get("controlloPraticaId"); |
||||
if (Validator.isNotNull(controlloPraticaId)) { |
||||
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil |
||||
.fetchControlloPratica(GetterUtil.getLong(controlloPraticaId)); |
||||
if (Validator.isNotNull(controlloPratica)) { |
||||
lista.add(controlloPratica); |
||||
} |
||||
} |
||||
} |
||||
} catch (ParseException | SearchException | SystemException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return lista; |
||||
} |
||||
|
||||
public static Hits searchTaskConclusi(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
if (ParamUtil.getBoolean(request, "searchForExport", false)) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=ControlloPratica & roleIds non e tra i
|
||||
// taskAssigneeIds userId non e tra taskAssigneeId
|
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
BooleanQuery booleanQueryRoleIds = BooleanQueryFactoryUtil.create(searchContext); |
||||
List<Organization> organizationUserList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
List<Role> organizationRoleList = null; |
||||
for (Organization org : organizationUserList) { |
||||
organizationRoleList = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), org.getGroupId()); |
||||
for (Role role : organizationRoleList) { |
||||
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, "taskAssigneeRoleIds", |
||||
(role.getRoleId() + StringPool.DASH + org.getGroupId())); |
||||
booleanQueryRoleIds.add(roleIdTerm, BooleanClauseOccur.SHOULD); |
||||
} |
||||
} |
||||
BooleanQuery booleanQueryStatus = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery statusDenied = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_DENIED); |
||||
booleanQueryStatus.add(statusDenied, BooleanClauseOccur.SHOULD); |
||||
TermQuery statusApproved = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_APPROVED); |
||||
booleanQueryStatus.add(statusApproved, BooleanClauseOccur.SHOULD); |
||||
TermQuery statusIncomplete = TermQueryFactoryUtil.create(searchContext, "status", |
||||
WorkflowConstants.STATUS_INCOMPLETE); |
||||
booleanQueryStatus.add(statusIncomplete, BooleanClauseOccur.SHOULD); |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
if (organizationUserList != null && !organizationUserList.isEmpty() && organizationRoleList != null |
||||
&& !organizationRoleList.isEmpty()) { |
||||
booleanQuery.add(booleanQueryRoleIds, BooleanClauseOccur.MUST_NOT); |
||||
} |
||||
booleanQuery.add(booleanQueryStatus, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); |
||||
BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList) && !organizationList.isEmpty()) { |
||||
for (Organization org : organizationList) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
||||
org.getGroupId()); |
||||
groupIdsQuery.add(singleGroupIdQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
booleanQuery.add(groupIdsQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
// Condizioni aggiuntive
|
||||
retrieveQuery(request, user, booleanQuery, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
private static void retrieveQuery(HttpServletRequest request, User user, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) { |
||||
|
||||
// Search Param
|
||||
String numeroProgettoSearch = ParamUtil.getString(request, "numeroProgetto"); |
||||
String protocolloSearch = ParamUtil.getString(request, "protocollo"); |
||||
String tipoPraticaSearch = ParamUtil.getString(request, "tipoPratica"); |
||||
String statoPraticaSearch = ParamUtil.getString(request, "statoPratica"); |
||||
String committenteSearch = ParamUtil.getString(request, "committente"); |
||||
String soggettiInterconnessiSearch = ParamUtil.getString(request, "soggettiInterconnessi"); |
||||
String istruttoreId = ParamUtil.getString(request, "istruttore"); |
||||
String unitaOperativa = ParamUtil.getString(request, "unitaOperativa"); |
||||
String dataDa = ParamUtil.getString(request, "dataRichiestaInizio"); |
||||
String dataAl = ParamUtil.getString(request, "dataRichiestaFine"); |
||||
String comune = ParamUtil.getString(request, "comune"); |
||||
String tipoAttivita = ParamUtil.getString(request, "tipoAttivita"); |
||||
Long geologi = ParamUtil.getLong(request, "geologi"); |
||||
Long parereGeologo = ParamUtil.getLong(request, "parereGeologo"); |
||||
// ADT - BUG-11 Aggiunta filtro ricerca
|
||||
String controlloObbligatorioSearch = ParamUtil.getString(request, "controlloObbligatorio"); |
||||
try { |
||||
if (Validator.isNotNull(tipoAttivita) && !tipoAttivita.equals("-1")) { |
||||
TermQuery tipoAttivitaTermQuery = TermQueryFactoryUtil.create(searchContext, "workflowState", |
||||
tipoAttivita); |
||||
booleanQuery.add(tipoAttivitaTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (Validator.isNotNull(numeroProgettoSearch)) { |
||||
TermQuery numeroProgettoTermQuery = TermQueryFactoryUtil.create(searchContext, "numeroProgetto", |
||||
numeroProgettoSearch); |
||||
booleanQuery.add(numeroProgettoTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (Validator.isNotNull(protocolloSearch)) { |
||||
TermQuery protocolloSearchTermQuery = TermQueryFactoryUtil.create(searchContext, "protocollo", |
||||
protocolloSearch); |
||||
booleanQuery.add(protocolloSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (Validator.isNotNull(tipoPraticaSearch) && !tipoPraticaSearch.equals("-1")) { |
||||
TermQuery tipoPraticaSearchTermQuery = TermQueryFactoryUtil.create(searchContext, "tipoPratica", |
||||
tipoPraticaSearch); |
||||
booleanQuery.add(tipoPraticaSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
// Gestione StatoPratica
|
||||
if (Validator.isNotNull(statoPraticaSearch) && !statoPraticaSearch.equals("-1")) { |
||||
if (statoPraticaSearch.equals(StatoPraticaConstants.COLLAUDO_PARZIALE)) { |
||||
TermQuery collaudoParzialeSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"collaudoParziale", StringPool.TRUE); |
||||
booleanQuery.add(collaudoParzialeSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} else if (statoPraticaSearch.equals(StatoPraticaConstants.COLLAUDO)) { |
||||
TermQuery collaudoSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"collaudoCompletato", StringPool.TRUE); |
||||
booleanQuery.add(collaudoSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} else if (statoPraticaSearch.equals(StatoPraticaConstants.FINE_LAVORI)) { |
||||
TermQuery fineLavoriSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"fineLavoriCompletati", StringPool.TRUE); |
||||
booleanQuery.add(fineLavoriSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} else if (statoPraticaSearch.equals(StatoPraticaConstants.FINE_LAVORI_PARZIALE)) { |
||||
TermQuery fineLavoriParzialiSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"fineLavoriParziali", StringPool.TRUE); |
||||
booleanQuery.add(fineLavoriParzialiSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} else if (statoPraticaSearch.equals(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) { |
||||
TermQuery sottopostaParereSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"sottopostoAParere", StringPool.TRUE); |
||||
booleanQuery.add(sottopostaParereSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} else if (statoPraticaSearch.equals(StatoPraticaConstants.VARIATA)) { |
||||
TermQuery sottopostaParereSearchTermQuery = TermQueryFactoryUtil.create(searchContext, "variata", |
||||
StringPool.TRUE); |
||||
booleanQuery.add(sottopostaParereSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery statoPraticaSearchTermQuery = TermQueryFactoryUtil.create(searchContext, "statoPratica", |
||||
statoPraticaSearch); |
||||
booleanQuery.add(statoPraticaSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
queryTipoProcedura(request, booleanQuery, searchContext); |
||||
|
||||
if (Validator.isNotNull(committenteSearch)) { |
||||
TermQuery committenteSearchTermQuery = TermQueryFactoryUtil.create(searchContext, "committenti", |
||||
committenteSearch.toUpperCase()); |
||||
booleanQuery.add(committenteSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (Validator.isNotNull(soggettiInterconnessiSearch)) { |
||||
TermQuery soggettiInterconnessiSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"soggettiInterconnessi", soggettiInterconnessiSearch.toUpperCase()); |
||||
booleanQuery.add(soggettiInterconnessiSearchTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (Validator.isNotNull(istruttoreId) && !istruttoreId.equals("-1") && !istruttoreId.equals("0")) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "istruttoreUserId", |
||||
istruttoreId); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(geologi) && !geologi.equals(-1L) && !geologi.equals(0L)) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "geologi", geologi); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(parereGeologo) && !parereGeologo.equals(-1L)) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "parereGeologo", |
||||
parereGeologo); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(unitaOperativa) && !unitaOperativa.equals("-1")) { |
||||
TermQuery uoQuery = TermQueryFactoryUtil.create(searchContext, "unitaOperativa", unitaOperativa); |
||||
booleanQuery.add(uoQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(dataDa) && Validator.isNotNull(dataAl)) { |
||||
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDa); |
||||
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAl); |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", DATE_FORMAT_LUCENE.format(dataDaApp), |
||||
DATE_FORMAT_LUCENE.format(dataAlApp), true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} else if (Validator.isNull(dataDa) && Validator.isNotNull(dataAl)) { |
||||
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAl); |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", "00000000", DATE_FORMAT_LUCENE.format(dataAlApp), true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} else if (Validator.isNotNull(dataDa) && Validator.isNull(dataAl)) { |
||||
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDa); |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", DATE_FORMAT_LUCENE.format(dataDaApp), |
||||
DATE_FORMAT_LUCENE.format(new Date()), true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (Validator.isNotNull(comune) && !comune.equals("-1")) { |
||||
TermQuery comuneTermQuery = TermQueryFactoryUtil.create(searchContext, "comuneId", comune); |
||||
booleanQuery.add(comuneTermQuery, BooleanClauseOccur.MUST); |
||||
|
||||
} |
||||
// ADT - BUG-11 Aggiunta filtro ricerca
|
||||
if (Validator.isNotNull(controlloObbligatorioSearch)) { |
||||
TermQuery controlloObbligatorioTermQuery = TermQueryFactoryUtil.create(searchContext, |
||||
"controlloObbligatorio", controlloObbligatorioSearch); |
||||
booleanQuery.add(controlloObbligatorioTermQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
} catch (ParseException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
} |
||||
|
||||
private static void queryTipoProcedura(HttpServletRequest request, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) throws ParseException { |
||||
|
||||
String tipoProcedura = ParamUtil.getString(request, PortosIndexField.TIPO_PROCEDURA); |
||||
if (Validator.isNotNull(tipoProcedura) && !tipoProcedura.equals("-1")) { |
||||
String[] procSplit = StringUtils.split(tipoProcedura, "|"); |
||||
if (procSplit.length > 0) { |
||||
for (String proc : procSplit) { |
||||
BooleanQuery bq = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.TIPO_PROCEDURA, |
||||
proc); |
||||
bq.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
booleanQuery.add(bq, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static Sort[] getOrderedQuery(HttpServletRequest request) { |
||||
Properties properties = PropsUtil.getProperties("elasticsearch.", true); |
||||
String orderField = ParamUtil.getString(request, "ordinaPer", "numeroProgetto"); |
||||
String orderType = ParamUtil.getString(request, "ordinaTipo", "desc"); |
||||
List<Sort> sortes = new ArrayList<Sort>(); |
||||
Sort sort = new Sort(); |
||||
if (Validator.isNotNull(orderField) && !orderField.equals("-1")) { |
||||
if (properties.size() > 0) { |
||||
sort.setFieldName(orderField + "_sortable"); |
||||
} else { |
||||
sort.setFieldName(orderField); |
||||
} |
||||
if (orderField.equals("numeroProgetto")) { |
||||
sort.setType(Sort.INT_TYPE); |
||||
} else if (orderField.equals(PortosIndexField.PROTOCOLLO)) { |
||||
sort.setType(Sort.INT_TYPE); |
||||
} else if (orderField.equals("dtPratica") || |
||||
orderField.equals("dataCreazione") || |
||||
orderField.equals("createDate") |
||||
) { |
||||
sort.setType(Sort.LONG_TYPE); |
||||
} |
||||
} |
||||
|
||||
if (Validator.isNotNull(orderType) && !orderType.equals("-1")) { |
||||
if (orderType.equals("asc")) { |
||||
sort.setReverse(false); |
||||
} else { |
||||
sort.setReverse(true); |
||||
} |
||||
} |
||||
sortes.add(sort); |
||||
return sortes.toArray(new Sort[0]); |
||||
} |
||||
} |
@ -0,0 +1,478 @@
|
||||
package it.mwg.sismica.bo.search; |
||||
|
||||
import it.mwg.sismica.bo.shared.util.IndexField; |
||||
import it.mwg.sismica.bo.shared.util.UserUtil; |
||||
import it.mwg.sismica.bo.shared.util.WorkflowConstants; |
||||
import it.tref.liferay.portos.bo.model.ControlloPratica; |
||||
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
||||
|
||||
import java.text.DateFormat; |
||||
import java.text.Format; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
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.search.BooleanClauseOccur; |
||||
import com.liferay.portal.kernel.search.BooleanQuery; |
||||
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.Document; |
||||
import com.liferay.portal.kernel.search.Field; |
||||
import com.liferay.portal.kernel.search.Hits; |
||||
import com.liferay.portal.kernel.search.ParseException; |
||||
import com.liferay.portal.kernel.search.SearchContext; |
||||
import com.liferay.portal.kernel.search.SearchContextFactory; |
||||
import com.liferay.portal.kernel.search.SearchEngineUtil; |
||||
import com.liferay.portal.kernel.search.SearchException; |
||||
import com.liferay.portal.kernel.search.TermQuery; |
||||
import com.liferay.portal.kernel.search.TermQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.TermRangeQuery; |
||||
import com.liferay.portal.kernel.search.TermRangeQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.util.FastDateFormatFactoryUtil; |
||||
import com.liferay.portal.kernel.util.GetterUtil; |
||||
import com.liferay.portal.kernel.util.ParamUtil; |
||||
import com.liferay.portal.kernel.util.PropsKeys; |
||||
import com.liferay.portal.kernel.util.PropsUtil; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.model.Organization; |
||||
import com.liferay.portal.model.Role; |
||||
import com.liferay.portal.model.User; |
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
||||
import com.liferay.portal.service.RoleLocalServiceUtil; |
||||
|
||||
public class ControlloPraticaSearch extends BaseSearch { |
||||
|
||||
private static final Log _log = LogFactoryUtil.getLog(ControlloPraticaSearch.class); |
||||
|
||||
public static final Format DATE_FORMAT_LUCENE = FastDateFormatFactoryUtil.getSimpleDateFormat("yyyyMMdd"); |
||||
|
||||
public static final DateFormat DATE_FORMAT_STRING = new SimpleDateFormat("dd/MM/yyyy"); |
||||
|
||||
public static Hits searchMieiTask(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
if (ParamUtil.getBoolean(request, "searchForExport", false)) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca : entryClassName=ControlloPratica & userId=taskAssigneeUserId
|
||||
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
ControlloPratica.class.getName()); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.TASK_ASSIGNEE_USER_ID, user.getUserId()); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, WorkflowConstants.STATUS_PENDING); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); |
||||
BooleanQuery groupQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(orgs) && !orgs.isEmpty()) { |
||||
for (Organization org : orgs) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
||||
org.getGroupId()); |
||||
groupQuery.add(singleGroupIdQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
query.add(groupQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
query.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
// Condizioni aggiuntive
|
||||
query(request, user, query, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + query.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, query); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchTaskMieiRuoli(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
if (ParamUtil.getBoolean(request, "searchForExport", false)) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=ControlloPratica & roleIds tra i taskAssigneeIds
|
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
ControlloPratica.class.getName()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQueryRoleIds = BooleanQueryFactoryUtil.create(searchContext); |
||||
List<Organization> organizationUserList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
List<Role> organizationRoleList = null; |
||||
for (Organization org : organizationUserList) { |
||||
organizationRoleList = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), org.getGroupId()); |
||||
for (Role role : organizationRoleList) { |
||||
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, |
||||
IndexField.TASK_ASSIGNEE_ROLE_IDS, "R" + role.getRoleId() + "G" + org.getGroupId()); |
||||
booleanQueryRoleIds.add(roleIdTerm, BooleanClauseOccur.SHOULD); |
||||
} |
||||
} |
||||
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext); |
||||
query.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
|
||||
if (organizationUserList != null && !organizationUserList.isEmpty() && organizationRoleList != null |
||||
&& !organizationRoleList.isEmpty()) { |
||||
query.add(booleanQueryRoleIds, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, IndexField.TASK_ASSIGNEE_ROLE_IDS, |
||||
"R0G0"); |
||||
booleanQueryRoleIds.add(roleIdTerm, BooleanClauseOccur.SHOULD); |
||||
query.add(booleanQueryRoleIds, BooleanClauseOccur.MUST); |
||||
} |
||||
query.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
long ufficio = ParamUtil.getLong(request, "ufficio"); |
||||
if (ufficio != 0 && ufficio != -1) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", ufficio); |
||||
query.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList) && !organizationList.isEmpty()) { |
||||
for (Organization org : organizationList) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
||||
org.getGroupId()); |
||||
groupIdsQuery.add(singleGroupIdQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
query.add(groupIdsQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
query.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
Set<Integer> uos = UserUtil.getUnitaOperative(user); |
||||
if ((uos.size() > 0) && !uos.contains(0)) { |
||||
BooleanQuery uoQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
for (int uo : uos) { |
||||
TermQuery tq = TermQueryFactoryUtil.create(searchContext, IndexField.UNITA_OPERATIVA, uo); |
||||
uoQuery.add(tq, BooleanClauseOccur.SHOULD); |
||||
} |
||||
query.add(uoQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
// Condizioni aggiuntive
|
||||
query(request, user, query, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + query.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, query); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchAltriTask(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
||||
if (searchForExport) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=ControlloPratica & roleIds non e tra i
|
||||
// taskAssigneeIds userId non e tra taskAssigneeId
|
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
ControlloPratica.class.getName()); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.TASK_ASSIGNEE_USER_ID, user.getUserId()); |
||||
query.add(term, BooleanClauseOccur.MUST_NOT); |
||||
BooleanQuery subQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); |
||||
List<Role> roles = null; |
||||
for (Organization org : orgs) { |
||||
roles = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), org.getGroupId()); |
||||
for (Role role : roles) { |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.TASK_ASSIGNEE_ROLE_IDS, |
||||
"R" + role.getRoleId() + "G" + org.getGroupId()); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
} |
||||
} |
||||
if (subQuery.clauses().size() > 0) { |
||||
query.add(subQuery, BooleanClauseOccur.MUST_NOT); |
||||
} |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, WorkflowConstants.STATUS_PENDING); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
orgs = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); |
||||
subQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNull(orgs)) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, 0L); |
||||
query.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
for (Organization org : orgs) { |
||||
term = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, org.getGroupId()); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
} |
||||
query.add(subQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
// Condizioni aggiuntive
|
||||
query(request, user, query, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + query.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, query); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static List<ControlloPratica> searchTaskPerEsportazioneDirigente(HttpServletRequest request, User user, |
||||
int start, int end) { |
||||
|
||||
List<ControlloPratica> lista = new ArrayList<ControlloPratica>(); |
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
String dataDa = ParamUtil.getString(request, "dataRichiestaInizio"); |
||||
String dataAl = ParamUtil.getString(request, "dataRichiestaFine"); |
||||
if (Validator.isNotNull(dataDa) || Validator.isNotNull(dataAl)) { |
||||
if (Validator.isNull(dataDa)) { |
||||
dataDa = "00000000"; |
||||
} else { |
||||
dataDa = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataDa)); |
||||
} |
||||
if (Validator.isNull(dataAl)) { |
||||
dataAl = DATE_FORMAT_LUCENE.format(new Date()); |
||||
} else { |
||||
dataAl = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataAl)); |
||||
} |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", dataDa, dataAl, true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hints found : " + hits.getLength()); |
||||
} |
||||
for (Document doc : hits.toList()) { |
||||
String controlloPraticaId = doc.get("controlloPraticaId"); |
||||
if (Validator.isNotNull(controlloPraticaId)) { |
||||
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil |
||||
.fetchControlloPratica(GetterUtil.getLong(controlloPraticaId)); |
||||
if (Validator.isNotNull(controlloPratica)) { |
||||
lista.add(controlloPratica); |
||||
} |
||||
} |
||||
} |
||||
} catch (ParseException | SearchException | SystemException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return lista; |
||||
} |
||||
|
||||
public static List<ControlloPratica> searchTaskPerEsportazionePO(HttpServletRequest request, User user, int start, |
||||
int end) { |
||||
|
||||
List<ControlloPratica> lista = new ArrayList<ControlloPratica>(); |
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
TermQuery entryClassNameTermQuery = TermQueryFactoryUtil.create(searchContext, "entryClassName", |
||||
ControlloPratica.class.getName()); |
||||
TermQuery userIdTermQuery = TermQueryFactoryUtil.create(searchContext, "taskAssigneeUserId", |
||||
user.getUserId()); |
||||
TermQuery statusTermQuery = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, |
||||
WorkflowConstants.STATUS_PENDING); |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
booleanQuery.add(entryClassNameTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(userIdTermQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(statusTermQuery, BooleanClauseOccur.MUST); |
||||
String dataDa = ParamUtil.getString(request, "dataRichiestaInizio"); |
||||
String dataAl = ParamUtil.getString(request, "dataRichiestaFine"); |
||||
if (Validator.isNotNull(dataDa) || Validator.isNotNull(dataAl)) { |
||||
if (Validator.isNull(dataDa)) { |
||||
dataDa = "00000000"; |
||||
} else { |
||||
dataDa = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataDa)); |
||||
} |
||||
if (Validator.isNull(dataAl)) { |
||||
dataAl = DATE_FORMAT_LUCENE.format(new Date()); |
||||
} else { |
||||
dataAl = DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING.parse(dataAl)); |
||||
} |
||||
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
"dataInizioProcedimento", dataDa, dataAl, true, true); |
||||
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
for (Document doc : hits.toList()) { |
||||
String controlloPraticaId = doc.get("controlloPraticaId"); |
||||
if (Validator.isNotNull(controlloPraticaId)) { |
||||
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil |
||||
.fetchControlloPratica(GetterUtil.getLong(controlloPraticaId)); |
||||
if (Validator.isNotNull(controlloPratica)) { |
||||
lista.add(controlloPratica); |
||||
} |
||||
} |
||||
} |
||||
} catch (ParseException | SearchException | SystemException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return lista; |
||||
} |
||||
|
||||
public static Hits searchTaskConclusi(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
if (ParamUtil.getBoolean(request, "searchForExport", false)) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=ControlloPratica & roleIds non e tra i
|
||||
// taskAssigneeIds userId non e tra taskAssigneeId
|
||||
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
ControlloPratica.class.getName()); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
BooleanQuery subQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
List<Organization> orgs = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); |
||||
List<Role> roles = null; |
||||
for (Organization org : orgs) { |
||||
roles = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), org.getGroupId()); |
||||
for (Role role : roles) { |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.TASK_ASSIGNEE_ROLE_IDS, |
||||
"R" + role.getRoleId() + "G" + org.getGroupId()); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
} |
||||
} |
||||
if (Validator.isNotNull(roles)) { |
||||
query.add(subQuery, BooleanClauseOccur.MUST_NOT); |
||||
} |
||||
subQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, WorkflowConstants.STATUS_DENIED); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, WorkflowConstants.STATUS_APPROVED); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
term = TermQueryFactoryUtil.create(searchContext, IndexField.STATUS, WorkflowConstants.STATUS_INCOMPLETE); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
query.add(subQuery, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId relativi all utente che effettua la ricerca per filtrare
|
||||
orgs = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); |
||||
subQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(orgs) && !orgs.isEmpty()) { |
||||
for (Organization org : orgs) { |
||||
term = TermQueryFactoryUtil.create(searchContext, "groupId", org.getGroupId()); |
||||
subQuery.add(term, BooleanClauseOccur.SHOULD); |
||||
} |
||||
query.add(subQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
term = TermQueryFactoryUtil.create(searchContext, "groupId", 0L); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
// Condizioni aggiuntive
|
||||
query(request, user, query, searchContext); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("User " + user.getScreenName() + " Request query : " + query.toString()); |
||||
} |
||||
hits = SearchEngineUtil.search(searchContext, query); |
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
private static void query(HttpServletRequest request, User user, BooleanQuery query, SearchContext searchContext) { |
||||
|
||||
try { |
||||
fullQuery(request, user, query, searchContext); |
||||
} catch (ParseException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
} |
||||
} |
@ -1,583 +0,0 @@
|
||||
package it.mwg.sismica.bo.search; |
||||
|
||||
import it.mwg.sismica.bo.shared.util.PortosIndexField; |
||||
import it.tref.liferay.portos.bo.model.IntPratica; |
||||
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
||||
|
||||
import java.text.DateFormat; |
||||
import java.text.Format; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Properties; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
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.search.BooleanClauseOccur; |
||||
import com.liferay.portal.kernel.search.BooleanQuery; |
||||
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.Field; |
||||
import com.liferay.portal.kernel.search.Hits; |
||||
import com.liferay.portal.kernel.search.ParseException; |
||||
import com.liferay.portal.kernel.search.SearchContext; |
||||
import com.liferay.portal.kernel.search.SearchContextFactory; |
||||
import com.liferay.portal.kernel.search.SearchEngineUtil; |
||||
import com.liferay.portal.kernel.search.SearchException; |
||||
import com.liferay.portal.kernel.search.Sort; |
||||
import com.liferay.portal.kernel.search.TermQuery; |
||||
import com.liferay.portal.kernel.search.TermQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.TermRangeQuery; |
||||
import com.liferay.portal.kernel.search.TermRangeQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.util.FastDateFormatFactoryUtil; |
||||
import com.liferay.portal.kernel.util.GetterUtil; |
||||
import com.liferay.portal.kernel.util.ParamUtil; |
||||
import com.liferay.portal.kernel.util.PropsKeys; |
||||
import com.liferay.portal.kernel.util.PropsUtil; |
||||
import com.liferay.portal.kernel.util.StringPool; |
||||
import com.liferay.portal.kernel.util.StringUtil; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.model.Organization; |
||||
import com.liferay.portal.model.User; |
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
||||
|
||||
public class IntPraticaAdvancedSearch { |
||||
|
||||
private static final Log _log = LogFactoryUtil.getLog(IntPraticaAdvancedSearch.class); |
||||
|
||||
public static final String[] OVERRIDE_KEYWORDS = { PortosIndexField.INT_PRATICA_ID, |
||||
PortosIndexField.NUMERO_PROGETTO, PortosIndexField.TIPO_PRATICA, PortosIndexField.STATO_PRATICA, |
||||
PortosIndexField.DATA_RICHIESTA, PortosIndexField.COMMITTENTE, PortosIndexField.SOGGETTI_INTERESSATI, |
||||
PortosIndexField.STATUS, Field.ENTRY_CLASS_NAME, Field.USER_ID, PortosIndexField.DESC_INTERVENTO, |
||||
PortosIndexField.TIPO_PROCEDURA }; |
||||
|
||||
public static final Format DATE_FORMAT_LUCENE = FastDateFormatFactoryUtil.getSimpleDateFormat("yyyyMMdd"); |
||||
|
||||
public static final DateFormat DATE_FORMAT_STRING = new SimpleDateFormat("dd/MM/yyyy"); |
||||
|
||||
public static Hits searchMieiProgetti(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & userId=userId e stato!=chiuso ??
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.USER_ID, user.getUserId()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.PRATICA_APERTA, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.IN_LAVORAZIONE_SUE, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (SearchException | ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchAltriProgetti(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & soggettiInteressati=userScreenName
|
||||
// e userId!=myUserId e stato!=chiuso ??
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.SOGGETTI_INTERESSATI, user |
||||
.getScreenName().toUpperCase()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.PRATICA_APERTA, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.IN_LAVORAZIONE_SUE, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchArchivioProgetti(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & soggettiInteressati=userScreenName
|
||||
// e stato==chiuso
|
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
BooleanQuery altriProgettiBooleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.SOGGETTI_INTERESSATI, |
||||
user.getScreenName().toUpperCase()); |
||||
altriProgettiBooleanQuery.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.USER_ID, user.getUserId()); |
||||
altriProgettiBooleanQuery.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.PRATICA_APERTA, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(altriProgettiBooleanQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.IN_LAVORAZIONE_SUE, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchProgettiBO(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
||||
if (searchForExport) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & dtPratica valorizzato & GroupId
|
||||
// facente parte dei miei gruopId delle mie organizzazioni
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "dtPratica", 0); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST_NOT); |
||||
// Ricavo i groupId legati all utente che effettua la ricerca
|
||||
int ufficio = ParamUtil.getInteger(request, "ufficio"); |
||||
if (ufficio != 0 && ufficio != -1) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, ufficio); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
BooleanQuery groupIdsQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList)) { |
||||
for (Organization org : organizationList) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, org.getGroupId()); |
||||
groupIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
} |
||||
booleanQuery.add(groupIdsQuery, BooleanClauseOccur.MUST); |
||||
} else { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, 0L); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record
|
||||
public static Hits searchAttivitaIstruttore(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
return searchAttivitaIstruttore(request, user, start, end, false); |
||||
} |
||||
|
||||
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record
|
||||
public static Hits searchAttivitaIstruttore(HttpServletRequest request, User user, int start, int end, |
||||
boolean isExport) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
||||
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record
|
||||
if (!isExport) { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & statusByUserId = myUserId
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "istruttoreUserId", user.getUserId()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
queryForIstruttore(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
/* |
||||
* Manifattura Web Group per Regione Siciliana Modifiche per rendere i campi di testo ricercabili per parole |
||||
* contenute e non per corrispondenza esatta. |
||||
*/ |
||||
private static void query(HttpServletRequest request, User user, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) { |
||||
|
||||
String istruttoreId = ParamUtil.getString(request, "istruttore"); |
||||
String unitaOperativa = ParamUtil.getString(request, "unitaOperativa"); |
||||
Long geologi = ParamUtil.getLong(request, "geologi"); |
||||
Long parereGeologo = ParamUtil.getLong(request, "parereGeologo"); |
||||
|
||||
try { |
||||
TermQuery termQuery; |
||||
queryPraticaAperta(request, booleanQuery, searchContext); |
||||
queryNumeroProgetto(request, booleanQuery, searchContext); |
||||
String protocollo = ParamUtil.getString(request, PortosIndexField.PROTOCOLLO); |
||||
if (Validator.isNotNull(protocollo)) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.PROTOCOLLO, protocollo); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
queryTipoPratica(request, booleanQuery, searchContext); |
||||
queryTipoProcedura(request, booleanQuery, searchContext); |
||||
String tipoIntervento = ParamUtil.getString(request, "tipoIntervento"); |
||||
if (Validator.isNotNull(tipoIntervento)) { |
||||
if (tipoIntervento.equals("interventoLocale")) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "interventoLocale", StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} else if (tipoIntervento.equals("miglioramento")) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.MIGLIORAMENTO_SISMICO, |
||||
StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} else if (tipoIntervento.equals("adeguamento")) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.ADEGUAMENTO_SISMICO, |
||||
StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} else if (tipoIntervento.equals(PortosIndexField.NUOVA_COSTRUZIONE)) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.NUOVA_COSTRUZIONE, |
||||
StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
queryStatoPratica(request, booleanQuery, searchContext); |
||||
addRequiredTerms(booleanQuery, PortosIndexField.COMMITTENTI, ParamUtil.getString(request, "committente")); |
||||
|
||||
addRequiredTerms(booleanQuery, PortosIndexField.ISTRUTTORE_FULL_NAME, |
||||
ParamUtil.getString(request, "tecnicoIstruttore")); |
||||
addRequiredTerms(booleanQuery, PortosIndexField.PROPRIETARIO_DIGITALE_FULL_NAME, |
||||
ParamUtil.getString(request, "titolareDigitale")); |
||||
for (String field : new String[] { PortosIndexField.SOGGETTI_INTERCONNESSI, |
||||
PortosIndexField.DESC_INTERVENTO, PortosIndexField.INDIRIZZO }) |
||||
addRequiredTerms(booleanQuery, field, ParamUtil.getString(request, field)); |
||||
String provincia = ParamUtil.getString(request, PortosIndexField.PROVINCIA); |
||||
if (Validator.isNotNull(provincia) && !provincia.equals("000")) { |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.PROVINCIA_CODICE, provincia); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
queryComune(request, booleanQuery, searchContext); |
||||
queryDate(request, booleanQuery, searchContext); |
||||
|
||||
if (Validator.isNotNull(istruttoreId) && !istruttoreId.equals("-1") && !istruttoreId.equals("0")) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "istruttoreUserId", |
||||
istruttoreId); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(unitaOperativa) && !unitaOperativa.equals("-1")) { |
||||
TermQuery uoQuery = TermQueryFactoryUtil.create(searchContext, "unitaOperativa", |
||||
unitaOperativa); |
||||
booleanQuery.add(uoQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(geologi) && !geologi.equals(-1L) && !geologi.equals(0L)) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "geologi", |
||||
geologi); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
if (Validator.isNotNull(parereGeologo) && !parereGeologo.equals(-1L)) { |
||||
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "parereGeologo", |
||||
parereGeologo); |
||||
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
|
||||
} catch (ParseException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
|
||||
} |
||||
|
||||
private static void queryForIstruttore(HttpServletRequest request, User user, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) { |
||||
|
||||
try { |
||||
queryNumeroProgetto(request, booleanQuery, searchContext); |
||||
queryPraticaAperta(request, booleanQuery, searchContext); |
||||
queryTipoPratica(request, booleanQuery, searchContext); |
||||
if (!ParamUtil.getBoolean(request, "interventoTutti")) { |
||||
if (ParamUtil.getBoolean(request, "interventoNuovaCostruzione")) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, |
||||
PortosIndexField.NUOVA_COSTRUZIONE, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (ParamUtil.getBoolean(request, "interventoAdeguamentoSismico")) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, |
||||
PortosIndexField.ADEGUAMENTO_SISMICO, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (ParamUtil.getBoolean(request, "interventoMiglioramentoSismico")) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, |
||||
PortosIndexField.MIGLIORAMENTO_SISMICO, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
if (ParamUtil.getBoolean(request, "interventoRiparazioneInterventoLocale")) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, |
||||
PortosIndexField.RIPARAZIONE_INTERVENTO_LOCALE, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
queryStatoPratica(request, booleanQuery, searchContext); |
||||
for (String field : new String[] { PortosIndexField.COMMITTENTI, PortosIndexField.SOGGETTI_INTERCONNESSI, |
||||
PortosIndexField.DIRETTORE_LAVORI }) |
||||
addRequiredTerms(booleanQuery, field, ParamUtil.getString(request, field)); |
||||
queryDate(request, booleanQuery, searchContext); |
||||
queryComune(request, booleanQuery, searchContext); |
||||
|
||||
String ufficio = ParamUtil.getString(request, "ufficio"); |
||||
if (Validator.isNotNull(ufficio) && !ufficio.equals("-1")) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, ufficio); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} catch (ParseException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
} |
||||
|
||||
private static void addRequiredTerms(BooleanQuery booleanQuery, String field, String terms) { |
||||
if (Validator.isNotNull(terms)) |
||||
for (String term : StringUtil.split(terms, StringPool.SPACE)) |
||||
if (Validator.isNotNull(term)) |
||||
booleanQuery.addRequiredTerm(field, term); |
||||
} |
||||
|
||||
private static Sort[] getOrderedQuery(HttpServletRequest request) { |
||||
|
||||
Properties properties = PropsUtil.getProperties("elasticsearch.", true); |
||||
String orderField = ParamUtil.getString(request, "ordinaPer"); |
||||
String orderType = ParamUtil.getString(request, "ordinaTipo"); |
||||
List<Sort> sortes = new ArrayList<Sort>(); |
||||
Sort sort = new Sort(); |
||||
if (Validator.isNotNull(orderField) && !orderField.equals("-1")) { |
||||
if (properties.size() > 0) { |
||||
sort.setFieldName(orderField + "_sortable"); |
||||
} else { |
||||
sort.setFieldName(orderField); |
||||
} |
||||
if (orderField.equals(PortosIndexField.NUMERO_PROGETTO)) { |
||||
sort.setType(Sort.INT_TYPE); |
||||
} else if (orderField.equals(PortosIndexField.PROTOCOLLO)) { |
||||
sort.setType(Sort.INT_TYPE); |
||||
} else if (orderField.equals("dtPratica") || |
||||
orderField.equals("dataCreazione") || |
||||
orderField.equals("createDate") |
||||
) { |
||||
sort.setType(Sort.LONG_TYPE); |
||||
} |
||||
} |
||||
|
||||
if (Validator.isNotNull(orderType) && !orderType.equals("-1")) { |
||||
if (orderType.equals("asc")) { |
||||
sort.setReverse(false); |
||||
} else { |
||||
sort.setReverse(true); |
||||
} |
||||
} |
||||
sortes.add(sort); |
||||
return sortes.toArray(new Sort[0]); |
||||
} |
||||
|
||||
/* |
||||
* Manifattura Web Group per Regione Siciliana |
||||
* |
||||
* Rimosse numerose righe di codice che trattavano separatamente i 3 casi: entrambe le date inserite, inserita solo |
||||
* la data iniziale, inserita solo la data finale. Le funzioni seguenti sono state create per ridurre la |
||||
* duplicazione di codice. |
||||
*/ |
||||
private static void queryDate(HttpServletRequest request, BooleanQuery booleanQuery, SearchContext searchContext) |
||||
throws ParseException, java.text.ParseException { |
||||
String dataDaSearch = ParamUtil.getString(request, "dataRichiestaInizio"); |
||||
String dataASearch = ParamUtil.getString(request, "dataRichiestaFine"); |
||||
|
||||
if (Validator.isNotNull(dataDaSearch) || Validator.isNotNull(dataASearch)) { |
||||
|
||||
String dataDa = Validator.isNull(dataDaSearch) ? "00000000" : DATE_FORMAT_LUCENE.format(DATE_FORMAT_STRING |
||||
.parse(dataDaSearch)); |
||||
String dataA = DATE_FORMAT_LUCENE.format(Validator.isNull(dataASearch) ? new Date() : DATE_FORMAT_STRING |
||||
.parse(dataASearch)); |
||||
|
||||
TermRangeQuery termRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
||||
PortosIndexField.DATA_RICHIESTA, dataDa, dataA, true, true); |
||||
booleanQuery.add(termRangeQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryComune(HttpServletRequest request, BooleanQuery booleanQuery, SearchContext searchContext) |
||||
throws ParseException { |
||||
|
||||
String comune = ParamUtil.getString(request, PortosIndexField.COMUNE); |
||||
if (Validator.isNotNull(comune) && !comune.equals("000")) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.COMUNE_ID, comune); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryNumeroProgetto(HttpServletRequest request, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) throws ParseException { |
||||
|
||||
String numeroProgetto = ParamUtil.getString(request, PortosIndexField.NUMERO_PROGETTO); |
||||
if (Validator.isNotNull(numeroProgetto)) { |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.NUMERO_PROGETTO, |
||||
numeroProgetto); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryTipoProcedura(HttpServletRequest request, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) throws ParseException { |
||||
|
||||
String tipoProcedura = ParamUtil.getString(request, PortosIndexField.TIPO_PROCEDURA); |
||||
if (Validator.isNotNull(tipoProcedura) && !tipoProcedura.equals("-1")) { |
||||
String[] procSplit = StringUtils.split(tipoProcedura, "|"); |
||||
if(procSplit.length > 0){ |
||||
for(String proc : procSplit){ |
||||
BooleanQuery bq = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.TIPO_PROCEDURA, proc); |
||||
bq.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
booleanQuery.add(bq, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void queryStatoPratica(HttpServletRequest request, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) throws ParseException { |
||||
|
||||
String statoPratica = ParamUtil.getString(request, PortosIndexField.STATO_PRATICA); |
||||
if (Validator.isNotNull(statoPratica)) { |
||||
TermQuery termQuery = null; |
||||
if (statoPratica.equals(StatoPraticaConstants.COLLAUDO_PARZIALE)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.COLLAUDO_PARZIALE, |
||||
StringPool.TRUE); |
||||
else if (statoPratica.equals(StatoPraticaConstants.COLLAUDO)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.COLLAUDO_COMPLETATO, |
||||
StringPool.TRUE); |
||||
else if (statoPratica.equals(StatoPraticaConstants.FINE_LAVORI)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.FINE_LAVORI_COMPLETATI, |
||||
StringPool.TRUE); |
||||
else if (statoPratica.equals(StatoPraticaConstants.FINE_LAVORI_PARZIALE)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.FINE_LAVORI_PARZIALI, |
||||
StringPool.TRUE); |
||||
else if (statoPratica.equals(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.SOTTOPOSTO_A_PARERE, |
||||
StringPool.TRUE); |
||||
else if (statoPratica.equals(PortosIndexField.STATUS_SOSPESA)) |
||||
termQuery = TermQueryFactoryUtil |
||||
.create(searchContext, PortosIndexField.STATUS_SOSPESA, StringPool.TRUE); |
||||
else if (statoPratica.equals("IC")) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "dtPratica", "0"); |
||||
else if (statoPratica.equals(StatoPraticaConstants.VARIATA)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "variata", StringPool.TRUE); |
||||
else if(statoPratica.equals(PortosIndexField.ASSEGNATA_AD_ISTRUTTORE)) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.ASSEGNATA_AD_ISTRUTTORE, 1L); |
||||
else if (!statoPratica.equals("-1")) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.STATO_PRATICA, statoPratica); |
||||
if (Validator.isNotNull(termQuery)) |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryPraticaAperta(HttpServletRequest request, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) throws ParseException { |
||||
|
||||
String praticaAperta = ParamUtil.getString(request, PortosIndexField.PRATICA_APERTA); |
||||
if (Validator.isNotNull(praticaAperta)) { |
||||
TermQuery termQuery = null; |
||||
if (praticaAperta.equals("aperta")) |
||||
termQuery = TermQueryFactoryUtil |
||||
.create(searchContext, PortosIndexField.PRATICA_APERTA, StringPool.TRUE); |
||||
else if (praticaAperta.equals("chiusa")) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.PRATICA_APERTA, |
||||
StringPool.FALSE); |
||||
if (Validator.isNotNull(termQuery)) |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void queryTipoPratica(HttpServletRequest request, BooleanQuery booleanQuery, |
||||
SearchContext searchContext) throws ParseException { |
||||
|
||||
String tipoPratica = ParamUtil.getString(request, PortosIndexField.TIPO_PRATICA); |
||||
if (Validator.isNotNull(tipoPratica)) { |
||||
TermQuery termQuery = null; |
||||
if (tipoPratica.equals("co")) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "controlloObbligatorio", StringPool.TRUE); |
||||
else if (!tipoPratica.equals("-1")) |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, PortosIndexField.TIPO_PRATICA, tipoPratica); |
||||
if (Validator.isNotNull(termQuery)) |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
|
||||
private static void logResults(User user, BooleanQuery booleanQuery, Hits hits) { |
||||
|
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Utente " + user.getScreenName() + " query : " + booleanQuery.toString()); |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,258 @@
|
||||
package it.mwg.sismica.bo.search; |
||||
|
||||
import it.mwg.sismica.bo.shared.util.IndexField; |
||||
import it.tref.liferay.portos.bo.model.IntPratica; |
||||
|
||||
import java.util.List; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
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.search.BooleanClauseOccur; |
||||
import com.liferay.portal.kernel.search.BooleanQuery; |
||||
import com.liferay.portal.kernel.search.BooleanQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.search.Field; |
||||
import com.liferay.portal.kernel.search.Hits; |
||||
import com.liferay.portal.kernel.search.ParseException; |
||||
import com.liferay.portal.kernel.search.SearchContext; |
||||
import com.liferay.portal.kernel.search.SearchContextFactory; |
||||
import com.liferay.portal.kernel.search.SearchEngineUtil; |
||||
import com.liferay.portal.kernel.search.SearchException; |
||||
import com.liferay.portal.kernel.search.TermQuery; |
||||
import com.liferay.portal.kernel.search.TermQueryFactoryUtil; |
||||
import com.liferay.portal.kernel.util.GetterUtil; |
||||
import com.liferay.portal.kernel.util.ParamUtil; |
||||
import com.liferay.portal.kernel.util.PropsKeys; |
||||
import com.liferay.portal.kernel.util.PropsUtil; |
||||
import com.liferay.portal.kernel.util.StringPool; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.model.Organization; |
||||
import com.liferay.portal.model.User; |
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
||||
|
||||
public class IntPraticaSearch extends BaseSearch { |
||||
|
||||
private static final Log _log = LogFactoryUtil.getLog(IntPraticaSearch.class); |
||||
|
||||
public static Hits searchMieiProgetti(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & userId=userId e stato!=chiuso ??
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.USER_ID, user.getUserId()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.IN_LAVORAZIONE_SUE, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (SearchException | ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchAltriProgetti(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & soggettiInteressati=userScreenName
|
||||
// e userId!=myUserId e stato!=chiuso ??
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.SOGGETTO, user.getScreenName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.PRATICA_APERTA, StringPool.TRUE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.IN_LAVORAZIONE_SUE, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchArchivioProgetti(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & soggettiInteressati=userScreenName
|
||||
// e stato==chiuso
|
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
BooleanQuery altriProgettiBooleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.SOGGETTO, user.getScreenName()); |
||||
altriProgettiBooleanQuery.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.USER_ID, user.getUserId()); |
||||
altriProgettiBooleanQuery.add(termQuery, BooleanClauseOccur.SHOULD); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.PRATICA_APERTA, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
booleanQuery.add(altriProgettiBooleanQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, IndexField.IN_LAVORAZIONE_SUE, StringPool.FALSE); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
query(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
public static Hits searchProgettiBO(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
||||
if (searchForExport) { |
||||
int maxEnd = GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)); |
||||
searchContext.setStart(0); |
||||
searchContext.setEnd(maxEnd); |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
} |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & groupId tra quelli delle mie
|
||||
// organizzazioni
|
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
// Ricavo i groupId legati all utente che effettua la ricerca
|
||||
int ufficio = ParamUtil.getInteger(request, "ufficio"); |
||||
if (ufficio != 0 && ufficio != -1) { |
||||
term = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, ufficio); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} else { |
||||
List<Organization> organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user |
||||
.getUserId()); |
||||
BooleanQuery groups = BooleanQueryFactoryUtil.create(searchContext); |
||||
if (Validator.isNotNull(organizationList)) { |
||||
for (Organization org : organizationList) { |
||||
term = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, org.getGroupId()); |
||||
groups.add(term, BooleanClauseOccur.SHOULD); |
||||
} |
||||
query.add(groups, BooleanClauseOccur.MUST); |
||||
} else { |
||||
term = TermQueryFactoryUtil.create(searchContext, Field.GROUP_ID, 0L); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} |
||||
} |
||||
// Condizioni aggiuntive
|
||||
query(request, user, query, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, query); |
||||
logResults(user, query, hits); |
||||
} catch (ParseException | SearchException | SystemException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record
|
||||
public static Hits searchAttivitaIstruttore(HttpServletRequest request, User user, int start, int end) { |
||||
|
||||
return searchAttivitaIstruttore(request, user, start, end, false); |
||||
} |
||||
|
||||
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record
|
||||
public static Hits searchAttivitaIstruttore(HttpServletRequest request, User user, int start, int end, |
||||
boolean isExport) { |
||||
|
||||
SearchContext searchContext = SearchContextFactory.getInstance(request); |
||||
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record
|
||||
if (!isExport) { |
||||
searchContext.setAttribute("paginationType", "more"); |
||||
} else { |
||||
searchContext.setAttribute("paginationType", "none"); |
||||
} |
||||
searchContext.setStart(start); |
||||
searchContext.setEnd(end); |
||||
// Gestione Ordinamento
|
||||
searchContext.setSorts(getOrderedQuery(request)); |
||||
Hits hits = null; |
||||
try { |
||||
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext); |
||||
// Condizioni necessarie per questa ricerca: entryClassName=IntPratica & statusByUserId = myUserId
|
||||
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, Field.ENTRY_CLASS_NAME, |
||||
IntPratica.class.getName()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
termQuery = TermQueryFactoryUtil.create(searchContext, "istruttoreUserId", user.getUserId()); |
||||
booleanQuery.add(termQuery, BooleanClauseOccur.MUST); |
||||
// Condizioni aggiuntive
|
||||
queryForIstruttore(request, user, booleanQuery, searchContext); |
||||
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
||||
logResults(user, booleanQuery, hits); |
||||
} catch (ParseException | SearchException e) { |
||||
_log.error(e, e); |
||||
} |
||||
return hits; |
||||
} |
||||
|
||||
private static void queryForIstruttore(HttpServletRequest request, User user, BooleanQuery query, |
||||
SearchContext searchContext) { |
||||
|
||||
try { |
||||
fullQuery(request, user, query, searchContext); |
||||
} catch (ParseException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
} |
||||
|
||||
private static void query(HttpServletRequest request, User user, BooleanQuery query, SearchContext searchContext) { |
||||
|
||||
try { |
||||
fullQuery(request, user, query, searchContext); |
||||
TermQuery term = TermQueryFactoryUtil.create(searchContext, IndexField.IN_COMPILAZIONE, StringPool.FALSE); |
||||
query.add(term, BooleanClauseOccur.MUST); |
||||
} catch (ParseException | java.text.ParseException e) { |
||||
_log.error(e, e); |
||||
} |
||||
} |
||||
|
||||
private static void logResults(User user, BooleanQuery booleanQuery, Hits hits) { |
||||
|
||||
if (_log.isDebugEnabled()) { |
||||
_log.debug("Utente " + user.getScreenName() + " query : " + booleanQuery); |
||||
_log.debug("Number of hint find : " + hits.getLength()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,266 +0,0 @@
|
||||
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<%@page import="it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil"%> |
||||
<%@page import="it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants"%> |
||||
<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%> |
||||
<%@page import="com.liferay.portal.kernel.json.JSONFactoryUtil"%> |
||||
<%@page import="com.liferay.portal.kernel.json.JSONObject"%> |
||||
<%@page import="com.liferay.portal.service.UserGroupRoleLocalServiceUtil"%> |
||||
<%@page import="com.liferay.portal.model.UserGroupRole"%> |
||||
<%@page import="com.liferay.portal.service.RoleLocalServiceUtil"%> |
||||
<%@page import="com.liferay.portal.model.Role"%> |
||||
<%@page import="java.util.Map.Entry"%> |
||||
<%@page import="java.util.ArrayList"%> |
||||
<%@page import="com.liferay.portal.model.Organization"%> |
||||
<%@page import="com.liferay.portal.service.OrganizationLocalServiceUtil"%> |
||||
<%@include file="/html/fascicolo/init.jsp"%> |
||||
<% |
||||
String provinciaSelect = ParamUtil.getString(renderRequest, "provincia"); |
||||
String comuneSelect = ParamUtil.getString(renderRequest, "comune"); |
||||
String istruttoreSelect = ParamUtil.getString(renderRequest, "istruttore"); |
||||
String uoSelect = ParamUtil.getString(renderRequest, "unitaOperativa"); |
||||
String geologoSelect = ParamUtil.getString(renderRequest, "geologi"); |
||||
%> |
||||
<liferay-ui:panel title="filters" defaultState="closed" |
||||
id='<%= renderResponse.getNamespace() + scopeGroupId + "ricercaSaiPanel" %>' collapsible="true" extended="false" |
||||
persistState="true"> |
||||
<div class="container-fluid" style="padding: 15px;"> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="numeroProgetto" label="Numero Progetto" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="tipoProcedura" label="Tipo Pratica"> |
||||
<aui:option value="-1">Seleziona il tipo di pratica</aui:option> |
||||
<% |
||||
for (Entry<String, String> procedura : IntPraticaLocalServiceUtil.getTipiProcedure().entrySet()) { |
||||
String tipo = procedura.getKey(); |
||||
String label = procedura.getValue(); |
||||
String nomeProcedura = LanguageUtil.get(pageContext, "label_procedura_"+tipo) + ") " + label; |
||||
if(nomeProcedura.length() > 90) |
||||
nomeProcedura = nomeProcedura.substring(0, 90) + "..."; |
||||
%> |
||||
<aui:option value="<%= tipo %>"><%= nomeProcedura %></aui:option> |
||||
<% |
||||
} |
||||
%> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="provincia" label="Provincia" cssClass="provinciaSelect" /> |
||||
</div> |
||||
<div class="col-sm-12 col-md-3 add-new-project__comune"> |
||||
<aui:select name="comune" label="Comune" /> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="titolareDigitale" label="Titolare Digitale" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="committente" label="Committente" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="soggettiInterconnessi" label="Soggetti Interconnessi" /> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-1"> |
||||
<aui:select name="unitaOperativa" label="unita-operativa" cssClass="uoSelect" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-2"> |
||||
<aui:select name="istruttore" label="Istruttore" cssClass="istruttoreSelect" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="geologi" label="Parere endoprocedimentale" cssClass="geologoSelect" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="parereGeologo" label="Parere fornito"> |
||||
<aui:option value="-1">Tutte</aui:option> |
||||
<aui:option value="1">Si</aui:option> |
||||
<aui:option value="0">No</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-12"> |
||||
<aui:field-wrapper label="Data richiesta da" inlineField="true"> |
||||
<liferay-util:include page="/html/common/input_date_time.jsp" servletContext="<%= application %>"> |
||||
<liferay-util:param name="field" value="dataRichiestaInizio" /> |
||||
</liferay-util:include> |
||||
</aui:field-wrapper> |
||||
<aui:field-wrapper label="a" inlineField="true"> |
||||
<liferay-util:include page="/html/common/input_date_time.jsp" servletContext="<%= application %>"> |
||||
<liferay-util:param name="field" value="dataRichiestaFine" /> |
||||
</liferay-util:include> |
||||
</aui:field-wrapper> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="tipoAttivita" label="Attività"> |
||||
<aui:option value="-1">Tutte</aui:option> |
||||
<aui:option value="Assegnazione">Assegnazione</aui:option> |
||||
<aui:option value="Approvazione">Approvazione</aui:option> |
||||
<aui:option value="Annullato">Annullato</aui:option> |
||||
<aui:option value="Esito">Esito</aui:option> |
||||
<aui:option value="NonApprovato">Non Approvato</aui:option> |
||||
<aui:option value="signal_cittadino">Richiesta Integrazione</aui:option> |
||||
<aui:option value="signal_ff">Firma</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="statoPratica" label="Esito"> |
||||
<aui:option value="-1">Tutti</aui:option> |
||||
<% |
||||
for (String esito : new String[] { |
||||
StatoPraticaConstants.AUTORIZZATA, |
||||
StatoPraticaConstants.ANNULLATA, |
||||
StatoPraticaConstants.INTEGRAZIONE, |
||||
StatoPraticaConstants.NO_PARERE, |
||||
StatoPraticaConstants.NON_AUTORIZZATA, |
||||
StatoPraticaConstants.PREAVVISO_CONTRARIO, |
||||
StatoPraticaConstants.PERIZIA_SANZIONE, |
||||
StatoPraticaConstants.DECRETO_SANZIONE, |
||||
}) { |
||||
%> |
||||
<aui:option value="<%= esito %>" label='<%= "stato-pratica-" + esito %>' /> |
||||
<% |
||||
} |
||||
%> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="ordinaPer" label="Ordina Per"> |
||||
<aui:option value="taskName">Nome Task</aui:option> |
||||
<aui:option selected="true" value="numeroProgetto">Numero Progetto</aui:option> |
||||
<aui:option value="protocollo">Protocollo</aui:option> |
||||
<aui:option value="createDate">Data Invio</aui:option> |
||||
<aui:option value="tipoPratica">Tipo Pratica</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="ordinaTipo" label="Tipo Ordine"> |
||||
<aui:option selected="true" value="dec">Dec</aui:option> |
||||
<aui:option value="asc">Asc</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<aui:button type="submit" value="search" /> |
||||
</div> |
||||
</liferay-ui:panel> |
||||
|
||||
<liferay-portlet:resourceURL id="unitaOperative" var="getUnitaOperativeUrl" /> |
||||
<liferay-portlet:resourceURL id="province" var="getProvinceURL" /> |
||||
<liferay-portlet:resourceURL id="comuni" var="getComuniURL" /> |
||||
<liferay-portlet:resourceURL id="istruttore" var="getIstruttoriUrl" /> |
||||
<liferay-portlet:resourceURL id="geologo" var="getGeologoUrl" /> |
||||
|
||||
<aui:script use="aui-io-request,liferay-dynamic-select"> |
||||
var getUnitaOperative = function(callback) { |
||||
A.io.request('<%= getUnitaOperativeUrl %>', { |
||||
dataType: 'json', |
||||
on: { |
||||
success: function() { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getProvince = function(callback) { |
||||
A.io.request('<%= getProvinceURL %>', { |
||||
dataType: 'json', |
||||
on: { |
||||
success: function() { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getComuni = function(callback, provinciaId) { |
||||
A.io.request('<%= getComuniURL %>', { |
||||
data: { |
||||
<portlet:namespace />provinciaId: provinciaId, |
||||
}, |
||||
dataType: 'json', |
||||
on: { |
||||
success: function() { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getIstruttori = function(callback, uoId) { |
||||
A.io.request('<%= getIstruttoriUrl %>', { |
||||
data: { |
||||
<portlet:namespace />uoId: uoId, |
||||
}, |
||||
dataType: 'json', |
||||
on: { |
||||
success: function() { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getGeologo = function(callback) { |
||||
A.io.request('<%= getGeologoUrl %>', { |
||||
dataType: 'json', |
||||
on: { |
||||
success: function() { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
new Liferay.DynamicSelect([ |
||||
{ |
||||
select: '<portlet:namespace />provincia', |
||||
selectData: getProvince, |
||||
selectDesc: 'descLong', |
||||
selectId: 'provinciaId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(provinciaSelect) ? StringPool.BLANK : provinciaSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace />comune', |
||||
selectData: getComuni, |
||||
selectDesc: 'descLong', |
||||
selectId: 'comuneId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(comuneSelect) ? StringPool.BLANK : comuneSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace />unitaOperativa', |
||||
selectData: getUnitaOperative, |
||||
selectDesc: 'descLong', |
||||
selectId: 'uoId', |
||||
selectSort: false, |
||||
selectVal: '<%= Validator.isNull(uoSelect) ? StringPool.BLANK : uoSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace />istruttore', |
||||
selectData: getIstruttori, |
||||
selectDesc: 'descLong', |
||||
selectId: 'istruttoreId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(istruttoreSelect) ? StringPool.BLANK : istruttoreSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace />geologi', |
||||
selectData: getGeologo, |
||||
selectDesc: 'descLong', |
||||
selectId: 'geologoId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(geologoSelect) ? StringPool.BLANK : geologoSelect %>', |
||||
}, |
||||
]); |
||||
</aui:script> |
@ -0,0 +1,339 @@
|
||||
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> |
||||
<%@page import="it.mwg.sismica.bo.shared.util.IndexField"%> |
||||
<%@page import="it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil"%> |
||||
<%@page import="it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants"%> |
||||
<%@page import="java.util.Calendar"%> |
||||
<%@page import="java.text.DateFormat"%> |
||||
<%@page import="java.util.Map.Entry"%> |
||||
<%@include file="/html/gestioneattivita/init.jsp"%> |
||||
<% |
||||
String provinciaSelect = ParamUtil.getString(renderRequest, IndexField.CODICE_PROVINCIA); |
||||
String comuneSelect = ParamUtil.getString(renderRequest, IndexField.COMUNE_ID); |
||||
String istruttoreSelect = ParamUtil.getString(renderRequest, IndexField.ISTRUTTORE_ID); |
||||
String uoSelect = ParamUtil.getString(renderRequest, IndexField.UNITA_OPERATIVA); |
||||
String geologoSelect = ParamUtil.getString(renderRequest, IndexField.GEOLOGO_ID); |
||||
String pareriFornitiSelect = ParamUtil.getString(renderRequest, IndexField.PARERI_FORNITI); |
||||
String orderByColSelect = ParamUtil.getString(renderRequest, "orderByCol", IndexField.NUMERO_PROGETTO); |
||||
String orderByTypeSelect = ParamUtil.getString(renderRequest, "orderByType", "dec"); |
||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy"); |
||||
Calendar richiestaDa = null; |
||||
String data = ParamUtil.getString(renderRequest, IndexField.DATA_RICHIESTA_DA); |
||||
if (Validator.isNotNull(data)) { |
||||
richiestaDa = Calendar.getInstance(); |
||||
richiestaDa.setTime(format.parse(data)); |
||||
} |
||||
Calendar richiestaA = null; |
||||
data = ParamUtil.getString(renderRequest, IndexField.DATA_RICHIESTA_A); |
||||
if (Validator.isNotNull(data)) { |
||||
richiestaA = Calendar.getInstance(); |
||||
richiestaA.setTime(format.parse(data)); |
||||
} |
||||
Calendar esitoDa = null; |
||||
data = ParamUtil.getString(renderRequest, IndexField.DATA_ESITO_DA); |
||||
if (Validator.isNotNull(data)) { |
||||
esitoDa = Calendar.getInstance(); |
||||
esitoDa.setTime(format.parse(data)); |
||||
} |
||||
Calendar esitoA = null; |
||||
data = ParamUtil.getString(renderRequest, IndexField.DATA_ESITO_A); |
||||
if (Validator.isNotNull(data)) { |
||||
esitoA = Calendar.getInstance(); |
||||
esitoA.setTime(format.parse(data)); |
||||
} |
||||
%> |
||||
<liferay-ui:panel title="filters" defaultState="closed" |
||||
id='<%= renderResponse.getNamespace() + scopeGroupId + "ricercaSaiPanel" %>' collapsible="true" |
||||
extended="false" persistState="true"> |
||||
<div class="container-fluid" style="padding: 15px;"> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="numeroProgetto" label="ricercapratiche.numeroProgetto" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="tipoProcedura" label="ricercapratiche.tipoProcedura"> |
||||
<aui:option value="">Seleziona il tipo di pratica</aui:option> |
||||
<% |
||||
for (Entry<String, String> procedura : IntPraticaLocalServiceUtil.getTipiProcedure().entrySet()) { |
||||
String tipo = procedura.getKey(); |
||||
String label = procedura.getValue(); |
||||
String nomeProcedura = LanguageUtil.get(pageContext, "label_procedura_" + tipo) + ") " + label; |
||||
if (nomeProcedura.length() > 120) { |
||||
nomeProcedura = nomeProcedura.substring(0, 117) + "..."; |
||||
} |
||||
%> |
||||
<aui:option value="<%= tipo %>"><%= nomeProcedura %></aui:option> |
||||
<% |
||||
} |
||||
for (Entry<String, String> procedura : IntPraticaLocalServiceUtil.getVecchieProcedure().entrySet()) { |
||||
String tipo = procedura.getKey(); |
||||
String label = procedura.getValue(); |
||||
String nomeProcedura = LanguageUtil.get(pageContext, "label_procedura_" + tipo) + ") " + label; |
||||
if (nomeProcedura.length() > 120) { |
||||
nomeProcedura = nomeProcedura.substring(0, 117) + "..."; |
||||
} |
||||
%> |
||||
<aui:option style="color:#888888;font-style:italic" |
||||
value="<%= tipo %>"><i><%= nomeProcedura %></i></aui:option> |
||||
<% |
||||
} |
||||
%> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="<%= IndexField.CODICE_PROVINCIA %>" label="Provincia" cssClass="provinciaSelect" /> |
||||
</div> |
||||
<div class="col-sm-12 col-md-3 add-new-project__comune"> |
||||
<aui:select name="<%= IndexField.COMUNE_ID %>" label="Comune" /> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="<%= IndexField.TITOLARE %>" label="Titolare Digitale" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="<%= IndexField.COMMITTENTE %>" label="Committente" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:input type="text" name="<%= IndexField.SOGGETTO %>" label="Soggetti Interconnessi" /> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-1"> |
||||
<aui:select name="<%= IndexField.UNITA_OPERATIVA %>" label="unita-operativa" cssClass="uoSelect" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-2"> |
||||
<aui:select name="<%= IndexField.ISTRUTTORE_ID %>" label="Istruttore" cssClass="istruttoreSelect" |
||||
disabled="<%= tabs1.equals(tabs[0]) %>"/> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="<%= IndexField.GEOLOGO_ID %>" label="Parere endoprocedimentale" cssClass="geologoSelect" /> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="<%= IndexField.PARERI_FORNITI %>" label="Parere fornito"> |
||||
<aui:option value="">Tutte</aui:option> |
||||
<aui:option selected='<%= "true".equals(pareriFornitiSelect) %>' value="true">Sì</aui:option> |
||||
<aui:option selected='<%= "false".equals(pareriFornitiSelect) %>' value="false">No</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-12"> |
||||
<aui:field-wrapper label="Data richiesta da" inlineField="true"> |
||||
<liferay-util:include page="/html/common/input_date_time.jsp" servletContext="<%= application %>"> |
||||
<liferay-util:param name="field" value="<%= IndexField.DATA_RICHIESTA_DA %>" /> |
||||
<c:if test="<%= Validator.isNotNull(richiestaDa) %>"> |
||||
<liferay-util:param name="fieldParam" value="Set" /> |
||||
<liferay-util:param name="SetYear" value="<%= String.valueOf(richiestaDa.get(Calendar.YEAR)) %>" /> |
||||
<liferay-util:param name="SetMonth" value="<%= String.valueOf(richiestaDa.get(Calendar.MONTH)) %>" /> |
||||
<liferay-util:param name="SetDay" value="<%= String.valueOf(richiestaDa.get(Calendar.DAY_OF_MONTH)) %>" /> |
||||
</c:if> |
||||
</liferay-util:include> |
||||
</aui:field-wrapper> |
||||
<aui:field-wrapper label="a" inlineField="true"> |
||||
<liferay-util:include page="/html/common/input_date_time.jsp" servletContext="<%= application %>"> |
||||
<liferay-util:param name="field" value="<%= IndexField.DATA_RICHIESTA_A %>" /> |
||||
<c:if test="<%= Validator.isNotNull(richiestaA) %>"> |
||||
<liferay-util:param name="fieldParam" value="Set" /> |
||||
<liferay-util:param name="SetYear" value="<%= String.valueOf(richiestaA.get(Calendar.YEAR)) %>" /> |
||||
<liferay-util:param name="SetMonth" value="<%= String.valueOf(richiestaA.get(Calendar.MONTH)) %>" /> |
||||
<liferay-util:param name="SetDay" value="<%= String.valueOf(richiestaA.get(Calendar.DAY_OF_MONTH)) %>" /> |
||||
</c:if> |
||||
</liferay-util:include> |
||||
</aui:field-wrapper> |
||||
<aui:field-wrapper label="Data esito da" inlineField="true"> |
||||
<liferay-util:include page="/html/common/input_date_time.jsp" servletContext="<%= application %>"> |
||||
<liferay-util:param name="field" value="<%= IndexField.DATA_ESITO_DA %>" /> |
||||
<c:if test="<%= Validator.isNotNull(esitoDa) %>"> |
||||
<liferay-util:param name="fieldParam" value="Set" /> |
||||
<liferay-util:param name="SetYear" value="<%= String.valueOf(esitoDa.get(Calendar.YEAR)) %>" /> |
||||
<liferay-util:param name="SetMonth" value="<%= String.valueOf(esitoDa.get(Calendar.MONTH)) %>" /> |
||||
<liferay-util:param name="SetDay" value="<%= String.valueOf(esitoDa.get(Calendar.DAY_OF_MONTH)) %>" /> |
||||
</c:if> |
||||
</liferay-util:include> |
||||
</aui:field-wrapper> |
||||
<aui:field-wrapper label="a" inlineField="true"> |
||||
<liferay-util:include page="/html/common/input_date_time.jsp" servletContext="<%= application %>"> |
||||
<liferay-util:param name="field" value="<%= IndexField.DATA_ESITO_A %>" /> |
||||
<c:if test="<%= Validator.isNotNull(esitoA) %>"> |
||||
<liferay-util:param name="fieldParam" value="Set" /> |
||||
<liferay-util:param name="SetYear" value="<%= String.valueOf(esitoA.get(Calendar.YEAR)) %>" /> |
||||
<liferay-util:param name="SetMonth" value="<%= String.valueOf(esitoA.get(Calendar.MONTH)) %>" /> |
||||
<liferay-util:param name="SetDay" value="<%= String.valueOf(esitoA.get(Calendar.DAY_OF_MONTH)) %>" /> |
||||
</c:if> |
||||
</liferay-util:include> |
||||
</aui:field-wrapper> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="<%= IndexField.WORKFLOW_STATE %>" label="Attività"> |
||||
<aui:option value="">Tutte</aui:option> |
||||
<aui:option value="Assegnazione">Assegnazione</aui:option> |
||||
<aui:option value="Approvazione">Approvazione</aui:option> |
||||
<aui:option value="Annullato">Annullato</aui:option> |
||||
<aui:option value="Esito">Esito</aui:option> |
||||
<aui:option value="NonApprovato">Non Approvato</aui:option> |
||||
<aui:option value="signal_cittadino">Richiesta Integrazione</aui:option> |
||||
<aui:option value="signal_ff">Firma</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="<%= IndexField.STATO_PRATICA %>" label="Esito"> |
||||
<aui:option value="">Tutti</aui:option> |
||||
<% |
||||
for (String esito : new String[] { |
||||
StatoPraticaConstants.AUTORIZZATA, |
||||
StatoPraticaConstants.ANNULLATA, |
||||
StatoPraticaConstants.INTEGRAZIONE, |
||||
StatoPraticaConstants.NO_PARERE, |
||||
StatoPraticaConstants.NON_AUTORIZZATA, |
||||
StatoPraticaConstants.PREAVVISO_CONTRARIO, |
||||
StatoPraticaConstants.PERIZIA_SANZIONE, |
||||
StatoPraticaConstants.DECRETO_SANZIONE, |
||||
}) { |
||||
%> |
||||
<aui:option value="<%= esito %>" label='<%= "stato-pratica-" + esito %>' /> |
||||
<% |
||||
} |
||||
%> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="orderByCol" label="Ordina Per"> |
||||
<% |
||||
for (String col : Arrays.asList(IndexField.WORKFLOW_STATE, IndexField.NUMERO_PROGETTO, |
||||
IndexField.DATA_RICHIESTA, IndexField.TIPO_PROCEDURA)) { |
||||
%> |
||||
<aui:option selected="<%= col.equalsIgnoreCase(orderByColSelect) %>" value="<%= col %>" |
||||
label='<%= "ricercapratiche." + col %>' /> |
||||
<% |
||||
} |
||||
%> |
||||
</aui:select> |
||||
</div> |
||||
<div class="col-xs-12 col-md-3"> |
||||
<aui:select name="orderByType" label="Tipo Ordine"> |
||||
<aui:option value="asc">Crescente</aui:option> |
||||
<aui:option selected='<%= "dec".equals(orderByTypeSelect) %>' value="dec">Decrescente</aui:option> |
||||
</aui:select> |
||||
</div> |
||||
</div> |
||||
<aui:button type="submit" value="search" /> |
||||
</div> |
||||
</liferay-ui:panel> |
||||
|
||||
<liferay-portlet:resourceURL id="unitaOperative" var="getUnitaOperativeUrl" /> |
||||
<liferay-portlet:resourceURL id="province" var="getProvinceURL" /> |
||||
<liferay-portlet:resourceURL id="comuni" var="getComuniURL" /> |
||||
<liferay-portlet:resourceURL id="istruttore" var="getIstruttoriUrl" /> |
||||
<liferay-portlet:resourceURL id="geologo" var="getGeologoUrl" /> |
||||
|
||||
<aui:script use="aui-io-request,liferay-dynamic-select"> |
||||
var getUnitaOperative = function (callback) { |
||||
A.io.request('<%= getUnitaOperativeUrl %>', { |
||||
dataType: 'json', |
||||
on: { |
||||
success: function () { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getProvince = function (callback) { |
||||
A.io.request('<%= getProvinceURL %>', { |
||||
dataType: 'json', |
||||
on: { |
||||
success: function () { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getComuni = function (callback, provinciaId) { |
||||
A.io.request('<%= getComuniURL %>', { |
||||
data: { |
||||
<portlet:namespace />provinciaId: provinciaId, |
||||
}, |
||||
dataType: 'json', |
||||
on: { |
||||
success: function () { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getIstruttori = function (callback, uoId) { |
||||
A.io.request('<%= getIstruttoriUrl %>', { |
||||
data: { |
||||
<portlet:namespace />uoId: uoId, |
||||
}, |
||||
dataType: 'json', |
||||
on: { |
||||
success: function () { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
var getGeologo = function (callback) { |
||||
A.io.request('<%= getGeologoUrl %>', { |
||||
dataType: 'json', |
||||
on: { |
||||
success: function () { |
||||
callback(this.get('responseData')); |
||||
}, |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
new Liferay.DynamicSelect([ |
||||
{ |
||||
select: '<portlet:namespace /><%= IndexField.CODICE_PROVINCIA %>', |
||||
selectData: getProvince, |
||||
selectDesc: 'descLong', |
||||
selectId: 'provinciaId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(provinciaSelect) ? StringPool.BLANK : provinciaSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace /><%= IndexField.COMUNE_ID %>', |
||||
selectData: getComuni, |
||||
selectDesc: 'descLong', |
||||
selectId: 'comuneId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(comuneSelect) ? StringPool.BLANK : comuneSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace /><%= IndexField.UNITA_OPERATIVA %>', |
||||
selectData: getUnitaOperative, |
||||
selectDesc: 'descLong', |
||||
selectId: 'uoId', |
||||
selectSort: false, |
||||
selectVal: '<%= Validator.isNull(uoSelect) ? StringPool.BLANK : uoSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace /><%= IndexField.ISTRUTTORE_ID %>', |
||||
selectData: getIstruttori, |
||||
selectDesc: 'descLong', |
||||
selectId: 'istruttoreId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(istruttoreSelect) ? StringPool.BLANK : istruttoreSelect %>', |
||||
}, |
||||
{ |
||||
select: '<portlet:namespace /><%= IndexField.GEOLOGO_ID %>', |
||||
selectData: getGeologo, |
||||
selectDesc: 'descLong', |
||||
selectId: 'geologoId', |
||||
selectSort: true, |
||||
selectVal: '<%= Validator.isNull(geologoSelect) ? StringPool.BLANK : geologoSelect %>', |
||||
}, |
||||
]); |
||||
</aui:script> |
@ -0,0 +1,37 @@
|
||||
package it.mwg.sismica.bo.shared.util; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@SuppressWarnings("serial") |
||||
public class IndexField implements Serializable { |
||||
|
||||
public static final String CODICE_PROVINCIA = "codiceProvincia"; |
||||
public static final String COMMITTENTE = "committente"; |
||||
public static final String COMUNE_ID = "comuneId"; |
||||
public static final String CONTROLLO_PRATICA_ID = "controlloPraticaId"; |
||||
public static final String DATA_ESITO = "dataEsito"; |
||||
public static final String DATA_ESITO_A = "dataEsitoA"; |
||||
public static final String DATA_ESITO_DA = "dataEsitoDa"; |
||||
public static final String DATA_RICHIESTA = "dataRichiesta"; |
||||
public static final String DATA_RICHIESTA_A = "dataRichiestaA"; |
||||
public static final String DATA_RICHIESTA_DA = "dataRichiestaDa"; |
||||
public static final String GEOLOGO_ID = "geologoId"; |
||||
public static final String IN_COMPILAZIONE = "inCompilazione"; |
||||
public static final String IN_LAVORAZIONE_SUE = "inLavorazioneSue"; |
||||
public static final String INT_PRATICA_ID = "intPraticaId"; |
||||
public static final String ISTRUTTORE = "istruttore"; |
||||
public static final String ISTRUTTORE_ID = "istruttoreId"; |
||||
public static final String NUMERO_PROGETTO = "numeroProgetto"; |
||||
public static final String PARERI_FORNITI = "pareriForniti"; |
||||
public static final String PRATICA_APERTA = "praticaAperta"; |
||||
public static final String SOGGETTO = "soggetto"; |
||||
public static final String STATO_PRATICA = "statoPratica"; |
||||
public static final String STATUS = "status"; |
||||
public static final String TASK = "task"; |
||||
public static final String TASK_ASSIGNEE_ROLE_IDS = "taskAssigneeRoleIds"; |
||||
public static final String TASK_ASSIGNEE_USER_ID = "taskAssigneeUserId"; |
||||
public static final String TIPO_PROCEDURA = "tipoProcedura"; |
||||
public static final String TITOLARE = "titolare"; |
||||
public static final String UNITA_OPERATIVA = "unitaOperativa"; |
||||
public static final String WORKFLOW_STATE = "workflowState"; |
||||
} |
@ -1,70 +0,0 @@
|
||||
package it.mwg.sismica.bo.shared.util; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@SuppressWarnings("serial") |
||||
public class PortosIndexField implements Serializable { |
||||
|
||||
public static final String INT_PRATICA_ID = "intPraticaId"; |
||||
public static final String CONTROLLO_PRATICA_ID = "controlloPraticaId"; |
||||
public static final String DETT_PRATICA_ID = "dettPraticaId"; |
||||
public static final String NUMERO_PROGETTO = "numeroProgetto"; |
||||
public static final String PROTOCOLLO = "protocollo"; |
||||
public static final String TIPO_PRATICA = "tipoPratica"; |
||||
public static final String DETT_PRATICA = "dettPratica"; |
||||
public static final String STATO_PRATICA = "statoPratica"; |
||||
public static final String DESC_INTERVENTO = "descIntervento"; |
||||
public static final String COMMITTENTE = "committente"; |
||||
public static final String COMMITTENTI = "committenti"; |
||||
public static final String DIRETTORE_LAVORI = "direttoreLavori"; |
||||
public static final String COLLAUDATORI = "collaudatori"; |
||||
public static final String DATA_RICHIESTA = "dataRichiesta"; |
||||
public static final String DT_PRATICA = "dtPratica"; |
||||
public static final String DATA_RICHIESTA_DA = "dataRichiestaDa"; |
||||
public static final String DATA_RICHIESTA_AL = "dataRichiestaAl"; |
||||
public static final String STATUS = "status"; |
||||
public static final String STATUS_SOSPESA = "sospesa"; |
||||
public static final String PRATICA_APERTA = "praticaAperta"; |
||||
public static final String STATUS_BY_USERID = "statusByUserId"; |
||||
public static final String STATUS_BY_USERNAME = "statusByUsername"; |
||||
public static final String STATUS_DATE = "statusDate"; |
||||
public static final String SOGGETTI_INTERCONNESSI = "soggettiInterconnessi"; |
||||
public static final String SOGGETTI_INTERESSATI = "soggettiInteressati"; |
||||
public static final String SOTTOPOSTO_A_PARERE = "sottopostoAParere"; |
||||
public static final String FINE_LAVORI_COMPLETATI = "fineLavoriCompletati"; |
||||
public static final String COLLAUDO_COMPLETATO = "collaudoCompletato"; |
||||
public static final String FINE_LAVORI_PARZIALI = "fineLavoriParziali"; |
||||
public static final String VARIATA = "variata"; |
||||
public static final String VIDIMATA = "vidimata"; |
||||
public static final String COLLAUDO_PARZIALE = "collaudoParziale"; |
||||
public static final String ISTRUTTORE_USER_ID = "istruttoreUserId"; |
||||
public static final String ISTRUTTORE_FULL_NAME = "istruttoreFullName"; |
||||
public static final String PROPRIETARIO_DIGITALE_FULL_NAME = "proprietarioDigitaleFullName"; |
||||
public static final String ISTRUTTORE_USERNAME = "istruttoreUsername"; |
||||
public static final String PARERE_GEOLOGO = "parereGeologo"; |
||||
public static final String GEOLOGI = "geologi"; |
||||
public static final String COMUNE_ID = "comuneId"; |
||||
public static final String COMUNE_DENOMINAZIONE = "comuneDenominazione"; |
||||
public static final String PROVINCIA_ID = "provinciaId"; |
||||
public static final String PROVINCIA_CODICE = "codiceProvincia"; |
||||
public static final String PROVINCIA_NAME = "nomeProvincia"; |
||||
public static final String DATA_INIZIO_PROCEDIMENTO = "dataInizioProcedimento"; |
||||
public static final String TASK_ASSIGNEE_USER_ID = "taskAssigneeUserId"; |
||||
public static final String TASK_ASSIGNEE_ROLE_IDS = "taskAssigneeRoleIds"; |
||||
public static final String WORKFLOW_DEFINITION_NAME = "workflowDefinitionName"; |
||||
public static final String WORKFLOW_DEFINITION_VERSION = "workflowDefinitionVersion"; |
||||
public static final String TASK_NAME = "taskName"; |
||||
public static final String WORKFLOW_STATE = "workflowState"; |
||||
public static final String NUOVA_COSTRUZIONE = "nuovaCostruzione"; |
||||
public static final String ADEGUAMENTO_SISMICO = "adeguamentoSismico"; |
||||
public static final String MIGLIORAMENTO_SISMICO = "miglioramentoSismico"; |
||||
public static final String RIPARAZIONE_INTERVENTO_LOCALE = "riparazioneInterventoLocale"; |
||||
public static final String INDIRIZZO = "indirizzo"; |
||||
public static final String LOCALITA = "localita"; |
||||
public static final String PROVINCIA = "provincia"; |
||||
public static final String COMUNE = "comune"; |
||||
public static final String TIPO_PROCEDURA = "tipoProcedura"; |
||||
public static final String UNITA_OPERATIVA = "unitaOperativa"; |
||||
public static final String IN_LAVORAZIONE_SUE = "inLavorazioneSue"; |
||||
public static final String ASSEGNATA_AD_ISTRUTTORE = "assegnataAdIstruttore"; |
||||
} |
Caricamento…
Reference in new issue