dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39605
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20056: Ouwt. Using new org unit query for search. Improves query time a lot.
------------------------------------------------------------
revno: 20056
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-09 10:59:43 +0200
message:
Ouwt. Using new org unit query for search. Improves query time a lot.
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2015-09-09 08:45:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2015-09-09 08:59:43 +0000
@@ -160,7 +160,7 @@
if ( params.getQuery() != null )
{
- hql += hlp.whereAnd() + " (lower(o.name) like :queryLower or o.code = :query or o.uid = :query)" ;
+ hql += hlp.whereAnd() + " (lower(o.name) like :queryLower or o.code = :query or o.uid = :query) " ;
}
if ( params.hasGroups() )
@@ -180,9 +180,11 @@
hql += "o.path like :" + parent.getUid() + " or ";
}
- hql = TextUtils.removeLastOr( hql ) + ")";
+ hql = TextUtils.removeLastOr( hql ) + ") ";
}
+ hql += "order by o.name";
+
Query query = getQuery( hql );
if ( params.getQuery() != null )
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm 2012-09-19 11:41:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm 2015-09-09 08:59:43 +0000
@@ -20,7 +20,7 @@
<img id="searchIcon" src="../images/search.png" style="cursor: pointer" title="$i18n.getString( 'locate_organisation_unit_by_name' )">
<span id="searchSpan" style="width:100%;display:none;">
- <input type="text" id="searchField" name="key" style="width:160px" />
+ <input type="text" id="searchField" name="key" style="width:155px" />
<input type="button" value="Find" onclick="selection.findByName()" />
</span>
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitsByNameAction.java 2015-09-09 08:59:43 +0000
@@ -28,18 +28,19 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.common.IdentifiableObjectUtils;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.user.CurrentUserService;
-import org.springframework.beans.factory.annotation.Autowired;
-
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitQueryParams;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
/**
* @author Chau Thu Tran
*/
@@ -52,20 +53,11 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
+
@Autowired
- private CurrentUserService currentUserService;
-
- public void setCurrentUserService( CurrentUserService currentUserService )
- {
- this.currentUserService = currentUserService;
- }
+ private OrganisationUnitSelectionManager selectionManager;
// -------------------------------------------------------------------------
// Input
@@ -99,23 +91,15 @@
{
term = term.toLowerCase();
- Set<OrganisationUnit> userOrganisationUnits = new HashSet<>( currentUserService.getCurrentUser().getOrganisationUnits() );
-
- userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( IdentifiableObjectUtils.getUids( userOrganisationUnits ) ) );
-
- for ( OrganisationUnit organisationUnit : userOrganisationUnits )
- {
- if ( organisationUnits.size() >= MAX )
- {
- return SUCCESS;
- }
-
- if ( organisationUnit.getName().toLowerCase().contains( term ) )
- {
- organisationUnits.add( organisationUnit );
- }
- }
-
+ Set<OrganisationUnit> parents = new HashSet<OrganisationUnit>( selectionManager.getSelectedOrganisationUnits() );
+
+ OrganisationUnitQueryParams params = new OrganisationUnitQueryParams();
+ params.setQuery( term );
+ params.setParents( parents );
+ params.setMax( MAX );
+
+ organisationUnits = organisationUnitService.getOrganisationUnitsByQuery( params );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2015-09-08 15:56:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2015-09-09 08:59:43 +0000
@@ -190,9 +190,7 @@
</bean>
<bean id="org.hisp.dhis.ouwt.action.GetOrganisationUnitsByNameAction" class="org.hisp.dhis.ouwt.action.GetOrganisationUnitsByNameAction"
- scope="prototype">
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- </bean>
+ scope="prototype" />
<!-- Organisation Unit Selection Tree -->