Keine Beschreibung

ProcessController.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package org.develop.officialjournal.controllers;
  2. import java.util.Comparator;
  3. import java.util.List;
  4. import org.develop.officialjournal.services.Database;
  5. import org.springframework.web.bind.annotation.PathVariable;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestParam;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import dao.connection.LuceneConnector;
  10. import dao.entity.DOProcess;
  11. import dao.entity.Entity;
  12. import dao.lucene.search.DAOSearch;
  13. import dao.lucene.tables.DAOProcess;
  14. @RestController
  15. public class ProcessController {
  16. private DAOSearch daoSearch;
  17. private DAOProcess daoProcess;
  18. public ProcessController() {
  19. daoSearch = Database.get().getDaoSearch();
  20. daoProcess = Database.get().getDaoProcess();
  21. }
  22. /**returns lawyer by id*/
  23. @RequestMapping("/process/{id}")
  24. public DOProcess getById(@PathVariable Long id ) {
  25. DOProcess process = this.daoProcess.get(id, LuceneConnector.getSearcherDisk());
  26. return process;
  27. }
  28. @RequestMapping("/process/{id}/all")
  29. public DOProcess getAllInfo(@PathVariable Integer id ) {
  30. if(daoProcess == null)
  31. daoProcess = Database.get().getDaoProcess();
  32. System.out.println("DAOPROCESS " +daoProcess);
  33. DOProcess process = this.daoProcess.getAllInfo(id, LuceneConnector.getSearcherDisk());
  34. return process;
  35. }
  36. @RequestMapping("/process/entity")
  37. public List<DOProcess> getProcessByEntity(@RequestParam (required = true) Integer entityId,
  38. @RequestParam (required = true) String type ,
  39. @RequestParam (required = false, defaultValue= "0") Integer processId )
  40. {
  41. Entity entity = new Entity();
  42. entity.setId(entityId);
  43. entity.setType(type);
  44. return daoSearch.search(entity);
  45. }
  46. @RequestMapping("/process/number")
  47. public List<DOProcess> getProcessByEntity( @RequestParam (required = true) String processNumber ,
  48. @RequestParam (required = false, defaultValue= "0") Integer processId )
  49. {
  50. List<DOProcess> searchResults = daoSearch.search(processNumber);
  51. searchResults.sort(new Comparator<DOProcess>() {
  52. public int compare(DOProcess o1, DOProcess o2) {
  53. // TODO Auto-generated method stub
  54. return (int) (o1.getProcessDate().getTime() - o2.getProcessDate().getTime());
  55. }
  56. });
  57. return searchResults;
  58. }
  59. }