public String toShortString() {
    StringBuilder builder = new StringBuilder();
    builder.append("CompositeSearchResult [containingConcept=");
    builder.append(containingConcept != null ? containingConcept.getNid() : null);

    if (matchingComponentNid_ != 0) {
      builder.append(", matchingComponentNid_=");
      builder.append(matchingComponentNid_);
    }

    builder.append(", bestScore=");
    builder.append(bestScore);

    if (matchingComponents != null && matchingComponents.size() > 0) {
      builder.append(", matchingComponents=");
      List<Integer> matchingComponentNids = new ArrayList<>();
      for (ComponentVersionBI matchingComponent : matchingComponents) {
        matchingComponentNids.add(matchingComponent != null ? matchingComponent.getNid() : null);
      }
      builder.append(matchingComponentNids);
    }

    builder.append("]");
    return builder.toString();
  }
Ejemplo n.º 2
0
  /**
   * Adds a dialect to the <code>initialVariantMap</code>.
   *
   * @param dialectSpec the <code>ConceptSpec</code> representing the dialect concept
   * @param viewCoordinate the view coordinate specifying which versions are active or inactive
   * @param varientsSpec the <code>ConceptSpec</code> representing the dialect refex concept
   * @param terminologySnapshot the terminologySnapshot to use for getting component versions
   * @param initialVariantMap the map to udpate
   * @throws ContradictionException if more than one version is found for a given position or view
   *     coordinate
   * @throws IOException signals that an I/O exception has occurred
   */
  private static void addDialect(
      ConceptSpec dialectSpec,
      ViewCoordinate viewCoordinate,
      ConceptSpec varientsSpec,
      TerminologySnapshotDI terminologySnapshot,
      HashMap<Integer, Map<String, String>> initialVariantMap)
      throws ContradictionException, IOException {
    ConceptVersionBI dialectC = dialectSpec.getStrict(viewCoordinate);
    ConceptVersionBI variantTextRefsetC = varientsSpec.getStrict(viewCoordinate);

    Collection<? extends RefexChronicleBI<?>> dialectVarients =
        variantTextRefsetC.getRefexMembersActive(viewCoordinate);
    Map<String, String> variantDialectMap = new HashMap<String, String>();
    for (RefexChronicleBI<?> refex : dialectVarients) {
      if (RefexStringVersionBI.class.isAssignableFrom(refex.getClass())) {
        RefexStringVersionBI<?> dialectText =
            (RefexStringVersionBI<?>) refex.getVersion(viewCoordinate);
        if (dialectText != null) {
          RefexStringVersionBI<?> variantText =
              (RefexStringVersionBI<?>)
                  terminologySnapshot.getComponentVersion(dialectText.getReferencedComponentNid());
          variantDialectMap.put(variantText.getString1(), dialectText.getString1());
        }
      }
    }
    initialVariantMap.put(dialectC.getNid(), variantDialectMap);
  }
 protected void merge(CompositeSearchResult other) {
   if (containingConcept.getNid() != other.containingConcept.getNid()) {
     throw new RuntimeException("Unmergeable!");
   }
   if (other.bestScore > bestScore) {
     bestScore = other.bestScore;
   }
   matchingComponents.addAll(other.getMatchingComponents());
 }