org.gcube.portlets.user.searchportlet.server
Class SearchServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
              extended by com.google.gwt.user.server.rpc.RemoteServiceServlet
                  extended by org.gcube.portlets.user.searchportlet.server.SearchServlet
All Implemented Interfaces:
com.google.gwt.user.client.rpc.RemoteService, com.google.gwt.user.server.rpc.SerializationPolicyProvider, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, SearchService

public class SearchServlet
extends com.google.gwt.user.server.rpc.RemoteServiceServlet
implements SearchService

Search Servlet

Author:
Panagiota Koltsida, NKUA
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
perThreadRequest, perThreadResponse
 
Constructor Summary
SearchServlet()
           
 
Method Summary
 void addSearchField(SearchableFieldBean sField)
          This method is used to add a new criterion to the active query.
 void addSearchFieldOnPreviousQuery(SearchableFieldBean sField)
          This method is used to add a new criterion on a previous query
 SearchableFieldBean[] createPreviousQuery(int indexOfQueryGroupToClone)
          This method creates a new previous query.
 ArrayList<String> getAvailableLanguages()
           
 ArrayList<BrowsableFieldBean> getBrowsableFields()
          This method retrieves the browsable fields
 Integer getNumberOfSelectedCollections()
          Gets the number of the selected collections, excluding group collections
 LinkedList<PreviousResultsInfo> getPreviousQueries()
          This method retrieves all the previous advanced or simple queries that had been performed.
 SavedBasketQueriesInfo getQueryFromBasket(String id)
          This method gets the information of a specific object that is saved as a Query in basket
 Integer getResultsNumberPerPage()
          This method is used to retrieve the number of results per page that a user has selected in browse
 ArrayList<SearchableFieldBean> getSearchFields()
          This method retrieves the available search fields
 SearchAvailabilityType getSearchStatus()
           
 String getSelectedConditionType()
          This method returns the current condition type, AND | OR
 String getSelectedConditionTypeOnPreviousSearch()
          This method returns the current condition type of a previous query, AND | OR
 ArrayList<SearchableFieldBean> getSelectedFields()
          This method returns the current criteria
 ArrayList<SearchableFieldBean> getSelectedFieldsOnPreviousSearch()
          This method returns the current criteria for a previous query
 String getSelectedLanguage()
           
 Boolean getSelectedRadioBtn()
          This method retrieves the current selected tab of the search portlet
 Integer getSelectedTab()
          This method retrieves the current selected tab of the search portlet
 String getSimpleSearchTerm()
          This method returns the text that was last used in a simple search
 ArrayList<SearchableFieldBean> getSortableFields()
          This method retrieves the sortable fields
 void init(javax.servlet.ServletConfig conf)
          Init Method
 boolean isAdvancedOpen()
           
 Boolean isSemanticAvailableForCurrentScope()
           
 String readPropertyFromFile(String propertyName)
           
 void removeSearchField(int searchFieldNo)
          This method is used to remove a criterion.
 void removeSearchFieldOnPreviousQuery(int searchFieldNo)
          This method is used to remove a criterion on a previous query.
 void resetFields(boolean isPrevious)
          This method is used to reset all the current criteria
 void sendEmailWithErrorToSupport(Throwable caught)
           
 void setAdvancedPanelStatus(boolean isOpened)
           
 Boolean setSelectedLanguage(String language)
           
 void setSelectedRadioBtn(boolean isBasketSelected)
           
 void setSelectedTab(Integer x)
          This method sets the current selected tab to the session
 void setSimpleSearchTerm(String term)
           
 String stackTraceAsString(Throwable caught)
           
 void storeConditionType(String newValue)
          This method is used to change the condition type of the criteria.
 void storeConditionTypeOnPreviousSearch(String newValue)
          This method is used to change the condition type of the selected fields on the previous results portlet.
 void storeSelectedFieldsOnPreviousSearch(int fieldNo, int internalNo, String newValue)
          This method is used to change the name, the value or the operator of the selected field for the 'search previous results functionality, depending on the given parameters.
 void submitAdvancedQuery(ArrayList<SearchableFieldBean> criteria, String sortby, String order, boolean searchPerCollection)
          This method submits the advances query to the underlying system, by using the ASL
 Boolean submitBrowseQuery(BrowsableFieldBean browseBy, String sortOrder, String typeOfBrowse, int resultNumPerPage)
          Submits a browse query
 void submitBrowseQueryOnPreviousResult(int index)
          This method is used to show the results of a query that is already performed in the current session
 void submitGenericQuery(String query, String type)
          This method submits a query that is saved in user's basket
 void submitQueryOnPreviousResult(ArrayList<SearchableFieldBean> criteria, String sortby, String sortOrder, String showRank)
           
 void submitSimpleQuery(String fts, boolean setRanking, boolean isSemanticSearch)
          Submits a simple query
 void updateCriterionName(int internalNo, String newID, String newName)
          This method is used to update the name of the criterion, specified by the internalNo
 void updateCriterionNameOnPreviousQuery(int internalNo, String newID, String newName)
          This method is used to update the name of the criterion, specified by the internalNo in a previous Query
 void updateCriterionValue(int internalNo, String newValue)
          This method is used to update the value of the criterion, specified by the internalNo
 void updateCriterionValueOnPreviousQuery(int internalNo, String newValue)
          This method is used to update the value of the criterion, specified by the internalNo in a previous Query
 
Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet
checkPermutationStrongName, doGetSerializationPolicy, getSerializationPolicy, onAfterResponseSerialized, onBeforeRequestDeserialized, processCall, processPost, shouldCompressResponse
 
Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
doPost, doUnexpectedFailure, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, onAfterRequestDeserialized, readContent
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchServlet

public SearchServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws javax.servlet.ServletException
Init Method

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

addSearchField

public void addSearchField(SearchableFieldBean sField)
This method is used to add a new criterion to the active query.

Specified by:
addSearchField in interface SearchService
Parameters:
name - The name of the criterion to be added

addSearchFieldOnPreviousQuery

public void addSearchFieldOnPreviousQuery(SearchableFieldBean sField)
This method is used to add a new criterion on a previous query

Specified by:
addSearchFieldOnPreviousQuery in interface SearchService
Parameters:
name - The name of the criterion to be added

createPreviousQuery

public SearchableFieldBean[] createPreviousQuery(int indexOfQueryGroupToClone)
This method creates a new previous query. The new query has the same information with the existing query that it's index is passed as a parameter.

Specified by:
createPreviousQuery in interface SearchService
Parameters:
indexOfQueryGroupToClone - The index of the existing query to clone
Returns:
the Index of the new query

getAvailableLanguages

public ArrayList<String> getAvailableLanguages()
Specified by:
getAvailableLanguages in interface SearchService

getBrowsableFields

public ArrayList<BrowsableFieldBean> getBrowsableFields()
This method retrieves the browsable fields

Specified by:
getBrowsableFields in interface SearchService
Returns:
the fields that can be used for browsing

getNumberOfSelectedCollections

public Integer getNumberOfSelectedCollections()
Gets the number of the selected collections, excluding group collections

Specified by:
getNumberOfSelectedCollections in interface SearchService
Returns:
the number of the selected collections

getPreviousQueries

public LinkedList<PreviousResultsInfo> getPreviousQueries()
This method retrieves all the previous advanced or simple queries that had been performed. It returns a linked list with all the information needed.

Specified by:
getPreviousQueries in interface SearchService
Returns:
LinkedList with PreviousResultsInfo objects

getQueryFromBasket

public SavedBasketQueriesInfo getQueryFromBasket(String id)
This method gets the information of a specific object that is saved as a Query in basket

Specified by:
getQueryFromBasket in interface SearchService
Parameters:
The - ID of the query that is saved in basket
Returns:
The query description as a String representation

getResultsNumberPerPage

public Integer getResultsNumberPerPage()
This method is used to retrieve the number of results per page that a user has selected in browse

Specified by:
getResultsNumberPerPage in interface SearchService
Returns:
A number that declares the results per page

getSearchFields

public ArrayList<SearchableFieldBean> getSearchFields()
This method retrieves the available search fields

Specified by:
getSearchFields in interface SearchService
Returns:
an array with the searchable fields

getSelectedConditionType

public String getSelectedConditionType()
This method returns the current condition type, AND | OR

Specified by:
getSelectedConditionType in interface SearchService
Returns:
AND or OR condition type in a String representation

getSelectedConditionTypeOnPreviousSearch

public String getSelectedConditionTypeOnPreviousSearch()
This method returns the current condition type of a previous query, AND | OR

