Make the persistence method of hanging protocols configurable
- Implement ProtocolStore interface to allow persisting hanging protocols using different strategies - Implement and set default strategy to persist hanging protocols in the MongoDB collection “HangingProtocols” in the application server
This commit is contained in:
1 parent
06412b51bf
commit
77182d1916
17 files changed
+282
-183
No files matched your search
@@ -7,5 +7,8 @@ HangingProtocols.allow({
|
||||
},
|
||||
update: function() {
|
||||
return true;
|
||||
},
|
||||
remove: function() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -1,46 +0,0 @@
|
||||
Router.route('/protocol-export/:_id', function() {
|
||||
var protocolId = this.params._id;
|
||||
var protocol = HangingProtocols.findOne({
|
||||
id: protocolId
|
||||
});
|
||||
|
||||
if (!protocol) {
|
||||
this.response.writeHead(404);
|
||||
|
||||
// This will not actually respond with a 404 because of https://github.com/iron-meteor/iron-router/issues/1055
|
||||
this.response.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the MongoDB _id
|
||||
delete protocol._id;
|
||||
|
||||
var protocolJSON = JSON.stringify(protocol, null, 2),
|
||||
currentDate = new Date(),
|
||||
filename = protocol.name + '-' + (currentDate.getTime().toString()) + '.json';
|
||||
|
||||
this.response.writeHead(200, {
|
||||
'Content-Type': 'application/x-download',
|
||||
'Content-Disposition': 'attachment; filename=' + filename,
|
||||
'Content-Length': protocolJSON.length
|
||||
});
|
||||
|
||||
this.response.end(protocolJSON);
|
||||
}, {
|
||||
where: 'server'
|
||||
});
|
||||
|
||||
Router.route('/protocol-import', {
|
||||
where: 'server'
|
||||
}).post(function() {
|
||||
try {
|
||||
var toImport = JSON.parse(this.request.body.protocol);
|
||||
HangingProtocols.insert(toImport);
|
||||
|
||||
this.response.writeHead(200);
|
||||
this.response.end(toImport.id);
|
||||
} catch(e) {
|
||||
this.response.writeHead(500);
|
||||
this.response.end('Failed to parse protocol JSON.');
|
||||
}
|
||||
});
|
||||
@@ -20,6 +20,7 @@ function getDefaultProtocol() {
|
||||
|
||||
function getMRTwoByTwoTest() {
|
||||
var proto = new HP.Protocol('MR_TwoByTwo');
|
||||
proto.id = 'MR_TwoByTwo';
|
||||
proto.locked = true;
|
||||
// Use http://localhost:3000/viewer/1.2.840.113619.2.5.1762583153.215519.978957063.78
|
||||
|
||||
|
||||
Reference in new issue
Block a user