private void add( CodingSchemeReference codingSchemeReference, ValueSetDefinitionEntry cts2Entry, org.LexGrid.valueSets.ValueSetDefinition definition) { CompleteCodeSystemReference ccr = new CompleteCodeSystemReference(); String codeSystemName = codingSchemeReference.getCodingScheme(); SupportedCodingScheme supportedCodingScheme = this.findCodingScheme(definition, codeSystemName); ccr.setCodeSystem( this.getTransformUtils() .toCodeSystemReference( supportedCodingScheme.getLocalId(), supportedCodingScheme.getUri())); cts2Entry.setCompleteCodeSystem(ccr); }
private void add( PropertyReference propertyReference, ValueSetDefinitionEntry cts2Entry, org.LexGrid.valueSets.ValueSetDefinition definition) { PropertyQueryReference pqr = new PropertyQueryReference(); String codingScheme = propertyReference.getCodingScheme(); SupportedCodingScheme supportedCodingScheme = this.findCodingScheme(definition, codingScheme); pqr.setCodeSystem( this.getTransformUtils() .toCodeSystemReference( supportedCodingScheme.getLocalId(), supportedCodingScheme.getUri())); String propertyName = propertyReference.getPropertyName(); String matchAlgorithm = propertyReference.getPropertyMatchValue().getMatchAlgorithm(); String matchValue = propertyReference.getPropertyMatchValue().getContent(); SupportedProperty supportedProperty = this.findProperty(definition.getMappings(), propertyName); String propName; String propUri; if (StringUtils.isBlank(propertyName)) { // TODO: What is the correct behavior here? propName = "UNSPECIFIED"; propUri = "UNSPECIFIED"; } else { propName = supportedProperty.getLocalId(); propUri = supportedProperty.getUri(); } FilterComponent filter = new FilterComponent(); filter.setMatchAlgorithm(new MatchAlgorithmReference()); filter.getMatchAlgorithm().setContent(matchAlgorithm); filter.setPropertyReference(new URIAndEntityName()); filter.getPropertyReference().setName(propName); filter.getPropertyReference().setUri(propUri); filter.setMatchValue(matchValue); pqr.setFilter(filter); cts2Entry.setPropertyQuery(pqr); }
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); } }