Skip to content

Commit

Permalink
#96 coffee annotation changed
Browse files Browse the repository at this point in the history
  • Loading branch information
sisak committed Feb 2, 2024
1 parent b26d3a0 commit b07af06
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public SampleResponse sampleWriteRead(SampleRequest sampleRequest) throws BaseEx
throw new TechnicalException("Unexpected data integrity error, some mandatory field is empty or not equal!");
}

transactionHelper.executeWithTransaction(() -> {
sampleEntityService.updateAllStatusAndInputValue(SampleStatus.DONE, "done");
});

SampleResponse response = new SampleResponse();
response.setSample(sampleTypeConverter.convert(readed));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import jakarta.persistence.QueryHint;

import org.apache.deltaspike.data.api.EntityRepository;
import org.apache.deltaspike.data.api.Modifying;
import org.apache.deltaspike.data.api.Query;
import org.apache.deltaspike.data.api.QueryParam;
import org.apache.deltaspike.data.api.Repository;
import org.apache.deltaspike.data.api.criteria.CriteriaSupport;
import org.hibernate.jpa.HibernateHints;
Expand Down Expand Up @@ -74,4 +76,15 @@ public interface SampleEntityRepository extends EntityRepository<SampleEntity, S
// @Query(value = "SELECT s FROM SampleEntity s WHERE s.status = ?1")
List<SampleEntity> findAllByStatus(SampleStatus status);

/**
* update all sampleEntity by params
*
* @param status status
* @param inputValue input value
* @return status of update
*/
@Modifying
@Query("UPDATE SampleEntity s SET s.status = :status, s.inputValue = :inputValue")
int updateAllSampleStatusAndInputValue(@QueryParam("status") SampleStatus status, @QueryParam("inputValue") String inputValue);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hu.icellmobilsoft.coffee.dto.exception.BaseException;
import hu.icellmobilsoft.sampler.common.system.jpa.service.BaseService;
import hu.icellmobilsoft.sampler.model.sample.SampleEntity;
import hu.icellmobilsoft.sampler.model.sample.SampleEntity_;
import hu.icellmobilsoft.sampler.model.sample.enums.SampleStatus;
import hu.icellmobilsoft.sampler.sample.jpaservice.repository.SampleEntityRepository;

Expand Down Expand Up @@ -60,4 +61,24 @@ public class SampleEntityService extends BaseService<SampleEntity> {
public List<SampleEntity> findAllByStatus(SampleStatus status) throws BaseException {
return wrapListValidated(sampleEntityRepository::findAllByStatus, status, "findAllByStatus", "status");
}

/**
* Updates all SampleEntity entity with the given params
*
* @param sampleStatus new sampleStatus
* @param inputValue new inputValue
* @return status of update
* @throws BaseException on error
*/
public int updateAllStatusAndInputValue(SampleStatus sampleStatus, String inputValue) throws BaseException {

return wrapValidated(
sampleEntityRepository::updateAllSampleStatusAndInputValue,
sampleStatus,
inputValue,
"updateAllSampleStatusAndInputValue",
SampleEntity_.STATUS,
SampleEntity_.INPUT_VALUE
);
}
}

0 comments on commit b07af06

Please sign in to comment.