Package javango.db

Examples of javango.db.Manager


    return options == null || "".equals(options.verboseName())
            ? className.substring(className.lastIndexOf(".")+1)
            : options.verboseName();
  }
  private Manager findManager(Class clazz, ModelAdmin ma) {
    Manager m = ma.getManager();
    if (m == null) {
      m = managers.forClass(clazz);
    }
    return m;
  }
View Full Code Here


        throw new Http404("Class not found, or not authorized");
      } else if (!ma.isAuthor(request.getUser())) {
        throw new Http404("Class not found, or not authorized");
      }
     
      Manager manager = findManager(pc, ma);
     
      Object object = null;

      if (object_id != null) {
        object = manager.get(object_id);
        if (object == null) {
          return new SimpleHttpResponse("Object not found");
        }
      }

      String[] property_list = ma.getFields();     

      Form form = ma.getForm();
     
      if (form == null) {
        String[] includeFields = property_list == null ? getIncludeFields(pc) : property_list;
 
        ModelForm mForm = new ModelForm(fieldFactory, hibernateUtil, managers);
        if (includeFields != null) mForm.setInclude(includeFields);
        mForm.setModel(pc);
        form = mForm;
      }
     
      if ("POST".equals(request.getMethod())) {
        // update the object
        if (object == null) object=injector.getInstance(pc);
       
        form.bind(request.getParameterMap());
        // form = modelFactory.form(pc.getMappedClass(), request.getParameterMap());
        if (form.isValid()) {
//          if (object_id == null) { // this is a new object
//            if (!bl.canCreate()) {
//              throw new HttpException("Unable to create");
//            }
//          } else {
//            if (!bl.canUpdate(object)) {
//              throw new HttpException("Unable to updte");
//            }
//          }
         
          form.clean(object);
          try {
            if (object_id == null) {
              manager.create(object);
            } else {
              manager.save(object);
            }
           
            if (request.getParameterMap().containsKey("_addanother")) {
              return new HttpResponseRedirect("../add");
            } else if (request.getParameterMap().containsKey("_continue")) {
              return new HttpResponseRedirect(String.format("../%s/", manager.getPk(object)));
            }
            return new HttpResponseRedirect("..");
          } catch (ManagerException e) {
            request.getSession().addError(e.getMessage());
          }
View Full Code Here

      if (pc == null) {
        throw new Http404("Class not found");
      }
      ModelAdmin ma = options.getModelAdmin(pc);
     
      Manager manager = findManager(pc, ma);

      Object object = manager.get(object_id);
      if (object == null) {
        throw new Http404("Not found"); // TODO 404
      }
 
//      if (!bl.canDelete(object)) {
//        throw new HttpException("Unauthorized to delete");
//      }
       
      if ("POST".equals(request.getMethod())) {
        try {
          manager.delete(object);
          return new HttpResponseRedirect("../..");
        } catch (ManagerException e) {
          request.getSession().addError(e.getMessage());
        }
      }
View Full Code Here

    injector.getInstance(HibernateUtil.class).getSession().beginTransaction();
    for (int i=0; i<ct; i++) {
      Poll p = new Poll();
      p.setQuestion("AdminTestQuestion : " + i );
      p.setPubDate(new Date());
      Manager dao = new HibernateManager(injector.getInstance(HibernateUtil.class), Poll.class);
   
      dao.save(p);
    }
    injector.getInstance(HibernateUtil.class).getSession().getTransaction().commit();
  }
View Full Code Here

TOP

Related Classes of javango.db.Manager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.