Пример #1
0
  private void matchLanguage(Criteria criteria, String thesaurusId) {
    Criteria thesaurusCriteria =
        getCurrentSession()
            .createCriteria(Thesaurus.class, "t")
            .add(Restrictions.eq("t.identifier", thesaurusId));

    List<Thesaurus> lThesaurus = thesaurusCriteria.list();
    Thesaurus thesaurus = lThesaurus.get(0);

    criteria.add(Restrictions.in("tt.language", thesaurus.getLang()));
  }
Пример #2
0
  private Criteria getCriteriaByThesaurusAndTopConcept(
      Thesaurus thesaurus, boolean topConcept, String like) {
    Criteria criteria = getCurrentSession().createCriteria(ThesaurusConcept.class, "tc");

    if (null != like) {
      criteria =
          getCurrentSession()
              .createCriteria(ThesaurusTerm.class, "tt")
              .add(Restrictions.isNotNull("tt.concept"))
              .createCriteria("concept", "tc", JoinType.RIGHT_OUTER_JOIN);

      criteria
          .setProjection(
              Projections.projectionList()
                  .add(Projections.property("tt.lexicalValue"))
                  .add(Projections.property("tc.identifier").as("identifier")))
          .setResultTransformer(Transformers.aliasToBean(ThesaurusConcept.class));
      conceptNameIsLike(criteria, like);
    }

    selectThesaurus(criteria, thesaurus.getIdentifier());
    selectOrphans(criteria, !topConcept);
    selectNoParents(criteria);
    return criteria;
  }
  /**
   * Exports complex concept
   *
   * @param thesaurus
   * @param model
   * @return
   */
  public Model exportComplexConcept(Thesaurus thesaurus, Model model) {
    List<SplitNonPreferredTerm> complexConcepts =
        splitNonPreferredTermService.getSplitNonPreferredTermList(
            0, -1, thesaurus.getThesaurusId());
    if (!complexConcepts.isEmpty()) {

      for (SplitNonPreferredTerm complexConcept : complexConcepts) {

        Resource inScheme = model.createResource(complexConcept.getThesaurus().getIdentifier());

        // Add splitNonPreferredTerm resource
        Resource complexConceptRes =
            model.createResource(complexConcept.getIdentifier(), ISOTHES.SPLIT_NON_PREFERRED_TERM);

        model.add(complexConceptRes, SKOS.IN_SCHEME, inScheme);

        model.add(
            complexConceptRes,
            SKOSXL.LITERAL_FORM,
            StringEscapeUtils.unescapeXml(complexConcept.getLexicalValue()),
            complexConcept.getLanguage().getId());
        model.add(
            complexConceptRes,
            DCTerms.created,
            DateUtil.toISO8601String(complexConcept.getCreated()));
        model.add(
            complexConceptRes,
            DCTerms.modified,
            DateUtil.toISO8601String(complexConcept.getModified()));
        model.add(complexConceptRes, ISOTHES.STATUS, complexConcept.getStatus().toString());

        if (StringUtils.isNotEmpty(complexConcept.getSource())) {
          model.add(complexConceptRes, DC.source, complexConcept.getSource());
        }

        // Add compoundEquivalence resource

        Resource compoundEquivalenceRes = model.createResource(ISOTHES.COMPOUND_EQUIVALENCE);
        model.add(compoundEquivalenceRes, SKOS.IN_SCHEME, inScheme);
        model.add(compoundEquivalenceRes, ISOTHES.PLUS_UF, complexConcept.getIdentifier());
        for (ThesaurusTerm term : complexConcept.getPreferredTerms()) {
          model.add(compoundEquivalenceRes, ISOTHES.PLUS_USE, term.getIdentifier());
        }
      }
    }
    return model;
  }