dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17360
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6872: CCEM work in progress
------------------------------------------------------------
revno: 6872
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-05-07 17:19:40 +0530
message:
CCEM work in progress
modified:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttribute.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeStore.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogTypeAttributeService.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogTypeAttributeStore.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm
--
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 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttribute.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttribute.java 2012-04-16 11:29:53 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttribute.java 2012-05-07 11:49:40 +0000
@@ -2,8 +2,15 @@
import java.util.Set;
-public class CatalogTypeAttribute
+import org.hisp.dhis.common.BaseNameableObject;
+
+public class CatalogTypeAttribute extends BaseNameableObject
{
+ /**
+ * Determines if a de-serialized file is compatible with this class.
+ */
+ private static final long serialVersionUID = -6551567526188061690L;
+
public static final String TYPE_DATE = "DATE";
public static final String TYPE_STRING = "TEXT";
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeService.java 2012-04-25 05:52:37 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeService.java 2012-05-07 11:49:40 +0000
@@ -20,6 +20,14 @@
Collection<CatalogTypeAttribute> getAllCatalogTypeAttributes();
-
+ // methods
+
+ int getCatalogTypeAttributeCount();
+
+ int getCatalogTypeAttributeCountByName( String name );
+
+ Collection<CatalogTypeAttribute> getCatalogTypeAttributesBetween( int first, int max );
+
+ Collection<CatalogTypeAttribute> getCatalogTypeAttributesBetweenByName( String name, int first, int max );
}
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeStore.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeStore.java 2012-04-21 10:23:39 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogTypeAttributeStore.java 2012-05-07 11:49:40 +0000
@@ -2,16 +2,19 @@
import java.util.Collection;
-public interface CatalogTypeAttributeStore
+import org.hisp.dhis.common.GenericNameableObjectStore;
+
+public interface CatalogTypeAttributeStore extends GenericNameableObjectStore<CatalogTypeAttribute>
{
String ID = CatalogTypeAttributeStore.class.getName();
+ /*
int addCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute );
-
+
void updateCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute );
void deleteCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute );
-
+ */
CatalogTypeAttribute getCatalogTypeAttribute( int id );
CatalogTypeAttribute getCatalogTypeAttributeByName( String name );
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogTypeAttributeService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogTypeAttributeService.java 2012-04-21 10:23:39 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogTypeAttributeService.java 2012-05-07 11:49:40 +0000
@@ -1,9 +1,14 @@
package org.hisp.dhis.coldchain.catalog;
+import static org.hisp.dhis.i18n.I18nUtils.getCountByName;
+import static org.hisp.dhis.i18n.I18nUtils.getObjectsBetween;
+import static org.hisp.dhis.i18n.I18nUtils.getObjectsBetweenByName;
+
import java.util.Collection;
+import org.hisp.dhis.i18n.I18nService;
import org.springframework.transaction.annotation.Transactional;
-
+@Transactional
public class DefaultCatalogTypeAttributeService implements CatalogTypeAttributeService
{
// -------------------------------------------------------------------------
@@ -16,25 +21,28 @@
{
this.catalogTypeAttributeStore = catalogTypeAttributeStore;
}
+
+ private I18nService i18nService;
+ public void setI18nService( I18nService service )
+ {
+ i18nService = service;
+ }
+
// -------------------------------------------------------------------------
// CatalogTypeAttribute
// -------------------------------------------------------------------------
- @Transactional
+ /*
@Override
public int addCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
{
return catalogTypeAttributeStore.addCatalogTypeAttribute( catalogTypeAttribute );
}
-
- @Transactional
@Override
public void deleteCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
{
catalogTypeAttributeStore.deleteCatalogTypeAttribute( catalogTypeAttribute );
}
-
- @Transactional
@Override
public Collection<CatalogTypeAttribute> getAllCatalogTypeAttributes()
{
@@ -47,19 +55,71 @@
{
catalogTypeAttributeStore.updateCatalogTypeAttribute( catalogTypeAttribute );
}
-
- @Transactional
- @Override
- public CatalogTypeAttribute getCatalogTypeAttribute( int id )
- {
- return catalogTypeAttributeStore.getCatalogTypeAttribute( id );
- }
-
- @Transactional
- @Override
- public CatalogTypeAttribute getCatalogTypeAttributeByName( String name )
- {
- return catalogTypeAttributeStore.getCatalogTypeAttributeByName( name );
-
+ @Override
+ public CatalogTypeAttribute getCatalogTypeAttribute( int id )
+ {
+ return catalogTypeAttributeStore.getCatalogTypeAttribute( id );
+ }
+ @Override
+ public CatalogTypeAttribute getCatalogTypeAttributeByName( String name )
+ {
+ return catalogTypeAttributeStore.getCatalogTypeAttributeByName( name );
+
+ }
+ */
+ // -------------------------------------------------------------------------
+ // CatalogTypeAttribute
+ // -------------------------------------------------------------------------
+ @Override
+ public int addCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
+ {
+ return catalogTypeAttributeStore.save( catalogTypeAttribute );
+ }
+ @Override
+ public void deleteCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
+ {
+ catalogTypeAttributeStore.delete( catalogTypeAttribute );
+ }
+ @Override
+ public void updateCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
+ {
+ catalogTypeAttributeStore.update( catalogTypeAttribute );
+ }
+
+ @Override
+ public Collection<CatalogTypeAttribute> getAllCatalogTypeAttributes()
+ {
+ return catalogTypeAttributeStore.getAllCatalogTypeAttributes();
+ }
+ @Override
+ public CatalogTypeAttribute getCatalogTypeAttribute( int id )
+ {
+ return catalogTypeAttributeStore.getCatalogTypeAttribute( id );
+ }
+ @Override
+ public CatalogTypeAttribute getCatalogTypeAttributeByName( String name )
+ {
+ return catalogTypeAttributeStore.getCatalogTypeAttributeByName( name );
+
+ }
+ //Methods
+ public int getCatalogTypeAttributeCount()
+ {
+ return catalogTypeAttributeStore.getCount();
+ }
+
+ public int getCatalogTypeAttributeCountByName( String name )
+ {
+ return getCountByName( i18nService, catalogTypeAttributeStore, name );
+ }
+
+ public Collection<CatalogTypeAttribute> getCatalogTypeAttributesBetween( int first, int max )
+ {
+ return getObjectsBetween( i18nService, catalogTypeAttributeStore, first, max );
+ }
+
+ public Collection<CatalogTypeAttribute> getCatalogTypeAttributesBetweenByName( String name, int first, int max )
+ {
+ return getObjectsBetweenByName( i18nService, catalogTypeAttributeStore, name, first, max );
}
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogTypeAttributeStore.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogTypeAttributeStore.java 2012-04-25 05:52:37 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogTypeAttributeStore.java 2012-05-07 11:49:40 +0000
@@ -2,79 +2,103 @@
import java.util.Collection;
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeStore;
-import org.hisp.dhis.reports.Report_in;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-public class HibernateCatalogTypeAttributeStore implements CatalogTypeAttributeStore
+//public class HibernateCatalogTypeAttributeStore implements CatalogTypeAttributeStore
+public class HibernateCatalogTypeAttributeStore extends HibernateIdentifiableObjectStore<CatalogTypeAttribute> implements CatalogTypeAttributeStore
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+ /*
private SessionFactory sessionFactory;
- public void setSessionFactory( SessionFactory sessionFactory )
+ public void setSessionFactory( SessionFactory sessionFactory )o
{
this.sessionFactory = sessionFactory;
}
-
+ */
// -------------------------------------------------------------------------
// CatalogTypeAttribute
// -------------------------------------------------------------------------
+ /*
@Override
- public int addCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
+ public void addCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
{
+
+ sessionFactory.getCurrentSession().save( catalogTypeAttribute );
+
Session session = sessionFactory.getCurrentSession();
return (Integer) session.save( catalogTypeAttribute );
+
}
@Override
public void deleteCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
{
+
+ sessionFactory.getCurrentSession().delete( catalogTypeAttribute );
+
Session session = sessionFactory.getCurrentSession();
session.delete( catalogTypeAttribute );
- }
-
- @Override
- public Collection<CatalogTypeAttribute> getAllCatalogTypeAttributes()
- {
- Session session = sessionFactory.getCurrentSession();
-
- return session.createCriteria( CatalogTypeAttribute.class ).list();
- }
-
+
+ }
+
@Override
public void updateCatalogTypeAttribute( CatalogTypeAttribute catalogTypeAttribute )
{
+ sessionFactory.getCurrentSession().update( catalogTypeAttribute );
+
Session session = sessionFactory.getCurrentSession();
- session.update( catalogTypeAttribute );
+ session.update( catalogTypeAttribute );
+
}
+ */
@Override
public CatalogTypeAttribute getCatalogTypeAttribute( int id )
{
+ return (CatalogTypeAttribute) sessionFactory.getCurrentSession().get( CatalogTypeAttribute.class, id );
+
+ /*
Session session = sessionFactory.getCurrentSession();
return (CatalogTypeAttribute) session.get( CatalogTypeAttribute.class, id );
+ */
}
@Override
public CatalogTypeAttribute getCatalogTypeAttributeByName( String name )
{
+ return (CatalogTypeAttribute) getCriteria( Restrictions.eq( "name", name ) ).uniqueResult();
+
+ /*
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( CatalogTypeAttribute.class );
criteria.add( Restrictions.eq( "name", name ) );
return (CatalogTypeAttribute) criteria.uniqueResult();
-
- }
+ */
+
+ }
+ @SuppressWarnings( "unchecked" )
+ public Collection<CatalogTypeAttribute> getAllCatalogTypeAttributes()
+ {
+ return sessionFactory.getCurrentSession().createCriteria( CatalogTypeAttribute.class ).list();
+ /*
+ Session session = sessionFactory.getCurrentSession();
+
+ return session.createCriteria( CatalogTypeAttribute.class ).list();
+ */
+ }
+
+
+
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-05-04 07:42:28 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-05-07 11:49:40 +0000
@@ -9,10 +9,19 @@
class="org.hisp.dhis.coldchain.catalog.hibernate.HibernateCatalogTypeAttributeOptionStore">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
+ <!--
<bean id="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeStore"
class="org.hisp.dhis.coldchain.catalog.hibernate.HibernateCatalogTypeAttributeStore">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
+ -->
+ <bean id="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeStore"
+ class="org.hisp.dhis.coldchain.catalog.hibernate.HibernateCatalogTypeAttributeStore">
+ <property name="clazz" value="org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute" />
+ <property name="sessionFactory" ref="sessionFactory"/>
+ <property name="cacheable" value="true" />
+ </bean>
+
<bean id="org.hisp.dhis.coldchain.catalog.CatalogTypeStore"
class="org.hisp.dhis.coldchain.catalog.hibernate.HibernateCatalogTypeStore">
<property name="sessionFactory" ref="sessionFactory"/>
@@ -60,10 +69,18 @@
class="org.hisp.dhis.coldchain.catalog.DefaultCatalogTypeAttributeOptionService">
<property name="catalogTypeAttributeOptionStore" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeOptionStore"/>
</bean>
+<!--
<bean id="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService"
class="org.hisp.dhis.coldchain.catalog.DefaultCatalogTypeAttributeService">
<property name="catalogTypeAttributeStore" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeStore"/>
</bean>
+-->
+ <bean id="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService"
+ class="org.hisp.dhis.coldchain.catalog.DefaultCatalogTypeAttributeService">
+ <property name="catalogTypeAttributeStore" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeStore"/>
+ <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
+ </bean>
+
<bean id="org.hisp.dhis.coldchain.catalog.CatalogTypeService"
class="org.hisp.dhis.coldchain.catalog.DefaultCatalogTypeService">
<property name="catalogTypeStore" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeStore"/>
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java 2012-04-21 10:23:39 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java 2012-05-07 11:49:40 +0000
@@ -1,5 +1,7 @@
package org.hisp.dhis.coldchain.catalog.action;
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -7,10 +9,10 @@
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService;
import org.hisp.dhis.coldchain.catalog.comparator.CatalogTypeAttributeComparator;
-
-import com.opensymphony.xwork2.Action;
-
-public class GetColdChainCatalogTypeAttributeListAction implements Action
+import org.hisp.dhis.paging.ActionPagingSupport;
+
+//public class GetColdChainCatalogTypeAttributeListAction implements Action
+public class GetColdChainCatalogTypeAttributeListAction extends ActionPagingSupport<CatalogTypeAttribute>
{
// -------------------------------------------------------------------------
// Dependency
@@ -33,14 +35,42 @@
{
return catalogTypeAttributes;
}
+
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute() throws Exception
{
+ // -------------------------------------------------------------------------
+ // Criteria
+ // -------------------------------------------------------------------------
+
+ if ( isNotBlank( key ) ) // Filter on key only if set
+ {
+ this.paging = createPaging( catalogTypeAttributeService.getCatalogTypeAttributeCountByName( key ) );
+
+ catalogTypeAttributes = new ArrayList<CatalogTypeAttribute>( catalogTypeAttributeService.getCatalogTypeAttributesBetweenByName( key, paging.getStartPos(), paging.getPageSize() ));
+ }
+ else
+ {
+ this.paging = createPaging( catalogTypeAttributeService.getCatalogTypeAttributeCount() );
+
+ catalogTypeAttributes = new ArrayList<CatalogTypeAttribute>( catalogTypeAttributeService.getCatalogTypeAttributesBetween( paging.getStartPos(), paging.getPageSize() ));
+ }
- catalogTypeAttributes = new ArrayList<CatalogTypeAttribute>(catalogTypeAttributeService.getAllCatalogTypeAttributes());
Collections.sort( catalogTypeAttributes, new CatalogTypeAttributeComparator() );
return SUCCESS;
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm 2012-04-30 11:24:11 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm 2012-05-07 11:49:40 +0000
@@ -5,8 +5,8 @@
<td style="vertical-align:top">
<table width="100%">
<tr>
- <td>
- $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+ <td>#filterDiv( "coldChainCatalogTypeAttribute" )
+ <!--$i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>-->
</td>
<td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddColdChainCatalogTypeAttributeForm.action'" style="width:70px"></td>
</tr>
@@ -47,6 +47,9 @@
</tbody>
</table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">