Example #1
0
  private BlockingService processBlockingConfiguration(MpiConfigDocument configuration) {
    checkConfiguration(configuration);

    if (configuration.getMpiConfig().getBlockingConfigurationArray() == null) {
      return null;
    }

    int count = configuration.getMpiConfig().getBlockingConfigurationArray().length;
    BlockingService blockingService = null;
    for (int i = 0; i < count; i++) {
      BlockingConfigurationType obj = configuration.getMpiConfig().getBlockingConfigurationArray(i);
      if (obj == null) {
        log.warn("No blocking service configuration has been specified.");
        return null;
      }
      log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI());
      String namespaceUriStr = obj.getDomNode().getNamespaceURI();
      URI namespaceURI = getNamespaceURI(namespaceUriStr);

      String resourcePath = generateComponentResourcePath(namespaceURI);
      Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath);

      String configurationLoaderBean = getExtensionBeanNameFromComponent(component);

      ConfigurationLoader loader =
          (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean);
      loader.loadAndRegisterComponentConfiguration(this, obj);

      Component.Extension extension =
          component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION);
      if (extension == null) {
        log.error(
            "Encountered a custom blocking component with no implementation extension: "
                + component);
        throw new InitializationException(
            "Unable to locate an implementation component for custom blocking component "
                + component.getName());
      }
      log.debug(
          "Registering implementation of blocking component named "
              + extension.getName()
              + " and implementation key "
              + extension.getImplementationKey());
      blockingService =
          (BlockingService)
              Context.getApplicationContext().getBean(extension.getImplementationKey());

      String entity = loader.getComponentEntity();
      log.info("Registering blocking service " + blockingService + " for entity " + entity);
      Context.registerCustomBlockingService(entity, blockingService);
    }
    return blockingService;
  }
 @Test
 public void testLoadingOfConfigurationFile() {
   try {
     MpiConfigDocument configDocument = loadConfigurationFromSource();
     MpiConfigImpl mpiconfig = (MpiConfigImpl) configDocument.getMpiConfig();
     Object obj = mpiconfig.getFileLoaderConfiguration();
     System.out.println("Type is " + mpiconfig.getClass());
     log.debug("Admin Configuration is: " + configDocument.getMpiConfig().getAdminConfiguration());
     log.debug(
         "Blocking Configuration is: " + configDocument.getMpiConfig().getBlockingConfiguration());
     log.debug(
         "Custom Fields Configuration is: " + configDocument.getMpiConfig().getCustomFields());
     log.debug(
         "File Loader Configuration is: "
             + configDocument.getMpiConfig().getFileLoaderConfiguration());
     log.debug(
         "Global Identifier Configuration is: "
             + configDocument.getMpiConfig().getGlobalIdentifier());
     log.debug(
         "Matching Configuration is: " + configDocument.getMpiConfig().getMatchingConfiguration());
   } catch (XmlException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Example #3
0
 private GlobalIdentifier processGlobalIdentifier(MpiConfigDocument configuration) {
   globalIdentifier = new GlobalIdentifier();
   if (!configuration.getMpiConfig().isSetGlobalIdentifier()) {
     globalIdentifier.setAssignGlobalIdentifier(false);
     return globalIdentifier;
   }
   globalIdentifier.setAssignGlobalIdentifier(
       configuration.getMpiConfig().getGlobalIdentifier().getAssignGlobalIdentifier());
   globalIdentifier.setIdentifierDomainName(
       configuration.getMpiConfig().getGlobalIdentifier().getIdentifierDomainName());
   globalIdentifier.setIdentifierDomainDescription(
       configuration.getMpiConfig().getGlobalIdentifier().getIdentifierDomainDescription());
   globalIdentifier.setNamespaceIdentifier(
       configuration.getMpiConfig().getGlobalIdentifier().getNamespaceIdentifier());
   globalIdentifier.setUniversalIdentifier(
       configuration.getMpiConfig().getGlobalIdentifier().getUniversalIdentifier());
   globalIdentifier.setUniversalIdentifierType(
       configuration.getMpiConfig().getGlobalIdentifier().getUniversalIdentifierType());
   IdentifierDomain domain =
       Context.getPersonQueryService()
           .findIdentifierDomainByName(globalIdentifier.getIdentifierDomainName());
   if (domain == null) {
     log.error(
         "Global identifier domain not found; correct system configuration and start system again.");
     System.exit(-1);
   }
   globalIdentifier.setIdentifierDomain(domain);
   return globalIdentifier;
 }
Example #4
0
  private void processSingleBestRecordConfiguration(MpiConfigDocument configuration) {
    checkConfiguration(configuration);
    if (configuration.getMpiConfig().sizeOfSingleBestRecordArray() == 0) {
      log.warn("No single best record configuration has been specified.");
      return;
    }
    SingleBestRecordType obj = configuration.getMpiConfig().getSingleBestRecordArray(0);
    log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI());
    String namespaceUriStr = obj.getDomNode().getNamespaceURI();
    URI namespaceURI = getNamespaceURI(namespaceUriStr);

    String resourcePath = generateComponentResourcePath(namespaceURI);
    Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath);

    String configurationLoaderBean = getExtensionBeanNameFromComponent(component);

    ConfigurationLoader loader =
        (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean);
    loader.loadAndRegisterComponentConfiguration(this, obj);

    Component.Extension extension =
        component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION);
    if (extension == null) {
      log.error(
          "Encountered a custom single best record component with no implementation extension: "
              + component);
      throw new InitializationException(
          "Unable to locate an implementation component for custom single best record component "
              + component.getName());
    }
    log.debug(
        "Registering implementation of single best record component named "
            + extension.getName()
            + " and implementation key "
            + extension.getImplementationKey());
    SingleBestRecordService singleBestRecordService =
        (SingleBestRecordService)
            Context.getApplicationContext().getBean(extension.getImplementationKey());
    Context.registerCustomSingleBestRecordService(singleBestRecordService);
  }
