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

openmrs / openmrs-core / 20784346756

07 Jan 2026 02:13PM UTC coverage: 63.283%. First build
20784346756

push

github

web-flow
TRUNK-6418 Run liquibase checks and data imports only when version of core or modules changes (#5603)

* TRUNK-6418: Run liquibase checks and data imports only when version of core or modules changes

(cherry picked from commit 4723e71c3)

* TRUNK-6418: Follow up adjustments

---------

Co-authored-by: IamMujuziMoses <mujuzimoses@gmail.com>

49 of 112 new or added lines in 9 files covered. (43.75%)

23080 of 36471 relevant lines covered (63.28%)

0.63 hits per line

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

75.86
/web/src/main/java/org/openmrs/web/filter/update/UpdateFilterModel.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.web.filter.update;
11

12
import javax.xml.crypto.Data;
13
import java.util.Collections;
14
import java.util.List;
15

16
import org.openmrs.liquibase.LiquibaseProvider;
17
import org.openmrs.util.DatabaseUpdater;
18
import org.openmrs.util.DatabaseUpdater.OpenMRSChangeSet;
19
import org.openmrs.util.DatabaseUpdaterLiquibaseProvider;
20
import org.openmrs.util.OpenmrsConstants;
21
import org.openmrs.util.RoleConstants;
22
import org.openmrs.web.WebConstants;
23
import org.openmrs.web.filter.StartupFilter;
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

27
/**
28
 * The {@link UpdateFilter} uses this model object to hold all properties that are edited by the
29
 * user in the wizard. All attributes on this model object are added to all templates rendered by
30
 * the {@link StartupFilter}.
31
 */
32
public class UpdateFilterModel {
33
        
34
        private static final Logger log = LoggerFactory.getLogger(UpdateFilterModel.class);
1✔
35
        
36
        // automatically given to the .vm files and used there
37
        public static final String HEADER_TEMPLATE = "org/openmrs/web/filter/update/header.vm";
38

39
        // automatically given to the .vm files and used there
40
        public static final String FOOTER_TEMPLATE = "org/openmrs/web/filter/footer.vm";
41
                
42
        public List<OpenMRSChangeSet> changes = null;
1✔
43
        
44
        public String superuserrole = RoleConstants.SUPERUSER;
1✔
45

46
        public String setupPageUrl = WebConstants.SETUP_PAGE_URL;
1✔
47
        
48
        public static final String OPENMRS_VERSION = OpenmrsConstants.OPENMRS_VERSION_SHORT;
1✔
49
        
50
        public Boolean updateRequired = false;
1✔
51
        
52
        private LiquibaseProvider liquibaseProvider;
53
        
54
        private DatabaseUpdaterWrapper databaseUpdaterWrapper;
55
        
56
        /**
57
         * Default constructor that sets up some of the properties
58
         */
59
        public UpdateFilterModel() {
60
                this(new DatabaseUpdaterLiquibaseProvider(), new DatabaseUpdaterWrapper());
×
61
                log.debug("executing default constructor...");
×
62
        }
×
63
        
64
        /**
65
         * Constructor that allows to inject a Liquibase provider.
66
         * 
67
         * @param liquibaseProvider a Liquibase provider
68
         */
69
        public UpdateFilterModel(LiquibaseProvider liquibaseProvider, DatabaseUpdaterWrapper databaseUpdaterWrapper) {
1✔
70
                log.debug("executing non-default constructor...");
1✔
71
                this.liquibaseProvider = liquibaseProvider;
1✔
72
                this.databaseUpdaterWrapper = databaseUpdaterWrapper;
1✔
73
                
74
                try {
75
                        updateRequired = databaseUpdaterWrapper.updatesRequired();
1✔
76
                        
77
                        if (updateRequired) {
1✔
78
                                updateChanges();
1✔
79
                                updateRequired = changes != null;
1✔
80
                        }
81
                }
82
                catch (Exception e) {
×
83
                        // do nothing
84
                }
1✔
85
        }
1✔
86
        
87
        /**
88
         * Convenience method that reads from liquibase again to get the most recent list of changesets that
89
         * still need to be run.
90
         */
91
        public void updateChanges() {
92
                log.debug("executing updateChanges()...");
1✔
93
                try {
94
                        if (updateRequired) {
1✔
95
                                changes = databaseUpdaterWrapper.getUnrunDatabaseChanges(liquibaseProvider);
1✔
96

97
                                // not sure why this is necessary...
98
                                if (changes == null && databaseUpdaterWrapper.isLocked()) {
1✔
NEW
99
                                        changes = databaseUpdaterWrapper.getUnrunDatabaseChanges(liquibaseProvider);
×
100
                                }
101
                        }
102
                }
103
                catch (Exception e) {
×
104
                        log.error("Unable to get the database changes", e);
×
105
                }
1✔
106
        }
1✔
107
}
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

© 2026 Coveralls, Inc