Index: grails-app/domain/com/lemans/ds/catalog/CatalogInstance.groovy =================================================================== diff -u -rc3c96d3a8e487752b18608b2cfeb14a94081be61 -re73cbb9ae6fdf2bf0f8b9a944893e2c9e969aa8b --- grails-app/domain/com/lemans/ds/catalog/CatalogInstance.groovy (.../CatalogInstance.groovy) (revision c3c96d3a8e487752b18608b2cfeb14a94081be61) +++ grails-app/domain/com/lemans/ds/catalog/CatalogInstance.groovy (.../CatalogInstance.groovy) (revision e73cbb9ae6fdf2bf0f8b9a944893e2c9e969aa8b) @@ -11,8 +11,8 @@ // String mainframeCatalogCode String flipBookUrl Integer year - //Integer source = 2 - Integer sourceId = 2 + Integer source = 2 + //Integer sourceId = 2 // Integer primaryMediaId // Date finalRetrievalDate // Integer pageOffset Index: grails-app/services/com/lemans/ds/catalog/CatalogInstanceManagerService.groovy =================================================================== diff -u -rc3c96d3a8e487752b18608b2cfeb14a94081be61 -re73cbb9ae6fdf2bf0f8b9a944893e2c9e969aa8b --- grails-app/services/com/lemans/ds/catalog/CatalogInstanceManagerService.groovy (.../CatalogInstanceManagerService.groovy) (revision c3c96d3a8e487752b18608b2cfeb14a94081be61) +++ grails-app/services/com/lemans/ds/catalog/CatalogInstanceManagerService.groovy (.../CatalogInstanceManagerService.groovy) (revision e73cbb9ae6fdf2bf0f8b9a944893e2c9e969aa8b) @@ -28,24 +28,31 @@ CatalogInstance deleteCatalogInstance(Integer catalogInstanceId, String username) { CatalogInstance catalogInstance = CatalogInstance.findByIdAndDateDeletedIsNull(catalogInstanceId) if (catalogInstance) { + customValidateDelete(catalogInstance) softDelete(catalogInstance, username) } catalogInstance } private void customValidateCatalogInstance(CatalogInstance catalogInstance) { - if (catalogInstance.sourceId != 2) { - catalogInstance.errors.reject('catalogInstance.source', 'sourceId should be 2:DigitalServices') + if (catalogInstance.source != 2) { + catalogInstance.errors.reject('catalogInstance.source', 'source should be 2:DigitalServices') } if (CatalogInstance.findByInstanceNameAndDateDeletedIsNull(catalogInstance.instanceName)) { catalogInstance.errors.reject('catalogInstance.instanceName', 'instance name should be unique') } } private void customValidateUpdate(CatalogInstance catalogInstance) { - if (catalogInstance.sourceId != 2) { - catalogInstance.errors.reject('catalogInstance.source', 'sourceId should be 2:DigitalServices') + if (catalogInstance.source != 2) { + catalogInstance.errors.reject('catalogInstance.source', 'source should be 2:DigitalServices') } } + private void customValidateDelete(CatalogInstance catalogInstance) { + if (catalogInstance.source != 2) { + catalogInstance.errors.reject('catalogInstance.source', 'source that is not 2(DigitalServies) cannot be deleted') + } + } + } Index: src/integration-test/groovy/com/lemans/ds/catalogInstance/CatalogInstanceFuncSpec.groovy =================================================================== diff -u -rc3c96d3a8e487752b18608b2cfeb14a94081be61 -re73cbb9ae6fdf2bf0f8b9a944893e2c9e969aa8b --- src/integration-test/groovy/com/lemans/ds/catalogInstance/CatalogInstanceFuncSpec.groovy (.../CatalogInstanceFuncSpec.groovy) (revision c3c96d3a8e487752b18608b2cfeb14a94081be61) +++ src/integration-test/groovy/com/lemans/ds/catalogInstance/CatalogInstanceFuncSpec.groovy (.../CatalogInstanceFuncSpec.groovy) (revision e73cbb9ae6fdf2bf0f8b9a944893e2c9e969aa8b) @@ -40,9 +40,9 @@ payload.results } - def 'can not create a catalogInstance with invalid sourceId'() { + def 'can not create a catalogInstance with invalid source'() { given: - Map input = [marketingName: marketingName, sourceId: 1, catalogId: 1] + Map input = [marketingName: marketingName, source: 1, catalogId: 1] path() invalid() @@ -51,7 +51,7 @@ then: payload.messages[0].type == 'error' - payload.messages[0].text == 'sourceId should be 2:DigitalServices' + payload.messages[0].text == 'source should be 2:DigitalServices' } def 'can create a catalogInstance'() { @@ -67,7 +67,7 @@ then: payload payload.results.marketingName == marketingName - payload.results.sourceId == 2 + payload.results.source == 2 } def 'can not update catalogName'() { @@ -83,9 +83,9 @@ payload } - def 'can not update sourceId'() { + def 'can not update source'() { given: - Map input = [sourceId: 1] + Map input = [source: 1] path("$catalogInstanceId") invalid()