Skip to content

Commit

Permalink
Add settlement type mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
hugohills-regnosys committed Aug 4, 2023
1 parent 077ab77 commit c3e3b51
Show file tree
Hide file tree
Showing 45 changed files with 462 additions and 363 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

<repoServerHost>oss.sonatype.org</repoServerHost>

<rosetta.bundle.version>7.5.9</rosetta.bundle.version>
<rosetta.bundle.version>7.5.10</rosetta.bundle.version>
<rosetta.code-gen.version>${rosetta.bundle.version}</rosetta.code-gen.version>
<rosetta.dsl.version>8.3.5</rosetta.dsl.version>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cdm.product.common.settlement.processor;

import cdm.product.common.settlement.SettlementTerms;
import cdm.product.common.settlement.SettlementTypeEnum;
import com.regnosys.rosetta.common.translation.Path;
import com.rosetta.model.metafields.FieldWithMetaString;

import java.util.Optional;

public class SettlementTypeHelper {

public void setSettlementType(Path settlementCurrencySynonymPath, SettlementTerms.SettlementTermsBuilder settlementTermsBuilder) {
if (settlementCurrencySynonymPath.endsWith("commoditySwap", "settlementCurrency")
|| settlementCurrencySynonymPath.endsWith("exercise", "settlementCurrency")) {
Optional.ofNullable(settlementTermsBuilder)
.filter(this::settlementCurrencyExists)
.ifPresent(builder -> {
if (builder.getSettlementType() == null) {
builder.setSettlementType(SettlementTypeEnum.CASH);
}
});
}
}

private boolean settlementCurrencyExists(SettlementTerms.SettlementTermsBuilder builder) {
return Optional.ofNullable(builder.getSettlementCurrency()).map(FieldWithMetaString::getValue).isPresent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cdm.product.common.settlement.processor;

import com.regnosys.rosetta.common.translation.MappingContext;
import com.regnosys.rosetta.common.translation.MappingProcessor;
import com.regnosys.rosetta.common.translation.Path;
import com.rosetta.model.lib.RosettaModelObjectBuilder;
import com.rosetta.model.lib.path.RosettaPath;

import java.util.List;
import java.util.Optional;

import static cdm.product.common.settlement.SettlementTerms.SettlementTermsBuilder;

/**
* FpML mapping processor.
*/
@SuppressWarnings("unused")
public class SettlementTypeMappingProcessor extends MappingProcessor {

private final SettlementTypeHelper settlementTypeHelper;

public SettlementTypeMappingProcessor(RosettaPath modelPath, List<Path> synonymPaths, MappingContext context) {
super(modelPath, synonymPaths, context);
this.settlementTypeHelper = new SettlementTypeHelper();
}

@Override
public <T> void mapBasic(Path synonymPath, Optional<T> instance, RosettaModelObjectBuilder parent) {
settlementTypeHelper.setSettlementType(synonymPath, (SettlementTermsBuilder) parent);
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex01-gas-swap-daily-delivery-prices-last.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":4,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex02-gas-swap-prices-first-day.xml","excludedPaths":0,"externalPaths":60,"outstandingMappings":4,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex03-gas-swap-prices-last-three-days.xml","excludedPaths":0,"externalPaths":64,"outstandingMappings":5,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex04-electricity-swap-hourly-off-peak.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":4,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex05-gas-v-electricity-spark-spread.xml","excludedPaths":0,"externalPaths":67,"outstandingMappings":4,"validationFailures":7,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_Basis","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex06-gas-call-option.xml","excludedPaths":0,"externalPaths":61,"outstandingMappings":9,"validationFailures":9,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex07-gas-put-option.xml","excludedPaths":0,"externalPaths":59,"outstandingMappings":9,"validationFailures":9,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex08-oil-call-option-strip.xml","excludedPaths":0,"externalPaths":64,"outstandingMappings":9,"validationFailures":7,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex09-oil-put-option-american.xml","excludedPaths":0,"externalPaths":66,"outstandingMappings":11,"validationFailures":7,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex27-wti-put-option-asian-listedoption-date.xml","excludedPaths":0,"externalPaths":63,"outstandingMappings":11,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex28-gas-swap-daily-delivery-prices-option-last.xml","excludedPaths":0,"externalPaths":66,"outstandingMappings":6,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex01-gas-swap-daily-delivery-prices-last.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":4,"validationFailures":4,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex02-gas-swap-prices-first-day.xml","excludedPaths":0,"externalPaths":60,"outstandingMappings":4,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex03-gas-swap-prices-last-three-days.xml","excludedPaths":0,"externalPaths":64,"outstandingMappings":5,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex04-electricity-swap-hourly-off-peak.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":4,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex05-gas-v-electricity-spark-spread.xml","excludedPaths":0,"externalPaths":67,"outstandingMappings":4,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_Basis","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex06-gas-call-option.xml","excludedPaths":0,"externalPaths":61,"outstandingMappings":9,"validationFailures":8,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex07-gas-put-option.xml","excludedPaths":0,"externalPaths":59,"outstandingMappings":9,"validationFailures":8,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex08-oil-call-option-strip.xml","excludedPaths":0,"externalPaths":64,"outstandingMappings":9,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex09-oil-put-option-american.xml","excludedPaths":0,"externalPaths":66,"outstandingMappings":11,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex27-wti-put-option-asian-listedoption-date.xml","excludedPaths":0,"externalPaths":63,"outstandingMappings":11,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex28-gas-swap-daily-delivery-prices-option-last.xml","excludedPaths":0,"externalPaths":66,"outstandingMappings":6,"validationFailures":4,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex39-basket-option-confirmation.xml","excludedPaths":0,"externalPaths":114,"outstandingMappings":96,"validationFailures":4,"qualificationExpectation":{"success":true,"qualifyResults":[],"qualifiableObjectCount":0}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex41-oil-asian-barrier-option-strip.xml","excludedPaths":0,"externalPaths":83,"outstandingMappings":29,"validationFailures":9,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex46-simple-financial-put-option.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":8,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}}]
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex41-oil-asian-barrier-option-strip.xml","excludedPaths":0,"externalPaths":83,"outstandingMappings":29,"validationFailures":8,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-10/products/commodity/com-ex46-simple-financial-put-option.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":8,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}}]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
{"fileName":"cdm-sample-files/fpml-5-12/products/commodity/com-ex1-gas-swap-daily-delivery-prices-last.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":4,"validationFailures":5,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-12/products/commodity/com-ex5-gas-v-electricity-spark-spread.xml","excludedPaths":0,"externalPaths":67,"outstandingMappings":4,"validationFailures":7,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_Basis","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-12/products/commodity/com-ex8-oil-call-option-strip.xml","excludedPaths":0,"externalPaths":64,"outstandingMappings":9,"validationFailures":7,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}}]
{"fileName":"cdm-sample-files/fpml-5-12/products/commodity/com-ex1-gas-swap-daily-delivery-prices-last.xml","excludedPaths":0,"externalPaths":62,"outstandingMappings":4,"validationFailures":4,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_FixedFloat","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-12/products/commodity/com-ex5-gas-v-electricity-spark-spread.xml","excludedPaths":0,"externalPaths":67,"outstandingMappings":4,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Swap_Basis","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}},
{"fileName":"cdm-sample-files/fpml-5-12/products/commodity/com-ex8-oil-call-option-strip.xml","excludedPaths":0,"externalPaths":64,"outstandingMappings":9,"validationFailures":6,"qualificationExpectation":{"success":true,"qualifyResults":[{"qualifiedName":"Commodity_Option","qualifiedObjectClass":"cdm.product.template.EconomicTerms"}],"qualifiableObjectCount":1}}]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"meta" : {
"globalKey" : "6dc04898"
"globalKey" : "d4e0c05"
},
"trade" : {
"contractDetails" : {
Expand Down Expand Up @@ -34,7 +34,7 @@
}
},
"meta" : {
"globalKey" : "6dc04898"
"globalKey" : "d4e0c05"
},
"party" : [ {
"meta" : {
Expand Down Expand Up @@ -119,14 +119,15 @@
},
"settlementTerms" : {
"meta" : {
"globalKey" : "14966"
"globalKey" : "7610bbd9"
},
"settlementCurrency" : {
"value" : "USD"
}
},
"settlementType" : "CASH"
},
"meta" : {
"globalKey" : "cf7d9ddc"
"globalKey" : "f7f45f67"
},
"pricingDates" : {
"parametricDates" : {
Expand All @@ -147,7 +148,7 @@
}
} ],
"meta" : {
"globalKey" : "cf7d9ddc"
"globalKey" : "f7f45f67"
}
},
"terminationDate" : {
Expand All @@ -169,11 +170,11 @@
}
},
"meta" : {
"globalKey" : "641e159"
"globalKey" : "d4ee1656"
}
},
"meta" : {
"globalKey" : "641e159"
"globalKey" : "d4ee1656"
}
},
"tradeLot" : [ {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"meta" : {
"globalKey" : "26160b23"
"globalKey" : "abc778a8"
},
"trade" : {
"contractDetails" : {
Expand Down Expand Up @@ -34,7 +34,7 @@
}
},
"meta" : {
"globalKey" : "26160b23"
"globalKey" : "abc778a8"
},
"party" : [ {
"meta" : {
Expand Down Expand Up @@ -115,14 +115,15 @@
"commodityPayout" : [ {
"settlementTerms" : {
"meta" : {
"globalKey" : "14966"
"globalKey" : "7610bbd9"
},
"settlementCurrency" : {
"value" : "USD"
}
},
"settlementType" : "CASH"
},
"meta" : {
"globalKey" : "14966"
"globalKey" : "7610bbd9"
}
} ],
"fixedPricePayout" : [ {
Expand All @@ -143,7 +144,7 @@
}
} ],
"meta" : {
"globalKey" : "c9b3e779"
"globalKey" : "11b904e6"
}
},
"terminationDate" : {
Expand All @@ -165,11 +166,11 @@
}
},
"meta" : {
"globalKey" : "c7422745"
"globalKey" : "eb01e050"
}
},
"meta" : {
"globalKey" : "c7422745"
"globalKey" : "eb01e050"
}
},
"tradeLot" : [ {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"meta" : {
"globalKey" : "bcf466bb"
"globalKey" : "b627eec0"
},
"trade" : {
"contractDetails" : {
Expand Down Expand Up @@ -34,7 +34,7 @@
}
},
"meta" : {
"globalKey" : "bcf466bb"
"globalKey" : "b627eec0"
},
"party" : [ {
"meta" : {
Expand Down Expand Up @@ -115,14 +115,15 @@
"commodityPayout" : [ {
"settlementTerms" : {
"meta" : {
"globalKey" : "10da2"
"globalKey" : "76108015"
},
"settlementCurrency" : {
"value" : "EUR"
}
},
"settlementType" : "CASH"
},
"meta" : {
"globalKey" : "10da2"
"globalKey" : "76108015"
}
} ],
"fixedPricePayout" : [ {
Expand All @@ -143,7 +144,7 @@
}
} ],
"meta" : {
"globalKey" : "cd5168bd"
"globalKey" : "1556862a"
}
},
"terminationDate" : {
Expand All @@ -165,11 +166,11 @@
}
},
"meta" : {
"globalKey" : "5c977881"
"globalKey" : "21b7a70c"
}
},
"meta" : {
"globalKey" : "5c977881"
"globalKey" : "21b7a70c"
}
},
"tradeLot" : [ {
Expand Down
Loading

0 comments on commit c3e3b51

Please sign in to comment.