@Test public void testUpdateMatches() throws Exception { final String updateGroupA = "updateGroupA"; final CanvasMatches insertMatches = new CanvasMatches(updateGroupA, "tile.p", "section.b", "tile.q", new Matches(new double[][]{{1}, {4},}, new double[][]{{11}, {14}}, new double[]{7})); final List<CanvasMatches> insertList = new ArrayList<>(); insertList.add(insertMatches); dao.saveMatches(collectionId, insertList); final CanvasMatches updateMatches = new CanvasMatches(insertMatches.getpGroupId(), insertMatches.getpId(), insertMatches.getqGroupId(), insertMatches.getqId(), new Matches(new double[][]{{2}, {5},}, new double[][]{{12}, {15}}, new double[]{8})); final List<CanvasMatches> updateList = new ArrayList<>(); updateList.add(updateMatches); dao.saveMatches(collectionId, updateList); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(1024); dao.writeMatchesOutsideGroup(collectionId, null, updateGroupA, false, outputStream); final List<CanvasMatches> retrievedList = getListFromStream(outputStream); Assert.assertEquals("invalid number of matches returned, matches=" + retrievedList, 1, retrievedList.size()); for (final CanvasMatches canvasMatches : retrievedList) { final Matches matches = canvasMatches.getMatches(); final double[] ws = matches.getWs(); Assert.assertEquals("weight not updated", 8.0, ws[0], 0.01); } }
private int updateMatches(final List<MongoCursor<Document>> cursorList, final List<CanvasMatches> matchesList, final int index) { CanvasMatches canvasMatches = null; final MongoCursor<Document> cursor = cursorList.get(index); if (cursor.hasNext()) { canvasMatches = CanvasMatches.fromJson(cursor.next().toJson()); } matchesList.set(index, canvasMatches); return (canvasMatches == null ? 1 : 0); }
MatchDao { private int updateMatches(final List<MongoCursor<Document>> cursorList, final List<CanvasMatches> matchesList, final int index) { CanvasMatches canvasMatches = null; final MongoCursor<Document> cursor = cursorList.get(index); if (cursor.hasNext()) { canvasMatches = CanvasMatches.fromJson(cursor.next().toJson()); } matchesList.set(index, canvasMatches); return (canvasMatches == null ? 1 : 0); } }
MatchDao { private int updateMatches(final List<MongoCursor<Document>> cursorList, final List<CanvasMatches> matchesList, final int index) { CanvasMatches canvasMatches = null; final MongoCursor<Document> cursor = cursorList.get(index); if (cursor.hasNext()) { canvasMatches = CanvasMatches.fromJson(cursor.next().toJson()); } matchesList.set(index, canvasMatches); return (canvasMatches == null ? 1 : 0); } MatchDao(final MongoClient client); }
MatchDao { private int updateMatches(final List<MongoCursor<Document>> cursorList, final List<CanvasMatches> matchesList, final int index) { CanvasMatches canvasMatches = null; final MongoCursor<Document> cursor = cursorList.get(index); if (cursor.hasNext()) { canvasMatches = CanvasMatches.fromJson(cursor.next().toJson()); } matchesList.set(index, canvasMatches); return (canvasMatches == null ? 1 : 0); } MatchDao(final MongoClient client); static MatchDao build(); List<MatchCollectionMetaData> getMatchCollectionMetaData(); List<String> getDistinctPGroupIds(final MatchCollectionId collectionId); List<String> getDistinctQGroupIds(final MatchCollectionId collectionId); List<String> getDistinctGroupIds(final MatchCollectionId collectionId); List<String> getMultiConsensusPGroupIds(final MatchCollectionId collectionId); Set<String> getMultiConsensusGroupIds(final MatchCollectionId collectionId); void writeMatchesWithPGroup(final MatchCollectionId collectionId,
                                       final List<MatchCollectionId> mergeCollectionIdList,
                                       final String pGroupId,
                                       final boolean excludeMatchDetails,
                                       final OutputStream outputStream); void writeMatchesWithinGroup(final MatchCollectionId collectionId,
                                        final List<MatchCollectionId> mergeCollectionIdList,
                                        final String groupId,
                                        final boolean excludeMatchDetails,
                                        final OutputStream outputStream); void writeMatchesOutsideGroup(final MatchCollectionId collectionId,
                                         final List<MatchCollectionId> mergeCollectionIdList,
                                         final String groupId,
                                         final boolean excludeMatchDetails,
                                         final OutputStream outputStream); List<CanvasMatches> getMatchesWithinGroup(final MatchCollectionId collectionId,
                                                     final String groupId,
                                                     final boolean excludeMatchDetails); List<CanvasMatches> getMatchesOutsideGroup(final MatchCollectionId collectionId,
                                                      final String groupId,
                                                      final boolean excludeMatchDetails); List<CanvasMatches> getMatchesBetweenGroups(final MatchCollectionId collectionId,
                                                       final String pGroupId,
                                                       final String qGroupId,
                                                       final boolean excludeMatchDetails); void writeMatchesBetweenGroups(final MatchCollectionId collectionId,
                                          final List<MatchCollectionId> mergeCollectionIdList,
                                          final String pGroupId,
                                          final String qGroupId,
                                          final boolean excludeMatchDetails,
                                          final OutputStream outputStream); void writeMatchesBetweenObjectAndGroup(final MatchCollectionId collectionId,
                                                  final List<MatchCollectionId> mergeCollectionIdList,
                                                  final String pGroupId,
                                                  final String pId,
                                                  final String qGroupId,
                                                  final boolean excludeMatchDetails,
                                                  final OutputStream outputStream); CanvasMatches getMatchesBetweenObjects(final MatchCollectionId collectionId,
                                                  final String pGroupId,
                                                  final String pId,
                                                  final String qGroupId,
                                                  final String qId); void writeMatchesBetweenObjects(final MatchCollectionId collectionId,
                                           final List<MatchCollectionId> mergeCollectionIdList,
                                           final String pGroupId,
                                           final String pId,
                                           final String qGroupId,
                                           final String qId,
                                           final OutputStream outputStream); void writeMatchesInvolvingObject(final MatchCollectionId collectionId,
                                            final List<MatchCollectionId> mergeCollectionIdList,
                                            final String groupId,
                                            final String id,
                                            final OutputStream outputStream); void removeMatchesInvolvingObject(final MatchCollectionId collectionId,
                                             final String groupId,
                                             final String id); void removeMatchesBetweenTiles(final MatchCollectionId collectionId,
                                          final String pGroupId,
                                          final String pId,
                                          final String qGroupId,
                                          final String qId); void removeMatchesBetweenGroups(final MatchCollectionId collectionId,
                                           final String pGroupId,
                                           final String qGroupId); void removeMatchesWithPGroup(final MatchCollectionId collectionId,
                                        final String pGroupId); void removeMatchesOutsideGroup(final MatchCollectionId collectionId,
                                          final String groupId); void saveMatches(final MatchCollectionId collectionId,
                            final List<CanvasMatches> matchesList); void removeAllMatches(final MatchCollectionId collectionId); void renameMatchCollection(final MatchCollectionId fromCollectionId,
                                      final MatchCollectionId toCollectionId); MatchTrial getMatchTrial(final String trialId); MatchTrial insertMatchTrial(final MatchTrial matchTrial); void updateMatchCountsForPGroup(final MatchCollectionId collectionId,
                                           final String pGroupId); }