Example #5
0
 public void saveConfiguration() {
   File file = getDefaultConfigurationFile();
   log.info("Storing current configuration in file: " + file.getAbsolutePath());
   try {
     XmlOptions opts = new XmlOptions();
     opts.setSavePrettyPrint();
     opts.setSavePrettyPrintIndent(4);
     configuration.save(file, opts);
   } catch (IOException e) {
     log.error("Unable to save the updated configuration in file: " + file.getAbsolutePath());
     throw new RuntimeException("Unable to save the updated configuration: " + e.getMessage());
   }
 }
Example #6
0
  private void validateConfiguration(MpiConfigDocument configuration) {

    // Set up the validation error listener.
    ArrayList<XmlError> validationErrors = new ArrayList<XmlError>();
    XmlOptions validationOptions = new XmlOptions();
    validationOptions.setErrorListener(validationErrors);

    // During validation, errors are added to the ArrayList for
    // retrieval and printing by the printErrors method.
    boolean isValid = configuration.validate(validationOptions);

    // Print the errors if the XML is invalid.
    if (!isValid) {
      java.util.Iterator<XmlError> iter = validationErrors.iterator();
      StringBuffer sb = new StringBuffer("MPI Configuration validation errors:\n");
      while (iter.hasNext()) {
        sb.append(">> ").append(iter.next()).append("\n");
      }
    }
  }
Example #7
0
  private List<ScheduledTaskEntry> processScheduledTasks(MpiConfigDocument configuration) {
    checkConfiguration(configuration);

    List<ScheduledTaskEntry> list = new ArrayList<ScheduledTaskEntry>();
    ScheduledTasks tasks = configuration.getMpiConfig().getScheduledTasks();
    if (tasks == null) {
      log.warn("No scheduled tasks have been specified in the configuration.");
      return list;
    }

    for (int i = 0; i < tasks.sizeOfScheduledTaskArray(); i++) {
      org.openhie.openempi.configuration.xml.ScheduledTask taskXml = tasks.getScheduledTaskArray(i);
      ScheduledTaskEntry entry = buildScheduledTaskFromXml(taskXml);
      if (entry != null) {
        list.add(entry);
      }
    }
    registerConfigurationEntry(null, ConfigurationRegistry.SCHEDULED_TASK_LIST, list);
    return list;
  }
Example #8
0
  private AdminConfiguration processAdminConfiguration(MpiConfigDocument configuration) {
    adminConfiguration = new AdminConfiguration();
    if (configuration.getMpiConfig().getAdminConfiguration() != null) {
      adminConfiguration.setConfigFileDirectory(
          configuration.getMpiConfig().getAdminConfiguration().getFileRepositoryDirectory());
    }

    org.openhie.openempi.configuration.xml.AdminConfiguration adminConfig =
        configuration.getMpiConfig().getAdminConfiguration();
    if (adminConfig.getFileRepositoryDirectory() == null) {
      adminConfiguration.setConfigFileDirectory(Constants.DEFAULT_FILE_REPOSITORY_DIRECTORY);
    } else {
      adminConfiguration.setConfigFileDirectory(adminConfig.getFileRepositoryDirectory());
    }

    if (adminConfig.getDataDirectory() == null) {
      adminConfiguration.setDataDirectory(Context.getOpenEmpiHome() + "/data");
    } else {
      adminConfiguration.setDataDirectory(adminConfig.getDataDirectory());
    }

    if (configuration.getMpiConfig().getAdminConfiguration().getUpdateNotificationEntries() != null
        && configuration
                .getMpiConfig()
                .getAdminConfiguration()
                .getUpdateNotificationEntries()
                .sizeOfUpdateNotificationEntryArray()
            > 0) {
      UpdateNotificationEntry[] entries =
          configuration
              .getMpiConfig()
              .getAdminConfiguration()
              .getUpdateNotificationEntries()
              .getUpdateNotificationEntryArray();
      for (int i = 0; i < entries.length; i++) {
        UpdateNotificationRegistrationEntry entry = processUpdateNotificationEntry(entries[i]);
        if (entry != null) {
          adminConfiguration.addUpdateNotificationRegistrationEntries(entry);
        }
      }
    }
    return adminConfiguration;
  }
Example #9
0
 public MpiConfig getMpiConfig() {
   return configuration.getMpiConfig();
 }
Example #10
0
 public BlockingConfigurationType getBlockingConfiguration() {
   return configuration.getMpiConfig().getBlockingConfigurationArray(0);
 }