Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
 public static void xrefAnnotation(RefexChronicleBI annotation) throws IOException {
   ConceptChronicle refexConcept = ConceptChronicle.get(annotation.getRefexExtensionNid());
   if (refexConcept.isAnnotationIndex()) {
     if (refexConcept.addMemberNid(annotation.getNid())) {
       annotationConcepts.add(refexConcept);
     }
   }
 }
Exemplo n.º 3
0
  /**
   * Imports the dialect variant words into a map of the dialect to the dialect variant word. Checks
   * to see if the map is empty before loading, and will only load the words if the map is found to
   * be empty.
   *
   * @param dialectOrLanguageNid the dialect or language nid
   * @throws UnsupportedDialectOrLanguage indicates an unsupported dialect or language
   * @throws IOException signals that an I/O exception has occurred
   */
  private static void lazyInit(int dialectOrLanguageNid)
      throws UnsupportedDialectOrLanguage, IOException {
    if (variantMap == null) {
      initLock.lock();
      try {
        if (variantMap == null) {
          HashMap<Integer, Map<String, String>> initialVariantMap =
              new HashMap<Integer, Map<String, String>>();
          variantSetMap = new HashMap<Integer, Set<String>>();
          ViewCoordinate vc = AppContext.getService(TerminologyStoreDI.class).getMetadataVC();
          TerminologySnapshotDI ts =
              AppContext.getService(TerminologyStoreDI.class).getSnapshot(vc);

          ConceptVersionBI enVariantTextRefsetC =
              Language.EN_VARIANT_TEXT.getStrict(
                  AppContext.getService(TerminologyStoreDI.class).getMetadataVC());
          Collection<? extends RefexChronicleBI<?>> enVariants = enVariantTextRefsetC.getRefexes();
          Set<String> variantSet = new HashSet<String>();
          for (RefexChronicleBI<?> refex : enVariants) {
            if (RefexStringVersionBI.class.isAssignableFrom(refex.getClass())) {
              RefexStringVersionBI<?> variantText = (RefexStringVersionBI<?>) refex.getVersion(vc);
              if (variantText != null) {
                variantSet.add(variantText.getString1());
              }
            }
          }
          variantSetMap.put(Language.EN.getStrict(vc).getNid(), variantSet);

          addDialect(Language.EN_AU, vc, Language.EN_AU_TEXT_VARIANTS, ts, initialVariantMap);
          addDialect(Language.EN_CA, vc, Language.EN_CA_TEXT_VARIANTS, ts, initialVariantMap);
          addDialect(Language.EN_NZ, vc, Language.EN_NZ_TEXT_VARIANTS, ts, initialVariantMap);
          addDialect(Language.EN_UK, vc, Language.EN_UK_TEXT_VARIANTS, ts, initialVariantMap);
          addDialect(Language.EN_US, vc, Language.EN_US_TEXT_VARIANTS, ts, initialVariantMap);
          DialectHelper.variantMap = initialVariantMap;
        }
      } catch (ContradictionException ex) {
        throw new IOException(ex);
      } finally {
        initLock.unlock();
      }
    }
    if (!variantMap.containsKey(dialectOrLanguageNid)
        && !variantSetMap.containsKey(dialectOrLanguageNid)) {
      throw new UnsupportedDialectOrLanguage("nid: " + dialectOrLanguageNid);
    }
  }
