Skip to content

Commit 43788da

Browse files
authored
#320 - Displays pre-loader should only run if there are display heade… (#321)
1 parent 29a42f6 commit 43788da

5 files changed

Lines changed: 56 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo
230230
#### version 2.12.0
231231
* Fix conceptsets domain to prevent incorrect unretiring of associated concept
232232
* Fix to ensure concept lookups correctly handle concepts with % characters
233+
* Fix for performance to only process displays preloaders if they are present within csvs
233234

234235
#### Version 2.11.0
235236
* Added support for patient flags (flags, flagpriorities, flagtags) domains

api-bahmni/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<resource>
119119
<directory>../api/src/test/resources</directory>
120120
<excludes>
121-
<exclude>../api/src/test/resources/test-hibernate.cfg.xml</exclude>
121+
<exclude>test-hibernate.cfg.xml</exclude>
122122
</excludes>
123123
</resource>
124124
</resources>

api-bahmni/src/test/resources/test-hibernate.cfg.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,41 @@
55

66
<hibernate-configuration>
77
<session-factory>
8+
<!-- AH -->
9+
<mapping resource="AddressHierarchyLevel.hbm.xml"/>
10+
<mapping resource="AddressHierarchyEntry.hbm.xml"/>
11+
<!-- MDS -->
12+
<mapping resource="ImportedItem.hbm.xml"/>
13+
<mapping resource="ImportedPackage.hbm.xml"/>
14+
<!-- Htmlformentry -->
15+
<mapping resource="HtmlFormEntryHtmlForm.hbm.xml"/>
16+
<!-- Idgen -->
17+
<mapping resource="IdentifierSource.hbm.xml"/>
18+
<!-- MetadataMapping -->
19+
<mapping resource="MetadataSource.hbm.xml"/>
20+
<mapping resource="MetadataTermMapping.hbm.xml"/>
21+
<mapping resource="MetadataSet.hbm.xml"/>
22+
<mapping resource="MetadataSetMember.hbm.xml"/>
23+
<!-- Bahmni Appointments -->
24+
<mapping resource="Speciality.hbm.xml"/>
25+
<mapping resource="AppointmentServiceDefinition.hbm.xml"/>
26+
<mapping resource="ServiceWeeklyAvailability.hbm.xml"/>
27+
<mapping resource="AppointmentServiceType.hbm.xml"/>
28+
<!-- Reporting - For Validator -->
29+
<mapping resource="ReportDesign.hbm.xml"/>
30+
<!-- Provider Management -->
31+
<mapping resource="ProviderRole.hbm.xml"/>
32+
<!-- Cohort -->
33+
<mapping resource="CohortAttributeType.hbm.xml"/>
34+
<mapping resource="CohortAttribute.hbm.xml"/>
35+
<mapping resource="CohortMemberAttribute.hbm.xml"/>
36+
<mapping resource="CohortMemberAttributeType.hbm.xml"/>
37+
<!-- Patient Flags -->
38+
<mapping resource="DisplayPoint.hbm.xml"/>
39+
<mapping resource="Flag.hbm.xml"/>
40+
<mapping resource="Priority.hbm.xml"/>
41+
<mapping resource="Tag.hbm.xml"/>
42+
<mapping resource="PatientFlag.hbm.xml"/>
843
<!-- Bahmni Core -->
944
<mapping resource="ProgramAttributeType.hbm.xml"/>
1045
</session-factory>

api/src/main/java/org/openmrs/module/initializer/api/display/DisplaysPreLoader.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
import org.openmrs.OpenmrsObject;
44
import org.openmrs.module.initializer.api.BaseLineProcessor;
55
import org.openmrs.module.initializer.api.CsvParser;
6+
import org.openmrs.module.initializer.api.c.LocalizedHeader;
67
import org.openmrs.module.initializer.api.loaders.BaseCsvLoader;
8+
import org.openmrs.module.initializer.api.utils.IgnoreBOMInputStream;
79
import org.springframework.beans.factory.annotation.Autowired;
810
import org.springframework.stereotype.Component;
911

12+
import java.io.File;
13+
import java.io.FileInputStream;
14+
import java.io.InputStream;
15+
16+
import static org.openmrs.module.initializer.api.display.DisplayLineProcessor.HEADER_DISPLAY;
17+
1018
@Component
1119
public class DisplaysPreLoader extends BaseCsvLoader<OpenmrsObject, DisplaysCsvParser> {
1220

@@ -40,4 +48,14 @@ public void setBootstrapParser(
4048
this.parser.setBootstrapParser(parser);
4149
}
4250

51+
@Override
52+
public void load(File file) throws Exception {
53+
try (InputStream is = new IgnoreBOMInputStream(new FileInputStream(file))) {
54+
final CsvParser<OpenmrsObject, BaseLineProcessor<OpenmrsObject>> parser = getParser(is);
55+
LocalizedHeader lh = LocalizedHeader.getLocalizedHeader(parser.getHeaderLine(), HEADER_DISPLAY);
56+
if (lh != null && !lh.getLocales().isEmpty()) {
57+
super.load(file);
58+
}
59+
}
60+
}
4361
}

api/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitiveTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected void initModules() {
153153
{
154154
try {
155155
Class.forName("org.bahmni.module.bahmnicore.Activator");
156-
Module mod = new Module("", "bahmnicore", "", "", "", "0.94-SNAPSHOT");
156+
Module mod = new Module("", "bahmnicore", "", "", "", "0.93-1.1.0");
157157
mod.setFile(new File(""));
158158
ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod);
159159
}

0 commit comments

Comments
 (0)