dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33660
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17219: add refresh method to idManager, used to reload an instance from db
------------------------------------------------------------
revno: 17219
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-23 12:40:21 +0700
message:
add refresh method to idManager, used to reload an instance from db
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.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-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2014-10-15 18:59:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2014-10-23 05:40:21 +0000
@@ -28,7 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.common.IdentifiableProperty;
import org.hisp.dhis.common.NameableObject.NameableProperty;
import java.util.Collection;
@@ -122,6 +121,8 @@
<T extends IdentifiableObject> int getCountLikeShortName( Class<T> clazz, String shortName );
+ void refresh( Object object );
+
// -------------------------------------------------------------------------
// NO ACL
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2014-10-15 18:59:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2014-10-23 05:40:21 +0000
@@ -30,7 +30,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.IdentifiableProperty;
+import org.hibernate.SessionFactory;
import org.hisp.dhis.common.NameableObject.NameableProperty;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,6 +61,9 @@
@Autowired
private Set<GenericNameableObjectStore<? extends NameableObject>> nameableObjectStores;
+ @Autowired
+ private SessionFactory sessionFactory;
+
private Map<Class<? extends IdentifiableObject>, GenericIdentifiableObjectStore<? extends IdentifiableObject>> identifiableObjectStoreMap;
private Map<Class<? extends NameableObject>, GenericNameableObjectStore<? extends NameableObject>> nameableObjectStoreMap;
@@ -683,6 +686,12 @@
}
@Override
+ public void refresh( Object object )
+ {
+ sessionFactory.getCurrentSession().refresh( object );
+ }
+
+ @Override
@SuppressWarnings( "unchecked" )
public <T extends IdentifiableObject> T getNoAcl( Class<T> clazz, String uid )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-10-22 07:40:37 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-10-23 05:40:21 +0000
@@ -31,10 +31,7 @@
import com.google.common.base.Enums;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
-import org.hibernate.LockOptions;
-import org.hibernate.SessionFactory;
import org.hisp.dhis.acl.AclService;
-import org.hisp.dhis.cache.HibernateCacheManager;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
@@ -127,9 +124,6 @@
@Autowired
protected ContextService contextService;
- @Autowired
- private SessionFactory sessionFactory;
-
//--------------------------------------------------------------------------
// GET
//--------------------------------------------------------------------------
@@ -584,7 +578,7 @@
}
manager.update( objects.get( 0 ) );
- sessionFactory.getCurrentSession().refresh( candidate );
+ manager.refresh( candidate );
}
@RequestMapping( value = "/{uid}/{property}/{itemId}", method = RequestMethod.DELETE )
@@ -653,7 +647,7 @@
}
manager.update( objects.get( 0 ) );
- sessionFactory.getCurrentSession().refresh( candidate );
+ manager.refresh( candidate );
}
//--------------------------------------------------------------------------