use of org.vcell.sbml.vcell.SBMLExporter in project vcell by virtualcell.
the class BiomodelSBMLServerResource method getBiomodelSBML.
private String getBiomodelSBML(User vcellUser) {
RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
try {
// Make temporary resource compatible with restDatabaseService so we can re-use
BiomodelVCMLServerResource bmsr = new BiomodelVCMLServerResource() {
@Override
public Map<String, Object> getRequestAttributes() {
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put(VCellApiApplication.BIOMODELID, BiomodelSBMLServerResource.this.biomodelid);
return hashMap;
}
@Override
public Request getRequest() {
// TODO Auto-generated method stub
return BiomodelSBMLServerResource.this.getRequest();
}
};
String biomodelVCML = restDatabaseService.query(bmsr, vcellUser);
BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(biomodelVCML));
// public SBMLExporter(BioModel argBioModel, int argSbmlLevel, int argSbmlVersion, boolean isSpatial) {
SimulationContext simulationContext = null;
if (appName != null) {
simulationContext = bioModel.getSimulationContext(appName);
} else {
simulationContext = bioModel.getSimulationContext(0);
}
SBMLExporter sbmlExporter = new SBMLExporter(simulationContext, 3, 1, simulationContext.getGeometryContext().getGeometry().getDimension() > 0);
return sbmlExporter.getSBMLString();
} catch (PermissionException e) {
e.printStackTrace();
throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "permission denied to requested resource");
} catch (Exception e) {
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
}
}
Aggregations