@Override
	public ArrayList<Map<String,String>> getAuctionsByCategory(String category) {
		ArrayList<Map<String,String>> auctions = new ArrayList<Map<String,String>>();
		TypedQuery<Auction> categoryAuctionsQuery = emgr.createNamedQuery(
				"Auction.findAuctionsByCategory", Auction.class);
		
		
		categoryAuctionsQuery.setParameter("categoryName", category);
		List<Auction> obtainedAuctions = (List<Auction>) categoryAuctionsQuery.getResultList();
		for (int i = 0; i < obtainedAuctions.size(); i++) {
			Map<String, String> tempMap = new HashMap<String,String>();
			
			System.out.println("\n -------------auct ID " + obtainedAuctions.get(i).getAuctionId() + "-------------");
			// Obtain the current date and time
			Calendar currentDateCalendar = Calendar.getInstance();
			System.out.println("CURRENT DATE " + currentDateCalendar.getTime().toString());
			// Obtain the end time and date
			Time endTime = obtainedAuctions.get(i).getEndTime();
			System.out.println("END TIME = " + endTime.toString());
			Calendar endDateCal = new GregorianCalendar();
			endDateCal.setTime(obtainedAuctions.get(i).getEndDate());
			System.out.println("PRE- END DATE " + endDateCal.getTime().toString());
			
			// Assign the time to the end date calendar
			String[] splitEndTime = endTime.toString().split(":");
			
			endDateCal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitEndTime[0]));
			endDateCal.set(Calendar.MINUTE, Integer.parseInt(splitEndTime[1]));
			endDateCal.set(Calendar.SECOND, Integer.parseInt(splitEndTime[2]));
			System.out.println("END DATE " + endDateCal.getTime().toString());
	
			if (currentDateCalendar.after(endDateCal)) {
				System.out.println("EXPIRED!!!!!!!!!!!!!!!!!");
				
				// Set the auction as expired.
				Auction auction = emgr.find(Auction.class, obtainedAuctions.get(i).getAuctionId());
				short expired = 1;
				auction.setAuctionExpired(expired);
				
				emgr.persist(auction);
			} else {
				System.out.println("Not yet expired.");
				
				int daysBetween = Days.daysBetween(new DateTime(currentDateCalendar.getTime()), new DateTime(endDateCal.getTime())).getDays();
				
				// Obtain the time difference and compensate for 1 hour (since the calendar starts at 01:00 and not 00:00)
				Date dateDiff = new Date(endDateCal.getTime().getTime() - currentDateCalendar.getTime().getTime() - 3600000);
				SimpleDateFormat timeFormat = new SimpleDateFormat("H:mm:ss");
				System.out.println("Duration: " + timeFormat.format(dateDiff));
				
				tempMap.put("auctionName", obtainedAuctions.get(i).getAuctionName());
				tempMap.put("auctionDescription", obtainedAuctions.get(i).getAuctionDescription());
				tempMap.put("auctionId", Integer.toString(obtainedAuctions.get(i).getAuctionId()));
				tempMap.put("auctionDaysLeft", Integer.toString(daysBetween));
				tempMap.put("auctionTimeLeft", timeFormat.format(dateDiff));
				
				TypedQuery<Bid> bidQuery = emgr.createNamedQuery("Bid.findBidByAuction", Bid.class);
				bidQuery.setParameter("auctionId", obtainedAuctions.get(i).getAuctionId());
				try {
					Bid obtainedBid = bidQuery.getSingleResult();
					int bidConsequence = obtainedBid.getBidConsequence();
					double currentHighestBid = obtainedBid.getCurrentHighest();
					
					tempMap.put("auctionBidConsequence", Integer.toString(bidConsequence));
					tempMap.put("auctionHighestBid", Double.toString(currentHighestBid));
					
					auctions.add(tempMap);
				} catch(NoResultException e) {
					System.out.println("Catched NoResultException - " + e.getMessage());
					tempMap.put("auctionBidConsequence", "0");
					tempMap.put("auctionHighestBid", obtainedAuctions.get(i).getStartPrice());
					auctions.add(tempMap);
					continue;
				}
			} // End of else (not expired)
		} // End loop for obtainedAuctions
		return auctions;
	}// End of GetAuctionsByCategory