package gw.rating.rtm.valueprovider uses gw.api.productmodel.PolicyLinePattern uses gw.rating.flow.domain.CoverageQueryParameterSource uses gw.api.productmodel.PolicyLinePatternLookup uses gw.api.productmodel.ProductModelClass uses gw.api.system.PCDependenciesGateway /** * An abstract base class for any kind of value provider that pulls data from PC product model. */ abstract class AbstractProductModelValueProvider extends RateTableCellValueProvider implements CoverageQueryParameterSource { private var _policyLinePattern : PolicyLinePattern as PolicyLinePattern construct(column : RateTableColumn) { super(column) _policyLinePattern = PolicyLinePatternLookup.getByPublicID(column.Definition.PolicyLine) } static function removeQuotes(src : String[]) : String[] { src.eachWithIndex(\ s,idx -> { s = s.trim() if (s.startsWith("\"") and s.endsWith("\"")) { src[idx] = s.substring(1, s.length() - 1) } }) return src } /** * Converts a product model code identifier to its associated public id. * * @param codeId the code identifier to convert * @return the public id associated with the specified code identifier * @throws InvalidCodeIdentifierException if the specified code identifier is not valid */ override function convertCodeIdentifierToPublicID(codeId: String): String { var publicId = PCDependenciesGateway.getProductModel().getPublicIdForCodeIdentifier(codeId, this.ProductModelType) if (publicId == null) { throw new InvalidCodeIdentifierException("Conversion to public id failed due to invalid code identifier: ${codeId}", codeId) } return publicId } override function convertPublicIDToCodeIdentifier(str : String) : String { var codeIdentifier = PCDependenciesGateway.getProductModel().getPattern(str, this.ProductModelType).CodeIdentifier return codeIdentifier ?: str } abstract property get ProductModelType() : Type }