Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean duplicatePanelExists(Panel panel) throws LIMSRuntimeException {
- try {
- List<Panel> list = new ArrayList<>();
- // not case sensitive hemolysis and Hemolysis are considered
- // duplicates
- String sql = "from Panel t where trim(lower(t.panelName)) = :param and t.id != :panelId";
- Query<Panel> query = entityManager.unwrap(Session.class).createQuery(sql, Panel.class);
- query.setParameter("param", panel.getPanelName().toLowerCase().trim());
- // initialize with 0 (for new records where no id has been generated
- // yet
- String panelId = "0";
- if (!StringUtil.isNullorNill(panel.getId())) {
- panelId = panel.getId();
- }
- query.setParameter("panelId", Integer.parseInt(panelId));
- list = query.list();
- if (list.size() > 0) {
- return true;
- } else {
- return false;
- }
- } catch (RuntimeException e) {
- LogEvent.logError(e);
- throw new LIMSRuntimeException("Error in duplicatePanelExists()", e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement