private void cleanupExternalLinks(Region region) { for (AccountLink link : objectManager.find(AccountLink.class, ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_REGION_ID, region.getId())) { if (!link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) { objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, link, null); } } } }
private void getLinkedEnvironments(long accountId, Map<String, Long> links, Map<Long, Region> regionsIds, Map<String, ExternalProject> externalProjects) { List<AccountLink> accountLinks = objectManager.find(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID, accountId, ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_REGION_ID, new Condition(ConditionType.NOTNULL)); for (AccountLink link : accountLinks) { if (link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) { continue; } if(link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVED)) { continue; } Region targetRegion = regionsIds.get(link.getLinkedRegionId()); if (targetRegion == null) { continue; } String UUID = getUUID(targetRegion.getName(), link.getLinkedAccount()); if (!externalProjects.containsKey(UUID)) { links.put(UUID, targetRegion.getId()); } } }
private void reconcileAccountLinks(long accountId, Map<String, Region> regionsMap, List<AccountLink> toRemove, List<AccountLink> toUpdate, Set<String> toCreate) { for (AccountLink item : toRemove) { if (!item.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) { objectProcessManager.scheduleStandardProcess(StandardProcess.REMOVE, item, null); if (item.getState().equalsIgnoreCase(CommonStatesConstants.REQUESTED)) { objectProcessManager.scheduleStandardProcessAsync(StandardProcess.CREATE, item, null);
protected void createNewAccountLinks(Account account, List<? extends Long> newAccountIds) { for (Long accountId : newAccountIds) { AccountLink link = objectManager.findAny(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID, account.getId(), ACCOUNT_LINK.LINKED_ACCOUNT_ID, accountId, ACCOUNT_LINK.REMOVED, null); if (link == null) { link = objectManager.create(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID, account.getId(), ACCOUNT_LINK.LINKED_ACCOUNT_ID, accountId); } if (link.getState().equalsIgnoreCase(CommonStatesConstants.REQUESTED)) { objectProcessManager.executeStandardProcess(StandardProcess.CREATE, link, null); } } }
new Condition(ConditionType.NOTNULL)); for(AccountLink link : accountLinks) { if (invalidStates.contains(link.getState())) { continue;
/** * {@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()); }