Skip to content

Commit

Permalink
Added findSourceNodesFor() and findTargetNodesFor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbwilcox committed Oct 4, 2007
1 parent 3883221 commit ea3f1cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.jumpmind.symmetric.model.DataEventAction;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeSecurity;

Expand All @@ -19,6 +20,10 @@ public interface INodeService {

public List<Node> findNodesToPushTo();

public List<Node> findSourceNodesFor(DataEventAction eventAction);

public List<Node> findTargetNodesFor(DataEventAction eventAction);

public boolean updateNode(Node node);

}
Expand Up @@ -87,22 +87,31 @@ public Node findIdentity() {
return (Node) getFirstEntry(list);
}

@SuppressWarnings("unchecked")
public List<Node> findNodesToPull() {
return findSourceNodesFor(DataEventAction.WAIT_FOR_POLL);
}

public List<Node> findNodesToPushTo() {
return findTargetNodesFor(DataEventAction.PUSH);
}

@SuppressWarnings("unchecked")
public List<Node> findSourceNodesFor(DataEventAction eventAction) {
Node node = findIdentity();
return jdbcTemplate.query(findNodesWhoTargetMeSql, new Object[] {
node.getNodeGroupId(), DataEventAction.WAIT_FOR_POLL.getCode() },
node.getNodeGroupId(), eventAction.getCode() },
new NodeRowMapper());
}

@SuppressWarnings("unchecked")
public List<Node> findNodesToPushTo() {
public List<Node> findTargetNodesFor(DataEventAction eventAction) {
Node node = findIdentity();
return jdbcTemplate.query(findNodesWhoITargetSql, new Object[] {
node.getNodeGroupId(), DataEventAction.PUSH.getCode() },
node.getNodeGroupId(), eventAction.getCode() },
new NodeRowMapper());
}


class NodeRowMapper implements RowMapper {
public Object mapRow(ResultSet rs, int num) throws SQLException {
Node node = new Node();
Expand Down

0 comments on commit ea3f1cf

Please sign in to comment.