package gw.riskassessment uses gw.api.locale.DisplayKey uses gw.api.system.PCConfigParameters uses gw.api.util.DisplayableException uses gw.plugin.Plugins uses gw.plugin.policylocation.RiskAssessmentErrorCollector uses gw.plugin.policylocation.LocationRiskAssessmentParameters uses gw.plugin.policylocation.LocationRiskAssessmentPlugin /** * Gateway for using Risk Assessment communication, and actions. */ @ReadOnly class PolicyLocationRiskAssessmentGateway { var _errorCollector: RiskAssessmentErrorCollector var _riskAssessmentPlugin: LocationRiskAssessmentPlugin construct(errorCollector : RiskAssessmentErrorCollector) { _errorCollector = errorCollector if (not Plugins.isEnabled(LocationRiskAssessmentPlugin)) { throw new DisplayableException(DisplayKey.get("Web.RiskAssessment.Integration.PluginNotEnabled")) } _riskAssessmentPlugin = Plugins.get(LocationRiskAssessmentPlugin) if (_riskAssessmentPlugin == null) { throw new DisplayableException(DisplayKey.get("Web.RiskAssessment.Integration.PluginNotEnabled")) } } function getRiskAssessmentResultsForLocation(params : LocationRiskAssessmentParameters) : InboundLocationRiskAssessmentTempStore { var result: InboundLocationRiskAssessmentTempStore if (params != null) { params.LocationGeoCodeMap.Keys.each(\locationData -> { if (not(PCConfigParameters.RiskAssessmentIntegrationEnabled.Value and PCConfigParameters.SingleLocationRiskAssessmentEnabled.Value)) { _errorCollector.addRequestError(locationData.OutboundPeriodRiskAssessmentTempStore, RiskAssessmentError.TC_LACKSSINGLELOCATIONRISKASSESSMENTPERMISSION) } else { result = _riskAssessmentPlugin.getRiskAssessmentResultsForPeriod(locationData.OutboundPeriodRiskAssessmentTempStore, params, _errorCollector)?.first() } }) } return result } function navigateToRiskAssessmentSystem(parameters : List) { if (PCConfigParameters.RiskAssessmentIntegrationEnabled.Value) { _riskAssessmentPlugin.navigateToRiskAssessmentSystem(parameters) } else { throw new DisplayableException(DisplayKey.get("Web.RiskAssessment.Integration.InsufficientPermissions")) } } function acceptRiskAssessmentInboundData(policyLocation : PolicyLocation, inboundData : InboundLocationRiskAssessmentTempStore) { var assessment = new LocationRiskAssessment(policyLocation.Branch) assessment.copyRiskAssessmentData(inboundData) assessment.InputChecksum = _riskAssessmentPlugin.getRiskAssessmentDataHash(inboundData.OutboundLocationRiskAssessmentTempStore).computeHash() policyLocation.addToLocationRiskAssessments(assessment) } function callRiskAssessmentServiceAndAcceptResult(outboundTempStore : OutboundPeriodRiskAssessmentTempStore, params: LocationRiskAssessmentParameters) { var result: List if (PCConfigParameters.RiskAssessmentIntegrationEnabled.Value and PCConfigParameters.MultipleLocationRiskAssessmentEnabled.Value) { result = _riskAssessmentPlugin.getRiskAssessmentResultsForPeriod(outboundTempStore, params, _errorCollector) } else { _errorCollector.addRequestError(outboundTempStore, RiskAssessmentError.TC_LACKSMULTIPLELOCATIONRISKASSESSMENTPERMISSION) } if (not _errorCollector.hasErrors()) { result.each(\inboundRiskAssessment -> { acceptRiskAssessmentInboundData(inboundRiskAssessment.OutboundLocationRiskAssessmentTempStore.PolicyLocation, inboundRiskAssessment) }) } } }