class SimpleProvenanceService implements ProvenanceService {

    @Override
    public Optional<Activity> getActivity(Resource activityIRI) {
        try (RepositoryConnection conn = repo.getConnection()) {
            Model activityModel = RepositoryResults.asModel(conn.getStatements(activityIRI, null, null), mf);
            return activityFactory.getExisting(activityIRI, activityModel).flatMap(activity -> {
                addEntitiesToModel(activity.getGenerated_resource(), activityModel, conn);
                addEntitiesToModel(activity.getInvalidated_resource(), activityModel, conn);
                addEntitiesToModel(activity.getUsed_resource(), activityModel, conn);
                return Optional.of(activity);
            });
        }
    }

}