Search in sources :

Example 1 with StructureRecordXLSXReporter

use of ambit2.db.reporters.xlsx.StructureRecordXLSXReporter in project ambit-mirror by ideaconsult.

the class SubstanceDatasetResource method createXLSXReporter.

protected IProcessor<Q, Representation> createXLSXReporter(MediaType media, boolean hssf, String filenamePrefix) {
    groupProperties.add(new SubstancePublicName());
    groupProperties.add(new SubstanceName());
    groupProperties.add(new SubstanceUUID());
    groupProperties.add(new SubstanceOwner());
    String jsonpcallback = getParams().getFirstValue("jsonp");
    if (jsonpcallback == null)
        jsonpcallback = getParams().getFirstValue("callback");
    String configResource = String.format("config-%s.js", ((IFreeMarkerApplication) getApplication()).getProfile());
    return new OutputStreamConvertor(new StructureRecordXLSXReporter(getRequest().getRootRef().toString(), hssf, getTemplate(), getGroupProperties(), getBundles(), null, true, configResource) {

        @Override
        protected void configurePropertyProcessors() {
            getCompositionProcessors(getProcessors());
            getProcessors().add(getPropertyProcessors(false, false));
        }

        @Override
        protected void initColumns(int afterCol) {
            for (I5_ROOT_OBJECTS section : I5_ROOT_OBJECTS.values()) {
                if (section.isIUCLID5() && section.isScientificPart() && section.isSupported() && !section.isNanoMaterialTemplate()) {
                    int last = mergedProperties.size();
                    mergedProperties.put("http://www.opentox.org/echaEndpoints.owl#" + section.name(), last);
                    Cell hcell = sheet.getRow(0).createCell(last + afterCol);
                    hcell.setCellStyle(hstyle);
                    hcell.setCellType(CellType.STRING);
                    hcell.setCellValue(section.getNumber() + ". " + section.getTitle());
                    sheet.autoSizeColumn(hcell.getColumnIndex(), true);
                    // initially hide all columns, unhide if data is added
                    // to
                    sheet.setColumnHidden(hcell.getColumnIndex(), true);
                }
            }
        }
    }, media, filenamePrefix);
}
Also used : SubstanceName(ambit2.base.data.substance.SubstanceName) OutputStreamConvertor(ambit2.rest.OutputStreamConvertor) SubstanceOwner(ambit2.base.data.substance.SubstanceOwner) SubstanceUUID(ambit2.base.data.substance.SubstanceUUID) I5_ROOT_OBJECTS(net.idea.i5.io.I5_ROOT_OBJECTS) StructureRecordXLSXReporter(ambit2.db.reporters.xlsx.StructureRecordXLSXReporter) Cell(org.apache.poi.ss.usermodel.Cell) SubstancePublicName(ambit2.base.data.substance.SubstancePublicName)

Aggregations

SubstanceName (ambit2.base.data.substance.SubstanceName)1 SubstanceOwner (ambit2.base.data.substance.SubstanceOwner)1 SubstancePublicName (ambit2.base.data.substance.SubstancePublicName)1 SubstanceUUID (ambit2.base.data.substance.SubstanceUUID)1 StructureRecordXLSXReporter (ambit2.db.reporters.xlsx.StructureRecordXLSXReporter)1 OutputStreamConvertor (ambit2.rest.OutputStreamConvertor)1 I5_ROOT_OBJECTS (net.idea.i5.io.I5_ROOT_OBJECTS)1 Cell (org.apache.poi.ss.usermodel.Cell)1