package com.lemans.ds.product import com.lemans.ds.qualitycontrol.QCLog import groovy.transform.ToString @ToString class Product extends QCLog { static final Integer VIRTUAL_CATALOG_ID = 0 private static final Map IMMUTABLE_PROPERTIES = [ catalogInstanceId: 'Catalog' ].asImmutable() Integer id Integer catalogInstanceId Integer categoryId Integer brandId String productName String internalNotes Boolean isDigiActive Integer primaryMediaId String description String caption Date effectiveDate Date mediaEffectiveDate static constraints = { categoryId nullable: true, validator: { value, product -> if (value == null && product.catalogInstanceId == VIRTUAL_CATALOG_ID) { return 'nullable' } } brandId nullable: true, validator: { value, product -> if (value == null && product.catalogInstanceId == VIRTUAL_CATALOG_ID) { return 'nullable' } } productName nullable: false, minSize: 3, maxSize: 150 description nullable: true, maxSize: 2000 caption nullable: true, maxSize: 150 effectiveDate nullable: true primaryMediaId nullable: true internalNotes nullable: true isDigiActive nullable: false mediaEffectiveDate nullable: true } static mapping = { table 'Product' id column: 'productId' catalogInstanceId updateable: false } @Override protected Map immutables() { Product.IMMUTABLE_PROPERTIES } }