当前位置: 首页>>代码示例>>Java>>正文


Java OpenmrsUtil.getDirectoryInApplicationDataDirectory方法代码示例

本文整理汇总了Java中org.openmrs.util.OpenmrsUtil.getDirectoryInApplicationDataDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java OpenmrsUtil.getDirectoryInApplicationDataDirectory方法的具体用法?Java OpenmrsUtil.getDirectoryInApplicationDataDirectory怎么用?Java OpenmrsUtil.getDirectoryInApplicationDataDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openmrs.util.OpenmrsUtil的用法示例。


在下文中一共展示了OpenmrsUtil.getDirectoryInApplicationDataDirectory方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: serialize

import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
 * Perform the serialization process of the record. The output will be stored
 * in the predefined folders which is not visible to the users.
 * 
 * UID of the <code>Record</code> object will be the output file name of the
 * serialization process
 * 
 * @param record that will be serialized
 * @throws IOException
 */
public static void serialize(Record record) throws FileNotFoundException, SecurityException, IOException {
	String filename = String.valueOf(record.getUID());
	
	String configLocation = MatchingConstants.SERIAL_FOLDER_NAME;
       File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
       File serialFile = new File(configFileFolder, filename);
       
       // only serialize if the same record have not been serialized before
       if (!serialFile.exists()) {
           FileOutputStream outputStream = new FileOutputStream(serialFile);
           stream.toXML(record, outputStream);
           outputStream.close();
       }
}
 
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:25,代码来源:RecordSerializer.java

示例7: deserialize

import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
 * Perform the de-serialization process. This will read the xml output of
 * the serialization process and try to reconstruct the <code>Record</code>
 * object from the xml file.
 * 
 * @param xmlName the uid of the record
 * @return <code>Record</code> object constructed from the xml file
 * @throws IOException
 */
public static Record deserialize(String xmlName) throws FileNotFoundException, SecurityException {
	String configLocation = MatchingConstants.SERIAL_FOLDER_NAME;
       File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
       File serialFile = new File(configFileFolder, xmlName);
       
	FileInputStream fis = new FileInputStream(serialFile);
	//hack: need to do this to let know XStream the appropriate type of object to be created
       stream.setClassLoader(new Record(-999, "OpenMRS").getClass().getClassLoader());
       record = (Record) stream.fromXML(fis);
       return record;
}
 
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:21,代码来源:RecordSerializer.java

示例8: loadPatientMatchingConfig

import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
 * Retrieve a particular matching configuration from a configuration file based on the blocking
 * run name and then return it as <code>PatientMatchingConfiguration</code> object to the web
 * controller
 * 
 * @param name the blocking run name
 * @return <code>PatientMatchingObject</code> representing the selected blocking run
 */
public static final PatientMatchingConfiguration loadPatientMatchingConfig(String name,
                                                                           List<String> listExcludedProperties) {
	String configurationFolder = MatchingConstants.CONFIG_FOLDER_NAME;
	File configurationFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configurationFolder);
	File configurationFile = new File(configurationFileFolder, MatchingConstants.CONFIG_FILE_NAME);
	
	PatientMatchingConfiguration patientMatchingConfig = createPatientMatchingConfig(listExcludedProperties);
	log.info("Loading PatientMatchingConfig with name: " + name);
	
	if (configurationFile.exists()) {
		RecMatchConfig recMatchConfig = XMLTranslator.createRecMatchConfig(XMLTranslator
		        .getXMLDocFromFile(configurationFile));
		List<MatchingConfig> matchingConfigList = recMatchConfig.getMatchingConfigs();
		MatchingConfig matchingConfig = findMatchingConfigByName(name, matchingConfigList);
		
		for (ConfigurationEntry configEntry : patientMatchingConfig.getConfigurationEntries()) {
			MatchingConfigRow configRow = matchingConfig.getMatchingConfigRowByName(configEntry.getFieldName());
			configEntry.setBlockOrder(configRow.getBlockOrder());
			
			if (configRow.isIncluded() || configRow.getBlockOrder() > 0) {
				configRow.setSetID(configRow.getSetID());
				configEntry.setSET(configRow.getSetID());
			}
			if (configRow.isIncluded()) {
				configEntry.setIncluded();
			}
			if (configRow.getBlockOrder() > 0) {
				configEntry.setBlocking();
				
			}
		}
		
		PatientMatchingReportMetadataService service = Context.getService(PatientMatchingReportMetadataService.class);
		PatientMatchingConfiguration newMatchingConfiguration = service.findPatientMatchingConfigurationByName(name);
		
		//Collections.sort(patientMatchingConfig.getConfigurationEntries());
		//Collections.sort(newMatchingConfiguration.getConfigurationEntries());
		patientMatchingConfig.setConfigurationEntries(newMatchingConfiguration.getConfigurationEntries());
		
		patientMatchingConfig.setConfigurationName(newMatchingConfiguration.getConfigurationName());
		patientMatchingConfig.setUsingRandomSample(newMatchingConfiguration.isUsingRandomSample());
		patientMatchingConfig.setRandomSampleSize(newMatchingConfiguration.getRandomSampleSize());
	}
	return patientMatchingConfig;
}
 
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:54,代码来源:MatchingConfigurationUtils.java

