Source:
<code>void createService(ExternalEvent event, Map<String, Object> serviceData) { Service svc = serviceDao.getServiceByExternalId(event.getAccountId(), event.getExternalId()); if (svc != null) { return; } Stack stack = getStack(event); if (stack == null) { log.info("Can't process service event. Could not get or create stack. Event: [{}]", event); return; } <START> List<Service> existingSvcs = objectManager.find(Service.class, <END> SERVICE.NAME, serviceData.get(FIELD_NAME), SERVICE.REMOVED, null, SERVICE.STACK_ID, stack.getId(), SERVICE.ACCOUNT_ID, event.getAccountId(), SERVICE.KIND, ServiceConstants.KIND_KUBERNETES_SERVICE); for(Service existingSvc : existingSvcs) { if(existingSvc!=null && !existingSvc.getExternalId().equals(event.getExternalId())) { log.info("Deleting existing kubernetes service with externalId and accountId {}", existingSvc.getName(), existingSvc.getExternalId(), existingSvc.getAccountId()); objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, existingSvc, null); } } Map<String, Object> service = new HashMap<String, Object>(); if (serviceData != null) { service.putAll(serviceData); } service.put(ObjectMetaDataManager.ACCOUNT_FIELD, event.getAccountId()); service.put(FIELD_STACK_ID, stack.getId()); try { String create = objectProcessManager.getStandardProcessName(StandardProcess.CREATE, Service.class); String activate = objectProcessManager.getStandardProcessName(StandardProcess.ACTIVATE, Service.class); ProcessUtils.chainInData(service, create, activate); resourceDao.createAndSchedule(Service.class, service); } catch (ProcessCancelException e) { log.info("Create and activate process cancelled for service with account id {}and external id {}", event.getAccountId(), event.getExternalId()); } }</code><technical_language>findAny</technical_language>

Target:
void createService(ExternalEvent event, Map<String, Object> serviceData) { Service svc = serviceDao.getServiceByExternalId(event.getAccountId(), event.getExternalId()); if (svc != null) { return; } Stack stack = getStack(event); if (stack == null) { log.info("Can't process service event. Could not get or create stack. Event: [{}]", event); return; } List<Service> existingSvcs = objectManager.find(Service.class, SERVICE.NAME, serviceData.get(FIELD_NAME), SERVICE.REMOVED, null, SERVICE.STACK_ID, stack.getId(), SERVICE.ACCOUNT_ID, event.getAccountId(), SERVICE.KIND, ServiceConstants.KIND_KUBERNETES_SERVICE); for(Service existingSvc : existingSvcs) { if(existingSvc.getState().equals(CommonStatesConstants.REMOVING)) { continue; } if(existingSvc != null && existingSvc.getExternalId() != null && !existingSvc.getExternalId().equals(event.getExternalId())) { log.info("Deleting existing kubernetes service with externalId {}", existingSvc.getName(), existingSvc.getExternalId()); objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, existingSvc, null); } } Map<String, Object> service = new HashMap<String, Object>(); if (serviceData != null) { service.putAll(serviceData); } service.put(ObjectMetaDataManager.ACCOUNT_FIELD, event.getAccountId()); service.put(FIELD_STACK_ID, stack.getId()); try { String create = objectProcessManager.getStandardProcessName(StandardProcess.CREATE, Service.class); String activate = objectProcessManager.getStandardProcessName(StandardProcess.ACTIVATE, Service.class); ProcessUtils.chainInData(service, create, activate); resourceDao.createAndSchedule(Service.class, service); } catch (ProcessCancelException e) { log.info("Create and activate process cancelled for service with account id {}and external id {}", event.getAccountId(), event.getExternalId()); } }