dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37808
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19309: Switched to using dbmsManager.clearSession in Event/Tei/Enrollment services (for flushing in bulk...
------------------------------------------------------------
revno: 19309
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-08 15:53:59 +0700
message:
Switched to using dbmsManager.clearSession in Event/Tei/Enrollment services (for flushing in bulk imports)
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java
--
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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-06-08 06:22:39 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-06-08 08:53:59 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.common.QueryItem;
import org.hisp.dhis.common.QueryOperator;
+import org.hisp.dhis.dbms.DbmsManager;
import org.hisp.dhis.dxf2.events.event.Note;
import org.hisp.dhis.dxf2.events.trackedentity.Attribute;
import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
@@ -113,7 +114,7 @@
protected UserService userService;
@Autowired
- protected SessionFactory sessionFactory;
+ protected DbmsManager dbmsManager;
private CachingMap<String, OrganisationUnit> organisationUnitCache = new CachingMap<>();
@@ -357,8 +358,7 @@
if ( counter % FLUSH_FREQUENCY == 0 )
{
- sessionFactory.getCurrentSession().flush();
- sessionFactory.getCurrentSession().clear();
+ dbmsManager.clearSession();
}
counter++;
@@ -460,8 +460,7 @@
if ( counter % FLUSH_FREQUENCY == 0 )
{
- sessionFactory.getCurrentSession().flush();
- sessionFactory.getCurrentSession().clear();
+ dbmsManager.clearSession();
}
counter++;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-06-02 12:59:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-06-08 08:53:59 +0000
@@ -28,18 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.system.notification.NotificationLevel.ERROR;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -52,6 +42,7 @@
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dbms.DbmsManager;
import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.common.ImportOptions;
import org.hisp.dhis.dxf2.events.report.EventRow;
@@ -77,9 +68,7 @@
import org.hisp.dhis.system.callable.IdentifiableObjectCallable;
import org.hisp.dhis.system.notification.NotificationLevel;
import org.hisp.dhis.system.notification.Notifier;
-import org.hisp.dhis.util.CachingMap;
import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.util.DebugUtils;
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
@@ -89,12 +78,23 @@
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
+import org.hisp.dhis.util.CachingMap;
+import org.hisp.dhis.util.DebugUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hisp.dhis.system.notification.NotificationLevel.ERROR;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -135,7 +135,7 @@
@Autowired
protected TrackedEntityInstanceService entityInstanceService;
-
+
@Autowired
protected TrackedEntityCommentService commentService;
@@ -152,6 +152,9 @@
protected SessionFactory sessionFactory;
@Autowired
+ protected DbmsManager dbmsManager;
+
+ @Autowired
protected IdentifiableObjectManager manager;
protected final int FLUSH_FREQUENCY = 20;
@@ -186,8 +189,7 @@
if ( counter % FLUSH_FREQUENCY == 0 )
{
- sessionFactory.getCurrentSession().flush();
- sessionFactory.getCurrentSession().clear();
+ dbmsManager.clearSession();
}
counter++;
@@ -401,10 +403,10 @@
public Events getEvents( EventSearchParams params )
{
List<OrganisationUnit> organisationUnits = new ArrayList<>();
-
+
OrganisationUnit orgUnit = params.getOrgUnit();
OrganisationUnitSelectionMode orgUnitSelectionMode = params.getOrgUnitSelectionMode();
-
+
if ( params.getOrgUnit() != null )
{
if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( orgUnitSelectionMode ) )
@@ -428,35 +430,35 @@
}
Events events = new Events();
-
+
if ( params.isPaging() )
{
int count = 0;
-
+
if ( params.isTotalPages() )
{
count = eventStore.getEventCount( params, organisationUnits );
}
-
+
Pager pager = new Pager( params.getPageWithDefault(), count, params.getPageSizeWithDefault() );
events.setPager( pager );
}
-
+
List<Event> eventList = eventStore.getEvents( params, organisationUnits );
events.setEvents( eventList );
return events;
}
-
+
@Override
public EventRows getEventRows( EventSearchParams params )
{
List<OrganisationUnit> organisationUnits = new ArrayList<>();
-
+
OrganisationUnit orgUnit = params.getOrgUnit();
OrganisationUnitSelectionMode orgUnitSelectionMode = params.getOrgUnitSelectionMode();
-
+
if ( params.getOrgUnit() != null )
{
if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( orgUnitSelectionMode ) )
@@ -474,19 +476,19 @@
}
}
- EventRows eventRows = new EventRows();
-
-
+ EventRows eventRows = new EventRows();
+
+
List<EventRow> eventRowList = eventStore.getEventRows( params, organisationUnits );
eventRows.setEventRows( eventRowList );
return eventRows;
}
-
+
@Override
public EventSearchParams getFromUrl( String program, String programStage, ProgramStatus programStatus, Boolean followUp, String orgUnit,
- OrganisationUnitSelectionMode orgUnitSelectionMode, String trackedEntityInstance, Date startDate, Date endDate,
+ OrganisationUnitSelectionMode orgUnitSelectionMode, String trackedEntityInstance, Date startDate, Date endDate,
EventStatus status, Date lastUpdated, IdSchemes idSchemes, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging, boolean includeAttributes )
{
EventSearchParams params = new EventSearchParams();
@@ -506,19 +508,19 @@
}
OrganisationUnit ou = organisationUnitService.getOrganisationUnit( orgUnit );
-
+
if ( StringUtils.isNotEmpty( orgUnit ) && ou == null )
{
throw new IllegalQueryException( "Org unit is specified but does not exist: " + orgUnit );
}
-
+
TrackedEntityInstance tei = entityInstanceService.getTrackedEntityInstance( trackedEntityInstance );
-
+
if ( StringUtils.isNotEmpty( trackedEntityInstance ) && tei == null )
{
throw new IllegalQueryException( "Tracked entity instance is specified but does not exist: " + trackedEntityInstance );
}
-
+
params.setProgram( pr );
params.setProgramStage( ps );
params.setOrgUnit( ou );
@@ -536,10 +538,10 @@
params.setTotalPages( totalPages );
params.setSkipPaging( skipPaging );
params.setIncludeAttributes( includeAttributes );
-
+
return params;
}
-
+
@Override
public Event getEvent( String uid )
{
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-06-08 06:22:39 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-06-08 08:53:59 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.common.QueryItem;
import org.hisp.dhis.common.QueryOperator;
+import org.hisp.dhis.dbms.DbmsManager;
import org.hisp.dhis.dxf2.importsummary.ImportConflict;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
@@ -95,7 +96,7 @@
protected UserService userService;
@Autowired
- protected SessionFactory sessionFactory;
+ protected DbmsManager dbmsManager;
private CachingMap<String, OrganisationUnit> organisationUnitCache = new CachingMap<>();
@@ -213,8 +214,7 @@
if ( counter % FLUSH_FREQUENCY == 0 )
{
- sessionFactory.getCurrentSession().flush();
- sessionFactory.getCurrentSession().clear();
+ dbmsManager.clearSession();
}
counter++;
@@ -273,8 +273,7 @@
if ( counter % FLUSH_FREQUENCY == 0 )
{
- sessionFactory.getCurrentSession().flush();
- sessionFactory.getCurrentSession().clear();
+ dbmsManager.clearSession();
}
counter++;