Specified by:
getSelectedConditionTypeOnPreviousSearch in interface SearchService
Returns:
AND or OR condition type in a String representation

getSelectedFields

public ArrayList<SearchableFieldBean> getSelectedFields()
This method returns the current criteria

Specified by:
getSelectedFields in interface SearchService
Returns:
A 2-dimensional string array with the name and value of the criteria

getSelectedFieldsOnPreviousSearch

public ArrayList<SearchableFieldBean> getSelectedFieldsOnPreviousSearch()
This method returns the current criteria for a previous query

Specified by:
getSelectedFieldsOnPreviousSearch in interface SearchService
Returns:
A 2-dimensional string array with the name and value of the criteria

getSelectedLanguage

public String getSelectedLanguage()
Specified by:
getSelectedLanguage in interface SearchService

getSelectedTab

public Integer getSelectedTab()
This method retrieves the current selected tab of the search portlet

Specified by:
getSelectedTab in interface SearchService
Returns:
an Integer which identifies the current selected tab

getSelectedRadioBtn

public Boolean getSelectedRadioBtn()
This method retrieves the current selected tab of the search portlet

Specified by:
getSelectedRadioBtn in interface SearchService
Returns:
an Integer which identifies the current selected tab

isAdvancedOpen

public boolean isAdvancedOpen()
Specified by:
isAdvancedOpen in interface SearchService

getSimpleSearchTerm

public String getSimpleSearchTerm()
This method returns the text that was last used in a simple search

Specified by:
getSimpleSearchTerm in interface SearchService
Returns:
the last text that used in a simple search

setSimpleSearchTerm

public void setSimpleSearchTerm(String term)
Specified by:
setSimpleSearchTerm in interface SearchService

getSortableFields

public ArrayList<SearchableFieldBean> getSortableFields()
This method retrieves the sortable fields

Specified by:
getSortableFields in interface SearchService
Returns:
the fields that can be used for sorting

getSearchStatus

public SearchAvailabilityType getSearchStatus()
Specified by:
getSearchStatus in interface SearchService

removeSearchField

public void removeSearchField(int searchFieldNo)
This method is used to remove a criterion.

Specified by:
removeSearchField in interface SearchService
Parameters:
searchFieldNo - the internal ID of the criterion to be removed

removeSearchFieldOnPreviousQuery

public void removeSearchFieldOnPreviousQuery(int searchFieldNo)
This method is used to remove a criterion on a previous query.

Specified by:
removeSearchFieldOnPreviousQuery in interface SearchService
Parameters:
searchFieldNo - the internal ID of the criterion to be removed

resetFields

public void resetFields(boolean isPrevious)
This method is used to reset all the current criteria

Specified by:
resetFields in interface SearchService

sendEmailWithErrorToSupport

public void sendEmailWithErrorToSupport(Throwable caught)
Specified by:
sendEmailWithErrorToSupport in interface SearchService

setSelectedLanguage

public Boolean setSelectedLanguage(String language)
Specified by:
setSelectedLanguage in interface SearchService

setSelectedTab

public void setSelectedTab(Integer x)
This method sets the current selected tab to the session

Specified by:
setSelectedTab in interface SearchService
Parameters:
An - integer with the selected tab of the search panel

setAdvancedPanelStatus

public void setAdvancedPanelStatus(boolean isOpened)
Specified by:
setAdvancedPanelStatus in interface SearchService

setSelectedRadioBtn

public void setSelectedRadioBtn(boolean isBasketSelected)
Specified by:
setSelectedRadioBtn in interface SearchService

stackTraceAsString

public String stackTraceAsString(Throwable caught)
Specified by:
stackTraceAsString in interface SearchService

storeConditionType

public void storeConditionType(String newValue)
This method is used to change the condition type of the criteria.

Specified by:
storeConditionType in interface SearchService
Parameters:
newValue - the condition type, AND | OR

storeConditionTypeOnPreviousSearch

public void storeConditionTypeOnPreviousSearch(String newValue)
This method is used to change the condition type of the selected fields on the previous results portlet. The condition type is stored on the 3rd item of the array with the selected field's information

Specified by:
storeConditionTypeOnPreviousSearch in interface SearchService

storeSelectedFieldsOnPreviousSearch

public void storeSelectedFieldsOnPreviousSearch(int fieldNo,
                                                int internalNo,
                                                String newValue)
