package de.avatic.lcc.service.transformer.material;


import de.avatic.lcc.dto.generic.PropertyDTO;
import de.avatic.lcc.model.db.properties.PackagingProperty;
import org.springframework.stereotype.Service;

/**
 * Service that transforms {@link PackagingProperty} objects into {@link PropertyDTO} objects.
 * This transformer handles the conversion of material packaging properties into a format
 * that can be used in other application layers.
 */
@Service
public class MaterialDetailPackagingPropertyTransformer {

    /**
     * Converts a {@link PackagingProperty} object to a {@link PropertyDTO}.
     * This method maps the values and metadata of packaging properties for external consumption.
     *
     * @param property the {@link PackagingProperty} to transform
     * @return the transformed {@link PropertyDTO} object with mapped values
     */
    public PropertyDTO toPropertyDTO(PackagingProperty property) {
        PropertyDTO dto = new PropertyDTO();

        dto.setCurrentValue(property.getValue());
        dto.setDataType(property.getType().getDataType().name());
        dto.setRequired(property.getType().getRequired());
        dto.setName(property.getType().getName());
        dto.setExternalMappingId(property.getType().getExternalMappingId());
        dto.setValidationRule(property.getType().getValidationRule());




        return dto;
    }

}
