Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Search Engine (issue 535) #97

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3916bcd
Added search bar UI
halfcurry May 18, 2017
17b6d5f
Worked on SearchResults classes
halfcurry May 23, 2017
e052d70
New tab opens but is Singleton
halfcurry May 26, 2017
e3a44e5
Work on Search results page title
halfcurry May 29, 2017
695f257
Multiple tabs open but bugs exist
halfcurry May 31, 2017
5f749b4
Attempt at connecting to Solr Server
halfcurry Jun 4, 2017
883460a
Minor changes to the search classes
halfcurry Jun 7, 2017
34597da
Added an index button to do full import
halfcurry Jun 9, 2017
c08b492
Attempt at presentation of results on screen
halfcurry Jun 12, 2017
cfa0418
Results rendering but views not changing
halfcurry Jun 13, 2017
882cc0e
Fixed Search results view changing issue and cleaned code
halfcurry Jun 14, 2017
8dd81b4
[Issue #535]: Attempt at opening a project on clicking project search…
halfcurry Jun 22, 2017
b533347
[Issue #535]:Contacts, OrgUnits open on clicking results
halfcurry Jun 27, 2017
0fc5440
[Issue 535]: Made search results pretty
halfcurry Jun 28, 2017
049a3ee
[Issue 535]:Added search filtering and resolved first-time connection…
halfcurry Jun 28, 2017
14db114
[Issue #535]:Added icons to differentiate between types of results
halfcurry Jun 30, 2017
9d15b0a
[Issue #535]:Added filtering (using existing permissions of user) for…
halfcurry Jul 5, 2017
d3e1fb3
[Issue #535]: Contacts and OrgUnits permmission filtering and cleanin…
halfcurry Jul 7, 2017
dd095d6
[Issue #535]: Added an auto full-data import indexing job
halfcurry Jul 9, 2017
0604656
[Issue #535]: Modified pom.xml to include global sigmah core url prop…
halfcurry Jul 9, 2017
1fd1e1c
[Issue #535]:Added solr sonfig files
halfcurry Jul 10, 2017
44ef000
[Issue #535]: Added a panel in admin settings for solr settings
halfcurry Jul 16, 2017
bec9e80
[Issue #535]:Added a column to table organization to store and use so…
halfcurry Jul 19, 2017
ae9af1a
[Issue #535]:Multiple failed attempts at querying the database for a …
halfcurry Jul 28, 2017
b235197
[Issue #535]:Added File indexing capability via existing command patt…
halfcurry Jul 30, 2017
9b2bdd4
[Issue #535]:Small error in last commit
halfcurry Jul 30, 2017
1f7d1f3
[Issue #535]:Modified automatic and manual indexing to include files …
halfcurry Jul 30, 2017
035c728
[Issue #535]:Presentation of files in search results
halfcurry Aug 2, 2017
05abe0b
[Issue #535]:Made UI changes and very rudimentary files results filte…
halfcurry Aug 5, 2017
fb2f93e
[Issue #535]:Multiple changes to UIs of search bar, results and admin
halfcurry Aug 6, 2017
39b19a1
[Issue #535]:Added proper errror messages for different cases
halfcurry Aug 8, 2017
6b2ed5f
[Issue #535]:Code cleanup #1
halfcurry Aug 12, 2017
4999b3a
[Issue #535]:Code cleanup #2, added comments
halfcurry Aug 12, 2017
8f9281a
[Issue #535]:Added Global Permission SEARCH for viewing search bar
halfcurry Aug 13, 2017
9df59b2
[Issue #535]:Added a search button image
halfcurry Aug 13, 2017
4e9ea32
[Issue #535]:Final few changes and code cleanup
halfcurry Aug 21, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</hibernate.dialect>
<hibernate.connection.driver_class>org.postgresql.Driver</hibernate.connection.driver_class>
<hibernate.hbm2ddl.auto>update</hibernate.hbm2ddl.auto>
<hibernate.show_sql>true</hibernate.show_sql>
<hibernate.show_sql>false</hibernate.show_sql>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two cents about this: instead of modifying the common pom.xml file, you should rather maintain your own Maven settings.xml file as very recently documented here: http://wiki.sigmah.org/doku.php?id=contributorguide:preparebuildenvironment#step_3your_first_build

Enjoy !

<hibernate.format_sql>true</hibernate.format_sql>
<hibernate.connection.url>${sigmah.database.url}</hibernate.connection.url>
<hibernate.connection.username>${sigmah.database.user}</hibernate.connection.username>
Expand Down Expand Up @@ -551,6 +551,15 @@
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore any local changes I have made. The only one which matters is this solr dependency.

<!-- SolrJ -->
<dependency>
<artifactId>solr-solrj</artifactId>
<groupId>org.apache.solr</groupId>
<version>6.5.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

<!-- MISC -->
<dependency>
Expand Down Expand Up @@ -1039,6 +1048,13 @@
<id>sigmah-dev</id>
<properties>

<!-- Overrride properties for your local profile here... -->
<sigmah.database.url>jdbc:postgresql://localhost:5432/sigmah</sigmah.database.url>
<sigmah.database.user>sigmah</sigmah.database.user>
<sigmah.database.password>hamsig</sigmah.database.password>
<files.repository.name>/home/sigmah_dev</files.repository.name>
<archives.repository.name>/home/sigmah_dev/archives</archives.repository.name>

<gwt.style>PRETTY</gwt.style>

<!-- Logger properties. -->
Expand All @@ -1047,7 +1063,7 @@

<!-- Hibernate properties. -->

<hibernate.show_sql>true</hibernate.show_sql>
<hibernate.show_sql>false</hibernate.show_sql>

<!-- Mailer properties. -->

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/sigmah/client/search/SearchService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sigmah.client.search;

import java.util.ArrayList;

import org.sigmah.shared.dto.search.SearchResultsDTO;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("search")
public interface SearchService extends RemoteService {
//TODO Add method stubs here
ArrayList<SearchResultsDTO> search(String searchStr);
}
12 changes: 12 additions & 0 deletions src/main/java/org/sigmah/client/search/SearchServiceAsync.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.sigmah.client.search;

import java.util.ArrayList;

import org.sigmah.shared.dto.search.SearchResultsDTO;
import com.google.gwt.user.client.rpc.AsyncCallback;


public interface SearchServiceAsync {

public void search(String searchStr, AsyncCallback<ArrayList<SearchResultsDTO>> callback);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sigmah.client.ui.presenter;

import java.io.IOException;

/*
* #%L
* Sigmah
Expand Down Expand Up @@ -30,13 +32,16 @@
import java.util.Map;
import java.util.Set;

import org.apache.solr.client.solrj.SolrServerException;
import org.sigmah.client.dispatch.CommandResultHandler;
import org.sigmah.client.dispatch.monitor.LoadingMask;
import org.sigmah.client.i18n.I18N;
import org.sigmah.client.inject.Injector;
import org.sigmah.client.page.Page;
import org.sigmah.client.page.PageRequest;
import org.sigmah.client.page.RequestParameter;
import org.sigmah.client.search.SearchService;
import org.sigmah.client.search.SearchServiceAsync;
import org.sigmah.client.ui.presenter.base.AbstractPagePresenter;
import org.sigmah.client.ui.presenter.contact.dashboardlist.ContactsListWidget;
import org.sigmah.client.ui.presenter.project.treegrid.ProjectsListWidget;
Expand Down Expand Up @@ -69,6 +74,7 @@
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.Component;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
Expand Down Expand Up @@ -97,6 +103,7 @@
import org.sigmah.shared.conf.PropertyName;
import org.sigmah.shared.dto.profile.CheckPointDTO;
import org.sigmah.shared.dto.profile.ExecutionDTO;
import org.sigmah.shared.dto.search.SearchResultsDTO;

/**
* Dashboard page presenter.
Expand Down Expand Up @@ -137,12 +144,17 @@ public Page getPage() {
}

@Override
public void onPageRequest(PageRequest request) {
public void onPageRequest(PageRequest request){
// TODO Auto-generated method stub
//view.initialize() is default
String title = (String)request.getData(RequestParameter.TITLE);
//Window.alert("Title is " + title );
view.initialize(title);
// SearchResultsDTO search_res = new SearchResultsDTO();
// Map<String, Object> results = search_res.getResult();
// for (Map.Entry<String, Object> entry : results.entrySet()){
// Window.alert(entry.getKey() + "/" + entry.getValue());
// }
}


Expand Down
122 changes: 99 additions & 23 deletions src/main/java/org/sigmah/client/ui/presenter/zone/SearchPresenter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sigmah.client.ui.presenter.zone;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -10,6 +11,8 @@
import org.sigmah.client.page.Page;
import org.sigmah.client.page.PageRequest;
import org.sigmah.client.page.RequestParameter;
import org.sigmah.client.search.SearchService;
import org.sigmah.client.search.SearchServiceAsync;
import org.sigmah.client.ui.presenter.CreateProjectPresenter;
import org.sigmah.client.ui.presenter.base.AbstractZonePresenter;
import org.sigmah.client.ui.view.base.ViewInterface;
Expand All @@ -22,16 +25,26 @@
import org.sigmah.client.ui.zone.ZoneRequest;
import org.sigmah.client.util.ClientUtils;
import org.sigmah.shared.conf.PropertyName;
import org.sigmah.shared.dto.search.SearchResultsDTO;

import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.ui.client.event.Events;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.inject.ImplementedBy;
import com.google.inject.Inject;
Expand Down Expand Up @@ -60,20 +73,22 @@
*/

/**
* Organization banner presenter displaying organization's name and logo.
*
* @author
*/
* Organization banner presenter displaying organization's name and logo.
*
* @author
*/

@Singleton
public class SearchPresenter extends AbstractZonePresenter<SearchPresenter.View> {


private final SearchServiceAsync searchService = GWT.create(SearchService.class);
private ArrayList<SearchResultsDTO> searchResults = new ArrayList<SearchResultsDTO>();

@Inject
public SearchPresenter(View view, Injector injector) {
super(view, injector);
// TODO Auto-generated constructor stub
}


/**
* View interface.
Expand All @@ -82,9 +97,13 @@ public SearchPresenter(View view, Injector injector) {
public static interface View extends ViewInterface {

HasHTML getNameLabel();

Panel getSearchBarPanel();

ListBox getSearchOptions();

TextBox getSearchText();

Button getSearchButton();

}
Expand All @@ -97,49 +116,106 @@ public Zone getZone() {
// TODO Auto-generated method stub
return Zone.SEARCH_BANNER;
}

/**
* {@inheritDoc}
*/
@Override
public void onBind() {


view.getSearchButton().addKeyUpHandler( new KeyUpHandler() {

@Override
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
String searchText = view.getSearchText().getText();
if (searchText.length() > 0) {
final PageRequest request = new PageRequest(Page.SEARCH_RESULTS);
request.addData(RequestParameter.HEADER, searchText);
request.addData(RequestParameter.TITLE, searchText);
request.addParameter(RequestParameter.ID, searchText.replaceAll("\\W", ""));
request.addParameter(RequestParameter.CONTENT, searchText);
request.addParameter(RequestParameter.HEADER, searchText);
request.addParameter(RequestParameter.TITLE, searchText);
// Log.error("Title set to " +
// request.getData(RequestParameter.TITLE));
// Window.alert("Title set to " +
// request.getData(RequestParameter.TITLE));
// Log.error("Header set to " +
// request.getData(RequestParameter.HEADER));
// Window.alert("Header set to " +
// request.getData(RequestParameter.HEADER));
search();
eventBus.navigateRequest(request);
}
}
}

});


view.getSearchButton().addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {

//have to add a request param here so that it opens a tab with a new title
//request.addParameter(RequestParameter.HEADER, view.getSearchText());

// have to add a request param here so that it opens a tab with
// a new title
// request.addParameter(RequestParameter.HEADER,
// view.getSearchText());
String searchText = view.getSearchText().getText();
if(searchText.length() > 0){
if (searchText.length() > 0) {
final PageRequest request = new PageRequest(Page.SEARCH_RESULTS);
request.addData(RequestParameter.HEADER, searchText );
request.addData(RequestParameter.TITLE, searchText );
request.addData(RequestParameter.HEADER, searchText);
request.addData(RequestParameter.TITLE, searchText);
request.addParameter(RequestParameter.ID, searchText.replaceAll("\\W", ""));
request.addParameter(RequestParameter.CONTENT, searchText );
request.addParameter(RequestParameter.HEADER, searchText );
request.addParameter(RequestParameter.TITLE, searchText );
//Log.error("Title set to " + request.getData(RequestParameter.TITLE));
//Window.alert("Title set to " + request.getData(RequestParameter.TITLE));
//Log.error("Header set to " + request.getData(RequestParameter.HEADER));
//Window.alert("Header set to " + request.getData(RequestParameter.HEADER));
request.addParameter(RequestParameter.CONTENT, searchText);
request.addParameter(RequestParameter.HEADER, searchText);
request.addParameter(RequestParameter.TITLE, searchText);
// Log.error("Title set to " +
// request.getData(RequestParameter.TITLE));
// Window.alert("Title set to " +
// request.getData(RequestParameter.TITLE));
// Log.error("Header set to " +
// request.getData(RequestParameter.HEADER));
// Window.alert("Header set to " +
// request.getData(RequestParameter.HEADER));
search();
eventBus.navigateRequest(request);

}
}

});

}
private void search() {

String textToServer = view.getSearchText().getText();

// Send the input to the server.
searchService.search(textToServer, new AsyncCallback<ArrayList<SearchResultsDTO>>() {
public void onFailure(Throwable caught) {
Window.alert("Failure on the server side!");
caught.printStackTrace();
}

public void onSuccess(ArrayList<SearchResultsDTO> result) {
searchResults = result;
for( SearchResultsDTO doc : searchResults ){
Window.alert(doc.getResult().toString());
}
}
});
}

/**
* {@inheritDoc}
*/
@Override
public void onZoneRequest(ZoneRequest zoneRequest) {
// TODO Auto-generated method stub

}

}
Loading