Exemplo n.º 1
0
  /**
   * Returns a tree representation of the classes in the range of the given property, with the nodes
   * in alphabetic order.
   *
   * @param user User id
   * @param prop Property name
   * @return Hierarchy[] tree representation of range class hierarchy, empty if session expired
   */
  public Hierarchy[] getRangeHierarchy(String user, String prop) {
    if (!userMap.containsKey(user)) return new Hierarchy[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      if (prop.equals("ANYTHING")) return session.getReader().getClassHierarchy();
      return session.getReader().getRangeHierarchy(prop);
    }
  }
Exemplo n.º 2
0
  /**
   * Returns a tag cloud for the given property.
   *
   * @param user User ID
   * @param property Property name
   * @return TagCloud, null if session expired or error occurred
   */
  public TagCloud getTagCloud(String user, String property) {
    try {
      if (!userMap.containsKey(user)) return null;

      LiberSession session = userMap.get(user);
      synchronized (session) {
        session.setLastUpdated();
        TagCloud tc =
            new Folksonomy(user)
                .getTagCloud(session.getReader(), session.getReader().getProperty(property));
        return tc;
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Exemplo n.º 3
0
  /**
   * Returns an aggregated tag cloud for a set of properties.
   *
   * @param user User ID
   * @param properties String[] with property names
   * @return TagCloud, null if session expired or error occurred
   */
  public TagCloud getTagCloud(String user, String[] properties) {
    try {
      if (!userMap.containsKey(user)) return null;

      LiberSession session = userMap.get(user);
      synchronized (session) {
        session.setLastUpdated();
        List<OntProperty> list = new ArrayList<OntProperty>();
        for (int i = 0; i < properties.length; i++)
          list.add(session.getReader().getProperty(properties[i]));
        TagCloud tc = new Folksonomy(user).getTagCloud(session.getReader(), list);
        return tc;
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Exemplo n.º 4
0
  /**
   * Returns the values allowed in the range of the given property.
   *
   * @param user User ID
   * @param property Property name
   * @return String[] with possible range values, null if session expired
   */
  public String[] getRange(String user, String property) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.getReader().getRestrictedRange(property).toArray(new String[0]);
    }
  }
Exemplo n.º 5
0
  /**
   * Returns a tree representation of the subclasses of the given nodes, with the nodes in
   * alphabetic order.
   *
   * @param user User id
   * @param roots Root nodes
   * @return Hierarchy[] tree representation of class hierarchy, null if session expired
   */
  public Hierarchy[] getClassHierarchy(String user, String[] roots) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.getReader().getClassHierarchy(roots);
    }
  }
Exemplo n.º 6
0
  /**
   * Returns all string datatype properties with cardinal constraints of this class.
   *
   * @param user User ID
   * @param type Class name
   * @return FormInfo[] with information needed to create a small form for new instance creation,
   *     null if error occurred or session expired
   */
  public FormInfo[] getCardinalStringProperties(String user, String type) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      try {
        return session.getReader().getCardinalStringProperties(type);
      } catch (Exception e) {
        return null;
      }
    }
  }
Exemplo n.º 7
0
  /**
   * Returns the type of the property: object- or datatype, and whether it has restricted values,
   * and any cardinality constraints it might have. The first element in the array returns the range
   * type, the second a maximum cardinality constraint (0 if there is none)
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param type Session type
   * @param key browsing session id (null if session type is EDIT)
   * @return Integer[] with property type.
   */
  public Integer[] getType(String user, String anchor, String property, int type, String key) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    Integer[] result = new Integer[2];
    synchronized (session) {
      session.setLastUpdated();
      result[0] = session.getReader().getRangeType(property);
      result[1] = new Integer(session.getMax(anchor, property, type, key));
    }

    return result;
  }