Search in sources :

Example 1 with ProductFamilyElementType

use of com.qcadoo.mes.basic.constants.ProductFamilyElementType in project mes by qcadoo.

the class ProductHooksD method onSave.

public void onSave(final DataDefinition dataDefinition, final Entity product) {
    if (Objects.nonNull(product.getId())) {
        Entity productFromDB = dataDefinition.get(product.getId());
        ProductFamilyElementType oldProductType = ProductFamilyElementType.from(productFromDB);
        ProductFamilyElementType newProductType = ProductFamilyElementType.from(product);
        if (oldProductType.compareTo(newProductType) != 0) {
            if (ProductFamilyElementType.PARTICULAR_PRODUCT.compareTo(newProductType) == 0) {
                moveCompanyProductFamiliesToCompanyProducts(product);
            } else if (ProductFamilyElementType.PRODUCTS_FAMILY.compareTo(newProductType) == 0) {
                moveCompanyProductsToCompanyProductFamilies(product);
            }
        }
    }
    updateDefaultSupplier(dataDefinition, product);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProductFamilyElementType(com.qcadoo.mes.basic.constants.ProductFamilyElementType)

Aggregations

ProductFamilyElementType (com.qcadoo.mes.basic.constants.ProductFamilyElementType)1 Entity (com.qcadoo.model.api.Entity)1