示例9: ReadConfigFile

import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
public static Map<String, Object> ReadConfigFile(Map<String,Object> objects, String[] selectedStrategies){
	log.info("Starting generate report process sequence");
	
	// open the config.xml file
	String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
	File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
	File configFile = new File(configFileFolder, MatchingConstants.CONFIG_FILE_NAME);

	log.info("Reading matching config file from " + configFile.getAbsolutePath());
	
	RecMatchConfig recMatchConfig = XMLTranslator.createRecMatchConfig(XMLTranslator.getXMLDocFromFile(configFile));
	List<PatientMatchingConfiguration> configList = Context.getService(PatientMatchingReportMetadataService.class).getMatchingConfigs();
       List<MatchingConfig> matchingConfigLists = new ArrayList<MatchingConfig>();

	for (String selectedStrat : selectedStrategies) {
		for (PatientMatchingConfiguration config : configList) {
			if (OpenmrsUtil.nullSafeEquals(config.getConfigurationName(), selectedStrat)) {
				matchingConfigLists.add(ReportMigrationUtils.ptConfigurationToMatchingConfig(config));
			}
		}
	}
	
	DedupMatchResultList handler = new DedupMatchResultList();

	Properties c = Context.getRuntimeProperties();

	String url = c.getProperty("connection.url");
	String user = c.getProperty("connection.username");
	String passwd = c.getProperty("connection.password");
	String driver = c.getProperty("connection.driver_class");
	log.info("URL: " + url);

	Connection databaseConnection = null;
	try {
		Class.forName(driver);
		ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
				url, user, passwd);
		databaseConnection = connectionFactory.createConnection();
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	
	objects.put("databaseConnection", databaseConnection);
	objects.put("recMatchConfig", recMatchConfig);
	objects.put("driver", driver);
	objects.put("url", url);
	objects.put("user", user);
	objects.put("passwd", passwd);
	objects.put("matchingConfigLists", matchingConfigLists);
	objects.put("configFileFolder", configFileFolder);
	objects.put("handler", handler);
	return objects;
}
 
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:54,代码来源:MatchingReportUtils.java

示例10: migrateConfigurations

import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
 * This method migrates the old configurations from the config.xml to the database
 */
public static void migrateConfigurations() {
    String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
    File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
    File configFile = new File(configFileFolder, MatchingConstants.CONFIG_FILE_NAME);

    if(!configFile.exists()){
       return;
    }

    RecMatchConfig recMatchConfig = XMLTranslator.createRecMatchConfig(XMLTranslator.getXMLDocFromFile(configFile));
    List<MatchingConfig> matchConf = recMatchConfig.getMatchingConfigs();

    PatientMatchingReportMetadataService metadataService = Context.getService(PatientMatchingReportMetadataService.class);

    List<String> existingConfigList = MatchingConfigurationUtils.listAvailableBlockingRuns_db();

    for (MatchingConfig conf : matchConf) {
        if (existingConfigList.contains(conf.getName())) {
            log.warn("There exists a configuration in the database with same name as " + conf.getName() + ". The configuration Ignored.");
            continue;
        }
        PatientMatchingConfiguration configuration = new PatientMatchingConfiguration();
        configuration.setConfigurationName(conf.getName());
        Set<ConfigurationEntry> configurationEntries = new TreeSet<ConfigurationEntry>();
        for (MatchingConfigRow row : conf.getMatchingConfigRows()) {
            if (row.isIncluded()) {
                ConfigurationEntry entry = new ConfigurationEntry();
                entry.setFieldName(row.getName());
                entry.setSET(row.getSetID());
                entry.setPatientMatchingConfiguration(configuration);

                //set name and view name
                if (row.getName().startsWith("org.openmrs")) {
                    entry.setFieldViewName("patientmatching." + row.getName());
                } else {
                    entry.setFieldViewName(row.getName());
                }

                //Check whether must match field or should match field
                if (row.getBlockOrder() > 0) {
                    entry.setBlocking();
                    entry.setBlockOrder(row.getBlockOrder());
                } else {
                    entry.setIncluded();
                }
                configurationEntries.add(entry);
            }
        }
        configuration.setConfigurationEntries(configurationEntries);
        configuration.setUsingRandomSample(conf.isUsingRandomSampling());
        configuration.setRandomSampleSize(conf.getRandomSampleSize());
        metadataService.savePatientMatchingConfiguration(configuration);
        log.info("Configuration " + conf.getName() + " successfully migrated to database");
    }
}
 
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:59,代码来源:ReportMigrationUtils.java

示例11: setReportFile

import org.openmrs.util.OpenmrsUtil; //导入方法依赖的package包/类
/**
 * Select report file name that will be processed by this class.
 * 
 * @param filename
 */
private void setReportFile(String filename) {
    String configLocation = MatchingConstants.CONFIG_FOLDER_NAME;
    File configFileFolder = OpenmrsUtil.getDirectoryInApplicationDataDirectory(configLocation);
    reportFile = new File(configFileFolder, filename);
}
 
开发者ID:openmrs,项目名称:openmrs-module-patientmatching,代码行数:11,代码来源:MatchingReportReader.java


注:本文中的org.openmrs.util.OpenmrsUtil.getDirectoryInApplicationDataDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。