All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.saphyra.randwo.label.service.update.UpdateLabelService Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.github.saphyra.randwo.label.service.update;

import java.util.UUID;

import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.github.saphyra.randwo.label.domain.Label;
import com.github.saphyra.randwo.label.repository.LabelDao;
import com.github.saphyra.randwo.label.service.LabelQueryService;
import com.github.saphyra.randwo.label.service.LabelValueValidator;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class UpdateLabelService {
    private final LabelDao labelDao;
    private final LabelQueryService labelQueryService;
    private final LabelValueValidator labelValueValidator;

    @Transactional
    public void update(UUID labelId, String newValue) {
        labelValueValidator.validate(newValue);

        Label label = labelQueryService.findByLabelIdValidated(labelId);
        label.setLabelValue(newValue);
        labelDao.save(label);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy