Exemplo n.º 1
0
  /**
   * getListInformation
   *
   * <p>Retrieves some information about the list of fedora objects.
   *
   * <pre>
   * Version	Date		Developer				Description
   * 0.14		26/07/2012	Genevieve Turner(GT)	Initial
   * </pre>
   *
   * @param fedoraObjects A list of fedora objects to get more information for
   * @return Returns a list of fedora objects
   * @see
   *     au.edu.anu.datacommons.security.service.FedoraObjectService#getListInformation(java.util.List)
   */
  @Override
  public List<Result> getListInformation(List<FedoraObject> fedoraObjects) {
    if (fedoraObjects.size() == 0) {
      return null;
    }
    // Create the sparql query
    SparqlQuery sparqlQuery = new SparqlQuery();
    sparqlQuery.addVar("?id");
    sparqlQuery.addVar("?name");
    sparqlQuery.addTriple("?item", "<dc:identifier>", "?id", Boolean.FALSE);
    sparqlQuery.addTriple("?item", "<dc:title>", "?name", Boolean.FALSE);
    // Ensure that the linked to item is active (i.e. it hasn't been deleted)
    sparqlQuery.addTriple("?item", "<fedora-model:state>", "<fedora-model:Active>", Boolean.FALSE);
    StringBuffer queryFilter = new StringBuffer();
    for (FedoraObject fedoraObject : fedoraObjects) {
      if (queryFilter.length() > 0) {
        queryFilter.append(" || ");
      }
      queryFilter.append("?id = '");
      queryFilter.append(fedoraObject.getObject_id());
      queryFilter.append("' ");
    }
    sparqlQuery.addFilter(queryFilter.toString(), "");

    ClientResponse clientResponse = riSearchService.post("query", sparqlQuery.generateQuery());

    List<Result> resultList = getSparqlResultList(clientResponse);
    return resultList;
  }
Exemplo n.º 2
0
  /**
   * getLinks
   *
   * <p>Retrieves the links for a page.
   *
   * <pre>
   * Version	Date		Developer				Description
   * 0.3		26/04/2012	Genevieve Turner (GT)	Initial
   * 0.7		08/06/2012	Genevieve Turner (GT)	Updated to cater for change to post method in the riSearchService
   * 0.17		28/08/2012	Genevieve Turner (GT)	Added the display of reverse links
   * 0.19		28/09/2012	Genevieve Turner (GT)	Updated so reverse links are not displayed
   * 0.21		22/10/2012	Genevieve Turner (GT)	Made this method public
   * </pre>
   *
   * @param fedoraObject The object to retrieve the links for
   * @return The results of the query
   */
  @Override
  public List<Result> getLinks(FedoraObject fedoraObject) {
    SparqlQuery sparqlQuery = new SparqlQuery();

    sparqlQuery.addVar("?item");
    sparqlQuery.addVar("?title");
    sparqlQuery.addVar("?predicate");
    sparqlQuery.addVar("?type");

    sparqlQuery.addTriple(
        "<info:fedora/" + fedoraObject.getObject_id() + ">", "?predicate", "?item", Boolean.FALSE);
    // GT - 20120928 - Note this code is only commented out as it may be placed back in at a later
    // date.
    /*
    StringBuilder tripleString = new StringBuilder();
    tripleString.append("{ <info:fedora/");
    tripleString.append(fedoraObject.getObject_id());
    tripleString.append("> ?predicate ?item . } ");
    tripleString.append("UNION ");
    tripleString.append("{ ?item ?predicate <info:fedora/");
    tripleString.append(fedoraObject.getObject_id());
    tripleString.append("> } ");

    sparqlQuery.addTripleSet(tripleString.toString());
    */
    // Ensure that the linked to item is active (i.e. it hasn't been deleted)
    sparqlQuery.addTriple("?item", "<dc:title>", "?title", true);
    sparqlQuery.addTriple("?item", "<dc:type>", "?type", true);
    sparqlQuery.addTriple("?item", "<fedora-model:state>", "?state", true);
    String filterString =
        "regex(str(?predicate), '"
            + GlobalProps.getProperty(GlobalProps.PROP_FEDORA_RELATEDURI)
            + "', 'i')";
    sparqlQuery.addFilter(filterString, "");
    sparqlQuery.addFilter("!BOUND(?state) || regex(str(?state), 'Active')", "&&");
    ClientResponse respFromRiSearch = riSearchService.post("query", sparqlQuery.generateQuery());

    List<Result> resultList = getSparqlResultList(respFromRiSearch);
    LOGGER.debug("Number of related items found: {}", resultList.size());
    return resultList;
  }