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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations