use of ambit2.base.data.study.ReliabilityParams._r_flags in project ambit-mirror by ideaconsult.
the class SubstanceStudyParser method parseReliability.
// ProtocolApplicationAnnotated
protected void parseReliability(ObjectNode node, ProtocolApplication record) {
if (node == null)
return;
ReliabilityParams reliability = new ReliabilityParams();
JsonNode jn = node.get(_FIELDS_RELIABILITY.r_isUsedforMSDS.name());
try {
reliability.setIsUsedforMSDS(jn.asBoolean());
} catch (Exception x) {
}
jn = node.get(_FIELDS_RELIABILITY.r_isRobustStudy.name());
try {
reliability.setIsRobustStudy(jn.asBoolean());
} catch (Exception x) {
}
jn = node.get(_FIELDS_RELIABILITY.r_isUsedforClassification.name());
try {
reliability.setIsUsedforClassification(jn.asBoolean());
} catch (Exception x) {
}
jn = node.get(_FIELDS_RELIABILITY.r_purposeFlag.name());
try {
reliability.setPurposeFlag(jn.textValue());
} catch (Exception x) {
}
jn = node.get(_FIELDS_RELIABILITY.r_studyResultType.name());
try {
reliability.setStudyResultType(jn.textValue());
} catch (Exception x) {
}
jn = node.get(_FIELDS_RELIABILITY.r_value.name());
try {
reliability.setValue(jn.textValue());
} catch (Exception x) {
}
record.setReliability(reliability);
}
use of ambit2.base.data.study.ReliabilityParams._r_flags in project ambit-mirror by ideaconsult.
the class StringArrayHeader method getExperiment.
protected ProtocolApplication<Protocol, IParams, String, IParams, String> getExperiment(CATEGORIES categories, SubstanceRecord record, Protocol protocol, ReliabilityParams reliability) {
String experimentUUID = prefix + UUID.nameUUIDFromBytes((record.getSubstanceUUID() + lines[_lines.technology.ordinal()] + lines[_lines.endpoint.ordinal()]).getBytes());
if (record.getMeasurements() != null)
for (ProtocolApplication<Protocol, IParams, String, IParams, String> experiment : record.getMeasurements()) {
if (experimentUUID.equals(experiment.getDocumentUUID()))
return experiment;
}
ProtocolApplication<Protocol, IParams, String, IParams, String> experiment = new ProtocolApplication<Protocol, IParams, String, IParams, String>(protocol);
experiment.setReliability(reliability);
experiment.setParameters(new Params());
experiment.getParameters().put("testmat_form", null);
experiment.getParameters().put("Type of method", null);
setCitation(experiment);
experiment.setDocumentUUID(experimentUUID);
return experiment;
}
use of ambit2.base.data.study.ReliabilityParams._r_flags in project ambit-mirror by ideaconsult.
the class StructureRecordXLSXReporter method processItem.
@Override
public Object processItem(IStructureRecord item) throws Exception {
Row row = sheet.createRow(rowIndex);
row.setHeightInPoints(new Float(d.getHeight() + 2 * offset));
int r = 0;
if (item instanceof SubstanceRecord) {
SubstanceRecord record = (SubstanceRecord) item;
Cell cell = row.createCell(_columns.tag.ordinal());
cell.setCellType(CellType.NUMERIC);
cell.setCellStyle(style);
cell.setCellValue(rowIndex);
cell = row.createCell(_columns.name.ordinal());
cell.setCellType(CellType.STRING);
cell.setCellStyle(style);
try {
Object name = record.getRecordProperty(new SubstancePublicName());
cell.setCellValue(name == null ? record.getRecordProperty(new SubstanceName()).toString() : name.toString());
} catch (Exception x) {
}
for (Property p : record.getRecordProperties()) if (p.getLabel().startsWith(prefix)) {
Integer colIndex = mergedProperties.get(p.getLabel());
if (colIndex == null) {
int last = mergedProperties.size();
mergedProperties.put(p.getLabel(), last);
colIndex = last;
}
Cell pcell = row.getCell(colIndex + _columns.component.ordinal() + 1);
if (pcell == null) {
pcell = row.createCell(colIndex + _columns.component.ordinal() + 1);
pcell.setCellStyle(blueStyle);
pcell.setCellType(CellType.STRING);
Cell hcell = sheet.getRow(0).createCell(colIndex + _columns.component.ordinal() + 1);
hcell.setCellType(CellType.STRING);
hcell.setCellStyle(hstyle);
String h = p.getLabel().replace(prefix, "");
try {
Protocol._categories c = Protocol._categories.valueOf(h + "_SECTION");
hcell.setCellValue(c.getNumber() + ". " + c.toString());
} catch (Exception x) {
hcell.setCellValue(h);
}
if (isAutosizeColumns())
sheet.autoSizeColumn(hcell.getColumnIndex(), true);
sheet.setColumnHidden(hcell.getColumnIndex(), false);
}
Object value = record.getRecordProperty(p);
try {
String cellvalue = formatter.format((SubstanceProperty) p, value);
if (cellvalue == null || "".equals(cellvalue.trim())) {
// do nothing
} else {
_r_flags studyResultType = ((SubstanceProperty) p).getStudyResultType();
String flag = "";
Font font = redFont;
if (studyResultType != null)
switch(studyResultType) {
case experimentalresult:
{
font = blueFont;
break;
}
case other:
{
font = blackFont;
break;
}
case unsupported:
{
font = blackFont;
break;
}
case NOTSPECIFIED:
{
font = blackFont;
break;
}
case nodata:
{
font = blackFont;
break;
}
default:
{
font = redFont;
flag = studyResultType.getIdentifier() + ": ";
}
}
RichTextString rtvalue = pcell.getRichStringCellValue();
if (rtvalue == null || rtvalue.length() == 0 || "".equals(rtvalue.getString().trim())) {
pcell.setCellValue(createRichTextString(flag + cellvalue, font));
} else {
if (rtvalue instanceof XSSFRichTextString) {
((XSSFRichTextString) rtvalue).append("\n" + flag + cellvalue, (XSSFFont) font);
} else {
pcell.setCellValue(createRichTextString(pcell.getStringCellValue() + "\n" + flag + cellvalue, font));
}
}
if (isAutosizeColumns())
sheet.autoSizeColumn(pcell.getColumnIndex(), true);
}
} catch (Exception x) {
if (value instanceof IValue) {
value = p.getName() + "=" + ((IValue) value).toHumanReadable() + ((p.getUnits() != null) ? p.getUnits() : "") + (p.getReference().getURL() != null ? ("[" + p.getReference().getURL() + "]") : "");
} else if (value instanceof MultiValue) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < ((MultiValue) value).size(); i++) {
if (i > 0)
b.append("\n");
b.append(p.getName());
b.append("=");
b.append(((IValue) ((MultiValue) value).get(i)).toHumanReadable());
if (p.getUnits() != null)
b.append(p.getUnits());
}
if (p.getReference().getURL() != null) {
b.append(" [");
b.append(p.getReference().getURL());
b.append("]");
}
value = b.toString();
} else {
value = p.getName() + "=" + value.toString() + ((p.getUnits() != null) ? p.getUnits() : "") + (p.getReference().getURL() != null ? ("[" + p.getReference().getURL() + "]") : "");
}
pcell.setCellValue(String.format("%s%s%s", pcell.getStringCellValue() == null ? "" : pcell.getStringCellValue(), pcell.getStringCellValue() == null ? "" : "\n", value.toString()));
}
}
//
if (record.getRelatedStructures() != null) {
for (CompositionRelation relation : record.getRelatedStructures()) {
Row structure = (r == 0) ? row : sheet.createRow((short) (rowIndex + r));
try {
structure.setHeightInPoints(new Float(d.getHeight() + 2 * offset));
addPicture(relation.getSecondStructure(), structure.getRowNum(), _columns.diagram.ordinal());
} catch (Exception x) {
x.printStackTrace();
}
Cell cellStruc = structure.createCell(_columns.component.ordinal());
cellStruc.setCellStyle(style);
cellStruc.setCellValue(relation.getRelationType().toHumanReadable());
r++;
}
}
}
if (r > 1) {
for (int c = 0; c < mergedProperties.size(); c++) {
sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex + r - 1, c + _columns.component.ordinal() + 1, c + _columns.component.ordinal() + 1));
}
rowIndex += r;
} else
rowIndex++;
return item;
}
use of ambit2.base.data.study.ReliabilityParams._r_flags in project ambit-mirror by ideaconsult.
the class StudyFormatter method format.
public int format(final ProtocolApplication<Protocol, String, String, Object, String> pa, IStudyPrinter printer) throws Exception {
_r_flags flag = null;
try {
for (_r_flags rf : _r_flags.values()) if (rf.toString().equals(pa.getReliability().getStudyResultType().toString())) {
flag = rf;
break;
}
;
} catch (Exception x) {
}
ObjectNode column = (ObjectNode) columns.get(pa.getProtocol().getCategory());
// defaultColumn
// TODO default column
ObjectNode config = getGuidelineConfig(column);
if (isVisible(config))
try {
printer.print(0, getColumn(config), getOrder(config), pa.getProtocol().getGuideline().get(0), false, flag);
} catch (Exception x) {
logger.log(Level.WARNING, x.getMessage());
}
config = getCitationConfig(column);
if (isVisible(config))
try {
printer.print(0, getColumn(config), getOrder(config), pa.getReferenceYear(), false, flag);
} catch (Exception x) {
logger.log(Level.WARNING, x.getMessage());
}
config = getOwnerConfig(column);
if (isVisible(config))
printer.print(0, getColumn(config), getOrder(config), pa.getReferenceOwner(), false, flag);
config = getInterpretationResultConfig(column);
if (isVisible(config)) {
printer.print(0, getColumn(config), getOrder(config), pa.getInterpretationResult(), true, flag);
}
config = getInterpretationResultCriteria(column);
if (isVisible(config)) {
printer.print(0, getColumn(config), getOrder(config), pa.getInterpretationCriteria(), false, flag);
}
try {
JsonNode conditions = mapper.readTree(new StringReader(pa.getParameters()));
if (conditions instanceof ObjectNode) {
IParams params = SubstanceStudyParser.parseParams((ObjectNode) conditions);
printConditions(0, params, getParametersConfig(column), printer, flag);
}
} catch (Exception x) {
}
/**
* Effects
*/
int row = 0;
if (pa.getEffects() != null)
for (EffectRecord<String, Object, String> effect : pa.getEffects()) {
if (effect.getConditions() != null) {
IParams params = SubstanceStudyParser.parseConditions(dx, effect.getConditions().toString());
printConditions(row, params, getConditionsConfig(column), printer, flag);
}
config = getEndpointConfig(column);
if (isVisible(config))
printer.print(row, getColumn(config), getOrder(config), effect.getEndpoint(), false, flag);
config = getResultConfig(column);
if (isVisible(config))
printer.print(row, getColumn(config), getOrder(config), formatValue(effect), true, flag);
config = getTextResultConfig(column);
if ((effect.getTextValue() != null) && isVisible(config))
printer.print(row, getColumn(config), getOrder(config), effect.getTextValue().toString(), true, flag);
row++;
}
return row + 1;
}
use of ambit2.base.data.study.ReliabilityParams._r_flags in project ambit-mirror by ideaconsult.
the class ReadSubstanceStudy method getObject.
@Override
public PA getObject(ResultSet rs) throws AmbitException {
if (record == null) {
record = (PA) new ProtocolApplication<Protocol, String, String, IParams, String>(new Protocol(null));
} else
record.clear();
try {
Protocol protocol = new Protocol(rs.getString("endpoint"));
protocol.addGuideline(rs.getString("guidance"));
protocol.setCategory(rs.getString("endpointcategory"));
protocol.setTopCategory(rs.getString("topcategory"));
record.setProtocol(protocol);
try {
record.setDocumentUUID(I5Utils.getPrefixedUUID(rs.getString("document_prefix"), rs.getString("u")));
} catch (Exception xx) {
record.setDocumentUUID(null);
}
try {
record.setSubstanceUUID(I5Utils.getPrefixedUUID(rs.getString("substance_prefix"), rs.getString("su")));
} catch (Exception xx) {
record.setSubstanceUUID(null);
}
record.setReference(rs.getString("reference"));
try {
record.setReferenceYear(Integer.toString(rs.getInt("reference_year")));
} catch (Exception x) {
record.setReferenceYear(null);
}
try {
record.setReferenceOwner(rs.getString("reference_owner"));
} catch (Exception x) {
record.setReferenceOwner(null);
}
// parse json
record.setParameters(rs.getString("params"));
// parse
record.setInterpretationCriteria(rs.getString("interpretation_criteria"));
// json
// parse
record.setInterpretationResult(rs.getString("interpretation_result"));
// json
record.setCompanyName(rs.getString("owner_name"));
try {
record.setCompanyUUID(I5Utils.getPrefixedUUID(rs.getString("owner_prefix"), rs.getString("ou")));
} catch (Exception xx) {
record.setCompanyUUID(null);
}
try {
record.setReferenceSubstanceUUID(I5Utils.getPrefixedUUID(rs.getString("rs_prefix"), rs.getString("rsu")));
} catch (Exception xx) {
record.setReferenceSubstanceUUID(null);
}
ReliabilityParams reliability = new ReliabilityParams();
record.setReliability(reliability);
try {
reliability.setValue(rs.getString("reliability"));
} catch (Exception x) {
}
try {
reliability.setIsRobustStudy(rs.getBoolean("isRobustStudy"));
} catch (Exception x) {
}
try {
reliability.setIsUsedforClassification(rs.getBoolean("isUsedforClassification"));
} catch (Exception x) {
}
try {
reliability.setIsUsedforMSDS(rs.getBoolean("isUsedforMSDS"));
} catch (Exception x) {
}
try {
reliability.setPurposeFlag(rs.getString("purposeFlag"));
} catch (Exception x) {
}
try {
reliability.setStudyResultType(rs.getString("studyResultType"));
} catch (Exception x) {
}
try {
String iuuid = rs.getString("iuuid");
record.setInvestigationUUID(iuuid);
} catch (Exception x) {
record.setInvestigationUUID((String) null);
}
try {
String auuid = rs.getString("auuid");
record.setAssayUUID(auuid);
} catch (Exception x) {
record.setAssayUUID((String) null);
}
try {
record.setUpdated(new Date(rs.getTimestamp("updated").getTime()));
} catch (Exception x) {
record.setReferenceYear(null);
}
} catch (Exception x) {
x.printStackTrace();
}
return record;
}
Aggregations