PageRenderTime 30ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/org.itbelts.domain/src/main/java/org/itbelts/dao/mongolab/CommunityDAOImpl.java

https://bitbucket.org/itbelts/itbelts
Java | 49 lines | 23 code | 11 blank | 15 comment | 0 complexity | 3403f83e9f7330fad86dd68e1ceee4fb MD5 | raw file
  1. package org.itbelts.dao.mongolab;
  2. import java.lang.reflect.Type;
  3. import java.net.URL;
  4. import java.util.List;
  5. import org.itbelts.dao.ICommunityDAO;
  6. import org.itbelts.domain.Community;
  7. import com.google.gson.reflect.TypeToken;
  8. /**
  9. * MongoDB implementation for the ICommunityDAO.
  10. * <br><br>
  11. * <u><i>Version History</i></u>
  12. * <pre>
  13. * v2013.10.0 20-okt.-2013 - DKBR813 - initial release
  14. *
  15. * </pre>
  16. *
  17. * @version v2013.10.0 20-okt.-2013
  18. * @author <a href=\"mailto:koenbruyndonckx@gmail.com\"> Koen Bruyndonckx </a>
  19. */
  20. public class CommunityDAOImpl extends AbstractMongoLabDAO implements ICommunityDAO {
  21. private static final String PATH = "collections/communities";
  22. /* (non-Javadoc)
  23. * @see org.itbelts.dao.ISpecialtyDAO#getSpecialties()
  24. */
  25. @Override
  26. public List<Community> getCommunities() {
  27. URL url = buildUrl( PATH );
  28. Type theListType = new TypeToken<List<Community>>(){}.getType();
  29. return readFrom( url, theListType );
  30. }
  31. @Override
  32. public Community getCommunity( String aCommunityId ) {
  33. URL url = buildUrl( PATH, "q={\"_id\":\"" + aCommunityId + "\"}" );
  34. Type theListType = new TypeToken<List<Community>>(){}.getType();
  35. List<Community> theList = readFrom( url, theListType );
  36. return theList.get( 0 );
  37. }
  38. }