本文整理汇总了Java中org.openmrs.util.OpenmrsUtil类的典型用法代码示例。如果您正苦于以下问题:Java OpenmrsUtil类的具体用法?Java OpenmrsUtil怎么用?Java OpenmrsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OpenmrsUtil类属于org.openmrs.util包,在下文中一共展示了OpenmrsUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compare
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(FormField formField, FormField other) {
int temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getPageNumber(), other.getPageNumber());
if (temp == 0) {
temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getFieldNumber(), other.getFieldNumber());
}
if (temp == 0) {
temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getFieldPart(), other.getFieldPart());
}
if (temp == 0 && formField.getPageNumber() == null && formField.getFieldNumber() == null
&& formField.getFieldPart() == null) {
temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getSortWeight(), other.getSortWeight());
}
if (temp == 0) {
// to prevent ties
temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getFormFieldId(), other.getFormFieldId());
}
return temp;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:EncounterFormController.java
示例2: compareTo
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Use this row's FormField to make comparisons about where to put it in relation to the
* FieldHolder's
*
* @see org.openmrs.FormField#compareTo(org.openmrs.FormField)
*/
public int compareTo(FieldHolder other) {
int temp = OpenmrsUtil
.compareWithNullAsGreatest(formField.getPageNumber(), other.getFormField().getPageNumber());
if (temp == 0) {
temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getFieldNumber(), other.getFormField()
.getFieldNumber());
}
if (temp == 0) {
temp = OpenmrsUtil.compareWithNullAsGreatest(formField.getFieldPart(), other.getFormField().getFieldPart());
}
if (temp == 0 && formField.getPageNumber() == null && formField.getFieldNumber() == null
&& formField.getFieldPart() == null) {
temp = OpenmrsUtil
.compareWithNullAsGreatest(formField.getSortWeight(), other.getFormField().getSortWeight());
}
return temp;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:24,代码来源:EncounterDisplayController.java
示例3: formBackingObject
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
//map containing the privilege and true/false whether the privilege is core or not
Map<Privilege, Boolean> privilegeList = new LinkedHashMap<Privilege, Boolean>();
//only fill the Object is the user has authenticated properly
if (Context.isAuthenticated()) {
UserService us = Context.getUserService();
for (Privilege p : us.getAllPrivileges()) {
if (OpenmrsUtil.getCorePrivileges().keySet().contains(p.getPrivilege())) {
privilegeList.put(p, true);
} else {
privilegeList.put(p, false);
}
}
}
return privilegeList;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:26,代码来源:PrivilegeListController.java
示例4: formBackingObject
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
//default empty Object
// Object = the role
// Boolean= whether or not the role is a core role (not able to be deleted)
Map<Role, Boolean> roleList = new LinkedHashMap<Role, Boolean>();
//only fill the Object if the user has authenticated properly
if (Context.isAuthenticated()) {
UserService us = Context.getUserService();
for (Role r : us.getAllRoles()) {
if (OpenmrsUtil.getCoreRoles().keySet().contains(r.getRole())) {
roleList.put(r, true);
} else {
roleList.put(r, false);
}
}
}
return roleList;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:28,代码来源:RoleListController.java
示例5: isConceptFound
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Convenient method that determines whether given concept is present in result list or not
*
* @param expected the concept to be checked
* @param result the list of concept lookup result items
* @return true if given concept is present among result items
*/
private boolean isConceptFound(Concept expected, List<Object> result) {
boolean found = Boolean.FALSE;
if (result != null) {
for (Iterator<?> iterator = result.iterator(); iterator.hasNext();) {
Object item = iterator.next();
if (item instanceof ConceptListItem) {
ConceptListItem resultItem = (ConceptListItem) item;
if (resultItem != null && OpenmrsUtil.nullSafeEquals(resultItem.getConceptId(), expected.getConceptId())) {
found = Boolean.TRUE;
break;
}
}
}
}
return found;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:24,代码来源:DWRConceptServiceTest.java
示例6: getFromBackUp
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
private String getFromBackUp(String path) {
String backupFilePath = OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_DHIS2BACKUP_FOLDER + path;
File backupFile = new File(backupFilePath);
if (backupFile.exists()) {
try {
return FileUtils.readFileToString(backupFile);
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
return null;
}
开发者ID:jembi,项目名称:openmrs-module-dhisconnector,代码行数:18,代码来源:DHISConnectorServiceImpl.java
示例7: subDirectoryJSONAndXMLFilePost
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
private void subDirectoryJSONAndXMLFilePost(File file) {
if (file != null && file.exists()) {
if (file.isFile() && (file.getName().endsWith(".json") || file.getName().endsWith(".xml"))) {
try {
String data = FileUtils.readFileToString(file);
String endPoint = file.getPath()
.replace(OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_DATA_FOLDER, "")
.replace(File.separator + file.getName(), "");
if (StringUtils.isNotBlank(data) && StringUtils.isNotBlank(endPoint)) {
file.delete();
postDataToDHISEndpoint(endPoint, data);
}
}
catch (IOException e) {
e.printStackTrace();
}
} else if (file.isDirectory()) {
for (File f : file.listFiles()) {
subDirectoryJSONAndXMLFilePost(f);
}
}
}
}
开发者ID:jembi,项目名称:openmrs-module-dhisconnector,代码行数:25,代码来源:DHISConnectorServiceImpl.java
示例8: permanentlyDeleteMapping
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
@Override
public boolean permanentlyDeleteMapping(DHISMapping mapping) {
File mappingsFolder = new File(OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_MAPPINGS_FOLDER);
boolean deleted = false;
if (mapping != null) {
String mappingFileName = mapping.getName() + "." + mapping.getCreated() + DHISCONNECTOR_MAPPING_FILE_SUFFIX;
if (checkIfDirContainsFile(mappingsFolder, mappingFileName)) {
try {
if ((new File(mappingsFolder.getCanonicalPath() + File.separator + mappingFileName)).delete()) {
deleted = true;
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}
return deleted;
}
开发者ID:jembi,项目名称:openmrs-module-dhisconnector,代码行数:23,代码来源:DHISConnectorServiceImpl.java
示例9: handleSubmission
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
public String handleSubmission(@ModelAttribute("globalPropertiesModel") GlobalPropertiesModel globalPropertiesModel,
Errors errors, WebRequest request, HttpServletRequest req) {
if (Context.hasPrivilege("Manage OWA")) {
globalPropertiesModel.validate(globalPropertiesModel, errors);
if (errors.hasErrors())
return null; // show the form again
AdministrationService administrationService = Context.getAdministrationService();
for (GlobalProperty p : globalPropertiesModel.getProperties()) {
if (p.getProperty().equals(AppManager.KEY_APP_FOLDER_PATH) && p.getPropertyValue().equals("")) {
p.setPropertyValue(OpenmrsUtil.getApplicationDataDirectory()
+ (OpenmrsUtil.getApplicationDataDirectory().endsWith(File.separator) ? "owa" : File.separator
+ "owa"));
} else if (p.getProperty().equals(AppManager.KEY_APP_BASE_URL) && p.getPropertyValue().equals("")) {
p.setPropertyValue("/owa");
}
administrationService.saveGlobalProperty(p);
}
request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService()
.getMessage("general.saved"), WebRequest.SCOPE_SESSION);
}
return "redirect:settings.form";
}
开发者ID:openmrs,项目名称:openmrs-module-owa,代码行数:26,代码来源:SettingsFormController.java
示例10: loadSettings
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
@RequestMapping(value = "/manager", method = RequestMethod.GET)
public String loadSettings(HttpServletRequest request, ModelMap model) {
if (Context.hasPrivilege("Manage OWA")) {
String appFolderPath = appManager.getAppFolderPath();
String appStoreUrl = getStoreUrl();
if (null == appFolderPath) {
String owaAppFolderPath = OpenmrsUtil.getApplicationDataDirectory()
+ (OpenmrsUtil.getApplicationDataDirectory().endsWith(File.separator) ? "owa" : File.separator
+ "owa");
appManager.setAppFolderPath(owaAppFolderPath);
}
if (null == appStoreUrl) {
appManager.setAppStoreUrl("https://modules.openmrs.org");
}
model.clear();
}
return "redirect:manage.form";
}
开发者ID:openmrs,项目名称:openmrs-module-owa,代码行数:22,代码来源:OwaManageController.java
示例11: hasSameValues
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Checks if this reaction has the same values as the given one
*
* @param reaction the reaction whose values to compare with
* @return true if the values match, else false
*/
public boolean hasSameValues(AllergyReaction reaction) {
if (!OpenmrsUtil.nullSafeEquals(getAllergyReactionId(), reaction.getAllergyReactionId())) {
return false;
}
if (!OpenmrsUtil.nullSafeEquals(getReaction(), reaction.getReaction())) {
//if object instances are different but with the same concept id, then not changed
if (getReaction() != null && reaction.getReaction() != null) {
if (!OpenmrsUtil.nullSafeEquals(getReaction().getConceptId(), reaction.getReaction().getConceptId())) {
return false;
}
}
else {
return false;
}
}
if (!OpenmrsUtil.nullSafeEquals(getReactionNonCoded(), reaction.getReactionNonCoded())) {
return false;
}
return true;
}
开发者ID:openmrs,项目名称:openmrs-module-allergyapi,代码行数:28,代码来源:AllergyReaction.java
示例12: serializePatientIdentifiers
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* serializes a list of patient identifiers to a delimited string after sorting and removing blanks
*
* @param identifiers the patient identifiers to be serialized
* @return a string containing all non-blank identifier values delimited by {@link DELIMITER}
*/
private String serializePatientIdentifiers(List<PatientIdentifier> identifiers) {
List<String> idlist = new ArrayList<String>();
for (PatientIdentifier identifier: identifiers) {
String id = identifier.getIdentifier();
if (StringUtils.hasText(id))
idlist.add(id);
}
if (idlist == null || idlist.isEmpty())
return "";
Collections.sort(idlist);
// TODO escape strings in list with DELIMITER before joining
return OpenmrsUtil.join(idlist, MatchingConstants.MULTI_FIELD_DELIMITER);
}
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:23,代码来源:LinkDBConnections.java
示例13: listAvailableBlockingRuns
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Method to get the list of all available blocking runs in the configuration file. This will be
* used to display all blocking run for further modification or deletion from the web front end.
*
* @return list of all blocking runs found in the configuration file
* @deprecated Use listAvailableBlockingRuns_db
*/
@Deprecated
public static final List<String> listAvailableBlockingRuns() {
log.info("Listing all available blocking run");
List<String> blockingRuns = new ArrayList<String>();
String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
File configFile = new File(configFileFolder, MatchingConstants.CONFIG_FILE_NAME);
if (configFile.exists()) {
RecMatchConfig recMatchConfig = XMLTranslator.createRecMatchConfig(XMLTranslator.getXMLDocFromFile(configFile));
List<MatchingConfig> matchingConfigLists = recMatchConfig.getMatchingConfigs();
for (MatchingConfig matchingConfig : matchingConfigLists) {
blockingRuns.add(matchingConfig.getName());
}
}
return blockingRuns;
}
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:27,代码来源:MatchingConfigurationUtils.java
示例14: deleteBlockingRun
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Method to delete a particular blocking run from the configuration file. If the blocking run
* is the last entry in the configuration file, the configuration file will also be deleted.
*
* @param name blocking run name that will be deleted
*/
public static final void deleteBlockingRun(String name) {
log.info("Deleting blocking run with name: " + name);
String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
File configFile = new File(configFileFolder, MatchingConstants.CONFIG_FILE_NAME);
if (configFile.exists()) {
RecMatchConfig recMatchConfig = XMLTranslator.createRecMatchConfig(XMLTranslator.getXMLDocFromFile(configFile));
List<MatchingConfig> matchingConfigLists = recMatchConfig.getMatchingConfigs();
MatchingConfig matchingConfig = findMatchingConfigByName(name, matchingConfigLists);
if (matchingConfig != null) {
matchingConfigLists.remove(matchingConfig);
}
log.info("List Size: " + matchingConfigLists.size());
if (matchingConfigLists.size() > 0) {
XMLTranslator.writeXMLDocToFile(XMLTranslator.toXML(recMatchConfig), configFile);
} else {
log.info("Deleting file: " + configFile.getAbsolutePath());
boolean deleted = configFile.delete();
if (deleted) {
log.info("Config file deleted.");
}
}
}
}
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:32,代码来源:MatchingConfigurationUtils.java
示例15: listAvailableReport
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Method to get the list of the available report for display. The method
* will return all report found in the designated folder in the server.
*
* @return all available report in the server
*/
@Deprecated
public static List<String> listAvailableReport() {
log.info("Listing all available report");
List<String> reports = new ArrayList<String>();
String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
File configFileFolder = OpenmrsUtil
.getDirectoryInApplicationDataDirectory(configLocation);
File[] files = configFileFolder.listFiles();
for (File file : files) {
if (file.getName().startsWith("dedup")) {
reports.add(file.getName());
}
}
Collections.sort(reports);
return reports;
}
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:27,代码来源:MatchingReportUtils.java
示例16: migrateReports
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Method to migrate the old reports to the database
*/
public static void migrateReports() {
String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
for (File file : configFileFolder.listFiles()) {
/*
only the files that has the name starting with "dedup"(for de-duplication) are considered
So the backup files that were already moved and any other files are ignored
*/
if (file.isFile() && file.getName().startsWith("dedup")) {
Report report = flatFileToReport(file);
if (report != null) {
Context.getService(PatientMatchingReportMetadataService.class).savePatientMatchingReport(report);
}
//Backup report file
String backupFileName = "backup-" + file.getName();
file.renameTo(new File(configFileFolder, backupFileName));
log.info("Report migrated to database. File backed up as " + backupFileName);
}
}
}
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:25,代码来源:ReportMigrationUtils.java
示例17: DedupMatchResultList
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
public DedupMatchResultList() {
super();
pairIdList = new ArrayList<RecordPairId>();
flattenedPairIds = new ArrayList<Set<Long>>();
serializedRecord = new TreeSet<Long>();
String configLocation = MatchingConstants.SERIAL_FOLDER_NAME;
File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
cleanUpFolder(configFileFolder);
boolean deleted = configFileFolder.delete();
if (deleted) {
log.info("Deleted record serialization folder ...");
}
}
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:17,代码来源:DedupMatchResultList.java
示例18: getReportTemplateHome
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* Gets folder to store {@code MRRT} templates.
*
* @return templates folder
* @throws IllegalStateException if global property cannot be found
* @should create a directory under the openmrs application data directory if GP value is relative
* @should creates a directory at GP value if it is an absolute path
* @should throw illegal state exception if global property cannot be found
*/
public File getReportTemplateHome() {
Path templatesPath = Paths.get(getGlobalProperty(RadiologyConstants.GP_MRRT_REPORT_TEMPLATE_DIR, true));
if (!templatesPath.isAbsolute()) {
templatesPath = Paths.get(OpenmrsUtil.getApplicationDataDirectory(), templatesPath.toString());
}
if (!templatesPath.toFile()
.exists()) {
templatesPath.toFile()
.mkdirs();
}
return templatesPath.toFile();
}
开发者ID:openmrs,项目名称:openmrs-module-radiology,代码行数:25,代码来源:RadiologyProperties.java
示例19: shouldCreateADirectoryUnderTheOpenmrsApplicationDataDirectoryIfGPValueIsRelative
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* @see RadiologyProperties#getReportTemplateHome()
*/
@Test
public void shouldCreateADirectoryUnderTheOpenmrsApplicationDataDirectoryIfGPValueIsRelative() throws Exception {
File openmrsApplicationDataDirectory = temporaryFolder.newFolder("openmrs_home");
OpenmrsUtil.setApplicationDataDirectory(openmrsApplicationDataDirectory.getAbsolutePath());
administrationService.setGlobalProperty(RadiologyConstants.GP_MRRT_REPORT_TEMPLATE_DIR, "mrrt_templates");
File templateHome = radiologyProperties.getReportTemplateHome();
File templateHomeFromGP =
new File(administrationService.getGlobalProperty(RadiologyConstants.GP_MRRT_REPORT_TEMPLATE_DIR));
assertNotNull(templateHome);
assertThat(templateHome.exists(), is(true));
assertThat(templateHome.getName(), is(templateHomeFromGP.getName()));
assertThat(templateHome.getParentFile()
.getName(),
is(openmrsApplicationDataDirectory.getName()));
}
开发者ID:openmrs,项目名称:openmrs-module-radiology,代码行数:20,代码来源:RadiologyPropertiesComponentTest.java
示例20: equals
import org.openmrs.util.OpenmrsUtil; //导入依赖的package包/类
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof ConceptReferenceTermListItem) {
ConceptReferenceTermListItem term2 = (ConceptReferenceTermListItem) obj;
OpenmrsUtil.nullSafeEquals(conceptReferenceTermId, term2.getConceptReferenceTermId());
}
return false;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:12,代码来源:ConceptReferenceTermListItem.java
注:本文中的org.openmrs.util.OpenmrsUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论