@Test public void testCreateServiceRouteRules() { OperationContext operator = newOperationContext(); String serviceId = new BigInteger(130, random).toString(32); List<RouteRuleInfo> routeRuleInfos = newRouteRuleInfos(serviceId); businessDao.createServiceRouteRules(operator, serviceId, routeRuleInfos); assertServiceRouteRule(serviceId, routeRuleInfos, null, null); businessDao.createServiceRouteRules(operator, serviceId, routeRuleInfos); assertServiceRouteRule(serviceId, routeRuleInfos, null, null); List<RouteRuleInfo> activeRouteRuleInfos = newRouteRuleInfos(serviceId); businessDao.createServiceRouteRules(operator, serviceId, activeRouteRuleInfos); assertServiceRouteRule(serviceId, routeRuleInfos, null, null); businessDao.activateServiceRouteRules(operator, serviceId, activeRouteRuleInfos); assertServiceRouteRule(serviceId, activeRouteRuleInfos, GroupRepository.RouteRuleStatus.ACTIVE, GroupRepository.GroupStatus.ACTIVE); assertServiceRouteRule(serviceId, routeRuleInfos, GroupRepository.RouteRuleStatus.INACTIVE, GroupRepository.GroupStatus.INACTIVE); businessDao.activateServiceRouteRules(operator, serviceId, activeRouteRuleInfos); assertServiceRouteRule(serviceId, activeRouteRuleInfos, GroupRepository.RouteRuleStatus.ACTIVE, GroupRepository.GroupStatus.ACTIVE); assertServiceRouteRule(serviceId, routeRuleInfos, GroupRepository.RouteRuleStatus.INACTIVE, GroupRepository.GroupStatus.INACTIVE); }
@Transactional public void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos) { checkServiceRouteRules(serviceId, routeRuleInfos); List<RouteRuleModel> routeRuleModels = Lists.newArrayList(); Map<String, GroupModel> groupModels = Maps.newHashMap(); ListMultimap<String, GroupWeight> routeRuleGroups = ArrayListMultimap.create(); for (RouteRuleInfo info : routeRuleInfos) { routeRuleModels.add(ServiceRouteRules.newRouteRuleModel(info.getRouteRule())); for (GroupWeight group : info.getGroups()) { String groupKey = group.getGroupKey(); groupModels.put(groupKey, Groups.newGroupModel(group)); routeRuleGroups.put(info.getRouteRule().getName().toLowerCase(), group); } } insertRouteRules(operationContext, routeRuleModels); insertGroups(operationContext, Lists.newArrayList(groupModels.values())); insertOrUpdateRouteRuleGroups(operationContext, getRouteRuleGroups(serviceId, routeRuleGroups)); }
BusinessDao { @Transactional public void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos) { checkServiceRouteRules(serviceId, routeRuleInfos); List<RouteRuleModel> routeRuleModels = Lists.newArrayList(); Map<String, GroupModel> groupModels = Maps.newHashMap(); ListMultimap<String, GroupWeight> routeRuleGroups = ArrayListMultimap.create(); for (RouteRuleInfo info : routeRuleInfos) { routeRuleModels.add(ServiceRouteRules.newRouteRuleModel(info.getRouteRule())); for (GroupWeight group : info.getGroups()) { String groupKey = group.getGroupKey(); groupModels.put(groupKey, Groups.newGroupModel(group)); routeRuleGroups.put(info.getRouteRule().getName().toLowerCase(), group); } } insertRouteRules(operationContext, routeRuleModels); insertGroups(operationContext, Lists.newArrayList(groupModels.values())); insertOrUpdateRouteRuleGroups(operationContext, getRouteRuleGroups(serviceId, routeRuleGroups)); } }
BusinessDao { @Transactional public void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos) { checkServiceRouteRules(serviceId, routeRuleInfos); List<RouteRuleModel> routeRuleModels = Lists.newArrayList(); Map<String, GroupModel> groupModels = Maps.newHashMap(); ListMultimap<String, GroupWeight> routeRuleGroups = ArrayListMultimap.create(); for (RouteRuleInfo info : routeRuleInfos) { routeRuleModels.add(ServiceRouteRules.newRouteRuleModel(info.getRouteRule())); for (GroupWeight group : info.getGroups()) { String groupKey = group.getGroupKey(); groupModels.put(groupKey, Groups.newGroupModel(group)); routeRuleGroups.put(info.getRouteRule().getName().toLowerCase(), group); } } insertRouteRules(operationContext, routeRuleModels); insertGroups(operationContext, Lists.newArrayList(groupModels.values())); insertOrUpdateRouteRuleGroups(operationContext, getRouteRuleGroups(serviceId, routeRuleGroups)); }  }
BusinessDao { @Transactional public void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos) { checkServiceRouteRules(serviceId, routeRuleInfos); List<RouteRuleModel> routeRuleModels = Lists.newArrayList(); Map<String, GroupModel> groupModels = Maps.newHashMap(); ListMultimap<String, GroupWeight> routeRuleGroups = ArrayListMultimap.create(); for (RouteRuleInfo info : routeRuleInfos) { routeRuleModels.add(ServiceRouteRules.newRouteRuleModel(info.getRouteRule())); for (GroupWeight group : info.getGroups()) { String groupKey = group.getGroupKey(); groupModels.put(groupKey, Groups.newGroupModel(group)); routeRuleGroups.put(info.getRouteRule().getName().toLowerCase(), group); } } insertRouteRules(operationContext, routeRuleModels); insertGroups(operationContext, Lists.newArrayList(groupModels.values())); insertOrUpdateRouteRuleGroups(operationContext, getRouteRuleGroups(serviceId, routeRuleGroups)); }  @Transactional void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void activateServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete); RouteRuleModel generateRouteRule(RouteRuleModel routeRuleModel); GroupModel generateGroup(GroupModel groupModel); @Transactional void updateGroupInstance(OperationContext operationContext, Long groupId, Set<String> instanceIds); void deleteGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void insertOrUpdateGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void deleteGroups(OperationContext operationContext, List<Long> groupIds); void insertOrUpdateGroups(OperationContext operationContext, List<GroupModel> groups); void insertGroups(OperationContext operationContext, List<GroupModel> groups); void deleteRouteRules(OperationContext operationContext, List<Long> routeRuleIds); void insertOrUpdateRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void insertRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void deleteRouteRuleGroups(OperationContext operationContext, List<Long> ids); void insertOrUpdateRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void releaseRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void publishRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void deleteGroupInstances(OperationContext operationContext, List<Long> groupInstanceIds); void deleteGroupInstancesByFilter(OperationContext operationContext, List<GroupInstanceModel> groupInstances); void insertGroupInstances(OperationContext operationContext, List<GroupInstanceModel> groupInstanceModels); void deleteServiceInstances(OperationContext operationContext, List<Long> serviceInstanceIds); void deleteServiceInstancesByFilter(OperationContext operationContext, List<ServiceInstanceModel> serviceInstances); void insertServiceInstances(OperationContext operationContext, List<ServiceInstanceModel> serviceInstanceModels); }
BusinessDao { @Transactional public void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos) { checkServiceRouteRules(serviceId, routeRuleInfos); List<RouteRuleModel> routeRuleModels = Lists.newArrayList(); Map<String, GroupModel> groupModels = Maps.newHashMap(); ListMultimap<String, GroupWeight> routeRuleGroups = ArrayListMultimap.create(); for (RouteRuleInfo info : routeRuleInfos) { routeRuleModels.add(ServiceRouteRules.newRouteRuleModel(info.getRouteRule())); for (GroupWeight group : info.getGroups()) { String groupKey = group.getGroupKey(); groupModels.put(groupKey, Groups.newGroupModel(group)); routeRuleGroups.put(info.getRouteRule().getName().toLowerCase(), group); } } insertRouteRules(operationContext, routeRuleModels); insertGroups(operationContext, Lists.newArrayList(groupModels.values())); insertOrUpdateRouteRuleGroups(operationContext, getRouteRuleGroups(serviceId, routeRuleGroups)); }  @Transactional void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void activateServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete); RouteRuleModel generateRouteRule(RouteRuleModel routeRuleModel); GroupModel generateGroup(GroupModel groupModel); @Transactional void updateGroupInstance(OperationContext operationContext, Long groupId, Set<String> instanceIds); void deleteGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void insertOrUpdateGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void deleteGroups(OperationContext operationContext, List<Long> groupIds); void insertOrUpdateGroups(OperationContext operationContext, List<GroupModel> groups); void insertGroups(OperationContext operationContext, List<GroupModel> groups); void deleteRouteRules(OperationContext operationContext, List<Long> routeRuleIds); void insertOrUpdateRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void insertRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void deleteRouteRuleGroups(OperationContext operationContext, List<Long> ids); void insertOrUpdateRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void releaseRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void publishRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void deleteGroupInstances(OperationContext operationContext, List<Long> groupInstanceIds); void deleteGroupInstancesByFilter(OperationContext operationContext, List<GroupInstanceModel> groupInstances); void insertGroupInstances(OperationContext operationContext, List<GroupInstanceModel> groupInstanceModels); void deleteServiceInstances(OperationContext operationContext, List<Long> serviceInstanceIds); void deleteServiceInstancesByFilter(OperationContext operationContext, List<ServiceInstanceModel> serviceInstances); void insertServiceInstances(OperationContext operationContext, List<ServiceInstanceModel> serviceInstanceModels); static final BusinessDao INSTANCE; }