|
|
|
@ -3,6 +3,8 @@ package it.tref.liferay.portos.bo.search;
|
|
|
|
|
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 it.tref.liferay.portos.bo.shared.util.UnitaOperativeUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.util.PortosIndexField; |
|
|
|
|
import it.tref.liferay.portos.bo.util.WorkflowConstants; |
|
|
|
|
|
|
|
|
|
import java.text.DateFormat; |
|
|
|
@ -11,7 +13,6 @@ import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map.Entry; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
@ -59,24 +60,13 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
public static final DateFormat DATE_FORMAT_STRING = new SimpleDateFormat("dd/MM/yyyy"); |
|
|
|
|
|
|
|
|
|
public static Hits searchMieiTask(HttpServletRequest request, User user, int start, int end) { |
|
|
|
|
|
|
|
|
|
// Parametro proveniente dalla ricerca
|
|
|
|
|
int ufficioSearch = ParamUtil.getInteger(request, "ufficio"); |
|
|
|
|
|
|
|
|
|
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
|
|
|
|
|
|
|
|
|
SearchContext searchContext = SearchContextFactory.getInstance(request); |
|
|
|
|
|
|
|
|
|
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
|
|
|
|
|
|
|
|
|
if (searchForExport) { |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
@ -85,7 +75,6 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
|
|
|
|
|
// Gestione Ordinamento
|
|
|
|
|
searchContext.setSorts(getOrderedQuery(request)); |
|
|
|
|
|
|
|
|
|
Hits hits = null; |
|
|
|
|
try { |
|
|
|
|
// Condizioni necessarie per questa ricerca :
|
|
|
|
@ -104,50 +93,36 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
|
|
|
|
|
// Ricavo i groupId relativi all utente che effettua la ricerca per
|
|
|
|
|
// filtrare
|
|
|
|
|
|
|
|
|
|
if (ufficioSearch != 0 && ufficioSearch != -1) { |
|
|
|
|
|
|
|
|
|
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
|
|
|
|
ufficioSearch); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
@ -156,24 +131,13 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Hits searchTaskMieiRuoli(HttpServletRequest request, User user, int start, int end) { |
|
|
|
|
|
|
|
|
|
// Parametro proveniente dalla ricerca
|
|
|
|
|
int ufficioSearch = ParamUtil.getInteger(request, "ufficio"); |
|
|
|
|
|
|
|
|
|
SearchContext searchContext = SearchContextFactory.getInstance(request); |
|
|
|
|
|
|
|
|
|
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
|
|
|
|
|
|
|
|
|
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
|
|
|
|
|
|
|
|
|
if (searchForExport) { |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
@ -184,29 +148,24 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
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); |
|
|
|
@ -226,42 +185,45 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
|
|
|
|
|
// Ricavo i groupId relativi all utente che effettua la ricerca per
|
|
|
|
|
// filtrare
|
|
|
|
|
|
|
|
|
|
if (ufficioSearch != 0 && ufficioSearch != -1) { |
|
|
|
|
|
|
|
|
|
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
|
|
|
|
ufficioSearch); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Integer> uos = UnitaOperativeUtil.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()); |
|
|
|
|
} |
|
|
|
|
_log.info("User " + user.getScreenName() + " Request query : " + booleanQuery.toString()); |
|
|
|
|
|
|
|
|
|
hits = SearchEngineUtil.search(searchContext, booleanQuery); |
|
|
|
|
|
|
|
|
@ -276,26 +238,14 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Hits searchAltriTask(HttpServletRequest request, User user, int start, int end) { |
|
|
|
|
|
|
|
|
|
// List<ControlloPratica> lista = new ArrayList<ControlloPratica>();
|
|
|
|
|
|
|
|
|
|
// Parametro proveniente dalla ricerca
|
|
|
|
|
int ufficioSearch = ParamUtil.getInteger(request, "ufficio"); |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
@ -306,7 +256,6 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
searchContext.setSorts(getOrderedQuery(request)); |
|
|
|
|
Hits hits = null; |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
// Condizioni necessarie per questa ricerca :
|
|
|
|
|
// entryClassName=ControlloPratica &
|
|
|
|
|
// roleIds non e tra i taskAssigneeIds
|
|
|
|
@ -323,7 +272,6 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
for (Organization org : organizationUserList) { |
|
|
|
|
organizationRoleList = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), |
|
|
|
|
org.getGroupId()); |
|
|
|
|
|
|
|
|
|
for (Role role : organizationRoleList) { |
|
|
|
|
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, "taskAssigneeRoleIds", |
|
|
|
|
(role.getRoleId() + "-" + org.getGroupId())); |
|
|
|
@ -348,72 +296,39 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
|
|
|
|
|
// Ricavo i groupId relativi all utente che effettua la ricerca per
|
|
|
|
|
// filtrare
|
|
|
|
|
|
|
|
|
|
if (ufficioSearch != 0 && ufficioSearch != -1) { |
|
|
|
|
|
|
|
|
|
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "groupId", |
|
|
|
|
ufficioSearch); |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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 e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SearchException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
} catch (ParseException | SearchException | SystemException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return hits; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -421,119 +336,62 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
// BooleanQuery booleanQueryAttivita =
|
|
|
|
|
// BooleanQueryFactoryUtil.create(searchContext);
|
|
|
|
|
// TermQuery assegnazioneTerm =
|
|
|
|
|
// TermQueryFactoryUtil.create(searchContext, "workflowState",
|
|
|
|
|
// " Assegnazione");
|
|
|
|
|
// TermQuery approvazioneTerm =
|
|
|
|
|
// TermQueryFactoryUtil.create(searchContext, "workflowState",
|
|
|
|
|
// "Approvazione");
|
|
|
|
|
//
|
|
|
|
|
// booleanQueryAttivita.add(assegnazioneTerm,
|
|
|
|
|
// BooleanClauseOccur.SHOULD);
|
|
|
|
|
// booleanQueryAttivita.add(approvazioneTerm,
|
|
|
|
|
// BooleanClauseOccur.SHOULD);
|
|
|
|
|
//
|
|
|
|
|
// booleanQuery.add(booleanQueryAttivita, BooleanClauseOccur.MUST);
|
|
|
|
|
|
|
|
|
|
String dataDaSearch = ParamUtil.getString(request, "dataRichiestaInizio"); |
|
|
|
|
String dataAlSearch = ParamUtil.getString(request, "dataRichiestaFine"); |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch != null && !dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch != null && !dataAlSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDaSearch); |
|
|
|
|
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAlSearch); |
|
|
|
|
|
|
|
|
|
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
|
|
|
|
"dataInizioProcedimento", DATE_FORMAT_LUCENE.format(dataDaApp), |
|
|
|
|
DATE_FORMAT_LUCENE.format(dataAlApp), true, true); |
|
|
|
|
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch == null || dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch != null && !dataDaSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAlSearch); |
|
|
|
|
|
|
|
|
|
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
|
|
|
|
"dataInizioProcedimento", "00000000", DATE_FORMAT_LUCENE.format(dataAlApp), true, |
|
|
|
|
true); |
|
|
|
|
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch != null && !dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch == null || dataAlSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDaSearch); |
|
|
|
|
|
|
|
|
|
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", DATE_FORMAT_LUCENE.format(dataDaApp), |
|
|
|
|
DATE_FORMAT_LUCENE.format(new Date()), true, true); |
|
|
|
|
"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()); |
|
|
|
|
_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 e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SearchException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (java.text.ParseException e) { |
|
|
|
|
} catch (ParseException | SearchException | SystemException | java.text.ParseException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -542,19 +400,13 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
@ -562,128 +414,63 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
// BooleanQuery booleanQueryAttivita =
|
|
|
|
|
// BooleanQueryFactoryUtil.create(searchContext);
|
|
|
|
|
// TermQuery assegnazioneTerm =
|
|
|
|
|
// TermQueryFactoryUtil.create(searchContext, "workflowState",
|
|
|
|
|
// " Assegnazione");
|
|
|
|
|
// TermQuery approvazioneTerm =
|
|
|
|
|
// TermQueryFactoryUtil.create(searchContext, "workflowState",
|
|
|
|
|
// "Approvazione");
|
|
|
|
|
//
|
|
|
|
|
// booleanQueryAttivita.add(assegnazioneTerm,
|
|
|
|
|
// BooleanClauseOccur.SHOULD);
|
|
|
|
|
// booleanQueryAttivita.add(approvazioneTerm,
|
|
|
|
|
// BooleanClauseOccur.SHOULD);
|
|
|
|
|
//
|
|
|
|
|
// booleanQuery.add(booleanQueryAttivita, BooleanClauseOccur.MUST);
|
|
|
|
|
|
|
|
|
|
String dataDaSearch = ParamUtil.getString(request, "dataRichiestaInizio"); |
|
|
|
|
String dataAlSearch = ParamUtil.getString(request, "dataRichiestaFine"); |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch != null && !dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch != null && !dataAlSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDaSearch); |
|
|
|
|
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAlSearch); |
|
|
|
|
|
|
|
|
|
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
|
|
|
|
"dataInizioProcedimento", DATE_FORMAT_LUCENE.format(dataDaApp), |
|
|
|
|
DATE_FORMAT_LUCENE.format(dataAlApp), true, true); |
|
|
|
|
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch == null || dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch != null && !dataDaSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAlSearch); |
|
|
|
|
|
|
|
|
|
TermRangeQuery dateSearchTermRangeQuery = TermRangeQueryFactoryUtil.create(searchContext, |
|
|
|
|
"dataInizioProcedimento", "00000000", DATE_FORMAT_LUCENE.format(dataAlApp), true, |
|
|
|
|
true); |
|
|
|
|
booleanQuery.add(dateSearchTermRangeQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch != null && !dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch == null || dataAlSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDaSearch); |
|
|
|
|
|
|
|
|
|
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", DATE_FORMAT_LUCENE.format(dataDaApp), |
|
|
|
|
DATE_FORMAT_LUCENE.format(new Date()), true, true); |
|
|
|
|
"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 e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SearchException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (java.text.ParseException e) { |
|
|
|
|
} 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) { |
|
|
|
|
|
|
|
|
|
// List<ControlloPratica> lista = new ArrayList<ControlloPratica>();
|
|
|
|
|
|
|
|
|
|
SearchContext searchContext = SearchContextFactory.getInstance(request); |
|
|
|
|
|
|
|
|
|
searchContext.setKeywords(OVERRIDE_KEYWORDS.toString()); |
|
|
|
|
|
|
|
|
|
boolean searchForExport = ParamUtil.getBoolean(request, "searchForExport", false); |
|
|
|
|
|
|
|
|
|
if (searchForExport) { |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
@ -709,17 +496,13 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
for (Organization org : organizationUserList) { |
|
|
|
|
organizationRoleList = RoleLocalServiceUtil.getUserGroupRoles(user.getUserId(), |
|
|
|
|
org.getGroupId()); |
|
|
|
|
|
|
|
|
|
for (Role role : organizationRoleList) { |
|
|
|
|
TermQuery roleIdTerm = TermQueryFactoryUtil.create(searchContext, "taskAssigneeRoleIds", |
|
|
|
|
(role.getRoleId() + "-" + 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); |
|
|
|
@ -729,10 +512,8 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
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); |
|
|
|
@ -744,19 +525,14 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
// 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); |
|
|
|
@ -768,18 +544,11 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
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 e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SearchException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (SystemException e) { |
|
|
|
|
} catch (ParseException | SearchException | SystemException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -799,8 +568,8 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
// ADT ADT BUG BO ID = 8
|
|
|
|
|
String istruttoreId = ParamUtil.getString(request, "istruttore"); |
|
|
|
|
|
|
|
|
|
String dataDaSearch = ParamUtil.getString(request, "dataRichiestaInizio"); |
|
|
|
|
String dataAlSearch = ParamUtil.getString(request, "dataRichiestaFine"); |
|
|
|
|
String dataDa = ParamUtil.getString(request, "dataRichiestaInizio"); |
|
|
|
|
String dataAl = ParamUtil.getString(request, "dataRichiestaFine"); |
|
|
|
|
String comune = ParamUtil.getString(request, "comune"); |
|
|
|
|
String tipoProcedura = ParamUtil.getString(request, "tipoProcedura"); |
|
|
|
|
String tipoAttivita = ParamUtil.getString(request, "tipoAttivita"); |
|
|
|
@ -808,28 +577,22 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
// ADT - BUG-11 Aggiunta filtro ricerca
|
|
|
|
|
String controlloObbligatorioSearch = ParamUtil.getString(request, "controlloObbligatorio"); |
|
|
|
|
String sorteggiataSearch = ParamUtil.getString(request, "sorteggiata"); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
if (tipoAttivita != null && !tipoAttivita.equals("") && !tipoAttivita.equals("-1")) { |
|
|
|
|
TermQuery tipoAttivitaTermQuery = TermQueryFactoryUtil.create(searchContext, "workflowState", |
|
|
|
|
tipoAttivita); |
|
|
|
|
booleanQuery.add(tipoAttivitaTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (numeroProgettoSearch != null && !numeroProgettoSearch.equals("")) { |
|
|
|
|
TermQuery numeroProgettoTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"numeroProgetto", numeroProgettoSearch); |
|
|
|
|
booleanQuery.add(numeroProgettoTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (protocolloSearch != null && !protocolloSearch.equals("")) { |
|
|
|
|
TermQuery protocolloSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"protocollo", protocolloSearch); |
|
|
|
|
booleanQuery.add(protocolloSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (tipoPraticaSearch != null && !tipoPraticaSearch.equals("") && !tipoPraticaSearch.equals("-1")) { |
|
|
|
|
TermQuery tipoPraticaSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"tipoPratica", tipoPraticaSearch); |
|
|
|
@ -839,118 +602,84 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
// Gestione StatoPratica
|
|
|
|
|
if (statoPraticaSearch != null && !statoPraticaSearch.equals("") |
|
|
|
|
&& !statoPraticaSearch.equals("-1")) { |
|
|
|
|
|
|
|
|
|
if (statoPraticaSearch.equals(StatoPraticaConstants.COLLAUDO_PARZIALE)) { |
|
|
|
|
|
|
|
|
|
TermQuery collaudoParzialeSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"collaudoParziale", "true"); |
|
|
|
|
booleanQuery.add(collaudoParzialeSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else if (statoPraticaSearch.equals(StatoPraticaConstants.COLLAUDO)) { |
|
|
|
|
|
|
|
|
|
TermQuery collaudoSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"collaudoCompletato", "true"); |
|
|
|
|
booleanQuery.add(collaudoSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else if (statoPraticaSearch.equals(StatoPraticaConstants.FINE_LAVORI)) { |
|
|
|
|
|
|
|
|
|
TermQuery fineLavoriSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"fineLavoriCompletati", "true"); |
|
|
|
|
booleanQuery.add(fineLavoriSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else if (statoPraticaSearch.equals(StatoPraticaConstants.FINE_LAVORI_PARZIALE)) { |
|
|
|
|
|
|
|
|
|
TermQuery fineLavoriParzialiSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"fineLavoriParziali", "true"); |
|
|
|
|
booleanQuery.add(fineLavoriParzialiSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else if (statoPraticaSearch.equals(StatoPraticaConstants.SORTEGGIATA)) { |
|
|
|
|
|
|
|
|
|
TermQuery sorteggiataSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"lavorazioneSorteggiata", "true"); |
|
|
|
|
booleanQuery.add(sorteggiataSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else if (statoPraticaSearch.equals(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) { |
|
|
|
|
|
|
|
|
|
TermQuery sottopostaParereSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"sottopostoAParere", "true"); |
|
|
|
|
booleanQuery.add(sottopostaParereSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else if (statoPraticaSearch.equals(StatoPraticaConstants.VARIATA)) { |
|
|
|
|
|
|
|
|
|
TermQuery sottopostaParereSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"variata", "true"); |
|
|
|
|
booleanQuery.add(sottopostaParereSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
TermQuery statoPraticaSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"statoPratica", statoPraticaSearch); |
|
|
|
|
booleanQuery.add(statoPraticaSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (committenteSearch != null && !committenteSearch.equals("")) { |
|
|
|
|
TermQuery committenteSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"committenti", committenteSearch.toUpperCase()); |
|
|
|
|
booleanQuery.add(committenteSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (soggettiInterconnessiSearch != null && !soggettiInterconnessiSearch.equals("")) { |
|
|
|
|
TermQuery soggettiInterconnessiSearchTermQuery = TermQueryFactoryUtil.create(searchContext, |
|
|
|
|
"soggettiInterconnessi", soggettiInterconnessiSearch.toUpperCase()); |
|
|
|
|
booleanQuery.add(soggettiInterconnessiSearchTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (istruttoreId != null && !istruttoreId.equals("") && !istruttoreId.equals("-1")) { |
|
|
|
|
TermQuery singleGroupIdQuery = TermQueryFactoryUtil.create(searchContext, "istruttoreUserId", |
|
|
|
|
istruttoreId); |
|
|
|
|
booleanQuery.add(singleGroupIdQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
if ((dataDa != null && !dataDa.equals("")) && (dataAl != null && !dataAl.equals(""))) { |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch != null && !dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch != null && !dataAlSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDaSearch); |
|
|
|
|
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAlSearch); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch == null || dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch != null && !dataDaSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataAlApp = DATE_FORMAT_STRING.parse(dataAlSearch); |
|
|
|
|
|
|
|
|
|
if ((dataDa == null || dataDa.equals("")) && (dataAl != null && !dataDa.equals(""))) { |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((dataDaSearch != null && !dataDaSearch.equals("")) |
|
|
|
|
&& (dataAlSearch == null || dataAlSearch.equals(""))) { |
|
|
|
|
|
|
|
|
|
Date dataDaApp = DATE_FORMAT_STRING.parse(dataDaSearch); |
|
|
|
|
|
|
|
|
|
if ((dataDa != null && !dataDa.equals("")) && (dataAl == null || dataAl.equals(""))) { |
|
|
|
|
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 (comune != null && !comune.equals("") && !comune.equals("-1")) { |
|
|
|
|
TermQuery comuneTermQuery = TermQueryFactoryUtil.create(searchContext, "comuneId", comune); |
|
|
|
|
booleanQuery.add(comuneTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Validator.isNotNull(tipoProcedura)) { |
|
|
|
|
TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, "tipoProcedura", |
|
|
|
|
tipoProcedura); |
|
|
|
@ -970,33 +699,24 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
sorteggiataSearch); |
|
|
|
|
booleanQuery.add(sorteggiataTermQuery, BooleanClauseOccur.MUST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} catch (java.text.ParseException e) { |
|
|
|
|
} catch (ParseException | java.text.ParseException e) { |
|
|
|
|
_log.error(e, e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 (orderField != null && !orderField.equals("") && !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("protocollo")) { |
|
|
|
@ -1008,9 +728,7 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
} else if (orderField.equals("tipoPratica")) { |
|
|
|
|
sort.setType(Sort.INT_TYPE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderType != null && !orderType.equals("") && !orderType.equals("-1")) { |
|
|
|
|
if (orderType.equals("desc")) { |
|
|
|
|
sort.setReverse(false); |
|
|
|
@ -1018,9 +736,7 @@ public class ControlloPraticaAdvancedSearch {
|
|
|
|
|
sort.setReverse(true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sortes.add(sort); |
|
|
|
|
|
|
|
|
|
return sortes.toArray(new Sort[0]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|