예제 #1
0
  public AndTest() throws IOException {
    this.q =
        new Query(
            TaxonomyCoordinates.getInferredTaxonomyCoordinate(
                StampCoordinates.getDevelopmentLatestActiveOnly(),
                Get.configurationService().getDefaultLanguageCoordinate())) {
          @Override
          protected ForSetSpecification ForSetSpecification() {
            return new ForSetSpecification(ComponentCollectionTypes.ALL_CONCEPTS);
          }

          @Override
          public void Let() {
            let("Physical force", Snomed.PHYSICAL_FORCE);
            let("Motion", Snomed.MOTION);
          }

          @Override
          public Clause Where() {
            return And(
                ConceptIsKindOf("Physical force"),
                Xor(ConceptIsKindOf("Motion"), ConceptIsDescendentOf("Motion")));
          }
        };
  }
  @Override
  public C build(
      EditCoordinate editCoordinate, ChangeCheckerMode changeCheckerMode, List builtObjects)
      throws IllegalStateException {
    if (referencedComponentNid == Integer.MAX_VALUE) {
      referencedComponentNid =
          Get.identifierService().getNidForUuids(referencedComponentBuilder.getUuids());
    }
    SememeChronologyImpl sememeChronicle =
        new SememeChronologyImpl(
            sememeType,
            primordialUuid,
            Get.identifierService().getNidForUuids(this.getUuids()),
            assemblageConceptSequence,
            referencedComponentNid,
            Get.identifierService().getSememeSequenceForUuids(this.getUuids()));
    sememeChronicle.setAdditionalUuids(additionalUuids);
    Get.identifierService()
        .setConceptSequenceForComponentNid(assemblageConceptSequence, sememeChronicle.getNid());
    switch (sememeType) {
      case COMPONENT_NID:
        ComponentNidSememeImpl cnsi =
            (ComponentNidSememeImpl)
                sememeChronicle.createMutableVersion(
                    ComponentNidSememeImpl.class, State.ACTIVE, editCoordinate);
        cnsi.setComponentNid((Integer) parameters[0]);
        break;
      case LONG:
        LongSememeImpl lsi =
            (LongSememeImpl)
                sememeChronicle.createMutableVersion(
                    LongSememeImpl.class, State.ACTIVE, editCoordinate);
        lsi.setLongValue((Long) parameters[0]);
        break;
      case LOGIC_GRAPH:
        LogicGraphSememeImpl lgsi =
            (LogicGraphSememeImpl)
                sememeChronicle.createMutableVersion(
                    LogicGraphSememeImpl.class, State.ACTIVE, editCoordinate);
        lgsi.setGraphData(((LogicalExpression) parameters[0]).getData(DataTarget.INTERNAL));
        break;
      case MEMBER:
        SememeVersionImpl svi =
            (SememeVersionImpl)
                sememeChronicle.createMutableVersion(
                    SememeVersionImpl.class, State.ACTIVE, editCoordinate);
        break;
      case STRING:
        StringSememeImpl ssi =
            (StringSememeImpl)
                sememeChronicle.createMutableVersion(
                    StringSememeImpl.class, State.ACTIVE, editCoordinate);
        ssi.setString((String) parameters[0]);
        break;
      case DESCRIPTION:
        {
          DescriptionSememeImpl dsi =
              (DescriptionSememeImpl)
                  sememeChronicle.createMutableVersion(
                      DescriptionSememeImpl.class, State.ACTIVE, editCoordinate);
          dsi.setCaseSignificanceConceptSequence((Integer) parameters[0]);
          dsi.setDescriptionTypeConceptSequence((Integer) parameters[1]);
          dsi.setLanguageConceptSequence((Integer) parameters[2]);
          dsi.setText((String) parameters[3]);
          break;
        }
      case DYNAMIC:
        {
          DynamicSememeImpl dsi =
              (DynamicSememeImpl)
                  sememeChronicle.createMutableVersion(
                      DynamicSememeImpl.class, State.ACTIVE, editCoordinate);
          if (parameters != null && parameters.length > 0) {
            // See notes in SememeBuilderProvider - this casting / wrapping nonesense it to work
            // around Java being stupid.
            dsi.setData(((AtomicReference<DynamicSememeDataBI[]>) parameters[0]).get());
          }
          // TODO DAN this needs to fire the validator!
          break;
        }
      default:
        throw new UnsupportedOperationException("Can't handle: " + sememeType);
    }

    if (changeCheckerMode == ChangeCheckerMode.ACTIVE) {
      Get.commitService().addUncommitted(sememeChronicle);
    } else {
      Get.commitService().addUncommittedNoChecks(sememeChronicle);
    }
    builtObjects.add(sememeChronicle);
    return (C) sememeChronicle;
  }