private EntityListEntry createEntityListEntry() {
      /* EntityDescription */
      EntityDescription entityDescription = new EntityDescription();
      NamedEntityDescription namedEntityDescription = new NamedEntityDescription();
      ScopedEntityName name = new ScopedEntityName();
      name.setName("test");
      name.setNamespace("test");

      CodeSystemVersionReference ref = new CodeSystemVersionReference();
      ref.setCodeSystem(new CodeSystemReference("test.ref"));
      ref.setVersion(new NameAndMeaningReference("test.ref.version"));
      namedEntityDescription.setEntityID(name);
      namedEntityDescription.setDescribingCodeSystemVersion(ref);
      namedEntityDescription.setAbout("test.about");

      URIAndEntityName uriAndEntityName = new URIAndEntityName();
      uriAndEntityName.setName("test.entityType");
      uriAndEntityName.setNamespace("test.namespace");
      uriAndEntityName.setUri("http://my/uri");

      List<URIAndEntityName> uriAndEntityNameList = new ArrayList<URIAndEntityName>(1);
      uriAndEntityNameList.add(uriAndEntityName);

      namedEntityDescription.setEntityType(uriAndEntityNameList);
      entityDescription.setNamedEntity(namedEntityDescription);

      /* EntityListEntry */
      EntityListEntry entry = new EntityListEntry();
      entry.setEntry(entityDescription);
      return entry;
    }
 private EntityDescriptionBase createEntityDescription() {
   EntityDescriptionBase entityDescription = new NamedEntityDescription();
   entityDescription.setAbout("test.about");
   CodeSystemVersionReference versionRef = new CodeSystemVersionReference();
   versionRef.setCodeSystem(new CodeSystemReference("test.codesystem"));
   NameAndMeaningReference nameRef = new NameAndMeaningReference("test.nameref");
   versionRef.setVersion(nameRef);
   entityDescription.setDescribingCodeSystemVersion(versionRef);
   URIAndEntityName uriAndEntityName = new URIAndEntityName();
   uriAndEntityName.setName("test.urientityname");
   uriAndEntityName.setNamespace("test");
   uriAndEntityName.setUri("http://my/uri");
   URIAndEntityName uriAndEntityNames[] = new URIAndEntityName[1];
   uriAndEntityNames[0] = uriAndEntityName;
   entityDescription.setEntityType(uriAndEntityNames);
   return entityDescription;
 }
  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);
    }
  }