示例#1
0
 public NameAndValueList getMappingAssociationNames(String scheme, String version) {
   CodingSchemeVersionOrTag csvt = new CodingSchemeVersionOrTag();
   if (version != null) {
     csvt.setVersion(version);
   }
   NameAndValueList navList = new NameAndValueList();
   try {
     CodingScheme cs = lbSvc.resolveCodingScheme(scheme, csvt);
     Relations[] relations = cs.getRelations();
     for (int i = 0; i < relations.length; i++) {
       Relations relation = relations[i];
       Boolean isMapping = relation.isIsMapping();
       if (isMapping != null && isMapping.equals(Boolean.TRUE)) {
         AssociationPredicate[] associationPredicates = relation.getAssociationPredicate();
         for (int j = 0; j < associationPredicates.length; j++) {
           AssociationPredicate associationPredicate = associationPredicates[j];
           String name = associationPredicate.getAssociationName();
           NameAndValue vNameAndValue = new NameAndValue();
           vNameAndValue.setName(name);
           navList.addNameAndValue(vNameAndValue);
         }
         return navList;
       } else {
         return null;
       }
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return null;
 }
示例#2
0
  public ResolvedConceptReferencesIterator getMappingDataIterator(
      String scheme, String version, List<MappingSortOption> sortOptionList) {
    CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
    if (version != null) {
      versionOrTag.setVersion(version);
    }
    String relationsContainerName = null;
    try {

      CodingScheme cs = lbSvc.resolveCodingScheme(scheme, versionOrTag);
      if (cs == null) return null;

      java.util.Enumeration<? extends Relations> relations = cs.enumerateRelations();
      while (relations.hasMoreElements()) {
        Relations relation = (Relations) relations.nextElement();
        Boolean isMapping = relation.getIsMapping();
        if (isMapping != null && isMapping.equals(Boolean.TRUE)) {
          relationsContainerName = relation.getContainerName();
          break;
        }
      }
      if (relationsContainerName == null) {
        return null;
      }

      MappingExtension mappingExtension =
          (MappingExtension) lbSvc.getGenericExtension("MappingExtension");

      ResolvedConceptReferencesIterator itr =
          mappingExtension.resolveMapping(
              scheme, versionOrTag, relationsContainerName, sortOptionList);

      return itr;

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }
  /**
   * Return a list of Association names
   *
   * @param scheme
   * @param version
   * @return
   */
  public Vector<String> getAssociationNames(String scheme, String version) {
    Vector<String> association_vec = new Vector<String>();
    try {
      LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
      CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
      if (version != null) {
        versionOrTag.setVersion(version);
      }
      CodingScheme cs = lbSvc.resolveCodingScheme(scheme, versionOrTag);

      SupportedHierarchy[] hierarchies = cs.getMappings().getSupportedHierarchy();
      String[] ids = hierarchies[0].getAssociationNames();
      for (int i = 0; i < ids.length; i++) {
        if (!association_vec.contains(ids[i])) {
          association_vec.add(ids[i]);
          _logger.debug("AssociationName: " + ids[i]);
        }
      }
    } catch (Exception ex) {
      _logger.warn(ex.getMessage());
    }
    return association_vec;
  }
  private void add(
      EntityReference entityReference,
      ValueSetDefinitionEntry cts2Entry,
      org.LexGrid.valueSets.ValueSetDefinition lexEvsVSD) {
    URIAndEntityName uriAndName = new URIAndEntityName();
    uriAndName.setName(entityReference.getEntityCode());

    String namespace = entityReference.getEntityCodeNamespace();
    if (StringUtils.isBlank(namespace)) {
      namespace = lexEvsVSD.getDefaultCodingScheme();
    }

    uriAndName.setNamespace(namespace);

    SupportedNamespace supportedNamespace = this.findNamespace(lexEvsVSD.getMappings(), namespace);

    if (supportedNamespace == null) {
      log.warn(
          "EntityRefernece: "
              + entityReference.getEntityCodeNamespace()
              + ":"
              + entityReference.getEntityCode()
              + " does not have a valid namespace.");

      try {
        CodingScheme cs = this.lexBigService.resolveCodingScheme(namespace, null);
        SupportedNamespace sns = new SupportedNamespace();
        sns.setContent(cs.getCodingSchemeName());
        sns.setEquivalentCodingScheme(cs.getCodingSchemeName());
        sns.setLocalId(cs.getCodingSchemeName());
        sns.setUri(cs.getCodingSchemeURI());

        supportedNamespace = sns;
      } catch (LBException e) {
        log.info(e);

        // we have to punt here
        SupportedNamespace sns = new SupportedNamespace();
        sns.setContent("unknown");
        sns.setEquivalentCodingScheme("unknown");
        sns.setLocalId("unknown");
        sns.setUri("unknown");
      }
    }

    uriAndName.setUri(
        UriUtils.combine(supportedNamespace.getUri(), entityReference.getEntityCode()));

    if (entityReference.getReferenceAssociation() != null) {
      AssociatedEntitiesReference ref = new AssociatedEntitiesReference();
      ref.setReferencedEntity(uriAndName);
      ref.setDirection(
          entityReference.getTargetToSource()
              ? AssociationDirection.TARGET_TO_SOURCE
              : AssociationDirection.SOURCE_TO_TARGET);

      String cs = supportedNamespace.getEquivalentCodingScheme();
      SupportedCodingScheme supportedCodingScheme = this.findCodingScheme(lexEvsVSD, cs);

      CodeSystemReference codingSchemeRef =
          this.getTransformUtils()
              .toCodeSystemReference(
                  supportedCodingScheme.getLocalId(), supportedCodingScheme.getUri());

      ref.setCodeSystem(codingSchemeRef);

      ref.setTransitivity(
          entityReference.getTransitiveClosure()
              ? TransitiveClosure.TRANSITIVE_CLOSURE
              : TransitiveClosure.DIRECTLY_ASSOCIATED);

      ref.setLeafOnly(
          entityReference.getLeafOnly() ? LeafOrAll.LEAF_ONLY : LeafOrAll.ALL_INTERMEDIATE_NODES);

      String association = entityReference.getReferenceAssociation();
      PredicateReference predicate = new PredicateReference();
      predicate.setName(association);

      // namespace for a predicate is not guaranteed in LexEVS... not sure
      // how we want to handle this. For now, assume the same namespace
      // as the starting entity.
      SupportedAssociation supportedAssociation =
          this.findAssociation(lexEvsVSD.getMappings(), association);

      if (supportedAssociation == null) {
        predicate.setNamespace(supportedCodingScheme.getLocalId());
        predicate.setUri(UriUtils.combine(supportedCodingScheme.getUri(), association));
      } else {
        predicate.setNamespace(supportedAssociation.getEntityCodeNamespace());
        if (StringUtils.isNotBlank(supportedAssociation.getUri())) {
          predicate.setUri(supportedAssociation.getUri());
        } else {
          predicate.setUri(UriUtils.combine(supportedCodingScheme.getUri(), association));
        }
      }

      ref.setPredicate(predicate);

      cts2Entry.setAssociatedEntities(ref);
    } else {
      SpecificEntityList sel = new SpecificEntityList();

      sel.addReferencedEntity(uriAndName);

      cts2Entry.setEntityList(sel);
    }
  }