Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion SBOLCanvasBackend/src/servlets/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class Convert extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
if (request.getPathInfo() == null) {
response.setStatus(HttpStatus.SC_BAD_REQUEST);
return;
}

if (request.getPathInfo().equals("/toMxGraph")) {
SBOLToMx converter = new SBOLToMx();
converter.toGraph(request.getInputStream(), response.getOutputStream());
Expand Down Expand Up @@ -79,7 +84,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
} catch (SBOLValidationException | IOException | SBOLConversionException | ParserConfigurationException
| TransformerException | SAXException | TransformerFactoryConfigurationError | URISyntaxException | SynBioHubException | javax.xml.stream.XMLStreamException e) {
ServletOutputStream outputStream = response.getOutputStream();
InputStream inputStream = new ByteArrayInputStream(e.getMessage().getBytes());
String message = e.getMessage() != null ? e.getMessage() : "Export failed";
InputStream inputStream = new ByteArrayInputStream(message.getBytes());
IOUtils.copy(inputStream, outputStream);

response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
Expand Down
10 changes: 10 additions & 0 deletions SBOLCanvasBackend/src/servlets/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class Data extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
if (request.getPathInfo() == null) {
response.setStatus(HttpStatus.SC_BAD_REQUEST);
return;
}

// setup the json
Gson gson = new Gson();
String body = null;
Expand Down Expand Up @@ -52,6 +57,11 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
body = gson.toJson(SBOLData.getSimulationConfig());
}

if (body == null) {
response.setStatus(HttpStatus.SC_BAD_REQUEST);
return;
}

// write it to the response body
ServletOutputStream outputStream = response.getOutputStream();
InputStream inputStream = new ByteArrayInputStream(body.getBytes());
Expand Down
2 changes: 1 addition & 1 deletion SBOLCanvasBackend/src/utils/MxToSBML.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ private void createEvents(Model sbmlModel) {
if (eventId == null || eventId.isEmpty()) {
eventId = eventInfo.getDisplayID();
}
Event event = sbmlModel.createEvent(eventId);
Event event = sbmlModel.createEvent(sanitizeId(eventId));
event.setUseValuesFromTriggerTime(false);

// Trigger hardcoded to true. TODO: add conditional triggers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@

.model-section > * {
width: 100%;
}

.config-error {
color: #f44336;
padding: 8px;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div *ngIf="configLoadError && !simulationConfig" class="config-error">
Failed to load simulation fields<br>
from backend.<br>
</div>
<div *ngIf="simulationConfig">
<!-- Glyph Simulation Parameters -->
<div *ngIf="glyphInfo" class="model-menu-container">
Expand Down
24 changes: 12 additions & 12 deletions SBOLCanvasFrontend/src/app/model-editor/model-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class ModelEditorComponent implements OnInit {
glyphInfo: GlyphInfo;
interactionInfo: InteractionInfo;
eventInfo: EventInfo;
simulationConfig: SimulationConfig = {};
simulationConfig: SimulationConfig = null;
configLoadError = false;

validationErrors: { [fieldId: string]: string } = {};

Expand All @@ -100,23 +101,22 @@ export class ModelEditorComponent implements OnInit {
}

getSimulationConfig() {
this.metadataService.loadSimulationConfig().subscribe(config => {
this.simulationConfig = config;
this.metadataService.loadSimulationConfig().subscribe({
next: config => { this.simulationConfig = config; this.configLoadError = false; },
error: () => {
console.warn('Failed to load simulation config from backend');
this.simulationConfig = null;
this.configLoadError = true;
}
});
}

getDefaultValue(roleOrType: string, paramName: string): number {
if (!this.simulationConfig) {
throw new Error('Simulation config not loaded');
}
if (!this.simulationConfig[roleOrType]) {
throw new Error(`No simulation config for: ${roleOrType}`);
if (!this.simulationConfig || !this.simulationConfig[roleOrType]) {
return 0;
}
const value = this.simulationConfig[roleOrType][paramName];
if (value === undefined) {
throw new Error(`No default value for param: ${paramName} in ${roleOrType}`);
}
return value;
return value !== undefined ? value : 0;
}

glyphInfoUpdated(glyphInfo: GlyphInfo) {
Expand Down