src/org/ohmage/request/survey/SurveyResponseFunctionReadRequest.java
private void subdivideSurveyId(
			Map<PrivacyState, Collection<Collection<SurveyResponse>>> privacyStateBucket) {
		
		// For each of the privacy state buckets,
		for(PrivacyState privacyState : privacyStateBucket.keySet()) {
			// Get the current privacy state bucket.
			Collection<Collection<SurveyResponse>> currPrivacyStateBucket =
					privacyStateBucket.get(privacyState);
			
			// Create a new, empty privacy state bucket.
			Collection<Collection<SurveyResponse>> newPrivacyStateBucket =
					new LinkedList<Collection<SurveyResponse>>();
			
			// Subdivide each of the outer buckets by removing their inner 
			// buckets and replacing them with their subdivided counterparts.
			for(Collection<SurveyResponse> currBucket : currPrivacyStateBucket) {
				// Subdivide the inner collections.
				Map<String, Collection<SurveyResponse>> newInnerBuckets =
						new HashMap<String, Collection<SurveyResponse>>();
				
				// For all of the survey responses in this inner bucket, get
				// their survey ID and re-bucket them.
				for(SurveyResponse surveyResponse : currBucket) {
					// Get the date that this record was created.
					String surveyId = surveyResponse.getSurvey().getId();
					
					// Get the other responses on this date.
					Collection<SurveyResponse> currResponses = 
							newInnerBuckets.get(surveyId);
					
					// If no other responses exist for this date, create
					// the list.
					if(currResponses == null) {
						currResponses = new LinkedList<SurveyResponse>();
						newInnerBuckets.put(surveyId, currResponses);
					}
					
					// Add this response to the given date.
					currResponses.add(surveyResponse);
				}
				
				// Add the inner buckets to the collection of outer buckets.
				for(String surveyId : newInnerBuckets.keySet()) {
					newPrivacyStateBucket.add(newInnerBuckets.get(surveyId));
				}
			}
			
			privacyStateBucket.put(privacyState, newPrivacyStateBucket);
		}
	}
/**
	 * Subdivides the privacy state buckets into those survey responses whose
	 * corresponding survey has the same ID.
	 * 
	 * @param privacyStateBucket The map of privacy state to buckets of
	 * 							 collections of survey responses.
	 */
Subdivides the privacy state buckets into those survey responses whose
corresponding survey has the same ID.

@param privacyStateBucket The map of privacy state to buckets of
collections of survey responses.
Subdivides the privacy state buckets into those survey responses whose corresponding survey has the same ID . @param privacyStateBucket The map of privacy state to buckets of collections of survey responses .
private void subdivideSurveyId(
			Map<PrivacyState, Collection<Collection<SurveyResponse>>> privacyStateBucket) {
		for(PrivacyState privacyState : privacyStateBucket.keySet()) {
			Collection<Collection<SurveyResponse>> currPrivacyStateBucket =
					privacyStateBucket.get(privacyState);
			Collection<Collection<SurveyResponse>> newPrivacyStateBucket =
					new LinkedList<Collection<SurveyResponse>>();
			for(Collection<SurveyResponse> currBucket : currPrivacyStateBucket) {
				Map<String, Collection<SurveyResponse>> newInnerBuckets =
						new HashMap<String, Collection<SurveyResponse>>();
				for(SurveyResponse surveyResponse : currBucket) {
					String surveyId = surveyResponse.getSurvey().getId();
					Collection<SurveyResponse> currResponses = 
							newInnerBuckets.get(surveyId);
					if(currResponses == null) {
						currResponses = new LinkedList<SurveyResponse>();
						newInnerBuckets.put(surveyId, currResponses);
					}
					currResponses.add(surveyResponse);
				}
				for(String surveyId : newInnerBuckets.keySet()) {
					newPrivacyStateBucket.add(newInnerBuckets.get(surveyId));
				}
			}
			privacyStateBucket.put(privacyState, newPrivacyStateBucket);
		}
	}
private void subdivideSurveyId ( Map < PrivacyState , Collection < Collection < SurveyResponse > > > privacyStateBucket ) { for ( PrivacyState privacyState : privacyStateBucket . keySet ( ) ) { Collection < Collection < SurveyResponse > > currPrivacyStateBucket = privacyStateBucket . get ( privacyState ) ; Collection < Collection < SurveyResponse > > newPrivacyStateBucket = new LinkedList < Collection < SurveyResponse > > ( ) ; for ( Collection < SurveyResponse > currBucket : currPrivacyStateBucket ) { Map < String , Collection < SurveyResponse > > newInnerBuckets = new HashMap < String , Collection < SurveyResponse > > ( ) ; for ( SurveyResponse surveyResponse : currBucket ) { String surveyId = surveyResponse . getSurvey ( ) . getId ( ) ; Collection < SurveyResponse > currResponses = newInnerBuckets . get ( surveyId ) ; if ( currResponses == null ) { currResponses = new LinkedList < SurveyResponse > ( ) ; newInnerBuckets . put ( surveyId , currResponses ) ; } currResponses . add ( surveyResponse ) ; } for ( String surveyId : newInnerBuckets . keySet ( ) ) { newPrivacyStateBucket . add ( newInnerBuckets . get ( surveyId ) ) ; } } privacyStateBucket . put ( privacyState , newPrivacyStateBucket ) ; } }
Subdivides the privacy state buckets into those survey responses whose
 corresponding survey has the same ID.
Subdivides the privacy state buckets into those survey responses whose corresponding survey has the same ID .
// For each of the privacy state buckets, // Get the current privacy state bucket. // Create a new, empty privacy state bucket. // Subdivide each of the outer buckets by removing their inner  // buckets and replacing them with their subdivided counterparts. // Subdivide the inner collections. // For all of the survey responses in this inner bucket, get // their survey ID and re-bucket them. // Get the date that this record was created. // Get the other responses on this date. // If no other responses exist for this date, create // the list. // Add this response to the given date. // Add the inner buckets to the collection of outer buckets.