public void setComponent(int componentOrConceptNid) {
    ComponentVersionBI componentVersion = OTFUtility.getComponentVersion(componentOrConceptNid);
    if (componentVersion == null) {
      // May be a concept
      componentVersion = OTFUtility.getConceptVersion(componentOrConceptNid);
    }

    if (componentVersion == null) {
      String msg = "No componentOrConcept or concept retrieved for nid " + componentOrConceptNid;
      LOG.error(msg);
      throw new RuntimeException(msg);
    }

    setComponent(componentVersion);
  }
  public String toStringWithDescriptions() {
    StringBuilder builder = new StringBuilder();
    builder.append("CompositeSearchResult [containingConcept=");
    String containingConceptDesc = null;
    if (containingConcept != null) {
      try {
        containingConceptDesc =
            OTFUtility.getDescriptionIfConceptExists(containingConcept.getConceptNid());
      } catch (Exception e) {
        containingConceptDesc = "{nid=" + containingConcept.getConceptNid() + "}";
      }
    }
    builder.append(containingConceptDesc);

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

    String matchingComponentDesc = null;
    if (matchingComponentNid_ != 0) {
      try {
        ComponentChronicleBI<?> cc = OTFUtility.getComponentChronicle(matchingComponentNid_);
        matchingComponentDesc = cc.toUserString();
      } catch (Exception e) {
        // NOOP
      }
    }
    if (matchingComponentDesc != null) {
      builder.append(", matchingComponent=");
      builder.append(matchingComponentDesc);
    }

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

    builder.append(", numMatchingComponents=");
    List<Integer> matchingComponentNids = new ArrayList<>();
    for (ComponentVersionBI matchingComponent : getMatchingComponents()) {
      matchingComponentNids.add(matchingComponent != null ? matchingComponent.getNid() : null);
    }
    builder.append(matchingComponentNids);

    builder.append("]");
    return builder.toString();
  }
 private String getDefaultPromotionPathCoordinateTextFieldContent() {
   UUID promotionPathUUID =
       AppContext.getAppConfiguration().getCurrentWorkflowPromotionPathUuidAsUUID();
   if (promotionPathUUID == null) {
     return "";
   }
   try {
     return OTFUtility.getConceptVersion(promotionPathUUID).getPreferredDescription().getText();
   } catch (IOException | ContradictionException e) {
     return "";
   }
 }
  public CompositeSearchResult(ComponentVersionBI matchingComponent, float score) {
    this.matchingComponents.add(matchingComponent);
    this.bestScore = score;
    // matchingComponent may be null, if the match is not on our view path...
    if (matchingComponent == null) {
      throw new RuntimeException(
          "Please call the constructor that takes a nid, if matchingComponent is null...");
    } else {
      this.matchingComponentNid_ = matchingComponent.getNid();
    }
    this.containingConcept =
        OTFUtility.getConceptVersion(matchingComponent.getAssociatedConceptNid());

    // TODO - we need to evaluate / design proper behavior for how view coordinate should work with
    // search
    // default back to just using this for the moment, rather than what OTFUtility says.
    // this.containingConcept = OTFUtility.getConceptVersion(matchingComponent.getConceptNid(), vc);
  }
  public void setComponent(ComponentVersionBI passedComponentOrConcept) {
    if (componentOrConcept != null) {
      String msg =
          "Cannot reset componentOrConcept from "
              + componentOrConcept.getNid()
              + " to "
              + passedComponentOrConcept.getNid();
      LOG.error(msg);
      throw new RuntimeException(msg);
    }

    componentOrConcept = passedComponentOrConcept;
    if (componentOrConcept instanceof ConceptVersionBI) {
      LOG.debug(
          "Set concept nid="
              + passedComponentOrConcept.getNid()
              + ", uuid="
              + passedComponentOrConcept.getPrimordialUuid()
              + ", desc="
              + passedComponentOrConcept.toUserString());
    } else {
      LOG.debug(
          "Set componentOrConcept nid="
              + passedComponentOrConcept.getNid()
              + ", uuid="
              + passedComponentOrConcept.getPrimordialUuid()
              + ", desc="
              + OTFUtility.getDescription(passedComponentOrConcept.getNid()));
    }

    try {
      loadContents();
    } catch (IOException e) {
      LOG.error("Unexpected", e);
      throw new RuntimeException(e);
    }
  }