-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "FM2-642: Improve performance of loading locations by tag (#547)"
This reverts commit ca8bf98.
- Loading branch information
Showing
62 changed files
with
529 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
api/src/main/java/org/openmrs/module/fhir2/api/dao/FhirGlobalPropertyDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.api.dao; | ||
|
||
import java.util.Map; | ||
|
||
import org.openmrs.GlobalProperty; | ||
import org.openmrs.annotation.Authorized; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.util.PrivilegeConstants; | ||
|
||
public interface FhirGlobalPropertyDao { | ||
|
||
@Authorized(PrivilegeConstants.GET_GLOBAL_PROPERTIES) | ||
String getGlobalProperty(String property) throws APIException; | ||
|
||
@Authorized(PrivilegeConstants.GET_GLOBAL_PROPERTIES) | ||
GlobalProperty getGlobalPropertyObject(String property); | ||
|
||
@Authorized(PrivilegeConstants.GET_GLOBAL_PROPERTIES) | ||
Map<String, String> getGlobalProperties(String... properties); | ||
} |
62 changes: 62 additions & 0 deletions
62
api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirGlobalPropertyDaoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.api.dao.impl; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hibernate.SessionFactory; | ||
import org.hibernate.criterion.Restrictions; | ||
import org.openmrs.GlobalProperty; | ||
import org.openmrs.api.APIException; | ||
import org.openmrs.module.fhir2.api.dao.FhirGlobalPropertyDao; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Setter(AccessLevel.PACKAGE) | ||
public class FhirGlobalPropertyDaoImpl implements FhirGlobalPropertyDao { | ||
|
||
@Autowired | ||
@Qualifier("sessionFactory") | ||
private SessionFactory sessionFactory; | ||
|
||
@Override | ||
public String getGlobalProperty(String property) throws APIException { | ||
GlobalProperty globalProperty = (GlobalProperty) sessionFactory.getCurrentSession().get(GlobalProperty.class, | ||
property); | ||
return globalProperty == null ? null : globalProperty.getPropertyValue(); | ||
} | ||
|
||
@Override | ||
public GlobalProperty getGlobalPropertyObject(String property) { | ||
return (GlobalProperty) sessionFactory.getCurrentSession().createCriteria(GlobalProperty.class) | ||
.add(Restrictions.eq("property", property)).uniqueResult(); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public Map<String, String> getGlobalProperties(String... properties) { | ||
Map<String, String> globalPropertiesMap = new HashMap<>(); | ||
|
||
Collection<GlobalProperty> globalProperties = (sessionFactory.getCurrentSession() | ||
.createCriteria(GlobalProperty.class).add(Restrictions.in("property", properties)).list()); | ||
|
||
for (GlobalProperty property : globalProperties) { | ||
globalPropertiesMap.put(property.getProperty(), property.getPropertyValue()); | ||
} | ||
|
||
return globalPropertiesMap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.