This method is used to change the name, the value or the operator of the selected field for the 'search previous results functionality, depending on the given parameters. internal No: 0 > name of the field, 1 > value of the field, 2 > AND or OR, depending on the condition


submitAdvancedQuery

public void submitAdvancedQuery(ArrayList<SearchableFieldBean> criteria,
                                String sortby,
                                String order,
                                boolean searchPerCollection)
                         throws SearchSubmissionException
This method submits the advances query to the underlying system, by using the ASL

Specified by:
submitAdvancedQuery in interface SearchService
Parameters:
sortby - which field will be used to sort the result
order - Ascending or Descending order
keepTop -
searchPerCollection - if "True" perform a search per collection, else merge the collections
Throws:
SearchSubmissionException
Exception

submitBrowseQuery

public Boolean submitBrowseQuery(BrowsableFieldBean browseBy,
                                 String sortOrder,
                                 String typeOfBrowse,
                                 int resultNumPerPage)
                          throws SearchSubmissionException
Submits a browse query

Specified by:
submitBrowseQuery in interface SearchService
Parameters:
sortBy - which field will be used to sort the result
sortOrder - Ascending or Descending order
typeOfBrowse - Browse collection or browse only one field
Returns:
True if the browse succeeded else False
Throws:
SearchSubmissionException

submitBrowseQueryOnPreviousResult

public void submitBrowseQueryOnPreviousResult(int index)
                                       throws SearchSubmissionException
This method is used to show the results of a query that is already performed in the current session

Specified by:
submitBrowseQueryOnPreviousResult in interface SearchService
Parameters:
The - index of the queryGroup which the results will be shown
Throws:
SearchSubmissionException

submitGenericQuery

public void submitGenericQuery(String query,
                               String type)
                        throws SearchSubmissionException
This method submits a query that is saved in user's basket

Specified by:
submitGenericQuery in interface SearchService
Parameters:
The - query that will be submitted, written in gCube's query language
The - type of search that this query represents
Throws:
SearchSubmissionException

submitQueryOnPreviousResult

public void submitQueryOnPreviousResult(ArrayList<SearchableFieldBean> criteria,
                                        String sortby,
                                        String sortOrder,
                                        String showRank)
                                 throws SearchSubmissionException
Specified by:
submitQueryOnPreviousResult in interface SearchService
Throws:
SearchSubmissionException

submitSimpleQuery

public void submitSimpleQuery(String fts,
                              boolean setRanking,
                              boolean isSemanticSearch)
                       throws SearchSubmissionException
Submits a simple query

Specified by:
submitSimpleQuery in interface SearchService
Parameters:
fts - The keyword to search for
Throws:
SearchSubmissionException

updateCriterionName

public void updateCriterionName(int internalNo,
                                String newID,
                                String newName)
This method is used to update the name of the criterion, specified by the internalNo

Specified by:
updateCriterionName in interface SearchService
Parameters:
internalNo - the internal ID of the criterion to be changed
newName - the name to be set to the criterion

updateCriterionNameOnPreviousQuery

public void updateCriterionNameOnPreviousQuery(int internalNo,
                                               String newID,
                                               String newName)
This method is used to update the name of the criterion, specified by the internalNo in a previous Query

Specified by:
updateCriterionNameOnPreviousQuery in interface SearchService
Parameters:
internalNo - the internal ID of the criterion to be changed
newName - the name to be set to the criterion

updateCriterionValue

public void updateCriterionValue(int internalNo,
                                 String newValue)
This method is used to update the value of the criterion, specified by the internalNo

Specified by:
updateCriterionValue in interface SearchService
Parameters:
internalNo - the internal ID of the criterion to be changed
newValue - the value to be set to the criterion

updateCriterionValueOnPreviousQuery

public void updateCriterionValueOnPreviousQuery(int internalNo,
                                                String newValue)
This method is used to update the value of the criterion, specified by the internalNo in a previous Query

Specified by:
updateCriterionValueOnPreviousQuery in interface SearchService
Parameters:
internalNo - the internal ID of the criterion to be changed
newValue - the value to be set to the criterion

isSemanticAvailableForCurrentScope

public Boolean isSemanticAvailableForCurrentScope()
Specified by:
isSemanticAvailableForCurrentScope in interface SearchService

readPropertyFromFile

public String readPropertyFromFile(String propertyName)


Copyright © 2013. All Rights Reserved.