Package edu.mit.simile.fresnel.selection

Examples of edu.mit.simile.fresnel.selection.Lens


      it = conn.getStatements((Resource) null, FresnelCore.classLensDomain, (Value) null, false);
      while (it.hasNext()) {
        try {
          Statement lensResourceStatement = (Statement) it.next();
          Lens lens = new Lens(this._source, lensResourceStatement.getSubject(), this);
          if (!this._all.containsKey(lens.getIdentifier())) addLens(lens);
        } catch (ParsingException e) {
          gather(e);
        } catch (UnresolvableException u) {
          gather(u);
        }
View Full Code Here


      validStarts = null;
    }

    Iterator<Lens> li = grouping.getLenses().iterator();
    while (li.hasNext()) {
      Lens lens = li.next();
      Iterator<ISelector> di = lens.getDomainSet().iterator();
      while (di.hasNext()) {
        ISelector select = di.next();
        if (select.canSelectResources()) {
          try {
            Iterator<Resource> ri = select.selectResources(in);
            while (ri.hasNext()) {
              Resource res = (Resource) ri.next();
              if (null == validStarts || (null != validStarts && validStarts.contains(res))) {
                if (this._lensMatches.containsKey(res)) {
                  LensMatchSet match = this._lensMatches.getMatch(res);
                  match.add(lens);
                } else {
                  LensMatchSet match = new LensMatchSet(res);
                  match.add(lens);
                  this._lensMatches.putMatch(res, match);
                }
              }
            }
          } catch (InvalidResultSetException e) {
            //
          }
        }
      }
    }

    // exception if no matches
    if (this._lensMatches.size() == 0)
      throw new NoResultsException("No lenses matching the data could be found.");

    Selection answer = new Selection(this);
    answer.setLangPref(langPref);

    Iterator<?> resources = this._lensMatches.keySet().iterator();
    while (resources.hasNext()) {
      Resource subject = (Resource) resources.next();
      LensMatchSet match = this._lensMatches.getMatch(subject);
      Lens best = match.topMatch();
      answer.addPrimary(answer.applyLens(grouping, in, best, subject, 0, MAXIMUM_LENS_DEPTH));
    }

    return answer;
  }
View Full Code Here

    LensMatchSet match = null;

    Iterator<Lens> li = grouping.getLenses().iterator();
    while (li.hasNext()) {
      Lens lens = li.next();
      Iterator<ISelector> di = lens.getDomainSet().iterator();
      while (di.hasNext()) {
        ISelector select = di.next();
        if (select.canSelectResources()) {
          if (select.canSelect(in, focus)) {
            if (null == validStarts || (null != validStarts && validStarts.contains(focus))) {
View Full Code Here

      throw new NoResultsException("No lenses matching the data could be found.");

    Selection answer = new Selection(this);
    answer.setLangPref(langPref);

    Lens best = match.topMatch();

    // check purposes
    for (Iterator<Lens> pli = match.lensIterator(); pli.hasNext(); ) {
      Lens potential = pli.next();
      if (potential.hasPurpose(purpose)) {
        best = potential;
        break;
      }
    }
    answer.addPrimary(answer.applyLens(grouping, in, best, focus, 0, MAXIMUM_LENS_DEPTH));
View Full Code Here

      throw new NoResultsException("No lenses matching the data could be found.");

    Selection answer = new Selection(this);
    answer.setLangPref(langPref);
   
    Lens best = match.topMatch();
    answer.addPrimary(answer.applyLens(grouping, in, best, focus, 0, MAXIMUM_LENS_DEPTH));

    return answer;
  }
View Full Code Here

   * @return The found <code>Lens</code>
   * @throws ParsingException If the lens is not found anywhere or if there are problems parsing the lens
   * @throws UnresolvableException If there are problems parsing the lens
   */
  public Lens lensLookup(Resource identifier) throws ParsingException, UnresolvableException, ResourceNotFoundException {
    Lens out = null;
    if (this._all.containsKey(identifier) && this._lenses.contains(this._all.get(identifier)))
      out = (Lens) this._all.get(identifier);
    else {
      RepositoryConnection conn = null;
      try {
        conn = this._source.getConnection();
        if (conn.hasStatement(identifier, FresnelCore.instanceLensDomain, (Value) null, false)) {
          out = new InstanceLens(this._source, identifier, this);
          addInstanceLens(out);
        } else if (conn.hasStatement(identifier, FresnelCore.classLensDomain, (Value) null, false)) {
          out = new Lens(this._source, identifier, this);
          addLens(out);
        } else {
          throw new ResourceNotFoundException("Explicitly named lens not found in configuration");
        }
      } catch (RepositoryException e) {
View Full Code Here

          } else {
            // instance
            int i = 0;
            int size = this._instances.size();
            for ( ; i < size; i++) {
              Lens compare = this._instances.get(i);
              if (((URI) compare.getIdentifier()).toString().compareTo(((URI) lens.getIdentifier()).toString()) < 0) {
                this._instances.add(i, lens);
                break;
              }
            }
            if (size == i) this._instances.add(lens);
          }
        } else if (lens.isDefault()) {
            // default
            int i = 0;
            int size = this._defaults.size();
            for ( ; i < size; i++) {
                Lens compare = (Lens) this._defaults.get(i);
                if (((URI) compare.getIdentifier()).toString().compareTo(((URI) lens.getIdentifier()).toString()) < 0) {
                    this._defaults.add(i, lens);
                    break;
                }
            }
            if (size == i) this._defaults.add(lens);
        } else {
            // class
            int i = 0;
            int size = this._types.size();
            for ( ; i < size; i++) {
                Lens compare = (Lens) this._types.get(i);
                if (((URI) compare.getIdentifier()).toString().compareTo(((URI) lens.getIdentifier()).toString()) < 0) {
                    this._types.add(i, lens);
                    break;
                }
            }
            if (size == i) this._types.add(lens);
View Full Code Here

     * Returns the top ranked match for the resource amongst all applicable lenses
     *
     * @return A matching <code>Lens</code>
     */
    public Lens topMatch() {
        Lens out = null;
        if (this._instances.size() > 0) out = (Lens) this._instances.get(0);
        else if (this._defaults.size() > 0) out = (Lens) this._defaults.get(0);
        else if (this._types.size() > 0) out = (Lens) this._types.get(0);
        return out;
    }
View Full Code Here

                  // if we've hit the limit, stop with sublensing
                  subr.setTitle(resolveLabel(in, objResource));
                } else {                 
                  // pick a sublens to apply to the resource
                  int newdepth = (selectorPD.getDepth() + current < max) ? selectorPD.getDepth() + current : max;
                  Lens sublens = null;
                  Iterator<Lens> sublensesIt = selectorPD.getSublensesIterator();
                  boolean match = false;
                  matched:
                  while (sublensesIt.hasNext()) {
                    sublens = sublensesIt.next();
                    Iterator<ISelector> domainIt = sublens.getDomainSet().iterator();
                    while (domainIt.hasNext()) {
                      ISelector subdomain = domainIt.next();
                      if (subdomain.canSelect(in, objResource)) {
                        subr = applyLens(group, in, sublens, objResource, current + 1, newdepth);
                        match = true;
View Full Code Here

                  pr.addValue(vr);
                  this._propertyResultModelHash.putResult(prop, pr);
                } else {
                  // pick a sublens to apply to the resource
                  int newdepth = (selectorPD.getDepth() + current < max) ? selectorPD.getDepth() : max;
                  Lens sublens = null;
                  Iterator<Lens> sublensesIt = selectorPD.getSublensesIterator();
                  boolean matched = false;
                  matching:
                  while (sublensesIt.hasNext()) {
                    sublens = sublensesIt.next();
                    Iterator<ISelector> domainIt = sublens.getDomainSet().iterator();
                    while (domainIt.hasNext()) {
                      ISelector subdomain = domainIt.next();
                      if (subdomain.canSelect(in, objResource)) {
                        Result subr = applyLabelLens(sublens, in, objResource, current + 1, newdepth);
                        ValueResult vr = new ValueResult(subr, pr, selected.getContext());
View Full Code Here

TOP

Related Classes of edu.mit.simile.fresnel.selection.Lens

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.