2018-03-13 14:09:39 +01:00
|
|
|
package com.sismics.docs.core.util.action;
|
|
|
|
|
2018-03-29 17:59:47 +02:00
|
|
|
import com.sismics.docs.core.dao.TagDao;
|
|
|
|
import com.sismics.docs.core.dao.criteria.TagCriteria;
|
|
|
|
import com.sismics.docs.core.dao.dto.TagDto;
|
2018-03-13 14:09:39 +01:00
|
|
|
|
2023-04-09 21:31:53 +02:00
|
|
|
import jakarta.json.JsonObject;
|
2018-03-13 14:09:39 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2018-03-29 17:59:47 +02:00
|
|
|
/**
|
|
|
|
* Abstract class for tag actions.
|
|
|
|
*
|
|
|
|
* @author bgamard
|
|
|
|
*/
|
2018-03-13 14:09:39 +01:00
|
|
|
public abstract class TagAction implements Action {
|
|
|
|
@Override
|
|
|
|
public void validate(JsonObject action) throws Exception {
|
|
|
|
TagDao tagDao = new TagDao();
|
|
|
|
String tagId = action.getString("tag");
|
|
|
|
if (tagId == null) {
|
|
|
|
throw new Exception("step.transitions.actions.tag is required");
|
|
|
|
}
|
|
|
|
List<TagDto> tagDtoList = tagDao.findByCriteria(new TagCriteria().setId(tagId), null);
|
|
|
|
if (tagDtoList.size() != 1) {
|
|
|
|
throw new Exception(tagId + " is not a valid tag");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|