# HG changeset patch # User Raimund Renkert # Date 1372938340 -7200 # Node ID f0482fa04e2bc776987c28f22802a52608bfa1ac # Parent 90404d19e75dcab0f039d48e025aac69ed9f6264 Code documentation and minor code style. diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/authentication/LdapAuthentication.java --- a/src/main/java/de/intevation/lada/authentication/LdapAuthentication.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/authentication/LdapAuthentication.java Thu Jul 04 13:45:40 2013 +0200 @@ -189,5 +189,4 @@ response.setNetzbetreiber(nb); return response; } - -} +} \ No newline at end of file diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LKommentarMRepository.java --- a/src/main/java/de/intevation/lada/data/LKommentarMRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LKommentarMRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -18,8 +18,7 @@ import de.intevation.lada.rest.Response; /** - * This Container is an interface to request, filter and select LKommentarM - * obejcts from the connected database. + * This Container is an interface to read, write and update LKommentarM objects. * * @author Raimund Renkert */ @@ -34,7 +33,7 @@ private EntityManager em; /** - * Manager class for LPRobe. Used to manipulate data objects. + * The data manager providing database operations. */ @Inject @Named("datamanager") @@ -46,8 +45,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -58,8 +57,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -73,9 +72,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -85,7 +84,12 @@ return new Response(true, 200, item); } - @Override + /** + * Create a new LKommentarM object. + * + * @param object The new object. + * @return Response object. + */ public Response create(Object object) { if (!(object instanceof LKommentarM)) { return new Response(false, 602, object); @@ -115,7 +119,12 @@ return response; } - @Override + /** + * Update a LKommentarM object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LKommentarM)) { return new Response(false, 602, object); @@ -145,7 +154,12 @@ return response; } - @Override + /** + * Delete a LKommentarM object. + * + * @param object The object to delete + * @return Response object. + */ public Response delete(Object object) { if (!(object instanceof LKommentarM)) { return new Response(false, 602, null); diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LKommentarPRepository.java --- a/src/main/java/de/intevation/lada/data/LKommentarPRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LKommentarPRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -18,6 +18,11 @@ import de.intevation.lada.model.LKommentarP; import de.intevation.lada.rest.Response; +/** + * This Container is an interface to read, write and update LKommentarP objects. + * + * @author Raimund Renkert + */ @ApplicationScoped @Named("lkommentarRepository") public class LKommentarPRepository implements Repository @@ -28,10 +33,16 @@ @Inject private EntityManager em; + /** + * The data manager providing database operations. + */ @Inject @Named("datamanager") private Manager manager; + /** + * The logger for this class. + */ @Inject private Logger logger; @@ -42,8 +53,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -54,34 +65,39 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } + * @param clazz The object type. + * @return Response object. + */ + public Response findAll(Class clazz) { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaQuery criteria = builder.createQuery(clazz); + Root member = criteria.from(clazz); + criteria.select(member); + List result = em.createQuery(criteria).getResultList(); + return new Response(true, 200, result); + } - /** - * Find a single object identified by its id. - * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } + /** + * Find a single object identified by its id. + * + * @param clazz The object type. + * @param id The object id. + * @return Response object. + */ + public Response findById(Class clazz, String id) { + T item = em.find(clazz, id); + if (item == null) { + return new Response(false, 600, null); + } + return new Response(true, 200, item); + } - + /** + * Create a new LKommentarP object. + * + * @param object The new object. + * @return Response object. + */ public Response create(Object object) { if (!(object instanceof LKommentarP)) { return new Response(false, 602, object); @@ -111,6 +127,12 @@ return response; } + /** + * Update a LKommentarP object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LKommentarP)) { return new Response(false, 602, object); @@ -140,6 +162,12 @@ return response; } + /** + * Delete a LKommentarP object. + * + * @param object The object to delete. + * @return Response object. + */ public Response delete(Object object) { if (!(object instanceof LKommentarP)) { return new Response(false, 602, null); diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LMessungRepository.java --- a/src/main/java/de/intevation/lada/data/LMessungRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LMessungRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -21,8 +21,7 @@ import de.intevation.lada.validation.Validator; /** - * This Container is an interface to request, filter and select LMessung - * obejcts from the connected database. + * This Container is an interface to read, write and update LMessung obejcts. * * @author Raimund Renkert */ @@ -37,12 +36,15 @@ private EntityManager em; /** - * Manager class for LPRobe. Used to manipulate data objects. + * The data manager providing database operations. */ @Inject @Named("datamanager") private Manager manager; + /** + * The validator used for LMessung objects. + */ @Inject @Named("lmessungvalidator") private Validator validator; @@ -54,8 +56,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response opbject. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -66,8 +68,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -81,9 +83,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -94,10 +96,10 @@ } /** - * Validate and persist a new LProbe object. + * Validate and persist a new LMessung object. * - * @param probe The new LProbe object - * @return Response. + * @param probe The new object + * @return Response object. */ public Response create(Object object) { if (!(object instanceof LMessung)) { @@ -105,7 +107,6 @@ } LMessung messung = (LMessung)object; Response response = new Response(true, 200, messung); - // Try to save the new LMessung. try { Map warnings = validator.validate(messung); manager.create(messung); @@ -137,6 +138,12 @@ return response; } + /** + * Update a LMessung object. + * + * @param object The object to update + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LMessung)) { return new Response(false, 602, object); @@ -175,9 +182,12 @@ return response; } - @Override + /** + * This class does not support this operation. + * + * @param object + */ public Response delete(Object object) { - // TODO Auto-generated method stub return null; } } diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LMesswertRepository.java --- a/src/main/java/de/intevation/lada/data/LMesswertRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LMesswertRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -18,8 +18,7 @@ import de.intevation.lada.rest.Response; /** - * This Container is an interface to request, filter and select LMesswert - * obejcts from the connected database. + * This Container is an interface to read, write and update LMesswert obejcts. * * @author Raimund Renkert */ @@ -34,7 +33,7 @@ private EntityManager em; /** - * Manager class for LPRobe. Used to manipulate data objects. + * The data manager providing database operations. */ @Inject @Named("datamanager") @@ -46,8 +45,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -58,8 +57,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -73,9 +72,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -85,13 +84,18 @@ return new Response(true, 200, item); } + /** + * Create a new LMesswert object. + * + * @param object The new object. + * @return Response object. + */ public Response create(Object object) { if (!(object instanceof LMesswert)) { return new Response(false, 602, object); } LMesswert messwert = (LMesswert)object; Response response = new Response(true, 200, messwert); - // Try to save the new LProbe. try { manager.create(messwert); return response; @@ -115,13 +119,18 @@ return response; } + /** + * Update a LMesswert object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LMesswert)) { return new Response(false, 602, object); } LMesswert messwert = (LMesswert)object; Response response = new Response(true, 200, messwert); - // Try to save the new LProbe. try { manager.update(messwert); return response; @@ -145,8 +154,12 @@ return response; } + /** + * This class does not support this operation. + * + * @param object. + */ public Response delete(Object object) { - // TODO Auto-generated method stub return null; } } \ No newline at end of file diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LOrtRepository.java --- a/src/main/java/de/intevation/lada/data/LOrtRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LOrtRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -20,6 +20,11 @@ import de.intevation.lada.validation.ValidationException; import de.intevation.lada.validation.Validator; +/** + * This Container is an interface to read, write and update LOrt objects. + * + * @author Raimund Renkert + */ @ApplicationScoped @Named("lortrepository") public class LOrtRepository implements Repository @@ -30,10 +35,16 @@ @Inject private EntityManager em; + /** + * The validator used for LOrt objects. + */ @Inject @Named("lortvalidator") private Validator validator; + /** + * The data manager providing database operations. + */ @Inject @Named("datamanager") private Manager manager; @@ -46,8 +57,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -57,8 +68,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -72,9 +83,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -85,10 +96,10 @@ } /** - * Validate and persist a new LProbe object. + * Validate and persist a new LOrt object. * - * @param probe The new LProbe object - * @return Response. + * @param object The new object + * @return Response object. */ public Response create(Object object) { if (!(object instanceof LOrt)) { @@ -128,6 +139,12 @@ return response; } + /** + * Validate and update a LOrt object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LOrt)) { return new Response(false, 600, object); @@ -166,7 +183,12 @@ return response; } - @Override + /** + * Delete a LOrt object. + * + * @param object The object to delete. + * @return Response object. + */ public Response delete(Object object) { if (!(object instanceof LOrt)) { return new Response(false, 602, null); diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LProbeRepository.java --- a/src/main/java/de/intevation/lada/data/LProbeRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LProbeRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -20,8 +20,7 @@ import de.intevation.lada.validation.Validator; /** - * This Container is an interface to request, filter and select LProbe - * obejcts from the connected database. + * This Container is an interface to read, write and update LProbe objects. * * @author Raimund Renkert */ @@ -35,12 +34,15 @@ private EntityManager em; /** - * Manager class for LPRobe. Used to manipulate data objects. + * The data manager providing database operations. */ @Inject @Named("datamanager") private Manager manager; + /** + * The validator used for LProbe objects. + */ @Inject @Named("lprobevalidator") private Validator validator; @@ -48,17 +50,24 @@ public EntityManager getEntityManager() { return this.em; } + /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); return new Response(true, 200, result); } + /** + * Get all objects. + * + * @param clazz The object type. (unused) + * @return Response object. + */ public Response findAll(Class clazz) { QueryBuilder builder = new QueryBuilder(this.getEntityManager(), LProbeInfo.class); @@ -66,6 +75,13 @@ return filter(builder.getQuery()); } + /** + * Find object identified by its id. + * + * @param clazz The object type.(unused) + * @param id The object id. + * @return Response object. + */ public Response findById(Class clazz, String id) { QueryBuilder builder = new QueryBuilder(this.getEntityManager(), LProbeInfo.class); @@ -118,13 +134,18 @@ return response; } + /** + * Validate and update a LProbe object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LProbe)) { return new Response(false, 602, object); } LProbe probe = (LProbe)object; Response response = new Response(true, 200, probe); - // Try to save the new LProbe. try { Map warnings = validator.validate(probe); manager.update(probe); @@ -156,7 +177,11 @@ return response; } - @Override + /** + * This class does not support this operation. + * + * @param object + */ public Response delete(Object object) { return null; } diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LStatusRepository.java --- a/src/main/java/de/intevation/lada/data/LStatusRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LStatusRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -18,8 +18,8 @@ import de.intevation.lada.rest.Response; /** - * This Container is an interface to request, filter and select LMesswert - * obejcts from the connected database. + * This Container is an interface to read, write and update LStatus + * objects from the connected database. * * @author Raimund Renkert */ @@ -34,7 +34,7 @@ private EntityManager em; /** - * Manager class for LPRobe. Used to manipulate data objects. + * The data manager providing database operations. */ @Inject @Named("datamanager") @@ -47,8 +47,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -59,8 +59,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -74,9 +74,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -86,13 +86,18 @@ return new Response(true, 200, item); } + /** + * Create a new LStatus object. + * + * @param object The new object. + * @return Response object. + */ public Response create(Object object) { if (!(object instanceof LStatus)) { return new Response(false, 602, object); } LStatus status = (LStatus)object; Response response = new Response(true, 200, status); - // Try to save the new LProbe. try { manager.create(status); return response; @@ -116,6 +121,12 @@ return response; } + /** + * Update a Lstatus object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LStatus)) { return new Response(false, 602, object); @@ -145,6 +156,11 @@ return response; } + /** + * This class does not support this operation. + * + * @param object + */ public Response delete(Object object) { return null; } diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/LZusatzwertRepository.java --- a/src/main/java/de/intevation/lada/data/LZusatzwertRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LZusatzwertRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -19,8 +19,8 @@ import de.intevation.lada.rest.Response; /** - * This Container is an interface to request, filter and select LZusatzWert - * obejcts from the connected database. + * This Container is an interface to read, write and update LZusatzWert + * objects from the connected database. * * @author Raimund Renkert */ @@ -35,7 +35,7 @@ private EntityManager em; /** - * Manager class for LPRobe. Used to manipulate data objects. + * The data manager providing database operations. */ @Inject @Named("datamanager") @@ -44,11 +44,12 @@ public EntityManager getEntityManager() { return this.em; } + /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -59,8 +60,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -74,9 +75,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -86,6 +87,12 @@ return new Response(true, 200, item); } + /** + * Create a new LZusatzwert object. + * + * @param object The new object. + * @return Response object. + */ public Response create(Object object) { if (!(object instanceof LZusatzWert)) { return new Response(false, 602, object); @@ -121,6 +128,12 @@ return response; } + /** + * Update a LZusatzwert object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof LZusatzWert)) { return new Response(false, 602, object); @@ -154,6 +167,12 @@ return response; } + /** + * Delete a LZusatzwert object. + * + * @param object The object to delete. + * @return Response object. + */ public Response delete(Object object) { if (!(object instanceof LZusatzWert)) { return new Response(false, 602, null); diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/OrtRepository.java --- a/src/main/java/de/intevation/lada/data/OrtRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/OrtRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -17,6 +17,11 @@ import de.intevation.lada.model.Ort; import de.intevation.lada.rest.Response; +/** + * Repository that allows read, write and update operations on 'Ort' objects. + * + * @author Raimund Renkert + */ @ApplicationScoped @Named("ortrepository") public class OrtRepository implements Repository @@ -27,6 +32,9 @@ @Inject private EntityManager em; + /** + * THe data manager providing database operations. + */ @Inject @Named("datamanager") private Manager manager; @@ -38,8 +46,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The query filter. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -50,8 +58,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -65,9 +73,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -77,6 +85,12 @@ return new Response(true, 200, item); } + /** + * Create a new 'Ort' object. + * + * @param object The new object. + * @return Response object. + */ public Response create(Object object) { if (!(object instanceof Ort)) { return new Response(false, 602, object); @@ -97,6 +111,12 @@ } } + /** + * Update a 'Ort' object. + * + * @param object The object to update. + * @return Response object. + */ public Response update(Object object) { if (!(object instanceof Ort)) { return new Response(false, 602, object); @@ -126,6 +146,12 @@ return response; } + /** + * Delete a 'Ort' object. + * + * @param object The object to delete. + * @return Response object. + */ public Response delete(Object object) { if (!(object instanceof Ort)) { return new Response(false, 602, null); diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/QueryBuilder.java --- a/src/main/java/de/intevation/lada/data/QueryBuilder.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/QueryBuilder.java Thu Jul 04 13:45:40 2013 +0200 @@ -8,6 +8,9 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; +/** + * @author Raimund Renkert + */ public class QueryBuilder { private EntityManager manager; @@ -17,6 +20,12 @@ private Class clazz; private Predicate filter; + /** + * Create a new QueryBuilder for the specified class. + * + * @param manager + * @param clazz + */ public QueryBuilder(EntityManager manager, Class clazz) { this.manager = manager; this.clazz = clazz; @@ -25,11 +34,23 @@ this.root = this.query.from(this.clazz); } + /** + * Get the criteria query build with this class. + * + * @return The query. + */ public CriteriaQuery getQuery() { this.query.where(this.filter); return this.query; } + /** + * Logical AND operation. + * + * @param id The database column name. + * @param value The filter value + * @return The builder itself. + */ public QueryBuilder and(String id, String value) { Predicate p = this.builder.equal(this.root.get(id), value); if (this.filter != null) { @@ -41,6 +62,13 @@ return this; } + /** + * Logical OR operation. + * + * @param id The database column name + * @param value The filter value. + * @return The builder itself. + */ public QueryBuilder or(String id, String value) { Predicate p = this.builder.equal(this.root.get(id), value); if (this.filter != null) { @@ -52,6 +80,14 @@ return this; } + /** + * Logical AND operation. + * All elements in values will be concatenated with AND operator. + * + * @param id The database column name. + * @param values List of values. + * @return The builder itself. + */ public QueryBuilder and(String id, List values) { for(String v: values) { this.and(id, v); @@ -59,6 +95,14 @@ return this; } + /** + * Logical OR operation. + * All elements in values will be concatenated with OR operator. + * + * @param id The database column name. + * @param values List of values. + * @return The builder itself. + */ public QueryBuilder or(String id, List values) { for (String v: values) { this.or(id, v); @@ -66,6 +110,14 @@ return this; } + /** + * Logical AND operation. + * The actually defined query will be concatenated with the query defined + * in the builder b. + * + * @param b A builder. + * @return The builder itself. + */ public QueryBuilder and(QueryBuilder b) { if (b == null || b.filter == null) { return this; @@ -79,6 +131,14 @@ return this; } + /** + * Logical OR operation. + * The actually defined query will be concatenated with the query defined + * in the builder b. + * + * @param b A builder. + * @return The builder itself. + */ public QueryBuilder or(QueryBuilder b) { if (b == null || b.filter == null) { return this; @@ -92,10 +152,19 @@ return this; } + /** + * Use 'distinct' in the query. + */ public void distinct() { this.query.distinct(true); } + /** + * Order result by the specified column name + * + * @param id The column name. + * @param asc Ascending(true), Descending(false). + */ public void orderBy(String id, boolean asc) { if (asc) { this.query.orderBy(this.builder.asc(this.root.get(id))); @@ -105,10 +174,15 @@ } } + /** + * Get an empty instance of this builder to create subfilters. + * + * @return An empty instance of this builder. + */ public QueryBuilder getEmptyBuilder(){ QueryBuilder copy = new QueryBuilder(manager, clazz); copy.builder = this.builder; copy.root = this.root; return copy; } -} +} \ No newline at end of file diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/data/ReadOnlyRepository.java --- a/src/main/java/de/intevation/lada/data/ReadOnlyRepository.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/ReadOnlyRepository.java Thu Jul 04 13:45:40 2013 +0200 @@ -12,6 +12,11 @@ import de.intevation.lada.rest.Response; +/** + * Repository that allows read only access to model objects. + * + * @author Raimund Renkert + */ @ApplicationScoped @Named("readonlyrepository") public class ReadOnlyRepository implements Repository @@ -29,8 +34,8 @@ /** * Filter object list by the given criteria. * - * @param criteria - * @return List of objects. + * @param criteria The filter query. + * @return Response object. */ public Response filter(CriteriaQuery filter) { List result = em.createQuery(filter).getResultList(); @@ -40,8 +45,8 @@ /** * Get all objects of type clazzfrom database. * - * @param clazz The class type. - * @return List of objects. + * @param clazz The object type. + * @return Response object. */ public Response findAll(Class clazz) { CriteriaBuilder builder = em.getCriteriaBuilder(); @@ -55,9 +60,9 @@ /** * Find a single object identified by its id. * - * @param clazz The class type. - * @param id The object id. - * @return The requested object of type clazz + * @param clazz The object type. + * @param id The object id. + * @return Response object. */ public Response findById(Class clazz, String id) { T item = em.find(clazz, id); @@ -67,15 +72,30 @@ return new Response(true, 200, item); } + /** + * This class does not support this operation. + * + * @param object + */ public Response create(Object object) { return null; } + /** + * This class does not support this operation. + * + * @param object + */ public Response update(Object object) { return null; } + /** + * This class does not support this operation. + * + * @param object + */ public Response delete(Object object) { return null; } -} +} \ No newline at end of file diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/rest/SMessMethodeService.java --- a/src/main/java/de/intevation/lada/rest/SMessMethodeService.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/SMessMethodeService.java Thu Jul 04 13:45:40 2013 +0200 @@ -17,12 +17,17 @@ import de.intevation.lada.data.Repository; import de.intevation.lada.model.SMessMethode; +/** + * This class produces a RESTful service to read SMessMethode objects. + * + * @author Raimund Renkert + */ @Path("/messmethode") @RequestScoped public class SMessMethodeService { /** - * The Repository for SUmwelt. + * The Repository for SMessMethode. */ @Inject @Named("readonlyrepository") @@ -36,7 +41,7 @@ private Authentication authentication; /** - * Request all SStaat objects. + * Request all SMessMethode objects. * * @param headers The HTTP header containing authorization information. * @return Response object. @@ -56,7 +61,7 @@ } /** - * Request a SStaat object via its id. + * Request a SMessMethode object via its id. * * @param id The object id. * @param headers The HTTP header containing authorization information. diff -r 90404d19e75d -r f0482fa04e2b src/main/java/de/intevation/lada/rest/SStaatService.java --- a/src/main/java/de/intevation/lada/rest/SStaatService.java Thu Jul 04 13:43:11 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/SStaatService.java Thu Jul 04 13:45:40 2013 +0200 @@ -27,7 +27,7 @@ public class SStaatService { /** - * The Repository for SUmwelt. + * The Repository for SStaat. */ @Inject @Named("readonlyrepository")