// Check the valuation parameters are compatible
if (!getExecutionSequence().equals(other.getExecutionSequence())) {
return null;
}
// Check the basic view definitions are compatible
final ViewDefinition myView = getViewDefinition();
final ViewDefinition otherView = other.getViewDefinition();
if (!ObjectUtils.equals(myView.getDefaultCurrency(), otherView.getDefaultCurrency())
|| !ObjectUtils.equals(myView.getMarketDataUser(), otherView.getMarketDataUser())
|| !ObjectUtils.equals(myView.getMaxDeltaCalculationPeriod(), otherView.getMaxDeltaCalculationPeriod())
|| !ObjectUtils.equals(myView.getMaxFullCalculationPeriod(), otherView.getMaxFullCalculationPeriod())
|| !ObjectUtils.equals(myView.getMinDeltaCalculationPeriod(), otherView.getMinDeltaCalculationPeriod())
|| !ObjectUtils.equals(myView.getMinFullCalculationPeriod(), otherView.getMinFullCalculationPeriod())
|| !ObjectUtils.equals(myView.getName(), otherView.getName())
|| !ObjectUtils.equals(myView.getPortfolioId(), otherView.getPortfolioId())
|| !ObjectUtils.equals(myView.getResultModelDefinition(), otherView.getResultModelDefinition())) {
return null;
}
// Check the calc configs are compatible
for (final ViewCalculationConfiguration myConfig : myView.getAllCalculationConfigurations()) {
final ViewCalculationConfiguration otherConfig = otherView.getCalculationConfiguration(myConfig.getName());
if (!ObjectUtils.equals(myConfig.getDefaultProperties(), otherConfig.getDefaultProperties())
|| !ObjectUtils.equals(myConfig.getDeltaDefinition(), otherConfig.getDeltaDefinition())
|| !ObjectUtils.equals(myConfig.getResolutionRuleTransform(), otherConfig.getResolutionRuleTransform())) {
// Configs aren't compatible
return null;
}
}
// Create a new view definition that is the union of all calc configs
final ViewDefinition newView = myView.copyWith(myView.getName(), myView.getPortfolioId(), myView.getMarketDataUser());
for (final ViewCalculationConfiguration otherConfig : otherView.getAllCalculationConfigurations()) {
final ViewCalculationConfiguration newConfig = newView.getCalculationConfiguration(otherConfig.getName());
if (newConfig == null) {
myView.addViewCalculationConfiguration(newConfig);
} else {
newConfig.addSpecificRequirements(otherConfig.getSpecificRequirements());
}