@Test public void testAddContacts() throws Exception { Account linkedin = modelFactory.getDAOFactory().createAccount("urn:service:linkedin"); linkedin.setPrefLabel("LinkedIn"); pimoService.create(linkedin); ResourceStore data = createResourceStore( this.getClass().getClassLoader().getResourceAsStream("account/linkedin-persons.ttl"), Syntax.Turtle); Collection<PersonContact> contacts = data.find(PersonContact.class).distinct().results(); updater.update(linkedin.asURI(), "/connections", contacts); PersonGroup accountGroup = resourceStore.find(PersonGroup.class).where(NIE.dataSource).is(linkedin).first(); assertNotNull(accountGroup); List<Agent> members = accountGroup.getAllMembers_as().asList(); assertEquals(2, members.size()); List<URI> uris = new LinkedList<URI>(); for (Thing m : members) uris.add(m.asURI()); Person anna = resourceStore.find(Person.class) .where(PIMO.groundingOccurrence).is(BasicQuery.X) .where(BasicQuery.X, NAO.externalIdentifier).is("9V7WOs5KHr") .first(); assertTrue(uris.contains(anna.asURI())); assertTrue(tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), FOAF.knows, anna)); Person norbert = resourceStore.find(Person.class) .where(PIMO.groundingOccurrence).is(BasicQuery.X) .where(BasicQuery.X, NAO.externalIdentifier).is("RYWVyGcfzR") .first(); assertTrue(uris.contains(norbert.asURI())); assertTrue(tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), FOAF.knows, norbert)); }
@Override public void update(URI accountUri, String path, PersonContact contact) throws AccountIntegrationException { logger.info("Updating "+path+" for "+accountUri+" with 1 contact."); URI accountPathGraph = getGraph(accountUri, path); removeResources(accountUri, path); if (path.contains("@me")) { PersonContact profile = (PersonContact) super.match(contact).castTo(PersonContact.class); profile.setPrefLabel(getProfilePrefLabel(profile, accountUri)); try { profile = profileEnricher.enrich(profile); } catch (DataMiningException e) { logger.error("Profile enrichment (fullname, postal address, etc.) failed for profile "+profile.asResource()+": "+e.getMessage(), e); } resourceStore.createOrUpdate(accountPathGraph, profile); if (!tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile)) { tripleStore.addStatement(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile); } if (!tripleStore.containsStatements(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri)) { tripleStore.addStatement(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri); } } else { throw new RuntimeException("NOT YET IMPLEMENTED!"); } }
ProfileAccountUpdater extends AccountUpdaterBase implements AccountUpdater<PersonContact> { @Override public void update(URI accountUri, String path, PersonContact contact) throws AccountIntegrationException { logger.info("Updating "+path+" for "+accountUri+" with 1 contact."); URI accountPathGraph = getGraph(accountUri, path); removeResources(accountUri, path); if (path.contains("@me")) { PersonContact profile = (PersonContact) super.match(contact).castTo(PersonContact.class); profile.setPrefLabel(getProfilePrefLabel(profile, accountUri)); try { profile = profileEnricher.enrich(profile); } catch (DataMiningException e) { logger.error("Profile enrichment (fullname, postal address, etc.) failed for profile "+profile.asResource()+": "+e.getMessage(), e); } resourceStore.createOrUpdate(accountPathGraph, profile); if (!tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile)) { tripleStore.addStatement(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile); } if (!tripleStore.containsStatements(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri)) { tripleStore.addStatement(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri); } } else { throw new RuntimeException("NOT YET IMPLEMENTED!"); } } }
ProfileAccountUpdater extends AccountUpdaterBase implements AccountUpdater<PersonContact> { @Override public void update(URI accountUri, String path, PersonContact contact) throws AccountIntegrationException { logger.info("Updating "+path+" for "+accountUri+" with 1 contact."); URI accountPathGraph = getGraph(accountUri, path); removeResources(accountUri, path); if (path.contains("@me")) { PersonContact profile = (PersonContact) super.match(contact).castTo(PersonContact.class); profile.setPrefLabel(getProfilePrefLabel(profile, accountUri)); try { profile = profileEnricher.enrich(profile); } catch (DataMiningException e) { logger.error("Profile enrichment (fullname, postal address, etc.) failed for profile "+profile.asResource()+": "+e.getMessage(), e); } resourceStore.createOrUpdate(accountPathGraph, profile); if (!tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile)) { tripleStore.addStatement(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile); } if (!tripleStore.containsStatements(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri)) { tripleStore.addStatement(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri); } } else { throw new RuntimeException("NOT YET IMPLEMENTED!"); } } ProfileAccountUpdater(ResourceStore resourceStore, PimoService pimoService);  ProfileAccountUpdater(ResourceStore resourceStore, PimoService pimoService, ProfileEnricher profileEnricher); }
ProfileAccountUpdater extends AccountUpdaterBase implements AccountUpdater<PersonContact> { @Override public void update(URI accountUri, String path, PersonContact contact) throws AccountIntegrationException { logger.info("Updating "+path+" for "+accountUri+" with 1 contact."); URI accountPathGraph = getGraph(accountUri, path); removeResources(accountUri, path); if (path.contains("@me")) { PersonContact profile = (PersonContact) super.match(contact).castTo(PersonContact.class); profile.setPrefLabel(getProfilePrefLabel(profile, accountUri)); try { profile = profileEnricher.enrich(profile); } catch (DataMiningException e) { logger.error("Profile enrichment (fullname, postal address, etc.) failed for profile "+profile.asResource()+": "+e.getMessage(), e); } resourceStore.createOrUpdate(accountPathGraph, profile); if (!tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile)) { tripleStore.addStatement(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile); } if (!tripleStore.containsStatements(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri)) { tripleStore.addStatement(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri); } } else { throw new RuntimeException("NOT YET IMPLEMENTED!"); } } ProfileAccountUpdater(ResourceStore resourceStore, PimoService pimoService);  ProfileAccountUpdater(ResourceStore resourceStore, PimoService pimoService, ProfileEnricher profileEnricher); @Override void update(URI accountUri, String path, PersonContact contact); @Override void update(URI accountUri, String path, Collection<PersonContact> contacts); }
ProfileAccountUpdater extends AccountUpdaterBase implements AccountUpdater<PersonContact> { @Override public void update(URI accountUri, String path, PersonContact contact) throws AccountIntegrationException { logger.info("Updating "+path+" for "+accountUri+" with 1 contact."); URI accountPathGraph = getGraph(accountUri, path); removeResources(accountUri, path); if (path.contains("@me")) { PersonContact profile = (PersonContact) super.match(contact).castTo(PersonContact.class); profile.setPrefLabel(getProfilePrefLabel(profile, accountUri)); try { profile = profileEnricher.enrich(profile); } catch (DataMiningException e) { logger.error("Profile enrichment (fullname, postal address, etc.) failed for profile "+profile.asResource()+": "+e.getMessage(), e); } resourceStore.createOrUpdate(accountPathGraph, profile); if (!tripleStore.containsStatements(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile)) { tripleStore.addStatement(pimoService.getPimoUri(), pimoService.getUserUri(), PIMO.occurrence, profile); } if (!tripleStore.containsStatements(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri)) { tripleStore.addStatement(accountPathGraph, profile.asResource(), NIE.dataSource, accountUri); } } else { throw new RuntimeException("NOT YET IMPLEMENTED!"); } } ProfileAccountUpdater(ResourceStore resourceStore, PimoService pimoService);  ProfileAccountUpdater(ResourceStore resourceStore, PimoService pimoService, ProfileEnricher profileEnricher); @Override void update(URI accountUri, String path, PersonContact contact); @Override void update(URI accountUri, String path, Collection<PersonContact> contacts);  }