public int exportNetwork(Network network) { if (network.getNetworkType() == Network.NetworkType.TECHNICAL) return exportTechnicalNetwork(network); else if (network.getNetworkType() == Network.NetworkType.TECHNICAL) return exportSocialNetwork(network); return -1; }
private int exportSocialNetwork(Network network) { int nid = insertSocialNetwork(network); network.setNid(nid); for (Edge edge : network.getEdges()) { edge.setNid(nid); insertSocialEdge(edge); } return nid; }
private int insertSocialNetwork(Network network) { String query = "INSERT INTO s_networks (iid, nid, t_nid) VALUES (?, default, ?)"; ISetter[] params = { new IntSetter(1, Resources.intervalID), new IntSetter(2, network.getT_nid()) }; PreparedStatementExecutionItem ei = new PreparedStatementExecutionItem(query, params); addExecutionItem(ei); ei.waitUntilExecuted(); return getSequenceValue("snetwork_id_seq"); }
private int insertTechnicalNetwork(Network network) { String query = "INSERT INTO t_networks (iid, nid, commit_date) VALUES (?, default, ?)"; ISetter[] params = { new IntSetter(1, Resources.intervalID), new TimestampSetter(2, network.getCommit_date()) }; PreparedStatementExecutionItem ei = new PreparedStatementExecutionItem(query, params); addExecutionItem(ei); ei.waitUntilExecuted(); return getSequenceValue("tnetwork_id_seq"); }