/** * Verifies that the group has the required success condition and action and * a falid target percentage. * * @param group * the input group * @return the verified group */ public static RolloutGroup verifyRolloutGroupHasConditions(final RolloutGroup group) { if (group.getTargetPercentage() < 1F || group.getTargetPercentage() > 100F) { throw new ValidationException("Target percentage has to be between 1 and 100"); } if (group.getSuccessCondition() == null) { throw new ValidationException("Rollout group is missing success condition"); } if (group.getSuccessAction() == null) { throw new ValidationException("Rollout group is missing success action"); } return group; }
jsonGroup.put("targetPercentage", group.getTargetPercentage()); if (group.getSuccessCondition() != null) { final JSONObject successCondition = new JSONObject(); jsonGroup.put("successCondition", successCondition); successCondition.put("condition", group.getSuccessCondition().toString()); successCondition.put("expression", group.getSuccessConditionExp());
group.setSuccessCondition(srcGroup.getSuccessCondition()); group.setSuccessConditionExp(srcGroup.getSuccessConditionExp());
group.setSuccessCondition(srcGroup.getSuccessCondition()); group.setSuccessConditionExp(srcGroup.getSuccessConditionExp());
private static ProxyRolloutGroup createProxy(final RolloutGroup rolloutGroup) { final ProxyRolloutGroup proxyRolloutGroup = new ProxyRolloutGroup(); proxyRolloutGroup.setName(rolloutGroup.getName()); proxyRolloutGroup.setDescription(rolloutGroup.getDescription()); proxyRolloutGroup.setCreatedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getCreatedAt())); proxyRolloutGroup.setModifiedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getLastModifiedAt())); proxyRolloutGroup.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rolloutGroup)); proxyRolloutGroup.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rolloutGroup)); proxyRolloutGroup.setId(rolloutGroup.getId()); proxyRolloutGroup.setStatus(rolloutGroup.getStatus()); proxyRolloutGroup.setErrorAction(rolloutGroup.getErrorAction()); proxyRolloutGroup.setErrorActionExp(rolloutGroup.getErrorActionExp()); proxyRolloutGroup.setErrorCondition(rolloutGroup.getErrorCondition()); proxyRolloutGroup.setErrorConditionExp(rolloutGroup.getErrorConditionExp()); proxyRolloutGroup.setSuccessCondition(rolloutGroup.getSuccessCondition()); proxyRolloutGroup.setSuccessConditionExp(rolloutGroup.getSuccessConditionExp()); proxyRolloutGroup.setFinishedPercentage(HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup, rolloutGroup.getTotalTargetCountStatus().getFinishedPercent())); proxyRolloutGroup.setRolloutRendererData(new RolloutRendererData(rolloutGroup.getName(), null)); proxyRolloutGroup.setTotalTargetsCount(String.valueOf(rolloutGroup.getTotalTargets())); proxyRolloutGroup.setTotalTargetCountStatus(rolloutGroup.getTotalTargetCountStatus()); return proxyRolloutGroup; }
private static ProxyRolloutGroup createProxy(final RolloutGroup rolloutGroup) { final ProxyRolloutGroup proxyRolloutGroup = new ProxyRolloutGroup(); proxyRolloutGroup.setName(rolloutGroup.getName()); proxyRolloutGroup.setDescription(rolloutGroup.getDescription()); proxyRolloutGroup.setCreatedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getCreatedAt())); proxyRolloutGroup.setModifiedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getLastModifiedAt())); proxyRolloutGroup.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rolloutGroup)); proxyRolloutGroup.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rolloutGroup)); proxyRolloutGroup.setId(rolloutGroup.getId()); proxyRolloutGroup.setStatus(rolloutGroup.getStatus()); proxyRolloutGroup.setErrorAction(rolloutGroup.getErrorAction()); proxyRolloutGroup.setErrorActionExp(rolloutGroup.getErrorActionExp()); proxyRolloutGroup.setErrorCondition(rolloutGroup.getErrorCondition()); proxyRolloutGroup.setErrorConditionExp(rolloutGroup.getErrorConditionExp()); proxyRolloutGroup.setSuccessCondition(rolloutGroup.getSuccessCondition()); proxyRolloutGroup.setSuccessConditionExp(rolloutGroup.getSuccessConditionExp()); proxyRolloutGroup.setFinishedPercentage(HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup, rolloutGroup.getTotalTargetCountStatus().getFinishedPercent())); proxyRolloutGroup.setRolloutRendererData(new RolloutRendererData(rolloutGroup.getName(), null)); proxyRolloutGroup.setTotalTargetsCount(String.valueOf(rolloutGroup.getTotalTargets())); proxyRolloutGroup.setTotalTargetCountStatus(rolloutGroup.getTotalTargetCountStatus()); return proxyRolloutGroup; }
body.setTotalTargets(rolloutGroup.getTotalTargets()); body.setSuccessCondition(new MgmtRolloutCondition(map(rolloutGroup.getSuccessCondition()), rolloutGroup.getSuccessConditionExp())); body.setSuccessAction(