• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 8606329231

08 Apr 2024 08:37PM CUT coverage: 64.712% (+0.03%) from 64.68%
8606329231

push

github

web-flow
github-actions(deps): bump actions/upload-artifact from 3 to 4 (#4615)

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

22772 of 35190 relevant lines covered (64.71%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/api/src/main/java/org/openmrs/api/db/hibernate/HibernateOpenmrsDataDAO.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs.api.db.hibernate;
11

12
import java.util.List;
13

14
import javax.persistence.Query;
15
import javax.persistence.TypedQuery;
16
import javax.persistence.criteria.CriteriaBuilder;
17
import javax.persistence.criteria.CriteriaQuery;
18
import javax.persistence.criteria.Root;
19

20
import org.hibernate.Session;
21
import org.hibernate.SessionFactory;
22
import org.openmrs.BaseOpenmrsData;
23
import org.openmrs.api.db.OpenmrsDataDAO;
24

25
/**
26
 * Abstract class implementing basic data access methods for BaseOpenmrsData persistents
27
 *
28
 * @since 1.10
29
 *
30
 * @param <T>
31
 */
32
public class HibernateOpenmrsDataDAO<T extends BaseOpenmrsData> extends HibernateOpenmrsObjectDAO<T> implements OpenmrsDataDAO<T> {
33
        
34
        public HibernateOpenmrsDataDAO(Class<T> mappedClass) {
35
                super();
×
36
                this.mappedClass = mappedClass;
×
37
        }
×
38
        
39
        /**
40
         * @see org.openmrs.api.db.OpenmrsDataDAO#getAll(boolean)
41
         */
42
        @Override
43
        public List<T> getAll(boolean includeVoided) {
44
                Session session = sessionFactory.getCurrentSession();
×
45
                CriteriaBuilder cb = session.getCriteriaBuilder();
×
46
                CriteriaQuery<T> cq = cb.createQuery(mappedClass);
×
47
                Root<T> root = cq.from(mappedClass);
×
48

49
                if (!includeVoided) {
×
50
                        cq.where(cb.isFalse(root.get("voided")));
×
51
                }
52

53
                return session.createQuery(cq).getResultList();
×
54
        }
55
        
56
        /**
57
         * @see org.openmrs.api.db.OpenmrsDataDAO#getAll(boolean, java.lang.Integer, java.lang.Integer)
58
         */
59
        @Override
60
        public List<T> getAll(boolean includeVoided, Integer firstResult, Integer maxResults) {
61
                Session session = sessionFactory.getCurrentSession();
×
62
                CriteriaBuilder cb = session.getCriteriaBuilder();
×
63
                CriteriaQuery<T> cq = cb.createQuery(mappedClass);
×
64
                Root<T> root = cq.from(mappedClass);
×
65

66
                if (!includeVoided) {
×
67
                        cq.where(cb.isFalse(root.get("voided")));
×
68
                }
69

70
                TypedQuery<T> query = session.createQuery(cq);
×
71
                if (firstResult != null) {
×
72
                        query.setFirstResult(firstResult);
×
73
                }
74
                if (maxResults != null) {
×
75
                        query.setMaxResults(maxResults);
×
76
                }
77
                return query.getResultList();
×
78
        }
79
        
80
        /**
81
         * @see org.openmrs.api.db.OpenmrsDataDAO#getAllCount(boolean)
82
         */
83
        @Override
84
        public int getAllCount(boolean includeVoided) {
85
                
86
                String hql = "select count(*)" + " from " + mappedClass;
×
87
                
88
                if (!includeVoided) {
×
89
                        hql += " where voided = false";
×
90
                }
91
                Query query = sessionFactory.getCurrentSession().createQuery(hql);
×
92
                
93
                Number count = JpaUtils.getSingleResultOrNull(query);
×
94
                
95
                return count == null ? 0 : count.intValue();
×
96
        }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc