コード例 #1
0
  public CheckPolicyRequestType transformEntityAlertToCheckPolicy(
      RespondingGatewaySendAlertMessageType message, String target) {

    CheckPolicyRequestType result = new CheckPolicyRequestType();
    if (message == null) {
      log.error("Request is null.");
      return result;
    }
    if (target == null || target.isEmpty()) {
      log.error("target is missing");
      return result;
    }

    if (message.getEDXLDistribution() == null) {
      log.error("missing body");
      return result;
    }
    if (message.getAssertion() == null) {
      log.error("missing assertion");
      return result;
    }
    if (message.getAssertion().getHomeCommunity() == null) {
      log.error("missing home community");
      return result;
    }

    EDXLDistribution body = message.getEDXLDistribution();
    // RequestType request = getRequestType(patDiscReq, event.getAssertion());
    RequestType request = new RequestType();
    AttributeHelper attrHelper = new AttributeHelper();

    log.debug("transformEntityAlertToCheckPolicy - adding subject");
    SubjectHelper subjHelp = new SubjectHelper();
    // SubjectType subject = subjHelp.subjectFactory(event.getAssertion().getHomeCommunity(),
    // event.getAssertion());
    SubjectType subject = new SubjectType();
    subject.setSubjectCategory(SubjectHelper.SubjectCategory);
    log.debug("transformEntityAlertToCheckPolicy - adding subject");
    request.getSubject().add(subject);

    ResourceType resource = new ResourceType();
    resource
        .getAttribute()
        .add(
            attrHelper.attributeFactory(
                Constants.HomeCommunityAttributeId,
                Constants.DataTypeString,
                message.getAssertion().getHomeCommunity().getHomeCommunityId()));

    request.getResource().add(resource);

    log.debug("transformEntityAlertToCheckPolicy - adding assertion data");
    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, message.getAssertion());

    request.setAction(ActionHelper.actionFactory(ActionOutValue));
    result.setAssertion(message.getAssertion());
    result.setRequest(request);
    return result;
  }
コード例 #2
0
 private static void setTopic(SubscribeEventType event, ResourceType resource) {
   String topic = null;
   try {
     LOG.debug("######## BEGIN TOPIC EXTRACTION ########");
     JAXBElement<TopicExpressionType> jbElement =
         (JAXBElement<TopicExpressionType>)
             event.getMessage().getSubscribe().getFilter().getAny().get(0);
     TopicExpressionType topicExpression = jbElement.getValue();
     topic = (String) topicExpression.getContent().get(0);
     LOG.debug("Topic extracted: " + topic);
   } catch (Throwable t) {
     LOG.error("Error extracting the topic: " + t.getMessage(), t);
   }
   if (NullChecker.isNotNullish(topic)) {
     if (LOG.isDebugEnabled()) {
       LOG.debug(
           "Adding topic ("
               + topic
               + ") as attribute ("
               + ATTRIBUTE_ID_TOPIC
               + ") and type: "
               + Constants.DataTypeString);
     }
     AttributeHelper attrHelper = new AttributeHelper();
     resource
         .getAttribute()
         .add(attrHelper.attributeFactory(ATTRIBUTE_ID_TOPIC, Constants.DataTypeString, topic));
   }
 }
  protected RequestType getRequestType(PRPAIN201305UV02 event, AssertionType assertion) {
    addDebugLog("Begin -- PatientDiscoveryPolicyTransformHelper.getRequestType()");
    RequestType request = new RequestType();

    setSubjectToRequestType(event, request, assertion);

    ResourceType resource = null;
    AttributeHelper attrHelper = new AttributeHelper();
    II ii = extractPatientIdentifier(event);
    if (ii != null) {
      resource = new ResourceType();
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot()));
      String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(ii.getExtension());
      log.debug("transformSubjectAddedInToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));
      request.getResource().add(resource);
    }
    request.getResource().add(resource);
    addDebugLog("End -- PatientDiscoveryPolicyTransformHelper.getRequestType()");
    return request;
  }
  /**
   * Transform method to create a CheckPolicyRequest object from a 201306 message
   *
   * @param request
   * @return CheckPolicyRequestType
   */
  public CheckPolicyRequestType transformPatientDiscoveryNhincToCheckPolicy(
      PatDiscReqEventType event) {
    addDebugLog(
        "Begin -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryNhincToCheckPolicy()");
    CheckPolicyRequestType checkPolicyRequest = null;

    if (event == null) {
      addErrorLog("Request is null.");
      return checkPolicyRequest;
    } else {
      checkPolicyRequest = new CheckPolicyRequestType();
    }

    PRPAIN201306UV02 patDiscReq = event.getPRPAIN201306UV02();
    RequestType request = new RequestType();

    SubjectHelper subjHelp = new SubjectHelper();
    SubjectType subject =
        subjHelp.subjectFactory(event.getSendingHomeCommunity(), event.getAssertion());
    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding subject");
    request.getSubject().add(subject);

    II qualifiedPatientIdentifier = extractPatientIdentifier(patDiscReq);
    if (qualifiedPatientIdentifier != null) {
      ResourceType resource = new ResourceType();
      AttributeHelper attrHelper = new AttributeHelper();
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId,
                  Constants.DataTypeString,
                  qualifiedPatientIdentifier.getRoot()));
      String sStrippedPatientId =
          PatientIdFormatUtil.parsePatientId(qualifiedPatientIdentifier.getExtension());
      log.debug(
          "transformPatientDiscoveryNhincToCheckPolicy: sStrippedPatientId = "
              + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));

      request.getResource().add(resource);
    }

    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding assertion data");
    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, event.getAssertion());

    request.setAction(ActionHelper.actionFactory(ActionInValue));

    checkPolicyRequest.setRequest(request);
    checkPolicyRequest.setAssertion(event.getAssertion());
    addDebugLog(
        "End -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryNhincToCheckPolicy()");
    return checkPolicyRequest;
  }
コード例 #5
0
  public static CheckPolicyRequestType transformSubscribeToCheckPolicy(SubscribeEventType event) {
    CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
    RequestType request = new RequestType();
    if (InboundOutboundChecker.isInbound(event.getDirection())) {
      request.setAction(ActionHelper.actionFactory(ActionInValue));
    }
    if (InboundOutboundChecker.isOutbound(event.getDirection())) {
      request.setAction(ActionHelper.actionFactory(ActionOutValue));
    }

    SubjectHelper subjHelp = new SubjectHelper();
    SubjectType subject =
        subjHelp.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
    request.getSubject().add(subject);

    AdhocQueryRequest adhocReq = new AdhocQueryRequest();
    AdhocQueryType adhocQuery = null;
    adhocQuery = getAdhocQuery(event.getMessage().getSubscribe());
    adhocReq.setAdhocQuery(adhocQuery);
    String patId = AdhocQueryTransformHelper.extractPatientIdentifierId(adhocReq);
    String assignAuth =
        AdhocQueryTransformHelper.extractPatientIdentifierAssigningAuthority(adhocReq);

    ResourceType resource = new ResourceType();
    AttributeHelper attrHelper = new AttributeHelper();

    if (NullChecker.isNotNullish(assignAuth)) {
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId, Constants.DataTypeString, assignAuth));
    }

    if (NullChecker.isNotNullish(patId)) {
      String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(patId);
      LOG.debug("transformSubscribeToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));
    }

    setTopic(event, resource);

    request.getResource().add(resource);

    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, event.getMessage().getAssertion());

    genericPolicyRequest.setRequest(request);
    genericPolicyRequest.setAssertion(event.getMessage().getAssertion());
    return genericPolicyRequest;
  }
コード例 #6
0
 @Parameter(
     optional = true,
     description =
         "Name of the attribute for the message. If this parameter is not specified, then by default the operator will look for an attribute named \\\"message\\\". If the \\\"message\\\" attribute is not found, messages will not be sent. Default is \\\"message\\\".")
 public void setMessageAttribute(String value) {
   messageAH.setName(value);
 }
コード例 #7
0
  public void initSchema(StreamSchema ss) throws Exception {
    trace.log(TraceLevel.INFO, "Connection properties: " + finalProperties);

    Set<MetaType> supportedTypes = new HashSet<MetaType>();
    supportedTypes.add(MetaType.RSTRING);
    supportedTypes.add(MetaType.USTRING);
    supportedTypes.add(MetaType.BLOB);

    keyAH.initialize(ss, false, supportedTypes);
    messageAH.initialize(ss, true, supportedTypes);

    // blobs are not supported for topics
    supportedTypes.remove(MetaType.BLOB);
    topicAH.initialize(ss, false, supportedTypes);

    OperatorContext operContext = getOperatorContext();
    if (operContext.getParameterNames().contains("partition") == false) {
      // we don't need to create this client if using simpleConsumerClient
      trace.log(TraceLevel.INFO, "Creating client");
      client = new KafkaClient(topicAH, keyAH, messageAH, finalProperties);
    }
  }
コード例 #8
0
 @Parameter(
     optional = true,
     description = "Name of the attribute for the key. Default is \\\"key\\\".")
 public void setKeyAttribute(String value) {
   keyAH.setName(value);
 }
コード例 #9
0
 /**
  * {@inheritDoc}
  *
  * <p>この実装では、カラム名をモデルクラスの注釈から自動的に抽出する。 注釈が指定されていない場合は例外がスローされる。
  */
 @Override
 public List<String> getColumnNames() {
   return AttributeHelper.getColumnNames(getModelType());
 }
コード例 #10
0
 /**
  * {@inheritDoc}
  *
  * <p>この実装では、テーブル名をモデルクラスの注釈から自動的に抽出する。 注釈が指定されていない場合は例外がスローされる。
  */
 @Override
 public String getTableName() {
   return AttributeHelper.getTableName(getModelType());
 }
  /**
   * Transform method to create a CheckPolicyRequest object from a 201305 request
   *
   * @param request
   * @return CheckPolicyRequestType
   */
  public CheckPolicyRequestType transformPatientDiscoveryEntityToCheckPolicy(
      RespondingGatewayPRPAIN201305UV02RequestType event) {
    addDebugLog(
        "Begin -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryEntityToCheckPolicy()");

    CheckPolicyRequestType checkPolicyRequest = null;

    if (event == null) {
      addErrorLog("Request is null.");
      return checkPolicyRequest;
    } else {
      checkPolicyRequest = new CheckPolicyRequestType();
    }

    PRPAIN201305UV02 patDiscReq = event.getPRPAIN201305UV02();
    // RequestType request = getRequestType(patDiscReq, event.getAssertion());
    RequestType request = new RequestType();

    SubjectHelper subjHelp = new SubjectHelper();
    // SubjectType subject = subjHelp.subjectFactory(event.getAssertion().getHomeCommunity(),
    // event.getAssertion());
    SubjectType subject = new SubjectType();
    subject.setSubjectCategory(SubjectHelper.SubjectCategory);
    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding subject");
    request.getSubject().add(subject);

    II qualifiedPatientIdentifier = extractPatientIdentifier(patDiscReq);
    if (qualifiedPatientIdentifier != null) {
      ResourceType resource = new ResourceType();
      AttributeHelper attrHelper = new AttributeHelper();
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId,
                  Constants.DataTypeString,
                  qualifiedPatientIdentifier.getRoot()));
      String sStrippedPatientId =
          PatientIdFormatUtil.parsePatientId(qualifiedPatientIdentifier.getExtension());
      log.debug(
          "transformPatientDiscoveryNhincToCheckPolicy: sStrippedPatientId = "
              + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));

      HomeCommunityType homeCommunityId = null;

      if (event != null
          && event.getPRPAIN201305UV02() != null
          && NullChecker.isNotNullish(event.getPRPAIN201305UV02().getReceiver())
          && event.getPRPAIN201305UV02().getReceiver().get(0) != null
          && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice() != null
          && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getAsAgent() != null
          && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getAsAgent().getValue()
              != null
          && event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
              != null
          && event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
              != null
          && NullChecker.isNotNullish(
              event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
                  .getId())
          && event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
                  .getId()
                  .get(0)
              != null
          && NullChecker.isNotNullish(
              event
                  .getPRPAIN201305UV02()
                  .getReceiver()
                  .get(0)
                  .getDevice()
                  .getAsAgent()
                  .getValue()
                  .getRepresentedOrganization()
                  .getValue()
                  .getId()
                  .get(0)
                  .getRoot())) {
        homeCommunityId = new HomeCommunityType();
        homeCommunityId.setHomeCommunityId(
            event
                .getPRPAIN201305UV02()
                .getReceiver()
                .get(0)
                .getDevice()
                .getAsAgent()
                .getValue()
                .getRepresentedOrganization()
                .getValue()
                .getId()
                .get(0)
                .getRoot());
      }
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  Constants.HomeCommunityAttributeId,
                  Constants.DataTypeString,
                  subjHelp.determineSendingHomeCommunityId(homeCommunityId, event.getAssertion())));

      request.getResource().add(resource);
    }

    log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding assertion data");
    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, event.getAssertion());

    request.setAction(ActionHelper.actionFactory(ActionOutValue));

    checkPolicyRequest.setRequest(request);
    checkPolicyRequest.setAssertion(event.getAssertion());

    addDebugLog(
        "End -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryEntityToCheckPolicy()");
    return checkPolicyRequest;
  }