Changeset 2165


Ignore:
Timestamp:
Apr 18, 2006, 12:27:06 PM (17 years ago)
Author:
Martin Svensson
Message:

Change the export format for helptexts

Location:
trunk/src/core/net/sf/basedb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/dtd/helpfile.dtd

    r2159 r2165  
    11<!--
    2   $Id: helpexport.dtd,2004/07/28 12:30:49 nicklas Exp $
     2  $Id: helpfile.dtd,2004/07/28 12:30:49 nicklas Exp $
    33
    44  BioArray Software Environment (BASE) - http://base.thep.lu.se/
     
    2222  Boston, MA  02111-1307, USA.
    2323-->
    24 <!ELEMENT helpexport (helpitem*) >
     24<!ELEMENT helptexts (helpitem*)>
     25<!ATTLIST helptexts
     26  clientExternalID CDATA #REQUIRED
     27>
    2528
    26 <!ELEMENT helpitem (property)>
     29<!ELEMENT helpitem (name,description)>
    2730<!ATTLIST helpitem
    28  id ID #REQUIRED
     31  externalID CDATA #REQUIRED
    2932>
    3033
    31 <!ELEMENT property EMPTY >
    32 <!ATTLIST property
    33   version CDATA #REQUIRED
    34   name CDATA #REQUIRED
    35   description CDATA #REQUIRED
    36   clientid CDATA #REQUIRED
    37   externalid CDATA #REQUIRED
    38 >
     34<!ELEMENT name (#CDATA)>
     35<!ELEMENT description (#CDATA)>
  • trunk/src/core/net/sf/basedb/plugins/HelpExporter.java

    r2159 r2165  
    274274      Writer helpExportStream = new OutputStreamWriter(file.getUploadStream(false), "UTF-8");
    275275      helpExportStream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    276       xmlOut.output(new DocType("helpexport", "helpfile.dtd"), helpExportStream);
    277       helpExportStream.write("\n<helpexport>\n");
     276      xmlOut.output(new DocType("helptexts", "helpfile.dtd"), helpExportStream);
     277      Element helpRoot = new Element("helptexts");
     278      helpRoot.setAttribute("clientExternalID", client.getExternalId());
    278279     
    279280      //Transform the helpitems to XML elements
     
    294295          exportedHelpItems++;
    295296          Help helpItem = (Help)result.next();
    296           int helpId = helpItem.getId();
    297297          Element newHelpElement = new Element("helpitem");
    298           newHelpElement.setAttribute("id", "help_" + helpId);
     298          newHelpElement.setAttribute("externalID", helpItem.getExternalId());
    299299         
    300           //Add the helpitem's properties to the helpitem element
    301           Element property = new Element("property");
    302           property.setAttribute("version", helpItem.getVersion() + "");
    303           property.setAttribute("name", helpItem.getName());
    304           property.setAttribute("description", helpItem.getDescription());
    305           property.setAttribute("clientid", helpItem.getClient().getId() + "");
    306           property.setAttribute("externalid", helpItem.getExternalId());
    307           newHelpElement.addContent(property);
     300          Element name = new Element("name");
     301          Element description = new Element("description");
    308302         
    309           xmlOut.output(newHelpElement, helpExportStream);
    310           helpExportStream.write("\n");         
     303          name.setText(helpItem.getName());
     304          description.setText(helpItem.getDescription());
     305         
     306          newHelpElement.addContent(name);
     307          newHelpElement.addContent(description);
     308         
     309          helpRoot.addContent(newHelpElement);
    311310          progress.display(percentDone,"");
    312311        }
     
    320319     
    321320      //Finish the XML document, close the stream and commit to DB
    322       helpExportStream.write("</helpexport>");
     321      xmlOut.output(helpRoot, helpExportStream);
    323322      helpExportStream.flush();
    324323      helpExportStream.close();
     
    336335  }
    337336 
    338   public int getPercentPerItem(ItemQuery<Help> query, DbControl dc)
     337  private int getPercentPerItem(ItemQuery<Help> query, DbControl dc)
    339338  {
    340339    query.setReturnTotalCount(true);
    341340    query.setFirstResult(0);
    342341    query.setMaxResults(0);
    343     int nrOfItem = (query.iterate(dc).getTotalCount());   
    344     return (100/nrOfItem);
     342    int nrOfItem = (query.iterate(dc).getTotalCount());
     343    if (nrOfItem > 0)
     344    {
     345      return (100/nrOfItem);
     346    }
     347    else
     348    {
     349      return 100;
     350    }
    345351  }
    346352}
Note: See TracChangeset for help on using the changeset viewer.