/** * 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(); }
/** * Gets the destination directory for hl7 archives. * * @return The destination directory for the hl7 in archive */ public static File getHl7ArchivesDirectory() throws APIException { String archiveDir = Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_HL7_ARCHIVE_DIRECTORY); if (StringUtils.isBlank(archiveDir)) { log.warn("Invalid value for global property '" + OpenmrsConstants.GLOBAL_PROPERTY_HL7_ARCHIVE_DIRECTORY + "', trying to set a default one"); archiveDir = HL7Constants.HL7_ARCHIVE_DIRECTORY_NAME; log.debug("Using '" + archiveDir + "' in the application data directory as the root directory for hl7_in_archives"); } return OpenmrsUtil.getDirectoryInApplicationDataDirectory(archiveDir); } }
/** * Convenience method to create and return a file for the stored ComplexData.data Object * * @param obs * @return File object */ public static File getComplexDataFile(Obs obs) { String[] names = obs.getValueComplex().split("\\|"); String filename = names.length < 2 ? names[0] : names[names.length - 1]; File dir = OpenmrsUtil.getDirectoryInApplicationDataDirectory( Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); return new File(dir, filename); }
File moduleRepository = OpenmrsUtil.getDirectoryInApplicationDataDirectory(moduleRepositoryFolder);
/** * Returns a {@link File} for the given obs complex data to be written to. The output file * location is determined off of the {@link OpenmrsConstants#GLOBAL_PROPERTY_COMPLEX_OBS_DIR} * and the file name is determined off the current obs.getComplexData().getTitle(). * * @param obs the Obs with a non-null complex data on it * @return File that the complex data should be written to */ public File getOutputFileToWrite(Obs obs) throws IOException { String title = obs.getComplexData().getTitle(); String titleWithoutExtension = FilenameUtils.removeExtension(title); String extension = "." + StringUtils.defaultIfEmpty(FilenameUtils.getExtension(title), "dat"); String uuid = obs.getUuid(); String filename; if (StringUtils.isNotBlank(titleWithoutExtension)) { filename = titleWithoutExtension + "_" + uuid + extension; } else { filename = uuid + extension; } File dir = OpenmrsUtil.getDirectoryInApplicationDataDirectory( Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); File outputfile = new File(dir, filename); return outputfile; }
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); File createdFile = new File(complexObsDir, "openmrs_logo_small.gif");
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); File previouslyCreatedFile = new File(complexObsDir, "nameOfFile.txt");
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); final File createdFile = new File(complexObsDir, "nameOfFile.txt");
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); File createdFile = new File(complexObsDir, filename);
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); File createdFile = new File(complexObsDir, "openmrs_logo_small.gif");
/** * @see ObsService#purgeObs(Obs) */ @Test public void purgeObs_shouldDeleteTheGivenObsFromTheDatabase() { ObsService obsService = Context.getObsService(); Obs obs = obsService.getObs(7); obsService.purgeObs(obs); Assert.assertNull(obsService.getObs(7)); executeDataSet(COMPLEX_OBS_XML); Obs complexObs = obsService.getComplexObs(44, ComplexObsHandler.RAW_VIEW); // obs #44 is coded by the concept complex #8473 pointing to ImageHandler // ImageHandler inherits AbstractHandler which handles complex data files on disk assertNotNull(complexObs.getComplexData()); AdministrationService as = Context.getAdministrationService(); File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); for (File file : complexObsDir.listFiles()) { file.delete(); } obsService.purgeObs(complexObs); assertNull(obsService.getObs(obs.getObsId())); }