Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5418

Show
Ignore:
Timestamp:
09/01/08 16:21:09 (3 months ago)
Author:
machosry
Message:

address hierarchy: fixed a bug in hierarchy tree.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/addresshierarchy/src/org/openmrs/module/addresshierarchy/AddressHierarchy.java

    r4705 r5418  
    1010     
    1111    public String toString(){ 
    12         return locationName
     12        return locationName+" "+locationId+" "+typeId+" "+parentId
    1313    } 
    1414     
  • openmrs-modules/addresshierarchy/src/org/openmrs/module/addresshierarchy/db/hibernate/HibernateAddressHierarchyDAO.java

    r5411 r5418  
    117117        if(parentLocationId == 0){ 
    118118                query = "select locationId from AddressHierarchy where locationName = '"+name+"' and parentId = null"; 
     119                 
    119120        } 
    120121        else{ 
    121122        query = "select locationId from AddressHierarchy where locationName = '"+name+"' and parentId = "+parentLocationId; 
     123         
    122124        } 
    123125        List<Integer> x = sessionFactory.getCurrentSession().find(query); 
    124         x.add(parentLocationId); 
     126        //x.add(parentLocationId); 
    125127        for(int i=0;b;i++){ 
    126128                String queryx = "select locationId from AddressHierarchy where parentId = "+x.get(i); 
     129         
    127130                List<Integer> y = sessionFactory.getCurrentSession().find(queryx); 
    128131                if(!y.isEmpty()) 
     
    137140                if(x.get(j)==0){ 
    138141                        delete = "delete from AddressHierarchy where parentId = null and name ='"+name+"'"; 
     142         
    139143                } 
    140144                else{ 
    141145                        delete = "delete from AddressHierarchy where parentId = "+x.get(j); 
     146 
    142147                } 
    143148                sessionFactory.getCurrentSession().beginTransaction(); 
     
    146151                 
    147152        } 
     153        String delete = "delete from AddressHierarchy where locationId = "+x.get(0); 
     154        sessionFactory.getCurrentSession().beginTransaction(); 
     155        sessionFactory.getCurrentSession().createQuery(delete).executeUpdate(); 
     156        sessionFactory.getCurrentSession().getTransaction().commit(); 
    148157    } 
    149158     
  • openmrs-modules/addresshierarchy/test/org/openmrs/module/addresshierarchy/AddressHierarchyTest.java

    r5411 r5418  
    3333        } 
    3434    } 
    35      
     35    */ 
    3636    public void testDeleteLocation() throws Exception{ 
    37         ((AddressHierarchyService)Context.getService(AddressHierarchyService.class)).deleteLocation(0, "tamil nadu"); 
     37        ((AddressHierarchyService)Context.getService(AddressHierarchyService.class)).deleteLocation(6, "h"); 
    3838         
    3939    } 
    40      
     40    /* 
    4141    public void testEditLocation() throws Exception{ 
    4242        ((AddressHierarchyService)Context.getService(AddressHierarchyService.class)).editLocation(0, "asdalsd", "usa"); 
     
    7777        System.out.println(x); 
    7878         
    79     }*/ 
     79    } 
    8080     
    8181    public void testDWRCreate(){