Package uk.ac.osswatch.simal.model

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


    if (!repo.isInitialised()) {
      repo.setIsTest(true);
      repo.initialise();
    }

    IPerson developer = SimalRepositoryFactory.getPersonService().findBySeeAlso("http://foo.org/~developer/#me");
    testDeveloperID = developer.getSimalID();
    testDeveloperEMail = developer.getEmail().toArray()[0].toString();
    Set<IProject> projects = developer.getProjects();
  testProjectID = ((IProject) projects.toArray()[0])
        .getSimalID();
  }
View Full Code Here


  @Test
  public void testImportProjectContacts() throws SimalRepositoryException {
    Iterator<IPerson> people = SimalRepositoryFactory.getPersonService().getAll().iterator();
    boolean personIsValid = false;
    while (people.hasNext()) {
      IPerson person = people.next();
      Set<String> name = person.getNames();
      if (name.contains("Person A")) {
        personIsValid = true;
       
        Set<IProject> projects = person.getProjects();
        assertEquals("Don't have the right number of projects for Person A",2, projects.size());
        IProject prj = (IProject) projects.toArray()[0];
        assertTrue("Person A is not associated with project foo", prj.getName().equals("Project A") || prj.getName().equals("Project D"));
       
        Set<IInternetAddress> emails = person.getEmail();
        assertTrue("Persons A has an invalid email setting", emails.toString().contains("persona@institutiona.ac.uk"));
       
        break;
      }
    }
View Full Code Here

    assertEquals("username is not correct", username, sessionData
        .getUsername());
   
    IPersonService service = SimalRepositoryFactory.getPersonService();
    IPerson user = service.findByUsername(username);
    user.delete();
  }
View Full Code Here

    Iterator<IProject> projects = getProjects().iterator();
    HashMap<String, IPerson> allPeople = new HashMap<String, IPerson>();
    while (projects.hasNext()) {
      Iterator<IPerson> people = projects.next().getAllPeople().iterator();
      while (people.hasNext()) {
        IPerson person = people.next();
        if (!allPeople.containsKey(person.getURI())) {
          allPeople.put(person.getURI(), person);
        }
      }
    }
    return new HashSet<IPerson>(allPeople.values());
  }
View Full Code Here

    HashSet<String> peopleIDs = new HashSet<String>();
    Iterator<Statement> itr = personList.iterator();
    while (itr.hasNext()) {
      String uri = itr.next().getResource().getURI();
      try {
        IPerson person = SimalRepositoryFactory.getPersonService().findBySeeAlso(uri);
        if (person == null) {
          person = SimalRepositoryFactory.getPersonService().get(uri);
          if (person == null) {
            throw new SimalRepositoryException("No person with the URI " + uri);
          }
        }
        String id = person.getSimalID();
        if (!peopleIDs.contains(id)) {
          people.add(person);
          peopleIDs.add(id);
        }
      } catch (SimalRepositoryException e) {
View Full Code Here

          com.hp.hpl.jena.rdf.model.Resource res = model.createResource(uri);
          s = model.createStatement(r, RDFS.seeAlso, res);
          model.add(s);
        }

        IPerson person = new Person(r);
        person.setSimalID(personID);
        return person;
  }
View Full Code Here

        RDFUtils.FOAF_NS, "mbox_sha1sum");
    for (int i = 0; i < sha1sums.getLength(); i = i + 1) {
      Element sha1sumNode = (Element) sha1sums.item(i);
      if (sha1sumNode.getParentNode().equals(sourcePersonRoot)) {
        String sha1Sum = sha1sumNode.getFirstChild().getNodeValue().trim();
        IPerson person = SimalRepositoryFactory.getPersonService().findBySha1Sum(sha1Sum);
        if (person != null) {
          LOGGER
              .debug("Simal already has a Person record with the foaf:mbox_sha1: "
                  + sha1Sum + " called " + person);
          person = SimalRepositoryFactory.getPersonService().findBySeeAlso(person.getURI());
          simalPersonURI = person.getURI();
        }
      }
    }

    // handle duplicate people identified by their rdf:about
    String uri = sourcePersonRoot.getAttributeNS(RDFUtils.RDF_NS, "about");
    IPerson person = SimalRepositoryFactory.getPersonService().findBySeeAlso(uri);
    if (person != null) {
      LOGGER
          .debug("Simal already has a Person record about "
                  + uri + " called " + person);
      simalPersonURI = person.getURI();
    }

    // handle duplicate people identified by their rdfs:seeAlso
    NodeList seeAlsos = sourcePersonRoot.getElementsByTagNameNS(
        RDFUtils.RDFS_NS, "seeAlso");
    Element seeAlso;
    for (int i = 0; i < seeAlsos.getLength(); i = i + 1) {
      seeAlso = (Element) seeAlsos.item(i);
      if (seeAlso.getParentNode().equals(sourcePersonRoot)) {
        uri = seeAlso.getAttributeNS(RDFUtils.RDF_NS, "resource").trim();
        person = SimalRepositoryFactory.getPersonService().findBySeeAlso(uri);
        if (person != null) {
          LOGGER
              .debug("Simal already has a Person record with the rdfs:seeAlso "
                  + uri + " called " + person);
          simalPersonURI = person.getURI();
        } else {
          seeAlso = simalPersonDoc.createElementNS(RDFUtils.RDFS_NS, "seeAlso");
          seeAlso.setAttributeNS(RDFUtils.RDF_NS, "resource", uri);
          simalPersonElement.appendChild(seeAlso);
        }
View Full Code Here

        String queryStr = "PREFIX xsd: <" + AbstractSimalRepository.XSD_NAMESPACE_URI
            + "> " + "PREFIX rdf: <" + AbstractSimalRepository.RDF_NAMESPACE_URI + ">"
            + "PREFIX simal: <" + AbstractSimalRepository.SIMAL_NAMESPACE_URI + ">"
            + "SELECT DISTINCT ?person WHERE { " + "?person simal:personId \"" + id
            + "\" }";
        IPerson person = findBySPARQL(queryStr);

        return person;
  }
View Full Code Here

      Model model = ((JenaSimalRepository)getRepository()).getModel();
      Query query = QueryFactory.create(queryStr);
      QueryExecution qe = QueryExecutionFactory.create(query, model);
      ResultSet results = qe.execSelect();

      IPerson person = null;
      while (results.hasNext()) {
        QuerySolution soln = results.nextSolution();
        RDFNode node = soln.get("person");
        if (node.isResource()) {
          person = new Person((com.hp.hpl.jena.rdf.model.Resource) node);
View Full Code Here

        + "PREFIX rdfs: <" + AbstractSimalRepository.RDFS_NAMESPACE_URI + "> "
        + "SELECT DISTINCT ?person WHERE { "
        + "?person rdf:type simal:Person . " + "?person rdfs:seeAlso <"
        + seeAlso + ">}";

    IPerson person = findBySPARQL(queryStr);

    return person;
  }
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.