コード例 #1
0
  /**
   * Returns an RDF representation of the feedback text, which is also stored in Sesame.
   *
   * @param user user id
   * @param type session type
   * @param key browsing session id (null if session type is EDIT)
   * @return String RDF, or null if the user's session is expired
   */
  public String upload(String user, int type, String key) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      return session.getRDF(type, key);
    }
  }
コード例 #2
0
  /**
   * Creates a SPARQL representation of the query, sends it to Sesame, and returns a description of
   * all matching resources.
   *
   * @param user user id
   * @param time Time it took the user to construct the query
   * @return description of matches, or null if the user's session is expired
   */
  public AnchorInfo[] getQueryResult(String user, long time) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      return session.getQueryResult(time);
    }
  }
コード例 #3
0
  /**
   * Returns the number of resources that match the current query
   *
   * @param user User ID
   * @return Integer
   */
  public Integer getMatchNr(String user) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.getMatchNr();
    }
  }
コード例 #4
0
  /**
   * Stores in the graph which properties in the query the user considers optional.
   *
   * @param user User ID
   * @param checks Boolean[], specifies whether optional checkboxes are checked
   * @return Number of objects in the archive that match the query
   */
  public Integer sendOptionalInfo(String user, Boolean[] checks) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.sendOptionalInfo(checks);
    }
  }
コード例 #5
0
  /**
   * Stores in the graph which properties in the query the user considers optional.
   *
   * @param user User ID
   * @return Boolean[], specifies whether optional checkboxes are checked
   */
  public Boolean[] getCheckedOptionals(String user) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.getQueryBuilder().getCheckedOptionals();
    }
  }
コード例 #6
0
  /**
   * Called when the users asks to show all elements in a summation.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] showSummation(String user, String anchor, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.showSummation(anchor, type, key);
    }
  }
コード例 #7
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]);
    }
  }
コード例 #8
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);
    }
  }
コード例 #9
0
  /**
   * Retrieves the SemanticGraph of the query result the user is interested in, and returns a
   * feedback text with all information about that object
   *
   * @param user user ID
   * @param idx Index
   * @return AnchorInfo[], serialisable version of feedback text, empty if the user's session is
   *     expired, null if an error occurred
   */
  public AnchorInfo[] getBrowsingDescription(String user, int idx) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.getBrowsingDescription(idx);
    }
  }
コード例 #10
0
  /**
   * Returns the feedback text
   *
   * @param user user id
   * @param type type of session
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] getFeedbackText(String user, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.getFeedbackText(type, key);
    }
  }
コード例 #11
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);
    }
  }
コード例 #12
0
  /**
   * Finds all objects in the archive of one of the given types and with the given name/title.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @param data Information about object added by user in form
   * @return String[] with brief descriptions of search results
   */
  public String[] checkDatabase(
      String user, String anchor, String property, int type, String key, InstanceData data) {
    if (!userMap.containsKey(user)) return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.checkDatabase(anchor, property, data, type, key);
    }
  }
コード例 #13
0
  /**
   * Adds multiple values for one property in one go. Only for datatype properties in the Query tab.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param values Values added by user
   * @param datatype Datatype of property. 1 for a datatype property with restricted values; 2 for a
   *     date; 3 for a double or float; 4 for an integer; 5 for a boolean; 6 for a string; and 7 for
   *     another object.
   * @param operator Boolean operator (and, or, not)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] multipleValuesUpdate(
      String user, String anchor, String property, String[] values, int datatype, String operator) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.multipleValuesUpdate(anchor, property, values, datatype, operator);
    }
  }
コード例 #14
0
  /**
   * Tries to export an object in a browsing pane to the editing pane. Returns null if the user's
   * session is expired, false if the operation fails and true if it succeeds. Used by previous
   * version of LIBER.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param key browsing session id (null if session type is EDIT)
   * @return true if it succeeded
   * @deprecated
   */
  public Boolean exportObject(String user, String anchor, String key) {
    if (!userMap.containsKey(user)) // if this user already has a session, do nothing
    return null;

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.exportObject(anchor, key);
    }
  }
コード例 #15
0
  /**
   * Adds multiple values for one property in one go. Only for datatype properties in the Query tab.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param values Values added by user
   * @param operator Boolean operator (and, or, not)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] updateDate(
      String user, String anchor, String property, QueryDateValue[] values, String operator) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.updateDate(anchor, property, values, operator);
    }
  }
コード例 #16
0
  /**
   * Removes edges from the Semantic Graph
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param values Values added by user
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] removeProperty(
      String user, String anchor, String property, String[] values, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.removeProperty(anchor, property, values, type, key);
    }
  }
コード例 #17
0
  /**
   * Updates multiple additions from a restricted range property
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param idx Values selected by user
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] multipleUpdate(
      String user, String anchor, String property, String[] idx, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.multipleUpdate(anchor, property, idx, type, key);
    }
  }
コード例 #18
0
  /**
   * Adds an abstract property.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param value Value added by user
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] updateAbstract(
      String user, String anchor, String property, String value, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.updateAbstract(anchor, property, value, type, key);
    }
  }
コード例 #19
0
  /**
   * Adds one or more object properties.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param range InstanceData[] specifying data about objects added by user
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] updateObjectProperty(
      String user, String anchor, String property, InstanceData[] range, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.updateObjectProperty(anchor, property, range, type, key);
    }
  }
コード例 #20
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;
  }
コード例 #21
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;
      }
    }
  }
コード例 #22
0
  /**
   * Returns the values of resourceID for the properties specified in formInformation.
   *
   * @param user User ID
   * @param resourceID Resource ID
   * @param formInformation FormInfo[] specifying properties
   * @return String[] with values, null if session expired or error occurred
   */
  public String[] getDescriptionValues(String user, String resourceID, FormInfo[] formInformation) {
    try {
      if (!userMap.containsKey(user)) return null;

      LiberSession session = userMap.get(user);
      synchronized (session) {
        session.setLastUpdated();
        return session.getDescriptionValues(resourceID, formInformation);
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
コード例 #23
0
  /**
   * Called when the users asks to show or hide all known information about a certain object from
   * the database.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param show If true, show more information, if false, hide information
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if an error occurred
   */
  public AnchorInfo[] changeTextContent(
      String user, String anchor, boolean show, int type, String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);

    Runtime r = Runtime.getRuntime();
    r.gc(); // FORCES GARBAGE COLLECTION
    r.runFinalization();

    synchronized (session) {
      session.setLastUpdated();
      return session.changeTextContent(anchor, show, type, key);
    }
  }
コード例 #24
0
  /**
   * Updates the SG with the newly added date. If it's the first date, it increments the 'last
   * operation' cntr; if it's the last, it updates and returns the feedback text.
   *
   * @param user User ID
   * @param anchor Unique ID of Anchor
   * @param property Property name
   * @param date Date value added by user
   * @param dateCntr Index number of date
   * @param updateText If true, the feedbacktext is regenerated and returned
   * @param type Session type (edit, query, browse)
   * @param key browsing session id (null if session type is EDIT)
   * @return AnchorInfo[] with serialisable version of feedback text, empty if the user's session is
   *     expired or null if updateText was false or an error occurred
   */
  public AnchorInfo[] updateDate(
      String user,
      String anchor,
      String property,
      String[] date,
      int dateCntr,
      boolean updateText,
      int type,
      String key) {
    if (!userMap.containsKey(user)) return new AnchorInfo[0];

    LiberSession session = userMap.get(user);
    synchronized (session) {
      session.setLastUpdated();
      return session.updateDate(anchor, property, date, dateCntr, updateText, type, key);
    }
  }
コード例 #25
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;
    }
  }
コード例 #26
0
  /**
   * Ends this particular session. If it's a browsing session, the browsing generator is removed;
   * otherwise, the entire user's session can be removed.
   *
   * @param user user id
   * @param type type of session
   * @param key browsing session id (null if session type is EDIT)
   */
  public void endSession(String user, int type, String key) {
    if (!userMap.containsKey(user)) return;

    if (type == LiberSession.BROWSE) {
      LiberSession session = userMap.get(user);
      synchronized (session) {
        session.removeBrowsingGenerator(key);
      }
    } else {
      if (type == LiberSession.QUERY) userMap.get(user).printQueryTimes();
      userMap.remove(user);
    }

    Runtime r = Runtime.getRuntime();
    r.gc(); // FORCES GARBAGE COLLECTION
    r.runFinalization();
  }
コード例 #27
0
 /**
  * Returns an NL-expression of the given date.
  *
  * @param user User ID
  * @param input QueryDateValue containing restriction on date
  * @return String with nl-expression for date restriction (e.g. 'before 2007'), empty String if
  *     session expired or null if error occurred
  */
 public String getDateExpression(String user, QueryDateValue input) {
   if (!userMap.containsKey(user)) return "";
   try {
     return new SGDateNode(input.getDates()).getQueryNLExpression(input.getComparator());
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
コード例 #28
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;
    }
  }
コード例 #29
0
  /**
   * Retrieves the values already added for this property and anchor
   *
   * @param user User ID
   * @param property Property name
   * @param anchor Unique ID of Anchor
   * @param key browsing session id (null if session type is EDIT)
   * @return String[] with values already added for this property and anchor, first element
   *     --EXPIRED-- if session expired, null if error occurred
   */
  public String[] getAddedValues(
      String user, String property, String anchor, int type, String key) {
    if (!userMap.containsKey(user)) {
      String[] result = new String[1];
      result[0] = "---EXPIRED---";
      return result;
    }

    try {
      LiberSession session = userMap.get(user);
      synchronized (session) {
        session.setLastUpdated();
        return session.getAddedValues(property, anchor, type, key);
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
コード例 #30
0
  /**
   * Initialises a new query session, and returns the class hierarchy. This hierarchy is special
   * because it includes the number of instances of each type.
   *
   * @param user user id
   * @param roots root classes of the hierarchy (null to get complete hierarchy)
   * @return Hierarchy[] containing class hierarchy
   */
  public Hierarchy[] initSessionAndGetClassHierarchy(String user, String[] roots) {
    try {
      if (userMap.containsKey(user)) userMap.get(user).setLastUpdated();
      else userMap.put(user, new LiberSession(ontology, user, null, null, LiberSession.QUERY));

      LiberSession session = userMap.get(user);

      Runtime r = Runtime.getRuntime();
      r.gc(); // FORCES GARBAGE COLLECTION
      r.runFinalization();

      synchronized (session) {
        return session.getCountedClassHierarchy(roots);
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }