001    package com.khubla.pragmatach.plugin.adminapp;
002    
003    import java.util.List;
004    
005    import com.khubla.pragmatach.framework.annotation.Controller;
006    import com.khubla.pragmatach.framework.annotation.Route;
007    import com.khubla.pragmatach.framework.annotation.View;
008    import com.khubla.pragmatach.framework.api.PragmatachException;
009    import com.khubla.pragmatach.framework.api.Response;
010    import com.khubla.pragmatach.framework.router.PragmatachRoute;
011    import com.khubla.pragmatach.framework.router.PragmatachRoutes;
012    
013    /**
014     * @author tome
015     */
016    @Controller(name = "pragmatachShowRoutesController")
017    @View(view = "pragmatach/admin/routes.html")
018    public class ShowRoutesController extends SecuredAdminController {
019       /*
020        * the POST routes
021        */
022       private List<PragmatachRoute> POSTRoutes;
023       /*
024        * the GET routes
025        */
026       private List<PragmatachRoute> GETRoutes;
027    
028       public List<PragmatachRoute> getGETRoutes() {
029          return GETRoutes;
030       }
031    
032       public List<PragmatachRoute> getPOSTRoutes() {
033          return POSTRoutes;
034       }
035    
036       public String getRouteParameters(PragmatachRoute pragmatachRoute) {
037          String ret = "";
038          int i = 0;
039          final Class<?>[] types = pragmatachRoute.getMethod().getParameterTypes();
040          if (null != types) {
041             for (final Class<?> type : types) {
042                if (i != 0) {
043                   ret += ",";
044                }
045                i++;
046                ret += type.getName();
047             }
048          }
049          return ret;
050       }
051    
052       @Route(uri = "/pragmatach/admin/routes")
053       public Response render() throws PragmatachException {
054          POSTRoutes = PragmatachRoutes.getInstance().getPOSTRoutes();
055          GETRoutes = PragmatachRoutes.getInstance().getGETRoutes();
056          return super.render();
057       }
058    
059       public void setGETRoutes(List<PragmatachRoute> gETRoutes) {
060          GETRoutes = gETRoutes;
061       }
062    
063       public void setPOSTRoutes(List<PragmatachRoute> pOSTRoutes) {
064          POSTRoutes = pOSTRoutes;
065       }
066    }