src/org/ohmage/service/UserCampaignServices.java
public Campaign xGetCampaignInformation(
			final String campaignId,
			final boolean withClasses,
			final boolean withUsers)
			throws ServiceException {
		
		try {
				
			Campaign result = campaignQueries.findCampaignConfiguration(campaignId);

			if(withClasses) {
				try {
					result.addClasses(
							campaignClassQueries.getClassesAssociatedWithCampaign(
									campaignId
								)
						);
				}
				catch(DomainException e) {
					throw new ServiceException(
							"There was a problem adding a class.",
							e);
				}
			}
			
			if(withUsers) {
				//users and their roles in different campaigns
				Map<String, Map<String, Collection<Campaign.Role>>> campaignUserRoles = null;
				
				// get subSelectStatement and parameters to be used in the query 
				Collection<Object> parameters = new LinkedList<Object>();
				String campaignListSubSelect = campaignId;
				
				// Add the users and their roles to the campaign.
				campaignUserRoles = userCampaignQueries.
						getUsersAndRolesForCampaigns(campaignListSubSelect, parameters);
				
				Map<String, Collection<Campaign.Role>> userRoles = campaignUserRoles.get(campaignId);
				if (userRoles != null) {
					result.addUsers(userRoles);
				}	
				
				/*
				// deprecated	--- to be deleted
				List<String> campaignUsernames = userCampaignQueries.getUsersInCampaign(campaignId);
				

				for(String campaignUsername : campaignUsernames) {
					List<Campaign.Role> userRoles = 
						userCampaignQueries.getUserCampaignRoles(
								campaignUsername, 
								campaignId
							);
					
					for(Campaign.Role userRole : userRoles) {
						try {
							result.addUser(campaignUsername, userRole);
						}
						catch(DomainException e) {
							throw new ServiceException(
									"There was a problem adding a user.",
									e);
						}
					}
				}
				*/
			}
			
			return result;
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Retrieves the information about a campaign.
	 * 
	 * @param campaignId The campaign's unqiue identifier.
	 * 
	 * @param withClasses Whether or not to populate the campaign with its list
	 * 					  of classes.
	 * 
	 * @param withUsers Whether or not to populate the campaign with its list 
	 * 					of users and their respective roles.
	 * 
	 * @return The campaign object with the specified information.
	 * 
	 * @throws ServiceException Thrown if there is an error.
	 */
Retrieves the information about a campaign.

@param campaignId The campaign's unqiue identifier.

@param withClasses Whether or not to populate the campaign with its list
of classes.

@param withUsers Whether or not to populate the campaign with its list
of users and their respective roles.

@return The campaign object with the specified information.

@throws ServiceException Thrown if there is an error.
Retrieves the information about a campaign . @param campaignId The campaign ' s unqiue identifier . @param withClasses Whether or not to populate the campaign with its list of classes . @param withUsers Whether or not to populate the campaign with its list of users and their respective roles . @return The campaign object with the specified information . @throws ServiceException Thrown if there is an error .
public Campaign xGetCampaignInformation(
			final String campaignId,
			final boolean withClasses,
			final boolean withUsers)
			throws ServiceException {
		try {
			Campaign result = campaignQueries.findCampaignConfiguration(campaignId);
			if(withClasses) {
				try {
					result.addClasses(
							campaignClassQueries.getClassesAssociatedWithCampaign(
									campaignId
								)
						);
				}
				catch(DomainException e) {
					throw new ServiceException(
							"There was a problem adding a class.",
							e);
				}
			}
			if(withUsers) {
				Map<String, Map<String, Collection<Campaign.Role>>> campaignUserRoles = null;
				Collection<Object> parameters = new LinkedList<Object>();
				String campaignListSubSelect = campaignId;
				campaignUserRoles = userCampaignQueries.
						getUsersAndRolesForCampaigns(campaignListSubSelect, parameters);
				Map<String, Collection<Campaign.Role>> userRoles = campaignUserRoles.get(campaignId);
				if (userRoles != null) {
					result.addUsers(userRoles);
				}	
				/*
				// deprecated	--- to be deleted
				List<String> campaignUsernames = userCampaignQueries.getUsersInCampaign(campaignId);
				for(String campaignUsername : campaignUsernames) {
					List<Campaign.Role> userRoles = 
						userCampaignQueries.getUserCampaignRoles(
								campaignUsername, 
								campaignId
							);
					for(Campaign.Role userRole : userRoles) {
						try {
							result.addUser(campaignUsername, userRole);
						}
						catch(DomainException e) {
							throw new ServiceException(
									"There was a problem adding a user.",
									e);
						}
					}
				}
				*/
			}
			return result;
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public Campaign xGetCampaignInformation ( final String campaignId , final boolean withClasses , final boolean withUsers ) throws ServiceException { try { Campaign result = campaignQueries . findCampaignConfiguration ( campaignId ) ; if ( withClasses ) { try { result . addClasses ( campaignClassQueries . getClassesAssociatedWithCampaign ( campaignId ) ) ; } catch ( DomainException e ) { throw new ServiceException ( "There was a problem adding a class." , e ) ; } } if ( withUsers ) { Map < String , Map < String , Collection < Campaign . Role > > > campaignUserRoles = null ; Collection < Object > parameters = new LinkedList < Object > ( ) ; String campaignListSubSelect = campaignId ; campaignUserRoles = userCampaignQueries . getUsersAndRolesForCampaigns ( campaignListSubSelect , parameters ) ; Map < String , Collection < Campaign . Role > > userRoles = campaignUserRoles . get ( campaignId ) ; if ( userRoles != null ) { result . addUsers ( userRoles ) ; } /*
				// deprecated	--- to be deleted
				List<String> campaignUsernames = userCampaignQueries.getUsersInCampaign(campaignId);
				

				for(String campaignUsername : campaignUsernames) {
					List<Campaign.Role> userRoles = 
						userCampaignQueries.getUserCampaignRoles(
								campaignUsername, 
								campaignId
							);
					
					for(Campaign.Role userRole : userRoles) {
						try {
							result.addUser(campaignUsername, userRole);
						}
						catch(DomainException e) {
							throw new ServiceException(
									"There was a problem adding a user.",
									e);
						}
					}
				}
				*/ } return result ; } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Retrieves the information about a campaign.
Retrieves the information about a campaign .
//users and their roles in different campaigns // get subSelectStatement and parameters to be used in the query  // Add the users and their roles to the campaign.