Package javango.contrib.hibernate.annotations

Examples of javango.contrib.hibernate.annotations.ModelChoiceFieldProperties


  @Override
  public void handleAnnotation(Annotation annotation) {   
    super.handleAnnotation(annotation);
    if (annotation instanceof ModelChoiceFieldProperties) {
      ModelChoiceFieldProperties mcfp = (ModelChoiceFieldProperties)annotation;
      this.setModel(mcfp.modelClass());
      try {
        QuerySet<?> qs = null;
     
        if (mcfp.filters().length > 0) {
          qs = managers.forClass(getModel()).all();
          for(Filter f : mcfp.filters()) {
            String[] value = f.value();
            if (value != null && value.length > 0) {
              if (value != null && value.length == 1) {
                qs = qs.filter(f.property(), value[0]);
              } else {
                qs = qs.filter(f.property(), value);
              }
            }
            if (!"".equals(f.otherProperty())) {
              qs = qs.filterByProperty(f.property(), f.otherProperty());
            }
            if (f.nullCheck()) {
              qs = qs.filter(f.property(), null);
            }
          }
        }
        if (mcfp.orderby().length > 0) {
          qs = qs != null ? qs : managers.forClass(getModel()).all();
            qs = qs.orderBy(mcfp.orderby());
        }
       
        if (qs != null) setQuerySet(qs);
      } catch (ManagerException e) {
        // ARGG WHAT TO DO...  think of the children
View Full Code Here

TOP

Related Classes of javango.contrib.hibernate.annotations.ModelChoiceFieldProperties

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.