private boolean isConceptProposal(String identifier) { return OpenmrsUtil.nullSafeEquals(identifier, OpenmrsConstants.PROPOSED_CONCEPT_IDENTIFIER); }
folder = new File(OpenmrsUtil.getApplicationDataDirectory(), folderName);
/** * Returns true if this {@link PatientState} is active as of the passed {@link Date} * * @param onDate - {@link Date} to check for {@link PatientState} enrollment * @return boolean - true if this {@link PatientState} is active as of the passed {@link Date} * @should return false if voided and date in range * @should return false if voided and date not in range * @should return true if not voided and date in range * @should return false if not voided and date earlier than startDate * @should return false if not voided and date later than endDate * @should return true if not voided and date in range with null startDate * @should return true if not voided and date in range with null endDate * @should return true if not voided and both startDate and endDate nulled * @should compare with current date if date null */ public boolean getActive(Date onDate) { if (onDate == null) { onDate = new Date(); } return !getVoided() && (OpenmrsUtil.compareWithNullAsEarliest(startDate, onDate) <= 0) && (OpenmrsUtil.compareWithNullAsLatest(endDate, onDate) > 0); }
private void setDatabaseNameIfInTestMode() { if (OpenmrsUtil.isTestMode()) { wizardModel.databaseName = OpenmrsUtil.getOpenMRSVersionInTestMode(); } }
private void setApplicationDataDirectory(ServletContext servletContext) { // note: the below value will be overridden after reading the runtime properties if the // "application_data_directory" runtime property is set String appDataDir = servletContext.getInitParameter("application.data.directory"); if (StringUtils.hasLength(appDataDir)) { OpenmrsUtil.setApplicationDataDirectory(appDataDir); } else if (!"openmrs".equalsIgnoreCase(WebConstants.WEBAPP_NAME)) { OpenmrsUtil.setApplicationDataDirectory( OpenmrsUtil.getApplicationDataDirectory() + File.separator + WebConstants.WEBAPP_NAME); } }
/** * Compares asOfDate to [startDate, endDate], inclusive of both endpoints. * @param asOfDate date to compare if membership is active or inactive * @return boolean true/false if membership is active/inactive */ public boolean isActive(Date asOfDate) { Date date = asOfDate == null ? new Date() : asOfDate; return !this.getVoided() && OpenmrsUtil.compare(startDate, date) <= 0 && OpenmrsUtil.compareWithNullAsLatest(date, endDate) <= 0; }
try { outStream = new FileOutputStream(file); OpenmrsUtil.copyFile(input, outStream);
/** * @see org.openmrs.hl7.HL7Service#loadHL7InArchiveData(HL7InArchive) */ @Override public void loadHL7InArchiveData(HL7InArchive archive) throws APIException { // quit early if there is no archive to work with if (archive == null) { return; } // quit early if the message is not migrated or already loaded if (!OpenmrsUtil.nullSafeEquals(archive.getMessageState(), HL7Constants.HL7_STATUS_MIGRATED) || archive.isLoaded()) { return; } try { archive.setHL7Data(OpenmrsUtil.getFileAsString(new File(new URI(archive.getHL7Data())))); archive.setLoaded(true); } catch (URISyntaxException e) { throw new APIException("Hl7Service.malformed.archive.location", new Object[] { archive.getHL7Data() }, e); } catch (IOException e) { throw new APIException("Hl7Service.unable.convert.archive", new Object[] { archive.getHL7Data() }, e); } }
/** * Checks whether orderable of this drug order is same as other order * * @since 1.10 * @param otherOrder the other order to match on * @return true if the drugs match * @should return false if the other order is null * @should return false if the other order is not a drug order * @should return false if both drugs are null and the concepts are different * @should return false if the concepts match and only this has a drug * @should return false if the concepts match and only the other has a drug * @should return false if the concepts match and drugs are different and not null * @should return true if both drugs are null and the concepts match * @should return true if the drugs match */ @Override public boolean hasSameOrderableAs(Order otherOrder) { if (!super.hasSameOrderableAs(otherOrder)) { return false; } if (!(otherOrder instanceof DrugOrder)) { return false; } DrugOrder otherDrugOrder = (DrugOrder) otherOrder; if (isNonCodedDrug() || otherDrugOrder.isNonCodedDrug()) { return OpenmrsUtil.nullSafeEqualsIgnoreCase(this.getDrugNonCoded(), otherDrugOrder.getDrugNonCoded()); } return OpenmrsUtil.nullSafeEquals(this.getDrug(), otherDrugOrder.getDrug()); }
@Override public int compare(PersonAttribute pa1, PersonAttribute pa2) { int retValue; if ((retValue = OpenmrsUtil.compareWithNullAsGreatest(pa1.getAttributeType(), pa2.getAttributeType())) != 0) { return retValue; } if ((retValue = pa1.getVoided().compareTo(pa2.getVoided())) != 0) { return retValue; } if ((retValue = OpenmrsUtil.compareWithNullAsLatest(pa1.getDateCreated(), pa2.getDateCreated())) != 0) { return retValue; } if ((retValue = OpenmrsUtil.compareWithNullAsGreatest(pa1.getValue(), pa2.getValue())) != 0) { return retValue; } return OpenmrsUtil.compareWithNullAsGreatest(pa1.getPersonAttributeId(), pa2.getPersonAttributeId()); } }
Properties props = new Properties(); OpenmrsUtil.loadProperties(props, propertyStream); propertyStream.close(); final String applicationDataDirectory = OpenmrsUtil.getApplicationDataDirectory(); for (Entry<Object, Object> entry : config.entrySet()) { String value = (String) entry.getValue();
/** * Returns the location of the OpenMRS log file. * * @return the path to the OpenMRS log file * @since 1.9.2 */ public static String getOpenmrsLogLocation() { String logPathGP = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GP_LOG_LOCATION, ""); File logPath = OpenmrsUtil.getDirectoryInApplicationDataDirectory(logPathGP); File logFile = new File(logPath, "openmrs.log"); return logFile.getPath(); }
OpenmrsConstants.APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY); if (StringUtils.isNotBlank(appDataDirectory)) { OpenmrsUtil.setApplicationDataDirectory(appDataDirectory); File moduleRepository = OpenmrsUtil.getDirectoryInApplicationDataDirectory(moduleRepositoryFolder); OpenmrsUtil.copyFile(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream( new File(moduleRepository, fileName)))); } else {
/** * Compares by startDate with null as earliest and endDate with null as latest. * * @see java.lang.Comparable#compareTo(java.lang.Object) * @should return positive if startDates equal and this endDate null * @should return negative if this startDate null * @should pass if two states have the same start date, end date and uuid * @should return positive or negative if two states have the same start date and end date but different uuids * Note: this comparator imposes orderings that are inconsistent with equals. */ @SuppressWarnings("squid:S1210") @Override public int compareTo(PatientState o) { int result = OpenmrsUtil.compareWithNullAsEarliest(getStartDate(), o.getStartDate()); if (result == 0) { result = OpenmrsUtil.compareWithNullAsLatest(getEndDate(), o.getEndDate()); } if (result == 0) { result = OpenmrsUtil.compareWithNullAsGreatest(getUuid(), o.getUuid()); } return result; } }
/** * Convenience method to load the runtime properties file. * * @return the runtime properties file. */ private File getRuntimePropertiesFile() { File file; String pathName = OpenmrsUtil.getRuntimePropertiesFilePathName(WebConstants.WEBAPP_NAME); if (pathName != null) { file = new File(pathName); } else { file = new File(OpenmrsUtil.getApplicationDataDirectory(), getRuntimePropertiesFileName()); } log.debug("Using file: " + file.getAbsolutePath()); return file; }
libCacheFolder = new File(OpenmrsUtil.getApplicationDataDirectory(), LIBCACHESUFFIX); OpenmrsUtil.deleteDirectory(libCacheFolder);
@Test public void join_shouldReturnListElementsJoinedBySeparatorIfGivenCollectionContainsNull() { List<String> listWithNull = Arrays.asList("module1", null, "module2"); assertThat(OpenmrsUtil.join(listWithNull, ","), is("module1,null,module2")); }
OpenmrsUtil.validateJavaVersion(); .getProperty(OpenmrsConstants.APPLICATION_DATA_DIRECTORY_RUNTIME_PROPERTY, null); if (StringUtils.hasLength(appDataRuntimeProperty)) { OpenmrsUtil.setApplicationDataDirectory(null); contextLog.setLevel(Level.INFO); contextLog.info("Using runtime properties file: " + OpenmrsUtil.getRuntimePropertiesFilePathName(WebConstants.WEBAPP_NAME));
OpenmrsUtil.getApplicationDataDirectory().replace("\\", "/")); try { fos = new FileOutputStream(getRuntimePropertiesFile()); OpenmrsUtil.storeProperties(runtimeProperties, fos, "Auto generated by OpenMRS initialization wizard"); wizardModel.workLog.add("Saved runtime properties file " + getRuntimePropertiesFile());
pathName = getRuntimePropertiesFilePathName(applicationName); FileInputStream propertyStream = null; try { OpenmrsUtil.loadProperties(props, propertyStream); propertyStream.close(); log.info("Using runtime properties file: " + pathName);