Changeset 2152


Ignore:
Timestamp:
Apr 6, 2006, 3:05:12 PM (17 years ago)
Author:
Nicklas Nordborg
Message:

Fixed export function so it supports ReporterScore?

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java

    r1875 r2152  
    152152      }
    153153    }
     154    guiContexts.add(new GuiContext(Item.REPORTERSCORE, GuiContext.Type.LIST));
    154155  }
    155156}
  • trunk/src/core/net/sf/basedb/core/Metadata.java

    r1993 r2152  
    245245    org.hibernate.Session session = dc.getHibernateSession();
    246246    Object value = null;
    247     BasicData data = null;
     247    Object data = null;
    248248    if (item instanceof BasicItem)
    249249    {
     
    254254      data = (BasicData)item;
    255255    }
     256    else if (item instanceof ReporterScore)
     257    {
     258      data = ((ReporterScore)item).getData();
     259    }
    256260    else
    257261    {
    258       throw new AssertionError("Item: " + item + " is not a BasicItem or BasicData");
     262      throw new AssertionError("Item: " + item + " is not a BasicItem, BasicData or ReporterScore");
    259263    }
    260264   
     
    265269        if (value instanceof BasicData)
    266270        {
    267           data = (BasicData)value;
    268           Class<? extends BasicData> dataClass = null;
     271          BasicData bData = (BasicData)value;
     272          data = value;
     273          Class<?> dataClass = null;
    269274          // If it is a proxy we must reload it using the current session
    270275          if (data instanceof org.hibernate.proxy.HibernateProxy)
    271276          {
    272277            dataClass = org.hibernate.proxy.HibernateProxyHelper.getClassWithoutInitializingProxy(data);
    273             data = HibernateUtil.loadData(session, dataClass, data.getId());
     278            data = HibernateUtil.loadData(session, dataClass, bData.getId());
    274279          }
    275280          else
  • trunk/src/core/net/sf/basedb/core/ReporterScore.java

    r2150 r2152  
    6666  }
    6767 
     68  ReporterListScoreData getData()
     69  {
     70    return data;
     71  }
     72 
    6873  /**
    6974    Get the reporter.
  • trunk/www/common/export/submit_export.jsp

    r2105 r2152  
    4141  import="net.sf.basedb.core.ItemQuery"
    4242  import="net.sf.basedb.core.DataQuery"
     43  import="net.sf.basedb.core.ReporterScoreQuery"
    4344  import="net.sf.basedb.core.Metadata"
    4445  import="net.sf.basedb.core.Path"
     
    5354  import="net.sf.basedb.core.query.Hql"
    5455  import="net.sf.basedb.core.data.BasicData"
     56  import="net.sf.basedb.core.data.ReporterListScoreData"
    5557  import="net.sf.basedb.util.FileUtil"
    5658  import="net.sf.basedb.clients.web.Base"
     
    132134    entityName = rba.getRawDataType().getEntityName();
    133135  }
     136  if (itemType == Item.REPORTERSCORE)
     137  {
     138    entityName = ReporterListScoreData.class.getName();
     139  }
    134140 
    135141  final Metadata metadata = entityName == null ?
     
    234240 
    235241  boolean basicItems = false;
     242  boolean basicDatas = false;
    236243  int exportedItems = 0;
    237244  do
     
    245252    {
    246253      result = ((DataQuery)query).iterate(dc);
    247       basicItems = false;
     254      basicDatas = true;
     255    }
     256    else if (query instanceof ReporterScoreQuery)
     257    {
     258      result = ((ReporterScoreQuery)query).iterate(dc);
    248259    }
    249260    exportedItems = 0;
     
    252263      exportedItems++;
    253264      Object item = result.next();
    254       int id = basicItems ? ((BasicItem)item).getId() : ((BasicData)item).getId();
     265      int id = 0;
     266      if (basicItems)
     267      {
     268        id = ((BasicItem)item).getId();
     269      }
     270      else if (basicDatas)
     271      {
     272        id =  ((BasicData)item).getId();
     273      }
    255274      AnnotationSet as = null;
    256275      org.jdom.Element itemElement = null;
Note: See TracChangeset for help on using the changeset viewer.