public int getVersion() { return integration.getVersion(); }
public boolean isDraft() { return deployment.map(x -> x.getVersion() != integration.getVersion()).orElse(true); }
public int getIntegrationVersion() { return deployment.getSpec().getVersion(); }
@GET @Produces(MediaType.APPLICATION_JSON) @Path(value = "/{id}/overview") public IntegrationOverview getOverview(@PathParam("id") final String id) { Integration integration = Getter.super.get(id); List<IntegrationDeployment> deployments = getDataManager().fetchAll(IntegrationDeployment.class, new IdPrefixFilter<>(id+":"), ReverseFilter.getInstance()) .getItems(); Optional<IntegrationBulletinBoard> bulletins = Optional .ofNullable(getDataManager().fetch(IntegrationBulletinBoard.class, id)); return new IntegrationOverview(integration, bulletins, deployments.stream().filter(d -> d.getVersion() == integration.getVersion()).findFirst()) { @Override public List<DeploymentOverview> getDeployments() { return deployments.stream() .map(x->new DeploymentOverview(x)) .collect(Collectors.toList()); } }; }
@Override public void update(String id, @ConvertGroup(from = Default.class, to = AllValidations.class) Integration integration) { Integration existing = Getter.super.get(id); Integration updatedIntegration = new Integration.Builder() .createFrom(encryptionSupport.encrypt(integration)) .version(existing.getVersion()+1) .updatedAt(System.currentTimeMillis()) .build(); getDataManager().update(updatedIntegration); updateBulletinBoard(id); }
private void importIntegrations(SecurityContext sec, JsonDbDao<Integration> export, ArrayList<ChangeEvent> result) { for (Integration integration : export.fetchAll().getItems()) { Integration.Builder builder = new Integration.Builder() .createFrom(integration) .isDeleted(false) .updatedAt(System.currentTimeMillis()); // Do we need to create it? String id = integration.getId().get(); Integration previous = dataManager.fetch(Integration.class, id); if (previous == null) { LOG.info("Creating integration: {}", integration.getName()); integrationHandler.create(sec, builder.build()); result.add(ChangeEvent.of("created", integration.getKind().getModelName(), id)); } else { LOG.info("Updating integration: {}", integration.getName()); integrationHandler.update(id, builder.version(previous.getVersion()+1).build()); result.add(ChangeEvent.of("updated", integration.getKind().getModelName(), id)); } integrationHandler.updateBulletinBoard(id); break; } }