Skip to content

Commit

Permalink
Update database client according latest database changes. Issue #14
Browse files Browse the repository at this point in the history
  • Loading branch information
bassstorm committed Nov 11, 2013
1 parent 99cf717 commit 828b6e6
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/main/java/org/gravidence/gravifon/db/ScrobblesDBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ public class ScrobblesDBClient extends BasicDBClient<ScrobbleDocument> implement
* JAX-RS client target associated with <code>main/all_scrobbles</code> view.
*/
private WebTarget viewMainAllScrobblesTarget;

/**
* JAX-RS client target associated with <code>main/all_user_scrobbles</code> view.
*/
private WebTarget viewMainAllUserScrobblesTarget;

/**
* JAX-RS client target associated with <code>main/all_track_scrobbles_amount</code> view.
*/
private WebTarget viewMainAllTrackScrobblesAmountTarget;

/**
* JAX-RS client target associated with <code>main/all_track_scrobbles_duration</code> view.
*/
private WebTarget viewMainAllTrackScrobblesDurationTarget;

@Override
public void afterPropertiesSet() throws Exception {
Expand All @@ -58,6 +73,12 @@ public void afterPropertiesSet() throws Exception {

viewMainAllScrobblesTarget = ViewUtils.getViewTarget(
getDbTarget(), "main", "all_scrobbles");
viewMainAllUserScrobblesTarget = ViewUtils.getViewTarget(
getDbTarget(), "main", "all_user_scrobbles");
viewMainAllTrackScrobblesAmountTarget = ViewUtils.getViewTarget(
getDbTarget(), "main", "all_track_scrobbles_amount");
viewMainAllTrackScrobblesDurationTarget = ViewUtils.getViewTarget(
getDbTarget(), "main", "all_track_scrobbles_duration");
}

/**
Expand Down Expand Up @@ -95,7 +116,7 @@ public List<ScrobbleDocument> retrieveScrobblesByKey(String userId, DateTime scr
key.add(userId);
key.add(SharedInstanceHolder.OBJECT_MAPPER.valueToTree(DateTimeUtils.dateTimeToArray(scrobbleStartDatetime)));

return retrieveByKey(viewMainAllScrobblesTarget, key, ScrobbleDocument.class);
return retrieveByKey(viewMainAllUserScrobblesTarget, key, ScrobbleDocument.class);
}

/**
Expand Down Expand Up @@ -150,7 +171,7 @@ else if (end != null) {
subKeyEnd = null;
}

return retrievePage(viewMainAllScrobblesTarget, key, subKeyStart, subKeyEnd, ascending, limit,
return retrievePage(viewMainAllUserScrobblesTarget, key, subKeyStart, subKeyEnd, ascending, limit,
ScrobbleDocument.class);
}

Expand Down

0 comments on commit 828b6e6

Please sign in to comment.