MatchDao { private int updateMatches(final List<MongoCursor<Document>> cursorList, final List<CanvasMatches> matchesList, final int index) { CanvasMatches canvasMatches = null; final MongoCursor<Document> cursor = cursorList.get(index); if (cursor.hasNext()) { canvasMatches = CanvasMatches.fromJson(cursor.next().toJson()); } matchesList.set(index, canvasMatches); return (canvasMatches == null ? 1 : 0); } MatchDao(final MongoClient client); static MatchDao build(); List<MatchCollectionMetaData> getMatchCollectionMetaData(); List<String> getDistinctPGroupIds(final MatchCollectionId collectionId); List<String> getDistinctQGroupIds(final MatchCollectionId collectionId); List<String> getDistinctGroupIds(final MatchCollectionId collectionId); List<String> getMultiConsensusPGroupIds(final MatchCollectionId collectionId); Set<String> getMultiConsensusGroupIds(final MatchCollectionId collectionId); void writeMatchesWithPGroup(final MatchCollectionId collectionId,
                                       final List<MatchCollectionId> mergeCollectionIdList,
                                       final String pGroupId,
                                       final boolean excludeMatchDetails,
                                       final OutputStream outputStream); void writeMatchesWithinGroup(final MatchCollectionId collectionId,
                                        final List<MatchCollectionId> mergeCollectionIdList,
                                        final String groupId,
                                        final boolean excludeMatchDetails,
                                        final OutputStream outputStream); void writeMatchesOutsideGroup(final MatchCollectionId collectionId,
                                         final List<MatchCollectionId> mergeCollectionIdList,
                                         final String groupId,
                                         final boolean excludeMatchDetails,
                                         final OutputStream outputStream); List<CanvasMatches> getMatchesWithinGroup(final MatchCollectionId collectionId,
                                                     final String groupId,
                                                     final boolean excludeMatchDetails); List<CanvasMatches> getMatchesOutsideGroup(final MatchCollectionId collectionId,
                                                      final String groupId,
                                                      final boolean excludeMatchDetails); List<CanvasMatches> getMatchesBetweenGroups(final MatchCollectionId collectionId,
                                                       final String pGroupId,
                                                       final String qGroupId,
                                                       final boolean excludeMatchDetails); void writeMatchesBetweenGroups(final MatchCollectionId collectionId,
                                          final List<MatchCollectionId> mergeCollectionIdList,
                                          final String pGroupId,
                                          final String qGroupId,
                                          final boolean excludeMatchDetails,
                                          final OutputStream outputStream); void writeMatchesBetweenObjectAndGroup(final MatchCollectionId collectionId,
                                                  final List<MatchCollectionId> mergeCollectionIdList,
                                                  final String pGroupId,
                                                  final String pId,
                                                  final String qGroupId,
                                                  final boolean excludeMatchDetails,
                                                  final OutputStream outputStream); CanvasMatches getMatchesBetweenObjects(final MatchCollectionId collectionId,
                                                  final String pGroupId,
                                                  final String pId,
                                                  final String qGroupId,
                                                  final String qId); void writeMatchesBetweenObjects(final MatchCollectionId collectionId,
                                           final List<MatchCollectionId> mergeCollectionIdList,
                                           final String pGroupId,
                                           final String pId,
                                           final String qGroupId,
                                           final String qId,
                                           final OutputStream outputStream); void writeMatchesInvolvingObject(final MatchCollectionId collectionId,
                                            final List<MatchCollectionId> mergeCollectionIdList,
                                            final String groupId,
                                            final String id,
                                            final OutputStream outputStream); void removeMatchesInvolvingObject(final MatchCollectionId collectionId,
                                             final String groupId,
                                             final String id); void removeMatchesBetweenTiles(final MatchCollectionId collectionId,
                                          final String pGroupId,
                                          final String pId,
                                          final String qGroupId,
                                          final String qId); void removeMatchesBetweenGroups(final MatchCollectionId collectionId,
                                           final String pGroupId,
                                           final String qGroupId); void removeMatchesWithPGroup(final MatchCollectionId collectionId,
                                        final String pGroupId); void removeMatchesOutsideGroup(final MatchCollectionId collectionId,
                                          final String groupId); void saveMatches(final MatchCollectionId collectionId,
                            final List<CanvasMatches> matchesList); void removeAllMatches(final MatchCollectionId collectionId); void renameMatchCollection(final MatchCollectionId fromCollectionId,
                                      final MatchCollectionId toCollectionId); MatchTrial getMatchTrial(final String trialId); MatchTrial insertMatchTrial(final MatchTrial matchTrial); void updateMatchCountsForPGroup(final MatchCollectionId collectionId,
                                           final String pGroupId);  }