Exemplo n.º 1
0
 private void setupNaiveBlockingService(String entityName) {
   log.warn(
       "Was unable to load the blocking service configuration; using the naive blocking service as a fallback mechanism.");
   BlockingService blockingService =
       (BlockingService) Context.getApplicationContext().getBean(Constants.NAIVE_BLOCKING_SERVICE);
   Context.registerCustomBlockingService(entityName, blockingService);
 }
  public List<RecordWeb> loadLinksFromRecord(EntityWeb entityModel, RecordWeb entity)
      throws Exception {
    log.debug("Received request to retrieve a list of entity record links.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      // loadRecordLinks without left and right Records
      List<Record> records =
          entityInstanceService.loadRecordLinksByRecordId(entityDef, entity.getRecordId());

      List<RecordWeb> dtos = new java.util.ArrayList<RecordWeb>(records.size());
      for (Record record : records) {
        RecordWeb dto = ModelTransformer.mapToRecord(record, RecordWeb.class);
        dtos.add(dto);
      }

      return dtos;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
 public void deleteCustomField(CustomField field) throws ApplicationException {
   if (field == null
       || ConvertUtil.isNullOrEmpty(field.getEntityName())
       || ConvertUtil.isNullOrEmpty(field.getFieldName())) {
     log.warn("The custom field to be deleted is invalid: " + field);
     throw new ApplicationException("Unable to add invalid custom field definition.");
   }
   Entity entity = findLatestEntityVersionByName(field.getEntityName());
   EntityAttribute attrib = null;
   for (EntityAttribute item : entity.getAttributes()) {
     if (item.getName().equalsIgnoreCase(field.getFieldName()) && item.getDateVoided() == null) {
       attrib = item;
     }
   }
   if (attrib == null) {
     log.info("The user attempted to delete a custom field that does not exist.");
     throw new ApplicationException("Unable to delete an unknown custom field definition.");
   }
   attrib.setDateVoided(new Date());
   attrib.setUserVoidedBy(Context.getUserContext().getUser());
   try {
     entityDefinitionDao.updateEntity(entity);
     // Generate a notification event to inform interested listeners via the lightweight mechanism
     // that this event has occurred.
     Context.notifyObserver(ObservationEventType.CUSTOM_FIELD_DELETE_EVENT, field);
   } catch (DaoException e) {
     log.error("Failed while deleting a custom field: " + e, e);
     throw new ApplicationException("Failed while deleting the custom field: " + e.getMessage());
   }
 }
 private void preloadCache() {
   List<Entity> entities = loadEntities();
   log.info("Pre-loaded configuration for " + entities.size() + " entities.");
   Map<String, List<CustomField>> customFieldsListByEntityName =
       new HashMap<String, List<CustomField>>();
   Map<String, Map<String, CustomField>> customFieldsMapByEntityName =
       new HashMap<String, Map<String, CustomField>>();
   for (Entity entity : entities) {
     List<CustomField> customFields = loadCustomFields(entity.getName());
     customFieldsListByEntityName.put(entity.getName(), customFields);
     log.info(
         "Pre-loaded a list of "
             + customFields.size()
             + " custom fields for entity "
             + entity.getName());
     Map<String, CustomField> customFieldMap = new HashMap<String, CustomField>();
     for (CustomField field : customFields) {
       customFieldMap.put(field.getFieldName(), field);
     }
     customFieldsMapByEntityName.put(entity.getName(), customFieldMap);
     Context.getConfiguration()
         .registerConfigurationEntry(
             entity.getName(),
             ConfigurationRegistry.CUSTOM_FIELD_LIST_BY_ENTITY_NAME_MAP,
             customFieldsListByEntityName);
     Context.getConfiguration()
         .registerConfigurationEntry(
             entity.getName(),
             ConfigurationRegistry.CUSTOM_FIELD_MAP_BY_ENTITY_NAME_MAP,
             customFieldsMapByEntityName);
   }
 }
Exemplo n.º 5
0
  public PersonIdentifier getGlobalIdentifierById(PersonIdentifier personIdentifier) {

    ValidationService validationService = Context.getValidationService();
    validationService.validate(personIdentifier);

    GlobalIdentifier globalIdentifier = Context.getConfiguration().getGlobalIdentifier();
    if (!globalIdentifier.isAssignGlobalIdentifier()) {
      log.warn("The system is not configured to assign global identifiers.");
      return null;
    }

    IdentifierDomain globalDomain = globalIdentifier.getIdentifierDomain();
    // Check to see if the person already has a global identifier
    Person person = personDao.getPersonById(personIdentifier);
    if (person != null) {
      for (PersonIdentifier identifier : person.getPersonIdentifiers()) {
        IdentifierDomain identifierDomain = identifier.getIdentifierDomain();
        if (identifierDomain != null && identifierDomain.equals(globalDomain)) {
          if (log.isTraceEnabled()) {
            log.trace("Person has a global identifier assigned: " + identifier);
          }
          return identifier;
        }
      }
    }
    return null;
  }
  public List<RecordWeb> findEntitiesByIdentifier(EntityWeb entityModel, IdentifierWeb identferWeb)
      throws Exception {
    log.debug(
        "Received request to retrieve a list of entity instance records that match the entity specified as a parameter.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      org.openhie.openempi.model.Identifier identifier =
          ModelTransformer.map(identferWeb, org.openhie.openempi.model.Identifier.class);

      List<Record> records = entityInstanceService.findRecordsByIdentifier(entityDef, identifier);

      List<RecordWeb> dtos = new java.util.ArrayList<RecordWeb>(records.size());
      for (Record record : records) {
        RecordWeb dto = ModelTransformer.mapToRecord(record, RecordWeb.class);
        dtos.add(dto);
      }

      return dtos;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
  public void testGetPersonByIdQueryRemoteService() {
    System.out.println(
        "Transactional support for this test has rollback set to " + this.isDefaultRollback());
    this.setDefaultRollback(true);

    try {
      org.openhie.openempi.service.PersonManagerService pms = Context.getPersonManagerService();
      PersonUtils.createTestPersonTable(pms, TABLE_NAME, "", false, null, false, null, null);

      RemotePersonServiceLocator remotePersonServiceLocator =
          Context.getRemotePersonServiceLocator();

      SecurityService securityService = remotePersonServiceLocator.getSecurityService(ipAddress);
      String sessionKey = securityService.authenticate("admin", "admin");
      System.out.println("Obtained a session key of " + sessionKey);

      PersonQueryService personQueryService = remotePersonServiceLocator.getPersonQueryService();
      Person p = personQueryService.getPersonById(sessionKey, TABLE_NAME, 1L);
      if (p != null) {
        System.out.println("Found person: " + p);
      }
    } catch (NamingException e) {
      e.printStackTrace();
    } catch (ApplicationException e) {
      e.printStackTrace();
    }
  }
  public List<RecordWeb> getMatchingEntities(EntityWeb entityModel, RecordWeb entity)
      throws Exception {
    log.debug(
        "Received request to retrieve a list of entity instance records that match the entity specified as a parameter.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      // pass the entity definition model for formatting the Date search string
      org.openhie.openempi.model.Record recordForMatch =
          ModelTransformer.mapToRecordForSearch(entityDef, entity, Record.class);

      List<Record> records =
          entityInstanceService.findRecordsByAttributes(entityDef, recordForMatch);

      List<RecordWeb> dtos = new java.util.ArrayList<RecordWeb>(records.size());
      for (Record record : records) {
        RecordWeb dto = ModelTransformer.mapToRecord(record, RecordWeb.class);
        dtos.add(dto);
      }

      return dtos;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
  public Entity addEntity(Entity entity) throws ApplicationException {
    if (entity == null) {
      return null;
    }

    if (entity.getEntityVersionId() != null) {
      throw new ApplicationException(
          "This entity definition already exists so it can only be updated.");
    }

    validateNameUniqueness(entity);
    try {
      entity.setUserCreatedBy(Context.getUserContext().getUser());
      Date dateCreated = new Date();
      entity.setDateCreated(dateCreated);
      for (EntityAttribute attribute : entity.getAttributes()) {
        attribute.setDateCreated(dateCreated);
        attribute.setUserCreatedBy(Context.getUserContext().getUser());
        attribute.setEntity(entity);
      }
      entityDefinitionDao.addEntity(entity);
      addToCache(entity);
      Context.notifyObserver(ObservationEventType.ENTITY_ADD_EVENT, entity);
      return entity;
    } catch (DaoException e) {
      throw new ApplicationException(e.getMessage());
    }
  }
  public RecordLinkWeb loadRecordLinks(
      EntityWeb entityModel, Long leftRecordId, Long rightRecordId, String state) throws Exception {
    log.debug("Received request to retrieve a list of entity record links.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      List<RecordLink> records =
          entityInstanceService.loadRecordLinks(
              entityDef, rightRecordId, RecordLinkState.fromString(state));

      for (RecordLink record : records) {

        // loadRecordLinks with left and right Records
        RecordLink recordlLink =
            entityInstanceService.loadRecordLink(entityDef, record.getRecordLinkId());
        if (recordlLink.getLeftRecord().getRecordId() == leftRecordId
            || recordlLink.getRightRecord().getRecordId() == leftRecordId) {

          RecordLinkWeb recordlLinkWeb =
              ModelTransformer.mapToRecordLink(recordlLink, RecordLinkWeb.class, true);
          return recordlLinkWeb;
        }
      }
      return null;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
  public List<RecordLinkWeb> loadRecordLinks(
      EntityWeb entityModel, String state, int firstResult, int maxResults) throws Exception {
    log.debug("Received request to retrieve a list of entity record links.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      List<RecordLink> records =
          entityInstanceService.loadRecordLinks(
              entityDef, RecordLinkState.fromString(state), firstResult, maxResults);

      List<RecordLinkWeb> dtos = new java.util.ArrayList<RecordLinkWeb>(records.size());
      for (RecordLink record : records) {

        // loadRecordLinks without left and right Records
        RecordLinkWeb dto = ModelTransformer.mapToRecordLink(record, RecordLinkWeb.class, false);
        dtos.add(dto);
      }

      return dtos;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
  public RecordLinkWeb updateRecordLink(EntityWeb entityModel, RecordLinkWeb linkPair)
      throws Exception {
    log.debug("Received request to updaty an entity record link.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      RecordManagerService entityInstanceManagerService = Context.getRecordManagerService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      RecordLink recordLink = ModelTransformer.mapToRecordLink(linkPair, RecordLink.class);

      RecordLink record =
          entityInstanceService.loadRecordLink(entityDef, recordLink.getRecordLinkId());
      record.setState(recordLink.getState());
      record = entityInstanceManagerService.updateRecordLink(record);

      RecordLinkWeb recordWeb = ModelTransformer.mapToRecordLink(record, RecordLinkWeb.class, true);

      return recordWeb;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
Exemplo n.º 13
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;
  }
  public Entity updateEntity(Entity entity) throws ApplicationException {
    if (entity == null) {
      return entity;
    }
    if (entity.getEntityVersionId() == null) {
      throw new ApplicationException(
          "An entity definition must first be created before it is updated.");
    }
    try {
      Date currentDate = new Date();
      entity.setDateChanged(currentDate);
      entity.setUserChangedBy(Context.getUserContext().getUser());
      for (EntityAttribute attrib : entity.getAttributes()) {
        if (attrib.getDateCreated() == null) {
          attrib.setDateCreated(currentDate);
          attrib.setUserCreatedBy(Context.getUserContext().getUser());
          // attrib.setEntity(entity);
        }
        attrib.setEntity(entity);
      }

      // Mark deletion attributes
      handleAttributeUpdates(entity);

      // remove validations for marked attribute
      for (EntityAttribute attrib : entity.getAttributes()) {
        if (attrib.getUserVoidedBy() != null) {

          // remove validations
          List<EntityAttributeValidation> existingValidations =
              loadEntityAttributeValidations(attrib);
          for (EntityAttributeValidation validation : existingValidations) {
            deleteEntityAttributeValidation(validation);
          }
        }
      }

      Entity updatedEntity = entityDefinitionDao.updateEntity(entity);
      updatedEntity = entityDefinitionDao.loadEntity(entity.getEntityVersionId());

      addToCache(updatedEntity);
      Context.notifyObserver(ObservationEventType.ENTITY_ATTRIBUTE_UPDATE_EVENT, entity);

      return updatedEntity;
    } catch (DaoException e) {
      throw new ApplicationException(e.getMessage());
    }
  }
  @Override
  public RecordListWeb getEntityRecordsBySearch(RecordSearchCriteriaWeb searchCriteria)
      throws Exception {
    log.debug("Get Entity Records By Search");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();

      EntityWeb entityModel = searchCriteria.getEntityModel();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      RecordWeb entity = searchCriteria.getRecord();
      int offset = searchCriteria.getFirstResult();
      int pageSize = searchCriteria.getMaxResults();

      org.openhie.openempi.model.Record recordForMatch =
          ModelTransformer.mapToRecordForSearch(entityDef, entity, Record.class);

      // Get total count
      Long totalCount = searchCriteria.getTotalCount();
      if (totalCount == 0) {
        totalCount = entityInstanceService.getRecordCount(entityDef, recordForMatch);
      }

      // get List of Record
      List<Record> records =
          entityInstanceService.findRecordsByAttributes(
              entityDef, recordForMatch, offset, pageSize);

      List<RecordWeb> dtos = new java.util.ArrayList<RecordWeb>(records.size());
      for (Record record : records) {
        RecordWeb dto = ModelTransformer.mapToRecord(record, RecordWeb.class);
        dtos.add(dto);
      }

      RecordListWeb recordList = new RecordListWeb();
      recordList.setTotalCount(totalCount);
      recordList.setRecords(dtos);

      return recordList;

    } catch (Exception e) {
      log.error("Failed while trying to get audit events: " + e, e);
    }
    return null;
  }
  @Override
  public RecordLinksListWeb loadRecordLinksPaged(RecordSearchCriteriaWeb searchCriteria)
      throws Exception {
    log.debug("Get Record Links");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();

      EntityWeb entityModel = searchCriteria.getEntityModel();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      int offset = searchCriteria.getFirstResult();
      int pageSize = searchCriteria.getMaxResults();
      String state = searchCriteria.getSearchMode().substring(0, 1);

      // Get total count
      Long totalCount = searchCriteria.getTotalCount();
      if (totalCount == 0) {
        totalCount =
            entityInstanceService.getRecordLinkCount(entityDef, RecordLinkState.fromString(state));
      }

      // get List of Record
      List<RecordLink> recordLinks =
          entityInstanceService.loadRecordLinks(
              entityDef, RecordLinkState.fromString(state), offset, pageSize);

      List<RecordLinkWeb> dtos = new java.util.ArrayList<RecordLinkWeb>(recordLinks.size());
      for (RecordLink record : recordLinks) {

        // loadRecordLinks without left and right Records
        RecordLinkWeb dto = ModelTransformer.mapToRecordLink(record, RecordLinkWeb.class, false);
        dtos.add(dto);
      }

      RecordLinksListWeb recordList = new RecordLinksListWeb();
      recordList.setTotalCount(totalCount);
      recordList.setRecordLinks(dtos);

      return recordList;

    } catch (Exception e) {
      log.error("Failed while trying to get audit events: " + e, e);
    }
    return null;
  }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
    public ContainerRequest filter(ContainerRequest request) {
      log.debug("Url invoked is: " + uriInfo.getPath());

      // We need to let the caller get through to the authentication call
      if (uriInfo.getPath() != null
          && (uriInfo.getPath().equalsIgnoreCase("security-resource/authenticate")
              || uriInfo.getPath().startsWith("records")
              || uriInfo.getPath().startsWith("record-links")
              || uriInfo.getPath().startsWith("entities")
              || uriInfo.getPath().startsWith("entity-attributes")
              || uriInfo.getPath().startsWith("identifier-domains")
              || uriInfo.getPath().equalsIgnoreCase("application.wadl"))) {
        log.debug("Request permitted due to URI being present in the exclusion list.");
        return request;
      }

      String sessionKey = request.getHeaderValue(OPENEMPI_SESSION_KEY_HEADER);
      if (sessionKey != null && sessionKey.length() > 0) {
        User user = org.openhie.openempi.context.Context.authenticate(sessionKey);
        if (user == null) {
          throw new WebApplicationException(Response.Status.UNAUTHORIZED);
        }
        return request;
      }
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
Exemplo n.º 19
0
 public Object lookupConfigurationEntry(String entityName, String key) {
   if (entityName == null) {
     log.info("Looking up configuration entry with key " + key + " in default registry.");
     return defaultConfigurationRegistry.get(key);
   }
   return Context.lookupConfigurationEntry(entityName, key);
 }
Exemplo n.º 20
0
  public Person findPersonById(PersonIdentifier personIdentifier) {

    ValidationService validationService = Context.getValidationService();
    validationService.validate(personIdentifier);

    return personDao.getPersonById(personIdentifier);
  }
Exemplo n.º 21
0
  public void testDataProfileView() {
    DataProfileService service = Context.getDataProfileService();
    List<DataProfileAttribute> dataList = service.getDataProfileAttributes(0);
    assertNotNull("Did not find any data profile attribute data.", dataList);
    assertTrue("The list of data profile attribute data is empty.", dataList.size() > 0);

    DataProfileAttribute givenNameAttribute = null;
    for (DataProfileAttribute attrib : dataList) {
      log.debug(attrib);
      if (attrib.getAttributeName() != null
          && attrib.getAttributeName().equalsIgnoreCase("givenName")) {
        givenNameAttribute = attrib;
      }
    }
    if (givenNameAttribute != null) {
      List<DataProfileAttributeValue> values =
          service.getTopDataProfileAttributeValues(givenNameAttribute.getAttributeId(), 10);
      assertNotNull("Did not find any data profile attribute data values.", values);
      assertTrue("The list of data profile attribute data values is empty.", values.size() > 0);
      for (DataProfileAttributeValue value : values) {
        log.debug(
            "The value ["
                + value.getAttributeValue()
                + "] has a frequence of "
                + value.getFrequency());
      }
    }
  }
Exemplo n.º 22
0
 public void testFileParsing() {
   try {
     JAXBContext jc = JAXBContext.newInstance(FileLoaderMap.class);
     Unmarshaller u = jc.createUnmarshaller();
     File dir = new File(Context.getOpenEmpiHome() + "/conf");
     File file = new File(dir, "file-loader-map.xml");
     FileLoaderMap fileMap = (FileLoaderMap) u.unmarshal(new FileInputStream(file));
     log.debug("File will be parsed using the delimeter: " + fileMap.getDelimeter());
     for (int i = 0; i < fileMap.getFields().getField().size(); i++) {
       FieldType field = fileMap.getFields().getField().get(i);
       if (field.isOneToMany()) {
         log.debug(
             "Field will be decomposed into subfields using delimeter: " + field.getDelimeter());
         for (FieldType subfield : field.getSubfields().getField()) {
           log.debug(
               "Will import field "
                   + subfield.getFieldName()
                   + " which should appear at column "
                   + i);
         }
       } else {
         log.debug(
             "Will import field " + field.getFieldName() + " which should appear at column " + i);
       }
     }
     log.debug("Finished processing file loader map");
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Exemplo n.º 23
0
  public IdentifierDomainAttribute getIdentifierDomainAttribute(
      IdentifierDomain identifierDomain, String attributeName) {

    ValidationService validationService = Context.getValidationService();
    validationService.validate(identifierDomain);

    return personDao.getIdentifierDomainAttribute(identifierDomain, attributeName);
  }
Exemplo n.º 24
0
  public List<Person> findPersonsById(PersonIdentifier personIdentifier) {

    ValidationService validationService = Context.getValidationService();
    validationService.validate(personIdentifier);

    List<Person> persons = personDao.getPersonsByIdentifier(personIdentifier);
    return persons;
  }
Exemplo n.º 25
0
  public List<IdentifierDomainAttribute> getIdentifierDomainAttributes(
      IdentifierDomain identifierDomain) {

    ValidationService validationService = Context.getValidationService();
    validationService.validate(identifierDomain);

    return personDao.getIdentifierDomainAttributes(identifierDomain);
  }
Exemplo n.º 26
0
 private void configureLoggingEnvironment() {
   String openEmpiHome = Context.getOpenEmpiHome();
   if (openEmpiHome != null && openEmpiHome.length() > 0) {
     String loggingConfigurationFile = openEmpiHome + "/conf/log4j.properties";
     PropertyConfigurator.configure(loggingConfigurationFile);
     log.info("Set the logging configuration file to " + loggingConfigurationFile);
   }
 }
 public void testInitialization() {
   PersonManagerService service = Context.getPersonManagerService();
   try {
     service.initializeRepository();
   } catch (ApplicationException e) {
     log.error("Failed while initializing the repository: " + e, e);
   }
 }
  public RecordListWeb findEntitiesByIdentifier(RecordSearchCriteriaWeb searchCriteria)
      throws Exception {
    log.debug("Received entity records by identifier.");

    authenticateCaller();
    try {
      RecordQueryService entityInstanceService = Context.getRecordQueryService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();

      EntityWeb entityModel = searchCriteria.getEntityModel();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());

      IdentifierWeb identifierWeb = searchCriteria.getIdentifier();
      int offset = searchCriteria.getFirstResult();
      int pageSize = searchCriteria.getMaxResults();

      org.openhie.openempi.model.Identifier identifier =
          ModelTransformer.map(identifierWeb, org.openhie.openempi.model.Identifier.class);

      // Get total count
      Long totalCount = searchCriteria.getTotalCount();
      if (totalCount == 0) {
        totalCount = entityInstanceService.getRecordCount(entityDef, identifier);
      }

      // get List of Record
      List<Record> records =
          entityInstanceService.findRecordsByIdentifier(entityDef, identifier, offset, pageSize);

      List<RecordWeb> dtos = new java.util.ArrayList<RecordWeb>(records.size());
      for (Record record : records) {
        RecordWeb dto = ModelTransformer.mapToRecord(record, RecordWeb.class);
        dtos.add(dto);
      }

      RecordListWeb recordList = new RecordListWeb();
      recordList.setTotalCount(totalCount);
      recordList.setRecords(dtos);

      return recordList;
    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }
Exemplo n.º 29
0
 public void shutdown() {
   if (loader != null) {
     loader.shutdown();
   }
   if (entityLoaderMgr != null) {
     entityLoaderMgr.shutdownConnection();
   }
   Context.shutdown();
 }
Exemplo n.º 30
0
  public IdentifierDomain findIdentifierDomainByName(String identifierDomainName) {
    ValidationService validationService = Context.getValidationService();
    validationService.validate(identifierDomainName);

    if (identifierDomainName == null || identifierDomainName.length() == 0) {
      return null;
    }
    return personDao.findIdentifierDomainByName(identifierDomainName);
  }