use of org.meveo.api.dto.payment.WFDecisionRuleDto in project meveo by meveo-org.
the class WFTransitionApi method create.
/**
* @param workflow
* @param wfTransitionDto
*
* @throws MissingParameterException
* @throws EntityDoesNotExistsException
* @throws EntityAlreadyExistsException
* @throws BusinessException
*/
public void create(Workflow workflow, WFTransitionDto wfTransitionDto) throws MissingParameterException, EntityDoesNotExistsException, EntityAlreadyExistsException, BusinessException {
validateDto(wfTransitionDto, false);
Set<WFDecisionRule> wfDecisionRuleList = new HashSet<>();
if (CollectionUtils.isNotEmpty(wfTransitionDto.getListWFDecisionRuleDto())) {
for (WFDecisionRuleDto wfDecisionRuleDto : wfTransitionDto.getListWFDecisionRuleDto()) {
WFDecisionRule wfDecisionRule = wfDecisionRuleService.getWFDecisionRuleByNameValue(wfDecisionRuleDto.getName(), wfDecisionRuleDto.getValue());
if (wfDecisionRule == null) {
wfDecisionRuleList.add(createNewWFDecisionRuleByName(wfDecisionRuleDto.getName(), wfDecisionRuleDto.getValue()));
} else {
wfDecisionRuleList.add(wfDecisionRule);
}
}
}
WFTransition wfTransition;
wfTransition = fromDTO(wfTransitionDto, null);
wfTransition.setWorkflow(workflow);
wfTransition.setWfDecisionRules(wfDecisionRuleList);
wfTransitionService.create(wfTransition);
if (CollectionUtils.isNotEmpty(wfTransitionDto.getListWFActionDto())) {
int priority = 1;
for (WFActionDto wfActionDto : wfTransitionDto.getListWFActionDto()) {
wfActionDto.setPriority(priority);
wfActionApi.create(wfTransition, wfActionDto);
priority++;
}
}
}
use of org.meveo.api.dto.payment.WFDecisionRuleDto in project meveo by meveo-org.
the class WFTransitionApi method update.
/**
* @param wfTransitionDto
*
* @throws MissingParameterException
* @throws EntityDoesNotExistsException
* @throws EntityAlreadyExistsException
* @throws BusinessException
* @throws BusinessApiException
*/
public void update(Workflow workflow, WFTransitionDto wfTransitionDto) throws MissingParameterException, EntityDoesNotExistsException, EntityAlreadyExistsException, BusinessException, BusinessApiException {
validateDto(wfTransitionDto, true);
WFTransition wfTransition = wfTransitionService.findWFTransitionByUUID(wfTransitionDto.getUuid());
if (wfTransition == null) {
throw new EntityDoesNotExistsException(WFTransition.class.getName() + "with uuid=" + wfTransitionDto.getUuid());
}
if (workflow.equals(wfTransition.getWorkflow())) {
throw new BusinessApiException("Workflow does not match");
}
Set<WFDecisionRule> wfDecisionRuleList = new HashSet<>();
if (CollectionUtils.isNotEmpty(wfTransitionDto.getListWFDecisionRuleDto())) {
for (WFDecisionRuleDto wfDecisionRuleDto : wfTransitionDto.getListWFDecisionRuleDto()) {
WFDecisionRule wfDecisionRule = wfDecisionRuleService.getWFDecisionRuleByNameValue(wfDecisionRuleDto.getName(), wfDecisionRuleDto.getValue());
if (wfDecisionRule == null) {
wfDecisionRuleList.add(createNewWFDecisionRuleByName(wfDecisionRuleDto.getName(), wfDecisionRuleDto.getValue()));
} else {
wfDecisionRuleList.add(wfDecisionRule);
}
}
}
wfTransition = fromDTO(wfTransitionDto, wfTransition);
List<WFAction> wfActionList = wfTransition.getWfActions();
wfTransition.setWorkflow(workflow);
wfTransition.setWfDecisionRules(wfDecisionRuleList);
wfTransitionService.update(wfTransition);
List<WFAction> updatedActions = new ArrayList<>();
if (CollectionUtils.isNotEmpty(wfTransitionDto.getListWFActionDto())) {
for (WFActionDto wfActionDto : wfTransitionDto.getListWFActionDto()) {
if (wfActionDto.getUuid() != null) {
WFAction wfAction = wfActionService.findWFActionByUUID(wfActionDto.getUuid());
updatedActions.add(wfAction);
}
}
}
if (CollectionUtils.isNotEmpty(wfActionList)) {
wfActionList.removeAll(updatedActions);
if (CollectionUtils.isNotEmpty(wfActionList)) {
for (WFAction wfAction : wfActionList) {
wfActionService.remove(wfAction);
}
}
}
if (wfTransitionDto.getListWFActionDto() != null && !wfTransitionDto.getListWFActionDto().isEmpty()) {
int priority = 1;
for (WFActionDto wfActionDto : wfTransitionDto.getListWFActionDto()) {
wfActionDto.setPriority(priority);
wfActionApi.createOrUpdate(wfTransition, wfActionDto);
priority++;
}
}
}
use of org.meveo.api.dto.payment.WFDecisionRuleDto in project meveo by meveo-org.
the class WFTransitionApi method validateDto.
/**
* @param wfTransitionDto
* @throws MissingParameterException
*/
public void validateDto(WFTransitionDto wfTransitionDto, boolean isUpdate) throws MissingParameterException {
if (wfTransitionDto == null) {
missingParameters.add("WFTransitionDto");
handleMissingParameters();
}
if (isUpdate && StringUtils.isBlank(wfTransitionDto.getUuid())) {
missingParameters.add("uuid");
}
if (StringUtils.isBlank(wfTransitionDto.getFromStatus())) {
missingParameters.add("FromStatus");
}
if (StringUtils.isBlank(wfTransitionDto.getToStatus())) {
missingParameters.add("ToStatus");
}
if (StringUtils.isBlank(wfTransitionDto.getDescription())) {
missingParameters.add("Description");
}
if (CollectionUtils.isNotEmpty(wfTransitionDto.getListWFDecisionRuleDto())) {
for (WFDecisionRuleDto wfDecisionRuleDto : wfTransitionDto.getListWFDecisionRuleDto()) {
if (StringUtils.isBlank(wfDecisionRuleDto.getName())) {
missingParameters.add("DecisionRuleName");
}
if (StringUtils.isBlank(wfDecisionRuleDto.getValue())) {
missingParameters.add("DecisionRuleValue");
}
}
}
handleMissingParameters();
}
Aggregations