Advertisement
derrickjunior

Untitled

Aug 16th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. @Override
  2. public boolean duplicatePanelExists(Panel panel) throws LIMSRuntimeException {
  3. try {
  4.  
  5. List<Panel> list = new ArrayList<>();
  6.  
  7. // not case sensitive hemolysis and Hemolysis are considered
  8. // duplicates
  9. String sql = "from Panel t where trim(lower(t.panelName)) = :param and t.id != :panelId";
  10. Query<Panel> query = entityManager.unwrap(Session.class).createQuery(sql, Panel.class);
  11. query.setParameter("param", panel.getPanelName().toLowerCase().trim());
  12.  
  13. // initialize with 0 (for new records where no id has been generated
  14. // yet
  15. String panelId = "0";
  16. if (!StringUtil.isNullorNill(panel.getId())) {
  17. panelId = panel.getId();
  18. }
  19. query.setParameter("panelId", Integer.parseInt(panelId));
  20.  
  21. list = query.list();
  22.  
  23. if (list.size() > 0) {
  24. return true;
  25. } else {
  26. return false;
  27. }
  28.  
  29. } catch (RuntimeException e) {
  30. LogEvent.logError(e);
  31. throw new LIMSRuntimeException("Error in duplicatePanelExists()", e);
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement