Ejemplo n.º 1
0
 /** Removes the empty iterators. */
 private void removeEmptyIterators() {
   List<ResolvedConceptReferencesIterator> newList =
       new ArrayList<ResolvedConceptReferencesIterator>();
   for (ResolvedConceptReferencesIterator itr : _iterators) {
     try {
       if (itr.hasNext()) {
         newList.add(itr);
       }
     } catch (LBResourceUnavailableException e) {
       throw new RuntimeException(e);
     }
   }
   _iterators = newList;
 }
Ejemplo n.º 2
0
  /**
   * Instantiates a new Iterator. Be sure that any desired restrictions have already been placed on
   * the CodedNodeSets before passing into this constructor
   *
   * @param codedNodeSets the coded node sets
   * @param sortOptions the sort options
   * @param filterOptions the filter options
   * @param restrictToProperties the restrict to properties
   * @param restrictToPropertyTypes the restrict to property types
   * @param resolve the resolve
   * @throws LBException the LB exception
   */
  public QuickUnionIterator(
      Vector<CodedNodeSet> codedNodeSets,
      SortOptionList sortOptions,
      LocalNameList filterOptions,
      LocalNameList restrictToProperties,
      PropertyType[] restrictToPropertyTypes,
      boolean resolve)
      throws LBException {

    for (CodedNodeSet cns : codedNodeSets) {
      // KLO 012310
      if (cns != null) {
        try {
          ResolvedConceptReferencesIterator iterator =
              cns.resolve(
                  sortOptions,
                  filterOptions,
                  restrictToProperties,
                  restrictToPropertyTypes,
                  resolve);
          if (iterator != null) {
            _iterators.add(iterator);
          }
        } catch (Exception ex) {
          _logger.error("QuickUnionIterator constructor - cns.resolve throws exception???");
          // ex.printStackTrace();
          System.out.println(
              "WARNING: QuickUnionIteratorWrapper constructor - cns.resolve throws exception???");
        }
      }
    }

    Collections.sort(_iterators, new IteratorSizeComparator());
  }
Ejemplo n.º 3
0
 /**
  * Gets the next from list.
  *
  * @return the next from list
  */
 private ResolvedConceptReference getNextFromList() {
   try {
     while (hasNext()) {
       int iterator = _currentIterator % _iterators.size();
       ResolvedConceptReferencesIterator itr = _iterators.get(iterator);
       if (itr.hasNext()) {
         _currentIterator++;
         return itr.next();
       } else {
         _currentIterator++;
       }
     }
     return null;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 4
0
  public List<MappingSortOption> createMappingSortOption(int sortBy) {
    List<MappingSortOption> list = new ArrayList<MappingSortOption>();
    MappingSortOption option = null;
    QualifierSortOption qualifierOption = null;
    switch (sortBy) {
      case 1:
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        break;

      case 2:
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        break;

        // to be modified
      case 3:
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        break;

      case 4:
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        break;

      case 5:
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        break;

      case 6:
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        break;

      case 7:
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        break;

        // to be modified
      case 8:
        // option = new MappingSortOption(MappingSortOptionName.TARGET_NAMESPACE, Direction.ASC);
        // list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.TARGET_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.TARGET_CODE, Direction.ASC);
        list.add(option);
        option = new MappingSortOption(MappingSortOptionName.SOURCE_CODE, Direction.ASC);
        list.add(option);
        option =
            new MappingSortOption(MappingSortOptionName.SOURCE_ENTITY_DESCRIPTION, Direction.ASC);
        list.add(option);
        qualifierOption = new QualifierSortOption(Direction.ASC, "rel");
        list.add(qualifierOption);
        qualifierOption = new QualifierSortOption(Direction.DESC, "score");
        list.add(qualifierOption);
        break;

      default:
        return createMappingSortOption(1);
    }
    return list;
  }
Ejemplo n.º 5
0
 /*
  * (non-Javadoc)
  *
  * @see org.LexGrid.LexBIG.Utility.Iterators.EntityListIterator#hasNext()
  */
 public boolean hasNext() throws LBResourceUnavailableException {
   removeEmptyIterators();
   return _iterators.size() > 0;
 }