diff --git a/app/controllers/rtb/RequestSimulatorServiceApiController.scala b/app/controllers/rtb/RequestSimulatorServiceApiController.scala index 8deb260..adb1fdc 100644 --- a/app/controllers/rtb/RequestSimulatorServiceApiController.scala +++ b/app/controllers/rtb/RequestSimulatorServiceApiController.scala @@ -5,15 +5,13 @@ import play.api.mvc._ import shared.com.ortb.controllers.core.AbstractBaseSimulatorServiceApiController import shared.com.ortb.manager.AppManager import shared.com.ortb.model.config._ -import shared.com.ortb.persistent.Repositories import shared.io.helpers.{ FileHelper, JsonHelper } import shared.io.loggers._ class RequestSimulatorServiceApiController @Inject()( - repositories : Repositories, appManager : AppManager, components : ControllerComponents) - extends AbstractBaseSimulatorServiceApiController(repositories, appManager, components) { + extends AbstractBaseSimulatorServiceApiController(appManager, components) { lazy val currentServiceModel : ServiceModel = services.requestSimulatorService lazy val jsonDirectory = "jsonRequestSamples" @@ -21,7 +19,7 @@ class RequestSimulatorServiceApiController @Inject()( def getAvailableCommands : Action[AnyContent] = Action { implicit request => try { val jsonString = JsonHelper.toJson(selfProperties.currentServiceModel.routing).get.toString() - selfProperties.restWebApiOkJson.OkJson(jsonString) + selfProperties.restWebApiOkJson.okJson(jsonString) } catch { case e : Exception => AppLogger.error(e) @@ -36,7 +34,7 @@ class RequestSimulatorServiceApiController @Inject()( "requests", s"${ bannerSuffix }-bid-request.json") - selfProperties.restWebApiOkJson.OkJson(jsonString) + selfProperties.restWebApiOkJson.okJson(jsonString) } catch { case e : Exception => AppLogger.error(e) diff --git a/app/shared/com/ortb/constants/AppConstants.scala b/app/shared/com/ortb/constants/AppConstants.scala index 68a3fde..b0b5115 100644 --- a/app/shared/com/ortb/constants/AppConstants.scala +++ b/app/shared/com/ortb/constants/AppConstants.scala @@ -3,6 +3,7 @@ package shared.com.ortb.constants import shared.com.ortb.manager.AppManager import shared.com.ortb.persistent.Repositories + object AppConstants { /** @@ -59,7 +60,17 @@ object AppConstants { /** * System.lineSeparator */ - lazy val NewLine : String = System.lineSeparator + lazy val SystemNewLine : String = System.lineSeparator + + /** + * '\n' + */ + lazy val NewLine : Char = '\n' + + /** + * '\t' + */ + lazy val Tab : Char = '\t' lazy val DoubleSpace : String = " " @@ -80,11 +91,12 @@ object AppConstants { lazy val DefaultDateTimeFormatPattern = "MM/dd/yyyy HH:mm:ss" lazy val DefaultDateFormatPattern = "MM/dd/yyyy" + lazy val IsThrownOnFailed = true /** * "=${NewLine}" */ - lazy val LogEqualNewLine : String = s"${ EqualSign }${ NewLine }" + lazy val LogEqualNewLine : String = s"${ EqualSign }${ SystemNewLine }" /** * "=${NewLine}${DoubleSpace}" @@ -94,4 +106,5 @@ object AppConstants { lazy val AppManager : AppManager = new AppManager lazy val Repositories : Repositories = new Repositories(AppManager) + lazy val biddingConstants = new BiddingConstants } diff --git a/app/shared/com/ortb/constants/BiddingConstants.scala b/app/shared/com/ortb/constants/BiddingConstants.scala new file mode 100644 index 0000000..aec0e42 --- /dev/null +++ b/app/shared/com/ortb/constants/BiddingConstants.scala @@ -0,0 +1,44 @@ +package shared.com.ortb.constants + +import shared.com.ortb.model.auctionbid.bidresponses.BidModel +import shared.io.extensions.TypeConvertExtensions._ + +sealed class BiddingConstants { + lazy val aDomains = List( + "Advertiser blocked domains list", + "Sample-Site-blocked.com", + "Sample-Site2-blocked.com", + "Sample-Site3-blocked.com") + + lazy val staticBidModel : BidModel = BidModel( + "static:bidId", + "-1", + 0, + "static:Advertise Id".toSome, + None, + "adm win-notice markup, optional and should be ignored.".toSome, + aDomains.toSome, + "iurl : uncached image link".toSome, + "static: CampaignId".toSome, + List("static: categoryId1", "static: categoryId2").toSome, + "static: dealId".toSome, + h = None, + w = None + ) + + /** + * HTTP 204 “No Content” from the bidder (most economical in terms of bandwidth). + *  An empty JSON object: {} + *  A well-formed no bid response: {"id": "1234567890", "seatbid": []} + *  A well-formed no bid response with a reason code: {"id": "1234567890", "seatbid": [], "nbr": 2} + */ + lazy val emptyStaticBidResponse = "{\"id\": \"\", \"seatbid\": []}" + + /** + * HTTP 204 “No Content” from the bidder (most economical in terms of bandwidth). + *  An empty JSON object: {} + *  A well-formed no bid response: {"id": "1234567890", "seatbid": []} + *  A well-formed no bid response with a reason code: {"id": "1234567890", "seatbid": [], "nbr": 2} + */ + lazy val emptyStaticBidResponseWithNoBidResponseCodeUnknown = "{\"id\": \"\", \"seatbid\": [], \"nbr\": 0}" +} diff --git a/app/shared/com/ortb/controllers/core/AbstractBaseSimulatorServiceApiController.scala b/app/shared/com/ortb/controllers/core/AbstractBaseSimulatorServiceApiController.scala index 2b6509b..9b8cfa0 100644 --- a/app/shared/com/ortb/controllers/core/AbstractBaseSimulatorServiceApiController.scala +++ b/app/shared/com/ortb/controllers/core/AbstractBaseSimulatorServiceApiController.scala @@ -1,6 +1,6 @@ package shared.com.ortb.controllers.core -import shared.com.ortb.controllers.implementations.{ RestWebApiOkJsonImplementation, ServiceControllerPropertiesContractsImplementation } +import shared.com.ortb.controllers.implementations.{ RestWebApiOkImplementation, ServiceControllerPropertiesContractsImplementation } import shared.com.ortb.controllers.traits.properties.ServiceControllerCorePropertiesContracts import javax.inject.Inject import play.api.Logger @@ -12,13 +12,12 @@ import shared.com.ortb.persistent.Repositories import shared.io.loggers.AppLogger abstract class AbstractBaseSimulatorServiceApiController @Inject()( - repositories : Repositories, appManager : AppManager, components : ControllerComponents) - extends ServiceBaseApiController(repositories, appManager, components) + extends ServiceBaseApiController(appManager, components) with ServiceControllerCorePropertiesContracts { val currentServiceModel : ServiceModel - lazy override val restWebApiOkJson : RestWebApiOkJsonImplementation = selfProperties.restWebApiOkJson + lazy override val restWebApiOkJson : RestWebApiOkImplementation = selfProperties.restWebApiOkJson lazy override val serviceTitle : String = currentServiceModel.title lazy val config : ConfigModel = appManager.config lazy val services : ServicesModel = config.server.services @@ -28,7 +27,7 @@ abstract class AbstractBaseSimulatorServiceApiController @Inject()( def getServiceName : Action[AnyContent] = Action { implicit request => try { - selfProperties.restWebApiOkJson.OkJson(selfProperties.serviceTitle) + selfProperties.restWebApiOkJson.okJson(selfProperties.serviceTitle) } catch { case e : Exception => handleError(e) diff --git a/app/shared/com/ortb/controllers/core/ServiceBaseApiController.scala b/app/shared/com/ortb/controllers/core/ServiceBaseApiController.scala index 93a965b..ecc5938 100644 --- a/app/shared/com/ortb/controllers/core/ServiceBaseApiController.scala +++ b/app/shared/com/ortb/controllers/core/ServiceBaseApiController.scala @@ -9,7 +9,6 @@ import shared.com.ortb.model.config.ServiceModel import shared.com.ortb.persistent.Repositories class ServiceBaseApiController @Inject()( - val repositories : Repositories, val appManager : AppManager, components : ControllerComponents) extends AbstractController(components) diff --git a/app/shared/com/ortb/controllers/implementations/RestWebApiOkImplementation.scala b/app/shared/com/ortb/controllers/implementations/RestWebApiOkImplementation.scala new file mode 100644 index 0000000..81754e2 --- /dev/null +++ b/app/shared/com/ortb/controllers/implementations/RestWebApiOkImplementation.scala @@ -0,0 +1,49 @@ +package shared.com.ortb.controllers.implementations + +import akka.util.ByteString +import play.api.http.{ HttpEntity, Status } +import play.api.mvc.{ AbstractController, ResponseHeader, Result } +import play.mvc.Http.MimeTypes +import shared.io.extensions.TypeConvertExtensions._ + +class RestWebApiOkImplementation(controller : AbstractController) { + def okJson(jsonString : String) : Result = controller.Ok(jsonString).as(MimeTypes.JSON) + + lazy val noContent : Result = controller.NoContent.as(MimeTypes.JSON) + + def okJsonWithStatus( + jsonString : String, + statusCode : Int = Status.OK, + contentType : String = MimeTypes.JSON + ) : Result = okJsonWithHeader( + jsonString, + ResponseHeader(statusCode), + contentType) + + def okTextWithStatus( + jsonString : String, + statusCode : Int = Status.OK, + contentType : String = MimeTypes.TEXT + ) : Result = okJsonWithHeader( + jsonString, + ResponseHeader(statusCode), + contentType) + + def okJsonWithHeader( + jsonString : String, + responseHeader : ResponseHeader = ResponseHeader(Status.OK), + contentType : String = MimeTypes.JSON + ) : Result = Result( + header = responseHeader, + body = HttpEntity.Strict(ByteString(jsonString), contentType.toSome) + ) + + def okHtmlWithStatus( + jsonString : String, + statusCode : Int = Status.OK, + contentType : String = MimeTypes.HTML + ) : Result = okJsonWithHeader( + jsonString, + ResponseHeader(statusCode), + contentType) +} diff --git a/app/shared/com/ortb/controllers/implementations/RestWebApiOkJsonImplementation.scala b/app/shared/com/ortb/controllers/implementations/RestWebApiOkJsonImplementation.scala deleted file mode 100644 index aad36a7..0000000 --- a/app/shared/com/ortb/controllers/implementations/RestWebApiOkJsonImplementation.scala +++ /dev/null @@ -1,8 +0,0 @@ -package shared.com.ortb.controllers.implementations - -import play.api.mvc.{ AbstractController, Result } -import play.mvc.Http.MimeTypes - -class RestWebApiOkJsonImplementation(controller : AbstractController) { - def OkJson(jsonString : String) : Result = controller.Ok(jsonString).as(MimeTypes.JSON) -} diff --git a/app/shared/com/ortb/controllers/implementations/ServiceControllerPropertiesContractsImplementation.scala b/app/shared/com/ortb/controllers/implementations/ServiceControllerPropertiesContractsImplementation.scala index 003dd3f..834e65b 100644 --- a/app/shared/com/ortb/controllers/implementations/ServiceControllerPropertiesContractsImplementation.scala +++ b/app/shared/com/ortb/controllers/implementations/ServiceControllerPropertiesContractsImplementation.scala @@ -12,7 +12,7 @@ class ServiceControllerPropertiesContractsImplementation (val serviceBaseApiController : ServiceBaseApiController, val serviceModelInstance : ServiceModel) extends ServiceControllerCorePropertiesContracts { EmptyValidateHelper.throwOnNullOrNoneOrNil(serviceModelInstance) - lazy val restWebApiOkJson = new RestWebApiOkJsonImplementation(serviceBaseApiController) + lazy val restWebApiOkJson = new RestWebApiOkImplementation(serviceBaseApiController) lazy val config : ConfigModel = appManager.config lazy val serviceTitle : String = serviceModelInstance.title lazy override val appManager : AppManager = serviceBaseApiController.appManager diff --git a/app/shared/com/ortb/controllers/traits/properties/ServiceControllerCorePropertiesContracts.scala b/app/shared/com/ortb/controllers/traits/properties/ServiceControllerCorePropertiesContracts.scala index 4758485..76d39cf 100644 --- a/app/shared/com/ortb/controllers/traits/properties/ServiceControllerCorePropertiesContracts.scala +++ b/app/shared/com/ortb/controllers/traits/properties/ServiceControllerCorePropertiesContracts.scala @@ -1,6 +1,6 @@ package shared.com.ortb.controllers.traits.properties -import shared.com.ortb.controllers.implementations.RestWebApiOkJsonImplementation +import shared.com.ortb.controllers.implementations.RestWebApiOkImplementation import play.api.Logger import shared.com.ortb.manager.AppManager import shared.com.ortb.model.config.{ ConfigModel, DemandSidePlatformConfigurationModel, ServiceModel, ServicesModel } @@ -12,7 +12,7 @@ trait ServiceControllerCorePropertiesContracts { val selfProperties : ServiceControllerCorePropertiesContracts val currentServiceModel : ServiceModel val appManager : AppManager - val restWebApiOkJson : RestWebApiOkJsonImplementation + val restWebApiOkJson : RestWebApiOkImplementation val serviceTitle : String val logger : Logger val databaseLogger : DatabaseLogTracer diff --git a/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformBiddingAgent.scala b/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformBiddingAgent.scala index 0c6ea7c..2d92851 100644 --- a/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformBiddingAgent.scala +++ b/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformBiddingAgent.scala @@ -1,5 +1,7 @@ package shared.com.ortb.demadSidePlatforms +import com.github.dwickern.macros.NameOf._ +import io.circe.generic.auto._ import shared.com.ortb.constants.AppConstants import shared.com.ortb.demadSidePlatforms.traits.getters._ import shared.com.ortb.demadSidePlatforms.traits.logics._ @@ -8,11 +10,14 @@ import shared.com.ortb.demadSidePlatforms.traits.{ AddNewAdvertiseOnNotFound, De import shared.com.ortb.enumeration.DemandSidePlatformBiddingAlgorithmType.DemandSidePlatformBiddingAlgorithmType import shared.com.ortb.enumeration.NoBidResponseType import shared.com.ortb.manager.traits.CreateDefaultContext -import shared.com.ortb.model.auctionbid.bidresponses.{ BidResponseModel, BidResponseModelWrapper } +import shared.com.ortb.model.auctionbid.biddingRequests.BidRequestModel +import shared.com.ortb.model.auctionbid.bidresponses.{ BidModel, BidResponseModel, BidResponseModelWrapper, SeatBidModel } import shared.com.ortb.model.auctionbid.{ DemandSidePlatformBidResponseModel, ImpressionDealModel } import shared.com.ortb.model.config.DemandSidePlatformConfigurationModel import shared.com.ortb.model.results.DemandSidePlatformBiddingRequestWrapperModel +import shared.com.ortb.persistent.schema.Tables import shared.com.ortb.persistent.schema.Tables._ +import shared.io.extensions.TypeConvertExtensions._ import shared.io.helpers.{ EmptyValidateHelper, JodaDateTimeHelper } import scala.concurrent.ExecutionContext @@ -108,7 +113,7 @@ class DemandSidePlatformBiddingAgent( bidRequestId, bidResponseId, auctionId, - Some(coreProperties.demandSideId), + coreProperties.demandSideId.toSome, createddatetimestamp = JodaDateTimeHelper.nowUtcJavaInstant ) @@ -127,11 +132,12 @@ class DemandSidePlatformBiddingAgent( val bidRepository = coreProperties .repositories .bidRepository - impressionDeals.get.foreach(impressionDeal => { + + val bids = impressionDeals.get.map(impressionDeal => { // TODO : create bid val impressionId = impressionDeal.impression.id.toInt val impressionToString = s", ImpressionDealModel(${ ImpressionDealModel.toString() })" - val advertiseId = Some(impressionDeal.advertise.advertiseid) + val advertiseId = impressionDeal.advertise.advertiseid.toSome val campaignId = 5 val minMaxHeightWidth = impressionDeal .impression @@ -139,26 +145,42 @@ class DemandSidePlatformBiddingAgent( val bid = BidRow( AppConstants.NewRecordIntId, - dealbiddingprice = Some(impressionDeal.deal), + dealbiddingprice = impressionDeal.deal.toSome, seatbidid = seatBidId.get, - campaignid = Some(campaignId), - impressionid = Some(impressionId), + campaignid = campaignId.toSome, + impressionid = impressionId.toSome, advertiseid = advertiseId, - adm = Some(s"adm $impressionToString"), - iurl = Some(s"iurl $impressionToString"), + adm = s"adm $impressionToString".toSome, + iurl = s"iurl $impressionToString".toSome, height = minMaxHeightWidth.maybeHeight, width = minMaxHeightWidth.maybeWidth, createddatetimestamp = JodaDateTimeHelper.nowUtcJavaInstant ) - bidRepository.addAsync(bid) + val createdBid = bidRepository.add(bid).row + + BidModel( + createdBid.bidid.toString, + impressionDeal.impression.id, + impressionDeal.deal, + bid.advertiseid.toStringOption, + bid.nurl, + bid.adm, + None, + bid.iurl, bid.campaignid.toStringOption, + None, + None, + None, + None) }) + val seatBids = Some(List(SeatBidModel(bids, seatBidId.toStringOption))) + val bidResponse2 = BidResponseModel( bidResponseId.toString, - None, - None, - nbr = Some(NoBidResponseType.UnknownError.value)) + seatBids, + coreProperties.demandSideId.toStringOption, + nbr = None) val bidResponseWrapper = BidResponseModelWrapper(Some(bidResponse2)) val demandSidePlatformBidResponse = DemandSidePlatformBidResponseModel( @@ -200,16 +222,22 @@ class DemandSidePlatformBiddingAgent( } def addBidResponseAsync(response : DemandSidePlatformBidResponseModel) : Unit = { + if (isStatic) { + // Don't perform database transaction during static mode + return + } + + val methodName = nameOf(addBidResponseAsync _) if (EmptyValidateHelper.isEmptyDirect( response, - Some("addBidResponse, given response is empty. Nothing to save."))) { + Some(s"$methodName, given response is empty. Nothing to save."))) { return } val bidResponse = response.bidResponseWrapper.bidResponse if (EmptyValidateHelper.isEmpty( bidResponse, - Some("addBidResponse, given bidResponse is empty. Nothing to save."))) { + Some(s"$methodName, given bidResponse is empty. Nothing to save."))) { // create no bid response createNoBidResponseToDbAsync() return @@ -223,4 +251,66 @@ class DemandSidePlatformBiddingAgent( bidResponseRepository.addAsync(bidResponseRow) } + + override def getActualBidRequestToBidRequestRow(bidRequest : BidRequestModel) : Tables.BidrequestRow = { + val bidRequestRow = getStaticBidRequestToBidRequestRow(bidRequest) + val response = coreProperties + .repositories + .bidRequestRepository + .add(bidRequestRow) + + val impressionRepository = coreProperties.repositories.impressionRepository + val impressionPlaceholderRepository = coreProperties.repositories.impressionPlaceholderRepository + + bidRequest.imp.forEachAsync(impression => { + val impressionJson = impression.toJsonString + if (impression.hasBannerOrVideo) { + val hasBanner = impression.hasBanner.toBoolInt + val hasVideo = impression.hasVideo.toBoolInt + val minMaxHeightWidth = impression.minMaxHeightWidth + val position = if (impression.hasBanner) impression.banner.get.pos else None + + val impressionRow = ImpressionRow( + -1, + bidrequestid = response.idOption, + bidresponseid = None, + rawimpressionjson = impressionJson, + isimpressionwonbyauction = 0, + isimpressionserved = 0, + bidfloor = impression.bidfloor.get, + bidfloorcur = impression.bidfloorcur.getOrElseDefault(), + createddatetimestamp = JodaDateTimeHelper.nowUtcJavaInstant, + advertisedisplayeddate = None) + + val impressionCreatedResponse = impressionRepository.add(impressionRow) + + val placeHolder = ImpressionplaceholderRow( + -1, + impressionCreatedResponse.id, + hasBanner, + hasVideo, + isnative = 0, + minMaxHeightWidth.height, + minMaxHeightWidth.width, + minMaxHeightWidth.minHeight, + minMaxHeightWidth.minWidth, + minMaxHeightWidth.maxHeight, + minMaxHeightWidth.maxWidth, + minMaxHeightWidth.isEmptyHeightWidth.toBoolInt, + minMaxHeightWidth.isMaxHeightWidthEmpty.toBoolInt, + minMaxHeightWidth.isMinHeightWidthEmpty.toBoolInt, + impression.mimes, + position, + createddatetimestamp = JodaDateTimeHelper.nowUtcJavaInstant + ) + + impressionPlaceholderRepository.addAsync(placeHolder) + } + }) + + bidRequestRow + } + + override def getStaticBidRequestToBidRequestRow(bidRequest : BidRequestModel) : Tables.BidrequestRow = + demandSidePlatformStaticBidResponseLogic.getStaticBidRequestToBidRequestRow(bidRequest) } diff --git a/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformSimulatorServiceApiController.scala b/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformSimulatorServiceApiController.scala index e32a2e2..95d525b 100644 --- a/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformSimulatorServiceApiController.scala +++ b/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformSimulatorServiceApiController.scala @@ -1,41 +1,88 @@ package shared.com.ortb.demadSidePlatforms -import shared.com.ortb.controllers.core.AbstractBaseSimulatorServiceApiController import io.circe.generic.auto._ import javax.inject.Inject import play.api.mvc._ +import shared.com.ortb.constants.AppConstants +import shared.com.ortb.controllers.core.AbstractBaseSimulatorServiceApiController import shared.com.ortb.demadSidePlatforms.traits.properties.DemandSidePlatformCorePropertiesContracts +import shared.com.ortb.enumeration.DemandSidePlatformBiddingAlgorithmType import shared.com.ortb.manager.AppManager import shared.com.ortb.model.auctionbid.biddingRequests.BidRequestModel -import shared.com.ortb.persistent.Repositories -import shared.io.helpers.JsonHelper +import shared.com.ortb.model.results.DemandSidePlatformBiddingRequestWrapperModel +import shared.io.extensions.TypeConvertExtensions._ +import shared.io.loggers.AppLogger + +import scala.util.Try class DemandSidePlatformSimulatorServiceApiController @Inject()( - repositories : Repositories, appManager : AppManager, components : ControllerComponents) extends AbstractBaseSimulatorServiceApiController( - repositories, appManager, components) with DemandSidePlatformCorePropertiesContracts { lazy val demandSideId = 1 + lazy override val coreProperties : DemandSidePlatformCorePropertiesContracts = this + lazy val agent = new DemandSidePlatformBiddingAgent( + coreProperties, + demandSideId, + DemandSidePlatformBiddingAlgorithmType.LinearBid) def makeBidRequest : Action[AnyContent] = Action { implicit request => try { val bodyRaw = request.body.asText.get logger.debug(bodyRaw) - val bidRequest = JsonHelper.toObjectUsingParser[BidRequestModel](bodyRaw) - val bidRequestToString = bidRequest.get.toString - val entityJson = demandSidePlatformJson.get - val response = s"$bidRequestToString \n $entityJson" - selfProperties.restWebApiOkJson.OkJson(response) + val bidRequest = bodyRaw.asFromJson[BidRequestModel] + val bidRequestRow = agent.getBidRequestToBidRequestRow(bidRequest) + val requestWrapperModel = DemandSidePlatformBiddingRequestWrapperModel( + bidRequest, + bidRequestRow, + demandSideId + ) + + val maybeDemandSidePlatformBidResponseModel = agent.getBid(requestWrapperModel) + + if (maybeDemandSidePlatformBidResponseModel.isDefined) { + val dspBidResponseModel = maybeDemandSidePlatformBidResponseModel.get + val bidRequestToString = bidRequest.toString + val entityJson = demandSidePlatformJson.get + val message = s""" + | $bidRequestToString + | ${ bidRequestRow.toString } + | EntityJson:$entityJson + | DemandSidePlatformBidResponseModel:$dspBidResponseModel""".stripMargin + AppLogger.debug("BidProcessedData(Raw)", message) + + val bidResponseJsonTry = Try(dspBidResponseModel + .bidResponseWrapper + .bidResponse + .get + .toJsonString) + + if (bidResponseJsonTry.isSuccess) { + selfProperties + .restWebApiOkJson + .okJsonWithStatus(bidResponseJsonTry.get) + } + else { + val noBid = AppConstants.biddingConstants.emptyStaticBidResponse + + selfProperties + .restWebApiOkJson + .okJsonWithStatus(noBid) + } + } + else { + selfProperties + .restWebApiOkJson + .noContent + } + } catch { case e : Exception => handleError(e) } } - - override val coreProperties : DemandSidePlatformCorePropertiesContracts = this } diff --git a/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformStaticBidResponseLogicImplementation.scala b/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformStaticBidResponseLogicImplementation.scala index 3253d26..834bbe1 100644 --- a/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformStaticBidResponseLogicImplementation.scala +++ b/app/shared/com/ortb/demadSidePlatforms/DemandSidePlatformStaticBidResponseLogicImplementation.scala @@ -1,19 +1,23 @@ package shared.com.ortb.demadSidePlatforms +import com.github.dwickern.macros.NameOf._ +import io.circe.generic.auto._ import shared.com.ortb.constants.AppConstants import shared.com.ortb.demadSidePlatforms.traits.logics.DemandSidePlatformStaticBidResponseLogic import shared.com.ortb.demadSidePlatforms.traits.properties.{ DemandSidePlatformBiddingProperties, DemandSidePlatformCorePropertiesContracts } -import shared.com.ortb.model.auctionbid.biddingRequests.ImpressionModel +import shared.com.ortb.enumeration.NoBidResponseType +import shared.com.ortb.model.auctionbid.biddingRequests.{ BidRequestModel, ImpressionModel } +import shared.com.ortb.model.auctionbid.bidresponses.{ BidModel, BidResponseModel, BidResponseModelWrapper, SeatBidModel } import shared.com.ortb.model.auctionbid.{ DemandSidePlatformBidResponseModel, ImpressionDealModel } import shared.com.ortb.model.config.DemandSidePlatformConfigurationModel import shared.com.ortb.model.logging.CallStackModel import shared.com.ortb.model.results.DemandSidePlatformBiddingRequestWrapperModel -import shared.com.ortb.model.{ EmptyHeightWidthModel, HeightWidthBaseModel, HeightWidthModel, MinMaxHeightWidthModel } -import shared.com.ortb.persistent.schema.Tables -import shared.io.helpers.JodaDateTimeHelper +import shared.com.ortb.persistent.schema._ import shared.io.extensions.TypeConvertExtensions._ +import shared.io.helpers.JodaDateTimeHelper import scala.collection.mutable.ArrayBuffer +import scala.util.Try class DemandSidePlatformStaticBidResponseLogicImplementation( val demandSideId : Int, @@ -26,12 +30,19 @@ class DemandSidePlatformStaticBidResponseLogicImplementation( override def getBidStatic( request : DemandSidePlatformBiddingRequestWrapperModel) : Option[DemandSidePlatformBidResponseModel] = { + val methodName = nameOf(getBidStatic _) val impressions : Seq[ImpressionModel] = request.bidRequest.imp val length = impressions.length val deals = new ArrayBuffer[ImpressionDealModel](length) val callStacks = new ArrayBuffer[CallStackModel](length) + val bidModels = new ArrayBuffer[BidModel](length) + val staticBidModel = AppConstants + .biddingConstants + .staticBidModel for (impression <- impressions) { + val minMaxHeightWidth = impression.minMaxHeightWidth + if (impression.bidfloor.isDefined) { val deal : Double = impression.bidfloor.get + defaultIncrementNumber val advertise = createStaticAdvertise(impression, deal, "Title") @@ -40,33 +51,62 @@ class DemandSidePlatformStaticBidResponseLogicImplementation( val callStackModel = CallStackModel( deal = deal, - performingAction = - s"[getBidStatic] -> adding deals($deal) for given bid request.", + performingAction = methodName, + message = s"[$methodName] -> -> adding deals($deal) for given bid request.", isServedAnyDeal = true ) callStacks.addOne(callStackModel) + val bidModel = staticBidModel.copy( + impid = impression.id, + price = deal, + nurl = s"http://adserver.com/winnotice?impid=${ impression.id }".toSome, + h = minMaxHeightWidth.maybeHeight, + w = minMaxHeightWidth.maybeWidth) + + bidModels.addOne(bidModel) } else { val advertise = createStaticAdvertise(impression, defaultStaticDeal, "Title") deals.addOne(ImpressionDealModel(impression, advertise, defaultStaticDeal)) val callStackModel = CallStackModel( deal = defaultStaticDeal, - performingAction = - s"[getBidStatic] -> adding deals($defaultStaticDeal) for given bid request.", + performingAction = methodName, + message = s"[$methodName] -> adding deals($defaultStaticDeal) for given bid request.", isServedAnyDeal = true ) callStacks.addOne(callStackModel) + val bidModel = staticBidModel.copy( + impid = impression.id, + price = defaultStaticDeal, + nurl = s"http://adserver.com/winnotice?impid=${ impression.id }".toSome, + h = minMaxHeightWidth.maybeHeight, + w = minMaxHeightWidth.maybeWidth) + + bidModels.addOne(bidModel) } } + val seatBidModel = SeatBidModel( + bidModels.toList, + seat = s"SeatBidID/DSP ID : $demandSideId".toSome) + + val bidResponse = BidResponseModel( + "_", + seatBidModel.toMakeListSome, + None, + nbr = Some(NoBidResponseType.UnknownError.value)) + + val bidResponseWrapper = BidResponseModelWrapper(Some(bidResponse)) + val dspBidderResultModel = DemandSidePlatformBidResponseModel( request, request.bidRequest, - bidResponseWrapper = null, + bidResponseWrapper = bidResponseWrapper, Some(deals.toList)) + dspBidderResultModel.addCallStacks(callStacks) Some(dspBidderResultModel) @@ -80,41 +120,44 @@ class DemandSidePlatformStaticBidResponseLogicImplementation( val hasBanner = impression .banner .isDefined - .toInt + .toBoolInt val hasVideo = impression .video .isDefined - .toInt + .toBoolInt val minMaxHeightWidth = impression.minMaxHeightWidth val impressionToString = s"impression(${ impression.toString })" val dealString = s"deal($deal)" Tables.AdvertiseRow( - AppConstants.NewRecordIntId, - AppConstants.NewRecordIntId, - 5, - title, - Some(5), - s"bidUrl($dealString)$impressionToString", - Some(s"Iframe($dealString)$impressionToString"), - 0, - Some(hasBanner), - hasVideo, - 1, - minMaxHeightWidth.height, - minMaxHeightWidth.width, - minMaxHeightWidth.minHeight, - minMaxHeightWidth.minWidth, - minMaxHeightWidth.maxHeight, - minMaxHeightWidth.maxWidth, - Some(minMaxHeightWidth.isEmptyHeightWidth.toInt), - Some(minMaxHeightWidth.isMaxHeightWithEmpty.toInt), - Some(minMaxHeightWidth.isMinHeightWithEmpty.toInt), + advertiseid = AppConstants.NewRecordIntId, + campaignid = AppConstants.NewRecordIntId, + banneradvertisetypeid = 5, + advertisetitle = title, + contentcontextid = Some(5), + bidurl = s"bidUrl($dealString)$impressionToString", + iframehtml = s"Iframe($dealString)$impressionToString".toSome, + iscountryspecific = 0, + isbanner = hasBanner, + isvideo = hasVideo, + isnative = 0, + impressioncount = 1, + height = minMaxHeightWidth.height, + width = minMaxHeightWidth.width, + minheight = minMaxHeightWidth.minHeight, + minwidth = minMaxHeightWidth.minWidth, + maxheight = minMaxHeightWidth.maxHeight, + maxwidth = minMaxHeightWidth.maxWidth, + isheightwidthempty = minMaxHeightWidth.isEmptyHeightWidth.toBoolInt, + ismaxheightwidthempty = minMaxHeightWidth.isMaxHeightWidthEmpty.toBoolInt, + isminheightwidthempty = minMaxHeightWidth.isMinHeightWidthEmpty.toBoolInt, + hasagerestriction = 0, + minage = Some(0), + maxage = Some(0), + duration = 0, 0, - Some(0), - Some(0), JodaDateTimeHelper.nowUtcJavaInstant) } @@ -134,9 +177,31 @@ class DemandSidePlatformStaticBidResponseLogicImplementation( // ) // // dspBidderResultModel.addCallStack(callStackModel) - // // Some(dspBidderResultModel) throw new NotImplementedError() + } + override def getStaticBidRequestToBidRequestRow(bidRequest : BidRequestModel) : Tables.BidrequestRow = { + val tryCountries = Try(bidRequest.device.get.geo.get.country) + val countries = if (tryCountries.isSuccess) tryCountries.get else None + val tryCity = Try(bidRequest.device.get.geo.get.city) + val city = if (tryCity.isSuccess) tryCity.get else None + val json = bidRequest.toJsonString + val impressions = bidRequest.imp + val hasBannerHasVideoArray = impressions.forAnyGroup(w => w.hasBanner, y => y.hasVideo) + val hasBanner = hasBannerHasVideoArray(0).toBoolInt + val hasVideo = hasBannerHasVideoArray(1).toBoolInt + + Tables.BidrequestRow( + bidrequestid = bidRequest.id.toIntOrDefault(), + demandsideplatformid = demandSideId, + isbanner = hasBanner, + isvideo = hasVideo, + auctionid = None, + countries = countries, + cities = city, targetedcities = city, + rawbidrequestjson = json, + createddatetimestamp = JodaDateTimeHelper.nowUtcJavaInstant + ) } } diff --git a/app/shared/com/ortb/demadSidePlatforms/traits/AddNewAdvertiseOnNotFound.scala b/app/shared/com/ortb/demadSidePlatforms/traits/AddNewAdvertiseOnNotFound.scala index 1714214..e3c6338 100644 --- a/app/shared/com/ortb/demadSidePlatforms/traits/AddNewAdvertiseOnNotFound.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/AddNewAdvertiseOnNotFound.scala @@ -1,5 +1,6 @@ package shared.com.ortb.demadSidePlatforms.traits +import shared.io.extensions.TypeConvertExtensions._ import com.github.dwickern.macros.NameOf._ import shared.com.ortb.constants.AppConstants import shared.com.ortb.demadSidePlatforms.DemandSidePlatformBiddingAgent @@ -89,14 +90,14 @@ trait AddNewAdvertiseOnNotFound { campaignid = campaignId.get, 1, s"Generated Banner Advertise($bannerString)", - Some(contextTextId), + contextTextId.toSome, s"BidUrl for $bannerString", - Some(s"IFrame for $bannerString"), + "IFrame for $bannerString".toSome, 0, + isbanner = 1, isvideo = 0, impressioncount = 0, height = simpleBanner.h, - isbanner = Some(1), width = simpleBanner.w, minheight = simpleBanner.hmin, minwidth = simpleBanner.wmin, @@ -107,8 +108,8 @@ trait AddNewAdvertiseOnNotFound { maxage = Some(0), createddatetimestamp = JodaDateTimeHelper.nowUtcJavaInstant) - advertiseRepository.add(advertise) - AppLogger.debug("Advertise added") + val response = advertiseRepository.add(advertise).attributes.get.message + AppLogger.debug(s"Advertise added : $response") // throw new NotImplementedError() } } diff --git a/app/shared/com/ortb/demadSidePlatforms/traits/DefaultActualNoContentResponse.scala b/app/shared/com/ortb/demadSidePlatforms/traits/DefaultActualNoContentResponse.scala index af4d3cc..9371223 100644 --- a/app/shared/com/ortb/demadSidePlatforms/traits/DefaultActualNoContentResponse.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/DefaultActualNoContentResponse.scala @@ -1,5 +1,6 @@ package shared.com.ortb.demadSidePlatforms.traits +import com.github.dwickern.macros.NameOf._ import shared.com.ortb.demadSidePlatforms.DemandSidePlatformBiddingAgent import shared.com.ortb.model.auctionbid.DemandSidePlatformBidResponseModel import shared.com.ortb.model.logging.CallStackModel @@ -10,6 +11,7 @@ trait DefaultActualNoContentResponse { def getBidActualNoContent( request : DemandSidePlatformBiddingRequestWrapperModel) : Option[DemandSidePlatformBidResponseModel] = { + val methodName = nameOf(getBidActualNoContent _) val dspBidderResultModel = DemandSidePlatformBidResponseModel( request, @@ -18,7 +20,7 @@ trait DefaultActualNoContentResponse { val callStackModel = CallStackModel( deal = coreProperties.noDealPrice, - performingAction = s"[getBidActualNoContent] -> No deals." + performingAction = s"[$methodName] -> No deals." ) // save no bid response diff --git a/app/shared/com/ortb/demadSidePlatforms/HeightWidthExtractorFromImpression.scala b/app/shared/com/ortb/demadSidePlatforms/traits/HeightWidthExtractorFromImpression.scala similarity index 87% rename from app/shared/com/ortb/demadSidePlatforms/HeightWidthExtractorFromImpression.scala rename to app/shared/com/ortb/demadSidePlatforms/traits/HeightWidthExtractorFromImpression.scala index 01d8f20..571521e 100644 --- a/app/shared/com/ortb/demadSidePlatforms/HeightWidthExtractorFromImpression.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/HeightWidthExtractorFromImpression.scala @@ -1,10 +1,9 @@ -package shared.com.ortb.demadSidePlatforms +package shared.com.ortb.demadSidePlatforms.traits -import shared.com.ortb.model.{ EmptyHeightWidthModel, HeightWidthBaseModel, HeightWidthModel, MinMaxHeightWidthModel } import shared.com.ortb.model.auctionbid.biddingRequests.ImpressionModel +import shared.com.ortb.model.dimensions.{ EmptyHeightWidthModel, HeightWidthBaseModel, HeightWidthModel, MinMaxHeightWidthModel } trait HeightWidthExtractorFromImpression { - def getMinMaxHeightWidths(impression : ImpressionModel) : MinMaxHeightWidthModel = { val heightWidth = getHeightWidth(impression) val maxHeightWidth = getMaxHeightWidth(impression) diff --git a/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformActualBidResponseLogic.scala b/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformActualBidResponseLogic.scala index 9b15f1e..b74168e 100644 --- a/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformActualBidResponseLogic.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformActualBidResponseLogic.scala @@ -1,7 +1,9 @@ package shared.com.ortb.demadSidePlatforms.traits.logics import shared.com.ortb.model.auctionbid.DemandSidePlatformBidResponseModel +import shared.com.ortb.model.auctionbid.biddingRequests.BidRequestModel import shared.com.ortb.model.results.DemandSidePlatformBiddingRequestWrapperModel +import shared.com.ortb.persistent.schema.Tables trait DemandSidePlatformActualBidResponseLogic { def getBidActual( @@ -9,4 +11,6 @@ trait DemandSidePlatformActualBidResponseLogic { def getBidActualNoContent( request : DemandSidePlatformBiddingRequestWrapperModel) : Option[DemandSidePlatformBidResponseModel] + + def getActualBidRequestToBidRequestRow(bidRequest : BidRequestModel) : Tables.BidrequestRow } diff --git a/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformBiddingLogic.scala b/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformBiddingLogic.scala index 468d64a..fddc374 100644 --- a/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformBiddingLogic.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformBiddingLogic.scala @@ -1,13 +1,23 @@ package shared.com.ortb.demadSidePlatforms.traits.logics import shared.com.ortb.model.auctionbid.DemandSidePlatformBidResponseModel +import shared.com.ortb.model.auctionbid.biddingRequests.BidRequestModel import shared.com.ortb.model.results.DemandSidePlatformBiddingRequestWrapperModel +import shared.com.ortb.persistent.schema.Tables trait DemandSidePlatformBiddingLogic extends DemandSidePlatformStaticBidResponseLogic with DemandSidePlatformActualBidResponseLogic { def isStatic : Boolean + def getBidRequestToBidRequestRow(bidRequest : BidRequestModel) : Tables.BidrequestRow = { + if (isStatic) { + return getStaticBidRequestToBidRequestRow(bidRequest) + } + + getActualBidRequestToBidRequestRow(bidRequest) + } + def getBidPrices(request : DemandSidePlatformBiddingRequestWrapperModel) : Option[DemandSidePlatformBidResponseModel] def getBid( diff --git a/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformStaticBidResponseLogic.scala b/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformStaticBidResponseLogic.scala index ee1c7fc..c93295d 100644 --- a/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformStaticBidResponseLogic.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/logics/DemandSidePlatformStaticBidResponseLogic.scala @@ -1,7 +1,9 @@ package shared.com.ortb.demadSidePlatforms.traits.logics import shared.com.ortb.model.auctionbid.DemandSidePlatformBidResponseModel +import shared.com.ortb.model.auctionbid.biddingRequests.BidRequestModel import shared.com.ortb.model.results.DemandSidePlatformBiddingRequestWrapperModel +import shared.com.ortb.persistent.schema.Tables trait DemandSidePlatformStaticBidResponseLogic { def getBidStatic( @@ -9,4 +11,6 @@ trait DemandSidePlatformStaticBidResponseLogic { def getBidStaticNoContent( request : DemandSidePlatformBiddingRequestWrapperModel) : Option[DemandSidePlatformBidResponseModel] + + def getStaticBidRequestToBidRequestRow(bidRequest : BidRequestModel) : Tables.BidrequestRow } diff --git a/app/shared/com/ortb/demadSidePlatforms/traits/properties/DemandSidePlatformCorePropertiesContracts.scala b/app/shared/com/ortb/demadSidePlatforms/traits/properties/DemandSidePlatformCorePropertiesContracts.scala index 01ac91d..c093330 100644 --- a/app/shared/com/ortb/demadSidePlatforms/traits/properties/DemandSidePlatformCorePropertiesContracts.scala +++ b/app/shared/com/ortb/demadSidePlatforms/traits/properties/DemandSidePlatformCorePropertiesContracts.scala @@ -1,5 +1,6 @@ package shared.com.ortb.demadSidePlatforms.traits.properties +import shared.com.ortb.constants.AppConstants import shared.com.ortb.controllers.traits.properties.ServiceControllerCorePropertiesContracts import shared.com.ortb.model.config.{ DemandSidePlatformConfigurationModel, RangeModel, ServiceModel } import shared.com.ortb.persistent.Repositories @@ -32,5 +33,5 @@ trait DemandSidePlatformCorePropertiesContracts lazy val demandSidePlatformConfiguration : DemandSidePlatformConfigurationModel = config.server.demandSidePlatformConfiguration - val repositories : Repositories + lazy val repositories : Repositories = AppConstants.Repositories } diff --git a/app/shared/com/ortb/executors/Application.scala b/app/shared/com/ortb/executors/Application.scala index 2e31ea2..e6b00c0 100644 --- a/app/shared/com/ortb/executors/Application.scala +++ b/app/shared/com/ortb/executors/Application.scala @@ -1,6 +1,7 @@ package shared.com.ortb.executors import com.github.dwickern.macros.NameOf._ +import shared.com.ortb.demadSidePlatforms.traits.properties.DemandSidePlatformCorePropertiesContracts import shared.com.ortb.manager.AppManager import shared.com.ortb.persistent.Repositories import shared.com.ortb.persistent.schema.Tables._ @@ -40,6 +41,7 @@ object Application { val res = response.data.get AppLogger.debug(res.toString) + } /** diff --git a/app/shared/com/ortb/model/auctionbid/biddingRequests/DeviceModel.scala b/app/shared/com/ortb/model/auctionbid/biddingRequests/DeviceModel.scala index 8a86231..5def086 100644 --- a/app/shared/com/ortb/model/auctionbid/biddingRequests/DeviceModel.scala +++ b/app/shared/com/ortb/model/auctionbid/biddingRequests/DeviceModel.scala @@ -1,3 +1,98 @@ package shared.com.ortb.model.auctionbid.biddingRequests -case class DeviceModel(id : String, geo : Option[GeoModel]) +case class DeviceModel( + /** + * Recommended + * UserAgent/Browser Agent + * Browser user agent string. + */ + ua : Option[String] = None, + + /** + * Recommended + * Location of the device assumed to be the + * user’s current location defined + * by a Geo object (Section 3.2.12). + */ + geo : Option[GeoModel] = None, + + /** + * Recommended + * Standard “Do Not Track” flag as set in the header by the browser, + * where 0 = tracking is unrestricted, 1 = do not track. + */ + dnt : Option[Int] = None, + + /** + * Recommended + * “Limit Ad Tracking” signal commercially + * endorsed (e.g., iOS, Android), + * where 0 = tracking is unrestricted, + * 1 = tracking must be limited per commercial guidelines. + */ + lmt : Option[Int] = None, + + /** + * Recommended + * IPv4 address closest to device. + */ + ip : Option[String] = None, + + /** + * IP address closest to device as IPv6. + */ + ipv6 : Option[String] = None, + + /** + * The general type of device. Refer to List 5.17. + * 1 - Mobile/Tablet - Version 2.0 + * 2 - Personal Computer - Version 2.0 + * 3 - Connected TV - Version 2.0 + * 4 - Phone - New for Version 2.2 + * 5 - Tablet - New for Version 2.2 + * 6 - Connected Device - New for Version 2.2 + * 7 - Set Top Box - New for Version 2.2 + */ + devicetype : Option[Int] = None, + + /** + * Device creator + * (e.g., “Apple”). + */ + make : Option[String] = None, + + /** + * Device model (e.g., “iPhone”). + */ + model : Option[String] = None, + + /** + * Device operating system (e.g., “iOS”). + */ + os : Option[String] = None, + + /** + * Physical height of the screen in pixels. + */ + h : Option[Int] = None, + + /** + * Physical width of the screen in pixels. + */ + w : Option[Int] = None, + + /** + * Screen size as pixels per linear inch. + */ + ppi : Option[Int] = None, + + /** + * Support for JavaScript, where 0 = no, 1 = yes. + */ + js : Option[Int] = None, + + /** + * Version of Flash supported by the browser. + */ + flashver : Option[String] = None +) diff --git a/app/shared/com/ortb/model/auctionbid/biddingRequests/ImpressionModel.scala b/app/shared/com/ortb/model/auctionbid/biddingRequests/ImpressionModel.scala index 6ffcdbe..04b6861 100644 --- a/app/shared/com/ortb/model/auctionbid/biddingRequests/ImpressionModel.scala +++ b/app/shared/com/ortb/model/auctionbid/biddingRequests/ImpressionModel.scala @@ -1,8 +1,9 @@ package shared.com.ortb.model.auctionbid.biddingRequests -import shared.com.ortb.demadSidePlatforms.HeightWidthExtractorFromImpression -import shared.com.ortb.model.MinMaxHeightWidthModel +import shared.com.ortb.demadSidePlatforms.traits.HeightWidthExtractorFromImpression import shared.com.ortb.model.auctionbid.biddingRequests.banners.BannerImpressionModel +import shared.com.ortb.model.dimensions.MinMaxHeightWidthModel +import shared.io.extensions.TypeConvertExtensions._ import shared.io.helpers.EmptyValidateHelper /** @@ -22,7 +23,7 @@ case class ImpressionModel( /** * Minimum bid for this impression expressed in CPM. */ - bidfloor : Option[Double], + bidfloor : Option[Double] = Some(0), /** * Currency specified using ISO-4217 alpha codes. @@ -48,7 +49,21 @@ case class ImpressionModel( ) { lazy val hasBanner : Boolean = EmptyValidateHelper.isDefined(banner) lazy val hasVideo : Boolean = EmptyValidateHelper.isDefined(video) + lazy val hasBannerOrVideo : Boolean = hasBanner || hasVideo lazy val hasBidFloor : Boolean = EmptyValidateHelper.isDefined(bidfloor) - lazy val hasBidFloorCurrency : Boolean = EmptyValidateHelper.isOptionStringDefined(bidfloorcur) - lazy val minMaxHeightWidth : MinMaxHeightWidthModel = HeightWidthExtractorFromImpression.getMinMaxHeightWidths(this) + lazy val hasBidFloorCurrency : Boolean = + EmptyValidateHelper.isOptionStringDefined(bidfloorcur) + lazy val minMaxHeightWidth : MinMaxHeightWidthModel = + HeightWidthExtractorFromImpression.getMinMaxHeightWidths(this) + + lazy private val hasBannerMimes = hasBanner && + EmptyValidateHelper.hasAnyItem(banner.get.mimes) + lazy private val videoMimes = video.get.mimes.toCsv.toSome + lazy private val bannerMimes = banner.get.mimes.get.toCsv.toSome + + lazy val mimes : Option[String] = + if (hasVideo) videoMimes + else if (hasBannerMimes) + bannerMimes + else None } diff --git a/app/shared/com/ortb/model/auctionbid/biddingRequests/VideoImpressionModel.scala b/app/shared/com/ortb/model/auctionbid/biddingRequests/VideoImpressionModel.scala index 1e5c217..b56cffe 100644 --- a/app/shared/com/ortb/model/auctionbid/biddingRequests/VideoImpressionModel.scala +++ b/app/shared/com/ortb/model/auctionbid/biddingRequests/VideoImpressionModel.scala @@ -1,6 +1,6 @@ package shared.com.ortb.model.auctionbid.biddingRequests -import shared.com.ortb.model.HeightWidthBaseModel +import shared.com.ortb.model.dimensions.HeightWidthBaseModel /** * Video Request(for Bid) Details inside the BidRequest -> Impression[] -> Impression -> video @@ -42,12 +42,12 @@ case class VideoImpressionModel( /** * Minimum video ad duration in seconds. */ - minduration : Option[Int], + minduration : Option[Int] = None, /** * Maximum video ad duration in seconds. */ - maxduration : Option[Int], + maxduration : Option[Int] = None, /** * Array of supported video bid response protocols. @@ -55,17 +55,17 @@ case class VideoImpressionModel( * At least one supported protocol * must be specified in either the protocol or protocols attribute. */ - protocols : Option[Int], + protocols : Option[Int] = None, /** * Width of the video player in pixels. */ - w : Option[Int], + w : Option[Int] = None, /** * Height of the video player in pixels. */ - h : Option[Int], + h : Option[Int] = None, /** * Indicates the start delay in @@ -73,12 +73,12 @@ case class VideoImpressionModel( * or post-roll ad placements. * Refer to List 5.10 for additional generic values. */ - startdelay : Option[Int], + startdelay : Option[Int] = None, /** * Indicates if the impression must be linear, nonlinear, etc. If none specified, assume all are allowed. Refer to List 5.7. */ - linearity : Option[Int], + linearity : Option[Int] = None, /** * default 1 diff --git a/app/shared/com/ortb/model/auctionbid/biddingRequests/banners/BannerImpressionModel.scala b/app/shared/com/ortb/model/auctionbid/biddingRequests/banners/BannerImpressionModel.scala index 279a4ee..689be64 100644 --- a/app/shared/com/ortb/model/auctionbid/biddingRequests/banners/BannerImpressionModel.scala +++ b/app/shared/com/ortb/model/auctionbid/biddingRequests/banners/BannerImpressionModel.scala @@ -1,7 +1,6 @@ package shared.com.ortb.model.auctionbid.biddingRequests.banners -import shared.com.ortb.model.HeightWidthBaseModel -import shared.io.helpers.EmptyValidateHelper +import shared.com.ortb.model.dimensions.HeightWidthBaseModel /** * Banner Details inside the BidRequest -> Impression[] -> Impression -> banner @@ -33,74 +32,74 @@ import shared.io.helpers.EmptyValidateHelper * * where 0 = no, 1 = yes. */ case class BannerImpressionModel( - id : Option[String], + id : Option[String] = None, /** * If included along with a w value then * w should be interpreted as a * recommended or preferred width. */ - wmin : Option[Int], + wmin : Option[Int] = None, /** * Maximum width of the impression in pixels. * If included along with a w value then w should be * interpreted as a recommended or preferred width. */ - wmax : Option[Int], + wmax : Option[Int] = None, /** * If neither wmin nor wmax are specified, * this value is an exact width requirement. * Otherwise it is a preferred width. */ - w : Option[Int], + w : Option[Int] = None, /** * If included along with an h value then h * should be interpreted as a * recommended or preferred height. */ - hmin : Option[Int], + hmin : Option[Int] = None, /** * If included along with an h value then h should be * interpreted as a recommended or preferred height. */ - hmax : Option[Int], + hmax : Option[Int] = None, /** * If neither hmin nor hmax are specified, * this value is an exact height requirement. * Otherwise it is a preferred height. */ - h : Option[Int], + h : Option[Int] = None, /** * Ad position on screen. */ - pos : Option[Int], + pos : Option[Int] = None, /** * Content MIME types supported. * Popular MIME types may include * “application/x-shockwave-flash”, */ - mimes : Option[List[String]], + mimes : Option[List[String]] = None, /** * Indicates if the banner is in the * top frame as opposed to an iframe, * where 0 = no, 1 = yes. */ - topframe : Option[Int], + topframe : Option[Int] = None, /** * Blocked banner ad types. Refer to List 5.2. */ - btype : Option[List[Int]], + btype : Option[List[Int]] = None, /** * Blocked creative attributes. Refer to List 5.3. */ - battr : Option[List[Int]]) extends HeightWidthBaseModel(h, w) + battr : Option[List[Int]] = None) extends HeightWidthBaseModel(h, w) diff --git a/app/shared/com/ortb/model/auctionbid/bidresponses/BidModel.scala b/app/shared/com/ortb/model/auctionbid/bidresponses/BidModel.scala index 0706595..ce23363 100644 --- a/app/shared/com/ortb/model/auctionbid/bidresponses/BidModel.scala +++ b/app/shared/com/ortb/model/auctionbid/bidresponses/BidModel.scala @@ -60,8 +60,7 @@ case class BidModel( /** * ID of a preloaded ad to be served if the bid wins. */ - adid : Option[String], - + adid : Option[String] = None, /** * Win notice URL called by the exchange if the bid wins; @@ -75,58 +74,68 @@ case class BidModel( * them with the appropriate data. Note that the substitution is * simple in the sense that wherever a legal macro is found, * it will be replaced without regard for syntax correctness. + * Eg. "http://adserver.com/winnotice?impid=102" */ - nurl : Option[String], + nurl : Option[String] = None, /** * Optional means of conveying ad markup in * case the bid wins; supersedes the * win notice if markup is included in both. + * + * Note that since there both a win notice URL and + * an inline VAST document in the adm attribute, + * which constitutes the ad markup. The win notice + * is still called, but if it were to return markup + * it would be ignored in favor of the contents of the adm attribute. */ - adm : Option[String], + adm : Option[String] = None, /** * Advertiser domain for block list checking (e.g., “ford.com”). * This can be an array of for the case of rotating creatives. * Exchanges can mandate that only one domain is allowed. + * Eg. [ "advertiserdomain.com" ] */ - adomain : Option[List[String]], + adomain : Option[List[String]] = None, /** * URL without cache-busting to an image that is * representative of the content of the * campaign for ad quality/safety checking. + * Eg. "http://adserver.com/pathtosampleimage" */ - iurl : Option[String], + iurl : Option[String] = None, /** * Campaign ID to assist with ad quality checking; t * he collection of creatives for which iurl * should be representative. + * Eg. "campaign111" */ - cid : Option[String], + cid : Option[String] = None, /** * IAB content categories + * can also be like "creative112" */ - cat : Option[List[String]], + cat : Option[List[String]] = None, /** * Reference to the deal.id from the bid request * if this bid pertains to a private marketplace direct deal. */ - dealid : Option[String], + dealid : Option[String] = None, /** * Height of the creative in pixels. */ - h : Option[Int], + h : Option[Int] = None, /** * Width of the creative in pixels. */ - w : Option[Int] - + w : Option[Int] = None ) diff --git a/app/shared/com/ortb/model/auctionbid/bidresponses/SeatBidModel.scala b/app/shared/com/ortb/model/auctionbid/bidresponses/SeatBidModel.scala index 4aa2859..3a74e6d 100644 --- a/app/shared/com/ortb/model/auctionbid/bidresponses/SeatBidModel.scala +++ b/app/shared/com/ortb/model/auctionbid/bidresponses/SeatBidModel.scala @@ -25,7 +25,7 @@ case class SeatBidModel( * https://bit.ly/2LRwlr2 * https://bit.ly/2LN018Q */ - seat : Option[String], + seat : Option[String] = None, /** * 0 = impressions can be won individually; diff --git a/app/shared/com/ortb/model/EmptyHeightWidthModel.scala b/app/shared/com/ortb/model/dimensions/EmptyHeightWidthModel.scala similarity index 65% rename from app/shared/com/ortb/model/EmptyHeightWidthModel.scala rename to app/shared/com/ortb/model/dimensions/EmptyHeightWidthModel.scala index 3435d17..dc5381d 100644 --- a/app/shared/com/ortb/model/EmptyHeightWidthModel.scala +++ b/app/shared/com/ortb/model/dimensions/EmptyHeightWidthModel.scala @@ -1,3 +1,3 @@ -package shared.com.ortb.model +package shared.com.ortb.model.dimensions case class EmptyHeightWidthModel() extends HeightWidthBaseModel(None, None) diff --git a/app/shared/com/ortb/model/HeightWidthBaseModel.scala b/app/shared/com/ortb/model/dimensions/HeightWidthBaseModel.scala similarity index 93% rename from app/shared/com/ortb/model/HeightWidthBaseModel.scala rename to app/shared/com/ortb/model/dimensions/HeightWidthBaseModel.scala index f06cd15..0718d2c 100644 --- a/app/shared/com/ortb/model/HeightWidthBaseModel.scala +++ b/app/shared/com/ortb/model/dimensions/HeightWidthBaseModel.scala @@ -1,4 +1,4 @@ -package shared.com.ortb.model +package shared.com.ortb.model.dimensions import shared.io.helpers.EmptyValidateHelper diff --git a/app/shared/com/ortb/model/HeightWidthModel.scala b/app/shared/com/ortb/model/dimensions/HeightWidthModel.scala similarity index 80% rename from app/shared/com/ortb/model/HeightWidthModel.scala rename to app/shared/com/ortb/model/dimensions/HeightWidthModel.scala index b2ad14d..6b3a260 100644 --- a/app/shared/com/ortb/model/HeightWidthModel.scala +++ b/app/shared/com/ortb/model/dimensions/HeightWidthModel.scala @@ -1,4 +1,4 @@ -package shared.com.ortb.model +package shared.com.ortb.model.dimensions case class HeightWidthModel( override val maybeHeight : Option[Int], diff --git a/app/shared/com/ortb/model/MinMaxHeightWidthModel.scala b/app/shared/com/ortb/model/dimensions/MinMaxHeightWidthModel.scala similarity index 68% rename from app/shared/com/ortb/model/MinMaxHeightWidthModel.scala rename to app/shared/com/ortb/model/dimensions/MinMaxHeightWidthModel.scala index b3cb619..ce8aeed 100644 --- a/app/shared/com/ortb/model/MinMaxHeightWidthModel.scala +++ b/app/shared/com/ortb/model/dimensions/MinMaxHeightWidthModel.scala @@ -1,4 +1,4 @@ -package shared.com.ortb.model +package shared.com.ortb.model.dimensions case class MinMaxHeightWidthModel( minHeightWidth : HeightWidthBaseModel, @@ -7,9 +7,9 @@ case class MinMaxHeightWidthModel( ) extends HeightWidthBaseModel(heightWidth.maybeHeight, heightWidth.maybeWidth) { lazy val minHeight : Int = minHeightWidth.height lazy val minWidth : Int = minHeightWidth.width - lazy val isMinHeightWithEmpty : Boolean = minHeightWidth.isEmptyHeightWidth + lazy val isMinHeightWidthEmpty : Boolean = minHeightWidth.isEmptyHeightWidth lazy val maxHeight : Int = maxHeightWidth.height lazy val maxWidth : Int = maxHeightWidth.width - lazy val isMaxHeightWithEmpty : Boolean = maxHeightWidth.isEmptyHeightWidth + lazy val isMaxHeightWidthEmpty : Boolean = maxHeightWidth.isEmptyHeightWidth } diff --git a/app/shared/com/ortb/model/results/RepositoryOperationResultModel.scala b/app/shared/com/ortb/model/results/RepositoryOperationResultModel.scala index 1bfd3ec..c8019ad 100644 --- a/app/shared/com/ortb/model/results/RepositoryOperationResultModel.scala +++ b/app/shared/com/ortb/model/results/RepositoryOperationResultModel.scala @@ -1,5 +1,6 @@ package shared.com.ortb.model.results +import shared.io.extensions.TypeConvertExtensions._ import shared.com.ortb.model.attributes.GenericResponseAttributesModel import shared.com.ortb.model.wrappers.persistent.EntityWrapperModel import shared.io.helpers.{ EmptyValidateHelper, ReflectionHelper } @@ -12,6 +13,7 @@ case class RepositoryOperationResultModel[TRow, TKey]( data : Option[EntityWrapperModel[TRow, TKey]] = None) { lazy val row : TRow = data.get.entity lazy val id : TKey = data.get.entityId + lazy val idOption : Option[TKey] = data.get.entityId.toSome lazy val hasItem : Boolean = EmptyValidateHelper.isDefined(data) def getIdAsInt : Option[Int] = { diff --git a/app/shared/com/ortb/model/results/RepositoryOperationResultsModel.scala b/app/shared/com/ortb/model/results/RepositoryOperationResultsModel.scala index e9fc2e4..48d638d 100644 --- a/app/shared/com/ortb/model/results/RepositoryOperationResultsModel.scala +++ b/app/shared/com/ortb/model/results/RepositoryOperationResultsModel.scala @@ -39,7 +39,7 @@ case class RepositoryOperationResultsModel[TRow, TKey]( val message = AppLogger.getLogMessageForEntities(isExecute = true, data, additionalMessage) val attributesToJson = basicEncoderForGenericResponseAttributesModel - .getJsonGenericParser + .genericJsonParser .toJsonStringPrettyFormatDirect(attributes.get) s""" diff --git a/app/shared/com/ortb/persistent/Repositories.scala b/app/shared/com/ortb/persistent/Repositories.scala index 36443d3..b9aecd2 100644 --- a/app/shared/com/ortb/persistent/Repositories.scala +++ b/app/shared/com/ortb/persistent/Repositories.scala @@ -3,7 +3,7 @@ package shared.com.ortb.persistent import com.google.inject.Inject import shared.com.ortb.manager.AppManager import shared.com.ortb.persistent.repositories.views.{ BidRelatedIdsViewRepository, KeywordAdvertiseMappingIdsViewRepository, WinningPriceInfoViewRepository } -import shared.com.ortb.persistent.repositories.{ BidContentCategoriesMappingRepository, BidRepository, CreativeAttributeRepository, DeviceTypeRepository, PrivateMarketPlaceDealRepository, SeatBidRepository, UserClassificationRepository, VideoPlaybackMethodRepository, VideoResponseProtocolRepository, _ } +import shared.com.ortb.persistent.repositories.{ BidContentCategoriesMappingRepository, BidRepository, CreativeAttributeRepository, DeviceTypeRepository, ImpressionPlaceholderRepository, PrivateMarketPlaceDealRepository, SeatBidRepository, UserClassificationRepository, VideoPlaybackMethodRepository, VideoResponseProtocolRepository, _ } import shared.com.ortb.persistent.schema.{ DatabaseSchema, DatabaseSchemaViews } class Repositories @Inject()(appManager: AppManager) @@ -36,6 +36,7 @@ class Repositories @Inject()(appManager: AppManager) new DeviceTypeRepository(appManager) lazy val geoMappingRepository = new GeoMappingRepository(appManager) lazy val impressionRepository = new ImpressionRepository(appManager) + lazy val impressionPlaceholderRepository = new ImpressionPlaceholderRepository(appManager) lazy val keywordAdvertiseMappingRepository = new KeywordAdvertiseMappingRepository(appManager) lazy val keywordRepository = new KeywordRepository(appManager) @@ -76,6 +77,7 @@ class Repositories @Inject()(appManager: AppManager) deviceTypeTableName -> deviceTypeRepository, geoMappingTableName -> geoMappingRepository, impressionTableName -> impressionRepository, + impressionPlaceholderTableName -> impressionPlaceholderRepository, keywordTableName -> keywordRepository, keywordAdvertiseMappingTableName -> keywordAdvertiseMappingRepository, logTraceTableName -> logTraceRepository, diff --git a/app/shared/com/ortb/persistent/repositories/ImpressionPlaceholderRepository.scala b/app/shared/com/ortb/persistent/repositories/ImpressionPlaceholderRepository.scala new file mode 100644 index 0000000..a4ce908 --- /dev/null +++ b/app/shared/com/ortb/persistent/repositories/ImpressionPlaceholderRepository.scala @@ -0,0 +1,62 @@ +package shared.com.ortb.persistent.repositories + +import io.circe.derivation._ +import io.circe.generic.semiauto._ +import io.circe._ +import io.circe.generic.auto._ +import com.google.inject.Inject +import shared.com.ortb.manager.AppManager +import shared.com.ortb.persistent.schema.Tables +import shared.com.ortb.persistent.schema.Tables._ +import shared.com.repository.RepositoryBase +import shared.io.jsonParse.implementations.JsonCirceDefaultEncodersImplementation +import slick.dbio.Effect +import slick.jdbc.SQLiteProfile.api._ +import slick.sql.FixedSqlAction + +class ImpressionPlaceholderRepository @Inject()(appManager: AppManager) + extends RepositoryBase[Impressionplaceholder, ImpressionplaceholderRow, Int](appManager) { + + override def tableName: String = this.impressionPlaceholderTableName + + override def getEntityIdFromOptionRow(entity : Option[Tables.ImpressionplaceholderRow]): Int = + if (entity.isDefined) entity.get.impressionid + else -1 + + override def setEntityIdFromOptionRow( + entityId: Option[Int], + entity: Option[Tables.ImpressionplaceholderRow] + ): Option[Tables.ImpressionplaceholderRow] = { + if (isEmptyGivenEntity(entityId, entity)) { + return None + } + + Some(entity.get.copy(impressionid = entityId.get)) + } + + override def getAddAction(entity: Tables.ImpressionplaceholderRow) = + table returning table.map(_.impressionid) into + ((entityProjection, + entityId) => entityProjection.copy(impressionid = entityId)) += entity + + override def table : TableQuery[Impressionplaceholder] = this.impressionPlaceholder + + override def getDeleteAction( + entityId: Int + ): FixedSqlAction[Int, NoStream, Effect.Write] = + getQueryById(entityId).delete + + override def getQueryById(id: Int) : Query[Impressionplaceholder, ImpressionplaceholderRow, Seq] = + table.filter(c => c.impressionid === id) + + override def getAllQuery : Query[Impressionplaceholder, ImpressionplaceholderRow, Seq] = + for {record <- table} yield record + + /** + * All encoders, decoders and codec for circe + * + * @return + */ + override def encoders : JsonCirceDefaultEncodersImplementation[ImpressionplaceholderRow] = + new JsonCirceDefaultEncodersImplementation[ImpressionplaceholderRow]() +} diff --git a/app/shared/com/ortb/persistent/repositories/views/BidRequestImpressionWithPlaceholderViewRepository.scala b/app/shared/com/ortb/persistent/repositories/views/BidRequestImpressionWithPlaceholderViewRepository.scala new file mode 100644 index 0000000..63b2b47 --- /dev/null +++ b/app/shared/com/ortb/persistent/repositories/views/BidRequestImpressionWithPlaceholderViewRepository.scala @@ -0,0 +1,34 @@ +package shared.com.ortb.persistent.repositories.views + +import io.circe.parser._ +import io.circe.generic.auto._ +import io.circe.generic.semiauto._ +import io.circe._ +import io.circe.generic.auto._ +import io.circe.derivation._ +import com.google.inject.Inject +import shared.com.ortb.manager.AppManager +import shared.com.ortb.persistent.schema.Tables._ +import shared.com.repository.RepositoryViewsCore +import shared.io.jsonParse.implementations.JsonCirceDefaultEncodersImplementation + +class BidRequestImpressionWithPlaceholderViewRepository @Inject()(appManager : AppManager) + extends RepositoryViewsCore[Bidrequestimpressionwithplaceholderview, BidrequestimpressionwithplaceholderviewRow](appManager) { + + override def tableName : String = + this.views.bidRequestImpressionWithPlaceholderViewName + + override def getAllQuery = + for {record <- table} yield record + + override def table = + this.views.bidRequestImpressionWithPlaceholderView + + /** + * All encoders, decoders and codec for circe + * + * @return + */ + override def encoders = + new JsonCirceDefaultEncodersImplementation[BidrequestimpressionwithplaceholderviewRow] +} diff --git a/app/shared/com/ortb/persistent/schema/DatabaseSchema.scala b/app/shared/com/ortb/persistent/schema/DatabaseSchema.scala index da0cba4..dc5c06b 100644 --- a/app/shared/com/ortb/persistent/schema/DatabaseSchema.scala +++ b/app/shared/com/ortb/persistent/schema/DatabaseSchema.scala @@ -62,6 +62,9 @@ class DatabaseSchema @Inject()(val appManager : AppManager) * Winning bid info */ lazy val impressions = TableQuery[Impression] + + lazy val impressionPlaceholder = TableQuery[Impressionplaceholder] + /** * Keywords in the system */ @@ -116,6 +119,7 @@ class DatabaseSchema @Inject()(val appManager : AppManager) deviceTypeTableName -> deviceTypes, geoMappingTableName -> geoMappings, impressionTableName -> impressions, + impressionPlaceholderTableName -> impressionPlaceholder, keywordTableName -> keywords, keywordAdvertiseMappingTableName -> keywordAdvertiseMappings, logTraceTableName -> logTraces, @@ -148,6 +152,7 @@ class DatabaseSchema @Inject()(val appManager : AppManager) lazy val deviceTypeTableName = "DeviceType" lazy val geoMappingTableName = "GeoMapping" lazy val impressionTableName = "Impression" + lazy val impressionPlaceholderTableName = "ImpressionPlaceholder" lazy val keywordTableName = "Keyword" lazy val keywordAdvertiseMappingTableName = "KeywordAdvertiseMapping" lazy val logTraceTableName = "LogTrace" @@ -180,6 +185,7 @@ class DatabaseSchema @Inject()(val appManager : AppManager) deviceTypeTableName, geoMappingTableName, impressionTableName, + impressionPlaceholderTableName, keywordTableName, keywordAdvertiseMappingTableName, logTraceTableName, diff --git a/app/shared/com/ortb/persistent/schema/DatabaseSchemaViews.scala b/app/shared/com/ortb/persistent/schema/DatabaseSchemaViews.scala index 93d5907..56d1443 100644 --- a/app/shared/com/ortb/persistent/schema/DatabaseSchemaViews.scala +++ b/app/shared/com/ortb/persistent/schema/DatabaseSchemaViews.scala @@ -1,22 +1,25 @@ package shared.com.ortb.persistent.schema -import slick.lifted.TableQuery import shared.com.ortb.persistent.schema.Tables._ +import slick.lifted.TableQuery class DatabaseSchemaViews { lazy val advertiseIsRunningViewName = "AdvertiseIsRunningView" lazy val bidRelatedIdsViewName = "BidRelatedIdsView" lazy val keywordAdvertiseMappingIdsViewName = "KeywordAdvertiseMappingIdsView" + lazy val bidRequestImpressionWithPlaceholderViewName = "BidRequestImpressionWithPlaceholderView" lazy val winningPriceInfoViewName = "WinningPriceInfoView" lazy val advertiseIsRunningView = TableQuery[Advertiseisrunningview] lazy val bidRelatedIdsView = TableQuery[Bidrelatedidsview] + lazy val bidRequestImpressionWithPlaceholderView = TableQuery[Bidrequestimpressionwithplaceholderview] lazy val keywordAdvertiseMappingIdsView = TableQuery[Keywordadvertisemappingidsview] lazy val winningPriceInfoView = TableQuery[Winningpriceinfoview] lazy val views = Map( advertiseIsRunningViewName -> advertiseIsRunningView, bidRelatedIdsViewName -> bidRelatedIdsView, + bidRequestImpressionWithPlaceholderViewName -> bidRequestImpressionWithPlaceholderView, keywordAdvertiseMappingIdsViewName -> keywordAdvertiseMappingIdsView, winningPriceInfoViewName -> winningPriceInfoView ) @@ -24,6 +27,7 @@ class DatabaseSchemaViews { lazy val viewNames = List( advertiseIsRunningViewName, bidRelatedIdsViewName, + bidRequestImpressionWithPlaceholderViewName, keywordAdvertiseMappingIdsViewName, winningPriceInfoViewName ) diff --git a/app/shared/com/ortb/persistent/schema/Tables.scala b/app/shared/com/ortb/persistent/schema/Tables.scala index b567e81..9f8b8b0 100644 --- a/app/shared/com/ortb/persistent/schema/Tables.scala +++ b/app/shared/com/ortb/persistent/schema/Tables.scala @@ -18,7 +18,7 @@ trait Tables { import slick.jdbc.{GetResult => GR} /** DDL for all tables. Call .create to execute. */ - lazy val schema: profile.SchemaDescription = Array(Advertise.schema, Advertiseisrunningview.schema, Auction.schema, Banneradvertisetype.schema, Bid.schema, Bidcontentcategoriesmapping.schema, Bidrelatedidsview.schema, Bidrequest.schema, Bidresponse.schema, Campaign.schema, Campaigntargetcity.schema, Campaigntargetoperatingsystem.schema, Campaigntargetsite.schema, Contentcategory.schema, Contentcontext.schema, Creativeattribute.schema, Demandsideplatform.schema, Devicetype.schema, Geomapping.schema, Impression.schema, Keyword.schema, Keywordadvertisemapping.schema, Keywordadvertisemappingidsview.schema, Logtrace.schema, Lostbid.schema, Nobidresponsetype.schema, Privatemarketplacedeal.schema, Publisher.schema, Seatbid.schema, Transaction.schema, Userclassification.schema, Videoplaybackmethod.schema, Videoresponseprotocol.schema, Winningpriceinfoview.schema).reduceLeft(_ ++ _) + lazy val schema: profile.SchemaDescription = Array(Advertise.schema, Advertiseisrunningview.schema, Auction.schema, Banneradvertisetype.schema, Bid.schema, Bidcontentcategoriesmapping.schema, Bidrelatedidsview.schema, Bidrequest.schema, Bidrequestimpressionwithplaceholderview.schema, Bidresponse.schema, Campaign.schema, Campaigntargetcity.schema, Campaigntargetoperatingsystem.schema, Campaigntargetsite.schema, Contentcategory.schema, Contentcontext.schema, Creativeattribute.schema, Demandsideplatform.schema, Devicetype.schema, Geomapping.schema, Impression.schema, Impressionplaceholder.schema, Keyword.schema, Keywordadvertisemapping.schema, Keywordadvertisemappingidsview.schema, Logtrace.schema, Lostbid.schema, Nobidresponsetype.schema, Privatemarketplacedeal.schema, Publisher.schema, Seatbid.schema, Transaction.schema, Userclassification.schema, Videoplaybackmethod.schema, Videoresponseprotocol.schema, Winningpriceinfoview.schema).reduceLeft(_ ++ _) @deprecated("Use .schema instead of .ddl", "3.0") def ddl = schema @@ -31,8 +31,9 @@ trait Tables { * @param bidurl Database column BidUrl SqlType(TEXT) * @param iframehtml Database column IFrameHtml SqlType(TEXT) * @param iscountryspecific Database column IsCountrySpecific SqlType(INTEGER), Length(1,false), Default(0) - * @param isbanner Database column IsBanner SqlType(INTEGER), Length(1,false), Default(Some(0)) + * @param isbanner Database column IsBanner SqlType(INTEGER), Length(1,false), Default(0) * @param isvideo Database column IsVideo SqlType(INTEGER), Length(1,false), Default(0) + * @param isnative Database column IsNative SqlType(INTEGER), Length(1,false), Default(0) * @param impressioncount Database column ImpressionCount SqlType(INTEGER), Default(0) * @param height Database column Height SqlType(INTEGER), Default(0) * @param width Database column Width SqlType(INTEGER), Default(0) @@ -40,24 +41,26 @@ trait Tables { * @param minwidth Database column MinWidth SqlType(INTEGER), Default(0) * @param maxheight Database column MaxHeight SqlType(INTEGER), Default(0) * @param maxwidth Database column MaxWidth SqlType(INTEGER), Default(0) - * @param isheightwidthempty Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(Some(1)) - * @param ismaxheightwidthempty Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(Some(1)) - * @param isminheightwidthempty Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(Some(1)) + * @param isheightwidthempty Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) + * @param ismaxheightwidthempty Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) + * @param isminheightwidthempty Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) * @param hasagerestriction Database column HasAgeRestriction SqlType(INTEGER), Length(1,false), Default(0) * @param minage Database column MinAge SqlType(INTEGER), Default(Some(0)) * @param maxage Database column MaxAge SqlType(INTEGER), Default(Some(0)) + * @param duration Database column Duration SqlType(INTEGER), Default(0) + * @param protocol Database column Protocol SqlType(INTEGER), Default(0) * @param createddatetimestamp Database column CreatedDateTimestamp SqlType(TIMESTAMP) */ - case class AdvertiseRow(advertiseid: Int, campaignid: Int, banneradvertisetypeid: Int, advertisetitle: String, contentcontextid: Option[Int], bidurl: String, iframehtml: Option[String], iscountryspecific: Int = 0, isbanner: Option[Int] = Some(0), isvideo: Int = 0, impressioncount: Int = 0, height: Int = 0, width: Int = 0, minheight: Int = 0, minwidth: Int = 0, maxheight: Int = 0, maxwidth: Int = 0, isheightwidthempty: Option[Int] = Some(1), ismaxheightwidthempty: Option[Int] = Some(1), isminheightwidthempty: Option[Int] = Some(1), hasagerestriction: Int = 0, minage: Option[Int] = Some(0), maxage: Option[Int] = Some(0), createddatetimestamp: java.time.Instant) + case class AdvertiseRow(advertiseid: Int, campaignid: Int, banneradvertisetypeid: Int, advertisetitle: String, contentcontextid: Option[Int], bidurl: String, iframehtml: Option[String], iscountryspecific: Int = 0, isbanner: Int = 0, isvideo: Int = 0, isnative: Int = 0, impressioncount: Int = 0, height: Int = 0, width: Int = 0, minheight: Int = 0, minwidth: Int = 0, maxheight: Int = 0, maxwidth: Int = 0, isheightwidthempty: Int = 1, ismaxheightwidthempty: Int = 1, isminheightwidthempty: Int = 1, hasagerestriction: Int = 0, minage: Option[Int] = Some(0), maxage: Option[Int] = Some(0), duration: Int = 0, protocol: Int = 0, createddatetimestamp: java.time.Instant) /** GetResult implicit for fetching AdvertiseRow objects using plain SQL queries */ implicit def GetResultAdvertiseRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[Int]], e3: GR[Option[String]], e4: GR[java.time.Instant]): GR[AdvertiseRow] = GR{ prs => import prs._ - AdvertiseRow(<<[Int], <<[Int], <<[Int], <<[String], <(r => AdvertiseRow(r(0).asInstanceOf[Option[Int]].get, r(1).asInstanceOf[Option[Int]].get, r(2).asInstanceOf[Option[Int]].get, r(3).asInstanceOf[Option[String]].get, r(4).asInstanceOf[Option[Int]], r(5).asInstanceOf[Option[String]].get, r(6).asInstanceOf[Option[String]], r(7).asInstanceOf[Option[Int]].get, r(8).asInstanceOf[Option[Int]], r(9).asInstanceOf[Option[Int]].get, r(10).asInstanceOf[Option[Int]].get, r(11).asInstanceOf[Option[Int]].get, r(12).asInstanceOf[Option[Int]].get, r(13).asInstanceOf[Option[Int]].get, r(14).asInstanceOf[Option[Int]].get, r(15).asInstanceOf[Option[Int]].get, r(16).asInstanceOf[Option[Int]].get, r(17).asInstanceOf[Option[Int]], r(18).asInstanceOf[Option[Int]], r(19).asInstanceOf[Option[Int]], r(20).asInstanceOf[Option[Int]].get, r(21).asInstanceOf[Option[Int]], r(22).asInstanceOf[Option[Int]], r(23).asInstanceOf[Option[java.time.Instant]].get), (_:Any) => throw new Exception("Inserting into ? projection not supported.")) + def ? = (Rep.Some(advertiseid) :: Rep.Some(campaignid) :: Rep.Some(banneradvertisetypeid) :: Rep.Some(advertisetitle) :: contentcontextid :: Rep.Some(bidurl) :: iframehtml :: Rep.Some(iscountryspecific) :: Rep.Some(isbanner) :: Rep.Some(isvideo) :: Rep.Some(isnative) :: Rep.Some(impressioncount) :: Rep.Some(height) :: Rep.Some(width) :: Rep.Some(minheight) :: Rep.Some(minwidth) :: Rep.Some(maxheight) :: Rep.Some(maxwidth) :: Rep.Some(isheightwidthempty) :: Rep.Some(ismaxheightwidthempty) :: Rep.Some(isminheightwidthempty) :: Rep.Some(hasagerestriction) :: minage :: maxage :: Rep.Some(duration) :: Rep.Some(protocol) :: Rep.Some(createddatetimestamp) :: HNil).shaped.<>(r => AdvertiseRow(r(0).asInstanceOf[Option[Int]].get, r(1).asInstanceOf[Option[Int]].get, r(2).asInstanceOf[Option[Int]].get, r(3).asInstanceOf[Option[String]].get, r(4).asInstanceOf[Option[Int]], r(5).asInstanceOf[Option[String]].get, r(6).asInstanceOf[Option[String]], r(7).asInstanceOf[Option[Int]].get, r(8).asInstanceOf[Option[Int]].get, r(9).asInstanceOf[Option[Int]].get, r(10).asInstanceOf[Option[Int]].get, r(11).asInstanceOf[Option[Int]].get, r(12).asInstanceOf[Option[Int]].get, r(13).asInstanceOf[Option[Int]].get, r(14).asInstanceOf[Option[Int]].get, r(15).asInstanceOf[Option[Int]].get, r(16).asInstanceOf[Option[Int]].get, r(17).asInstanceOf[Option[Int]].get, r(18).asInstanceOf[Option[Int]].get, r(19).asInstanceOf[Option[Int]].get, r(20).asInstanceOf[Option[Int]].get, r(21).asInstanceOf[Option[Int]].get, r(22).asInstanceOf[Option[Int]], r(23).asInstanceOf[Option[Int]], r(24).asInstanceOf[Option[Int]].get, r(25).asInstanceOf[Option[Int]].get, r(26).asInstanceOf[Option[java.time.Instant]].get), (_:Any) => throw new Exception("Inserting into ? projection not supported.")) /** Database column AdvertiseId SqlType(INTEGER), AutoInc, PrimaryKey */ val advertiseid: Rep[Int] = column[Int]("AdvertiseId", O.AutoInc, O.PrimaryKey) @@ -75,10 +78,12 @@ trait Tables { val iframehtml: Rep[Option[String]] = column[Option[String]]("IFrameHtml") /** Database column IsCountrySpecific SqlType(INTEGER), Length(1,false), Default(0) */ val iscountryspecific: Rep[Int] = column[Int]("IsCountrySpecific", O.Length(1,varying=false), O.Default(0)) - /** Database column IsBanner SqlType(INTEGER), Length(1,false), Default(Some(0)) */ - val isbanner: Rep[Option[Int]] = column[Option[Int]]("IsBanner", O.Length(1,varying=false), O.Default(Some(0))) + /** Database column IsBanner SqlType(INTEGER), Length(1,false), Default(0) */ + val isbanner: Rep[Int] = column[Int]("IsBanner", O.Length(1,varying=false), O.Default(0)) /** Database column IsVideo SqlType(INTEGER), Length(1,false), Default(0) */ val isvideo: Rep[Int] = column[Int]("IsVideo", O.Length(1,varying=false), O.Default(0)) + /** Database column IsNative SqlType(INTEGER), Length(1,false), Default(0) */ + val isnative: Rep[Int] = column[Int]("IsNative", O.Length(1,varying=false), O.Default(0)) /** Database column ImpressionCount SqlType(INTEGER), Default(0) */ val impressioncount: Rep[Int] = column[Int]("ImpressionCount", O.Default(0)) /** Database column Height SqlType(INTEGER), Default(0) */ @@ -93,18 +98,22 @@ trait Tables { val maxheight: Rep[Int] = column[Int]("MaxHeight", O.Default(0)) /** Database column MaxWidth SqlType(INTEGER), Default(0) */ val maxwidth: Rep[Int] = column[Int]("MaxWidth", O.Default(0)) - /** Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(Some(1)) */ - val isheightwidthempty: Rep[Option[Int]] = column[Option[Int]]("IsHeightWidthEmpty", O.Length(1,varying=false), O.Default(Some(1))) - /** Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(Some(1)) */ - val ismaxheightwidthempty: Rep[Option[Int]] = column[Option[Int]]("IsMaxHeightWidthEmpty", O.Length(1,varying=false), O.Default(Some(1))) - /** Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(Some(1)) */ - val isminheightwidthempty: Rep[Option[Int]] = column[Option[Int]]("IsMinHeightWidthEmpty", O.Length(1,varying=false), O.Default(Some(1))) + /** Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) */ + val isheightwidthempty: Rep[Int] = column[Int]("IsHeightWidthEmpty", O.Length(1,varying=false), O.Default(1)) + /** Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) */ + val ismaxheightwidthempty: Rep[Int] = column[Int]("IsMaxHeightWidthEmpty", O.Length(1,varying=false), O.Default(1)) + /** Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) */ + val isminheightwidthempty: Rep[Int] = column[Int]("IsMinHeightWidthEmpty", O.Length(1,varying=false), O.Default(1)) /** Database column HasAgeRestriction SqlType(INTEGER), Length(1,false), Default(0) */ val hasagerestriction: Rep[Int] = column[Int]("HasAgeRestriction", O.Length(1,varying=false), O.Default(0)) /** Database column MinAge SqlType(INTEGER), Default(Some(0)) */ val minage: Rep[Option[Int]] = column[Option[Int]]("MinAge", O.Default(Some(0))) /** Database column MaxAge SqlType(INTEGER), Default(Some(0)) */ val maxage: Rep[Option[Int]] = column[Option[Int]]("MaxAge", O.Default(Some(0))) + /** Database column Duration SqlType(INTEGER), Default(0) */ + val duration: Rep[Int] = column[Int]("Duration", O.Default(0)) + /** Database column Protocol SqlType(INTEGER), Default(0) */ + val protocol: Rep[Int] = column[Int]("Protocol", O.Default(0)) /** Database column CreatedDateTimestamp SqlType(TIMESTAMP) */ val createddatetimestamp: Rep[java.time.Instant] = column[java.time.Instant]("CreatedDateTimestamp") @@ -129,6 +138,7 @@ trait Tables { * @param iscountryspecific Database column IsCountrySpecific SqlType(INTEGER), Length(1,false) * @param isbanner Database column IsBanner SqlType(INTEGER), Length(1,false) * @param isvideo Database column IsVideo SqlType(INTEGER), Length(1,false) + * @param isnative Database column IsNative SqlType(INTEGER), Length(1,false) * @param impressioncount Database column ImpressionCount SqlType(INTEGER) * @param height Database column Height SqlType(INTEGER) * @param width Database column Width SqlType(INTEGER) @@ -142,17 +152,19 @@ trait Tables { * @param hasagerestriction Database column HasAgeRestriction SqlType(INTEGER), Length(1,false) * @param minage Database column MinAge SqlType(INTEGER) * @param maxage Database column MaxAge SqlType(INTEGER) + * @param duration Database column Duration SqlType(INTEGER) + * @param protocol Database column Protocol SqlType(INTEGER) * @param createddatetimestamp Database column CreatedDateTimestamp SqlType(TIMESTAMP) * @param isrunning Database column IsRunning SqlType(INTEGER), Length(1,false) */ - case class AdvertiseisrunningviewRow(advertiseid: Option[Int], campaignid: Option[Int], banneradvertisetypeid: Option[Int], advertisetitle: Option[String], contentcontextid: Option[Int], bidurl: Option[String], iframehtml: Option[String], iscountryspecific: Option[Int], isbanner: Option[Int], isvideo: Option[Int], impressioncount: Option[Int], height: Option[Int], width: Option[Int], minheight: Option[Int], minwidth: Option[Int], maxheight: Option[Int], maxwidth: Option[Int], isheightwidthempty: Option[Int], ismaxheightwidthempty: Option[Int], isminheightwidthempty: Option[Int], hasagerestriction: Option[Int], minage: Option[Int], maxage: Option[Int], createddatetimestamp: Option[java.time.Instant], isrunning: Option[Int]) + case class AdvertiseisrunningviewRow(advertiseid: Option[Int], campaignid: Option[Int], banneradvertisetypeid: Option[Int], advertisetitle: Option[String], contentcontextid: Option[Int], bidurl: Option[String], iframehtml: Option[String], iscountryspecific: Option[Int], isbanner: Option[Int], isvideo: Option[Int], isnative: Option[Int], impressioncount: Option[Int], height: Option[Int], width: Option[Int], minheight: Option[Int], minwidth: Option[Int], maxheight: Option[Int], maxwidth: Option[Int], isheightwidthempty: Option[Int], ismaxheightwidthempty: Option[Int], isminheightwidthempty: Option[Int], hasagerestriction: Option[Int], minage: Option[Int], maxage: Option[Int], duration: Option[Int], protocol: Option[Int], createddatetimestamp: Option[java.time.Instant], isrunning: Option[Int]) /** GetResult implicit for fetching AdvertiseisrunningviewRow objects using plain SQL queries */ implicit def GetResultAdvertiseisrunningviewRow(implicit e0: GR[Option[Int]], e1: GR[Option[String]], e2: GR[Option[java.time.Instant]]): GR[AdvertiseisrunningviewRow] = GR{ prs => import prs._ - AdvertiseisrunningviewRow(< import prs._ - BidrequestRow.tupled((<<[Int], <<[Int], < (BidrequestRow.tupled, BidrequestRow.unapply) + def * = (bidrequestid, demandsideplatformid, auctionid, isbanner, isvideo, countries, cities, targetedsites, targetedcities, rawbidrequestjson, currency, contentcontextid, iswontheauction, createddatetimestamp) <> (BidrequestRow.tupled, BidrequestRow.unapply) /** Maps whole row to an option. Useful for outer joins. */ - def ? = ((Rep.Some(bidrequestid), Rep.Some(demandsideplatformid), auctionid, Rep.Some(isbanner), Rep.Some(isvideo), height, width, countries, cities, targetedsites, targetedcities, Rep.Some(rawbidrequestjson), currency, contentcontextid, Rep.Some(iswontheauction), Rep.Some(createddatetimestamp))).shaped.<>({r=>import r._; _1.map(_=> BidrequestRow.tupled((_1.get, _2.get, _3, _4.get, _5.get, _6, _7, _8, _9, _10, _11, _12.get, _13, _14, _15.get, _16.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) + def ? = ((Rep.Some(bidrequestid), Rep.Some(demandsideplatformid), auctionid, Rep.Some(isbanner), Rep.Some(isvideo), countries, cities, targetedsites, targetedcities, Rep.Some(rawbidrequestjson), currency, contentcontextid, Rep.Some(iswontheauction), Rep.Some(createddatetimestamp))).shaped.<>({r=>import r._; _1.map(_=> BidrequestRow.tupled((_1.get, _2.get, _3, _4.get, _5.get, _6, _7, _8, _9, _10.get, _11, _12, _13.get, _14.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) /** Database column BidRequestId SqlType(INTEGER), AutoInc, PrimaryKey */ val bidrequestid: Rep[Int] = column[Int]("BidRequestId", O.AutoInc, O.PrimaryKey) @@ -457,10 +473,6 @@ trait Tables { val isbanner: Rep[Int] = column[Int]("IsBanner", O.Length(1,varying=false), O.Default(0)) /** Database column IsVideo SqlType(INTEGER), Length(1,false), Default(0) */ val isvideo: Rep[Int] = column[Int]("IsVideo", O.Length(1,varying=false), O.Default(0)) - /** Database column Height SqlType(INTEGER), Default(None) */ - val height: Rep[Option[Int]] = column[Option[Int]]("Height", O.Default(None)) - /** Database column Width SqlType(INTEGER), Default(None) */ - val width: Rep[Option[Int]] = column[Option[Int]]("Width", O.Default(None)) /** Database column Countries SqlType(TEXT), Default(None) */ val countries: Rep[Option[String]] = column[Option[String]]("Countries", O.Default(None)) /** Database column Cities SqlType(TEXT), Default(None) */ @@ -490,6 +502,144 @@ trait Tables { /** Collection-like TableQuery object for table Bidrequest */ lazy val Bidrequest = new TableQuery(tag => new Bidrequest(tag)) + /** Entity class storing rows of table Bidrequestimpressionwithplaceholderview + * @param bidrequestid Database column BidRequestId SqlType(INTEGER) + * @param createddatetimestamp Database column CreatedDateTimestamp SqlType(TIMESTAMP) + * @param iswontheauction Database column IsWonTheAuction SqlType(INTEGER), Length(1,false) + * @param contentcontextid Database column ContentContextId SqlType(INTEGER) + * @param currency Database column Currency SqlType(TEXT), Length(5,false) + * @param rawbidrequestjson Database column RawBidRequestJson SqlType(TEXT) + * @param targetedcities Database column TargetedCities SqlType(TEXT) + * @param targetedsites Database column TargetedSites SqlType(TEXT) + * @param cities Database column Cities SqlType(TEXT) + * @param countries Database column Countries SqlType(TEXT) + * @param isvideo Database column IsVideo SqlType(INTEGER), Length(1,false) + * @param isbanner Database column IsBanner SqlType(INTEGER), Length(1,false) + * @param auctionid Database column AuctionId SqlType(INTEGER) + * @param demandsideplatformid Database column DemandSidePlatformId SqlType(INTEGER) + * @param contentcontext Database column ContentContext SqlType(TEXT) + * @param isnativeplaceholder Database column IsNativePlaceHolder SqlType(INTEGER), Length(1,false) + * @param isvideoplaceholder Database column IsVideoPlaceHolder SqlType(INTEGER), Length(1,false) + * @param isbannnerplaceholder Database column IsBannnerPlaceHolder SqlType(INTEGER), Length(1,false) + * @param createddatetimestampimpressionplaceholder Database column CreatedDateTimestampImpressionPlaceholder SqlType(TIMESTAMP) + * @param istopframe Database column IsTopFrame SqlType(INTEGER), Length(1,false) + * @param position Database column Position SqlType(INTEGER) + * @param mimes Database column Mimes SqlType(TEXT) + * @param isminheightwidthempty Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false) + * @param isheightwidthempty Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false) + * @param maxwidth Database column MaxWidth SqlType(INTEGER) + * @param maxheight Database column MaxHeight SqlType(INTEGER) + * @param minwidth Database column MinWidth SqlType(INTEGER) + * @param minheight Database column MinHeight SqlType(INTEGER) + * @param width Database column Width SqlType(INTEGER) + * @param height Database column Height SqlType(INTEGER) + * @param createddatetimestampimpression Database column CreatedDateTimestampImpression SqlType(TIMESTAMP) + * @param ismaxheightwidthempty Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false) + * @param advertisedisplayeddate Database column AdvertiseDisplayedDate SqlType(TIMESTAMP) + * @param impressionid Database column ImpressionId SqlType(INTEGER) + * @param hash Database column Hash SqlType(TEXT) + * @param bidfloorcur Database column BidfloorCur SqlType(TEXT) + * @param bidfloor Database column Bidfloor SqlType(REAL) + * @param isimpressionserved Database column IsImpressionServed SqlType(INTEGER), Length(1,false) + * @param isimpressionwonbyauction Database column IsImpressionWonByAuction SqlType(INTEGER), Length(1,false) + * @param rawimpressionjson Database column RawImpressionJson SqlType(TEXT) + * @param bidresponseid Database column BidResponseId SqlType(INTEGER) */ + case class BidrequestimpressionwithplaceholderviewRow(bidrequestid: Option[Int], createddatetimestamp: Option[java.time.Instant], iswontheauction: Option[Int], contentcontextid: Option[Int], currency: Option[String], rawbidrequestjson: Option[String], targetedcities: Option[String], targetedsites: Option[String], cities: Option[String], countries: Option[String], isvideo: Option[Int], isbanner: Option[Int], auctionid: Option[Int], demandsideplatformid: Option[Int], contentcontext: Option[String], isnativeplaceholder: Option[Int], isvideoplaceholder: Option[Int], isbannnerplaceholder: Option[Int], createddatetimestampimpressionplaceholder: Option[java.time.Instant], istopframe: Option[Int], position: Option[Int], mimes: Option[String], isminheightwidthempty: Option[Int], isheightwidthempty: Option[Int], maxwidth: Option[Int], maxheight: Option[Int], minwidth: Option[Int], minheight: Option[Int], width: Option[Int], height: Option[Int], createddatetimestampimpression: Option[java.time.Instant], ismaxheightwidthempty: Option[Int], advertisedisplayeddate: Option[java.time.Instant], impressionid: Option[Int], hash: Option[String], bidfloorcur: Option[String], bidfloor: Option[Double], isimpressionserved: Option[Int], isimpressionwonbyauction: Option[Int], rawimpressionjson: Option[String], bidresponseid: Option[Int]) + /** GetResult implicit for fetching BidrequestimpressionwithplaceholderviewRow objects using plain SQL queries */ + implicit def GetResultBidrequestimpressionwithplaceholderviewRow(implicit e0: GR[Option[Int]], e1: GR[Option[java.time.Instant]], e2: GR[Option[String]], e3: GR[Option[Double]]): GR[BidrequestimpressionwithplaceholderviewRow] = GR{ + prs => import prs._ + BidrequestimpressionwithplaceholderviewRow(< new Bidrequestimpressionwithplaceholderview(tag)) + /** Entity class storing rows of table Bidresponse * @param bidresponseid Database column BidResponseId SqlType(INTEGER), AutoInc, PrimaryKey * @param currency Database column Currency SqlType(TEXT), Length(5,false), Default(Some(USD)) @@ -853,51 +1003,133 @@ trait Tables { /** Entity class storing rows of table Impression * @param impressionid Database column ImpressionId SqlType(INTEGER), AutoInc, PrimaryKey - * @param rawimpressionjson Database column RawImpressionJson SqlType(TEXT) - * @param bidid Database column BidId SqlType(INTEGER), Default(None) - * @param isimpressionservedorwonbyauction Database column IsImpressionServedOrWonByAuction SqlType(INTEGER), Length(1,false), Default(Some(0)) - * @param bidfloor Database column Bidfloor SqlType(REAL), Default(Some(0.0)) - * @param bidfloorcur Database column BidfloorCur SqlType(TEXT) + * @param bidresponseid Database column BidResponseId SqlType(INTEGER), Default(None) + * @param bidrequestid Database column BidRequestId SqlType(INTEGER), Default(None) + * @param rawimpressionjson Database column RawImpressionJson SqlType(TEXT), Default() + * @param isimpressionwonbyauction Database column IsImpressionWonByAuction SqlType(INTEGER), Length(1,false), Default(0) + * @param isimpressionserved Database column IsImpressionServed SqlType(INTEGER), Length(1,false), Default(0) + * @param bidfloor Database column Bidfloor SqlType(REAL), Default(0.0) + * @param bidfloorcur Database column BidfloorCur SqlType(TEXT), Default(USD) * @param hash Database column Hash SqlType(TEXT), Default(None) - * @param displaydate Database column DisplayDate SqlType(TIMESTAMP) + * @param advertisedisplayeddate Database column AdvertiseDisplayedDate SqlType(TIMESTAMP) * @param createddatetimestamp Database column CreatedDateTimestamp SqlType(TIMESTAMP) */ - case class ImpressionRow(impressionid: Int, rawimpressionjson: String, bidid: Option[Int] = None, isimpressionservedorwonbyauction: Option[Int] = Some(0), bidfloor: Option[Double] = Some(0.0), bidfloorcur: Option[String], hash: Option[String] = None, displaydate: java.time.Instant, createddatetimestamp: java.time.Instant) + case class ImpressionRow(impressionid: Int, bidresponseid: Option[Int] = None, bidrequestid: Option[Int] = None, rawimpressionjson: String = "", isimpressionwonbyauction: Int = 0, isimpressionserved: Int = 0, bidfloor: Double = 0.0, bidfloorcur: String = "USD", hash: Option[String] = None, advertisedisplayeddate: Option[java.time.Instant], createddatetimestamp: java.time.Instant) /** GetResult implicit for fetching ImpressionRow objects using plain SQL queries */ - implicit def GetResultImpressionRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[Int]], e3: GR[Option[Double]], e4: GR[Option[String]], e5: GR[java.time.Instant]): GR[ImpressionRow] = GR{ + implicit def GetResultImpressionRow(implicit e0: GR[Int], e1: GR[Option[Int]], e2: GR[String], e3: GR[Double], e4: GR[Option[String]], e5: GR[Option[java.time.Instant]], e6: GR[java.time.Instant]): GR[ImpressionRow] = GR{ prs => import prs._ - ImpressionRow.tupled((<<[Int], <<[String], < (ImpressionRow.tupled, ImpressionRow.unapply) + def * = (impressionid, bidresponseid, bidrequestid, rawimpressionjson, isimpressionwonbyauction, isimpressionserved, bidfloor, bidfloorcur, hash, advertisedisplayeddate, createddatetimestamp) <> (ImpressionRow.tupled, ImpressionRow.unapply) /** Maps whole row to an option. Useful for outer joins. */ - def ? = ((Rep.Some(impressionid), Rep.Some(rawimpressionjson), bidid, isimpressionservedorwonbyauction, bidfloor, bidfloorcur, hash, Rep.Some(displaydate), Rep.Some(createddatetimestamp))).shaped.<>({r=>import r._; _1.map(_=> ImpressionRow.tupled((_1.get, _2.get, _3, _4, _5, _6, _7, _8.get, _9.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) + def ? = ((Rep.Some(impressionid), bidresponseid, bidrequestid, Rep.Some(rawimpressionjson), Rep.Some(isimpressionwonbyauction), Rep.Some(isimpressionserved), Rep.Some(bidfloor), Rep.Some(bidfloorcur), hash, advertisedisplayeddate, Rep.Some(createddatetimestamp))).shaped.<>({r=>import r._; _1.map(_=> ImpressionRow.tupled((_1.get, _2, _3, _4.get, _5.get, _6.get, _7.get, _8.get, _9, _10, _11.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) /** Database column ImpressionId SqlType(INTEGER), AutoInc, PrimaryKey */ val impressionid: Rep[Int] = column[Int]("ImpressionId", O.AutoInc, O.PrimaryKey) - /** Database column RawImpressionJson SqlType(TEXT) */ - val rawimpressionjson: Rep[String] = column[String]("RawImpressionJson") - /** Database column BidId SqlType(INTEGER), Default(None) */ - val bidid: Rep[Option[Int]] = column[Option[Int]]("BidId", O.Default(None)) - /** Database column IsImpressionServedOrWonByAuction SqlType(INTEGER), Length(1,false), Default(Some(0)) */ - val isimpressionservedorwonbyauction: Rep[Option[Int]] = column[Option[Int]]("IsImpressionServedOrWonByAuction", O.Length(1,varying=false), O.Default(Some(0))) - /** Database column Bidfloor SqlType(REAL), Default(Some(0.0)) */ - val bidfloor: Rep[Option[Double]] = column[Option[Double]]("Bidfloor", O.Default(Some(0.0))) - /** Database column BidfloorCur SqlType(TEXT) */ - val bidfloorcur: Rep[Option[String]] = column[Option[String]]("BidfloorCur") + /** Database column BidResponseId SqlType(INTEGER), Default(None) */ + val bidresponseid: Rep[Option[Int]] = column[Option[Int]]("BidResponseId", O.Default(None)) + /** Database column BidRequestId SqlType(INTEGER), Default(None) */ + val bidrequestid: Rep[Option[Int]] = column[Option[Int]]("BidRequestId", O.Default(None)) + /** Database column RawImpressionJson SqlType(TEXT), Default() */ + val rawimpressionjson: Rep[String] = column[String]("RawImpressionJson", O.Default("")) + /** Database column IsImpressionWonByAuction SqlType(INTEGER), Length(1,false), Default(0) */ + val isimpressionwonbyauction: Rep[Int] = column[Int]("IsImpressionWonByAuction", O.Length(1,varying=false), O.Default(0)) + /** Database column IsImpressionServed SqlType(INTEGER), Length(1,false), Default(0) */ + val isimpressionserved: Rep[Int] = column[Int]("IsImpressionServed", O.Length(1,varying=false), O.Default(0)) + /** Database column Bidfloor SqlType(REAL), Default(0.0) */ + val bidfloor: Rep[Double] = column[Double]("Bidfloor", O.Default(0.0)) + /** Database column BidfloorCur SqlType(TEXT), Default(USD) */ + val bidfloorcur: Rep[String] = column[String]("BidfloorCur", O.Default("USD")) /** Database column Hash SqlType(TEXT), Default(None) */ val hash: Rep[Option[String]] = column[Option[String]]("Hash", O.Default(None)) - /** Database column DisplayDate SqlType(TIMESTAMP) */ - val displaydate: Rep[java.time.Instant] = column[java.time.Instant]("DisplayDate") + /** Database column AdvertiseDisplayedDate SqlType(TIMESTAMP) */ + val advertisedisplayeddate: Rep[Option[java.time.Instant]] = column[Option[java.time.Instant]]("AdvertiseDisplayedDate") /** Database column CreatedDateTimestamp SqlType(TIMESTAMP) */ val createddatetimestamp: Rep[java.time.Instant] = column[java.time.Instant]("CreatedDateTimestamp") - /** Foreign key referencing Bid (database name Bid_FK_1) */ - lazy val bidFk = foreignKey("Bid_FK_1", bidid, Bid)(r => Rep.Some(r.bidid), onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction) + /** Foreign key referencing Bidrequest (database name BidRequest_FK_1) */ + lazy val bidrequestFk = foreignKey("BidRequest_FK_1", bidrequestid, Bidrequest)(r => Rep.Some(r.bidrequestid), onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction) + /** Foreign key referencing Bidresponse (database name BidResponse_FK_2) */ + lazy val bidresponseFk = foreignKey("BidResponse_FK_2", bidresponseid, Bidresponse)(r => Rep.Some(r.bidresponseid), onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction) } /** Collection-like TableQuery object for table Impression */ lazy val Impression = new TableQuery(tag => new Impression(tag)) + /** Entity class storing rows of table Impressionplaceholder + * @param impressionplaceholderid Database column ImpressionPlaceholderId SqlType(INTEGER), AutoInc, PrimaryKey + * @param impressionid Database column ImpressionId SqlType(INTEGER) + * @param isbanner Database column IsBanner SqlType(INTEGER), Length(1,false), Default(0) + * @param isvideo Database column IsVideo SqlType(INTEGER), Length(1,false), Default(0) + * @param isnative Database column IsNative SqlType(INTEGER), Length(1,false), Default(0) + * @param height Database column Height SqlType(INTEGER), Default(0) + * @param width Database column Width SqlType(INTEGER), Default(0) + * @param minheight Database column MinHeight SqlType(INTEGER), Default(0) + * @param minwidth Database column MinWidth SqlType(INTEGER), Default(0) + * @param maxheight Database column MaxHeight SqlType(INTEGER), Default(0) + * @param maxwidth Database column MaxWidth SqlType(INTEGER), Default(0) + * @param isheightwidthempty Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) + * @param ismaxheightwidthempty Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) + * @param isminheightwidthempty Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) + * @param mimes Database column Mimes SqlType(TEXT), Default(None) + * @param position Database column Position SqlType(INTEGER), Default(None) + * @param istopframe Database column IsTopFrame SqlType(INTEGER), Length(1,false), Default(0) + * @param createddatetimestamp Database column CreatedDateTimestamp SqlType(TIMESTAMP) */ + case class ImpressionplaceholderRow(impressionplaceholderid: Int, impressionid: Int, isbanner: Int = 0, isvideo: Int = 0, isnative: Int = 0, height: Int = 0, width: Int = 0, minheight: Int = 0, minwidth: Int = 0, maxheight: Int = 0, maxwidth: Int = 0, isheightwidthempty: Int = 1, ismaxheightwidthempty: Int = 1, isminheightwidthempty: Int = 1, mimes: Option[String] = None, position: Option[Int] = None, istopframe: Int = 0, createddatetimestamp: java.time.Instant) + /** GetResult implicit for fetching ImpressionplaceholderRow objects using plain SQL queries */ + implicit def GetResultImpressionplaceholderRow(implicit e0: GR[Int], e1: GR[Option[String]], e2: GR[Option[Int]], e3: GR[java.time.Instant]): GR[ImpressionplaceholderRow] = GR{ + prs => import prs._ + ImpressionplaceholderRow.tupled((<<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], <<[Int], < (ImpressionplaceholderRow.tupled, ImpressionplaceholderRow.unapply) + /** Maps whole row to an option. Useful for outer joins. */ + def ? = ((Rep.Some(impressionplaceholderid), Rep.Some(impressionid), Rep.Some(isbanner), Rep.Some(isvideo), Rep.Some(isnative), Rep.Some(height), Rep.Some(width), Rep.Some(minheight), Rep.Some(minwidth), Rep.Some(maxheight), Rep.Some(maxwidth), Rep.Some(isheightwidthempty), Rep.Some(ismaxheightwidthempty), Rep.Some(isminheightwidthempty), mimes, position, Rep.Some(istopframe), Rep.Some(createddatetimestamp))).shaped.<>({r=>import r._; _1.map(_=> ImpressionplaceholderRow.tupled((_1.get, _2.get, _3.get, _4.get, _5.get, _6.get, _7.get, _8.get, _9.get, _10.get, _11.get, _12.get, _13.get, _14.get, _15, _16, _17.get, _18.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) + + /** Database column ImpressionPlaceholderId SqlType(INTEGER), AutoInc, PrimaryKey */ + val impressionplaceholderid: Rep[Int] = column[Int]("ImpressionPlaceholderId", O.AutoInc, O.PrimaryKey) + /** Database column ImpressionId SqlType(INTEGER) */ + val impressionid: Rep[Int] = column[Int]("ImpressionId") + /** Database column IsBanner SqlType(INTEGER), Length(1,false), Default(0) */ + val isbanner: Rep[Int] = column[Int]("IsBanner", O.Length(1,varying=false), O.Default(0)) + /** Database column IsVideo SqlType(INTEGER), Length(1,false), Default(0) */ + val isvideo: Rep[Int] = column[Int]("IsVideo", O.Length(1,varying=false), O.Default(0)) + /** Database column IsNative SqlType(INTEGER), Length(1,false), Default(0) */ + val isnative: Rep[Int] = column[Int]("IsNative", O.Length(1,varying=false), O.Default(0)) + /** Database column Height SqlType(INTEGER), Default(0) */ + val height: Rep[Int] = column[Int]("Height", O.Default(0)) + /** Database column Width SqlType(INTEGER), Default(0) */ + val width: Rep[Int] = column[Int]("Width", O.Default(0)) + /** Database column MinHeight SqlType(INTEGER), Default(0) */ + val minheight: Rep[Int] = column[Int]("MinHeight", O.Default(0)) + /** Database column MinWidth SqlType(INTEGER), Default(0) */ + val minwidth: Rep[Int] = column[Int]("MinWidth", O.Default(0)) + /** Database column MaxHeight SqlType(INTEGER), Default(0) */ + val maxheight: Rep[Int] = column[Int]("MaxHeight", O.Default(0)) + /** Database column MaxWidth SqlType(INTEGER), Default(0) */ + val maxwidth: Rep[Int] = column[Int]("MaxWidth", O.Default(0)) + /** Database column IsHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) */ + val isheightwidthempty: Rep[Int] = column[Int]("IsHeightWidthEmpty", O.Length(1,varying=false), O.Default(1)) + /** Database column IsMaxHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) */ + val ismaxheightwidthempty: Rep[Int] = column[Int]("IsMaxHeightWidthEmpty", O.Length(1,varying=false), O.Default(1)) + /** Database column IsMinHeightWidthEmpty SqlType(INTEGER), Length(1,false), Default(1) */ + val isminheightwidthempty: Rep[Int] = column[Int]("IsMinHeightWidthEmpty", O.Length(1,varying=false), O.Default(1)) + /** Database column Mimes SqlType(TEXT), Default(None) */ + val mimes: Rep[Option[String]] = column[Option[String]]("Mimes", O.Default(None)) + /** Database column Position SqlType(INTEGER), Default(None) */ + val position: Rep[Option[Int]] = column[Option[Int]]("Position", O.Default(None)) + /** Database column IsTopFrame SqlType(INTEGER), Length(1,false), Default(0) */ + val istopframe: Rep[Int] = column[Int]("IsTopFrame", O.Length(1,varying=false), O.Default(0)) + /** Database column CreatedDateTimestamp SqlType(TIMESTAMP) */ + val createddatetimestamp: Rep[java.time.Instant] = column[java.time.Instant]("CreatedDateTimestamp") + + /** Foreign key referencing Impression (database name Impression_FK_1) */ + lazy val impressionFk = foreignKey("Impression_FK_1", impressionid, Impression)(r => r.impressionid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction) + } + /** Collection-like TableQuery object for table Impressionplaceholder */ + lazy val Impressionplaceholder = new TableQuery(tag => new Impressionplaceholder(tag)) + /** Entity class storing rows of table Keyword * @param keywordid Database column KeywordId SqlType(INTEGER), AutoInc, PrimaryKey * @param keyword Database column Keyword SqlType(TEXT) */ @@ -961,16 +1193,17 @@ trait Tables { * @param banneradvertisetypeid Database column BannerAdvertiseTypeId SqlType(INTEGER) * @param isvideo Database column IsVideo SqlType(INTEGER), Length(1,false) * @param isbanner Database column IsBanner SqlType(INTEGER), Length(1,false) + * @param isnative Database column IsNative SqlType(INTEGER), Length(1,false) * @param contentcontextid Database column ContentContextId SqlType(INTEGER) */ - case class KeywordadvertisemappingidsviewRow(keywordid: Option[Int], keyword: Option[String], keywordadvertisemappingid: Option[Int], advertiseid: Option[Int], campaignid: Option[Int], banneradvertisetypeid: Option[Int], isvideo: Option[Int], isbanner: Option[Int], contentcontextid: Option[Int]) + case class KeywordadvertisemappingidsviewRow(keywordid: Option[Int], keyword: Option[String], keywordadvertisemappingid: Option[Int], advertiseid: Option[Int], campaignid: Option[Int], banneradvertisetypeid: Option[Int], isvideo: Option[Int], isbanner: Option[Int], isnative: Option[Int], contentcontextid: Option[Int]) /** GetResult implicit for fetching KeywordadvertisemappingidsviewRow objects using plain SQL queries */ implicit def GetResultKeywordadvertisemappingidsviewRow(implicit e0: GR[Option[Int]], e1: GR[Option[String]]): GR[KeywordadvertisemappingidsviewRow] = GR{ prs => import prs._ - KeywordadvertisemappingidsviewRow.tupled((< (KeywordadvertisemappingidsviewRow.tupled, KeywordadvertisemappingidsviewRow.unapply) + def * = (keywordid, keyword, keywordadvertisemappingid, advertiseid, campaignid, banneradvertisetypeid, isvideo, isbanner, isnative, contentcontextid) <> (KeywordadvertisemappingidsviewRow.tupled, KeywordadvertisemappingidsviewRow.unapply) /** Database column KeywordId SqlType(INTEGER) */ val keywordid: Rep[Option[Int]] = column[Option[Int]]("KeywordId") @@ -988,6 +1221,8 @@ trait Tables { val isvideo: Rep[Option[Int]] = column[Option[Int]]("IsVideo", O.Length(1,varying=false)) /** Database column IsBanner SqlType(INTEGER), Length(1,false) */ val isbanner: Rep[Option[Int]] = column[Option[Int]]("IsBanner", O.Length(1,varying=false)) + /** Database column IsNative SqlType(INTEGER), Length(1,false) */ + val isnative: Rep[Option[Int]] = column[Option[Int]]("IsNative", O.Length(1,varying=false)) /** Database column ContentContextId SqlType(INTEGER) */ val contentcontextid: Rep[Option[Int]] = column[Option[Int]]("ContentContextId") } @@ -1347,66 +1582,72 @@ trait Tables { /** Entity class storing rows of table Winningpriceinfoview * @param bidid Database column BidId SqlType(INTEGER) - * @param impressionid Database column ImpressionId SqlType(INTEGER) + * @param iswon Database column IsWon SqlType(INTEGER), Length(1,false) * @param seatbidid Database column SeatBidId SqlType(INTEGER) * @param campaignid Database column CampaignId SqlType(INTEGER) - * @param auctionid Database column AuctionId SqlType(INTEGER) + * @param advertiseid Database column AdvertiseId SqlType(INTEGER) + * @param dealbiddingprice Database column DealBiddingPrice SqlType(REAL) + * @param actualwiningprice Database column ActualWiningPrice SqlType(REAL) + * @param biddingcreateddatetimestamp Database column BiddingCreatedDateTimestamp SqlType(TIMESTAMP) + * @param impressionid Database column ImpressionId SqlType(INTEGER) * @param bidrequestid Database column BidRequestId SqlType(INTEGER) * @param bidresponseid Database column BidResponseId SqlType(INTEGER) - * @param advertiseid Database column AdvertiseId SqlType(INTEGER) * @param demandsideplatformid Database column DemandSidePlatformId SqlType(INTEGER) + * @param auctionid Database column AuctionId SqlType(INTEGER) * @param auctionwinningprice Database column AuctionWinningPrice SqlType(REAL) - * @param dealbiddingprice Database column DealBiddingPrice SqlType(REAL) - * @param actualwiningprice Database column ActualWiningPrice SqlType(REAL) * @param auctioncreateddatetimestamp Database column AuctionCreatedDateTimestamp SqlType(TIMESTAMP) - * @param biddingcreateddatetimestamp Database column BiddingCreatedDateTimestamp SqlType(TIMESTAMP) * @param impressioncreateddatetimestamp Database column ImpressionCreatedDateTimestamp SqlType(TIMESTAMP) - * @param iswon Database column IsWon SqlType(INTEGER), Length(1,false) - * @param isgroupbid Database column IsGroupBid SqlType(INTEGER), Length(1,false) */ - case class WinningpriceinfoviewRow(bidid: Option[Int], impressionid: Option[Int], seatbidid: Option[Int], campaignid: Option[Int], auctionid: Option[Int], bidrequestid: Option[Int], bidresponseid: Option[Int], advertiseid: Option[Int], demandsideplatformid: Option[Int], auctionwinningprice: Option[Double], dealbiddingprice: Option[Double], actualwiningprice: Option[Double], auctioncreateddatetimestamp: Option[java.time.Instant], biddingcreateddatetimestamp: Option[java.time.Instant], impressioncreateddatetimestamp: Option[java.time.Instant], iswon: Option[Int], isgroupbid: Option[Int]) + * @param isgroupbid Database column IsGroupBid SqlType(INTEGER), Length(1,false) + * @param bidfloorcur Database column BidfloorCur SqlType(TEXT) + * @param bidfloor Database column Bidfloor SqlType(REAL) */ + case class WinningpriceinfoviewRow(bidid: Option[Int], iswon: Option[Int], seatbidid: Option[Int], campaignid: Option[Int], advertiseid: Option[Int], dealbiddingprice: Option[Double], actualwiningprice: Option[Double], biddingcreateddatetimestamp: Option[java.time.Instant], impressionid: Option[Int], bidrequestid: Option[Int], bidresponseid: Option[Int], demandsideplatformid: Option[Int], auctionid: Option[Int], auctionwinningprice: Option[Double], auctioncreateddatetimestamp: Option[java.time.Instant], impressioncreateddatetimestamp: Option[java.time.Instant], isgroupbid: Option[Int], bidfloorcur: Option[String], bidfloor: Option[Double]) /** GetResult implicit for fetching WinningpriceinfoviewRow objects using plain SQL queries */ - implicit def GetResultWinningpriceinfoviewRow(implicit e0: GR[Option[Int]], e1: GR[Option[Double]], e2: GR[Option[java.time.Instant]]): GR[WinningpriceinfoviewRow] = GR{ + implicit def GetResultWinningpriceinfoviewRow(implicit e0: GR[Option[Int]], e1: GR[Option[Double]], e2: GR[Option[java.time.Instant]], e3: GR[Option[String]]): GR[WinningpriceinfoviewRow] = GR{ prs => import prs._ - WinningpriceinfoviewRow.tupled((< (WinningpriceinfoviewRow.tupled, WinningpriceinfoviewRow.unapply) + def * = (bidid, iswon, seatbidid, campaignid, advertiseid, dealbiddingprice, actualwiningprice, biddingcreateddatetimestamp, impressionid, bidrequestid, bidresponseid, demandsideplatformid, auctionid, auctionwinningprice, auctioncreateddatetimestamp, impressioncreateddatetimestamp, isgroupbid, bidfloorcur, bidfloor) <> (WinningpriceinfoviewRow.tupled, WinningpriceinfoviewRow.unapply) /** Database column BidId SqlType(INTEGER) */ val bidid: Rep[Option[Int]] = column[Option[Int]]("BidId") - /** Database column ImpressionId SqlType(INTEGER) */ - val impressionid: Rep[Option[Int]] = column[Option[Int]]("ImpressionId") + /** Database column IsWon SqlType(INTEGER), Length(1,false) */ + val iswon: Rep[Option[Int]] = column[Option[Int]]("IsWon", O.Length(1,varying=false)) /** Database column SeatBidId SqlType(INTEGER) */ val seatbidid: Rep[Option[Int]] = column[Option[Int]]("SeatBidId") /** Database column CampaignId SqlType(INTEGER) */ val campaignid: Rep[Option[Int]] = column[Option[Int]]("CampaignId") - /** Database column AuctionId SqlType(INTEGER) */ - val auctionid: Rep[Option[Int]] = column[Option[Int]]("AuctionId") + /** Database column AdvertiseId SqlType(INTEGER) */ + val advertiseid: Rep[Option[Int]] = column[Option[Int]]("AdvertiseId") + /** Database column DealBiddingPrice SqlType(REAL) */ + val dealbiddingprice: Rep[Option[Double]] = column[Option[Double]]("DealBiddingPrice") + /** Database column ActualWiningPrice SqlType(REAL) */ + val actualwiningprice: Rep[Option[Double]] = column[Option[Double]]("ActualWiningPrice") + /** Database column BiddingCreatedDateTimestamp SqlType(TIMESTAMP) */ + val biddingcreateddatetimestamp: Rep[Option[java.time.Instant]] = column[Option[java.time.Instant]]("BiddingCreatedDateTimestamp") + /** Database column ImpressionId SqlType(INTEGER) */ + val impressionid: Rep[Option[Int]] = column[Option[Int]]("ImpressionId") /** Database column BidRequestId SqlType(INTEGER) */ val bidrequestid: Rep[Option[Int]] = column[Option[Int]]("BidRequestId") /** Database column BidResponseId SqlType(INTEGER) */ val bidresponseid: Rep[Option[Int]] = column[Option[Int]]("BidResponseId") - /** Database column AdvertiseId SqlType(INTEGER) */ - val advertiseid: Rep[Option[Int]] = column[Option[Int]]("AdvertiseId") /** Database column DemandSidePlatformId SqlType(INTEGER) */ val demandsideplatformid: Rep[Option[Int]] = column[Option[Int]]("DemandSidePlatformId") + /** Database column AuctionId SqlType(INTEGER) */ + val auctionid: Rep[Option[Int]] = column[Option[Int]]("AuctionId") /** Database column AuctionWinningPrice SqlType(REAL) */ val auctionwinningprice: Rep[Option[Double]] = column[Option[Double]]("AuctionWinningPrice") - /** Database column DealBiddingPrice SqlType(REAL) */ - val dealbiddingprice: Rep[Option[Double]] = column[Option[Double]]("DealBiddingPrice") - /** Database column ActualWiningPrice SqlType(REAL) */ - val actualwiningprice: Rep[Option[Double]] = column[Option[Double]]("ActualWiningPrice") /** Database column AuctionCreatedDateTimestamp SqlType(TIMESTAMP) */ val auctioncreateddatetimestamp: Rep[Option[java.time.Instant]] = column[Option[java.time.Instant]]("AuctionCreatedDateTimestamp") - /** Database column BiddingCreatedDateTimestamp SqlType(TIMESTAMP) */ - val biddingcreateddatetimestamp: Rep[Option[java.time.Instant]] = column[Option[java.time.Instant]]("BiddingCreatedDateTimestamp") /** Database column ImpressionCreatedDateTimestamp SqlType(TIMESTAMP) */ val impressioncreateddatetimestamp: Rep[Option[java.time.Instant]] = column[Option[java.time.Instant]]("ImpressionCreatedDateTimestamp") - /** Database column IsWon SqlType(INTEGER), Length(1,false) */ - val iswon: Rep[Option[Int]] = column[Option[Int]]("IsWon", O.Length(1,varying=false)) /** Database column IsGroupBid SqlType(INTEGER), Length(1,false) */ val isgroupbid: Rep[Option[Int]] = column[Option[Int]]("IsGroupBid", O.Length(1,varying=false)) + /** Database column BidfloorCur SqlType(TEXT) */ + val bidfloorcur: Rep[Option[String]] = column[Option[String]]("BidfloorCur") + /** Database column Bidfloor SqlType(REAL) */ + val bidfloor: Rep[Option[Double]] = column[Option[Double]]("Bidfloor") } /** Collection-like TableQuery object for table Winningpriceinfoview */ lazy val Winningpriceinfoview = new TableQuery(tag => new Winningpriceinfoview(tag)) diff --git a/app/shared/com/ortb/routes/router/core/AbstractGenericRouter.scala b/app/shared/com/ortb/routes/router/core/AbstractGenericRouter.scala index 17ce9be..b77817e 100644 --- a/app/shared/com/ortb/routes/router/core/AbstractGenericRouter.scala +++ b/app/shared/com/ortb/routes/router/core/AbstractGenericRouter.scala @@ -51,7 +51,7 @@ abstract class AbstractGenericRouter[TTable, TRow, TKey : TypeTag]( } private def performAddTimes(addTimes : String) : Action[AnyContent] = { - val addTimesAsInt = NumberHelper.isInt(addTimes) + val addTimesAsInt = NumberHelper.getIntResult(addTimes) if (addTimesAsInt.isSuccess) { controller.addEntitiesBySinge(addTimesAsInt.result.get) } @@ -71,7 +71,7 @@ abstract class AbstractGenericRouter[TTable, TRow, TKey : TypeTag]( } protected def performGetByIdAsInteger(id : String) : Action[AnyContent] = { - val idAsInt = NumberHelper.isInt(id) + val idAsInt = NumberHelper.getIntResult(id) if (idAsInt.isSuccess) { controller.byId(idAsInt.result.get.asInstanceOf[TKey]) @@ -82,7 +82,7 @@ abstract class AbstractGenericRouter[TTable, TRow, TKey : TypeTag]( } protected def performUpdateByIdAsInteger(id : String) : Action[AnyContent] = { - val idAsInt = NumberHelper.isInt(id) + val idAsInt = NumberHelper.getIntResult(id) // TODO make it more DRY if (idAsInt.isSuccess) { controller.update(idAsInt.result.get.asInstanceOf[TKey]) diff --git a/app/shared/com/ortb/webapi/core/implementations/GenericControllerResponseImplementation.scala b/app/shared/com/ortb/webapi/core/implementations/GenericControllerResponseImplementation.scala index f4d15dc..0a37d40 100644 --- a/app/shared/com/ortb/webapi/core/implementations/GenericControllerResponseImplementation.scala +++ b/app/shared/com/ortb/webapi/core/implementations/GenericControllerResponseImplementation.scala @@ -40,7 +40,7 @@ class GenericControllerResponseImplementation extends GenericControllerResponse Seq(entityWrapper.entityId.toString)) val response = ControllerSuccessResultsModel[TRow, TKey](Some(attributes), Seq(entityWrapper.entity)) val encoder = service.serviceEncoders.controllerSuccessEncoder - val finalJson = encoder.getJsonGenericParser + val finalJson = encoder.genericJsonParser .toJsonString(Some(response)) finalJson.get } @@ -63,7 +63,7 @@ class GenericControllerResponseImplementation extends GenericControllerResponse Some(attributes), rows) val encoder = service.serviceEncoders.controllerSuccessEncoder - val finalJson = encoder.getJsonGenericParser + val finalJson = encoder.genericJsonParser .toJsonString(Some(response)) finalJson.get } @@ -83,7 +83,7 @@ class GenericControllerResponseImplementation extends GenericControllerResponse val response = ControllerSuccessResultsModel[TRow, TKey](Some(attributesModel), Seq(entityWrapper.entity.get)) val encoder = service.serviceEncoders.controllerSuccessEncoder - val finalJson = encoder.getJsonGenericParser + val finalJson = encoder.genericJsonParser .toJsonString(Some(response)) finalJson.get } diff --git a/app/shared/com/repository/traits/implementions/adapters/RepositoryJsonAdapterImplementation.scala b/app/shared/com/repository/traits/implementions/adapters/RepositoryJsonAdapterImplementation.scala index dca23e7..76a83b2 100644 --- a/app/shared/com/repository/traits/implementions/adapters/RepositoryJsonAdapterImplementation.scala +++ b/app/shared/com/repository/traits/implementions/adapters/RepositoryJsonAdapterImplementation.scala @@ -107,7 +107,7 @@ trait RepositoryJsonAdapterImplementation[TTable, TRow, TKey] } try { - val possibleEntities = this.encoders.getJsonGenericParser.toModels(jsonContent) + val possibleEntities = this.encoders.genericJsonParser.toModels(jsonContent) if (!EmptyValidateHelper.isItemsEmpty(possibleEntities)) { return toEntitiesWrapperWithOptions(possibleEntities) diff --git a/app/shared/io/extensions/TypeConvertExtensions.scala b/app/shared/io/extensions/TypeConvertExtensions.scala index 4826af0..b07f1f0 100644 --- a/app/shared/io/extensions/TypeConvertExtensions.scala +++ b/app/shared/io/extensions/TypeConvertExtensions.scala @@ -1,7 +1,11 @@ package shared.io.extensions +import shared.io.extensions.traits.asyncTypes.{ TypeConvertGenericFuture, TypeConvertGenericIterablesFuture } +import shared.io.extensions.traits.genericTypes._ import shared.io.extensions.traits.primitiveTypes._ +import scala.concurrent.Future + /** * Reference: https://github.com/Powerspace/scala-openrtb */ @@ -17,6 +21,11 @@ object TypeConvertExtensions { */ implicit class IntConverter(val i : Int) extends TypeConvertInteger + /** + * Convert an integer to the related value + */ + implicit class IntOptionConverter(val i : Option[Int]) extends TypeConvertIntegerOption + /** * Convert an string to the related values */ @@ -26,7 +35,19 @@ object TypeConvertExtensions { implicit class GenericConverter[T](val anyItem : T) extends TypeConvertGeneric[T] + implicit class GenericArrayConverter[T](val array : Array[T]) extends TypeConvertGenericArray[T] + + implicit class GenericListConverter[T](val list : List[T]) extends TypeConvertGenericList[T] + + implicit class GenericVectorConverter[T](val vector : Vector[T]) extends TypeConvertGenericVector[T] + implicit class GenericIterableConverter[T](val anyItems : Iterable[T]) extends TypeConvertGenericIterable[T] implicit class GenericJsonConverter[T](val anyItem : T) extends TypeConvertGenericJson[T] + + implicit class GenericFutureConverter[T](val eventualRequest : Future[T]) extends TypeConvertGenericFuture[T] + + implicit class GenericIterableFutureConverter[T](val eventualRequests : Iterable[Future[T]]) + extends TypeConvertGenericIterablesFuture[T] + } diff --git a/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericFuture.scala b/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericFuture.scala new file mode 100644 index 0000000..1ac8f10 --- /dev/null +++ b/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericFuture.scala @@ -0,0 +1,17 @@ +package shared.io.extensions.traits.asyncTypes + +import shared.com.repository.traits.FutureToRegular + +import scala.concurrent.Future +import scala.concurrent.duration.Duration +import scala.concurrent.duration.Duration.Inf + +trait TypeConvertGenericFuture[T] { + val eventualRequest : Future[T] + + def toRegular(wait : Duration = Inf) : T = FutureToRegular.toRegular(eventualRequest, wait) + + def toRegularOption(wait : Duration.Infinite = Inf) : Option[T] = FutureToRegular.toRegularAsOption(eventualRequest, wait) +} + + diff --git a/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericIterableForAsyncExtension.scala b/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericIterableForAsyncExtension.scala new file mode 100644 index 0000000..10723db --- /dev/null +++ b/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericIterableForAsyncExtension.scala @@ -0,0 +1,32 @@ +package shared.io.extensions.traits.asyncTypes + +import shared.io.extensions.TypeConvertExtensions._ +import shared.io.extensions.traits.genericTypes.TypeConvertGenericIterable + +import scala.collection.mutable.ArrayBuffer +import scala.concurrent.Future + +trait TypeConvertGenericIterableForAsyncExtension[T] { + this : TypeConvertGenericIterable[T] => + def forEachAsyncCompleted(f : T => Unit, defaultCapacity : Int = 50) : Unit = { + val allFutures = forEachAsync(f, defaultCapacity) + allFutures.waitUntilCompleted() + } + + def forEachAsync(f : T => Unit, defaultCapacity : Int = 50) : ArrayBuffer[Future[Unit]] = { + if (isEmpty) { + return ArrayBuffer.empty + } + + val arrayBuffer = new ArrayBuffer[Future[Unit]](defaultCapacity) + for (item <- anyItems) { + val future = Future { + f(item) + } + + arrayBuffer.addOne(future) + } + + arrayBuffer + } +} diff --git a/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericIterablesFuture.scala b/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericIterablesFuture.scala new file mode 100644 index 0000000..8c494e3 --- /dev/null +++ b/app/shared/io/extensions/traits/asyncTypes/TypeConvertGenericIterablesFuture.scala @@ -0,0 +1,21 @@ +package shared.io.extensions.traits.asyncTypes + +import shared.io.extensions.TypeConvertExtensions._ +import shared.io.helpers.EmptyValidateHelper + +import scala.concurrent.Future +import scala.concurrent.duration.Duration +import scala.concurrent.duration.Duration.Inf + +trait TypeConvertGenericIterablesFuture[T] { + lazy val isEmpty : Boolean = EmptyValidateHelper.isItemsEmptyDirect(eventualRequests) + val eventualRequests : Iterable[Future[T]] + + def waitUntilCompleted(wait : Duration = Inf) : Unit = { + if (isEmpty) { + return + } + + eventualRequests.foreach(eventualRequest => eventualRequest.toRegular(wait)) + } +} diff --git a/app/shared/io/extensions/traits/genericTypes/TypeConvertGeneric.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGeneric.scala new file mode 100644 index 0000000..38d0103 --- /dev/null +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGeneric.scala @@ -0,0 +1,25 @@ +package shared.io.extensions.traits.genericTypes + +import shared.io.helpers.EmptyValidateHelper + +import scala.reflect.ClassTag + +trait TypeConvertGeneric[T] { + lazy val isEmpty : Boolean = EmptyValidateHelper.isEmptyAny(anyItem) + lazy val isDefined : Boolean = !isEmpty + lazy val toSome : Option[T] = Some(anyItem) + lazy val toOption : Option[T] = Some(anyItem) + lazy val toMaybe : Option[T] = Some(anyItem) + protected val anyItem : T + + lazy val toMakeList : List[T] = List(anyItem) + lazy val toMakeListSome : Option[List[T]] = Some(List(anyItem)) + lazy val toMakeSeq : Seq[T] = Seq(anyItem) + lazy val toMakeSeqSome : Option[Seq[T]] = Some(Seq(anyItem)) + lazy val toMakeVector : Seq[T] = Vector(anyItem) + lazy val toMakeVectorSome : Option[Seq[T]] = Some(Vector(anyItem)) + + def toMakeArray(implicit T : ClassTag[T]) : Array[T] = Array(anyItem) + + def toMakeArraySome(implicit T : ClassTag[T]) : Option[Array[T]] = Some(Array(anyItem)) +} diff --git a/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericArray.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericArray.scala new file mode 100644 index 0000000..db3bc5c --- /dev/null +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericArray.scala @@ -0,0 +1,7 @@ +package shared.io.extensions.traits.genericTypes + +trait TypeConvertGenericArray[T] extends TypeConvertGenericIterable[T] { + lazy val anyItems : Iterable[T] = array.toIterable + protected val array : Array[T] + lazy val toSomeArray : Option[Array[T]] = Some(array) +} diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterable.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterable.scala similarity index 71% rename from app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterable.scala rename to app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterable.scala index fe633d4..220da48 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterable.scala +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterable.scala @@ -1,16 +1,22 @@ -package shared.io.extensions.traits.primitiveTypes +package shared.io.extensions.traits.genericTypes import shared.com.ortb.constants.AppConstants import shared.com.ortb.manager.AppManager -import shared.com.ortb.manager.traits.{ CreateDefaultContext, DefaultExecutionContextManager } +import shared.com.ortb.manager.traits.CreateDefaultContext import shared.com.ortb.persistent.repositories.LogTraceRepository +import shared.io.extensions.traits.asyncTypes.TypeConvertGenericIterableForAsyncExtension import shared.io.helpers.EmptyValidateHelper import scala.concurrent.ExecutionContext trait TypeConvertGenericIterable[T] - extends TypeConvertGenericIterableJson[T] with CreateDefaultContext { - protected val anyItems : Iterable[T] + extends TypeConvertGenericIterableJson[T] + with CreateDefaultContext + with TypeConvertGenericIterableForExtension[T] + with TypeConvertGenericIterableForAsyncExtension[T] { + lazy protected val logTraceRepository : LogTraceRepository = AppConstants + .Repositories + .logTraceRepository lazy val isEmpty : Boolean = !hasItem lazy val hasItem : Boolean = EmptyValidateHelper.hasAnyItemDirect(anyItems) @@ -19,20 +25,22 @@ trait TypeConvertGenericIterable[T] lazy val toMaybe : Option[Iterable[T]] = Some(anyItems) lazy val toCsv : String = anyItems.mkString(AppConstants.Comma) lazy protected val appManager : AppManager = AppConstants.AppManager - lazy protected val logTraceRepository : LogTraceRepository = AppConstants.Repositories.logTraceRepository + protected val anyItems : Iterable[T] + + lazy val toJoinStringLineSeparator : Any = anyItems.mkString(AppConstants.SystemNewLine) def toJoinString(separator : String) : String = anyItems.mkString(separator) def toJoinString(start : String, separator : String, end : String) : String = anyItems.mkString(start, separator, end) + override def createDefaultContext() : ExecutionContext = appManager + .executionContextManager + .createDefaultContext() + protected def throwOnNullOrNoneOrNil() : Unit = { EmptyValidateHelper.throwOnNullOrNoneOrNil( anyItems, Some(s"Undefined object given for json parsing.")) } - - override def createDefaultContext() : ExecutionContext = appManager - .executionContextManager - .createDefaultContext() } diff --git a/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableForExtension.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableForExtension.scala new file mode 100644 index 0000000..3caaffb --- /dev/null +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableForExtension.scala @@ -0,0 +1,62 @@ +package shared.io.extensions.traits.genericTypes + +import shared.com.repository.traits.FutureToRegular +import shared.io.extensions.TypeConvertExtensions._ +import scala.collection.mutable.ArrayBuffer +import scala.concurrent.Future + + +trait TypeConvertGenericIterableForExtension[T] { + this : TypeConvertGenericIterable[T] => + + /** + * Returns true if any is true, if empty then returns false. + * + * @param p + * + * @return + */ + def forAny(p : T => Boolean) : Boolean = { + if (isEmpty) { + return false + } + + val it = anyItems.iterator + while (it.hasNext) { + if (p(it.next)) { + return true + } + } + + false + } + + def forAnyGroup(predicates : (T => Boolean)*) : Array[Boolean] = { + val predicatesLength = predicates.length + val array = new Array[Boolean](predicatesLength) + + if (isEmpty) { + return array + } + + var trueFound = 0 + + for (item <- anyItems) { + var index = 0 + + for (predicate <- predicates) { + if (!array(index) && predicate(item)) { + trueFound += 1 + array(index) = true + } + index = index + 1 + } + + if (trueFound == predicatesLength) { + return array + } + } + + array + } +} diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterableJson.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableJson.scala similarity index 94% rename from app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterableJson.scala rename to app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableJson.scala index 4f83abf..a9a10e5 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterableJson.scala +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableJson.scala @@ -1,10 +1,10 @@ -package shared.io.extensions.traits.primitiveTypes +package shared.io.extensions.traits.genericTypes +import shared.io.extensions.TypeConvertExtensions._ import io.circe.Json import io.circe.generic.decoding.DerivedDecoder import io.circe.generic.encoding.DerivedAsObjectEncoder import shapeless.Lazy -import shared.io.extensions.TypeConvertExtensions._ import shared.io.jsonParse.implementations.BasicJsonEncoderImplementation import shared.io.jsonParse.traits.{ BasicJsonEncoder, GenericJsonParser } import shared.io.loggers.AppLogger @@ -12,6 +12,7 @@ import shared.io.loggers.AppLogger trait TypeConvertGenericIterableJson[T] extends TypeConvertGenericIterableLogToDatabase[T] { this : TypeConvertGenericIterable[T] => + def toJsons( implicit decoder : Lazy[DerivedDecoder[T]], encoder : Lazy[DerivedAsObjectEncoder[T]]) : Option[Iterable[Json]] = { @@ -31,16 +32,6 @@ trait TypeConvertGenericIterableJson[T] mayJsonString.getDefinedOrEmptyString } - def jsonGenericParser( - implicit decoder : Lazy[DerivedDecoder[T]], - encoder : Lazy[DerivedAsObjectEncoder[T]]) : GenericJsonParser[T] = - basicJsonEncoder(decoder, encoder).getJsonGenericParser - - def basicJsonEncoder( - implicit decoder : Lazy[DerivedDecoder[T]], - encoder : Lazy[DerivedAsObjectEncoder[T]]) : BasicJsonEncoder[T] = - new BasicJsonEncoderImplementation[T]()(decoder, encoder) - def logAsJson(message : String = "")( implicit decoder : Lazy[DerivedDecoder[T]], encoder : Lazy[DerivedAsObjectEncoder[T]]) : Unit = { @@ -56,4 +47,14 @@ trait TypeConvertGenericIterableJson[T] maybeJson.getDefinedOrEmptyString } + + def jsonGenericParser( + implicit decoder : Lazy[DerivedDecoder[T]], + encoder : Lazy[DerivedAsObjectEncoder[T]]) : GenericJsonParser[T] = + basicJsonEncoder(decoder, encoder).genericJsonParser + + def basicJsonEncoder( + implicit decoder : Lazy[DerivedDecoder[T]], + encoder : Lazy[DerivedAsObjectEncoder[T]]) : BasicJsonEncoder[T] = + new BasicJsonEncoderImplementation[T]()(decoder, encoder) } diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterableLogToDatabase.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableLogToDatabase.scala similarity index 98% rename from app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterableLogToDatabase.scala rename to app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableLogToDatabase.scala index fbde491..d494538 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericIterableLogToDatabase.scala +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericIterableLogToDatabase.scala @@ -1,6 +1,5 @@ -package shared.io.extensions.traits.primitiveTypes +package shared.io.extensions.traits.genericTypes -import shared.io.extensions.TypeConvertExtensions._ import io.circe.generic.decoding.DerivedDecoder import io.circe.generic.encoding.DerivedAsObjectEncoder import shapeless.Lazy @@ -9,6 +8,7 @@ import shared.com.ortb.enumeration.LogLevelType.LogLevelType import shared.com.ortb.enumeration.{ DatabaseActionType, LogLevelType } import shared.com.ortb.model.config.LogConfigurationModel import shared.com.ortb.persistent.schema.Tables +import shared.io.extensions.TypeConvertExtensions._ import shared.io.helpers.{ EmptyValidateHelper, JodaDateTimeHelper, ReflectionHelper } import shared.io.loggers.AppLogger diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericJson.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericJson.scala similarity index 81% rename from app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericJson.scala rename to app/shared/io/extensions/traits/genericTypes/TypeConvertGenericJson.scala index ff8c891..5282b47 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGenericJson.scala +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericJson.scala @@ -1,20 +1,25 @@ -package shared.io.extensions.traits.primitiveTypes +package shared.io.extensions.traits.genericTypes import io.circe.generic.decoding.DerivedDecoder import io.circe.generic.encoding.DerivedAsObjectEncoder import io.circe.{ Encoder, Json } import shapeless.Lazy +import shared.com.repository.traits.FutureToRegular import shared.io.helpers.JsonHelper import shared.io.jsonParse.implementations.BasicJsonEncoderImplementation import shared.io.jsonParse.traits.{ BasicJsonEncoder, GenericJsonParser } +import scala.concurrent.Future +import scala.concurrent.duration.Duration + + trait TypeConvertGenericJson[T] { protected val anyItem : T def jsonGenericParser( implicit decoder : Lazy[DerivedDecoder[T]], encoder : Lazy[DerivedAsObjectEncoder[T]]) : GenericJsonParser[T] = - basicJsonEncoder(decoder, encoder).getJsonGenericParser + basicJsonEncoder(decoder, encoder).genericJsonParser def basicJsonEncoder( implicit decoder : Lazy[DerivedDecoder[T]], diff --git a/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericList.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericList.scala new file mode 100644 index 0000000..15c30b2 --- /dev/null +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericList.scala @@ -0,0 +1,7 @@ +package shared.io.extensions.traits.genericTypes + +trait TypeConvertGenericList[T] extends TypeConvertGenericIterable[T] { + lazy val anyItems : Iterable[T] = list + protected val list : List[T] + lazy override val toSome : Option[List[T]] = Some(list) +} diff --git a/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericVector.scala b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericVector.scala new file mode 100644 index 0000000..197e308 --- /dev/null +++ b/app/shared/io/extensions/traits/genericTypes/TypeConvertGenericVector.scala @@ -0,0 +1,7 @@ +package shared.io.extensions.traits.genericTypes + +trait TypeConvertGenericVector[T] extends TypeConvertGenericIterable[T] { + lazy val anyItems : Iterable[T] = vector + protected val vector : Vector[T] + lazy override val toSome : Option[Vector[T]] = Some(vector) +} diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertBoolean.scala b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertBoolean.scala index 2013268..ba364e2 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertBoolean.scala +++ b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertBoolean.scala @@ -3,9 +3,11 @@ package shared.io.extensions.traits.primitiveTypes trait TypeConvertBoolean { protected val b : Boolean - def toIntString : String = toInt.toString + lazy val toIntString : String = toBoolInt.toString - def toInt : Int = if (b) 1 else 0 + lazy val toBoolInt : Int = if (b) 1 else 0 - override def toString : String = if (b) "true" else "false" + lazy val toBoolString : String = if (b) "true" else "false" + + lazy val toBoolIntSome : Option[Int] = Some(toBoolInt) } diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGeneric.scala b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGeneric.scala deleted file mode 100644 index 5b25353..0000000 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertGeneric.scala +++ /dev/null @@ -1,12 +0,0 @@ -package shared.io.extensions.traits.primitiveTypes - -import shared.io.helpers.EmptyValidateHelper - -trait TypeConvertGeneric[T] { - lazy val isEmpty : Boolean = EmptyValidateHelper.isEmptyAny(anyItem) - lazy val isDefined : Boolean = !isEmpty - lazy val toSome : Option[T] = Some(anyItem) - lazy val toOption : Option[T] = Some(anyItem) - lazy val toMaybe : Option[T] = Some(anyItem) - protected val anyItem : T -} diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertInteger.scala b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertInteger.scala index 7fefc38..d712220 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertInteger.scala +++ b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertInteger.scala @@ -1,9 +1,15 @@ package shared.io.extensions.traits.primitiveTypes +import shared.io.helpers.EmptyValidateHelper + trait TypeConvertInteger { protected val i : Int + lazy val toStringOption : Option[String] = Some(i.toString) + def toBoolString : String = toBoolean.toString - def toBoolean : Boolean = if (i == 0) false else true + def toBoolean : Boolean = if (i <= 0) false else true } + + diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertIntegerOption.scala b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertIntegerOption.scala new file mode 100644 index 0000000..d1a0f15 --- /dev/null +++ b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertIntegerOption.scala @@ -0,0 +1,18 @@ +package shared.io.extensions.traits.primitiveTypes + +import shared.io.helpers.EmptyValidateHelper + +trait TypeConvertIntegerOption { + + import shared.io.extensions.TypeConvertExtensions._ + + lazy val isEmpty : Boolean = EmptyValidateHelper.isEmpty(i) + lazy val hasNumber : Boolean = !isEmpty + lazy val toStringOption : Option[String] = if (hasNumber) self.toString.toSome else None + lazy protected val self : Int = i.get + protected val i : Option[Int] + + def toBoolString : String = toBoolean.toString + + def toBoolean : Boolean = if (i.isDefined && self <= 0) false else true +} diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertOptionString.scala b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertOptionString.scala index 530d9d2..c2ef072 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertOptionString.scala +++ b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertOptionString.scala @@ -1,10 +1,28 @@ package shared.io.extensions.traits.primitiveTypes -import shared.io.helpers.EmptyValidateHelper +import shared.com.ortb.model.results.ResultWithSuccessModel +import shared.io.helpers.{ EmptyValidateHelper, NumberHelper } trait TypeConvertOptionString { lazy val hasCharacter : Boolean = EmptyValidateHelper.isOptionStringDefined(s) lazy val isEmpty : Boolean = !hasCharacter lazy val getDefinedOrEmptyString : String = if (hasCharacter) s.get else "" + lazy val toIntSome : Option[Int] = if (hasCharacter) s.get.toIntOption else None + lazy val toDoubleSome : Option[Double] = if (hasCharacter) s.get.toDoubleOption else None + lazy val toFloatSome : Option[Float] = if (hasCharacter) s.get.toFloatOption else None + lazy val getIntResult : ResultWithSuccessModel[Int] = NumberHelper.getIntResult(self) + lazy val getDoubleResult : ResultWithSuccessModel[Double] = NumberHelper.getDoubleResult(self) + lazy val getFloatResult : ResultWithSuccessModel[Float] = NumberHelper.getFloatResult(self) + + def getOrElseDefault(default : String = "") : String = s.getOrElse(default) + + protected val self : String = if (hasCharacter) s.get else "" + + def toInt(default : Int = 0) : Int = if (getIntResult.isSuccess) getIntResult.result.get else default + + def toDouble(default : Double = 0) : Double = if (getDoubleResult.isSuccess) getDoubleResult.result.get else default + + def toFloat(default : Float = 0) : Float = if (getFloatResult.isSuccess) getFloatResult.result.get else default + protected val s : Option[String] } diff --git a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertString.scala b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertString.scala index 5aa797c..27e2916 100644 --- a/app/shared/io/extensions/traits/primitiveTypes/TypeConvertString.scala +++ b/app/shared/io/extensions/traits/primitiveTypes/TypeConvertString.scala @@ -1,8 +1,12 @@ package shared.io.extensions.traits.primitiveTypes +import io.circe.generic.decoding.DerivedDecoder +import io.circe.generic.encoding.DerivedAsObjectEncoder import org.joda.time.DateTime +import shapeless.Lazy import shared.com.ortb.constants.AppConstants import shared.io.helpers.{ EmptyValidateHelper, JodaDateTimeHelper } +import shared.io.jsonParse.implementations.BasicJsonEncoderImplementation trait TypeConvertString { protected val s : String @@ -18,6 +22,15 @@ trait TypeConvertString { isYesString lazy private val isYesString = hasCharacter && s.equalsIgnoreCase("yes") + def toIntOrDefault(default : Int = 0) : Int = { + if (isEmpty) { + return default + } + + val intResult = s.toIntOption + intResult.getOrElse(default) + } + def toDateTime(dateTimePattern : String = AppConstants.DefaultDateTimeFormatPattern) : DateTime = { EmptyValidateHelper.throwOnNullOrNoneOrNil(s, Some(s"Given string is Empty cannot be converted to Joda DateTime(pattern:$dateTimePattern)")) JodaDateTimeHelper.getDateTimeFrom(s, dateTimePattern) @@ -27,6 +40,39 @@ trait TypeConvertString { EmptyValidateHelper.throwOnNullOrNoneOrNil(s, Some(s"Given string is Empty cannot be converted to Joda Date(pattern:$datePattern)")) JodaDateTimeHelper.getDateTimeFrom(s, datePattern) } + + lazy val getLines : Array[String] = s.split(AppConstants.NewLine) + + def getLinesWithLineNumbers(lineJoiner : String = " . ") : Array[String] = { + var lineNumber = 0 + getLines.map(line => { + lineNumber += 1 + s"$lineNumber$lineJoiner$line" + }) + } + + /** + * Parse a json to object + * + * @param decoder + * @param encoder + * @tparam T2 + * + * @return + */ + def asFromJson[T2]( + implicit decoder : Lazy[DerivedDecoder[T2]], + encoder : Lazy[DerivedAsObjectEncoder[T2]]) : T2 = { + val basicEncoder = new BasicJsonEncoderImplementation[T2]()(decoder, encoder) + basicEncoder.genericJsonParser.toModelDirect(s) + } + + def asObjectsFromJson[T2]( + implicit decoder : Lazy[DerivedDecoder[T2]], + encoder : Lazy[DerivedAsObjectEncoder[T2]]) : Iterable[T2] = { + val basicEncoder = new BasicJsonEncoderImplementation[T2]()(decoder, encoder) + basicEncoder.genericJsonParser.toModelsDirect(s) + } } diff --git a/app/shared/io/helpers/EmptyValidateHelper.scala b/app/shared/io/helpers/EmptyValidateHelper.scala index bf44ec6..aca8fc8 100644 --- a/app/shared/io/helpers/EmptyValidateHelper.scala +++ b/app/shared/io/helpers/EmptyValidateHelper.scala @@ -1,6 +1,5 @@ package shared.io.helpers -import shared.com.ortb.constants.AppConstants import shared.io.loggers.AppLogger object EmptyValidateHelper { @@ -49,14 +48,33 @@ object EmptyValidateHelper { def isRightDefinedOnEither[A, B]( item : Either[A, B], - message : Option[String] = defaultNoContentMessage) : Boolean = { + message : Option[String] = defaultNoContentMessage, + isThrowOnLeft : Boolean = false) : Boolean = { val hasItem = item != null && item.getOrElse(null) != null - //noinspection DuplicatedCode val hasMessage = isOptionStringDefinedWithoutMessage(message) if (!hasItem && hasMessage) { AppLogger.debug(message.get) + + } + + val isLeft = !hasItem && item.isLeft + + if (isLeft) { + AppLogger.error(item.left.toString) + } + + if (isLeft && isThrowOnLeft) { + val left = item.left + if (left.isInstanceOf[Throwable]) { + val throwX = left.asInstanceOf[Throwable] + throw throwX + } + else { + val message = item.left.toString + throw new Error(message) + } } hasItem @@ -267,8 +285,27 @@ object EmptyValidateHelper { !hasAnyItem(Some(items), message) } + def isItemsEmptyOnAnyDirect[A]( + items : Iterable[A]*) : Boolean = { + if (isItemsEmptyDirect(items)) { + return true + } + + for (item <- items) { + if (isItemsEmptyDirect(item)) { + return true + } + } + + false + } + def isItemsEmptyOnAllDirect[A]( items : Iterable[A]*) : Boolean = { + if (isItemsEmptyDirect(items)) { + return true + } + items.forall(w => !hasAnyItem(Some(w))) } diff --git a/app/shared/io/helpers/NumberHelper.scala b/app/shared/io/helpers/NumberHelper.scala index 93c56bd..d30ddb4 100644 --- a/app/shared/io/helpers/NumberHelper.scala +++ b/app/shared/io/helpers/NumberHelper.scala @@ -1,70 +1,8 @@ package shared.io.helpers -import shared.com.ortb.model.results.ResultWithSuccessModel - -import scala.util.matching.Regex +import shared.io.helpers.traits.NumberHelperBase /** * Reference: https://bit.ly/2VY8I53 */ -object NumberHelper { - def isAllDigits(x : String) : Boolean = x forall Character.isDigit - - def isShort(aString : String) : ResultWithSuccessModel[Short] = - TryHelper.TryResult[Short](aString.toShort) - - def isInt(aString : String) : ResultWithSuccessModel[Int] = - TryHelper.TryResult[Int](aString.toInt) - - def isLong(aString : String) : ResultWithSuccessModel[Long] = - TryHelper.TryResult[Long](aString.toLong) - - def isDouble(aString : String) : ResultWithSuccessModel[Double] = - TryHelper.TryResult[Double](aString.toDouble) - - def isFloat(aString : String) : ResultWithSuccessModel[Float] = - TryHelper.TryResult[Float](aString.toFloat) - - def getAs[T](d : Option[T], default : T) : T = { - if (d.isEmpty) { - return default - } - - d.get - } - - def getAsInt(d : Option[Int]) : Int = { - if (d.isEmpty) { - return 0 - } - - d.get - } - - def getAsDouble(d : Option[Double]) : Double = { - if (d.isEmpty) { - return 0 - } - - d.get - } - - lazy val numberTestingRegex : Regex = "^\\d+$".r - - def isStringNumber(x : String) : Boolean = x match { - case numberTestingRegex() => true - case _ => false - } - - def isNumberType(anyType : Any) : Boolean = { - anyType.isInstanceOf[Int] || - anyType.isInstanceOf[Double] || - anyType.isInstanceOf[Byte] || - anyType.isInstanceOf[Short] || - anyType.isInstanceOf[Float] || - anyType.isInstanceOf[Long] || - anyType.isInstanceOf[BigDecimal] || - anyType.isInstanceOf[Integer] || - anyType.isInstanceOf[Integer] - } -} +object NumberHelper extends NumberHelperBase diff --git a/app/shared/io/helpers/PaginationHelper.scala b/app/shared/io/helpers/PaginationHelper.scala index 775a02a..f7cf74f 100644 --- a/app/shared/io/helpers/PaginationHelper.scala +++ b/app/shared/io/helpers/PaginationHelper.scala @@ -57,7 +57,7 @@ object PaginationHelper extends PaginationHelperBase { val apiModel = ApiPaginationResultsModel[TRow, TKey](Some(apiAttribute), allEntities) val encoder = service.serviceEncoders.apiPaginationEncoder - val finalJson = encoder.getJsonGenericParser + val finalJson = encoder.genericJsonParser .toJsonString(Some(apiModel)) finalJson.get diff --git a/app/shared/io/helpers/ReflectionHelper.scala b/app/shared/io/helpers/ReflectionHelper.scala index 8104a36..ea00854 100644 --- a/app/shared/io/helpers/ReflectionHelper.scala +++ b/app/shared/io/helpers/ReflectionHelper.scala @@ -4,7 +4,6 @@ import shared.io.helpers.implementations.NiceObject import shared.io.helpers.traits._ import shared.io.helpers.traits.reflection.{ ClassTagHelper, ReflectionHelperBase } - object ReflectionHelper extends ReflectionHelperBase { implicit def toNiceObject[T <: AnyRef](x : T) : NiceObject[T] = new NiceObject(x) } diff --git a/app/shared/io/helpers/traits/JodaDateTimeHelperBase.scala b/app/shared/io/helpers/traits/JodaDateTimeHelperBase.scala index a1aaaae..562e826 100644 --- a/app/shared/io/helpers/traits/JodaDateTimeHelperBase.scala +++ b/app/shared/io/helpers/traits/JodaDateTimeHelperBase.scala @@ -83,7 +83,7 @@ trait JodaDateTimeHelperBase { def millisStringToDateTime(millis : String) : DateTime = { EmptyValidateHelper.throwOnNullOrNoneOrNil(millis) - val asLong = NumberHelper.isLong(millis) + val asLong = NumberHelper.getLongResult(millis) if (asLong.isSuccess) { return millisToDateTime(asLong.result.get) diff --git a/app/shared/io/helpers/traits/NumberHelperBase.scala b/app/shared/io/helpers/traits/NumberHelperBase.scala new file mode 100644 index 0000000..85557e8 --- /dev/null +++ b/app/shared/io/helpers/traits/NumberHelperBase.scala @@ -0,0 +1,68 @@ +package shared.io.helpers.traits + +import shared.com.ortb.model.results.ResultWithSuccessModel +import shared.io.helpers.TryHelper + +import scala.util.matching.Regex + +trait NumberHelperBase { + lazy val numberTestingRegex : Regex = "^\\d+$".r + + def isAllDigits(x : String) : Boolean = x forall Character.isDigit + + def getShortResult(aString : String) : ResultWithSuccessModel[Short] = + TryHelper.TryResult[Short](aString.toShort) + + def getIntResult(aString : String) : ResultWithSuccessModel[Int] = + TryHelper.TryResult[Int](aString.toInt) + + def getLongResult(aString : String) : ResultWithSuccessModel[Long] = + TryHelper.TryResult[Long](aString.toLong) + + def getDoubleResult(aString : String) : ResultWithSuccessModel[Double] = + TryHelper.TryResult[Double](aString.toDouble) + + def getFloatResult(aString : String) : ResultWithSuccessModel[Float] = + TryHelper.TryResult[Float](aString.toFloat) + + def getAs[T](d : Option[T], default : T) : T = { + if (d.isEmpty) { + return default + } + + d.get + } + + def getAsInt(d : Option[Int]) : Int = { + if (d.isEmpty) { + return 0 + } + + d.get + } + + def getAsDouble(d : Option[Double]) : Double = { + if (d.isEmpty) { + return 0 + } + + d.get + } + + def isStringNumber(x : String) : Boolean = x match { + case numberTestingRegex() => true + case _ => false + } + + def isNumberType(anyType : Any) : Boolean = { + anyType.isInstanceOf[Int] || + anyType.isInstanceOf[Double] || + anyType.isInstanceOf[Byte] || + anyType.isInstanceOf[Short] || + anyType.isInstanceOf[Float] || + anyType.isInstanceOf[Long] || + anyType.isInstanceOf[BigDecimal] || + anyType.isInstanceOf[Integer] || + anyType.isInstanceOf[Integer] + } +} diff --git a/app/shared/io/jsonParse/implementations/GenericJsonParserImplementation.scala b/app/shared/io/jsonParse/implementations/GenericJsonParserImplementation.scala index 18f89be..ec8bc3e 100644 --- a/app/shared/io/jsonParse/implementations/GenericJsonParserImplementation.scala +++ b/app/shared/io/jsonParse/implementations/GenericJsonParserImplementation.scala @@ -1,6 +1,8 @@ package shared.io.jsonParse.implementations +import shared.io.extensions.TypeConvertExtensions._ import com.fasterxml.jackson.databind.JsonNode +import io.circe import io.circe.Json import io.circe.parser.decode import shared.com.ortb.constants.AppConstants @@ -15,12 +17,22 @@ import scala.collection.mutable.ArrayBuffer class GenericJsonParserImplementation[T](basicJsonEncoder : BasicJsonEncoder[T]) extends GenericJsonParser[T] { lazy val quote : String = AppConstants.Quote + lazy val isThrowOnFail : Boolean = AppConstants.IsThrownOnFailed override def fromJsonStringToModels(jsonString : Option[String]) : Option[Iterable[T]] = { val models = toModels(jsonString) models } + override def toModelsDirect(jsonString : String) : ArrayBuffer[T] = { + val results = toModels(Some(jsonString)) + if (EmptyValidateHelper.hasAnyItem(results)) { + return results.get + } + + ArrayBuffer.empty + } + override def toModels(jsonString : Option[String]) : Option[ArrayBuffer[T]] = { try { val decoder = basicJsonEncoder.getDecoder @@ -113,7 +125,11 @@ class GenericJsonParserImplementation[T](basicJsonEncoder : BasicJsonEncoder[T]) override def toModelDirect(jsonString : String) : T = { val toModelOption = toModel(Some(jsonString)) - toModelOption.get + if (toModelOption.isDefined) { + return toModelOption.get + } + + null.asInstanceOf[T] } override def toModel(jsonString : Option[String]) : Option[T] = { @@ -131,14 +147,31 @@ class GenericJsonParserImplementation[T](basicJsonEncoder : BasicJsonEncoder[T]) return model } + + handleExceptionCaseFor(json, modelEither) } catch { - case e : Exception => AppLogger.error(e) + case e : Exception => AppLogger.errorCaptureAndThrow(e) } None } + def handleExceptionCaseFor( + json : String, + modelEither : Either[circe.Error, T]) : Unit = { + val left = modelEither.left.getOrElse(null) + val jsonWithLines = json.getLinesWithLineNumbers().toJoinStringLineSeparator + val message = s"Failed JSON Parse :\n$jsonWithLines\nError Message:${ left.getMessage }\nFull Error:$left" + + if (isThrowOnFail) { + throw new Error(message) + } + else { + AppLogger.error(message) + } + } + override def toJsonStringDirect(model : T) : String = { val toJsonOption = toJsonString(Some(model)) toJsonOption.get @@ -161,19 +194,19 @@ class GenericJsonParserImplementation[T](basicJsonEncoder : BasicJsonEncoder[T]) /** * - * @param model + * @param jsonOption * @param isPrettyFormat : if true then returns string using space2 * * @return */ - override def fromJsonToJsonString(model : Option[Json], isPrettyFormat : Boolean) : Option[String] = { - EmptyValidateHelper.throwOnNullOrNoneOrNil(model, Some("model is empty")) + override def fromJsonToJsonString(jsonOption : Option[Json], isPrettyFormat : Boolean) : Option[String] = { + EmptyValidateHelper.throwOnNullOrNoneOrNil(jsonOption, Some("model is empty")) if (isPrettyFormat) { - return Some(model.get.spaces2) + return Some(jsonOption.get.spaces2) } - Some(model.get.noSpaces) + Some(jsonOption.get.noSpaces) } override def fromModelsToJsonString(models : Option[Iterable[T]]) : Option[String] = { @@ -331,7 +364,7 @@ class GenericJsonParserImplementation[T](basicJsonEncoder : BasicJsonEncoder[T]) override def toJsonStringPrettyFormatForModelsDirect(models : Iterable[T]) : String = { val jsonString = toJsonStringPrettyFormatForModels(Some(models)) - if(EmptyValidateHelper.isOptionStringDefined(jsonString)){ + if (EmptyValidateHelper.isOptionStringDefined(jsonString)) { return jsonString.get } @@ -349,7 +382,7 @@ class GenericJsonParserImplementation[T](basicJsonEncoder : BasicJsonEncoder[T]) override def toJsonStringPrettyFormatDirect(model : T) : String = { val jsonString = toJsonStringPrettyFormat(Some(model)) - if(EmptyValidateHelper.isOptionStringDefined(jsonString)){ + if (EmptyValidateHelper.isOptionStringDefined(jsonString)) { return jsonString.get } diff --git a/app/shared/io/jsonParse/implementations/JsonCirceDefaultEncodersImplementation.scala b/app/shared/io/jsonParse/implementations/JsonCirceDefaultEncodersImplementation.scala index 37b7ac4..55a185e 100644 --- a/app/shared/io/jsonParse/implementations/JsonCirceDefaultEncodersImplementation.scala +++ b/app/shared/io/jsonParse/implementations/JsonCirceDefaultEncodersImplementation.scala @@ -39,7 +39,7 @@ class JsonCirceDefaultEncodersImplementation[T]( def toJsonString(entities : Iterable[T], additionalAnnotationForItems : String = null) : String = { - getJsonGenericParser.toJsonString(entities, additionalAnnotationForItems) + genericJsonParser.toJsonString(entities, additionalAnnotationForItems) } def toIterableJson(entities : Iterable[T]) : Iterable[Json] = { diff --git a/app/shared/io/jsonParse/implementations/custom/models/ApiPaginationResultsModelCustomCodecImplementation.scala b/app/shared/io/jsonParse/implementations/custom/models/ApiPaginationResultsModelCustomCodecImplementation.scala index 2f31386..8047ef7 100644 --- a/app/shared/io/jsonParse/implementations/custom/models/ApiPaginationResultsModelCustomCodecImplementation.scala +++ b/app/shared/io/jsonParse/implementations/custom/models/ApiPaginationResultsModelCustomCodecImplementation.scala @@ -22,10 +22,10 @@ class ApiPaginationResultsModelCustomCodecImplementation[TRow, TKey]( */ override def getEncoder : Encoder[ApiPaginationResultsModel[TRow, TKey]] = (a : ApiPaginationResultsModel[TRow, TKey]) => { - val attributesJsonObject = attributesEncoder.getJsonGenericParser + val attributesJsonObject = attributesEncoder.genericJsonParser .toJsonObjectDirect(a.attributes.get) val rows = a.data - val genericJsonParser = jsonCirceDefaultEncoders.getJsonGenericParser + val genericJsonParser = jsonCirceDefaultEncoders.genericJsonParser val iterableJsonObjects = genericJsonParser.fromModelsToJsonObjects(Some(rows)) val dataToJson = Json.fromValues(iterableJsonObjects.get) diff --git a/app/shared/io/jsonParse/implementations/custom/models/ControllerSuccessResultsModelCustomCodecImplementation.scala b/app/shared/io/jsonParse/implementations/custom/models/ControllerSuccessResultsModelCustomCodecImplementation.scala index a855c92..5c9ec9e 100644 --- a/app/shared/io/jsonParse/implementations/custom/models/ControllerSuccessResultsModelCustomCodecImplementation.scala +++ b/app/shared/io/jsonParse/implementations/custom/models/ControllerSuccessResultsModelCustomCodecImplementation.scala @@ -25,10 +25,10 @@ class ControllerSuccessResultsModelCustomCodecImplementation[TRow, TKey]( override def getEncoder : Encoder[ControllerSuccessResultsModel[TRow, TKey]] = (a : ControllerSuccessResultsModel[TRow, TKey]) => { //noinspection DuplicatedCode - val attributesJsonObject = attributesEncoder.getJsonGenericParser + val attributesJsonObject = attributesEncoder.genericJsonParser .toJsonObjectDirect(a.attributes.get) val rows = a.data - val genericJsonParser = jsonCirceDefaultEncoders.getJsonGenericParser + val genericJsonParser = jsonCirceDefaultEncoders.genericJsonParser val iterableJsonObjects = genericJsonParser.fromModelsToJsonObjects(Some(rows)) val dataToJson = Json.fromValues(iterableJsonObjects.get) diff --git a/app/shared/io/jsonParse/traits/BasicJsonEncoder.scala b/app/shared/io/jsonParse/traits/BasicJsonEncoder.scala index 50f128c..a1dd5c3 100644 --- a/app/shared/io/jsonParse/traits/BasicJsonEncoder.scala +++ b/app/shared/io/jsonParse/traits/BasicJsonEncoder.scala @@ -8,5 +8,5 @@ trait BasicJsonEncoder[T] { def getDecoder : Decoder[T] - def getJsonGenericParser : GenericJsonParser[T] = new GenericJsonParserImplementation[T](this) + def genericJsonParser : GenericJsonParser[T] = new GenericJsonParserImplementation[T](this) } diff --git a/app/shared/io/jsonParse/traits/GenericJsonParser.scala b/app/shared/io/jsonParse/traits/GenericJsonParser.scala index 7886456..691b4d1 100644 --- a/app/shared/io/jsonParse/traits/GenericJsonParser.scala +++ b/app/shared/io/jsonParse/traits/GenericJsonParser.scala @@ -24,13 +24,17 @@ trait GenericJsonParser[T] { def toModels(jsonString : Option[String]) : Option[ArrayBuffer[T]] + def toModelsDirect(jsonString : String) : ArrayBuffer[T] + def toJsonObject(model : Option[T]) : Option[Json] def toJsonObjects(models : Option[Iterable[T]]) : Option[Iterable[Json]] /** * Usages 2 space json String format. + * * @param models + * * @return */ def toJsonStringPrettyFormatForModels(models : Option[Iterable[T]]) : Option[String] diff --git a/app/shared/io/loggers/traits/EntitiesLogger.scala b/app/shared/io/loggers/traits/EntitiesLogger.scala index 15c7c88..cf25b2d 100644 --- a/app/shared/io/loggers/traits/EntitiesLogger.scala +++ b/app/shared/io/loggers/traits/EntitiesLogger.scala @@ -83,7 +83,7 @@ trait EntitiesLogger { .get .productFieldModels .map(w => w.toStringField) - s"${ AppConstants.DoubleSpace }0. ${ ToStringHelper.join(Some(headers), " , ") }${ AppConstants.NewLine }" + s"${ AppConstants.DoubleSpace }0. ${ ToStringHelper.join(Some(headers), " , ") }${ AppConstants.SystemNewLine }" } def getLogMessageForEntities[T]( @@ -120,7 +120,7 @@ trait EntitiesLogger { else { s" ${ count }. null" } - }).mkString(AppConstants.NewLine) + }).mkString(AppConstants.SystemNewLine) val footer = s"\n[Complete] Total entities printed : [${ count }]\n" val returningResult = s"${ header }${ productFieldNamesHeader }${ items }${ footer }" diff --git a/app/shared/io/loggers/traits/JsonLogger.scala b/app/shared/io/loggers/traits/JsonLogger.scala index 9b11026..34a25ef 100644 --- a/app/shared/io/loggers/traits/JsonLogger.scala +++ b/app/shared/io/loggers/traits/JsonLogger.scala @@ -30,14 +30,14 @@ trait JsonLogger { lazy val basicJsonEncoder = new BasicJsonEncoderImplementation[T]()(decoder, encoder) if (maybeModel.isDefined) { - val logJson = basicJsonEncoder.getJsonGenericParser.toLogStringForEntity(maybeModel) + val logJson = basicJsonEncoder.genericJsonParser.toLogStringForEntity(maybeModel) additionalLogging(logJson, logLevelType, stackIndex) } val isExecute = maybeModels.isDefined && maybeModels.get.nonEmpty if (isExecute) { - val logJson = basicJsonEncoder.getJsonGenericParser.toLogStringForEntities(maybeModels) + val logJson = basicJsonEncoder.genericJsonParser.toLogStringForEntities(maybeModels) additionalLogging(logJson, logLevelType, stackIndex) } } diff --git a/app/shared/io/redis/implementations/RedisCommonJsonParsingMechanismImplementation.scala b/app/shared/io/redis/implementations/RedisCommonJsonParsingMechanismImplementation.scala index 0df7ad5..1f24566 100644 --- a/app/shared/io/redis/implementations/RedisCommonJsonParsingMechanismImplementation.scala +++ b/app/shared/io/redis/implementations/RedisCommonJsonParsingMechanismImplementation.scala @@ -42,7 +42,7 @@ class RedisCommonJsonParsingMechanismImplementation @Inject()( } val jsonParser = getBasicJsonEncoder[T] - val toJson = jsonParser.getJsonGenericParser.toJsonObject(value) + val toJson = jsonParser.genericJsonParser.toJsonObject(value) if(EmptyValidateHelper.isDefined(toJson)){ redisClient.set(key, toJson.get.noSpaces, whenSet, expire) @@ -63,7 +63,7 @@ class RedisCommonJsonParsingMechanismImplementation @Inject()( try { val value = redisClient.get(key) val jsonParser = getBasicJsonEncoder[T] - return jsonParser.getJsonGenericParser.toModel(value) + return jsonParser.genericJsonParser.toModel(value) } catch { case e : Exception => @@ -88,7 +88,7 @@ class RedisCommonJsonParsingMechanismImplementation @Inject()( val jsonParser = getBasicJsonEncoder[T] val parser = jsonParser - .getJsonGenericParser + .genericJsonParser val toJsons = parser .fromModelsToJsonObjects(Some(items)) @@ -121,7 +121,7 @@ class RedisCommonJsonParsingMechanismImplementation @Inject()( } val jsonParser = getBasicJsonEncoder[T] - val models = jsonParser.getJsonGenericParser + val models = jsonParser.genericJsonParser .toModels(valuesAsJsonString) return models diff --git a/conf/openRTBSample.db b/conf/openRTBSample.db index a4b69bc..ff3e754 100644 Binary files a/conf/openRTBSample.db and b/conf/openRTBSample.db differ diff --git a/conf/routes b/conf/routes index 58b47ab..1f53f96 100644 --- a/conf/routes +++ b/conf/routes @@ -12,32 +12,32 @@ -> /admin/v1/bidResponses controllers.v1.router.BidResponseApiRouter -> /admin/v1/campaignTargetCities controllers.v1.router.CampaignTargetCityApiRouter -> /admin/v1/ctc controllers.v1.router.CampaignTargetCityApiRouter --> /admin/v1/CampaignTargetOperatingSystems controllers.v1.router.CampaignTargetOperatingSystemApiRouter --> /admin/v1/ctos controllers.v1.router.CampaignTargetOperatingSystemApiRouter --> /admin/v1/CampaignTargetSiteSystems controllers.v1.router.CampaignTargetSiteSystemApiRouter --> /admin/v1/ctss controllers.v1.router.CampaignTargetSiteSystemApiRouter --> /admin/v1/ContentCategories controllers.v1.router.ContentCategoryApiRouter --> /admin/v1/contentContexts controllers.v1.router.ContentContextApiRouter --> /admin/v1/demandSidePlatforms controllers.v1.router.DemandSidePlatformApiRouter --> /admin/v1/dsps controllers.v1.router.DemandSidePlatformApiRouter --> /admin/v1/geoMappings controllers.v1.router.GeoMappingApiRouter --> /admin/v1/impressions controllers.v1.router.ImpressionApiRouter --> /admin/v1/KeywordAdvertiseMappings controllers.v1.router.KeywordAdvertiseMappingApiRouter --> /admin/v1/kam controllers.v1.router.KeywordAdvertiseMappingApiRouter --> /admin/v1/keywords controllers.v1.router.KeywordApiRouter --> /admin/v1/lostBids controllers.v1.router.LostBidApiRouter --> /admin/v1/noBidResponses controllers.v1.router.NoBidResponseTypeApiRouter --> /admin/v1/nbr controllers.v1.router.NoBidResponseTypeApiRouter --> /admin/v1/publishers controllers.v1.router.PublisherApiRouter --> /admin/v1/transactions controllers.v1.router.TransactionApiRouter +-> /admin/v1/CampaignTargetOperatingSystems controllers.v1.router.CampaignTargetOperatingSystemApiRouter +-> /admin/v1/ctos controllers.v1.router.CampaignTargetOperatingSystemApiRouter +-> /admin/v1/CampaignTargetSiteSystems controllers.v1.router.CampaignTargetSiteSystemApiRouter +-> /admin/v1/ctss controllers.v1.router.CampaignTargetSiteSystemApiRouter +-> /admin/v1/ContentCategories controllers.v1.router.ContentCategoryApiRouter +-> /admin/v1/contentContexts controllers.v1.router.ContentContextApiRouter +-> /admin/v1/demandSidePlatforms controllers.v1.router.DemandSidePlatformApiRouter +-> /admin/v1/dsps controllers.v1.router.DemandSidePlatformApiRouter +-> /admin/v1/geoMappings controllers.v1.router.GeoMappingApiRouter +-> /admin/v1/impressions controllers.v1.router.ImpressionApiRouter +-> /admin/v1/KeywordAdvertiseMappings controllers.v1.router.KeywordAdvertiseMappingApiRouter +-> /admin/v1/kam controllers.v1.router.KeywordAdvertiseMappingApiRouter +-> /admin/v1/keywords controllers.v1.router.KeywordApiRouter +-> /admin/v1/lostBids controllers.v1.router.LostBidApiRouter +-> /admin/v1/noBidResponses controllers.v1.router.NoBidResponseTypeApiRouter +-> /admin/v1/nbr controllers.v1.router.NoBidResponseTypeApiRouter +-> /admin/v1/publishers controllers.v1.router.PublisherApiRouter +-> /admin/v1/transactions controllers.v1.router.TransactionApiRouter --> /services/v1/rtbSimulateService controllers.controllerRoutes.routerGeneric.RtbServiceBasicRouter --> /services/v1/demansideplantformservice controllers.controllerRoutes.routerGeneric.DemandSidePlatformServiceRouter --> /services/v1/dspService controllers.controllerRoutes.routerGeneric.DemandSidePlatformServiceRouter +-> /services/v1/rtbSimulateService shared.com.ortb.routes.router.core.RtbServiceBasicRouter +-> /services/v1/demansideplantformservice shared.com.ortb.routes.router.DemandSidePlatformServiceRouter +-> /services/v1/dspService shared.com.ortb.routes.router.DemandSidePlatformServiceRouter # Map static resources from the /public folder to the /assets URL path -GET /assets/*file controllers.Assets.at(path="/public", file) +GET /assets/*file controllers.Assets.at(path="/public", file) diff --git a/database-schema/schema-quries.sql b/database-schema/schema-quries.sql new file mode 100644 index 0000000..115d57e --- /dev/null +++ b/database-schema/schema-quries.sql @@ -0,0 +1,18 @@ +DELETE +FROM + BidRequest; +DELETE +FROM + BidResponse; +DELETE +FROM + LogTrace; + + +UPDATE sqlite_sequence + SET seq = 0 + +WHERE + sqlite_sequence.name = 'BidResponse' + OR sqlite_sequence.name = 'LogTrace' + OR sqlite_sequence.name = 'BidRequest' \ No newline at end of file diff --git a/database-schema/schema-views.sql b/database-schema/schema-views.sql new file mode 100644 index 0000000..7e8a13b --- /dev/null +++ b/database-schema/schema-views.sql @@ -0,0 +1,149 @@ + +DROP VIEW "main"."AdvertiseIsRunningView"; + +CREATE VIEW "main"."AdvertiseIsRunningView" AS SELECT + Advertise.*, + Campaign.IsRunning +FROM + Advertise + INNER JOIN + Campaign + ON + Advertise.CampaignId = Campaign.CampaignId ; + +DROP VIEW "main"."BidRelatedIdsView"; + +CREATE VIEW "main"."BidRelatedIdsView" AS SELECT DISTINCT + Bid.BidId, + Impression.ImpressionId, + Bid.SeatBidId, + Bid.CampaignId, + Auction.AuctionId, + SeatBid.BidRequestId, + SeatBid.BidResponseId, + Bid.AdvertiseId, + SeatBid.DemandSidePlatformId +FROM + Impression + LEFT JOIN Bid ON Impression.BidId = Bid.BidId + AND Impression.ImpressionId = Bid.ImpressionId + LEFT JOIN SeatBid ON Bid.SeatBidId = SeatBid.SeatBidId + LEFT JOIN Auction ON SeatBid.AuctionId = Auction.AuctionId ; + +DROP VIEW "main"."KeywordAdvertiseMappingIdsView"; + +CREATE VIEW "main"."KeywordAdvertiseMappingIdsView" AS SELECT + Keyword.KeywordId, + Keyword.Keyword, + KeywordAdvertiseMapping.KeywordAdvertiseMappingId, + Advertise.AdvertiseId, + Advertise.CampaignId, + Advertise.BannerAdvertiseTypeId, + Advertise.IsVideo, + Advertise.IsBanner, + Advertise.ContentContextId +FROM + Advertise + INNER JOIN + KeywordAdvertiseMapping + ON + Advertise.AdvertiseId = KeywordAdvertiseMapping.AdvertiseId + INNER JOIN + Keyword + ON + KeywordAdvertiseMapping.KeywordId = Keyword.KeywordId ; + +DROP VIEW "main"."WinningPriceInfoView"; + +CREATE VIEW "main"."WinningPriceInfoView" AS SELECT + Bid.BidId, + Impression.ImpressionId, + Bid.SeatBidId, + Bid.CampaignId, + Auction.AuctionId, + SeatBid.BidRequestId, + SeatBid.BidResponseId, + Bid.AdvertiseId, + SeatBid.DemandSidePlatformId, + Auction.WinningPrice as AuctionWinningPrice, + Bid.DealBiddingPrice, + Bid.ActualWiningPrice, + Auction.CreatedDateTimestamp AS AuctionCreatedDateTimestamp, + Bid.CreatedDateTimestamp AS BiddingCreatedDateTimestamp, + Impression.CreatedDateTimestamp AS ImpressionCreatedDateTimestamp, + Bid.IsImpressionServedOrWonByAuction AS IsWon, + SeatBid.IsGroupBid +FROM + Impression + INNER JOIN + Bid + ON + Impression.BidId = Bid.BidId AND + Impression.ImpressionId = Bid.ImpressionId + INNER JOIN + SeatBid + ON + Bid.SeatBidId = SeatBid.SeatBidId + INNER JOIN + Auction + ON + SeatBid.AuctionId = Auction.AuctionId ; + +DROP VIEW "main"."BidRequestImpressionWithPlaceholderView"; + +CREATE VIEW "main"."BidRequestImpressionWithPlaceholderView" AS SELECT DISTINCT + BidRequest.BidRequestId, + BidRequest.CreatedDateTimestamp, + BidRequest.IsWonTheAuction, + BidRequest.ContentContextId, + BidRequest.Currency, + BidRequest.RawBidRequestJson, + BidRequest.TargetedCities, + BidRequest.TargetedSites, + BidRequest.Cities, + BidRequest.Countries, + BidRequest.IsVideo, + BidRequest.IsBanner, + BidRequest.AuctionId, + BidRequest.DemandSidePlatformId, + ContentContext.Context AS ContentContext, + ImpressionPlaceholder.IsNative AS IsNativePlaceHolder, + ImpressionPlaceholder.IsVideo AS IsVideoPlaceHolder, + ImpressionPlaceholder.IsBanner AS IsBannnerPlaceHolder, + ImpressionPlaceholder.CreatedDateTimestamp AS CreatedDateTimestampImpressionPlaceholder, + ImpressionPlaceholder.IsTopFrame, + ImpressionPlaceholder.Position, + ImpressionPlaceholder.Mimes, + ImpressionPlaceholder.IsMinHeightWidthEmpty, + ImpressionPlaceholder.IsHeightWidthEmpty, + ImpressionPlaceholder.MaxWidth, + ImpressionPlaceholder.MaxHeight, + ImpressionPlaceholder.MinWidth, + ImpressionPlaceholder.MinHeight, + ImpressionPlaceholder.Width, + ImpressionPlaceholder.Height, + Impression.CreatedDateTimestamp, + ImpressionPlaceholder.IsMaxHeightWidthEmpty, + Impression.AdvertiseDisplayedDate, + Impression.ImpressionId, + Impression.Hash, + Impression.BidfloorCur, + Impression.Bidfloor, + Impression.IsImpressionServedOrWonByAuction, + Impression.ImpressionPlaceholderId, + Impression.RawImpressionJson, + Impression.BidResponseId +FROM + BidRequest + LEFT JOIN + Impression + ON + BidRequest.BidRequestId = Impression.BidRequestId + LEFT JOIN + ImpressionPlaceholder + ON + Impression.ImpressionPlaceholderId = ImpressionPlaceholder.ImpressionPlaceholderId + LEFT JOIN + ContentContext + ON + BidRequest.ContentContextId = ContentContext.ContentContextId ; \ No newline at end of file diff --git a/database-schema/schema.sql b/database-schema/schema.sql index 7cde766..b7df2b6 100644 --- a/database-schema/schema.sql +++ b/database-schema/schema.sql @@ -10,7 +10,7 @@ Target Server Version : 3030001 File Encoding : 65001 - Date: 23/05/2020 16:35:45 + Date: 28/05/2020 18:01:54 */ PRAGMA foreign_keys = false; @@ -28,8 +28,9 @@ CREATE TABLE "Advertise" ( "BidUrl" TEXT NOT NULL, "IFrameHtml" TEXT, "IsCountrySpecific" INTEGER(1) NOT NULL DEFAULT 0, - "IsBanner" INTEGER(1) DEFAULT 0, + "IsBanner" INTEGER(1) NOT NULL DEFAULT 0, "IsVideo" INTEGER(1) NOT NULL DEFAULT 0, + "IsNative" INTEGER(1) NOT NULL DEFAULT 0, "ImpressionCount" INTEGER NOT NULL DEFAULT 0, "Height" INTEGER NOT NULL DEFAULT 0, "Width" INTEGER NOT NULL DEFAULT 0, @@ -37,12 +38,14 @@ CREATE TABLE "Advertise" ( "MinWidth" INTEGER NOT NULL DEFAULT 0, "MaxHeight" INTEGER NOT NULL DEFAULT 0, "MaxWidth" INTEGER NOT NULL DEFAULT 0, - "IsHeightWidthEmpty" INTEGER(1) DEFAULT 1, - "IsMaxHeightWidthEmpty" INTEGER(1) DEFAULT 1, - "IsMinHeightWidthEmpty" INTEGER(1) DEFAULT 1, + "IsHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMaxHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMinHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, "HasAgeRestriction" INTEGER(1) NOT NULL DEFAULT 0, "MinAge" INTEGER DEFAULT 0, "MaxAge" INTEGER DEFAULT 0, + "Duration" INTEGER NOT NULL DEFAULT 0, + "Protocol" INTEGER NOT NULL DEFAULT 0, "CreatedDateTimestamp" TIMESTAMP NOT NULL, CONSTRAINT "CampaignFK" FOREIGN KEY ("CampaignId") REFERENCES "Campaign" ("CampaignId") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "BannerAdvertiseTypeIdFK" FOREIGN KEY ("BannerAdvertiseTypeId") REFERENCES "BannerAdvertiseType" ("BannerAdvertiseTypeId") ON DELETE CASCADE ON UPDATE CASCADE, @@ -122,8 +125,6 @@ CREATE TABLE "BidRequest" ( "AuctionId" INTEGER DEFAULT NULL, "IsBanner" INTEGER(1) NOT NULL DEFAULT 0, "IsVideo" INTEGER(1) NOT NULL DEFAULT 0, - "Height" INTEGER DEFAULT NULL, - "Width" INTEGER DEFAULT NULL, "Countries" TEXT DEFAULT NULL, "Cities" TEXT DEFAULT NULL, "TargetedSites" TEXT DEFAULT NULL, @@ -283,15 +284,44 @@ CREATE TABLE "GeoMapping" ( DROP TABLE IF EXISTS "Impression"; CREATE TABLE "Impression" ( "ImpressionId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "RawImpressionJson" TEXT NOT NULL DEFAULT "", - "BidId" INTEGER DEFAULT NULL, - "IsImpressionServedOrWonByAuction" INTEGER(1) DEFAULT 0, - "Bidfloor" REAL DEFAULT 0, - "BidfloorCur" TEXT DEFAULT "USD", + "BidResponseId" INTEGER DEFAULT NULL, + "BidRequestId" INTEGER DEFAULT NULL, + "RawImpressionJson" TEXT NOT NULL DEFAULT '', + "IsImpressionWonByAuction" INTEGER(1) NOT NULL DEFAULT 0, + "IsImpressionServed" INTEGER(1) NOT NULL DEFAULT 0, + "Bidfloor" REAL NOT NULL DEFAULT 0, + "BidfloorCur" TEXT NOT NULL DEFAULT 'USD', "Hash" TEXT DEFAULT NULL, - "DisplayDate" TIMESTAMP NOT NULL, + "AdvertiseDisplayedDate" TIMESTAMP DEFAULT NULL, + "CreatedDateTimestamp" TIMESTAMP NOT NULL, + CONSTRAINT "BidResponseIdFK" FOREIGN KEY ("BidResponseId") REFERENCES "BidResponse" ("BidResponseId") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "BidRequestIdFK" FOREIGN KEY ("BidRequestId") REFERENCES "BidRequest" ("BidRequestId") ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- ---------------------------- +-- Table structure for ImpressionPlaceholder +-- ---------------------------- +DROP TABLE IF EXISTS "ImpressionPlaceholder"; +CREATE TABLE "ImpressionPlaceholder" ( + "ImpressionPlaceholderId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "ImpressionId" INTEGER NOT NULL, + "IsBanner" INTEGER(1) NOT NULL DEFAULT 0, + "IsVideo" INTEGER(1) NOT NULL DEFAULT 0, + "IsNative" INTEGER(1) NOT NULL DEFAULT 0, + "Height" INTEGER NOT NULL DEFAULT 0, + "Width" INTEGER NOT NULL DEFAULT 0, + "MinHeight" INTEGER NOT NULL DEFAULT 0, + "MinWidth" INTEGER NOT NULL DEFAULT 0, + "MaxHeight" INTEGER NOT NULL DEFAULT 0, + "MaxWidth" INTEGER NOT NULL DEFAULT 0, + "IsHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMaxHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMinHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "Mimes" TEXT DEFAULT NULL, + "Position" INTEGER DEFAULT NULL, + "IsTopFrame" INTEGER(1) NOT NULL DEFAULT 0, "CreatedDateTimestamp" TIMESTAMP NOT NULL, - CONSTRAINT "BidIdFK" FOREIGN KEY ("BidId") REFERENCES "Bid" ("BidId") ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT "ImpressionIdFK" FOREIGN KEY ("ImpressionId") REFERENCES "Impression" ("ImpressionId") ON DELETE NO ACTION ON UPDATE NO ACTION ); -- ---------------------------- @@ -498,8 +528,7 @@ FROM Impression LEFT JOIN Bid - ON - Impression.BidId = Bid.BidId AND + ON Impression.ImpressionId = Bid.ImpressionId LEFT JOIN SeatBid @@ -510,30 +539,86 @@ FROM ON SeatBid.AuctionId = Auction.AuctionId; +-- ---------------------------- +-- View structure for BidRequestImpressionWithPlaceholderView +-- ---------------------------- +DROP VIEW IF EXISTS "BidRequestImpressionWithPlaceholderView"; +CREATE VIEW "BidRequestImpressionWithPlaceholderView" AS SELECT DISTINCT + BidRequest.BidRequestId, + BidRequest.CreatedDateTimestamp, + BidRequest.IsWonTheAuction, + BidRequest.ContentContextId, + BidRequest.Currency, + BidRequest.RawBidRequestJson, + BidRequest.TargetedCities, + BidRequest.TargetedSites, + BidRequest.Cities, + BidRequest.Countries, + BidRequest.IsVideo, + BidRequest.IsBanner, + BidRequest.AuctionId, + BidRequest.DemandSidePlatformId, + ContentContext.Context AS ContentContext, + ImpressionPlaceholder.IsNative AS IsNativePlaceHolder, + ImpressionPlaceholder.IsVideo AS IsVideoPlaceHolder, + ImpressionPlaceholder.IsBanner AS IsBannnerPlaceHolder, + ImpressionPlaceholder.CreatedDateTimestamp AS CreatedDateTimestampImpressionPlaceholder, + ImpressionPlaceholder.IsTopFrame, + ImpressionPlaceholder.Position, + ImpressionPlaceholder.Mimes, + ImpressionPlaceholder.IsMinHeightWidthEmpty, + ImpressionPlaceholder.IsHeightWidthEmpty, + ImpressionPlaceholder.MaxWidth, + ImpressionPlaceholder.MaxHeight, + ImpressionPlaceholder.MinWidth, + ImpressionPlaceholder.MinHeight, + ImpressionPlaceholder.Width, + ImpressionPlaceholder.Height, + Impression.CreatedDateTimestamp as CreatedDateTimestampImpression, + ImpressionPlaceholder.IsMaxHeightWidthEmpty, + Impression.AdvertiseDisplayedDate, + Impression.ImpressionId, + Impression.Hash, + Impression.BidfloorCur, + Impression.Bidfloor, + Impression.IsImpressionServed, + Impression.IsImpressionWonByAuction, + Impression.RawImpressionJson, + Impression.BidResponseId +FROM + BidRequest + LEFT JOIN + Impression + ON + BidRequest.BidRequestId = Impression.BidRequestId + LEFT JOIN + ImpressionPlaceholder + ON + Impression.ImpressionId = ImpressionPlaceholder.ImpressionId + LEFT JOIN + ContentContext + ON + BidRequest.ContentContextId = ContentContext.ContentContextId; + -- ---------------------------- -- View structure for KeywordAdvertiseMappingIdsView -- ---------------------------- DROP VIEW IF EXISTS "KeywordAdvertiseMappingIdsView"; CREATE VIEW "KeywordAdvertiseMappingIdsView" AS SELECT - Keyword.KeywordId, - Keyword.Keyword, - KeywordAdvertiseMapping.KeywordAdvertiseMappingId, - Advertise.AdvertiseId, - Advertise.CampaignId, - Advertise.BannerAdvertiseTypeId, - Advertise.IsVideo, - Advertise.IsBanner, - Advertise.ContentContextId + Keyword.KeywordId, + Keyword.Keyword, + KeywordAdvertiseMapping.KeywordAdvertiseMappingId, + Advertise.AdvertiseId, + Advertise.CampaignId, + Advertise.BannerAdvertiseTypeId, + Advertise.IsVideo, + Advertise.IsBanner, + Advertise.IsNative, + Advertise.ContentContextId FROM Advertise - INNER JOIN - KeywordAdvertiseMapping - ON - Advertise.AdvertiseId = KeywordAdvertiseMapping.AdvertiseId - INNER JOIN - Keyword - ON - KeywordAdvertiseMapping.KeywordId = Keyword.KeywordId; + INNER JOIN KeywordAdvertiseMapping ON Advertise.AdvertiseId = KeywordAdvertiseMapping.AdvertiseId + JOIN Keyword ON KeywordAdvertiseMapping.KeywordId = Keyword.KeywordId; -- ---------------------------- -- View structure for WinningPriceInfoView @@ -541,34 +626,35 @@ FROM DROP VIEW IF EXISTS "WinningPriceInfoView"; CREATE VIEW "WinningPriceInfoView" AS SELECT Bid.BidId, - Impression.ImpressionId, + Bid.IsImpressionServedOrWonByAuction AS IsWon, Bid.SeatBidId, - Bid.CampaignId, - Auction.AuctionId, - SeatBid.BidRequestId, - SeatBid.BidResponseId, + Bid.CampaignId, Bid.AdvertiseId, - SeatBid.DemandSidePlatformId, - Auction.WinningPrice as AuctionWinningPrice, Bid.DealBiddingPrice, Bid.ActualWiningPrice, - Auction.CreatedDateTimestamp AS AuctionCreatedDateTimestamp, Bid.CreatedDateTimestamp AS BiddingCreatedDateTimestamp, + Impression.ImpressionId, + SeatBid.BidRequestId, + SeatBid.BidResponseId, + SeatBid.DemandSidePlatformId, + Auction.AuctionId, + Auction.WinningPrice AS AuctionWinningPrice, + Auction.CreatedDateTimestamp AS AuctionCreatedDateTimestamp, Impression.CreatedDateTimestamp AS ImpressionCreatedDateTimestamp, - Bid.IsImpressionServedOrWonByAuction AS IsWon, - SeatBid.IsGroupBid + SeatBid.IsGroupBid, + Impression.BidfloorCur, + Impression.Bidfloor FROM Impression - INNER JOIN + LEFT JOIN Bid ON - Impression.BidId = Bid.BidId AND Impression.ImpressionId = Bid.ImpressionId - INNER JOIN + LEFT JOIN SeatBid ON Bid.SeatBidId = SeatBid.SeatBidId - INNER JOIN + LEFT JOIN Auction ON SeatBid.AuctionId = Auction.AuctionId; @@ -582,6 +668,10 @@ FROM -- ---------------------------- UPDATE "sqlite_sequence" SET seq = 4 WHERE name = 'BannerAdvertiseType'; +-- ---------------------------- +-- Auto increment value for BidRequest +-- ---------------------------- + -- ---------------------------- -- Auto increment value for BidResponse -- ---------------------------- @@ -606,6 +696,14 @@ UPDATE "sqlite_sequence" SET seq = 16 WHERE name = 'CreativeAttribute'; -- ---------------------------- UPDATE "sqlite_sequence" SET seq = 3 WHERE name = 'DemandSidePlatform'; +-- ---------------------------- +-- Auto increment value for Impression +-- ---------------------------- + +-- ---------------------------- +-- Auto increment value for ImpressionPlaceholder +-- ---------------------------- + -- ---------------------------- -- Auto increment value for LogTrace -- ---------------------------- diff --git a/database-schema/schemaAndData.sql b/database-schema/schemaAndData.sql index f018666..6deb5cb 100644 --- a/database-schema/schemaAndData.sql +++ b/database-schema/schemaAndData.sql @@ -10,7 +10,7 @@ Target Server Version : 3030001 File Encoding : 65001 - Date: 23/05/2020 16:35:39 + Date: 28/05/2020 18:01:49 */ PRAGMA foreign_keys = false; @@ -28,8 +28,9 @@ CREATE TABLE "Advertise" ( "BidUrl" TEXT NOT NULL, "IFrameHtml" TEXT, "IsCountrySpecific" INTEGER(1) NOT NULL DEFAULT 0, - "IsBanner" INTEGER(1) DEFAULT 0, + "IsBanner" INTEGER(1) NOT NULL DEFAULT 0, "IsVideo" INTEGER(1) NOT NULL DEFAULT 0, + "IsNative" INTEGER(1) NOT NULL DEFAULT 0, "ImpressionCount" INTEGER NOT NULL DEFAULT 0, "Height" INTEGER NOT NULL DEFAULT 0, "Width" INTEGER NOT NULL DEFAULT 0, @@ -37,12 +38,14 @@ CREATE TABLE "Advertise" ( "MinWidth" INTEGER NOT NULL DEFAULT 0, "MaxHeight" INTEGER NOT NULL DEFAULT 0, "MaxWidth" INTEGER NOT NULL DEFAULT 0, - "IsHeightWidthEmpty" INTEGER(1) DEFAULT 1, - "IsMaxHeightWidthEmpty" INTEGER(1) DEFAULT 1, - "IsMinHeightWidthEmpty" INTEGER(1) DEFAULT 1, + "IsHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMaxHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMinHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, "HasAgeRestriction" INTEGER(1) NOT NULL DEFAULT 0, "MinAge" INTEGER DEFAULT 0, "MaxAge" INTEGER DEFAULT 0, + "Duration" INTEGER NOT NULL DEFAULT 0, + "Protocol" INTEGER NOT NULL DEFAULT 0, "CreatedDateTimestamp" TIMESTAMP NOT NULL, CONSTRAINT "CampaignFK" FOREIGN KEY ("CampaignId") REFERENCES "Campaign" ("CampaignId") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "BannerAdvertiseTypeIdFK" FOREIGN KEY ("BannerAdvertiseTypeId") REFERENCES "BannerAdvertiseType" ("BannerAdvertiseTypeId") ON DELETE CASCADE ON UPDATE CASCADE, @@ -130,8 +133,6 @@ CREATE TABLE "BidRequest" ( "AuctionId" INTEGER DEFAULT NULL, "IsBanner" INTEGER(1) NOT NULL DEFAULT 0, "IsVideo" INTEGER(1) NOT NULL DEFAULT 0, - "Height" INTEGER DEFAULT NULL, - "Width" INTEGER DEFAULT NULL, "Countries" TEXT DEFAULT NULL, "Cities" TEXT DEFAULT NULL, "TargetedSites" TEXT DEFAULT NULL, @@ -383,15 +384,44 @@ CREATE TABLE "GeoMapping" ( DROP TABLE IF EXISTS "Impression"; CREATE TABLE "Impression" ( "ImpressionId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "RawImpressionJson" TEXT NOT NULL DEFAULT "", - "BidId" INTEGER DEFAULT NULL, - "IsImpressionServedOrWonByAuction" INTEGER(1) DEFAULT 0, - "Bidfloor" REAL DEFAULT 0, - "BidfloorCur" TEXT DEFAULT "USD", + "BidResponseId" INTEGER DEFAULT NULL, + "BidRequestId" INTEGER DEFAULT NULL, + "RawImpressionJson" TEXT NOT NULL DEFAULT '', + "IsImpressionWonByAuction" INTEGER(1) NOT NULL DEFAULT 0, + "IsImpressionServed" INTEGER(1) NOT NULL DEFAULT 0, + "Bidfloor" REAL NOT NULL DEFAULT 0, + "BidfloorCur" TEXT NOT NULL DEFAULT 'USD', "Hash" TEXT DEFAULT NULL, - "DisplayDate" TIMESTAMP NOT NULL, + "AdvertiseDisplayedDate" TIMESTAMP DEFAULT NULL, "CreatedDateTimestamp" TIMESTAMP NOT NULL, - CONSTRAINT "BidIdFK" FOREIGN KEY ("BidId") REFERENCES "Bid" ("BidId") ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT "BidResponseIdFK" FOREIGN KEY ("BidResponseId") REFERENCES "BidResponse" ("BidResponseId") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "BidRequestIdFK" FOREIGN KEY ("BidRequestId") REFERENCES "BidRequest" ("BidRequestId") ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- ---------------------------- +-- Table structure for ImpressionPlaceholder +-- ---------------------------- +DROP TABLE IF EXISTS "ImpressionPlaceholder"; +CREATE TABLE "ImpressionPlaceholder" ( + "ImpressionPlaceholderId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "ImpressionId" INTEGER NOT NULL, + "IsBanner" INTEGER(1) NOT NULL DEFAULT 0, + "IsVideo" INTEGER(1) NOT NULL DEFAULT 0, + "IsNative" INTEGER(1) NOT NULL DEFAULT 0, + "Height" INTEGER NOT NULL DEFAULT 0, + "Width" INTEGER NOT NULL DEFAULT 0, + "MinHeight" INTEGER NOT NULL DEFAULT 0, + "MinWidth" INTEGER NOT NULL DEFAULT 0, + "MaxHeight" INTEGER NOT NULL DEFAULT 0, + "MaxWidth" INTEGER NOT NULL DEFAULT 0, + "IsHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMaxHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "IsMinHeightWidthEmpty" INTEGER(1) NOT NULL DEFAULT 1, + "Mimes" TEXT DEFAULT NULL, + "Position" INTEGER DEFAULT NULL, + "IsTopFrame" INTEGER(1) NOT NULL DEFAULT 0, + "CreatedDateTimestamp" TIMESTAMP NOT NULL, + CONSTRAINT "ImpressionIdFK" FOREIGN KEY ("ImpressionId") REFERENCES "Impression" ("ImpressionId") ON DELETE NO ACTION ON UPDATE NO ACTION ); -- ---------------------------- @@ -607,8 +637,11 @@ INSERT INTO "sqlite_sequence" VALUES ('Publisher', 3); INSERT INTO "sqlite_sequence" VALUES ('VideoPlaybackMethod', 4); INSERT INTO "sqlite_sequence" VALUES ('VideoResponseProtocol', 6); INSERT INTO "sqlite_sequence" VALUES ('BidResponse', 0); -INSERT INTO "sqlite_sequence" VALUES ('Advertise', 0); INSERT INTO "sqlite_sequence" VALUES ('LogTrace', 0); +INSERT INTO "sqlite_sequence" VALUES ('BidRequest', 0); +INSERT INTO "sqlite_sequence" VALUES ('Advertise', 0); +INSERT INTO "sqlite_sequence" VALUES ('ImpressionPlaceholder', 0); +INSERT INTO "sqlite_sequence" VALUES ('Impression', 0); -- ---------------------------- -- Table structure for sqlite_stat1 @@ -652,8 +685,7 @@ FROM Impression LEFT JOIN Bid - ON - Impression.BidId = Bid.BidId AND + ON Impression.ImpressionId = Bid.ImpressionId LEFT JOIN SeatBid @@ -664,30 +696,86 @@ FROM ON SeatBid.AuctionId = Auction.AuctionId; +-- ---------------------------- +-- View structure for BidRequestImpressionWithPlaceholderView +-- ---------------------------- +DROP VIEW IF EXISTS "BidRequestImpressionWithPlaceholderView"; +CREATE VIEW "BidRequestImpressionWithPlaceholderView" AS SELECT DISTINCT + BidRequest.BidRequestId, + BidRequest.CreatedDateTimestamp, + BidRequest.IsWonTheAuction, + BidRequest.ContentContextId, + BidRequest.Currency, + BidRequest.RawBidRequestJson, + BidRequest.TargetedCities, + BidRequest.TargetedSites, + BidRequest.Cities, + BidRequest.Countries, + BidRequest.IsVideo, + BidRequest.IsBanner, + BidRequest.AuctionId, + BidRequest.DemandSidePlatformId, + ContentContext.Context AS ContentContext, + ImpressionPlaceholder.IsNative AS IsNativePlaceHolder, + ImpressionPlaceholder.IsVideo AS IsVideoPlaceHolder, + ImpressionPlaceholder.IsBanner AS IsBannnerPlaceHolder, + ImpressionPlaceholder.CreatedDateTimestamp AS CreatedDateTimestampImpressionPlaceholder, + ImpressionPlaceholder.IsTopFrame, + ImpressionPlaceholder.Position, + ImpressionPlaceholder.Mimes, + ImpressionPlaceholder.IsMinHeightWidthEmpty, + ImpressionPlaceholder.IsHeightWidthEmpty, + ImpressionPlaceholder.MaxWidth, + ImpressionPlaceholder.MaxHeight, + ImpressionPlaceholder.MinWidth, + ImpressionPlaceholder.MinHeight, + ImpressionPlaceholder.Width, + ImpressionPlaceholder.Height, + Impression.CreatedDateTimestamp as CreatedDateTimestampImpression, + ImpressionPlaceholder.IsMaxHeightWidthEmpty, + Impression.AdvertiseDisplayedDate, + Impression.ImpressionId, + Impression.Hash, + Impression.BidfloorCur, + Impression.Bidfloor, + Impression.IsImpressionServed, + Impression.IsImpressionWonByAuction, + Impression.RawImpressionJson, + Impression.BidResponseId +FROM + BidRequest + LEFT JOIN + Impression + ON + BidRequest.BidRequestId = Impression.BidRequestId + LEFT JOIN + ImpressionPlaceholder + ON + Impression.ImpressionId = ImpressionPlaceholder.ImpressionId + LEFT JOIN + ContentContext + ON + BidRequest.ContentContextId = ContentContext.ContentContextId; + -- ---------------------------- -- View structure for KeywordAdvertiseMappingIdsView -- ---------------------------- DROP VIEW IF EXISTS "KeywordAdvertiseMappingIdsView"; CREATE VIEW "KeywordAdvertiseMappingIdsView" AS SELECT - Keyword.KeywordId, - Keyword.Keyword, - KeywordAdvertiseMapping.KeywordAdvertiseMappingId, - Advertise.AdvertiseId, - Advertise.CampaignId, - Advertise.BannerAdvertiseTypeId, - Advertise.IsVideo, - Advertise.IsBanner, - Advertise.ContentContextId + Keyword.KeywordId, + Keyword.Keyword, + KeywordAdvertiseMapping.KeywordAdvertiseMappingId, + Advertise.AdvertiseId, + Advertise.CampaignId, + Advertise.BannerAdvertiseTypeId, + Advertise.IsVideo, + Advertise.IsBanner, + Advertise.IsNative, + Advertise.ContentContextId FROM Advertise - INNER JOIN - KeywordAdvertiseMapping - ON - Advertise.AdvertiseId = KeywordAdvertiseMapping.AdvertiseId - INNER JOIN - Keyword - ON - KeywordAdvertiseMapping.KeywordId = Keyword.KeywordId; + INNER JOIN KeywordAdvertiseMapping ON Advertise.AdvertiseId = KeywordAdvertiseMapping.AdvertiseId + JOIN Keyword ON KeywordAdvertiseMapping.KeywordId = Keyword.KeywordId; -- ---------------------------- -- View structure for WinningPriceInfoView @@ -695,34 +783,35 @@ FROM DROP VIEW IF EXISTS "WinningPriceInfoView"; CREATE VIEW "WinningPriceInfoView" AS SELECT Bid.BidId, - Impression.ImpressionId, + Bid.IsImpressionServedOrWonByAuction AS IsWon, Bid.SeatBidId, - Bid.CampaignId, - Auction.AuctionId, - SeatBid.BidRequestId, - SeatBid.BidResponseId, + Bid.CampaignId, Bid.AdvertiseId, - SeatBid.DemandSidePlatformId, - Auction.WinningPrice as AuctionWinningPrice, Bid.DealBiddingPrice, Bid.ActualWiningPrice, - Auction.CreatedDateTimestamp AS AuctionCreatedDateTimestamp, Bid.CreatedDateTimestamp AS BiddingCreatedDateTimestamp, + Impression.ImpressionId, + SeatBid.BidRequestId, + SeatBid.BidResponseId, + SeatBid.DemandSidePlatformId, + Auction.AuctionId, + Auction.WinningPrice AS AuctionWinningPrice, + Auction.CreatedDateTimestamp AS AuctionCreatedDateTimestamp, Impression.CreatedDateTimestamp AS ImpressionCreatedDateTimestamp, - Bid.IsImpressionServedOrWonByAuction AS IsWon, - SeatBid.IsGroupBid + SeatBid.IsGroupBid, + Impression.BidfloorCur, + Impression.Bidfloor FROM Impression - INNER JOIN + LEFT JOIN Bid ON - Impression.BidId = Bid.BidId AND Impression.ImpressionId = Bid.ImpressionId - INNER JOIN + LEFT JOIN SeatBid ON Bid.SeatBidId = SeatBid.SeatBidId - INNER JOIN + LEFT JOIN Auction ON SeatBid.AuctionId = Auction.AuctionId; @@ -736,6 +825,10 @@ FROM -- ---------------------------- UPDATE "sqlite_sequence" SET seq = 4 WHERE name = 'BannerAdvertiseType'; +-- ---------------------------- +-- Auto increment value for BidRequest +-- ---------------------------- + -- ---------------------------- -- Auto increment value for BidResponse -- ---------------------------- @@ -760,6 +853,14 @@ UPDATE "sqlite_sequence" SET seq = 16 WHERE name = 'CreativeAttribute'; -- ---------------------------- UPDATE "sqlite_sequence" SET seq = 3 WHERE name = 'DemandSidePlatform'; +-- ---------------------------- +-- Auto increment value for Impression +-- ---------------------------- + +-- ---------------------------- +-- Auto increment value for ImpressionPlaceholder +-- ---------------------------- + -- ---------------------------- -- Auto increment value for LogTrace -- ---------------------------- diff --git a/documents/Notes.md b/documents/Notes.md index 44ce498..9767ee0 100644 --- a/documents/Notes.md +++ b/documents/Notes.md @@ -66,7 +66,10 @@ - Scala nameOf : https://stackoverflow.com/questions/5050682/get-scala-variable-name-at-runtime | https://github.com/dwickern/scala-nameof - Publish sbt package : https://bit.ly/2WbEqNn - Pimp My Library (Extension) : https://bit.ly/2WGpkyi | https://bit.ly/2WGpkyi -- Sqlite Expressions : https://www.sqlite.org/lang_expr.html +- Sqlite Expressions : https://www.sqlite.org/lang_expr.html +- Play Error handle : https://bit.ly/2BaSXRt +- Play Status Code : https://bit.ly/2XF6mZk | https://bit.ly/2zGh35Y | https://bit.ly/2B9XFil +- Play Cookies Builder : https://bit.ly/2XB7ltM ```scala def anyTypeToByteArray(value: Any): Array[Byte] = {