Search in sources :

Example 1 with OTHER

use of java.sql.Types.OTHER in project pay-adminusers by alphagov.

the class DatabaseTestHelper method insertServiceEntity.

public DatabaseTestHelper insertServiceEntity(ServiceEntity serviceEntity) {
    jdbi.withHandle(handle -> {
        PGobject customBranding = serviceEntity.getCustomBranding() == null ? null : new CustomBrandingConverter().convertToDatabaseColumn(serviceEntity.getCustomBranding());
        MerchantDetailsEntity merchantDetails = serviceEntity.getMerchantDetailsEntity();
        return handle.createUpdate("INSERT INTO services(" + "id, custom_branding, " + "merchant_name, merchant_telephone_number, merchant_address_line1, merchant_address_line2, merchant_address_city, " + "merchant_address_postcode, merchant_address_country, merchant_email, merchant_url, external_id, redirect_to_service_immediately_on_terminal_state, " + "current_go_live_stage, experimental_features_enabled, current_psp_test_account_stage, created_date) " + "VALUES (:id, :customBranding, :merchantName, :merchantTelephoneNumber, :merchantAddressLine1, :merchantAddressLine2, " + ":merchantAddressCity, :merchantAddressPostcode, :merchantAddressCountry, :merchantEmail, :merchantUrl, :externalId, :redirectToServiceImmediatelyOnTerminalState, " + ":currentGoLiveStage, :experimentalFeaturesEnabled, :pspTestAccountStage, :createdDate)").bind("id", serviceEntity.getId()).bindBySqlType("customBranding", customBranding, OTHER).bind("merchantName", merchantDetails.getName()).bind("merchantTelephoneNumber", merchantDetails.getTelephoneNumber()).bind("merchantAddressLine1", merchantDetails.getAddressLine1()).bind("merchantAddressLine2", merchantDetails.getAddressLine2()).bind("merchantAddressCity", merchantDetails.getAddressCity()).bind("merchantAddressPostcode", merchantDetails.getAddressPostcode()).bind("merchantAddressCountry", merchantDetails.getAddressCountryCode()).bind("merchantEmail", merchantDetails.getEmail()).bind("merchantUrl", merchantDetails.getUrl()).bind("externalId", serviceEntity.getExternalId()).bind("redirectToServiceImmediatelyOnTerminalState", serviceEntity.isRedirectToServiceImmediatelyOnTerminalState()).bind("currentGoLiveStage", serviceEntity.getCurrentGoLiveStage()).bind("experimentalFeaturesEnabled", serviceEntity.isExperimentalFeaturesEnabled()).bind("pspTestAccountStage", serviceEntity.getCurrentPspTestAccountStage()).bind("createdDate", serviceEntity.getCreatedDate()).execute();
    });
    serviceEntity.getGatewayAccountIds().forEach(gatewayAccount -> jdbi.withHandle(handle -> handle.createUpdate("INSERT INTO service_gateway_accounts(service_id, gateway_account_id) VALUES (:serviceId, :gatewayAccountId)").bind("serviceId", serviceEntity.getId()).bind("gatewayAccountId", gatewayAccount.getGatewayAccountId()).execute()));
    serviceEntity.getServiceNames().values().forEach((name) -> addServiceName(name, serviceEntity.getId()));
    return this;
}
Also used : Jdbi(org.jdbi.v3.core.Jdbi) MerchantDetailsEntity(uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity) User(uk.gov.pay.adminusers.model.User) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) Timestamp(java.sql.Timestamp) ZonedDateTime(java.time.ZonedDateTime) Permission(uk.gov.pay.adminusers.model.Permission) Role(uk.gov.pay.adminusers.model.Role) ZoneId(java.time.ZoneId) OTHER(java.sql.Types.OTHER) PGobject(org.postgresql.util.PGobject) List(java.util.List) ForgottenPassword(uk.gov.pay.adminusers.model.ForgottenPassword) ServiceNameEntity(uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity) Map(java.util.Map) Service(uk.gov.pay.adminusers.model.Service) SupportedLanguage(uk.gov.service.payments.commons.model.SupportedLanguage) CustomBrandingConverter(uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter) Timestamp.from(java.sql.Timestamp.from) MerchantDetails(uk.gov.pay.adminusers.model.MerchantDetails) MerchantDetailsEntity(uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity) CustomBrandingConverter(uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter) PGobject(org.postgresql.util.PGobject)

Aggregations

Timestamp (java.sql.Timestamp)1 Timestamp.from (java.sql.Timestamp.from)1 OTHER (java.sql.Types.OTHER)1 ZoneId (java.time.ZoneId)1 ZonedDateTime (java.time.ZonedDateTime)1 List (java.util.List)1 Map (java.util.Map)1 Jdbi (org.jdbi.v3.core.Jdbi)1 PGobject (org.postgresql.util.PGobject)1 ForgottenPassword (uk.gov.pay.adminusers.model.ForgottenPassword)1 MerchantDetails (uk.gov.pay.adminusers.model.MerchantDetails)1 Permission (uk.gov.pay.adminusers.model.Permission)1 Role (uk.gov.pay.adminusers.model.Role)1 Service (uk.gov.pay.adminusers.model.Service)1 User (uk.gov.pay.adminusers.model.User)1 CustomBrandingConverter (uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter)1 MerchantDetailsEntity (uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity)1 ServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntity)1 ServiceNameEntity (uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity)1 SupportedLanguage (uk.gov.service.payments.commons.model.SupportedLanguage)1