Changeset 4907


Ignore:
Timestamp:
Apr 28, 2009, 8:47:37 AM (13 years ago)
Author:
Martin Svensson
Message:

Fixes #1128 Export of child items

Location:
trunk/www/admin
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/admin/annotationtypecategories/index.jsp

    r4587 r4907  
    3939  import="net.sf.basedb.core.PermissionDeniedException"
    4040  import="net.sf.basedb.core.ItemAlreadyExistsException"
     41  import="net.sf.basedb.core.query.Expressions"
     42  import="net.sf.basedb.core.query.Hql"
     43  import="net.sf.basedb.core.query.Orders"
     44  import="net.sf.basedb.core.query.Restrictions"
    4145  import="net.sf.basedb.util.RemovableUtil"
    4246  import="net.sf.basedb.util.ShareableUtil"
    4347  import="net.sf.basedb.util.OwnableUtil"
     48  import="net.sf.basedb.util.formatter.NameableFormatter"
    4449  import="net.sf.basedb.clients.web.Base"
    4550  import="net.sf.basedb.clients.web.WebException"
    4651  import="net.sf.basedb.util.Values"
     52  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
    4753  import="net.sf.basedb.clients.web.util.HTML"
    4854  import="java.util.Enumeration"
     
    6066  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,description");
    6167  private static final Item itemType = Item.ANNOTATIONTYPECATEGORY;
     68 
     69  private static void registerExportUtils(ItemContext cc)
     70  {
     71    // Register formatter
     72    cc.setObject("export.formatter.&annotationTypes(name)", new NameableFormatter());
     73   
     74    // Register dataloader
     75    String categoryParameter = "category";
     76    ItemQuery<AnnotationType> annotationTypeQuery = AnnotationType.getQuery(null);
     77    annotationTypeQuery.include(cc.getInclude());
     78    annotationTypeQuery.join(Hql.innerJoin("categories", "ctg"));
     79    annotationTypeQuery.restrict(Restrictions.eq(Hql.alias("ctg"), Expressions.parameter(categoryParameter)));
     80    annotationTypeQuery.order(Orders.asc(Hql.property("name")));
     81    cc.setObject("export.dataloader.&annotationTypes(name)", new ItemQueryLoader(annotationTypeQuery, categoryParameter));
     82  }
    6283%>
    6384<%
     
    262283    cc.configureQuery(query, true);
    263284    cc.setQuery(query);
     285    registerExportUtils(cc);
    264286    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+annotation+type+categories";
    265287  }
     
    268290    // Run an export plugin in single-item context
    269291    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     292    registerExportUtils(cc);
    270293    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+annotation+type+category";
    271294  }
  • trunk/www/admin/annotationtypecategories/list_categories.jsp

    r4886 r4907  
    262262        datatype="string"
    263263        filterable="true"
     264        exportable="true"
    264265      />
    265266      <tbl:columndef
  • trunk/www/admin/annotationtypes/index.jsp

    r4889 r4907  
    4242  import="net.sf.basedb.core.PermissionDeniedException"
    4343  import="net.sf.basedb.core.ItemAlreadyExistsException"
     44  import="net.sf.basedb.core.query.Expressions"
     45  import="net.sf.basedb.core.query.Hql"
     46  import="net.sf.basedb.core.query.Orders"
     47  import="net.sf.basedb.core.query.Restrictions"
    4448  import="net.sf.basedb.util.RemovableUtil"
    4549  import="net.sf.basedb.util.ShareableUtil"
     
    4852  import="net.sf.basedb.clients.web.WebException"
    4953  import="net.sf.basedb.util.Values"
     54  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
    5055  import="net.sf.basedb.clients.web.util.HTML"
    5156  import="net.sf.basedb.util.formatter.Formatter"
     57  import="net.sf.basedb.util.formatter.NameableFormatter"
    5258  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
    5359  import="java.util.Enumeration"
     
    6571  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,valueType,requiredForMiame,itemTypes,description");
    6672  private static final Item itemType = Item.ANNOTATIONTYPE;
     73 
     74  private static void registerExportUtils(ItemContext cc)
     75  {
     76    // Register formatter
     77    cc.setObject("export.formatter.&categories(name)", new NameableFormatter());
     78   
     79    // Register dataloader
     80    String typeParameter = "annotationType";
     81    ItemQuery<AnnotationTypeCategory> categoryQuery = AnnotationTypeCategory.getQuery();
     82    categoryQuery.include(cc.getInclude());
     83    categoryQuery.join(Hql.innerJoin("annotationTypes", "atp"));
     84    categoryQuery.restrict(Restrictions.eq(Hql.alias("atp"), Expressions.parameter(typeParameter)));
     85    categoryQuery.order(Orders.asc(Hql.property("name")));
     86    cc.setObject("export.dataloader.&categories(name)", new ItemQueryLoader(categoryQuery, typeParameter));
     87  }
    6788%>
    6889<%
     
    389410    cc.configureQuery(query, true);
    390411    cc.setQuery(query);
     412    registerExportUtils(cc);
    391413    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+annotation+types";
    392414  }
     
    395417    // Run an export plugin in single-item context
    396418    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     419    registerExportUtils(cc);
    397420    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+annotation+type";
    398421  }
  • trunk/www/admin/annotationtypes/list_annotationtypes.jsp

    r4889 r4907  
    398398        datatype="string"
    399399        filterable="true"
     400        exportable="true"
    400401      />
    401402      <tbl:columndef
  • trunk/www/admin/hardwaretypes/index.jsp

    r4889 r4907  
    3535  import="net.sf.basedb.core.MultiPermissions"
    3636  import="net.sf.basedb.core.PermissionDeniedException"
     37  import="net.sf.basedb.core.Hardware"
    3738  import="net.sf.basedb.core.ItemAlreadyExistsException"
     39  import="net.sf.basedb.core.query.Expressions"
     40  import="net.sf.basedb.core.query.Hql"
     41  import="net.sf.basedb.core.query.Orders"
     42  import="net.sf.basedb.core.query.Restrictions"
    3843  import="net.sf.basedb.util.RemovableUtil"
     44  import="net.sf.basedb.util.formatter.NameableFormatter"
    3945  import="net.sf.basedb.clients.web.Base"
    4046  import="net.sf.basedb.clients.web.WebException"
    4147  import="net.sf.basedb.util.Values"
     48  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
    4249  import="net.sf.basedb.clients.web.util.HTML"
    4350  import="java.util.Enumeration"
     
    5259  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,hardware,description");
    5360  private static final Item itemType = Item.HARDWARETYPE;
     61 
     62  private static void registerExportUtils(ItemContext cc)
     63  {
     64    // Register formatter
     65    cc.setObject("export.formatter.&hardware(name)", new NameableFormatter());
     66   
     67    // Register dataloader
     68    String typeParameter = "hardwareType";
     69    ItemQuery<Hardware> hardwareQuery = Hardware.getQuery();
     70    hardwareQuery.include(cc.getInclude());
     71    hardwareQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
     72    hardwareQuery.restrict(Restrictions.eq(Hql.property("hardwareType"), Expressions.parameter(typeParameter)));
     73    hardwareQuery.order(Orders.asc(Hql.property("name")));
     74    cc.setObject("export.dataloader.&hardware(name)", new ItemQueryLoader(hardwareQuery, typeParameter));
     75  }
    5476%>
    5577<%
     
    193215    cc.configureQuery(query, true);
    194216    cc.setQuery(query);
     217    registerExportUtils(cc);
    195218    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+hardware+types";
    196219  }
     
    199222    // Run an export plugin in single-item context
    200223    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     224    registerExportUtils(cc);
    201225    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+hardware+type";
    202226  }
  • trunk/www/admin/hardwaretypes/list_hardwaretypes.jsp

    r4889 r4907  
    258258        datatype="string"
    259259        filterable="true"
     260        exportable="true"
    260261      />
    261262      <tbl:columndef
  • trunk/www/admin/quantities/index.jsp

    r4543 r4907  
    3535  import="net.sf.basedb.core.PermissionDeniedException"
    3636  import="net.sf.basedb.core.ItemAlreadyExistsException"
     37  import="net.sf.basedb.core.Unit"
     38  import="net.sf.basedb.core.query.Expressions"
     39  import="net.sf.basedb.core.query.Hql"
     40  import="net.sf.basedb.core.query.Orders"
     41  import="net.sf.basedb.core.query.Restrictions"
    3742  import="net.sf.basedb.util.RemovableUtil"
    3843  import="net.sf.basedb.clients.web.Base"
    3944  import="net.sf.basedb.clients.web.WebException"
    4045  import="net.sf.basedb.util.Values"
    41   import="net.sf.basedb.clients.web.util.HTML"
     46  import="net.sf.basedb.util.formatter.NameableFormatter"
     47  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
     48  import="net.sf.basedb.clients.web.util.HTML" 
    4249  import="java.util.Enumeration"
    4350  import="java.util.Set"
     
    5158  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,referenceUnit,description");
    5259  private static final Item itemType = Item.QUANTITY;
     60 
     61  private static void registerExportUtils(ItemContext cc)
     62  {
     63    // Register formatter
     64    cc.setObject("export.formatter.&units(displaySymbol)", new NameableFormatter());
     65   
     66    // Register dataloader
     67    String quantityParameter = "quantity";
     68    ItemQuery<Unit> unitQuery = Unit.getQuery();
     69    unitQuery.include(cc.getInclude());
     70    unitQuery.restrict(Restrictions.eq(Hql.property("quantity"), Expressions.parameter(quantityParameter)));
     71    unitQuery.order(Orders.desc(Hql.property("referenceFactor")));
     72    unitQuery.order(Orders.asc(Hql.property("displaySymbol")));
     73    cc.setObject("export.dataloader.&units(displaySymbol)", new ItemQueryLoader(unitQuery, quantityParameter));
     74  }
    5375%>
    5476<%
     
    194216    cc.configureQuery(query, true);
    195217    cc.setQuery(query);
     218    registerExportUtils(cc);
    196219    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+quantities";
    197220  }
     
    200223    // Run an export plugin in single-item context
    201224    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     225    registerExportUtils(cc);
    202226    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+quantity";
    203227  }
  • trunk/www/admin/quantities/list_quantities.jsp

    r4889 r4907  
    253253        datatype="string"
    254254        filterable="true"
     255        exportable="true"
    255256      />
    256257      <tbl:columndef
  • trunk/www/admin/softwaretypes/index.jsp

    r4889 r4907  
    3636  import="net.sf.basedb.core.PermissionDeniedException"
    3737  import="net.sf.basedb.core.ItemAlreadyExistsException"
     38  import="net.sf.basedb.core.Software"
     39  import="net.sf.basedb.core.query.Expressions"
     40  import="net.sf.basedb.core.query.Hql"
     41  import="net.sf.basedb.core.query.Orders"
     42  import="net.sf.basedb.core.query.Restrictions"
    3843  import="net.sf.basedb.util.RemovableUtil"
     44  import="net.sf.basedb.util.formatter.NameableFormatter"
    3945  import="net.sf.basedb.clients.web.Base"
    40   import="net.sf.basedb.clients.web.WebException"
     46  import="net.sf.basedb.clients.web.WebException" 
    4147  import="net.sf.basedb.util.Values"
    42   import="net.sf.basedb.clients.web.util.HTML"
     48  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
     49  import="net.sf.basedb.clients.web.util.HTML" 
    4350  import="java.util.Enumeration"
    4451  import="java.util.Set"
     
    5259  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,software,description");
    5360  private static final Item itemType = Item.SOFTWARETYPE;
     61 
     62  private static void registerExportUtils(ItemContext cc)
     63  {
     64    // Register formatter
     65    cc.setObject("export.formatter.&software(name)", new NameableFormatter());
     66   
     67    // Register dataloader
     68    String typeParameter = "softwareType";
     69    ItemQuery<Software> softwareQuery = Software.getQuery();
     70    softwareQuery.include(cc.getInclude());
     71    softwareQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
     72    softwareQuery.restrict(Restrictions.eq(Hql.property("softwareType"), Expressions.parameter(typeParameter)));
     73    softwareQuery.order(Orders.asc(Hql.property("name")));
     74    cc.setObject("export.dataloader.&software(name)", new ItemQueryLoader(softwareQuery, typeParameter));
     75  }
    5476%>
    5577<%
     
    127149    cc.configureQuery(query, true);
    128150    cc.setQuery(query);
     151    registerExportUtils(cc);
    129152    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+software+types";
    130153  }
     
    133156    // Run an export plugin in single-item context
    134157    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     158    registerExportUtils(cc);
    135159    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+software+type";
    136160  }
  • trunk/www/admin/softwaretypes/list_softwaretypes.jsp

    r4889 r4907  
    223223        datatype="string"
    224224        filterable="true"
     225        exportable="true"
    225226      />
    226227      <tbl:columndef
Note: See TracChangeset for help on using the changeset viewer.