class SimpleProvenanceService implements ProvenanceService {

    @Override
    public void updateActivity(Activity newActivity) {
        try (RepositoryConnection conn = repo.getConnection()) {
            if (!conn.contains(newActivity.getResource(), null, null)) {
                throw new IllegalArgumentException("Activity " + newActivity.getResource() + " does not exist");
            }
            conn.begin();
            Model activityModel = RepositoryResults.asModel(conn.getStatements(newActivity.getResource(), null, null),
                    mf);
            conn.remove(activityModel);
            Activity activity = activityFactory.getExisting(newActivity.getResource(), activityModel).orElseThrow(() ->
                    new IllegalStateException("Activity " + newActivity.getResource() + " could not be found"));
            activity.getGenerated_resource().forEach(resource -> conn.remove(resource, null, null));
            activity.getInvalidated_resource().forEach(resource -> conn.remove(resource, null, null));
            activity.getUsed_resource().forEach(resource -> conn.remove(resource, null, null));
            conn.add(newActivity.getModel());
            conn.commit();
        }
    }

}