Example #1
0
  public Alignment buildAlignment(
      Statement stmt, AlignmentType alignmentType, ThesaurusConcept concept) {
    logger.debug("Building alignment " + stmt.getObject().toString());

    Alignment alignment = new Alignment();
    alignment.setIdentifier(generatorService.generate(Alignment.class));
    alignment.setAlignmentType(alignmentType);
    alignment.setAndRelation(false);
    alignment.setCreated(concept.getCreated());
    alignment.setModified(concept.getModified());
    alignment.setSourceConcept(concept);

    if (alignmentType.isResource()) {

      Set<AlignmentResource> targetResources = new HashSet<AlignmentResource>();
      AlignmentResource targetResource = new AlignmentResource();

      String externalTargetResource = stmt.getObject().toString();

      targetResource.setAlignment(alignment);
      targetResource.setExternalTargetResource(externalTargetResource);

      targetResources.add(targetResource);
      alignment.setTargetResources(targetResources);

    } else {

      Set<AlignmentConcept> targetConcepts = new HashSet<AlignmentConcept>();

      AlignmentConcept targetConcept = new AlignmentConcept();
      targetConcept.setAlignment(alignment);

      String targetConceptId = stmt.getObject().toString();
      ThesaurusConcept internalTargetConcept =
          thesaurusConceptService.getThesaurusConceptById(targetConceptId);
      if (internalTargetConcept != null) {
        targetConcept.setInternalTargetConcept(internalTargetConcept);
        alignment.setInternalTargetThesaurus(internalTargetConcept.getThesaurus());
      } else {
        // Check if the concept has an ark indentifier.

        Matcher arkMt = arkPt.matcher(targetConceptId);
        Matcher urlMt = urlPt.matcher(targetConceptId);

        if (arkMt.find()) {
          setExternalThesaurus(alignment, arkMt.group());
        } else if (urlMt.find()) {
          setExternalThesaurus(alignment, urlMt.group());
        }
        targetConcept.setExternalTargetConcept(targetConceptId);
      }

      targetConcepts.add(targetConcept);
      alignment.setTargetConcepts(targetConcepts);
    }
    return alignment;
  }
Example #2
0
 /**
  * Builds the main concept node of the left tree
  *
  * @param parentId the identifier of the thesaurus
  * @return
  */
 public IThesaurusListNode getConcepts(String parentId) {
   IThesaurusListNode concepts = new ThesaurusListBasicNode();
   concepts.setTitle("Arborescence des concepts");
   concepts.setId(CONCEPTS_PREFIX + parentId);
   concepts.setType(ThesaurusListNodeType.FOLDER);
   concepts.setIconCls("icon-tree");
   concepts.setExpanded(false);
   concepts.setDisplayable(false);
   long nbTopConcepts = thesaurusConceptService.getTopTermThesaurusConceptsCount(parentId);
   if (nbTopConcepts > 0) {
     concepts.setChildren(null);
   } else {
     concepts.setChildren(new ArrayList<IThesaurusListNode>());
   }
   return concepts;
 }
Example #3
0
 /**
  * Builds the orphan concepts node of the left tree
  *
  * @param parentId the identifier of the thesaurus
  * @return the node, null if there are no orphan concepts
  */
 public IThesaurusListNode getOrphans(String parentId) {
   IThesaurusListNode orphans = new ThesaurusListBasicNode();
   orphans.setTitle("Concepts orphelins");
   orphans.setId(ORPHANS_PREFIX + parentId);
   orphans.setType(ThesaurusListNodeType.FOLDER);
   orphans.setIconCls("sandbox");
   orphans.setExpanded(false);
   orphans.setDisplayable(false);
   long nbOrphans = thesaurusConceptService.getOrphanThesaurusConceptsCount(parentId);
   if (nbOrphans > 0) {
     orphans.setChildren(null);
   } else {
     return null;
   }
   return orphans;
 }