12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package org.develop.officialjournal.controllers;
- import java.util.Comparator;
- import java.util.List;
- import org.develop.officialjournal.services.Database;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import dao.connection.LuceneConnector;
- import dao.entity.DOProcess;
- import dao.entity.Entity;
- import dao.lucene.search.DAOSearch;
- import dao.lucene.tables.DAOProcess;
- @RestController
- public class ProcessController {
- private DAOSearch daoSearch;
- private DAOProcess daoProcess;
- public ProcessController() {
- daoSearch = Database.get().getDaoSearch();
- daoProcess = Database.get().getDaoProcess();
- }
- /**returns lawyer by id*/
- @RequestMapping("/process/{id}")
- public DOProcess getById(@PathVariable Long id ) {
- DOProcess process = this.daoProcess.get(id, LuceneConnector.getSearcherDisk());
- return process;
- }
-
- @RequestMapping("/process/{id}/all")
- public DOProcess getAllInfo(@PathVariable Integer id ) {
- if(daoProcess == null)
- daoProcess = Database.get().getDaoProcess();
-
- System.out.println("DAOPROCESS " +daoProcess);
- DOProcess process = this.daoProcess.getAllInfo(id, LuceneConnector.getSearcherDisk());
-
- return process;
- }
- @RequestMapping("/process/entity")
- public List<DOProcess> getProcessByEntity(@RequestParam (required = true) Integer entityId,
- @RequestParam (required = true) String type ,
- @RequestParam (required = false, defaultValue= "0") Integer processId )
- {
- Entity entity = new Entity();
- entity.setId(entityId);
- entity.setType(type);
- return daoSearch.search(entity);
- }
-
- @RequestMapping("/process/number")
- public List<DOProcess> getProcessByEntity( @RequestParam (required = true) String processNumber ,
- @RequestParam (required = false, defaultValue= "0") Integer processId )
- {
-
- List<DOProcess> searchResults = daoSearch.search(processNumber);
- searchResults.sort(new Comparator<DOProcess>() {
- public int compare(DOProcess o1, DOProcess o2) {
- // TODO Auto-generated method stub
- return (int) (o1.getProcessDate().getTime() - o2.getProcessDate().getTime());
-
- }
- });
- return searchResults;
-
- }
-
-
-
-
- }
|