PageRenderTime 71ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/itbelts/itbelts
Java | 55 lines | 29 code | 14 blank | 12 comment | 0 complexity | 5884d98735ffd978b5a62faebc77e592 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.ISpecialtyDAO;
  6. import org.itbelts.domain.Specialty;
  7. import com.google.gson.reflect.TypeToken;
  8. /**
  9. * MongoDB implementation for the ISpecialtyDAO.
  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 SpecialtyDAOImpl extends AbstractMongoLabDAO implements ISpecialtyDAO {
  21. private static final String PATH = "collections/specialties";
  22. @Override
  23. public List<Specialty> getSpecialties() {
  24. URL url = buildUrl( PATH );
  25. Type theListType = new TypeToken<List<Specialty>>(){}.getType();
  26. return readFrom( url, theListType );
  27. }
  28. @Override
  29. public List<Specialty> getSpecialtiesForCommunity( String aCommunityId ) {
  30. URL url = buildUrl( PATH, "q={\"communityId\":\"" + aCommunityId + "\"}" );
  31. Type theListType = new TypeToken<List<Specialty>>(){}.getType();
  32. return readFrom( url, theListType );
  33. }
  34. @Override
  35. public Specialty getSpecialty( String aSpecialtyId ) {
  36. URL url = buildUrl( PATH, "q={\"_id\":\"" + aSpecialtyId + "\"}" );
  37. Type theListType = new TypeToken<List<Specialty>>(){}.getType();
  38. List<Specialty> theList = readFrom( url, theListType );
  39. return theList.get( 0 );
  40. }
  41. }