Search in sources :

Example 1 with SubstanceOwner

use of ambit2.base.data.substance.SubstanceOwner in project ambit-mirror by ideaconsult.

the class SubstanceByOwnerResource method createQuery.

@Override
protected Q createQuery(Context context, Request request, Response response) throws ResourceException {
    Object owneruuid = request.getAttributes().get(OwnerSubstanceFacetResource.idowner);
    ReadSubstanceByOwner q = new ReadSubstanceByOwner(ReadSubstanceByOwner._ownersearchmode.owner_uuid, owneruuid.toString()) {

        /**
         */
        private static final long serialVersionUID = 6003910893547753024L;

        public ambit2.base.data.SubstanceRecord getObject(java.sql.ResultSet rs) throws AmbitException {
            ambit2.base.data.SubstanceRecord record = super.getObject(rs);
            record.setRecordProperty(new SubstancePublicName(), record.getPublicName());
            record.setRecordProperty(new SubstanceName(), record.getSubstanceName());
            record.setRecordProperty(new SubstanceUUID(), record.getSubstanceUUID());
            record.setRecordProperty(new SubstanceOwner(), record.getOwnerName());
            return record;
        }
    };
    return (Q) q;
}
Also used : SubstanceName(ambit2.base.data.substance.SubstanceName) SubstanceOwner(ambit2.base.data.substance.SubstanceOwner) SubstanceUUID(ambit2.base.data.substance.SubstanceUUID) SubstanceRecord(ambit2.base.data.SubstanceRecord) ReadSubstanceByOwner(ambit2.db.substance.ReadSubstanceByOwner) SubstancePublicName(ambit2.base.data.substance.SubstancePublicName)

Example 2 with SubstanceOwner

use of ambit2.base.data.substance.SubstanceOwner 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)

Example 3 with SubstanceOwner

use of ambit2.base.data.substance.SubstanceOwner in project ambit-mirror by ideaconsult.

the class SubstanceDatasetResource method createCSVReporter.

protected IProcessor<Q, Representation> createCSVReporter(String filenamePrefix) {
    groupProperties.add(new SubstancePublicName());
    groupProperties.add(new SubstanceName());
    groupProperties.add(new SubstanceUUID());
    groupProperties.add(new SubstanceOwner());
    CSVReporter csvreporter = new CSVReporter(getRequest().getRootRef().toString(), getTemplate(), groupProperties, String.format("%s%s", getRequest().getRootRef(), "")) {

        @Override
        protected void configurePropertyProcessors() {
            getProcessors().add(getPropertyProcessors(false, false));
        }
    };
    try {
        Form form = getParams();
        csvreporter.setNumberofHeaderLines(Integer.parseInt(form.getFirstValue("headerlines")));
    } catch (Exception x) {
        csvreporter.setNumberofHeaderLines(3);
    }
    return new OutputWriterConvertor<SubstanceRecord, Q>(csvreporter, MediaType.TEXT_CSV, filenamePrefix);
}
Also used : SubstanceName(ambit2.base.data.substance.SubstanceName) SubstanceOwner(ambit2.base.data.substance.SubstanceOwner) SubstanceUUID(ambit2.base.data.substance.SubstanceUUID) Form(org.restlet.data.Form) OutputWriterConvertor(net.idea.restnet.db.convertors.OutputWriterConvertor) CSVReporter(ambit2.db.reporters.CSVReporter) SubstancePublicName(ambit2.base.data.substance.SubstancePublicName) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) ResourceException(org.restlet.resource.ResourceException)

Example 4 with SubstanceOwner

use of ambit2.base.data.substance.SubstanceOwner in project ambit-mirror by ideaconsult.

the class SubstanceDatasetResource method createRDFReporter.

