Package uk.ac.osswatch.simal.model

Examples of uk.ac.osswatch.simal.model.IPerson


      throws SimalRepositoryException {
    String queryStr = "PREFIX foaf: <" + RDFUtils.FOAF_NS + "> "
        + "SELECT DISTINCT ?person WHERE { " + "?person foaf:mbox_sha1sum \""
        + sha1sum + "\"}";

    IPerson person = findBySPARQL(queryStr);

    return person;
  }
View Full Code Here


  public IPerson findByUsername(String username) {
    String queryStr = "PREFIX simal: <" + SimalOntology.NS + "> "
    + "SELECT DISTINCT ?person WHERE { " + "?person simal:username \""
    + username + "\"}";

    IPerson person = findBySPARQL(queryStr);
   
    return person;
  }
View Full Code Here

  public String getAllAsJSON() throws SimalRepositoryException {
      StringBuffer json = new StringBuffer("{ \"items\": [");
      Set<IPerson> setOfPeople = getAll();
      Iterator<IPerson> people = setOfPeople.iterator();
      IPerson person;
      while (people.hasNext()) {
        person = people.next();
        json.append(person.toJSONRecord());
        if (people.hasNext()) {
          json.append(",");
        }
      }
      json.append("]}");
View Full Code Here

  public IPerson getOrCreate(String uri) throws SimalRepositoryException {
    if (SimalRepositoryFactory.getInstance().containsResource(uri)) {
      return SimalRepositoryFactory.getPersonService().get(uri);
    } else {
      IPerson person = findBySeeAlso(uri);
      if (person == null) {
        try {
          return SimalRepositoryFactory.getPersonService().create(uri);
        } catch (DuplicateURIException e) {
          LOGGER.error("Threw a DuplicateURIEception when we had already checked for resource existence", e);
View Full Code Here

      Iterator<IProject> projects = person.getProjects().iterator();
      while (projects.hasNext()) {
        IProject project = projects.next();
        Iterator<IPerson> people = project.getAllPeople().iterator();
        while (people.hasNext()) {
          IPerson colleague = people.next();
          String id = colleague.getSimalID();
          if (!id.equals(person.getSimalID()) && !colleagueIDs.contains(id)) {
            colleagues.add(colleague);
            colleagueIDs.add(id);
          }
        }
View Full Code Here

   * @throws SimalAPIException
   */
  public String getPerson(RESTCommand cmd) throws SimalAPIException {
    String id = command.getPersonID();
    String email = command.getPersonEMail();
  IPerson person = null;
   
    try {
      if (id != null) {
          person = SimalRepositoryFactory.getPersonService().findById(
              getRepository().getUniqueSimalID(id));
            if (person == null) {
                throw new SimalAPIException("Person with Simal ID " + id
                   + " does not exist");
              }
      } else if (email != null){
      person = SimalRepositoryFactory.getPersonService().findBySha1Sum(RDFUtils.getSHA1(email));
          if (person == null) {
              throw new SimalAPIException("Person with email " + email
                 + " does not exist");
            }
      } else {
        throw new SimalAPIException("Must provide sufficient parameters to identify a person, see REST API documentation for more details");
      }
    } catch (SimalRepositoryException e) {
      throw new SimalAPIException(
          "Unable to get XML representation of project from the repository",
          e);
    } catch (NoSuchAlgorithmException e) {
        throw new SimalAPIException(
                "Unable to generate an SHA1 hash of email: " + email,
                e);
  }

    if (command.isXML()) {
      try {
      return person.toXML();
      } catch (SimalRepositoryException e) {
        throw new SimalAPIException(
            "Unable to get XML representation of project from the repository",
            e);
      }
    } else if (command.isJSON()) {
      try {
        return person.toJSON();
      } catch (SimalRepositoryException e) {
        throw new SimalAPIException(
            "Unable to get XML representation of project from the repository",
            e);
      }
View Full Code Here

      throws SimalAPIException {
    final String id = cmd.getPersonID();

    String response;
    StringBuffer result = new StringBuffer();
    IPerson person;
    try {
      person = SimalRepositoryFactory.getPersonService().findById(
          getRepository().getUniqueSimalID(id));

      if(person != null) {
View Full Code Here

      result.append("<container>");

      result.append("<people>");
      result.append("<person id=\"" + person.getSimalID() + "\" name=\""
          + person.getGivennames() + "\">");
      IPerson friend;
      while (friends.hasNext()) {
        friend = friends.next();
        result.append("<friend>");
        result.append(friend.getSimalID());
        result.append("</friend>");
      }
      result.append("</person>");

      friends = colleaguesAndFriends.iterator();
      while (friends.hasNext()) {
        friend = friends.next();
        result.append("<person id=\"" + friend.getSimalID() + "\" name=\""
            + friend.getGivennames() + "\">");
        result.append("</person>");
      }
      result.append("</people>");

      result.append("</container>");
View Full Code Here

      sha1sum = RDFUtils.getSHA1(email);
    } catch (NoSuchAlgorithmException e) {
      throw new SimalRepositoryException(
          "Unable to generate SHA1Sum for email address");
    }
    IPerson duplicate = SimalRepositoryFactory.getPersonService().findBySha1Sum(
        sha1sum);
    if (duplicate != null) {
      return duplicate;
    } else {
      return null;
View Full Code Here

      if (people == null || people.size() == 0) {
        logger.info("No projects match the regular expression '" + filter + "'");
      } else {
        Iterator<IPerson> itr = people.iterator();
        while(itr.hasNext()) {
          IPerson person = itr.next();
          dump(person, cl);
          logger.info("\n\n============================================\n============================================\n\n");
        }
      }
    }
View Full Code Here

TOP

Related Classes of uk.ac.osswatch.simal.model.IPerson

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.