account.getId(), ACCOUNT_LINK.REMOVED, null); for (AccountLink accountLink : accountLinks) { Long accountId = accountLink.getAccountId(); accounts.put(accountId, allAccountsMap.get(accountId));
private void registerAsTargetService(Service targetService) { List<Long> accountIds = new ArrayList<>(); accountIds.add(targetService.getAccountId()); List<? extends AccountLink> linkedToAccounts = objectManager.find(AccountLink.class, ACCOUNT_LINK.LINKED_ACCOUNT_ID, targetService.getAccountId(), ACCOUNT_LINK.REMOVED, null); // add all accounts that are linked to service's account for (AccountLink linkedToAccount : linkedToAccounts) { accountIds.add(linkedToAccount.getAccountId()); } List<Service> services = new ArrayList<>(); for (Long accountId : accountIds) { services.addAll(objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId, SERVICE.REMOVED, null)); } for (Service service : services) { // skip itself if (targetService.getId().equals(service.getId())) { continue; } if (isSelectorLinkMatch(service.getSelectorLink(), targetService)) { addServiceLink(service, targetService); } } }
@SuppressWarnings("unchecked") private void updateServices(AccountLink accountLink) { List<? extends ServiceConsumeMap> consumeMaps = objectManager.find(ServiceConsumeMap.class, SERVICE_CONSUME_MAP.ACCOUNT_ID, accountLink.getAccountId(), SERVICE_CONSUME_MAP.REMOVED, null); List<? extends Service> services = objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountLink.getLinkedAccountId(), SERVICE.REMOVED, null); List<Long> serviceIds = (List<Long>) CollectionUtils.collect(services, TransformerUtils.invokerTransformer("getId")); for (ServiceConsumeMap consumeMap : consumeMaps) { if (serviceIds.contains(consumeMap.getConsumedServiceId())) { objectProcessManager.scheduleStandardProcessAsync(StandardProcess.REMOVE, consumeMap, null); } } }
link.getLinkedAccount(), localRegion.getName())); Account localAccount = objectManager.loadResource(Account.class, link.getAccountId()); ExternalAccountLink externalLink = RegionUtil.getExternalAccountLink(targetRegion, targetResourceAccount, localAccount, jsonMapper);
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { AccountLink accountLink = (AccountLink) state.getResource(); if (accountLink.getLinkedAccountId() == null) { regionSvc.deleteExternalAccountLink(accountLink); } else { updateServices(accountLink); Account account = objectManager.loadResource(Account.class, accountLink.getAccountId()); if (account == null) { return null; } regenerateAccountLinks(account); } return null; }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { AccountLink accountLink = (AccountLink) state.getResource(); if (accountLink.getLinkedAccountId() == null) { regionSvc.createExternalAccountLink(accountLink); } else { List<? extends Service> services = objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountLink.getAccountId(), SERVICE.SELECTOR_LINK, new Condition(ConditionType.NOTNULL), SERVICE.REMOVED, null); for (Service service : services) { sdSvc.registerServiceLinks(service); } } return null; }
Account localAccount = objectManager.loadResource(Account.class, link.getAccountId()); ExternalAccountLink accLink = RegionUtil.getAccountLinkForExternal(targetRegion, externalProject, localAccount, jsonMapper); if(accLink == null || removedStates.contains(accLink.getState())){
Account localAccount = objectManager.loadResource(Account.class, link.getAccountId()); ExternalAccountLink externalLink = RegionUtil.getExternalAccountLink(targetRegion, targetResourceAccount, localAccount, jsonMapper);
/** * {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.AccountLink from) { setId(from.getId()); setName(from.getName()); setAccountId(from.getAccountId()); setKind(from.getKind()); setUuid(from.getUuid()); setDescription(from.getDescription()); setState(from.getState()); setCreated(from.getCreated()); setRemoved(from.getRemoved()); setRemoveTime(from.getRemoveTime()); setData(from.getData()); setLinkedAccountId(from.getLinkedAccountId()); setLinkedAccount(from.getLinkedAccount()); setLinkedRegionId(from.getLinkedRegionId()); setLinkedRegion(from.getLinkedRegion()); setExternal(from.getExternal()); }