Exemplo n.º 4
0
  private FHIMInformationModel createInformationModel(RefexChronicleBI<?> modelRefex)
      throws ValidationException, IOException, ContradictionException {

    // Model name, UUID.
    StringMember modelAnnotation = (StringMember) modelRefex;
    String modelName = modelAnnotation.getString1();
    UUID modelUUID = modelRefex.getPrimordialUuid();
    FHIMInformationModel infoModel = new FHIMInformationModel(modelName, modelUUID);
    LOG.debug("Model name: " + modelName);
    LOG.debug("Model UUID: " + modelUUID);

    // Get all annotations on the model annotation.
    //        Collection<? extends RefexChronicleBI<?>> modelAnnotations =
    // getLatestAnnotations(modelRefex);

    /**
     * TODO - BAC // Enumerations. List<StringMember> enumAnnotations =
     * filterAnnotations(modelAnnotations, FHIMMetadataBinding.FHIM_ENUMERATIONS_REFSET,
     * StringMember.class); if (enumAnnotations.isEmpty()) { LOG.info("No FHIM_ENUMERATIONS_REFSET
     * member found."); } else { for (StringMember enumAnnotation : enumAnnotations) { Enumeration
     * enumeration = buildEnumeration(enumAnnotation); infoModel.addEnumeration(enumeration); } }
     *
     * <p>// Stub Classes first, they will be used as types. List<StringMember> classAnnotations =
     * filterAnnotations(modelAnnotations, FHIMMetadataBinding.FHIM_CLASSES_REFSET,
     * StringMember.class); if (classAnnotations.isEmpty()) { LOG.info("No FHIM_CLASSES_REFSET
     * member found."); } else { for (StringMember classAnnotation : classAnnotations) {
     *
     * <p>// Stub for now, we will flesh out later. Class clazz = new
     * Class(classAnnotation.getString1());
     *
     * <p>// Keep track for later. nidClassMap.put(classAnnotation.getNid(), clazz); } }
     *
     * <p>// Now flesh out Classes. for (StringMember classAnnotation : classAnnotations) { Class c
     * = buildClass(classAnnotation); infoModel.addClass(c); }
     *
     * <p>// Dependencies. List<NidNidStringMember> dependencyAnnotations =
     * filterAnnotations(modelAnnotations, FHIMMetadataBinding.FHIM_DEPENDENCIES_REFSET,
     * NidNidStringMember.class); if (dependencyAnnotations.isEmpty()) { LOG.info("No
     * FHIM_DEPENDENCIES_REFSET member found."); } else { for (NidNidStringMember
     * dependencyAnnotation : dependencyAnnotations) { Dependency d =
     * buildDependency(dependencyAnnotation); infoModel.addDependency(d); } }
     *
     * <p>// Create model-scoped Attributes, which will be used by Associations.
     * Collection<NidStringMember> attributeAnnotations = filterAnnotations( modelAnnotations,
     * FHIMMetadataBinding.FHIM_ATTRIBUTES_REFSET, NidStringMember.class); for (NidStringMember
     * attributeAnnotation : attributeAnnotations) { buildAttribute(attributeAnnotation); }
     *
     * <p>// Associations. List<StringMember> associationAnnotations =
     * filterAnnotations(modelAnnotations, FHIMMetadataBinding.FHIM_ASSOCIATIONS_REFSET,
     * StringMember.class); if (associationAnnotations.isEmpty()) { LOG.info("No
     * FHIM_ASSOCIATIONS_REFSET member found."); } else { for (StringMember associationAnnotation :
     * associationAnnotations) { Association a = buildAssociation(associationAnnotation);
     * infoModel.addAssociation(a); } }
     */
    return infoModel;
  }
  public TtkRefexUuidIntMemberChronicle(RefexChronicleBI another) throws IOException {
    super((RefexVersionBI) another.getPrimordialVersion());

    TerminologyStoreDI ts = Ts.get();
    Collection<? extends RefexNidIntVersionBI> refexes = another.getVersions();
    int partCount = refexes.size();
    Iterator<? extends RefexNidIntVersionBI> relItr = refexes.iterator();
    RefexNidIntVersionBI rv = relItr.next();

    this.uuid1 = ts.getUuidPrimordialForNid(rv.getNid1());
    this.int1 = rv.getInt1();

    if (partCount > 1) {
      revisions = new ArrayList<>(partCount - 1);

      while (relItr.hasNext()) {
        rv = relItr.next();
        revisions.add(new TtkRefexUuidIntRevision(rv));
      }
    }
  }