예제 #1
0
 @GET
 @Path("/definition/supportedCountries")
 @Produces({MediaType.APPLICATION_JSON})
 @Consumes({MediaType.APPLICATION_JSON})
 @PermitAll
 public Response getCountriesToAbsenceType(@javax.ws.rs.core.Context HttpServletRequest request) {
   try {
     AFMetaModelPack data = new AFMetaModelPack();
     AFClassInfo classInfo = new AFClassInfo();
     classInfo.setName("");
     AFFieldInfo fieldInfo = new AFFieldInfo();
     fieldInfo.setId("country");
     fieldInfo.addRule(new AFValidationRule(SupportedValidations.REQUIRED, "true"));
     fieldInfo.setWidgetType(SupportedWidgets.DROPDOWNMENU);
     List<Country> supportedCountries = getCountryManager().findAllCountry();
     classInfo.addFieldInfo(fieldInfo);
     data.setClassInfo(classInfo);
     HashMap<String, String> options = new HashMap<String, String>();
     for (Country country : supportedCountries) {
       options.put(String.valueOf(country.getId()), country.getName());
     }
     data.setOptionsToFields(options, "country");
     return Response.status(Response.Status.OK).entity(data).build();
   } catch (NamingException e) {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
   }
 }
예제 #2
0
 @GET
 @Path("/definition")
 @Produces({MediaType.APPLICATION_JSON})
 @Consumes({MediaType.APPLICATION_JSON})
 @PermitAll
 public Response getResources(@javax.ws.rs.core.Context HttpServletRequest request) {
   try {
     AFRest afSwing = new AFRestGenerator(request.getSession().getServletContext());
     afSwing.setMainLayout("templates/oneColumnLayout.xml");
     AFMetaModelPack data = afSwing.generateSkeleton(AbsenceType.class.getCanonicalName());
     HashMap<String, String> options = new HashMap<String, String>();
     options.put("true", "true");
     options.put("false", "false");
     data.setOptionsToFields(options, "active");
     return Response.status(Response.Status.OK).entity(data).build();
   } catch (MetamodelException e) {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
   }
 }