Changeset 4834
- Timestamp:
- 07/07/08 18:17:36 (6 months ago)
- Files:
-
- openmrs-modules/addresshierarchy/metadata/config.xml (modified) (2 diffs)
- openmrs-modules/addresshierarchy/metadata/messages.properties (modified) (1 diff)
- openmrs-modules/addresshierarchy/metadata/moduleApplicationContext.xml (modified) (2 diffs)
- openmrs-modules/addresshierarchy/src/org/openmrs/module/addresshierarchy/db/hibernate/HibernateAddressHierarchyDAO.java (modified) (11 diffs)
- openmrs-modules/addresshierarchy/src/org/openmrs/module/addresshierarchy/extension/html/AdminList.java (modified) (1 diff)
- openmrs-modules/addresshierarchy/web/module/addresshierarchyCreate.jsp (deleted)
- openmrs-modules/addresshierarchy/web/module/addresshierarchyTree.htm (added)
- openmrs-modules/addresshierarchy/web/src/org/openmrs/module/addresshierarchy/web/dwr/DWRAddressHierarchyService.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/addresshierarchy/metadata/config.xml
r4787 r4834 67 67 <include method="getLocationCount"/> 68 68 <include method="autocomplete" /> 69 <include method="createLocation"></include> 69 <include method="createLocation" /> 70 <include method="deleteLocation" /> 71 <include method="editLocation" /> 70 72 </create> 71 73 </allow> … … 81 83 DWRAddressHierarchy.autocomplete(Integer id,String str); 82 84 DWRAddressHierarchy.createLocation(String name, Integer typeId, Integer parentId ); 85 DWRAddressHierarchy.deleteLocation(Integer parentId, String childName); 86 DWRAddressHierarchy.editLocation(Integer parentLocationId,String oldName,String newName); 83 87 ]]> 84 88 </signatures> openmrs-modules/addresshierarchy/metadata/messages.properties
r4705 r4834 1 1 @MODULE_ID@.title=Address Hierarchy Support Module 2 @MODULE_ID@.tree=Address Hiererchy Tree 2 3 @MODULE_ID@.manage=Manage Hierarchy 3 4 @MODULE_ID@.create=Create Hierarchy openmrs-modules/addresshierarchy/metadata/moduleApplicationContext.xml
r4770 r4834 11 11 <prop key="module/@MODULE_ID@/addresshierarchy.form">addresshierarchyForm</prop> 12 12 <prop key="module/@MODULE_ID@/addresshierarchymanage.form">addresshierarchymanageForm</prop> 13 <prop key="module/@MODULE_ID@/addresshierarchycreate.form">addresshierarchyCreate</prop>13 14 14 </props> 15 15 </property> … … 58 58 <property name="successView"><value>addresshierarchymanage.form</value></property> 59 59 </bean> 60 <bean id="addresshierarchyCreate" class="org.openmrs.module.addresshierarchy.web.controller.AddressHierarchyCreate"> 61 <property name="commandName"><value>addresshierarchyCreate</value></property> 62 <property name="commandClass"><value>org.openmrs.module.addresshierarchy.web.controller.AddressHierarchyCreate</value></property> 63 <property name="formView"><value>/module/@MODULE_ID@/addresshierarchyCreate</value></property> 64 <property name="successView"><value>addresshierarchycreate.form</value></property> 65 </bean> 66 67 60 68 61 69 62 <!-- /Controllers --> openmrs-modules/addresshierarchy/src/org/openmrs/module/addresshierarchy/db/hibernate/HibernateAddressHierarchyDAO.java
r4787 r4834 168 168 public String getCompleteLocations(){ 169 169 String query = "Select locationName,locationId,typeId from AddressHierarchy where parentId = null"; 170 Parent parent = new Parent();171 Map children = new HashMap();172 170 Iterator x = sessionFactory.getCurrentSession().find(query).iterator(); 173 JSONArray finalarr = new JSONArray(); 174 int i1=0,i=0; 175 JSONArray a11 = new JSONArray(); 176 String ping = ""; 171 String ping = ""; 177 172 ping = "{treeNodes : [ { title : \"Start\" , locationId : \"0\", typeId : \"0\" , parentId : \"0\", children : ["; 178 179 173 for(int b1 = 0;x.hasNext();b1++){ 180 i1++;181 174 if(b1!=0){ 182 175 ping = ping +","; 183 176 } 184 185 int i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0,i10=0,i11=0;186 177 Object[] y = (Object[]) x.next(); 187 188 189 Child child = new Child();190 Child child1 = new Child();191 Child child2 = new Child();192 Child child3 = new Child();193 Child child4 = new Child();194 Child child5 = new Child();195 Child child6 = new Child();196 Child child7 = new Child();197 Child child8 = new Child();198 Child child9 = new Child();199 Child child10 = new Child();200 201 202 203 JSONArray a1 = new JSONArray();204 205 parent.setLocationName(y[0].toString());206 parent.setLocationId(y[1].toString());207 parent.setParentId("0");208 parent.setChildren(null);209 210 178 String query2 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y[1].toString(); 211 179 Iterator x1 = sessionFactory.getCurrentSession().find(query2).iterator(); 212 213 180 ping = ping + "{ title : \""+y[0].toString()+"\" , locationId : \""+y[1].toString()+"\", typeId : \""+y[2].toString()+"\" , parentId : \"0\""; 214 181 if(x1.hasNext()){ … … 218 185 ping = ping +"}";continue; 219 186 } 220 221 222 223 for(int b2 = 0;x1.hasNext();b2++){ 224 i1++; 187 for(int b2 = 0;x1.hasNext();b2++){ 225 188 if(b2!=0){ 226 189 ping = ping +","; 227 190 } 228 191 Object[] y1 = (Object[]) x1.next(); 229 230 child1.setLocationName(y1[0].toString()); 231 child1.setLocationId(y1[1].toString()); 232 child1.setParentId(y1[2].toString()); 233 child1.setChildren(null); 234 235 Map children2 = new HashMap(); 236 JSONArray a2 = new JSONArray(); 237 238 String query3 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y1[1].toString(); 192 String query3 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y1[1].toString(); 239 193 Iterator x2 = sessionFactory.getCurrentSession().find(query3).iterator(); 240 241 194 ping = ping + "{ title : \""+y1[0].toString()+"\" , locationId : \""+y1[1].toString()+"\", typeId : \""+y1[2].toString()+"\" , parentId : \""+y1[3].toString()+"\""; 242 195 if(x2.hasNext()){ … … 246 199 ping = ping +"}";continue; 247 200 } 248 249 250 for(int b3= 0;x2.hasNext();b3++){ 251 i1++; 201 for(int b3= 0;x2.hasNext();b3++){ 252 202 if(b3!=0){ 253 203 ping = ping +","; 254 204 } 255 205 Object[] y2 = (Object[]) x2.next(); 256 child2.setLocationName(y2[0].toString()); 257 child2.setLocationId(y2[1].toString()); 258 child2.setParentId(y2[2].toString()); 259 child2.setChildren(null); 260 261 Map children3 = new HashMap(); 262 JSONArray a3 = new JSONArray(); 263 264 265 String query4 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y2[1].toString(); 206 String query4 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y2[1].toString(); 266 207 Iterator x3 = sessionFactory.getCurrentSession().find(query4).iterator(); 267 268 269 208 ping = ping + "{ title : \""+y2[0].toString()+"\" , locationId : \""+y2[1].toString()+"\", typeId : \""+y2[2].toString()+"\" , parentId : \""+y2[3].toString()+"\""; 270 209 if(x3.hasNext()){ … … 274 213 ping = ping +"}";continue; 275 214 } 276 277 278 279 for(int b4 = 0;x3.hasNext();b4++){ 280 i1++; 215 for(int b4 = 0;x3.hasNext();b4++){ 281 216 if(b4!=0){ 282 217 ping = ping +","; 283 218 } 284 219 Object[] y3 = (Object[]) x3.next(); 285 child3.setLocationName(y3[0].toString()); 286 child3.setLocationId(y3[1].toString()); 287 child3.setParentId(y3[2].toString()); 288 child3.setChildren(null); 289 290 Map children4 = new HashMap(); 291 JSONArray a4 = new JSONArray(); 292 293 String query5 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y3[1].toString(); 220 String query5 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y3[1].toString(); 294 221 Iterator x4 = sessionFactory.getCurrentSession().find(query5).iterator(); 295 296 222 ping = ping + "{ title : \""+y3[0].toString()+"\" , locationId : \""+y3[1].toString()+"\", typeId : \""+y3[2].toString()+"\" , parentId : \""+y3[3].toString()+"\""; 297 223 if(x4.hasNext()){ … … 301 227 ping = ping +"}";continue; 302 228 } 303 304 305 306 for(int b5 = 0;x4.hasNext();b5++){ 307 i1++; 229 for(int b5 = 0;x4.hasNext();b5++){ 308 230 if(b5!=0){ 309 231 ping = ping +","; 310 232 } 311 233 Object[] y4 = (Object[]) x4.next(); 312 child4.setLocationName(y4[0].toString()); 313 child4.setLocationId(y4[1].toString()); 314 child4.setParentId(y4[2].toString()); 315 child4.setChildren(null); 316 317 Map children5 = new HashMap(); 318 JSONArray a5 = new JSONArray(); 319 320 String query6 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y4[1].toString(); 234 String query6 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y4[1].toString(); 321 235 Iterator x5 = sessionFactory.getCurrentSession().find(query6).iterator(); 322 323 324 236 ping = ping + "{ title : \""+y4[0].toString()+"\" , locationId : \""+y4[1].toString()+"\", typeId : \""+y4[2].toString()+"\" , parentId : \""+y4[3].toString()+"\""; 325 237 if(x5.hasNext()){ … … 329 241 ping = ping +"}";continue; 330 242 } 331 332 333 334 for(int b6 = 0;x5.hasNext();b6++){ 335 i1++; 243 for(int b6 = 0;x5.hasNext();b6++){ 336 244 if(b6!=0){ 337 245 ping = ping +","; 338 246 } 339 247 Object[] y5 = (Object[]) x5.next(); 340 child5.setLocationName(y5[0].toString()); 341 child5.setLocationId(y5[1].toString()); 342 child5.setParentId(y5[2].toString()); 343 child5.setChildren(null); 344 345 Map children6 = new HashMap(); 346 JSONArray a6= new JSONArray(); 347 348 String query7 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y5[1].toString(); 248 String query7 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y5[1].toString(); 349 249 Iterator x6 = sessionFactory.getCurrentSession().find(query7).iterator(); 350 351 250 ping = ping + "{ title : \""+y5[0].toString()+"\" , locationId : \""+y5[1].toString()+"\", typeId : \""+y5[2].toString()+"\" , parentId : \""+y5[3].toString()+"\""; 352 251 if(x6.hasNext()){ … … 356 255 ping = ping +"}";continue; 357 256 } 358 359 360 361 for(int b7 = 0;x6.hasNext();b7++){ 362 i1++; 257 for(int b7 = 0;x6.hasNext();b7++){ 363 258 if(b7!=0){ 364 259 ping = ping +","; 365 260 } 366 261 Object[] y6 = (Object[]) x6.next(); 367 child6.setLocationName(y6[0].toString()); 368 child6.setLocationId(y6[1].toString()); 369 child6.setParentId(y6[2].toString()); 370 child6.setChildren(null); 371 372 Map children7 = new HashMap(); 373 JSONArray a7 = new JSONArray(); 374 375 String query8 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y6[1].toString(); 262 String query8 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y6[1].toString(); 376 263 Iterator x7 = sessionFactory.getCurrentSession().find(query8).iterator(); 377 378 264 ping = ping + "{ title : \""+y6[0].toString()+"\" , locationId : \""+y6[1].toString()+"\", typeId : \""+y6[2].toString()+"\" , parentId : \""+y6[3].toString()+"\""; 379 265 if(x7.hasNext()){ … … 383 269 ping = ping +"}";continue; 384 270 } 385 386 387 388 for(int b8 = 0;x7.hasNext();b8++){ 389 i1++; 271 for(int b8 = 0;x7.hasNext();b8++){ 390 272 if(b8!=0){ 391 273 ping = ping +","; 392 274 } 393 275 Object[] y7 = (Object[]) x7.next(); 394 child7.setLocationName(y7[0].toString()); 395 child7.setLocationId(y7[1].toString()); 396 child7.setParentId(y7[2].toString()); 397 child7.setChildren(null); 398 399 Map children8 = new HashMap(); 400 JSONArray a8 = new JSONArray(); 401 402 String query9 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y7[1].toString(); 276 String query9 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y7[1].toString(); 403 277 Iterator x8 = sessionFactory.getCurrentSession().find(query3).iterator(); 404 405 278 ping = ping + "{ title : \""+y7[0].toString()+"\" , locationId : \""+y7[1].toString()+"\", typeId : \""+y7[2].toString()+"\" , parentId : \""+y7[3].toString()+"\""; 406 279 if(x8.hasNext()){ … … 410 283 ping = ping +"},";continue; 411 284 } 412 413 414 415 for(int b9 = 0;x8.hasNext();b9++){ 416 i1++; 285 for(int b9 = 0;x8.hasNext();b9++){ 417 286 if(b9!=0){ 418 287 ping = ping +","; 419 288 } 420 289 Object[] y8 = (Object[]) x8.next(); 421 child8.setLocationName(y8[0].toString()); 422 child8.setLocationId(y8[1].toString()); 423 child8.setParentId(y8[2].toString()); 424 child8.setChildren(null); 425 426 Map children9 = new HashMap(); 427 JSONArray a9 = new JSONArray(); 428 429 String query10 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y8[1].toString(); 290 String query10 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y8[1].toString(); 430 291 Iterator x9 = sessionFactory.getCurrentSession().find(query10).iterator(); 431 432 292 ping = ping + "{ title : \""+y8[0].toString()+"\" , locationId : \""+y8[1].toString()+"\", typeId : \""+y8[2].toString()+"\" , parentId : \""+y8[3].toString()+"\""; 433 293 if(x9.hasNext()){ … … 438 298 continue; 439 299 } 440 441 442 for(int b10 = 0;x9.hasNext();b10++){ 443 i1++; 300 for(int b10 = 0;x9.hasNext();b10++){ 444 301 if(b10!=0){ 445 302 ping = ping +","; 446 303 } 447 304 Object[] y9 = (Object[]) x9.next(); 448 child9.setLocationName(y9[0].toString()); 449 child9.setLocationId(y9[1].toString()); 450 child9.setParentId(y9[2].toString()); 451 child9.setChildren(null); 452 453 Map children10 = new HashMap(); 454 JSONArray a10 = new JSONArray(); 455 456 String query11 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y9[1].toString(); 305 String query11 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y9[1].toString(); 457 306 Iterator x10 = sessionFactory.getCurrentSession().find(query3).iterator(); 458 459 307 ping = ping + "{ title : \""+y9[0].toString()+"\" , locationId : \""+y9[1].toString()+"\", typeId : \""+y9[2].toString()+"\" , parentId : \""+y9[3].toString()+"\""; 460 308 if(x10.hasNext()){ … … 464 312 ping = ping +"}"; 465 313 } 466 467 468 for(int b11 = 0;x10.hasNext();b11++){ 469 i1++; 470 314 for(int b11 = 0;x10.hasNext();b11++){ 471 315 if(b11!=0){ 472 316 ping = ping+","; 473 317 } 474 318 Object[] y10 = (Object[]) x10.next(); 475 child10.setLocationName(y10[0].toString()); 476 child10.setLocationId(y10[1].toString()); 477 child10.setParentId(y10[2].toString()); 478 child10.setChildren(null); 479 ping = ping + "{ title : \""+y10[0].toString()+"\" , locationId : \""+y10[1].toString()+"\", typeId : \""+y10[2].toString()+"\" , parentId : \""+y10[3].toString()+"\""; 480 481 ping = ping +"}"; 482 483 Map children11 = new HashMap(); 484 485 486 String query12 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y10[1].toString(); 319 ping = ping + "{ title : \""+y10[0].toString()+"\" , locationId : \""+y10[1].toString()+"\", typeId : \""+y10[2].toString()+"\" , parentId : \""+y10[3].toString()+"\""; 320 ping = ping +"}"; 321 String query12 = "select locationName,locationId,typeId,parentId from AddressHierarchy where parentId = "+y10[1].toString(); 487 322 Iterator x11 = sessionFactory.getCurrentSession().find(query3).iterator(); 488 ob = JSONObject.fromObject(child10); 489 if(!ob.isNullObject()){ 490 a10.add(ob); 491 children11.put(childid, a10); 492 child9.setChildren(children11); 493 i11++; 494 } 495 496 } 497 ob = JSONObject.fromObject(child9); 498 if(!ob.isNullObject()){ 499 a9.add(ob);children10.put(childid, a9); 500 child8.setChildren(children10); 501 i10++; 502 503 504 ping = ping + "]}"; 505 506 507 508 509 } 510 } 511 ob = JSONObject.fromObject(child8); 512 if(!ob.isNullObject()){ 513 a8.add(ob);children9.put(childid, a8); 514 child7.setChildren(children9); 515 i9++; 516 323 } 324 ping = ping + "]}"; 325 } 517 326 ping = ping + "]}"; 518 519 520 } 521 } 522 ob = JSONObject.fromObject(child7); 523 if(!ob.isNullObject()){ 524 a7.add(ob);children8.put(childid, a7); 525 child6.setChildren(children8); 526 i8++; 527 528 ping = ping + "]}"; 529 530 } 531 } 532 ob = JSONObject.fromObject(child6); 533 if(!ob.isNullObject()){ 534 a6.add(ob);children7.put(childid, a6); 535 child5.setChildren(children7); 536 i7++; 327 } 328 ping = ping + "]}"; 329 } 537 330 ping = ping + "]}"; 538 539 } 540 } 541 ob = JSONObject.fromObject(child5); 542 if(!ob.isNullObject()){ 543 a5.add(ob);children6.put(childid, a5); 544 child4.setChildren(children6); 545 i6++; 546 547 ping = ping + "]}"; 548 549 } 550 } 551 ob = JSONObject.fromObject(child4); 552 if(!ob.isNullObject()){ 553 a4.add(ob);children5.put(childid, a4); 554 child3.setChildren(children5); 555 i5++; 556 557 ping = ping + "]}"; 558 559 } 560 } 561 ob = JSONObject.fromObject(child3); 562 if(!ob.isNullObject()){ 563 a3.add(ob);children4.put(childid, a3); 564 child2.setChildren(children4); 565 i4++; 566 567 ping = ping + "]}"; 568 569 } 570 } 571 ob = JSONObject.fromObject(child2); 572 if(!ob.isNullObject()){ 573 a2.add(ob);children3.put(childid, a2); 574 child1.setChildren(children3); 575 i3++; 576 577 ping = ping + "]}"; 578 579 } 580 } 581 582 ob = JSONObject.fromObject(child1); 583 if(!ob.isNullObject()){ 584 a1.add(ob);children2.put(childid, a1); 585 parent.setChildren(children2); 586 i2++; 331 } 332 ping = ping + "]}"; 333 } 334 ping = ping + "]}"; 335 } 336 ping = ping + "]}"; 337 } 338 ping = ping + "]}"; 339 } 587 340 ping = ping + "]}"; 588 589 } 590 } 591 592 ob = JSONObject.fromObject(parent); 593 if(!ob.isNullObject()){ 594 a11.add(0,ob); 595 children.put(childid, a11); 596 i++;} 597 i1++; 598 341 } 599 342 ping = ping + "]}"; 600 601 602 } 603 604 605 TreeNode dummy = new TreeNode(); 606 Map dummymap = new HashMap(); 607 dummymap.put("children", a11); 608 dummy.settreeNodes(dummymap); 609 JSONObject obj = JSONObject.fromObject(dummy); 610 fin = new JSONArray(); 611 fin.add(dummy); 612 ping = ping + "]}]}"; 613 343 } 344 ping = ping + "]}]}"; 614 345 return ping; 615 346 } openmrs-modules/addresshierarchy/src/org/openmrs/module/addresshierarchy/extension/html/AdminList.java
r4770 r4834 52 52 map.put("module/addresshierarchy/addresshierarchy.form", "addresshierarchy.create"); 53 53 map.put("module/addresshierarchy/addresshierarchymanage.form", "addresshierarchy.manage"); 54 map.put("module/addresshierarchy/addresshierarchy create.form", "addresshierarchy.delete");54