protected IProcessor<Q, Representation> createRDFReporter(MediaType media, String filenamePrefix) {
    groupProperties.add(new SubstancePublicName());
    groupProperties.add(new SubstanceName());
    groupProperties.add(new SubstanceUUID());
    groupProperties.add(new SubstanceOwner());
    DatasetRDFReporter reporter = new DatasetRDFReporter(getRequest(), media, getTemplate(), getGroupProperties()) {

        @Override
        protected boolean acceptProperty(Property p) {
            return true;
        }

        @Override
        protected void configurePropertyProcessors() {
            getProcessors().add(getPropertyProcessors(false, false));
        }
    };
    return new RDFJenaConvertor(reporter, media, filenamePrefix);
}
Also used : SubstanceName(ambit2.base.data.substance.SubstanceName) SubstanceOwner(ambit2.base.data.substance.SubstanceOwner) SubstanceUUID(ambit2.base.data.substance.SubstanceUUID) DatasetRDFReporter(ambit2.rest.dataset.DatasetRDFReporter) RDFJenaConvertor(ambit2.rest.RDFJenaConvertor) Property(ambit2.base.data.Property) ProtocolEffectRecord2SubstanceProperty(ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty) SubstanceProperty(ambit2.base.data.substance.SubstanceProperty) SubstancePublicName(ambit2.base.data.substance.SubstancePublicName)

Example 5 with SubstanceOwner

use of ambit2.base.data.substance.SubstanceOwner in project ambit-mirror by ideaconsult.

the class SubstanceDatasetResource method createJSONReporter.

@Override
protected IProcessor<Q, Representation> createJSONReporter(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");
    return new OutputWriterConvertor(new CompoundJSONReporter(getTemplate(), getGroupProperties(), folders, getBundles(), getRequest(), getRequest().getRootRef().toString(), false, jsonpcallback) {

        private static final long serialVersionUID = -5059577943753305935L;

        @Override
        protected String getURI(IStructureRecord item) {
            if (item instanceof SubstanceRecord)
                return SubstanceRecord.getURI(urlPrefix, ((SubstanceRecord) item));
            else
                return super.getURI(item);
        }

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

        @Override
        protected void append2header(Writer writer, IStructureRecord item) {
            if (header == null)
                return;
            for (Property p : item.getRecordProperties()) {
                if (header.indexOf(p) < 0)
                    header.add(p);
            }
        }
    }, MediaType.APPLICATION_JSON, filenamePrefix);
}
Also used : SubstanceName(ambit2.base.data.substance.SubstanceName) CompoundJSONReporter(ambit2.rest.structure.CompoundJSONReporter) OutputWriterConvertor(net.idea.restnet.db.convertors.OutputWriterConvertor) SubstanceRecord(ambit2.base.data.SubstanceRecord) IStructureRecord(ambit2.base.interfaces.IStructureRecord) SubstanceOwner(ambit2.base.data.substance.SubstanceOwner) SubstanceUUID(ambit2.base.data.substance.SubstanceUUID) Property(ambit2.base.data.Property) ProtocolEffectRecord2SubstanceProperty(ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty) SubstanceProperty(ambit2.base.data.substance.SubstanceProperty) SubstancePublicName(ambit2.base.data.substance.SubstancePublicName) Writer(java.io.Writer)

Aggregations

SubstanceName (ambit2.base.data.substance.SubstanceName)8 SubstanceOwner (ambit2.base.data.substance.SubstanceOwner)8 SubstancePublicName (ambit2.base.data.substance.SubstancePublicName)8 SubstanceUUID (ambit2.base.data.substance.SubstanceUUID)8 SubstanceRecord (ambit2.base.data.SubstanceRecord)4 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)4 ResourceException (org.restlet.resource.ResourceException)3 Property (ambit2.base.data.Property)2 SubstanceEndpointsBundle (ambit2.base.data.substance.SubstanceEndpointsBundle)2 SubstanceProperty (ambit2.base.data.substance.SubstanceProperty)2 ProtocolEffectRecord2SubstanceProperty (ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty)2 ReadSubstanceChemicalsUnionByBundle (ambit2.db.update.bundle.substance.ReadSubstanceChemicalsUnionByBundle)2 ReadSubstancesByBundle (ambit2.db.update.bundle.substance.ReadSubstancesByBundle)2 ResultSet (java.sql.ResultSet)2 OutputWriterConvertor (net.idea.restnet.db.convertors.OutputWriterConvertor)2 Form (org.restlet.data.Form)2 LiteratureEntry (ambit2.base.data.LiteratureEntry)1 Protocol (ambit2.base.data.study.Protocol)1 SubstancePropertyCategory (ambit2.base.data.substance.SubstancePropertyCategory)1 IStructureRecord (ambit2.base.interfaces.IStructureRecord)1