private void initializeSelectorIfNeeded( NodeBasedContext lastContext, GraphDatabaseService database) { if (selector == null) { long lastId = -1; Node lastNode = determineLastNode(lastContext, database); if (lastNode != null) { lastId = lastNode.getId(); } selector = new ContinuousNodeSelector(config.getNodeInclusionPolicy(), lastId); } }
/** {@inheritDoc} */ @Override public NodeBasedContext doSomeWork(NodeBasedContext lastContext, GraphDatabaseService database) { initializeSelectorIfNeeded(lastContext, database); Node node = determineNextNode(database); if (node == null) { LOG.warn( "RecommendationModule did not find a node to continue with. There are no nodes matching the configuration."); return lastContext; } LOG.info("Computing for " + node.getId()); List<Recommendation<Node>> recommendations = config.getEngine().recommend(node, config.getConfig()); persistRecommendations(node, recommendations); return new NodeBasedContext(node); }