23
23
import org .slf4j .Logger ;
24
24
import org .slf4j .LoggerFactory ;
25
25
import org .springframework .beans .factory .annotation .Value ;
26
+ import org .springframework .boot .info .BuildProperties ;
26
27
import org .springframework .core .io .Resource ;
27
28
import org .springframework .http .HttpStatus ;
28
29
import org .springframework .http .ProblemDetail ;
@@ -79,13 +80,15 @@ public class PlainSwapEditorController implements PlainSwapEditorApi {
79
80
private final ResourceGovernor resourceGovernor ;
80
81
private final ObjectMapper objectMapper ;
81
82
private final ValuationConfig valuationConfig ;
83
+ private final BuildProperties buildProperties ;
82
84
83
- public PlainSwapEditorController (DatabaseConnector databaseConnector , ResourceGovernor resourceGovernor , ObjectMapper objectMapper , ValuationConfig valuationConfig , ValuationConfig valuationConfig1 ) {
85
+ public PlainSwapEditorController (DatabaseConnector databaseConnector , ResourceGovernor resourceGovernor , ObjectMapper objectMapper , ValuationConfig valuationConfig , ValuationConfig valuationConfig1 , BuildProperties buildProperties ) {
84
86
this .databaseConnector = databaseConnector ;
85
87
this .resourceGovernor = resourceGovernor ;
86
88
this .objectMapper = objectMapper ;
87
89
this .schemaPath = valuationConfig .getFpmlSchemaPath ();
88
90
this .valuationConfig = valuationConfig1 ;
91
+ this .buildProperties = buildProperties ;
89
92
}
90
93
91
94
/**
@@ -101,7 +104,8 @@ public ResponseEntity<String> generatePlainSwapSdcml(PlainSwapOperationRequest p
101
104
String currentGenerator = identifyCurrentGenerator (plainSwapOperationRequest .getMarketDataProvider ());
102
105
return ResponseEntity .ok (new PlainSwapEditorHandler (plainSwapOperationRequest ,
103
106
currentGenerator ,
104
- schemaPath ).getContractAsXmlString ());
107
+ schemaPath ,
108
+ buildProperties .getVersion ()).getContractAsXmlString ());
105
109
} catch (JAXBException | IOException | DatatypeConfigurationException | SAXException e ) {
106
110
/*
107
111
You may see this recurring snippet of code in other controller methods as well. Its goal is to report the stack
@@ -135,7 +139,8 @@ public ResponseEntity<ValueResult> evaluateFromPlainSwapEditor(PlainSwapOperatio
135
139
String currentGenerator = identifyCurrentGenerator (plainSwapOperationRequest .getMarketDataProvider ());
136
140
sdcmlBody = new PlainSwapEditorHandler (plainSwapOperationRequest ,
137
141
currentGenerator ,
138
- schemaPath ).getContractAsXmlString ();
142
+ schemaPath ,
143
+ buildProperties .getVersion ()).getContractAsXmlString ();
139
144
} catch (JAXBException | IOException | DatatypeConfigurationException | SAXException e ) {
140
145
ProblemDetail pd = ProblemDetail .forStatusAndDetail (HttpStatus .INTERNAL_SERVER_ERROR ,
141
146
ErrorDetails .JAXB_ERROR_DETAIL );
@@ -201,7 +206,8 @@ public ResponseEntity<List<CashflowPeriod>> getFixedSchedule(PlainSwapOperationR
201
206
String currentGenerator = identifyCurrentGenerator (plainSwapOperationRequest .getMarketDataProvider ());
202
207
return ResponseEntity .ok (new PlainSwapEditorHandler (plainSwapOperationRequest ,
203
208
currentGenerator ,
204
- schemaPath ).getSchedule (
209
+ schemaPath ,
210
+ buildProperties .getVersion ()).getSchedule (
205
211
PlainSwapEditorHandler .LegSelector .FIXED_LEG , marketData ));
206
212
} catch (JAXBException | IOException | DatatypeConfigurationException | SAXException e ) {
207
213
ProblemDetail pd = ProblemDetail .forStatusAndDetail (HttpStatus .INTERNAL_SERVER_ERROR ,
@@ -246,7 +252,8 @@ public ResponseEntity<List<CashflowPeriod>> getFloatingSchedule(PlainSwapOperati
246
252
String currentGenerator = identifyCurrentGenerator (plainSwapOperationRequest .getMarketDataProvider ());
247
253
return ResponseEntity .ok (new PlainSwapEditorHandler (plainSwapOperationRequest ,
248
254
currentGenerator ,
249
- schemaPath ).getSchedule (
255
+ schemaPath ,
256
+ buildProperties .getVersion ()).getSchedule (
250
257
PlainSwapEditorHandler .LegSelector .FLOATING_LEG , marketData ));
251
258
} catch (JAXBException | IOException | DatatypeConfigurationException | SAXException e ) {
252
259
ProblemDetail pd = ProblemDetail .forStatusAndDetail (HttpStatus .INTERNAL_SERVER_ERROR ,
@@ -312,7 +319,8 @@ public ResponseEntity<ValueResult> refreshMarketData(PlainSwapOperationRequest p
312
319
String currentGenerator = identifyCurrentGenerator (plainSwapOperationRequest .getMarketDataProvider ());
313
320
sdc = SDCXMLParser .parse (new PlainSwapEditorHandler (plainSwapOperationRequest ,
314
321
currentGenerator ,
315
- schemaPath ).getContractAsXmlString ());
322
+ schemaPath ,
323
+ buildProperties .getVersion ()).getContractAsXmlString ());
316
324
} catch (IOException e ) {
317
325
ProblemDetail pd = ProblemDetail .forStatusAndDetail (HttpStatus .INTERNAL_SERVER_ERROR ,
318
326
ErrorDetails .STORAGE_ERROR_DETAIL );
@@ -455,7 +463,7 @@ public ResponseEntity<Double> getParRate(PlainSwapOperationRequest plainSwapOper
455
463
String currentGenerator = identifyCurrentGenerator (plainSwapOperationRequest .getMarketDataProvider ());
456
464
return (new MarginCalculator ()).getValue (marketDataString , new PlainSwapEditorHandler (
457
465
plainSwapOperationRequest .notionalAmount (1E15 ),
458
- currentGenerator , schemaPath ).getContractAsXmlString ())
466
+ currentGenerator , schemaPath , buildProperties . getVersion () ).getContractAsXmlString ())
459
467
.getValue ().doubleValue ();
460
468
} catch (Exception e ) {
461
469
ProblemDetail pd = ProblemDetail .forStatusAndDetail (HttpStatus .INTERNAL_SERVER_ERROR ,
0 commit comments