@Test public void testRepeatedUpdate() throws Exception { ResourceStore initialStore = createResourceStore( this.getClass().getClassLoader().getResourceAsStream("account/linkedin-connections-initial.ttl"), Syntax.Turtle); ResourceStore updatedStore = createResourceStore( this.getClass().getClassLoader().getResourceAsStream("account/linkedin-connections-updated.ttl"), Syntax.Turtle); Collection<PersonContact> initialContacts = initialStore.find(PersonContact.class).distinct().results(); Collection<PersonContact> updatedContacts = updatedStore.find(PersonContact.class).distinct().results(); Account linkedin = modelFactory.getDAOFactory().createAccount("urn:service:linkedin"); resourceStore.createOrUpdate(pimoService.getPimoUri(), linkedin); updater.update(linkedin.asURI(), "/connections", initialContacts); PersonContact initialContact = resourceStore.find(PersonContact.class).where(NAO.externalIdentifier).is("7N49Odr3Dk").first(); PersonName initialContactName = resourceStore.get(initialContact.getAllPersonName().next().asURI(), PersonName.class); assertEquals("Charlie", initialContactName.getNameGiven()); tripleStore.addStatement(pimoService.getPimoUri(), initialContact, NAO.hasTag, new URIImpl("urn:sometag")); updater.update(linkedin.asURI(), "/connections", updatedContacts); PersonContact updatedContact = resourceStore.find(PersonContact.class).where(NAO.externalIdentifier).is("7N49Odr3Dk").first(); PersonName updatedContactName = resourceStore.get(updatedContact.getAllPersonName().next().asURI(), PersonName.class); assertEquals(initialContact.asURI(), updatedContact.asURI()); assertEquals("Carmelo", updatedContactName.getNameGiven()); assertTrue(tripleStore.containsStatements(pimoService.getPimoUri(), updatedContact, NAO.hasTag, new URIImpl("urn:sometag"))); }
@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);  }