From a7d0306e75299387b693eb87901f27d4d9a424df Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 8 Apr 2016 05:37:21 +0200 Subject: [PATCH 01/44] Removed unnecessary transaction exceptions. Signed-off-by: Kai Zimmermann --- .../MultiTenantJpaTransactionManager.java | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java index 7b97f5037..1a519ea5b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit; import javax.persistence.EntityManager; import javax.transaction.Transaction; -import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.tenancy.TenantAware; @@ -38,38 +37,31 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { protected void doBegin(final Object transaction, final TransactionDefinition definition) { super.doBegin(transaction, definition); + // ignore transactions on tenant independent calls + if (isTenantManagement(definition) && isCurrentTenantKeyGenerator(definition)) { + return; + } + final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager .getResource(getEntityManagerFactory()); final EntityManager em = emHolder.getEntityManager(); - if (notTenantManagement(definition) && notCurrentTenantKeyGenerator(definition) - && notRolloutScheduler(definition) && notGetOrCreateTenantMetadata(definition)) { - - final String currentTenant = tenantAware.getCurrentTenant(); - if (currentTenant == null) { - throw new TenantNotExistException("Tenant Unknown. Canceling transaction."); - } - - em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); + final String currentTenant = tenantAware.getCurrentTenant(); + if (currentTenant == null) { + throw new TenantNotExistException("Tenant Unknown. Canceling transaction."); } + + em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); + } - private boolean notGetOrCreateTenantMetadata(final TransactionDefinition definition) { - return !definition.getName() - .startsWith(SystemManagement.class.getCanonicalName() + ".getOrCreateTenantMetadata"); - } - - private boolean notRolloutScheduler(final TransactionDefinition definition) { - return !definition.getName().startsWith(RolloutManagement.class.getCanonicalName() + ".rolloutScheduler"); - } - - private boolean notCurrentTenantKeyGenerator(final TransactionDefinition definition) { - return !definition.getName() + private boolean isCurrentTenantKeyGenerator(final TransactionDefinition definition) { + return definition.getName() .startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator"); } - private boolean notTenantManagement(final TransactionDefinition definition) { - return !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant") + private boolean isTenantManagement(final TransactionDefinition definition) { + return definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant") && !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants"); } } From e3de03206d540bea56b5bc1b70edc6d915798fc5 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 8 Apr 2016 05:59:34 +0200 Subject: [PATCH 02/44] Fixed condition --- .../main/java/org/eclipse/hawkbit/ui/HawkbitUI.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java index f4c26a960..4acd6e887 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java @@ -48,15 +48,13 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.ValoTheme; /** - * Vaadin management UI. - * - * - * + * hawkBit Management UI. * */ -@SuppressWarnings("serial") @Title("hawkBit Update Server") public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { + private static final long serialVersionUID = 1L; + private static final Logger LOG = LoggerFactory.getLogger(HawkbitUI.class); private static final String EMPTY_VIEW = ""; @@ -154,6 +152,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { } final Navigator navigator = new Navigator(this, content); navigator.addViewChangeListener(new ViewChangeListener() { + private static final long serialVersionUID = 1L; + @Override public boolean beforeViewChange(final ViewChangeEvent event) { return true; @@ -233,6 +233,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { } private class ManagementViewProvider implements ViewProvider { + private static final long serialVersionUID = 1L; @Override public String getViewName(final String viewAndParameters) { From 0c800d31490bf66810b382f7f6df22562f642261 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 8 Apr 2016 06:13:16 +0200 Subject: [PATCH 03/44] Fixed condition --- .../org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java index 1a519ea5b..ac6bc8806 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java @@ -38,7 +38,7 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { super.doBegin(transaction, definition); // ignore transactions on tenant independent calls - if (isTenantManagement(definition) && isCurrentTenantKeyGenerator(definition)) { + if (isTenantManagement(definition) || isCurrentTenantKeyGenerator(definition)) { return; } From cf8e4fd2fd55909a8fe66c43a2e59d422da1596e Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 8 Apr 2016 06:50:27 +0200 Subject: [PATCH 04/44] Revert "Fixed condition" This reverts commit e3de03206d540bea56b5bc1b70edc6d915798fc5. --- .../main/java/org/eclipse/hawkbit/ui/HawkbitUI.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java index 4acd6e887..f4c26a960 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java @@ -48,13 +48,15 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.ValoTheme; /** - * hawkBit Management UI. + * Vaadin management UI. + * + * + * * */ +@SuppressWarnings("serial") @Title("hawkBit Update Server") public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { - private static final long serialVersionUID = 1L; - private static final Logger LOG = LoggerFactory.getLogger(HawkbitUI.class); private static final String EMPTY_VIEW = ""; @@ -152,8 +154,6 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { } final Navigator navigator = new Navigator(this, content); navigator.addViewChangeListener(new ViewChangeListener() { - private static final long serialVersionUID = 1L; - @Override public boolean beforeViewChange(final ViewChangeEvent event) { return true; @@ -233,7 +233,6 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { } private class ManagementViewProvider implements ViewProvider { - private static final long serialVersionUID = 1L; @Override public String getViewName(final String viewAndParameters) { From ee0fc266780c0090244c7cfcf5e24c31d0b875fd Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 13 Apr 2016 14:10:28 +0200 Subject: [PATCH 05/44] TTL Signed-off-by: SirWayne --- .../simulator/amqp/AmqpProperties.java | 14 ++++ .../hawkbit/amqp/AmqpConfiguration.java | 30 ++++---- .../amqp/AmqpDeadletterProperties.java | 69 +++++++++++++++++++ 3 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java index f58355980..8fba3ac5b 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java @@ -39,6 +39,12 @@ public class AmqpProperties { */ private String deadLetterExchange = "simulator.deadletter"; + /** + * Message time to live (ttl) for the deadletter queue. Default ttl is 1 + * hour. + */ + private int deadLetterTtl = 60_000; + public String getReceiverConnectorQueueFromSp() { return receiverConnectorQueueFromSp; } @@ -70,4 +76,12 @@ public class AmqpProperties { public void setSenderForSpExchange(final String senderForSpExchange) { this.senderForSpExchange = senderForSpExchange; } + + public int getDeadLetterTtl() { + return deadLetterTtl; + } + + public void setDeadLetterTtl(final int deadLetterTtl) { + this.deadLetterTtl = deadLetterTtl; + } } diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java index acbcb453b..1e25e3717 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java @@ -8,9 +8,6 @@ */ package org.eclipse.hawkbit.amqp; -import java.util.HashMap; -import java.util.Map; - import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; @@ -31,15 +28,29 @@ import org.springframework.context.annotation.Bean; * {@code amqp} to use a AMQP for communication with SP enabled devices. * */ -@EnableConfigurationProperties(AmqpProperties.class) +@EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class }) public class AmqpConfiguration { @Autowired protected AmqpProperties amqpProperties; + @Autowired + protected AmqpDeadletterProperties amqpDeadletterProperties; + @Autowired private ConnectionFactory connectionFactory; + // /** + // * Method to set the Jackson2JsonMessageConverter. + // * + // * @return the Jackson2JsonMessageConverter + // */ + // @Bean + // public RabbitAdmin rabbitAdmin(final RabbitAdmin rabbitAdmin) { + // rabbitAdmin.setIgnoreDeclarationExceptions(true); + // return rabbitAdmin; + // } + /** * Method to set the Jackson2JsonMessageConverter. * @@ -59,7 +70,8 @@ public class AmqpConfiguration { */ @Bean public Queue receiverQueue() { - return new Queue(amqpProperties.getReceiverQueue(), true, false, false, getDeadLetterExchangeArgs()); + return new Queue(amqpProperties.getReceiverQueue(), true, false, false, + amqpDeadletterProperties.getDeadLetterExchangeArgs(amqpProperties.getDeadLetterExchange())); } /** @@ -79,7 +91,7 @@ public class AmqpConfiguration { */ @Bean public Queue deadLetterQueue() { - return new Queue(amqpProperties.getDeadLetterQueue()); + return amqpDeadletterProperties.createDeadletterQueue(amqpProperties.getDeadLetterQueue()); } /** @@ -149,10 +161,4 @@ public class AmqpConfiguration { return containerFactory; } - private Map getDeadLetterExchangeArgs() { - final Map args = new HashMap<>(); - args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange()); - return args; - } - } diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java new file mode 100644 index 000000000..8e988ff16 --- /dev/null +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.amqp; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.amqp.core.Queue; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Bean which holds the necessary properties for configuring the AMQP deadletter + * queue. + */ +@ConfigurationProperties("hawkbit.dmf.rabbitmq.deadLetter") +public class AmqpDeadletterProperties { + + /** + * Message time to live (ttl) for the deadletter queue. Default ttl is 3 + * weeks. + */ + private int ttl = 1_814_400_000; + + /** + * Return the deadletter arguments. + * + * @param exchange + * the deadletter exchange + * @return map which holds the properties + */ + public Map getDeadLetterExchangeArgs(final String exchange) { + final Map args = new HashMap<>(); + args.put("x-dead-letter-exchange", exchange); + return args; + } + + /** + * Create a deadletter queue with ttl for messages + * + * @param queueName + * the deadlette queue name + * @return the deadletter queue + */ + public Queue createDeadletterQueue(final String queueName) { + // getTTLArgs() + return new Queue(queueName, true, false, false, null); + } + + private Map getTTLArgs() { + final Map args = new HashMap<>(); + args.put("x-message-ttl", getTtl()); + return args; + } + + public int getTtl() { + return ttl; + } + + public void setTtl(final int ttl) { + this.ttl = ttl; + } + +} From 30ba98ff8e2d7fa7386460bfa2e25fa47dba2c52 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 13 Apr 2016 17:27:49 +0200 Subject: [PATCH 06/44] TTL Signed-off-by: SirWayne --- .../eclipse/hawkbit/amqp/AmqpConfiguration.java | 17 +++++++---------- .../hawkbit/amqp/AmqpDeadletterProperties.java | 3 +-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java index 1e25e3717..448206924 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java @@ -15,6 +15,7 @@ import org.springframework.amqp.core.FanoutExchange; import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; @@ -40,16 +41,12 @@ public class AmqpConfiguration { @Autowired private ConnectionFactory connectionFactory; - // /** - // * Method to set the Jackson2JsonMessageConverter. - // * - // * @return the Jackson2JsonMessageConverter - // */ - // @Bean - // public RabbitAdmin rabbitAdmin(final RabbitAdmin rabbitAdmin) { - // rabbitAdmin.setIgnoreDeclarationExceptions(true); - // return rabbitAdmin; - // } + @Bean + public RabbitAdmin rabbitAdmin() { + final RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory); + rabbitAdmin.setIgnoreDeclarationExceptions(true); + return rabbitAdmin; + } /** * Method to set the Jackson2JsonMessageConverter. diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java index 8e988ff16..e9ad60a1c 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java @@ -48,8 +48,7 @@ public class AmqpDeadletterProperties { * @return the deadletter queue */ public Queue createDeadletterQueue(final String queueName) { - // getTTLArgs() - return new Queue(queueName, true, false, false, null); + return new Queue(queueName, true, false, false, getTTLArgs()); } private Map getTTLArgs() { From 536098c4c786752256e29aaacece0f7d11aa5acb Mon Sep 17 00:00:00 2001 From: SirWayne Date: Fri, 15 Apr 2016 17:40:03 +0200 Subject: [PATCH 07/44] Load and format the user details by a user detail formatter Signed-off-by: SirWayne --- .../smtable/BaseSwModuleBeanQuery.java | 5 +- .../ui/common/UserDetailsFormatter.java | 170 ++++++++++++++++++ .../AbstractTableDetailsLayout.java | 40 ++--- .../ui/common/table/AbstractTable.java | 6 +- .../dstable/ManageDistBeanQuery.java | 5 +- .../smtable/SwModuleBeanQuery.java | 5 +- .../CustomTargetBeanQuery.java | 5 +- .../TargetFilterBeanQuery.java | 5 +- .../dstable/DistributionBeanQuery.java | 5 +- .../targettable/TargetBeanQuery.java | 5 +- .../management/targettable/TargetTable.java | 3 +- .../hawkbit/ui/menu/DashboardMenu.java | 65 ++----- .../rollout/DistributionBeanQuery.java | 12 +- .../ui/rollout/rollout/RolloutBeanQuery.java | 14 +- .../rolloutgroup/RolloutGroupBeanQuery.java | 5 +- .../RolloutGroupTargetsBeanQuery.java | 5 +- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 53 ------ .../hawkbit/ui/utils/SPDateTimeUtil.java | 23 ++- .../themes/hawkbit/customstyles/common.scss | 6 + 19 files changed, 272 insertions(+), 165 deletions(-) create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java index bb48c515a..29bea30eb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java @@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -101,8 +102,8 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery + */ + public static String loadAndFormatUsername(final String username) { + return loadAndFormatUsername(username, 50); + } + + /** + * Load user details by {@link BaseEntity#getCreatedBy()} and format the + * user name. Use {@link UserDetailsFormatter#loadAndFormatUsername(String)} + * + * @param baseEntity + * the entity + * @return the formatted 'created at user name' (max 100 characters) cannot + * be + */ + public static String loadAndFormatCreatedBy(final BaseEntity baseEntity) { + if (baseEntity == null || baseEntity.getCreatedBy() == null) { + return StringUtils.EMPTY; + } + + return loadAndFormatUsername(baseEntity.getCreatedBy()); + } + + /** + * Load user details by {@link BaseEntity#getLastModifiedBy()} and format + * the user name. Use + * {@link UserDetailsFormatter#loadAndFormatUsername(String)} + * + * @param baseEntity + * the entity + * @return the formatted 'last modefied by user name' (max 100 characters) + * cannot be + */ + public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) { + if (baseEntity == null || baseEntity.getLastModifiedBy() == null) { + return StringUtils.EMPTY; + } + + return loadAndFormatUsername(baseEntity.getLastModifiedBy()); + } + + /** + * Load user details by the current session information and format the user + * name to max 12 characters. @see + * {@link UserDetailsFormatter#loadAndFormatUsername(String, int)} + * + * @param baseEntity + * the entity + * @return the formatted user name (max 12 characters) cannot be + */ + public static String loadAndFormatCurrentUsername() { + return loadAndFormatUsername(getCurrentUser().getUsername(), 6); + } + + /** + * Load user details by the user name and format the user name. If the + * loaded {@link UserDetails} is not a instance of a {@link UserPrincipal}, + * then just the {@link UserDetails#getUsername()} will return. + * + * If first and last name available, they will combined. Otherwise the + * {@link UserPrincipal#getLoginname()} will formatted. The formatted name + * is reduced to 100 characters. + * + * @param username + * the user name + * @param expectedNameLength + * the name size of each name part + * @return the formatted user name (max 2 * expectedNameLength characters) + * cannot be + */ + public static String loadAndFormatUsername(final String username, final int expectedNameLength) { + final UserDetails userDetails = loadUserByUsername(username); + if (!(userDetails instanceof UserPrincipal)) { + return userDetails.getUsername(); + } + + final UserPrincipal userPrincipal = (UserPrincipal) userDetails; + + final String trimmedFirstname = trimAndFormatDetail(userPrincipal.getFirstname(), expectedNameLength); + final String trimmedLastname = trimAndFormatDetail(userPrincipal.getLastname(), expectedNameLength); + + if (StringUtils.isEmpty(trimmedFirstname) && StringUtils.isEmpty(trimmedLastname)) { + return StringUtils.substring(userPrincipal.getLoginname(), 0, 2 * expectedNameLength); + } + return trimmedFirstname + DETAIL_SEPERATOR + trimmedLastname; + } + + /** + * Format the current tenant. The information is loaded by the current + * session information. + * + * @return the formatted user name (max 8 characters) can be + */ + public static String formatCurrentTenant() { + final UserDetails userDetails = getCurrentUser(); + if (!(userDetails instanceof UserPrincipal)) { + return null; + } + + final UserPrincipal userPrincipal = (UserPrincipal) userDetails; + return trimAndFormatDetail(userPrincipal.getTenant(), 8); + } + + private static UserDetails getCurrentUser() { + final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession() + .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); + return (UserDetails) context.getAuthentication().getPrincipal(); + } + + private static String trimAndFormatDetail(final String formatString, final int expectedDetailLength) { + final String detail = StringUtils.defaultIfEmpty(formatString, StringUtils.EMPTY); + final String trimmedDetail = StringUtils.substring(detail, 0, expectedDetailLength); + if (StringUtils.length(detail) > expectedDetailLength) { + return trimmedDetail + TRIM_APPENDIX; + } + return trimmedDetail; + } + + private static UserDetails loadUserByUsername(final String username) { + final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class); + try { + final UserDetails loadUserByUsername = userDetailsService.loadUserByUsername(username); + if (loadUserByUsername == null) { + throw new UsernameNotFoundException("User not found " + username); + } + return loadUserByUsername; + } catch (final UsernameNotFoundException e) { // NOSONAR + } + return new User(username, "", Collections.emptyList()); + } +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java index 969436904..b2df26179 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java @@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; @@ -213,22 +214,24 @@ public abstract class AbstractTableDetailsLayout extends populateDetailsWidget(); } - protected void updateLogLayout(final VerticalLayout changeLogLayout, final Long lastModifiedAt, - final String lastModifiedBy, final Long createdAt, final String createdBy, final I18N i18n) { - changeLogLayout.removeAllComponents(); - changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"), - createdAt == null ? "" : SPDateTimeUtil.getFormattedDate(createdAt))); + protected void populateLog() { + logLayout.removeAllComponents(); - changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.by"), - createdBy == null ? "" : HawkbitCommonUtil.getIMUser(createdBy))); + logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"), + SPDateTimeUtil.formatCreatedAt(selectedBaseEntity))); - if (null != lastModifiedAt) { - changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"), - SPDateTimeUtil.getFormattedDate(lastModifiedAt))); + logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.by"), + UserDetailsFormatter.loadAndFormatCreatedBy(selectedBaseEntity))); - changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.by"), - lastModifiedBy == null ? "" : HawkbitCommonUtil.getIMUser(lastModifiedBy))); + if (selectedBaseEntity == null || selectedBaseEntity.getLastModifiedAt() == null) { + return; } + + logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"), + SPDateTimeUtil.formatLastModifiedAt(selectedBaseEntity))); + + logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.by"), + UserDetailsFormatter.loadAndFormatLastModifiedBy(selectedBaseEntity))); } protected void updateDescriptionLayout(final String descriptionLabel, final String description) { @@ -320,19 +323,6 @@ public abstract class AbstractTableDetailsLayout extends return detailsLayout; } - public VerticalLayout getLogLayout() { - return logLayout; - } - - private void populateLog() { - if (selectedBaseEntity == null) { - updateLogLayout(getLogLayout(), null, StringUtils.EMPTY, null, null, i18n); - return; - } - updateLogLayout(getLogLayout(), selectedBaseEntity.getLastModifiedAt(), selectedBaseEntity.getLastModifiedBy(), - selectedBaseEntity.getCreatedAt(), selectedBaseEntity.getCreatedBy(), i18n); - } - private void populateDescription() { if (selectedBaseEntity != null) { updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index 0737f42c8..2d9067de8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -20,7 +20,7 @@ import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.common.ManagmentEntityState; -import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -212,9 +212,9 @@ public abstract class AbstractTable extends Table { item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(baseEntity.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(baseEntity.getDescription()); item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY) - .setValue(HawkbitCommonUtil.getIMUser(baseEntity.getCreatedBy())); + .setValue(UserDetailsFormatter.loadAndFormatCreatedBy(baseEntity)); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) - .setValue(HawkbitCommonUtil.getIMUser(baseEntity.getLastModifiedBy())); + .setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(baseEntity)); item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) .setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getCreatedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java index 60b547285..78410f29c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java @@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyDistribution; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; @@ -113,8 +114,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery { proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setDescription(distributionSet.getDescription()); - proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); - proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); + proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet)); + proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet)); proxyDistribution.setIsComplete(distributionSet.isComplete()); proxyDistributions.add(proxyDistribution); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java index 5419cc1bf..21ce01347 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java @@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.CustomSoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -99,8 +100,8 @@ public class SwModuleBeanQuery extends AbstractBeanQuery proxyItem.setVersion(bean.getVersion()); proxyItem.setVendor(bean.getVendor()); proxyItem.setDescription(bean.getDescription()); - proxyItem.setCreatedByUser(HawkbitCommonUtil.getIMUser(bean.getCreatedBy())); - proxyItem.setModifiedByUser(HawkbitCommonUtil.getIMUser(bean.getLastModifiedBy())); + proxyItem.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(bean)); + proxyItem.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(bean)); proxyItem.setAssigned(customSoftwareModule.isAssigned()); proxyItem.setColour(bean.getType().getColour()); proxyItem.setTypeId(bean.getType().getId()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java index bf5fdbe54..2cc572245 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java @@ -15,6 +15,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTarget; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -118,8 +119,8 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery { prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedAt(targ.getCreatedAt()); - prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); - prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); + prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); + prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); prxyTarget.setInstalledDistributionSet(installedDistributionSet); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java index 9c50640cd..4a2d6da6c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java @@ -14,6 +14,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTargetFilter; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; @@ -93,9 +94,9 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery proxyTarFilter.setName(tarFilterQuery.getName()); proxyTarFilter.setId(tarFilterQuery.getId()); proxyTarFilter.setCreatedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getCreatedAt())); - proxyTarFilter.setCreatedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getCreatedBy())); + proxyTarFilter.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(tarFilterQuery)); proxyTarFilter.setModifiedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getLastModifiedAt())); - proxyTarFilter.setLastModifiedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getLastModifiedBy())); + proxyTarFilter.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(tarFilterQuery)); proxyTarFilter.setQuery(tarFilterQuery.getQuery()); proxyTargetFilter.add(proxyTarFilter); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java index 7b49ddcb2..7909a3850 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java @@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilte import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyDistribution; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; @@ -129,8 +130,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setDescription(distributionSet.getDescription()); - proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); - proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); + proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet)); + proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet)); proxyDistribution.setNameVersion( HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); proxyDistributions.add(proxyDistribution); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index dac50ab0d..e96a9af8e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -19,6 +19,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTarget; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -130,8 +131,8 @@ public class TargetBeanQuery extends AbstractBeanQuery { prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedAt(targ.getCreatedAt()); - prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); - prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); + prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); + prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); if (pinnedDistId == null) { prxyTarget.setInstalledDistributionSet(null); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 3b9c18952..ea75b5d31 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -32,6 +32,7 @@ import org.eclipse.hawkbit.repository.model.TargetInfo; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.ui.common.ManagmentEntityState; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.common.table.AbstractTable; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.filter.FilterExpression; @@ -739,7 +740,7 @@ public class TargetTable extends AbstractTable implements .setValue(updatedTarget.getTargetInfo().getLastTargetQuery()); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) - .setValue(HawkbitCommonUtil.getIMUser(updatedTarget.getLastModifiedBy())); + .setValue(UserDetailsFormatter.loadAndFormatCreatedBy(updatedTarget)); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) .setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java index bbbba8cec..690cb51a2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java @@ -18,23 +18,20 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.HawkbitServerProperties; import org.eclipse.hawkbit.im.authentication.PermissionService; -import org.eclipse.hawkbit.im.authentication.UserPrincipal; import org.eclipse.hawkbit.ui.UiProperties; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.web.context.HttpSessionSecurityContextRepository; import com.vaadin.server.FontAwesome; import com.vaadin.server.Page; import com.vaadin.server.ThemeResource; -import com.vaadin.server.VaadinService; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.UIScope; @@ -189,63 +186,27 @@ public final class DashboardMenu extends CustomComponent { return links; } - private UserDetails getCurrentUser() { - final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession() - .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); - return (UserDetails) context.getAuthentication().getPrincipal(); - } - private Component buildUserMenu() { final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); - final UserDetails user = getCurrentUser(); + settings.setHtmlContentAllowed(true); final MenuItem settingsItem = settings.addItem("", new ThemeResource("images/profile-pic-57px.jpg"), null); - if (user instanceof UserPrincipal - && (((UserPrincipal) user).getFirstname() != null || ((UserPrincipal) user).getLastname() != null)) { - settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n" - + concateFNameLName(((UserPrincipal) user).getFirstname(), ((UserPrincipal) user).getLastname())); - settingsItem.setDescription( - ((UserPrincipal) user).getFirstname() + " / " + ((UserPrincipal) user).getLastname()); - } else if (user instanceof UserPrincipal) { - if (((UserPrincipal) user).getLoginname().length() > 10) { - settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n" - + ((UserPrincipal) user).getLoginname().substring(0, 10) + ".."); - } else { - settingsItem.setText( - trimTanent(((UserPrincipal) user).getTenant()) + "\n" + ((UserPrincipal) user).getLoginname()); - } - settingsItem.setDescription(((UserPrincipal) user).getLoginname()); - } else if (user != null) { - settingsItem.setText(user.getUsername()); - settingsItem.setDescription(user.getUsername()); + + final String formattedTenant = UserDetailsFormatter.formatCurrentTenant(); + final String formattedUsername = UserDetailsFormatter.loadAndFormatCurrentUsername(); + String tenantAndUsernameHtml = ""; + if (!StringUtils.isEmpty(formattedTenant)) { + tenantAndUsernameHtml += formattedTenant + "
"; } + tenantAndUsernameHtml += formattedUsername; + settingsItem.setText(tenantAndUsernameHtml); + settingsItem.setDescription(formattedUsername); + settingsItem.setStyleName("user-menuitem"); settingsItem.addItem("Sign Out", selectedItem -> Page.getCurrent().setLocation("/UI/logout")); return settings; } - private String concateFNameLName(final String fName, final String lName) { - final StringBuilder userName = new StringBuilder(); - if (fName != null && fName.length() > 6) { - userName.append(fName.substring(0, 6) + ".." + ", "); - } else { - userName.append(fName).append(", "); - } - if (lName != null && lName.length() > 6) { - userName.append(lName.substring(0, 6) + ".."); - } else { - userName.append(lName); - } - return userName.toString(); - } - - private String trimTanent(final String tanent) { - if (tanent != null && tanent.length() > 8) { - return tanent.substring(0, 8) + ".."; - } - return tanent; - } - private Component buildToggleButton() { final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> { if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java index 74daf89d8..75d2741af 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java @@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyDistribution; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; @@ -62,7 +63,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort for (int distId = 1; distId < sortPropertyIds.length; distId++) { - sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId])); + sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, + (String) sortPropertyIds[distId])); } } } @@ -103,8 +105,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery final List proxyDistributions = new ArrayList<>(); for (final DistributionSet distributionSet : distBeans) { final ProxyDistribution proxyDistribution = new ProxyDistribution(); - proxyDistribution.setName(HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), - distributionSet.getVersion())); + proxyDistribution.setName( + HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setDistId(distributionSet.getId()); proxyDistribution.setId(distributionSet.getId()); @@ -112,8 +114,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setDescription(distributionSet.getDescription()); - proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); - proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); + proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet)); + proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet)); proxyDistribution.setIsComplete(distributionSet.isComplete()); proxyDistributions.add(proxyDistribution); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java index 5ab6f6a97..624f18b2f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java @@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; @@ -119,14 +120,14 @@ public class RolloutBeanQuery extends AbstractBeanQuery { proxyRollout.setName(rollout.getName()); proxyRollout.setDescription(rollout.getDescription()); final DistributionSet distributionSet = rollout.getDistributionSet(); - proxyRollout.setDistributionSetNameVersion(HawkbitCommonUtil.getFormattedNameVersion( - distributionSet.getName(), distributionSet.getVersion())); + proxyRollout.setDistributionSetNameVersion( + HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); proxyRollout.setDistributionSet(distributionSet); proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size())); proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt())); proxyRollout.setModifiedDate(SPDateTimeUtil.getFormattedDate(rollout.getLastModifiedAt())); - proxyRollout.setCreatedBy(HawkbitCommonUtil.getIMUser(rollout.getCreatedBy())); - proxyRollout.setLastModifiedBy(HawkbitCommonUtil.getIMUser(rollout.getLastModifiedBy())); + proxyRollout.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rollout)); + proxyRollout.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rollout)); proxyRollout.setForcedTime(rollout.getForcedTime()); proxyRollout.setId(rollout.getId()); proxyRollout.setStatus(rollout.getStatus()); @@ -134,7 +135,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery { final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus(); proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus); proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets())); - + proxyRolloutList.add(proxyRollout); } return proxyRolloutList; @@ -148,7 +149,8 @@ public class RolloutBeanQuery extends AbstractBeanQuery { * .util.List, java.util.List, java.util.List) */ @Override - protected void saveBeans(final List arg0, final List arg1, final List arg2) { + protected void saveBeans(final List arg0, final List arg1, + final List arg2) { /** * CRUD operations on Target will be done through repository methods */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupBeanQuery.java index 0dabb18fc..8273ed436 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupBeanQuery.java @@ -15,6 +15,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; @@ -110,8 +111,8 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery proxyRolloutGroup.setDescription(rolloutGroup.getDescription()); proxyRolloutGroup.setCreatedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getCreatedAt())); proxyRolloutGroup.setModifiedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getLastModifiedAt())); - proxyRolloutGroup.setCreatedBy(HawkbitCommonUtil.getIMUser(rolloutGroup.getCreatedBy())); - proxyRolloutGroup.setLastModifiedBy(HawkbitCommonUtil.getIMUser(rolloutGroup.getLastModifiedBy())); + proxyRolloutGroup.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rolloutGroup)); + proxyRolloutGroup.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rolloutGroup)); proxyRolloutGroup.setId(rolloutGroup.getId()); proxyRolloutGroup.setStatus(rolloutGroup.getStatus()); proxyRolloutGroup.setErrorAction(rolloutGroup.getErrorAction()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsBeanQuery.java index 097e076be..685be685e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsBeanQuery.java @@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetWithActionStatus; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTarget; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -105,8 +106,8 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedAt(targ.getCreatedAt()); - prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); - prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); + prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); + prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); if (targetWithActionStatus.getStatus() != null) { prxyTarget.setStatus(targetWithActionStatus.getStatus()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 117b5bcb8..bfc996087 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -20,7 +20,6 @@ import java.util.Map.Entry; import java.util.TimeZone; import org.apache.commons.lang3.StringUtils; -import org.eclipse.hawkbit.im.authentication.UserPrincipal; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.NamedEntity; @@ -34,9 +33,6 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status; import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; @@ -605,31 +601,6 @@ public final class HawkbitCommonUtil { return requiredExtraWidth + minTableWidth; } - /** - * get formatted name - lastname,firstname. - * - * @param user - * user name - * @return String formatted name - */ - public static String getFormattedName(final UserDetails user) { - final StringBuilder formattedName = new StringBuilder(); - if (user instanceof UserPrincipal) { - if (trimAndNullIfEmpty(((UserPrincipal) user).getLastname()) != null) { - formattedName.append(((UserPrincipal) user).getLastname()); - } - if (trimAndNullIfEmpty(((UserPrincipal) user).getFirstname()) != null) { - if (formattedName.length() > 0) { - formattedName.append(", "); - } - formattedName.append(((UserPrincipal) user).getFirstname()); - } - } else if (user != null) { - formattedName.append(user.getUsername()); - } - return formattedName.toString(); - } - /** * get the Last sequence of string which is after last dot in String. * @@ -686,30 +657,6 @@ public final class HawkbitCommonUtil { return exeJS.toString(); } - /** - * Get IM User for user UUID. - * - * @param uuid - * @return imReslovedUser user details - */ - public static String getIMUser(final String uuid) { - // Get modifed user - String imReslovedUser = HawkbitCommonUtil.SP_STRING_SPACE; - if (HawkbitCommonUtil.trimAndNullIfEmpty(uuid) != null) { - final UserDetailsService idManagement = SpringContextHelper.getBean(UserDetailsService.class); - try { - imReslovedUser = HawkbitCommonUtil.getFormattedName(idManagement.loadUserByUsername(uuid)); - } catch (final UsernameNotFoundException e) { // NOSONAR - // nope not need to handle - } - // If Null display the UID - if (HawkbitCommonUtil.trimAndNullIfEmpty(imReslovedUser) == null) { - imReslovedUser = uuid; - } - } - return imReslovedUser; - } - /** * Get formatted label.Appends ellipses if content does not fit the label. * diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java index 532dd010d..4712f2f20 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java @@ -15,7 +15,9 @@ import java.util.HashMap; import java.util.Map; import java.util.TimeZone; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DurationFormatUtils; +import org.eclipse.hawkbit.repository.model.BaseEntity; import com.vaadin.server.WebBrowser; @@ -80,14 +82,31 @@ public final class SPDateTimeUtil { * @param lastQueryDate * @return String formatted date */ - public static String getFormattedDate(final Long lastQueryDate) { + return formatDate(lastQueryDate, null); + } + + public static String formatCreatedAt(final BaseEntity baseEntity) { + if (baseEntity == null) { + return StringUtils.EMPTY; + } + return formatDate(baseEntity.getCreatedAt(), StringUtils.EMPTY); + } + + public static String formatLastModifiedAt(final BaseEntity baseEntity) { + if (baseEntity == null) { + return StringUtils.EMPTY; + } + return formatDate(baseEntity.getLastModifiedAt(), StringUtils.EMPTY); + } + + private static String formatDate(final Long lastQueryDate, final String defaultString) { if (lastQueryDate != null) { final SimpleDateFormat format = new SimpleDateFormat(SPUIDefinitions.LAST_QUERY_DATE_FORMAT); format.setTimeZone(getBrowserTimeZone()); return format.format(new Date(lastQueryDate)); } - return null; + return defaultString; } /** diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss index 87ea5b0b9..beb405c30 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss @@ -143,9 +143,15 @@ .valo-menu-title { line-height: 1.2; } + .v-menubar-user-menu:after { display: none; } + + .v-menubar-menuitem-user-menuitem { + width: 100%; + } + .v-menubar-user-menu > .v-menubar-menuitem { white-space: normal !important; .v-icon { From 2462c7b6bfc706b499d28275f0600262edfa950b Mon Sep 17 00:00:00 2001 From: SirWayne Date: Fri, 15 Apr 2016 17:47:02 +0200 Subject: [PATCH 08/44] Add javadoc Signed-off-by: SirWayne --- .../hawkbit/ui/common/UserDetailsFormatter.java | 7 ++++++- .../ui/management/targettable/TargetTable.java | 2 +- .../eclipse/hawkbit/ui/utils/SPDateTimeUtil.java | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java index 92cfaab41..61261c1d1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java @@ -1,5 +1,10 @@ /** - * Copyright (c) 2011-2016 Bosch Software Innovations GmbH, Germany. All rights reserved. + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html */ package org.eclipse.hawkbit.ui.common; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index ea75b5d31..08503413f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -740,7 +740,7 @@ public class TargetTable extends AbstractTable implements .setValue(updatedTarget.getTargetInfo().getLastTargetQuery()); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) - .setValue(UserDetailsFormatter.loadAndFormatCreatedBy(updatedTarget)); + .setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(updatedTarget)); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) .setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java index 4712f2f20..d28ac5f05 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java @@ -86,6 +86,13 @@ public final class SPDateTimeUtil { return formatDate(lastQueryDate, null); } + /** + * Get formatted date 'created at' by entity. + * + * @param baseEntity + * the entity + * @return String formatted date + */ public static String formatCreatedAt(final BaseEntity baseEntity) { if (baseEntity == null) { return StringUtils.EMPTY; @@ -93,6 +100,13 @@ public final class SPDateTimeUtil { return formatDate(baseEntity.getCreatedAt(), StringUtils.EMPTY); } + /** + * Get formatted date 'last modefied at' by entity. + * + * @param baseEntity + * the entity + * @return String formatted date + */ public static String formatLastModifiedAt(final BaseEntity baseEntity) { if (baseEntity == null) { return StringUtils.EMPTY; From 5fd220a5e3c44346d0d1e75f97121a2432de8b4f Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Sat, 16 Apr 2016 10:42:26 +0200 Subject: [PATCH 09/44] change transaction handling of creating groups and check running Rollouts Signed-off-by: Michael Hirsch --- .../hawkbit/repository/RolloutManagement.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 1573048ec..6fb2ce0f9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -58,6 +58,8 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.TransactionTemplate; @@ -259,13 +261,7 @@ public class RolloutManagement { entityManager.flush(); executor.execute(() -> { try { - final DefaultTransactionDefinition def = new DefaultTransactionDefinition(); - def.setName("creatingRollout"); - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); - new TransactionTemplate(txManager, def).execute(status -> { - createRolloutGroups(amountGroup, conditions, savedRollout); - return null; - }); + createRolloutGroupsInNewTransaction(amountGroup, conditions, savedRollout); } finally { creatingRollouts.remove(savedRollout.getName()); } @@ -288,6 +284,15 @@ public class RolloutManagement { } } + private Rollout createRolloutGroupsInNewTransaction(final int amountGroup, final RolloutGroupConditions conditions, + final Rollout savedRollout) { + final DefaultTransactionDefinition def = new DefaultTransactionDefinition(); + def.setName("creatingRollout"); + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); + return new TransactionTemplate(txManager, def) + .execute(status -> createRolloutGroups(amountGroup, conditions, savedRollout)); + } + /** * Method for creating rollout groups and calculating group sizes. Group * sizes are calculated by dividing the total count of targets through the @@ -308,7 +313,8 @@ public class RolloutManagement { int groupIndex = 0; final Long totalCount = savedRollout.getTotalTargets(); final int groupSize = (int) Math.ceil((double) totalCount / (double) amountGroup); - // validate if the amount of groups that will be created are the amount + // validate if the amount of groups that will be created are the + // amount // of groups that the client what's to have created. int amountGroupValidated = amountGroup; final int amountGroupCreation = (int) (Math.ceil((double) totalCount / (double) groupSize)); @@ -540,7 +546,7 @@ public class RolloutManagement { * this check. This check is only applied if the last check is * less than (lastcheck-delay). */ - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_UNCOMMITTED) @Modifying @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_SYSTEM_CODE) From fd7fb7bd0146847445980c7e5e4ea555570feb4c Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 18 Apr 2016 07:41:33 +0200 Subject: [PATCH 10/44] make use of the existencechecking annotation for targetrolloutgroup Signed-off-by: Michael Hirsch --- .../eclipse/hawkbit/repository/model/RolloutTargetGroup.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java index f1d4fe718..28a07f061 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java @@ -24,6 +24,9 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; +import org.eclipse.persistence.annotations.ExistenceChecking; +import org.eclipse.persistence.annotations.ExistenceType; + /** * @author Michael Hirsch * @@ -31,6 +34,7 @@ import javax.persistence.Table; @IdClass(RolloutTargetGroupId.class) @Entity @Table(name = "sp_rollouttargetgroup") +@ExistenceChecking(ExistenceType.ASSUME_NON_EXISTENCE) public class RolloutTargetGroup implements Serializable { private static final long serialVersionUID = 1L; From 8eac737219a84c9e22fbcbe866cf62aad5060d7f Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 18 Apr 2016 07:47:23 +0200 Subject: [PATCH 11/44] update javadoc and remove author from it Signed-off-by: Michael Hirsch --- .../eclipse/hawkbit/repository/model/RolloutTargetGroup.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java index 28a07f061..7a46b15b1 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java @@ -28,8 +28,9 @@ import org.eclipse.persistence.annotations.ExistenceChecking; import org.eclipse.persistence.annotations.ExistenceType; /** - * @author Michael Hirsch - * + * Entity with JPA annotation to store the information which {@link Target} is + * in a specific {@link RolloutGroup}. + * */ @IdClass(RolloutTargetGroupId.class) @Entity From d49546e71f80842172cdf8fb1af188826f1bc36b Mon Sep 17 00:00:00 2001 From: SirWayne Date: Mon, 18 Apr 2016 16:17:28 +0200 Subject: [PATCH 12/44] Add tooltip for username Signed-off-by: SirWayne --- .../AbstractTableDetailsLayout.java | 11 ++--- .../ui/common/table/AbstractTable.java | 11 +++++ .../ui/components/SPUIComponentProvider.java | 47 +++++++++++++++++++ 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java index b2df26179..360a9f925 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java @@ -17,7 +17,6 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; @@ -172,9 +171,7 @@ public abstract class AbstractTableDetailsLayout extends } private Label createHeaderCaption() { - final Label captionLabel = SPUIComponentProvider.getLabel(getDefaultCaption(), - SPUILabelDefinitions.SP_WIDGET_CAPTION); - return captionLabel; + return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION); } protected VerticalLayout getTabLayout() { @@ -220,8 +217,7 @@ public abstract class AbstractTableDetailsLayout extends logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"), SPDateTimeUtil.formatCreatedAt(selectedBaseEntity))); - logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.by"), - UserDetailsFormatter.loadAndFormatCreatedBy(selectedBaseEntity))); + logLayout.addComponent(SPUIComponentProvider.createCreatedByLabel(i18n, selectedBaseEntity)); if (selectedBaseEntity == null || selectedBaseEntity.getLastModifiedAt() == null) { return; @@ -230,8 +226,7 @@ public abstract class AbstractTableDetailsLayout extends logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"), SPDateTimeUtil.formatLastModifiedAt(selectedBaseEntity))); - logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.by"), - UserDetailsFormatter.loadAndFormatLastModifiedBy(selectedBaseEntity))); + logLayout.addComponent(SPUIComponentProvider.createLastModifiedByLabel(i18n, selectedBaseEntity)); } protected void updateDescriptionLayout(final String descriptionLabel, final String description) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index 2d9067de8..1808cf070 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -329,6 +329,17 @@ public abstract class AbstractTable extends Table { columnList.add( new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F)); + setItemDescriptionGenerator((source, itemId, propertyId) -> { + + if (SPUILabelDefinitions.VAR_CREATED_BY.equals(propertyId)) { + return getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).getValue().toString(); + } + if (SPUILabelDefinitions.VAR_LAST_MODIFIED_BY.equals(propertyId)) { + return getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).getValue().toString(); + } + return null; + }); + return columnList; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java index f5008eb31..d8e5e31d1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java @@ -12,7 +12,9 @@ import java.util.Arrays; import java.util.Map; import org.apache.commons.lang3.StringUtils; +import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIHeaderLayoutDecorator; @@ -20,6 +22,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUILabelDecorator; import org.eclipse.hawkbit.ui.decorators.SPUITextAreaDecorator; import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator; +import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -328,6 +331,50 @@ public final class SPUIComponentProvider { return nameValueLabel; } + private static Label createUsernameLabel(final String label, final String username) { + String loadAndFormatUsername = StringUtils.EMPTY; + if (!StringUtils.isEmpty(username)) { + loadAndFormatUsername = UserDetailsFormatter.loadAndFormatUsername(username); + } + + final Label nameValueLabel = new Label(getBoldHTMLText(label) + loadAndFormatUsername, ContentMode.HTML); + nameValueLabel.setSizeFull(); + nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE); + nameValueLabel.addStyleName("label-style"); + nameValueLabel.setDescription(loadAndFormatUsername); + return nameValueLabel; + } + + /** + * Create label which represents the {@link BaseEntity#getCreatedBy()} by + * user name + * + * @param i18n + * the i18n + * @param baseEntity + * the entity + * @return the label + */ + public static Label createCreatedByLabel(final I18N i18n, final BaseEntity baseEntity) { + return createUsernameLabel(i18n.get("label.created.by"), + baseEntity == null ? StringUtils.EMPTY : baseEntity.getCreatedBy()); + } + + /** + * Create label which represents the + * {@link BaseEntity#getLastModifiedBy()()} by user name + * + * @param i18n + * the i18n + * @param baseEntity + * the entity + * @return the label + */ + public static Label createLastModifiedByLabel(final I18N i18n, final BaseEntity baseEntity) { + return createUsernameLabel(i18n.get("label.modified.by"), + baseEntity == null ? StringUtils.EMPTY : baseEntity.getLastModifiedBy()); + } + /** * Get Bold Text. * From 702decee621284b3a0504e85bbcee7b5cb0c557c Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 19 Apr 2016 10:42:29 +0200 Subject: [PATCH 13/44] Rename deadletter queue and add ttl Signed-off-by: SirWayne --- .../src/main/resources/hawkbitdefaults.properties | 2 +- .../java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java | 6 ++++++ .../main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties index 198fce255..488777b8d 100644 --- a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties +++ b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties @@ -42,6 +42,6 @@ hawkbit.controller.minPollingTime=00:00:30 # Configuration for RabbitMQ integration -hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter +hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver \ No newline at end of file diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java index 448206924..20a11713f 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java @@ -41,6 +41,12 @@ public class AmqpConfiguration { @Autowired private ConnectionFactory connectionFactory; + /** + * Create a {@link RabbitAdmin} and ignore declaration exceptions. + * {@link RabbitAdmin#setIgnoreDeclarationExceptions(boolean)} + * + * @return the bean + */ @Bean public RabbitAdmin rabbitAdmin() { final RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory); diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java index 38c6d34b3..ce6068ce8 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java @@ -21,7 +21,7 @@ public class AmqpProperties { /** * DMF API dead letter queue. */ - private String deadLetterQueue = "dmf_connector_deadletter"; + private String deadLetterQueue = "dmf_connector_deadletter_ttl"; /** * DMF API dead letter exchange. From 5437f36c7507048354df2021a2a72cc43e9bbca8 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 19 Apr 2016 10:42:56 +0200 Subject: [PATCH 14/44] Rename deadletter queue and add ttl Signed-off-by: SirWayne --- .../src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/hawkbit-example-app/src/main/resources/application.properties b/examples/hawkbit-example-app/src/main/resources/application.properties index 7864087c8..64661d2ec 100644 --- a/examples/hawkbit-example-app/src/main/resources/application.properties +++ b/examples/hawkbit-example-app/src/main/resources/application.properties @@ -21,7 +21,7 @@ spring.rabbitmq.password=guest spring.rabbitmq.virtualHost=/ spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 -hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter +hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver From 3c454bfb9be3eb9485d843c11a994db93cc64554 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 19 Apr 2016 11:27:33 +0200 Subject: [PATCH 15/44] Modfiy username formatting Signed-off-by: SirWayne --- .../ui/common/UserDetailsFormatter.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java index 61261c1d1..df741a6fd 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java @@ -28,7 +28,7 @@ import com.vaadin.server.VaadinService; */ public final class UserDetailsFormatter { - private static final String TRIM_APPENDIX = ".."; + private static final String TRIM_APPENDIX = "..."; private static final String DETAIL_SEPERATOR = ", "; private UserDetailsFormatter() { @@ -45,7 +45,7 @@ public final class UserDetailsFormatter { * @return the formatted user name (max 100 characters) cannot be */ public static String loadAndFormatUsername(final String username) { - return loadAndFormatUsername(username, 50); + return loadAndFormatUsername(username, 100); } /** @@ -93,7 +93,7 @@ public final class UserDetailsFormatter { * @return the formatted user name (max 12 characters) cannot be */ public static String loadAndFormatCurrentUsername() { - return loadAndFormatUsername(getCurrentUser().getUsername(), 6); + return loadAndFormatUsername(getCurrentUser().getUsername(), 12); } /** @@ -109,7 +109,7 @@ public final class UserDetailsFormatter { * the user name * @param expectedNameLength * the name size of each name part - * @return the formatted user name (max 2 * expectedNameLength characters) + * @return the formatted user name (max expectedNameLength characters) * cannot be */ public static String loadAndFormatUsername(final String username, final int expectedNameLength) { @@ -120,13 +120,21 @@ public final class UserDetailsFormatter { final UserPrincipal userPrincipal = (UserPrincipal) userDetails; - final String trimmedFirstname = trimAndFormatDetail(userPrincipal.getFirstname(), expectedNameLength); - final String trimmedLastname = trimAndFormatDetail(userPrincipal.getLastname(), expectedNameLength); + String firstname = StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), StringUtils.EMPTY); - if (StringUtils.isEmpty(trimmedFirstname) && StringUtils.isEmpty(trimmedLastname)) { - return StringUtils.substring(userPrincipal.getLoginname(), 0, 2 * expectedNameLength); + if (!StringUtils.isEmpty(firstname)) { + firstname += DETAIL_SEPERATOR; } - return trimmedFirstname + DETAIL_SEPERATOR + trimmedLastname; + + final String firstAndLastname = firstname + + StringUtils.defaultIfEmpty(userPrincipal.getLastname(), StringUtils.EMPTY); + + final String trimmedUsername = trimAndFormatDetail(firstAndLastname, expectedNameLength); + + if (StringUtils.isEmpty(trimmedUsername)) { + return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength); + } + return firstAndLastname; } /** @@ -168,8 +176,8 @@ public final class UserDetailsFormatter { throw new UsernameNotFoundException("User not found " + username); } return loadUserByUsername; - } catch (final UsernameNotFoundException e) { // NOSONAR + } catch (final UsernameNotFoundException e) { + return new User(username, "", Collections.emptyList()); } - return new User(username, "", Collections.emptyList()); } } From 681a23e51dec4ccc949dfa37fa4ceb10669269d8 Mon Sep 17 00:00:00 2001 From: Dennis Melzer Date: Wed, 20 Apr 2016 12:31:32 +0200 Subject: [PATCH 16/44] Update UserDetailsFormatter.java --- .../org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java index df741a6fd..04ad0c51a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java @@ -98,7 +98,7 @@ public final class UserDetailsFormatter { /** * Load user details by the user name and format the user name. If the - * loaded {@link UserDetails} is not a instance of a {@link UserPrincipal}, + * loaded {@link UserDetails} is not an instance of a {@link UserPrincipal}, * then just the {@link UserDetails#getUsername()} will return. * * If first and last name available, they will combined. Otherwise the From 5027b36c59dc01a85c431c232bb5661ae6227db2 Mon Sep 17 00:00:00 2001 From: Dennis Melzer Date: Wed, 20 Apr 2016 12:49:50 +0200 Subject: [PATCH 17/44] Update SPDateTimeUtil.java --- .../main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java index d28ac5f05..49bae86e1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java @@ -101,7 +101,7 @@ public final class SPDateTimeUtil { } /** - * Get formatted date 'last modefied at' by entity. + * Get formatted date 'last modified at' by entity. * * @param baseEntity * the entity From 1220b490f8bbd76fb7bcbbcfba7cc9dcb5b0645e Mon Sep 17 00:00:00 2001 From: Jonathan Philip Knoblauch Date: Wed, 20 Apr 2016 16:15:03 +0200 Subject: [PATCH 18/44] Small fix since checkbox was using wrong item for enabling Signed-off-by: Jonathan Philip Knoblauch --- .../ui/tenantconfiguration/AuthenticationConfigurationView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java index 616acaf3f..329318b0f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java @@ -113,7 +113,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView downloadAnonymousCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); downloadAnonymousCheckBox.setId("downloadanonymouscheckbox"); - downloadAnonymousCheckBox.setValue(targetSecurityTokenAuthenticationConfigurationItem.isConfigEnabled()); + downloadAnonymousCheckBox.setValue(anonymousDownloadAuthenticationConfigurationItem.isConfigEnabled()); downloadAnonymousCheckBox.addValueChangeListener(this); anonymousDownloadAuthenticationConfigurationItem.addChangeListener(this); gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3); From ffd3373b3480ed694b65700b9f53d283ecf0916d Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 21 Apr 2016 11:53:54 +0200 Subject: [PATCH 19/44] Signed-off-by: SirWayne --- 3rd-dependencies/listDeps.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 3rd-dependencies/listDeps.sh diff --git a/3rd-dependencies/listDeps.sh b/3rd-dependencies/listDeps.sh old mode 100755 new mode 100644 From f7b30a59ba1d3353f87fe47258d6000a0dce721b Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 21 Apr 2016 16:58:08 +0200 Subject: [PATCH 20/44] Signed-off-by: SirWayne --- 3rd-dependencies/listDeps.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 3rd-dependencies/listDeps.sh diff --git a/3rd-dependencies/listDeps.sh b/3rd-dependencies/listDeps.sh old mode 100755 new mode 100644 From 6e85c724bf79b7a7d54148f228419b192b2191d6 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 25 Apr 2016 14:09:38 +0200 Subject: [PATCH 21/44] Removed the method exception from transaction manager as they where not needed anymore. The bean in systemmanagement should also not open a transaction. Signed-off-by: Kai Zimmermann --- .../MultiTenantJpaTransactionManager.java | 16 ---------------- .../hawkbit/repository/SystemManagement.java | 3 +-- .../hawkbit/tenancy/MultiTenancyEntityTest.java | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java index ac6bc8806..a45c846a9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit; import javax.persistence.EntityManager; import javax.transaction.Transaction; -import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.persistence.config.PersistenceUnitProperties; @@ -37,11 +36,6 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { protected void doBegin(final Object transaction, final TransactionDefinition definition) { super.doBegin(transaction, definition); - // ignore transactions on tenant independent calls - if (isTenantManagement(definition) || isCurrentTenantKeyGenerator(definition)) { - return; - } - final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager .getResource(getEntityManagerFactory()); final EntityManager em = emHolder.getEntityManager(); @@ -54,14 +48,4 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); } - - private boolean isCurrentTenantKeyGenerator(final TransactionDefinition definition) { - return definition.getName() - .startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator"); - } - - private boolean isTenantManagement(final TransactionDefinition definition) { - return definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant") - && !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants"); - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java index 5577e1d61..c1cee7223 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -164,6 +164,7 @@ public class SystemManagement { * @return the {@link CurrentTenantKeyGenerator} */ @Bean + @Transactional(propagation = Propagation.NOT_SUPPORTED) public CurrentTenantKeyGenerator currentTenantKeyGenerator() { return new CurrentTenantKeyGenerator(); } @@ -206,7 +207,6 @@ public class SystemManagement { @NotNull @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_SYSTEM_CODE) - // tenant independent public List findTenants() { return tenantMetaDataRepository.findAll().stream().map(md -> md.getTenant()).collect(Collectors.toList()); } @@ -221,7 +221,6 @@ public class SystemManagement { @Transactional @Modifying @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) - // tenant independent public void deleteTenant(@NotNull final String tenant) { cacheManager.evictCaches(tenant); cacheManager.getCache("currentTenant").evict(currentTenantKeyGenerator().generate(null, null)); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java index 1dd4c9823..67b9b5a26 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java @@ -78,6 +78,22 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest { assertThat(findTargetsForTenant).hasSize(1); } + @Test + @Description(value = "Ensures that tenant with proper permissions can read and delete other tenants.") + @WithUser(tenantId = "mytenant", allSpPermissions = true) + public void deleteAnotherTenantPossible() throws Exception { + // create target for another tenant + final String anotherTenant = "anotherTenant"; + final String controllerAnotherTenant = "anotherController"; + createTargetForTenant(controllerAnotherTenant, anotherTenant); + + assertThat(systemManagement.findTenants()).as("Expected number if tenants before deletion is").hasSize(3); + + systemManagement.deleteTenant(anotherTenant); + + assertThat(systemManagement.findTenants()).as("Expected number if tenants after deletion is").hasSize(2); + } + @Test @Description(value = "Ensures that tenant metadata is retrieved for the current tenant.") @WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true) From 23d15bf646242e44b4f752bd49c95b4cc7e18fbb Mon Sep 17 00:00:00 2001 From: venu1278 Date: Tue, 26 Apr 2016 16:13:06 +0530 Subject: [PATCH 22/44] Displaying DistributionSet Details in Tooltip Signed-off-by: venu1278 --- .../ui/common/table/AbstractTable.java | 4 + .../hawkbit/ui/components/ProxyTarget.java | 478 +++---- .../CreateOrUpdateFilterTable.java | 402 +++--- .../targettable/TargetBeanQuery.java | 329 ++--- .../management/targettable/TargetTable.java | 65 + .../ui/rollout/rollout/ProxyRollout.java | 77 ++ .../ui/rollout/rollout/RolloutBeanQuery.java | 5 + .../ui/rollout/rollout/RolloutListGrid.java | 1173 +++++++++-------- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 8 + 9 files changed, 1426 insertions(+), 1115 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index 0737f42c8..8e68be0d5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -323,6 +323,10 @@ public abstract class AbstractTable extends Table { return columnList; } columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, + i18n.get("header.assigned.ds"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + i18n.get("header.installed.ds"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java index d85b2bc71..084890f87 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java @@ -10,9 +10,11 @@ package org.eclipse.hawkbit.ui.components; import java.net.URI; import java.security.SecureRandom; +import java.util.Set; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; @@ -26,275 +28,293 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; * */ public class ProxyTarget extends Target { - private static final long serialVersionUID = -8891449133620645310L; - private String controllerId; - private URI address = null; - private Long lastTargetQuery = null; - private Long installationDate; + private static final long serialVersionUID = -8891449133620645310L; + private String controllerId; + private URI address = null; + private Long lastTargetQuery = null; + private Long installationDate; - private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; + private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; - private DistributionSet installedDistributionSet; + private DistributionSet installedDistributionSet; - private TargetIdName targetIdName; + private DistributionSet assignedDistributionSet; - private String assignedDistNameVersion; + private TargetIdName targetIdName; - private String installedDistNameVersion; + private String assignedDistNameVersion; - private String pollStatusToolTip; + private String installedDistNameVersion; - private String createdByUser; + private String pollStatusToolTip; - private String createdDate; + private String createdByUser; - private String lastModifiedDate; + private String createdDate; - private String modifiedByUser; + private String lastModifiedDate; - private Status status; + private String modifiedByUser; - /** - * @param controllerId - */ - public ProxyTarget() { - super(null); - final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE; - targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString()); - } + private Status status; - /** - * @return the createdByUser - */ - public String getCreatedByUser() { - return createdByUser; - } + /** + * @param controllerId + */ + public ProxyTarget() { + super(null); + final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE; + targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString()); + } - /** - * @param createdByUser - * the createdByUser to set - */ - public void setCreatedByUser(final String createdByUser) { - this.createdByUser = createdByUser; - } + /** + * @return the createdByUser + */ + public String getCreatedByUser() { + return createdByUser; + } - /** - * @return the createdDate - */ - public String getCreatedDate() { - return createdDate; - } + /** + * @param createdByUser + * the createdByUser to set + */ + public void setCreatedByUser(final String createdByUser) { + this.createdByUser = createdByUser; + } - /** - * @param createdDate - * the createdDate to set - */ - public void setCreatedDate(final String createdDate) { - this.createdDate = createdDate; - } + /** + * @return the createdDate + */ + public String getCreatedDate() { + return createdDate; + } - /** - * @return the modifiedByUser - */ - public String getModifiedByUser() { - return modifiedByUser; - } + /** + * @param createdDate + * the createdDate to set + */ + public void setCreatedDate(final String createdDate) { + this.createdDate = createdDate; + } - /** - * @param modifiedByUser - * the modifiedByUser to set - */ - public void setModifiedByUser(final String modifiedByUser) { - this.modifiedByUser = modifiedByUser; - } + /** + * @return the modifiedByUser + */ + public String getModifiedByUser() { + return modifiedByUser; + } - /** - * @return the lastModifiedDate - */ - public String getLastModifiedDate() { - return lastModifiedDate; - } + /** + * @param modifiedByUser + * the modifiedByUser to set + */ + public void setModifiedByUser(final String modifiedByUser) { + this.modifiedByUser = modifiedByUser; + } - /** - * @param lastModifiedDate - * the lastModifiedDate to set - */ - public void setLastModifiedDate(final String lastModifiedDate) { - this.lastModifiedDate = lastModifiedDate; - } + /** + * @return the lastModifiedDate + */ + public String getLastModifiedDate() { + return lastModifiedDate; + } - /** - * @return the assignedDistNameVersion - */ - public String getAssignedDistNameVersion() { - return assignedDistNameVersion; - } + /** + * @param lastModifiedDate + * the lastModifiedDate to set + */ + public void setLastModifiedDate(final String lastModifiedDate) { + this.lastModifiedDate = lastModifiedDate; + } - /** - * @param assignedDistNameVersion - * the assignedDistNameVersion to set - */ - public void setAssignedDistNameVersion(final String assignedDistNameVersion) { - this.assignedDistNameVersion = assignedDistNameVersion; - } + /** + * @return the assignedDistNameVersion + */ + public String getAssignedDistNameVersion() { + return assignedDistNameVersion; + } - /** - * @return the installedDistNameVersion - */ - public String getInstalledDistNameVersion() { - return installedDistNameVersion; - } + /** + * @param assignedDistNameVersion + * the assignedDistNameVersion to set + */ + public void setAssignedDistNameVersion(final String assignedDistNameVersion) { + this.assignedDistNameVersion = assignedDistNameVersion; + } - /** - * @param installedDistNameVersion - * the installedDistNameVersion to set - */ - public void setInstalledDistNameVersion(final String installedDistNameVersion) { - this.installedDistNameVersion = installedDistNameVersion; - } + /** + * @return the installedDistNameVersion + */ + public String getInstalledDistNameVersion() { + return installedDistNameVersion; + } - /** - * GET - ID. - * - * @return String as ID. - */ - @Override - public String getControllerId() { - return controllerId; - } + /** + * @param installedDistNameVersion + * the installedDistNameVersion to set + */ + public void setInstalledDistNameVersion(final String installedDistNameVersion) { + this.installedDistNameVersion = installedDistNameVersion; + } - /** - * SET - ID. - * - * @param controllerId - * as ID - */ - @Override - public void setControllerId(final String controllerId) { - this.controllerId = controllerId; - } + /** + * GET - ID. + * + * @return String as ID. + */ + @Override + public String getControllerId() { + return controllerId; + } - /** - * @return the ipAddress - */ - public URI getAddress() { - return address; - } + /** + * SET - ID. + * + * @param controllerId + * as ID + */ + @Override + public void setControllerId(final String controllerId) { + this.controllerId = controllerId; + } - /** - * @param ipAddress - * the ipAddress to set - */ - public void setAddress(final URI address) { - this.address = address; - } + /** + * @return the ipAddress + */ + public URI getAddress() { + return address; + } - /** - * @return the lastTargetQuery - */ - public Long getLastTargetQuery() { - return lastTargetQuery; - } + /** + * @param ipAddress + * the ipAddress to set + */ + public void setAddress(final URI address) { + this.address = address; + } - /** - * @param lastTargetQuery - * the lastTargetQuery to set - */ - public void setLastTargetQuery(final Long lastTargetQuery) { - this.lastTargetQuery = lastTargetQuery; - } + /** + * @return the lastTargetQuery + */ + public Long getLastTargetQuery() { + return lastTargetQuery; + } - /** - * @return the installationDate - */ - public Long getInstallationDate() { - return installationDate; - } + /** + * @param lastTargetQuery + * the lastTargetQuery to set + */ + public void setLastTargetQuery(final Long lastTargetQuery) { + this.lastTargetQuery = lastTargetQuery; + } - /** - * @param installationDate - * the installationDate to set - */ - public void setInstallationDate(final Long installationDate) { - this.installationDate = installationDate; - } + /** + * @return the installationDate + */ + public Long getInstallationDate() { + return installationDate; + } - /** - * @return the updateStatus - */ - public TargetUpdateStatus getUpdateStatus() { - return updateStatus; - } + /** + * @param installationDate + * the installationDate to set + */ + public void setInstallationDate(final Long installationDate) { + this.installationDate = installationDate; + } - /** - * @param updateStatus - * the updateStatus to set - */ - public void setUpdateStatus(final TargetUpdateStatus updateStatus) { - this.updateStatus = updateStatus; - } + /** + * @return the updateStatus + */ + public TargetUpdateStatus getUpdateStatus() { + return updateStatus; + } - /** - * @return the installedDistributionSet - */ - public DistributionSet getInstalledDistributionSet() { - return installedDistributionSet; - } + /** + * @param updateStatus + * the updateStatus to set + */ + public void setUpdateStatus(final TargetUpdateStatus updateStatus) { + this.updateStatus = updateStatus; + } - /** - * @param installedDistributionSet - * the installedDistributionSet to set - */ - public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) { - this.installedDistributionSet = installedDistributionSet; - } + /** + * @return the installedDistributionSet + */ + public DistributionSet getInstalledDistributionSet() { + return installedDistributionSet; + } - /** - * @return the targetIdName - */ - @Override - public TargetIdName getTargetIdName() { - if (this.targetIdName == null) { - return super.getTargetIdName(); - } - return this.targetIdName; - } + /** + * @param installedDistributionSet + * the installedDistributionSet to set + */ + public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) { + this.installedDistributionSet = installedDistributionSet; + } - /** - * @param targetIdName - * the targetIdName to set - */ - public void setTargetIdName(final TargetIdName targetIdName) { - this.targetIdName = targetIdName; - } + /** + * @return the assignedDistributionSet + */ + public DistributionSet getAssignedDistributionSet() { + return assignedDistributionSet; + } - /** - * @return the pollStatusToolTip - */ - public String getPollStatusToolTip() { - return pollStatusToolTip; - } + /** + * @param assignedDistributionSet + * the assignedDistributionSet to set + */ + public void setAssignedDistributionSet(DistributionSet assignedDistributionSet) { + this.assignedDistributionSet = assignedDistributionSet; + } - /** - * @param pollStatusToolTip - * the pollStatusToolTip to set - */ - public void setPollStatusToolTip(final String pollStatusToolTip) { - this.pollStatusToolTip = pollStatusToolTip; - } + /** + * @return the targetIdName + */ + @Override + public TargetIdName getTargetIdName() { + if (this.targetIdName == null) { + return super.getTargetIdName(); + } + return this.targetIdName; + } - /** - * @return the status - */ - public Status getStatus() { - return status; - } + /** + * @param targetIdName + * the targetIdName to set + */ + public void setTargetIdName(final TargetIdName targetIdName) { + this.targetIdName = targetIdName; + } + + /** + * @return the pollStatusToolTip + */ + public String getPollStatusToolTip() { + return pollStatusToolTip; + } + + /** + * @param pollStatusToolTip + * the pollStatusToolTip to set + */ + public void setPollStatusToolTip(final String pollStatusToolTip) { + this.pollStatusToolTip = pollStatusToolTip; + } + + /** + * @return the status + */ + public Status getStatus() { + return status; + } + + /** + * @param status + * the status to set + */ + public void setStatus(final Status status) { + this.status = status; + } - /** - * @param status - * the status to set - */ - public void setStatus(final Status status) { - this.status = status; - } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index ebeb95957..d067b388b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -13,10 +13,13 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; @@ -54,194 +57,259 @@ import com.vaadin.ui.themes.ValoTheme; @ViewScope public class CreateOrUpdateFilterTable extends Table { - private static final long serialVersionUID = 6887304217281629713L; + private static final long serialVersionUID = 6887304217281629713L; - @Autowired - private I18N i18n; + @Autowired + private I18N i18n; - @Autowired - private transient EventBus.SessionEventBus eventBus; + @Autowired + private transient EventBus.SessionEventBus eventBus; - @Autowired - private FilterManagementUIState filterManagementUIState; + @Autowired + private FilterManagementUIState filterManagementUIState; - private LazyQueryContainer container; + private LazyQueryContainer container; - private static final int PROPERTY_DEPT = 3; + private static final int PROPERTY_DEPT = 3; - /** - * Initialize the Action History Table. - */ - @PostConstruct - public void init() { - setStyleName("sp-table"); - setSizeFull(); - setImmediate(true); - setHeight(100.0f, Unit.PERCENTAGE); - addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); - addStyleName(ValoTheme.TABLE_SMALL); - setColumnCollapsingAllowed(true); - addCustomGeneratedColumns(); - restoreOnLoad(); - populateTableData(); - setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); - setSelectable(false); - eventBus.subscribe(this); - } + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; - @PreDestroy - void destroy() { - eventBus.unsubscribe(this); - } + private static final String INSTALL_DIST_SET = "installedDistributionSet"; - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final CustomFilterUIEvent custFUIEvent) { - if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW - || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { - UI.getCurrent().access(() -> populateTableData()); - } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { - UI.getCurrent().access(() -> onQuery()); - } - } + /** + * Initialize the Action History Table. + */ + @PostConstruct + public void init() { + setStyleName("sp-table"); + setSizeFull(); + setImmediate(true); + setHeight(100.0f, Unit.PERCENTAGE); + addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); + addStyleName(ValoTheme.TABLE_SMALL); + setColumnCollapsingAllowed(true); + addCustomGeneratedColumns(); + restoreOnLoad(); + populateTableData(); + setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); + setSelectable(false); + eventBus.subscribe(this); + setItemDescriptionGenerator(new TooltipGenerator()); + } - private void restoreOnLoad() { - if (filterManagementUIState.isCreateFilterViewDisplayed()) { - filterManagementUIState.setFilterQueryValue(null); - } else { - filterManagementUIState.getTfQuery() - .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); - } - } + @PreDestroy + void destroy() { + eventBus.unsubscribe(this); + } - /** - * Create a empty HierarchicalContainer. - */ - private LazyQueryContainer createContainer() { - // ADD all the filters to the query config - final Map queryConfig = prepareQueryConfigFilters(); + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final CustomFilterUIEvent custFUIEvent) { + if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW + || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { + UI.getCurrent().access(() -> populateTableData()); + } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { + UI.getCurrent().access(() -> onQuery()); + } + } - // Create TargetBeanQuery factory with the query config. - final BeanQueryFactory targetQF = new BeanQueryFactory<>(CustomTargetBeanQuery.class); - targetQF.setQueryConfiguration(queryConfig); + private void restoreOnLoad() { + if (filterManagementUIState.isCreateFilterViewDisplayed()) { + filterManagementUIState.setFilterQueryValue(null); + } else { + filterManagementUIState.getTfQuery() + .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); + } + } - // create lazy query container with lazy defination and query - final LazyQueryContainer targetTableContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), - targetQF); - targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); + /** + * Create a empty HierarchicalContainer. + */ + private LazyQueryContainer createContainer() { + // ADD all the filters to the query config + final Map queryConfig = prepareQueryConfigFilters(); - return targetTableContainer; + // Create TargetBeanQuery factory with the query config. + final BeanQueryFactory targetQF = new BeanQueryFactory<>(CustomTargetBeanQuery.class); + targetQF.setQueryConfiguration(queryConfig); - } + // create lazy query container with lazy defination and query + final LazyQueryContainer targetTableContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), + targetQF); + targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); - private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap<>(); - if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) { - queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue()); - } - queryConfig.put(SPUIDefinitions.FILTER_BY_INVALID_QUERY, - filterManagementUIState.getIsFilterByInvalidFilterQuery()); - return queryConfig; - } + return targetTableContainer; - /** - * populate campaign data. - * - */ - public void populateTableData() { - container = createContainer(); - setContainerDataSource(container); - addContainerproperties(); - setColumnProperties(); - setPageLength(30); - setCollapsibleColumns(); - } + } - private void setCollapsibleColumns() { - setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true); - setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true); - } + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap<>(); + if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) { + queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue()); + } + queryConfig.put(SPUIDefinitions.FILTER_BY_INVALID_QUERY, + filterManagementUIState.getIsFilterByInvalidFilterQuery()); + return queryConfig; + } - /** - * Create a empty HierarchicalContainer. - */ - private void addContainerproperties() { - /* Create HierarchicalContainer container */ - container.addContainerProperty(SPUILabelDefinitions.NAME, String.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); - container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); - container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); - container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); - } + /** + * populate campaign data. + * + */ + public void populateTableData() { + container = createContainer(); + setContainerDataSource(container); + addContainerproperties(); + setColumnProperties(); + setPageLength(30); + setCollapsibleColumns(); + } - private List getVisbleColumns() { - final List columnList = new ArrayList<>(); - columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); - columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, - i18n.get("header.assigned.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, - i18n.get("header.installed.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); - return columnList; - } + private void setCollapsibleColumns() { + setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true); + setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true); - private Component getStatusIcon(final Object itemId) { - final Item row1 = getItem(itemId); - final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 - .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); - final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); - label.setContentMode(ContentMode.HTML); - if (targetStatus == TargetUpdateStatus.PENDING) { - label.setDescription("Pending"); - label.setStyleName("statusIconYellow"); - label.setValue(FontAwesome.ADJUST.getHtml()); - } else if (targetStatus == TargetUpdateStatus.REGISTERED) { - label.setDescription("Registered"); - label.setStyleName("statusIconLightBlue"); - label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml()); - } else if (targetStatus == TargetUpdateStatus.ERROR) { - label.setDescription(i18n.get("label.error")); - label.setStyleName("statusIconRed"); - label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); - } else if (targetStatus == TargetUpdateStatus.IN_SYNC) { - label.setStyleName("statusIconGreen"); - label.setDescription("In-Synch"); - label.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); - } else if (targetStatus == TargetUpdateStatus.UNKNOWN) { - label.setStyleName("statusIconBlue"); - label.setDescription(i18n.get("label.unknown")); - label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml()); - } - return label; - } + setColumnCollapsed(ASSIGN_DIST_SET, true); + setColumnCollapsed(INSTALL_DIST_SET, true); + } - private void setColumnProperties() { - final List columnList = getVisbleColumns(); - final List swColumnIds = new ArrayList<>(); - for (final TableColumn column : columnList) { - setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader()); - setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio()); - swColumnIds.add(column.getColumnPropertyId()); - } - setVisibleColumns(swColumnIds.toArray()); - } + /** + * Create a empty HierarchicalContainer. + */ + private void addContainerproperties() { + /* Create HierarchicalContainer container */ + container.addContainerProperty(SPUILabelDefinitions.NAME, String.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); + container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); + container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); + container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); - protected void addCustomGeneratedColumns() { - addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); - } + container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true); + container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true); + } - private void onQuery() { - populateTableData(); - eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); - } + private List getVisbleColumns() { + final List columnList = new ArrayList<>(); + columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); + columnList.add( + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, + i18n.get("header.assigned.ds"), 0.125F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + i18n.get("header.installed.ds"), 0.125F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); + return columnList; + } + + private Component getStatusIcon(final Object itemId) { + final Item row1 = getItem(itemId); + final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 + .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); + final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + label.setContentMode(ContentMode.HTML); + if (targetStatus == TargetUpdateStatus.PENDING) { + label.setDescription("Pending"); + label.setStyleName("statusIconYellow"); + label.setValue(FontAwesome.ADJUST.getHtml()); + } else if (targetStatus == TargetUpdateStatus.REGISTERED) { + label.setDescription("Registered"); + label.setStyleName("statusIconLightBlue"); + label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml()); + } else if (targetStatus == TargetUpdateStatus.ERROR) { + label.setDescription(i18n.get("label.error")); + label.setStyleName("statusIconRed"); + label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); + } else if (targetStatus == TargetUpdateStatus.IN_SYNC) { + label.setStyleName("statusIconGreen"); + label.setDescription("In-Synch"); + label.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); + } else if (targetStatus == TargetUpdateStatus.UNKNOWN) { + label.setStyleName("statusIconBlue"); + label.setDescription(i18n.get("label.unknown")); + label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml()); + } + return label; + } + + private void setColumnProperties() { + final List columnList = getVisbleColumns(); + final List swColumnIds = new ArrayList<>(); + for (final TableColumn column : columnList) { + setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader()); + setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio()); + swColumnIds.add(column.getColumnPropertyId()); + } + setVisibleColumns(swColumnIds.toArray()); + } + + protected void addCustomGeneratedColumns() { + addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); + } + + private void onQuery() { + populateTableData(); + eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); + } + + public class TooltipGenerator implements ItemDescriptionGenerator { + private static final long serialVersionUID = 688730421728162456L; + + @Override + public String generateDescription(Component source, Object itemId, Object propertyId) { + final DistributionSet distributionSet; + final Item item = getItem(itemId); + if (propertyId != null) { + if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } + } + return null; + } + + private String getDSDetails(final DistributionSet distributionSet) { + StringBuilder swModuleNames = new StringBuilder(); + StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = (Set)distributionSet.getModules(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("
    "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" Required Migration step : ") + .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append("
  • "); + + stringBuilder.append("
"); + return stringBuilder.toString(); + } + + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index dac50ab0d..fae76caf9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -41,183 +41,188 @@ import com.google.common.base.Strings; * */ public class TargetBeanQuery extends AbstractBeanQuery { - private static final long serialVersionUID = -5645680058303167558L; - private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); - private Collection status = null; - private String[] targetTags = null; - private Long distributionId = null; - private String searchText = null; - private Boolean noTagClicked = Boolean.FALSE; - private transient TargetManagement targetManagement; - private transient I18N i18N; - private Long pinnedDistId = null; - private TargetFilterQuery targetFilterQuery; - private ManagementUIState managementUIState; + private static final long serialVersionUID = -5645680058303167558L; + private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); + private Collection status = null; + private String[] targetTags = null; + private Long distributionId = null; + private String searchText = null; + private Boolean noTagClicked = Boolean.FALSE; + private transient TargetManagement targetManagement; + private transient I18N i18N; + private Long pinnedDistId = null; + private TargetFilterQuery targetFilterQuery; + private ManagementUIState managementUIState; - /** - * Parametric Constructor. - * - * @param definition - * as Def - * @param queryConfig - * as Config - * @param sortIds - * as sort - * @param sortStates - * as Sort status - */ - public TargetBeanQuery(final QueryDefinition definition, final Map queryConfig, - final Object[] sortIds, final boolean[] sortStates) { - super(definition, queryConfig, sortIds, sortStates); + /** + * Parametric Constructor. + * + * @param definition + * as Def + * @param queryConfig + * as Config + * @param sortIds + * as sort + * @param sortStates + * as Sort status + */ + public TargetBeanQuery(final QueryDefinition definition, final Map queryConfig, + final Object[] sortIds, final boolean[] sortStates) { + super(definition, queryConfig, sortIds, sortStates); - if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) { - status = (Collection) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS); - targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG); - noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG); - distributionId = (Long) queryConfig.get(SPUIDefinitions.FILTER_BY_DISTRIBUTION); - searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); - targetFilterQuery = (TargetFilterQuery) queryConfig.get(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY); - if (!Strings.isNullOrEmpty(searchText)) { - searchText = String.format("%%%s%%", searchText); - } - pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION); - } + if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) { + status = (Collection) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS); + targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG); + noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG); + distributionId = (Long) queryConfig.get(SPUIDefinitions.FILTER_BY_DISTRIBUTION); + searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); + targetFilterQuery = (TargetFilterQuery) queryConfig.get(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY); + if (!Strings.isNullOrEmpty(searchText)) { + searchText = String.format("%%%s%%", searchText); + } + pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION); + } - if (HawkbitCommonUtil.checkBolArray(sortStates)) { - // Initalize Sor - sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]); - // Add sort. - for (int targetId = 1; targetId < sortIds.length; targetId++) { - sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId])); - } - } - } + if (HawkbitCommonUtil.checkBolArray(sortStates)) { + // Initalize Sor + sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]); + // Add sort. + for (int targetId = 1; targetId < sortIds.length; targetId++) { + sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId])); + } + } + } - @Override - protected ProxyTarget constructBean() { - return new ProxyTarget(); - } + @Override + protected ProxyTarget constructBean() { + return new ProxyTarget(); + } - @Override - protected List loadBeans(final int startIndex, final int count) { - Slice targetBeans; - final List proxyTargetBeans = new ArrayList<>(); - if (pinnedDistId != null) { - targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet( - new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, - distributionId, status, searchText, noTagClicked, targetTags); - } else if (null != targetFilterQuery) { - targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery, - new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); - } else if (!anyFilterSelected()) { - targetBeans = getTargetManagement().findTargetsAll( - new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); - } else { - targetBeans = getTargetManagement().findTargetByFilters( - new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), status, - searchText, distributionId, noTagClicked, targetTags); - } - for (final Target targ : targetBeans) { - final ProxyTarget prxyTarget = new ProxyTarget(); - prxyTarget.setTargetIdName(targ.getTargetIdName()); - prxyTarget.setName(targ.getName()); - prxyTarget.setDescription(targ.getDescription()); - prxyTarget.setControllerId(targ.getControllerId()); - prxyTarget.setInstallationDate(targ.getTargetInfo().getInstallationDate()); - prxyTarget.setAddress(targ.getTargetInfo().getAddress()); - prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); - prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); - prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); - prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); - prxyTarget.setCreatedAt(targ.getCreatedAt()); - prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); - prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); + @Override + protected List loadBeans(final int startIndex, final int count) { + Slice targetBeans; + final List proxyTargetBeans = new ArrayList<>(); + if (pinnedDistId != null) { + targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet( + new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, + distributionId, status, searchText, noTagClicked, targetTags); + } else if (null != targetFilterQuery) { + targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery, + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); + } else if (!anyFilterSelected()) { + targetBeans = getTargetManagement().findTargetsAll( + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); + } else { + targetBeans = getTargetManagement().findTargetByFilters( + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), status, + searchText, distributionId, noTagClicked, targetTags); + } + for (final Target targ : targetBeans) { + final ProxyTarget prxyTarget = new ProxyTarget(); + prxyTarget.setTargetIdName(targ.getTargetIdName()); + prxyTarget.setName(targ.getName()); + prxyTarget.setDescription(targ.getDescription()); + prxyTarget.setControllerId(targ.getControllerId()); + prxyTarget.setInstallationDate(targ.getTargetInfo().getInstallationDate()); + prxyTarget.setAddress(targ.getTargetInfo().getAddress()); + prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); + prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); + prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); + prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); + prxyTarget.setCreatedAt(targ.getCreatedAt()); + prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); + prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); - if (pinnedDistId == null) { - prxyTarget.setInstalledDistributionSet(null); - prxyTarget.setAssignedDistributionSet(null); - } else { - final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); - final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); - prxyTarget.setInstalledDistributionSet(installedDistributionSet); - final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); - prxyTarget.setAssignedDistributionSet(assignedDistributionSet); - } + if (pinnedDistId == null) { + prxyTarget.setInstalledDistributionSet(null); + prxyTarget.setAssignedDistributionSet(null); - prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); - prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); - prxyTarget.setTargetInfo(targ.getTargetInfo()); - prxyTarget.setPollStatusToolTip( - HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); - proxyTargetBeans.add(prxyTarget); - } - return proxyTargetBeans; - } + } else { + final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); + final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); + prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( + installedDistributionSet.getName(), installedDistributionSet.getVersion())); + prxyTarget.setInstalledDistributionSet(installedDistributionSet); + final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); + prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( + assignedDistributionSet.getName(), assignedDistributionSet.getVersion())); + prxyTarget.setAssignedDistributionSet(assignedDistributionSet); + } - private Boolean isTagSelected() { - if (targetTags == null && !noTagClicked) { - return false; - } - return true; - } + prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); + prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); + prxyTarget.setTargetInfo(targ.getTargetInfo()); + prxyTarget.setPollStatusToolTip( + HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); + proxyTargetBeans.add(prxyTarget); + } + return proxyTargetBeans; + } - @Override - protected void saveBeans(final List addedTargets, final List modifiedTargets, - final List removedTargets) { - // CRUD operations on Target will be done through repository methods - } + private Boolean isTagSelected() { + if (targetTags == null && !noTagClicked) { + return false; + } + return true; + } - private Boolean anyFilterSelected() { - if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()) { - return false; - } - return true; - } + @Override + protected void saveBeans(final List addedTargets, final List modifiedTargets, + final List removedTargets) { + // CRUD operations on Target will be done through repository methods + } - @Override - public int size() { - final long totSize = getTargetManagement().countTargetsAll(); - long size; - if (null != targetFilterQuery) { - size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery); - } else if (!anyFilterSelected()) { - size = totSize; - } else { - size = getTargetManagement().countTargetByFilters(status, searchText, distributionId, noTagClicked, - targetTags); - } + private Boolean anyFilterSelected() { + if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()) { + return false; + } + return true; + } - final ManagementUIState tmpManagementUIState = getManagementUIState(); - tmpManagementUIState.setTargetsCountAll(totSize); - if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { - tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); - size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES; - } else { - tmpManagementUIState.setTargetsTruncated(null); - } + @Override + public int size() { + final long totSize = getTargetManagement().countTargetsAll(); + long size; + if (null != targetFilterQuery) { + size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery); + } else if (!anyFilterSelected()) { + size = totSize; + } else { + size = getTargetManagement().countTargetByFilters(status, searchText, distributionId, noTagClicked, + targetTags); + } - return (int) size; - } + final ManagementUIState tmpManagementUIState = getManagementUIState(); + tmpManagementUIState.setTargetsCountAll(totSize); + if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { + tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); + size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES; + } else { + tmpManagementUIState.setTargetsTruncated(null); + } - private TargetManagement getTargetManagement() { - if (targetManagement == null) { - targetManagement = SpringContextHelper.getBean(TargetManagement.class); - } - return targetManagement; - } + return (int) size; + } - private ManagementUIState getManagementUIState() { - if (managementUIState == null) { - managementUIState = SpringContextHelper.getBean(ManagementUIState.class); - } - return managementUIState; - } + private TargetManagement getTargetManagement() { + if (targetManagement == null) { + targetManagement = SpringContextHelper.getBean(TargetManagement.class); + } + return targetManagement; + } - private I18N getI18N() { - if (i18N == null) { - i18N = SpringContextHelper.getBean(I18N.class); - } - return i18N; - } + private ManagementUIState getManagementUIState() { + if (managementUIState == null) { + managementUIState = SpringContextHelper.getBean(ManagementUIState.class); + } + return managementUIState; + } + + private I18N getI18N() { + if (i18N == null) { + i18N = SpringContextHelper.getBean(I18N.class); + } + return i18N; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 3b9c18952..2bfb717f3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -24,7 +24,9 @@ import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TargetManagement; +import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetIdName; @@ -40,6 +42,7 @@ import org.eclipse.hawkbit.ui.filter.target.CustomTargetFilter; import org.eclipse.hawkbit.ui.filter.target.TargetSearchTextFilter; import org.eclipse.hawkbit.ui.filter.target.TargetStatusFilter; import org.eclipse.hawkbit.ui.filter.target.TargetTagFilter; +import org.eclipse.hawkbit.ui.filtermanagement.CreateOrUpdateFilterTable.TooltipGenerator; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; @@ -92,6 +95,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.UI; import com.vaadin.ui.themes.ValoTheme; +import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; /** * Concrete implementation of Target table. @@ -108,6 +112,9 @@ public class TargetTable extends AbstractTable implements private static final int PROPERTY_DEPT = 3; private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed"; + + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; + private static final String INSTALL_DIST_SET = "installedDistributionSet"; @Autowired private transient TargetManagement targetManagement; @@ -136,6 +143,7 @@ public class TargetTable extends AbstractTable implements addActionHandler(this); actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall")); actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear")); + setItemDescriptionGenerator(new TooltipGenerator()); } /** @@ -1073,4 +1081,61 @@ public class TargetTable extends AbstractTable implements private boolean isFilteredByTags() { return !managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty(); } + + + /** + * tooltip for assignedDS and installedDS + */ + + protected class TooltipGenerator implements ItemDescriptionGenerator { + private static final long serialVersionUID = 688730421728162456L; + + @Override + public String generateDescription(Component source, Object itemId, Object propertyId) { + final DistributionSet distributionSet; + final Item item = getItem(itemId); + if (propertyId != null) { + if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } + } + return null; + } + + private String getDSDetails(final DistributionSet distributionSet) { + StringBuilder swModuleNames = new StringBuilder(); + StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = (Set)distributionSet.getModules(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("
    "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" Required Migration step : ") + .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append("
  • "); + stringBuilder.append("
"); + return stringBuilder.toString(); + } + } } \ No newline at end of file diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java index 6514ba2df..a010a3ba4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java @@ -8,7 +8,10 @@ */ package org.eclipse.hawkbit.ui.rollout.rollout; +import java.util.Set; + import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; import com.vaadin.server.FontAwesome; @@ -30,11 +33,85 @@ public class ProxyRollout extends Rollout { private Long numberOfGroups; private Boolean isActionRecieved = Boolean.FALSE; + + private Boolean isRequiredMigrationStep = Boolean.FALSE; private String totalTargetsCount; private RolloutRendererData rolloutRendererData; + + private String discription; + private String type; + + private Set swModules; + + + + /** + * @return the isRequiredMigrationStep + */ + + public Boolean getIsRequiredMigrationStep() { + return isRequiredMigrationStep; + } + + /** + * @param isRequiredMigrationStep + * the isRequiredMigrationStep to set + */ + + public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) { + this.isRequiredMigrationStep = isRequiredMigrationStep; + } + + + /** + * @return the discription + */ + + public String getDiscription() { + return discription; + } + + /** + * @param discription + * the discription to set + */ + + public void setDiscription(String discription) { + this.discription = discription; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type + * the type to set + */ + + public void setType(String type) { + this.type = type; + } + /** + * + * @return the Set of Software modules + */ + public Set getSwModules() { + return swModules; + } + /** + * @param swModules + * Set to set + */ + public void setSwModules(Set swModules) { + this.swModules = swModules; + } public RolloutRendererData getRolloutRendererData() { return rolloutRendererData; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java index 34ae323da..dbd01ac8a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java @@ -136,6 +136,11 @@ public class RolloutBeanQuery extends AbstractBeanQuery { final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus(); proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus); proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets())); + + proxyRollout.setDescription(distributionSet.getDescription()); + proxyRollout.setType(distributionSet.getType().getName()); + proxyRollout.setIsRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); + proxyRollout.setSwModules(distributionSet.getModules()); proxyRolloutList.add(proxyRollout); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index 1bb0fd831..c68bbf700 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -14,12 +14,14 @@ import java.util.EnumMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.ui.common.grid.AbstractGrid; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; @@ -68,562 +70,619 @@ import com.vaadin.ui.renderers.HtmlRenderer; @ViewScope public class RolloutListGrid extends AbstractGrid { - private static final long serialVersionUID = 4060904914954370524L; - - private static final String UPDATE_OPTION = "Update"; - - private static final String RESUME_OPTION = "Resume"; - - private static final String PAUSE_OPTION = "Pause"; - - private static final String START_OPTION = "Start"; - - private static final String ROLLOUT_RENDERER_DATA = "rolloutRendererData"; - - @Autowired - private transient RolloutManagement rolloutManagement; - - @Autowired - private AddUpdateRolloutWindowLayout addUpdateRolloutWindow; - - @Autowired - private UINotification uiNotification; - - @Autowired - private transient RolloutUIState rolloutUIState; - - @Autowired - private transient SpPermissionChecker permissionChecker; - - private transient Map statusIconMap = new EnumMap<>(RolloutStatus.class); - - /** - * Handles the RolloutEvent to refresh Grid. - * - */ - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final RolloutEvent event) { - switch (event) { - case FILTER_BY_TEXT: - case CREATE_ROLLOUT: - case UPDATE_ROLLOUT: - case SHOW_ROLLOUTS: - refreshGrid(); - break; - default: - return; - } - } - - /** - * Handles the RolloutChangeEvent to refresh the item in the grid. - * - * @param rolloutChangeEvent - * the event which contains the rollout which has been changed - */ - @SuppressWarnings("unchecked") - @EventBusListenerMethod(scope = EventScope.SESSION) - public void onEvent(final RolloutChangeEvent rolloutChangeEvent) { - if (!rolloutUIState.isShowRollOuts()) { - return; - } - final Rollout rollout = rolloutManagement.findRolloutWithDetailedStatus(rolloutChangeEvent.getRolloutId()); - final TotalTargetCountStatus totalTargetCountStatus = rollout.getTotalTargetCountStatus(); - final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource(); - final Item item = rolloutContainer.getItem(rolloutChangeEvent.getRolloutId()); - if (item == null) { - return; - } - item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus()); - item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus); - final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue(); - final int groupsCreated = rollout.getRolloutGroupsCreated(); - if (groupsCreated != 0) { - item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated)); - } else if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) { - item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS) - .setValue(Long.valueOf(rollout.getRolloutGroups().size())); - } - item.getItemProperty(ROLLOUT_RENDERER_DATA) - .setValue(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString())); - - } - - @Override - protected Container createContainer() { - final BeanQueryFactory rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class); - return new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf); - } - - @Override - protected void addContainerProperties() { - final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource(); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); - rolloutGridContainer.addContainerProperty(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, - false); - - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Long.class, 0, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, - TotalTargetCountStatus.class, null, false, false); - - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.ACTION, String.class, - FontAwesome.CIRCLE_O.getHtml(), false, false); - - } - - @Override - protected void setColumnExpandRatio() { - - getColumn(ROLLOUT_RENDERER_DATA).setMinimumWidth(40); - getColumn(ROLLOUT_RENDERER_DATA).setMaximumWidth(150); - - getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40); - getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150); - - getColumn(SPUILabelDefinitions.VAR_STATUS).setMinimumWidth(75); - getColumn(SPUILabelDefinitions.VAR_STATUS).setMaximumWidth(75); - - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100); - - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40); - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100); - - getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75); - getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75); - - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280); - - setFrozenColumnCount(getColumns().size()); - } - - @Override - protected void setColumnHeaderNames() { - getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); - getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset")); - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); - getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); - getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy")); - getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); - getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); - getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description")); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) - .setHeaderCaption(i18n.get("header.detail.status")); - getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); - getColumn(SPUILabelDefinitions.ACTION).setHeaderCaption(i18n.get("upload.action")); - } - - @Override - protected String getGridId() { - return SPUIComponetIdProvider.ROLLOUT_LIST_GRID_ID; - } - - @Override - protected void setColumnProperties() { - final List columnList = new ArrayList<>(); - columnList.add(ROLLOUT_RENDERER_DATA); - columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); - columnList.add(SPUILabelDefinitions.VAR_STATUS); - columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); - columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); - columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS); - columnList.add(SPUILabelDefinitions.ACTION); - - columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE); - columnList.add(SPUILabelDefinitions.VAR_CREATED_USER); - columnList.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); - columnList.add(SPUILabelDefinitions.VAR_MODIFIED_BY); - columnList.add(SPUILabelDefinitions.VAR_DESC); - setColumnOrder(columnList.toArray()); - alignColumns(); - } - - @Override - protected void setHiddenColumns() { - final List columnsToBeHidden = new ArrayList<>(); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC); - for (final Object propertyId : columnsToBeHidden) { - getColumn(propertyId).setHidden(true); - } - - } - - @Override - protected CellDescriptionGenerator getDescriptionGenerator() { - return cell -> getDescription(cell); - } - - @Override - protected void addColumnRenderes() { - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(), - new TotalTargetGroupsConverter()); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), - new TotalTargetCountStatusConverter()); - - createRolloutStatusToFontMap(); - getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); - - getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event))); - - final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class); - customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event)); - getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer); - - } - - private void createRolloutStatusToFontMap() { - statusIconMap.put(RolloutStatus.FINISHED, - new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN)); - statusIconMap.put(RolloutStatus.PAUSED, - new StatusFontIcon(FontAwesome.PAUSE, SPUIStyleDefinitions.STATUS_ICON_BLUE)); - statusIconMap.put(RolloutStatus.RUNNING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_YELLOW)); - statusIconMap.put(RolloutStatus.READY, - new StatusFontIcon(FontAwesome.DOT_CIRCLE_O, SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE)); - statusIconMap.put(RolloutStatus.STOPPED, - new StatusFontIcon(FontAwesome.STOP, SPUIStyleDefinitions.STATUS_ICON_RED)); - statusIconMap.put(RolloutStatus.CREATING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_GREY)); - statusIconMap.put(RolloutStatus.STARTING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_BLUE)); - statusIconMap.put(RolloutStatus.ERROR_CREATING, - new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); - statusIconMap.put(RolloutStatus.ERROR_STARTING, - new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); - } - - private void alignColumns() { - setCellStyleGenerator(new CellStyleGenerator() { - private static final long serialVersionUID = 5573570647129792429L; - - @Override - public String getStyle(final CellReference cellReference) { - final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION }; - if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) { - return "centeralign"; - } - return null; - } - }); - } - - private void onClickOfRolloutName(final RendererClickEvent event) { - rolloutUIState.setRolloutId((long) event.getItemId()); - final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId()) - .getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); - rolloutUIState.setRolloutName(rolloutName); - final String ds = (String) getContainerDataSource().getItem(event.getItemId()) - .getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue(); - rolloutUIState.setRolloutDistributionSet(ds); - eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS); - } - - private void onClickOfActionBtn(final RendererClickEvent event) { - final ContextMenu contextMenu = createContextMenu((Long) event.getItemId()); - contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent()); - contextMenu.open(event.getClientX(), event.getClientY()); - } - - private ContextMenu createContextMenu(final Long rolloutId) { - final ContextMenu context = new ContextMenu(); - context.addItemClickListener(event -> menuItemClicked(event)); - final Item row = getContainerDataSource().getItem(rolloutId); - final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS) - .getValue(); - - switch (rolloutStatus) { - case READY: - final ContextMenuItem startItem = context.addItem(START_OPTION); - startItem.setData(new ContextMenuData(rolloutId, ACTION.START)); - break; - case RUNNING: - final ContextMenuItem pauseItem = context.addItem(PAUSE_OPTION); - pauseItem.setData(new ContextMenuData(rolloutId, ACTION.PAUSE)); - break; - case PAUSED: - final ContextMenuItem resumeItem = context.addItem(RESUME_OPTION); - resumeItem.setData(new ContextMenuData(rolloutId, ACTION.RESUME)); - break; - case STARTING: - case CREATING: - case ERROR_CREATING: - case ERROR_STARTING: - // do not provide any action on these statuses - return context; - default: - break; - } - getUpdateMenuItem(context, rolloutId); - return context; - } - - private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) { - // Add 'Update' option only if user has update permission - if (!permissionChecker.hasRolloutUpdatePermission()) { - return; - } - final ContextMenuItem cancelItem = context.addItem(UPDATE_OPTION); - cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE)); - } - - private void menuItemClicked(final ContextMenuItemClickEvent event) { - final ContextMenuItem item = (ContextMenuItem) event.getSource(); - final ContextMenuData contextMenuData = (ContextMenuData) item.getData(); - final Item row = getContainerDataSource().getItem(contextMenuData.getRolloutId()); - final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); - switch (contextMenuData.getAction()) { - case PAUSE: - rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); - uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); - break; - case RESUME: - rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); - uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName)); - break; - case START: - rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName)); - uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName)); - break; - case UPDATE: - onUpdate(contextMenuData); - break; - default: - break; - } - } - - private void onUpdate(final ContextMenuData contextMenuData) { - addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId()); - final Window addTargetWindow = addUpdateRolloutWindow.getWindow(); - addTargetWindow.setCaption(i18n.get("caption.update.rollout")); - UI.getCurrent().addWindow(addTargetWindow); - addTargetWindow.setVisible(Boolean.TRUE); - } - - private void refreshGrid() { - ((LazyQueryContainer) getContainerDataSource()).refresh(); - } - - /** - * Generator to generate fontIcon by String. - */ - public final class FontIconGenerator extends PropertyValueGenerator { - - private static final long serialVersionUID = 2544026030795375748L; - private final FontAwesome fontIcon; - - public FontIconGenerator(final FontAwesome icon) { - this.fontIcon = icon; - } - - @Override - public String getValue(final Item item, final Object itemId, final Object propertyId) { - return fontIcon.getHtml(); - } - - @Override - public Class getType() { - return String.class; - } - } - - private String getDescription(final CellReference cell) { - if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { - return cell.getProperty().getValue().toString().toLowerCase(); - } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { - return SPUILabelDefinitions.ACTION.toLowerCase(); - } else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) { - return ((RolloutRendererData) cell.getProperty().getValue()).getName(); - } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { - return DistributionBarHelper - .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); - } - return null; - } - - enum ACTION { - PAUSE, RESUME, START, UPDATE - } - - /** - * Represents data of context menu item. - * - */ - public static class ContextMenuData { - - private Long rolloutId; - - private ACTION action; - - /** - * Set rollout if and action. - * - * @param rolloutId - * id of rollout - * @param action - * user action {@link ACTION} - */ - public ContextMenuData(final Long rolloutId, final ACTION action) { - this.action = action; - this.rolloutId = rolloutId; - } - - /** - * @return the rolloutId - */ - public Long getRolloutId() { - return rolloutId; - } - - /** - * @param rolloutId - * the rolloutId to set - */ - public void setRolloutId(final Long rolloutId) { - this.rolloutId = rolloutId; - } - - /** - * @return the action - */ - public ACTION getAction() { - return action; - } - - /** - * @param action - * the action to set - */ - public void setAction(final ACTION action) { - this.action = action; - } - } - - /** - * - * Converter to convert {@link RolloutStatus} to string. - * - */ - class RolloutStatusConverter implements Converter { - - private static final long serialVersionUID = -1217685750825632678L; - - @Override - public RolloutStatus convertToModel(final String value, final Class targetType, - final Locale locale) { - return null; - } - - @Override - public String convertToPresentation(final RolloutStatus value, final Class targetType, - final Locale locale) { - return convertRolloutStatusToString(value); - } - - @Override - public Class getModelType() { - return RolloutStatus.class; - } - - @Override - public Class getPresentationType() { - return String.class; - } - - private String convertRolloutStatusToString(final RolloutStatus value) { - final StatusFontIcon statusFontIcon = statusIconMap.get(value); - final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon); - return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), - SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID); - } - } - - /** - * Converter to convert {@link TotalTargetCountStatus} to formatted string - * with status and count details. - * - */ - class TotalTargetCountStatusConverter implements Converter { - - private static final long serialVersionUID = -5794528427855153924L; - - @Override - public TotalTargetCountStatus convertToModel(final String value, - final Class targetType, final Locale locale) - throws com.vaadin.data.util.converter.Converter.ConversionException { - return null; - } - - @Override - public String convertToPresentation(final TotalTargetCountStatus value, - final Class targetType, final Locale locale) - throws com.vaadin.data.util.converter.Converter.ConversionException { - return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); - } - - @Override - public Class getModelType() { - return TotalTargetCountStatus.class; - } - - @Override - public Class getPresentationType() { - return String.class; - } - } - - /** - * Converter to convert 0 to empty, if total target groups is zero. - * - */ - class TotalTargetGroupsConverter implements Converter { - - private static final long serialVersionUID = 6589305227035220369L; - - @Override - public Long convertToModel(final String value, final Class targetType, final Locale locale) - throws com.vaadin.data.util.converter.Converter.ConversionException { - return null; - } - - @Override - public String convertToPresentation(final Long value, final Class targetType, - final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { - if (value == 0) { - return ""; - } - return value.toString(); - } - - @Override - public Class getModelType() { - return Long.class; - } - - @Override - public Class getPresentationType() { - return String.class; - } - - } + private static final long serialVersionUID = 4060904914954370524L; + + private static final String UPDATE_OPTION = "Update"; + + private static final String RESUME_OPTION = "Resume"; + + private static final String PAUSE_OPTION = "Pause"; + + private static final String START_OPTION = "Start"; + + private static final String DS_TYPE = "type"; + + private static final String SW_MODULES = "swModules"; + + private static final String IS_REQUIRED_MIGRATION_STEP = "isRequiredMigrationStep"; + + private static final String ROLLOUT_RENDERER_DATA = "rolloutRendererData"; + + @Autowired + private transient RolloutManagement rolloutManagement; + + @Autowired + private AddUpdateRolloutWindowLayout addUpdateRolloutWindow; + + @Autowired + private UINotification uiNotification; + + @Autowired + private transient RolloutUIState rolloutUIState; + + @Autowired + private transient SpPermissionChecker permissionChecker; + + private transient Map statusIconMap = new EnumMap<>(RolloutStatus.class); + + /** + * Handles the RolloutEvent to refresh Grid. + * + */ + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final RolloutEvent event) { + switch (event) { + case FILTER_BY_TEXT: + case CREATE_ROLLOUT: + case UPDATE_ROLLOUT: + case SHOW_ROLLOUTS: + refreshGrid(); + break; + default: + return; + } + } + + /** + * Handles the RolloutChangeEvent to refresh the item in the grid. + * + * @param rolloutChangeEvent + * the event which contains the rollout which has been changed + */ + @SuppressWarnings("unchecked") + @EventBusListenerMethod(scope = EventScope.SESSION) + public void onEvent(final RolloutChangeEvent rolloutChangeEvent) { + if (!rolloutUIState.isShowRollOuts()) { + return; + } + final Rollout rollout = rolloutManagement.findRolloutWithDetailedStatus(rolloutChangeEvent.getRolloutId()); + final TotalTargetCountStatus totalTargetCountStatus = rollout.getTotalTargetCountStatus(); + final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource(); + final Item item = rolloutContainer.getItem(rolloutChangeEvent.getRolloutId()); + if (item == null) { + return; + } + item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus()); + item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus); + final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue(); + final int groupsCreated = rollout.getRolloutGroupsCreated(); + if (groupsCreated != 0) { + item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated)); + } else if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) { + item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS) + .setValue(Long.valueOf(rollout.getRolloutGroups().size())); + } + item.getItemProperty(ROLLOUT_RENDERER_DATA) + .setValue(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString())); + + } + + @Override + protected Container createContainer() { + final BeanQueryFactory rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class); + return new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf); + } + + @Override + protected void addContainerProperties() { + final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource(); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); + rolloutGridContainer.addContainerProperty(DS_TYPE, String.class, null, false, false); + rolloutGridContainer.addContainerProperty(SW_MODULES, Set.class, null, false, false); + rolloutGridContainer.addContainerProperty(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false); + rolloutGridContainer.addContainerProperty(IS_REQUIRED_MIGRATION_STEP, boolean.class, null, false, false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, + false); + + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Long.class, 0, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, + TotalTargetCountStatus.class, null, false, false); + + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.ACTION, String.class, + FontAwesome.CIRCLE_O.getHtml(), false, false); + + } + + @Override + protected void setColumnExpandRatio() { + + getColumn(ROLLOUT_RENDERER_DATA).setMinimumWidth(40); + getColumn(ROLLOUT_RENDERER_DATA).setMaximumWidth(150); + + getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40); + getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150); + + getColumn(SPUILabelDefinitions.VAR_STATUS).setMinimumWidth(75); + getColumn(SPUILabelDefinitions.VAR_STATUS).setMaximumWidth(75); + + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100); + + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40); + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100); + + getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75); + getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75); + + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280); + + setFrozenColumnCount(getColumns().size()); + } + + @Override + protected void setColumnHeaderNames() { + getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); + getColumn(DS_TYPE).setHeaderCaption("Type"); + getColumn(SW_MODULES).setHeaderCaption("swModules"); + getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption("IsRequiredMigrationStep"); + getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset")); + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); + getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); + getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy")); + getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); + getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); + getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description")); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) + .setHeaderCaption(i18n.get("header.detail.status")); + getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); + getColumn(SPUILabelDefinitions.ACTION).setHeaderCaption(i18n.get("upload.action")); + } + + @Override + protected String getGridId() { + return SPUIComponetIdProvider.ROLLOUT_LIST_GRID_ID; + } + + @Override + protected void setColumnProperties() { + final List columnList = new ArrayList<>(); + columnList.add(ROLLOUT_RENDERER_DATA); + columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); + columnList.add(DS_TYPE); + columnList.add(SW_MODULES); + columnList.add(IS_REQUIRED_MIGRATION_STEP); + columnList.add(SPUILabelDefinitions.VAR_STATUS); + columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); + columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); + columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS); + columnList.add(SPUILabelDefinitions.ACTION); + + columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE); + columnList.add(SPUILabelDefinitions.VAR_CREATED_USER); + columnList.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); + columnList.add(SPUILabelDefinitions.VAR_MODIFIED_BY); + columnList.add(SPUILabelDefinitions.VAR_DESC); + setColumnOrder(columnList.toArray()); + alignColumns(); + } + + @Override + protected void setHiddenColumns() { + final List columnsToBeHidden = new ArrayList<>(); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC); + columnsToBeHidden.add(IS_REQUIRED_MIGRATION_STEP); + columnsToBeHidden.add(DS_TYPE); + columnsToBeHidden.add(SW_MODULES); + for (final Object propertyId : columnsToBeHidden) { + getColumn(propertyId).setHidden(true); + } + + } + + @Override + protected CellDescriptionGenerator getDescriptionGenerator() { + return cell -> getDescription(cell); + } + + @Override + protected void addColumnRenderes() { + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(), + new TotalTargetGroupsConverter()); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), + new TotalTargetCountStatusConverter()); + + createRolloutStatusToFontMap(); + getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); + + getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event))); + + final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class); + customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event)); + getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer); + + } + + private void createRolloutStatusToFontMap() { + statusIconMap.put(RolloutStatus.FINISHED, + new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN)); + statusIconMap.put(RolloutStatus.PAUSED, + new StatusFontIcon(FontAwesome.PAUSE, SPUIStyleDefinitions.STATUS_ICON_BLUE)); + statusIconMap.put(RolloutStatus.RUNNING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_YELLOW)); + statusIconMap.put(RolloutStatus.READY, + new StatusFontIcon(FontAwesome.DOT_CIRCLE_O, SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE)); + statusIconMap.put(RolloutStatus.STOPPED, + new StatusFontIcon(FontAwesome.STOP, SPUIStyleDefinitions.STATUS_ICON_RED)); + statusIconMap.put(RolloutStatus.CREATING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_GREY)); + statusIconMap.put(RolloutStatus.STARTING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_BLUE)); + statusIconMap.put(RolloutStatus.ERROR_CREATING, + new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); + statusIconMap.put(RolloutStatus.ERROR_STARTING, + new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); + } + + private void alignColumns() { + setCellStyleGenerator(new CellStyleGenerator() { + private static final long serialVersionUID = 5573570647129792429L; + + @Override + public String getStyle(final CellReference cellReference) { + final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION }; + if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) { + return "centeralign"; + } + return null; + } + }); + } + + private void onClickOfRolloutName(final RendererClickEvent event) { + rolloutUIState.setRolloutId((long) event.getItemId()); + final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId()) + .getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); + rolloutUIState.setRolloutName(rolloutName); + final String ds = (String) getContainerDataSource().getItem(event.getItemId()) + .getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue(); + rolloutUIState.setRolloutDistributionSet(ds); + eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS); + } + + private void onClickOfActionBtn(final RendererClickEvent event) { + final ContextMenu contextMenu = createContextMenu((Long) event.getItemId()); + contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent()); + contextMenu.open(event.getClientX(), event.getClientY()); + } + + private ContextMenu createContextMenu(final Long rolloutId) { + final ContextMenu context = new ContextMenu(); + context.addItemClickListener(event -> menuItemClicked(event)); + final Item row = getContainerDataSource().getItem(rolloutId); + final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS) + .getValue(); + + switch (rolloutStatus) { + case READY: + final ContextMenuItem startItem = context.addItem(START_OPTION); + startItem.setData(new ContextMenuData(rolloutId, ACTION.START)); + break; + case RUNNING: + final ContextMenuItem pauseItem = context.addItem(PAUSE_OPTION); + pauseItem.setData(new ContextMenuData(rolloutId, ACTION.PAUSE)); + break; + case PAUSED: + final ContextMenuItem resumeItem = context.addItem(RESUME_OPTION); + resumeItem.setData(new ContextMenuData(rolloutId, ACTION.RESUME)); + break; + case STARTING: + case CREATING: + case ERROR_CREATING: + case ERROR_STARTING: + // do not provide any action on these statuses + return context; + default: + break; + } + getUpdateMenuItem(context, rolloutId); + return context; + } + + private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) { + // Add 'Update' option only if user has update permission + if (!permissionChecker.hasRolloutUpdatePermission()) { + return; + } + final ContextMenuItem cancelItem = context.addItem(UPDATE_OPTION); + cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE)); + } + + private void menuItemClicked(final ContextMenuItemClickEvent event) { + final ContextMenuItem item = (ContextMenuItem) event.getSource(); + final ContextMenuData contextMenuData = (ContextMenuData) item.getData(); + final Item row = getContainerDataSource().getItem(contextMenuData.getRolloutId()); + final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); + switch (contextMenuData.getAction()) { + case PAUSE: + rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); + uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); + break; + case RESUME: + rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); + uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName)); + break; + case START: + rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName)); + uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName)); + break; + case UPDATE: + onUpdate(contextMenuData); + break; + default: + break; + } + } + + private void onUpdate(final ContextMenuData contextMenuData) { + addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId()); + final Window addTargetWindow = addUpdateRolloutWindow.getWindow(); + addTargetWindow.setCaption(i18n.get("caption.update.rollout")); + UI.getCurrent().addWindow(addTargetWindow); + addTargetWindow.setVisible(Boolean.TRUE); + } + + private void refreshGrid() { + ((LazyQueryContainer) getContainerDataSource()).refresh(); + } + + /** + * Generator to generate fontIcon by String. + */ + public final class FontIconGenerator extends PropertyValueGenerator { + + private static final long serialVersionUID = 2544026030795375748L; + private final FontAwesome fontIcon; + + public FontIconGenerator(final FontAwesome icon) { + this.fontIcon = icon; + } + + @Override + public String getValue(final Item item, final Object itemId, final Object propertyId) { + return fontIcon.getHtml(); + } + + @Override + public Class getType() { + return String.class; + } + } + + private String getDescription(final CellReference cell) { + if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { + return cell.getProperty().getValue().toString().toLowerCase(); + } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { + return SPUILabelDefinitions.ACTION.toLowerCase(); + } else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) { + return ((RolloutRendererData) cell.getProperty().getValue()).getName(); + } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { + return DistributionBarHelper + .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); + } else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) { + return getDSDetails((Item) cell.getItem()); + } + return null; + } + + private String getDSDetails(final Item rolloutItem) { + StringBuilder swModuleNames = new StringBuilder(); + StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = (Set) rolloutItem.getItemProperty(SW_MODULES).getValue(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("
    "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Description : ") + .append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Type : ") + .append((String) rolloutItem.getItemProperty(DS_TYPE).getValue()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("Required Migration step : ") + .append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No"); + stringBuilder.append("
  • "); + + stringBuilder.append("
  • "); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append("
  • "); + + stringBuilder.append("
  • "); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append("
  • "); + + stringBuilder.append("
"); + return stringBuilder.toString(); + } + + enum ACTION { + PAUSE, RESUME, START, UPDATE + } + + /** + * Represents data of context menu item. + * + */ + public static class ContextMenuData { + + private Long rolloutId; + + private ACTION action; + + /** + * Set rollout if and action. + * + * @param rolloutId + * id of rollout + * @param action + * user action {@link ACTION} + */ + public ContextMenuData(final Long rolloutId, final ACTION action) { + this.action = action; + this.rolloutId = rolloutId; + } + + /** + * @return the rolloutId + */ + public Long getRolloutId() { + return rolloutId; + } + + /** + * @param rolloutId + * the rolloutId to set + */ + public void setRolloutId(final Long rolloutId) { + this.rolloutId = rolloutId; + } + + /** + * @return the action + */ + public ACTION getAction() { + return action; + } + + /** + * @param action + * the action to set + */ + public void setAction(final ACTION action) { + this.action = action; + } + } + + /** + * + * Converter to convert {@link RolloutStatus} to string. + * + */ + class RolloutStatusConverter implements Converter { + + private static final long serialVersionUID = -1217685750825632678L; + + @Override + public RolloutStatus convertToModel(final String value, final Class targetType, + final Locale locale) { + return null; + } + + @Override + public String convertToPresentation(final RolloutStatus value, final Class targetType, + final Locale locale) { + return convertRolloutStatusToString(value); + } + + @Override + public Class getModelType() { + return RolloutStatus.class; + } + + @Override + public Class getPresentationType() { + return String.class; + } + + private String convertRolloutStatusToString(final RolloutStatus value) { + final StatusFontIcon statusFontIcon = statusIconMap.get(value); + final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon); + return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), + SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID); + } + } + + /** + * Converter to convert {@link TotalTargetCountStatus} to formatted string + * with status and count details. + * + */ + class TotalTargetCountStatusConverter implements Converter { + + private static final long serialVersionUID = -5794528427855153924L; + + @Override + public TotalTargetCountStatus convertToModel(final String value, + final Class targetType, final Locale locale) + throws com.vaadin.data.util.converter.Converter.ConversionException { + return null; + } + + @Override + public String convertToPresentation(final TotalTargetCountStatus value, + final Class targetType, final Locale locale) + throws com.vaadin.data.util.converter.Converter.ConversionException { + return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); + } + + @Override + public Class getModelType() { + return TotalTargetCountStatus.class; + } + + @Override + public Class getPresentationType() { + return String.class; + } + } + + /** + * Converter to convert 0 to empty, if total target groups is zero. + * + */ + class TotalTargetGroupsConverter implements Converter { + + private static final long serialVersionUID = 6589305227035220369L; + + @Override + public Long convertToModel(final String value, final Class targetType, final Locale locale) + throws com.vaadin.data.util.converter.Converter.ConversionException { + return null; + } + + @Override + public String convertToPresentation(final Long value, final Class targetType, + final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { + if (value == 0) { + return ""; + } + return value.toString(); + } + + @Override + public Class getModelType() { + return Long.class; + } + + @Override + public Class getPresentationType() { + return String.class; + } + + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 117b5bcb8..7fdf3a46b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.im.authentication.UserPrincipal; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.AssignmentResult; +import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.SoftwareModule; @@ -106,6 +107,9 @@ public final class HawkbitCommonUtil { private static final String TARGET_TAG_DROP_REMOVE_SCRIPT = "var m = document.getElementById('show-filter-drop-hint'); if(m) { document.head.removeChild(m); } "; private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }"; private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } "; + + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; + private static final String INSTALL_DIST_SET = "installedDistributionSet"; /** * Define empty string. @@ -1090,6 +1094,10 @@ public final class HawkbitCommonUtil { targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null, false, true); targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); + + targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true); + targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true); + } /** From 0b275655c01f07bd5c0bd0b3bcf4df2dd2b73659 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Tue, 26 Apr 2016 18:47:47 +0530 Subject: [PATCH 23/44] Focus-TextArea-On-AddNewWindow Signed-off-by: venu1278 --- .../artifacts/smtable/SoftwareModuleAddUpdateWindow.java | 3 ++- .../artifacts/smtype/CreateUpdateSoftwareTypeLayout.java | 1 + .../disttype/CreateUpdateDistSetTypeLayout.java | 3 ++- .../dstable/DistributionAddUpdateWindowLayout.java | 7 ++++--- .../hawkbit/ui/management/tag/CreateUpdateTagLayout.java | 7 ++++--- .../targettable/TargetAddUpdateWindowLayout.java | 2 +- .../ui/rollout/rollout/AddUpdateRolloutWindowLayout.java | 1 + 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java index cc08929bb..1e4029087 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java @@ -234,12 +234,13 @@ public class SoftwareModuleAddUpdateWindow implements Serializable { mainLayout.addComponent(hLayout); mainLayout.setComponentAlignment(hLayout, Alignment.MIDDLE_LEFT); mainLayout.addComponents(nameTextField, versionTextField, vendorTextField, descTextArea, buttonsLayout); - + /* add main layout to the window */ window = SPUIComponentProvider.getWindow(i18n.get("upload.caption.add.new.swmodule"), null, SPUIDefinitions.CREATE_UPDATE_WINDOW); window.setContent(mainLayout); window.setModal(true); + nameTextField.focus(); } private void addDescriptionTextChangeListener() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index dc6d1081e..fe1fa9024 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -257,6 +257,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C mainLayout = new HorizontalLayout(); mainLayout.addComponent(fieldButtonLayout); setCompositionRoot(mainLayout); + typeName.focus(); } private void addListeners() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index 8d609f628..64a06bd38 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -284,7 +284,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co mainLayout.addComponent(fieldLayout); mainLayout.addComponent(twinTableLayout); - + colorLayout = new HorizontalLayout(); sliderLayout = new VerticalLayout(); final HorizontalLayout chooseColorLayout = new HorizontalLayout(); @@ -299,6 +299,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co mainWindowLayout.addComponent(colorLayout); mainWindowLayout.addComponent(buttonLayout); setCompositionRoot(mainWindowLayout); + typeName.focus(); } private HorizontalLayout createTwinColumnLayout() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 80c1b5700..5d9304191 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -145,11 +145,12 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { setSizeUndefined(); addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea, reqMigStepCheckbox); - + addComponent(buttonsLayout); setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT); - - } + distNameTextField.focus(); + + } /** * Create required UI components. diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java index b78db6b4f..6bed7dd4f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java @@ -171,7 +171,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME, true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME); - + tagDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC, false, "", i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); @@ -237,7 +237,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C fieldLayout.addComponent(madatoryLabel); fieldLayout.addComponent(tagName); fieldLayout.addComponent(tagDesc); - + + final HorizontalLayout colorLabelLayout = new HorizontalLayout(); colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn); fieldLayout.addComponent(colorLabelLayout); @@ -257,8 +258,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C mainLayout = new HorizontalLayout(); mainLayout.addComponent(fieldButtonLayout); - setCompositionRoot(mainLayout); + tagName.focus(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java index 973d61857..e54911d86 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java @@ -152,7 +152,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { madatoryLabel.setVisible(Boolean.FALSE); } mainLayout.addComponents(madatoryLabel, controllerIDTextField, nameTextField, descTextArea, buttonsLayout); - + nameTextField.focus(); } private void addListeners() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java index e5e86c520..7e8d45e1b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java @@ -209,6 +209,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { actionTypeOptionGroupLayout, linkToHelp, getSaveDiscardButtonLayout()); mainLayout.setComponentAlignment(linkToHelp, Alignment.BOTTOM_RIGHT); setCompositionRoot(mainLayout); + rolloutName.focus(); } private HorizontalLayout getGroupDetailsLayout() { From 5c86d2ad682c6c07fd5162087aedb0e54c3de190 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 26 Apr 2016 17:36:19 +0200 Subject: [PATCH 24/44] Upgrade Vaadin and MariaDB to newest stable version. Signed-off-by: Kai Zimmermann --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0c3207c13..b6d09758e 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ 1.0.0 0.0.6.RELEASE - 7.6.4 + 7.6.5 ${vaadin.version} 7.4.0.1 2.2.0 @@ -94,7 +94,7 @@ 0.9.1 1.8.5 19.0 - 1.3.5 + 1.4.3 1.50.2 1.18.1 2.2.4 From 9dd51e710544a58134ceb7d40981e3b0f0191c7e Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 27 Apr 2016 15:37:54 +0200 Subject: [PATCH 25/44] Use java 8 duration to calculate ttl Signed-off-by: SirWayne --- .../org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java index e9ad60a1c..7ed5e90c1 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.amqp; +import java.time.Duration; import java.util.HashMap; import java.util.Map; @@ -25,7 +26,7 @@ public class AmqpDeadletterProperties { * Message time to live (ttl) for the deadletter queue. Default ttl is 3 * weeks. */ - private int ttl = 1_814_400_000; + private long ttl = Duration.ofDays(21).toMillis(); /** * Return the deadletter arguments. @@ -57,11 +58,11 @@ public class AmqpDeadletterProperties { return args; } - public int getTtl() { + public long getTtl() { return ttl; } - public void setTtl(final int ttl) { + public void setTtl(final long ttl) { this.ttl = ttl; } From b53a635c1fc12146697767d6fcedcb851f60d0a9 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Wed, 27 Apr 2016 16:50:33 +0200 Subject: [PATCH 26/44] introduce a conditional property which allows to disable the startup generation of default simulator devices. Signed-off-by: Michael Hirsch --- .../java/org/eclipse/hawkbit/simulator/SimulatorStartup.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java index b772bae1f..9e6c0573a 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java @@ -16,6 +16,7 @@ import org.eclipse.hawkbit.simulator.amqp.SpSenderService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; @@ -25,6 +26,7 @@ import org.springframework.stereotype.Component; * */ @Component +@ConditionalOnProperty(prefix = "com.bosch.hawkbit.simulator", name = "generateOnStartup", matchIfMissing = true) public class SimulatorStartup implements ApplicationListener { private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class); From e5880561a1191fb2a96dbe7fa121638d74e3a8c7 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Wed, 27 Apr 2016 16:59:39 +0200 Subject: [PATCH 27/44] re-name property aligning the autostart property Signed-off-by: Michael Hirsch --- .../java/org/eclipse/hawkbit/simulator/SimulatorStartup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java index 9e6c0573a..19367a9d4 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component; * */ @Component -@ConditionalOnProperty(prefix = "com.bosch.hawkbit.simulator", name = "generateOnStartup", matchIfMissing = true) +@ConditionalOnProperty(prefix = "hawkbit.device.simulator", name = "autostart", matchIfMissing = true) public class SimulatorStartup implements ApplicationListener { private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class); From 63d6448432d5474373de49cde1d7f5194d8981cc Mon Sep 17 00:00:00 2001 From: venu1278 Date: Thu, 28 Apr 2016 11:55:48 +0530 Subject: [PATCH 28/44] Displaying DistributionSet Details in Tooltip Signed-off-by: venu1278 --- .../hawkbit/ui/management/targettable/TargetBeanQuery.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index d6b7f47c9..943efc262 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -131,8 +131,8 @@ public class TargetBeanQuery extends AbstractBeanQuery { prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedAt(targ.getCreatedAt()); - prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); - prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); + prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); + prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); if (pinnedDistId == null) { prxyTarget.setInstalledDistributionSet(null); From f62b740ae8dfd1518910484b9e99d6ffb40a5a32 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 28 Apr 2016 11:43:46 +0200 Subject: [PATCH 29/44] change propagation level to SUPPORTS instead of NOT_SUPPORTED Signed-off-by: Michael Hirsch --- .../java/org/eclipse/hawkbit/repository/SystemManagement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java index c1cee7223..be370cf2d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -164,7 +164,7 @@ public class SystemManagement { * @return the {@link CurrentTenantKeyGenerator} */ @Bean - @Transactional(propagation = Propagation.NOT_SUPPORTED) + @Transactional(propagation = Propagation.SUPPORTS) public CurrentTenantKeyGenerator currentTenantKeyGenerator() { return new CurrentTenantKeyGenerator(); } From 30788904be49bb3ab6064f5d6126871e945c2581 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 28 Apr 2016 11:45:06 +0200 Subject: [PATCH 30/44] code cleanup pull-request feedback Signed-off-by: Michael Hirsch --- .../hawkbit/repository/RolloutManagement.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 6fb2ce0f9..d02b64f35 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -299,7 +299,7 @@ public class RolloutManagement { * amount of given groups. In same cases this will lead to less rollout * groups than given by client. * - * @param amountGroup + * @param amountOfGroups * the amount of groups * @param conditions * the rollout group conditions @@ -307,18 +307,17 @@ public class RolloutManagement { * the rollout * @return the rollout with created groups */ - private Rollout createRolloutGroups(final int amountGroup, final RolloutGroupConditions conditions, + private Rollout createRolloutGroups(final int amountOfGroups, final RolloutGroupConditions conditions, final Rollout savedRollout) { int pageIndex = 0; int groupIndex = 0; final Long totalCount = savedRollout.getTotalTargets(); - final int groupSize = (int) Math.ceil((double) totalCount / (double) amountGroup); - // validate if the amount of groups that will be created are the - // amount + final int groupSize = (int) Math.ceil((double) totalCount / (double) amountOfGroups); + // validate if the amount of groups that will be created are the amount // of groups that the client what's to have created. - int amountGroupValidated = amountGroup; + int amountGroupValidated = amountOfGroups; final int amountGroupCreation = (int) (Math.ceil((double) totalCount / (double) groupSize)); - if (amountGroupCreation == (amountGroup - 1)) { + if (amountGroupCreation == (amountOfGroups - 1)) { amountGroupValidated--; } RolloutGroup lastSavedGroup = null; From 4e48c7c9d7e7d8323e337762560ae47ffb90ad60 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 28 Apr 2016 11:46:01 +0200 Subject: [PATCH 31/44] code cleanup pull-request feedback Signed-off-by: Michael Hirsch --- .../org/eclipse/hawkbit/repository/RolloutManagement.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index d02b64f35..9508a6aeb 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -284,13 +284,13 @@ public class RolloutManagement { } } - private Rollout createRolloutGroupsInNewTransaction(final int amountGroup, final RolloutGroupConditions conditions, + private Rollout createRolloutGroupsInNewTransaction(final int amountOfGroups, final RolloutGroupConditions conditions, final Rollout savedRollout) { final DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("creatingRollout"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); return new TransactionTemplate(txManager, def) - .execute(status -> createRolloutGroups(amountGroup, conditions, savedRollout)); + .execute(status -> createRolloutGroups(amountOfGroups, conditions, savedRollout)); } /** From d8d026e9a1167749b6d9f4a0f22d6c2ba814a4e7 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Thu, 28 Apr 2016 15:17:01 +0530 Subject: [PATCH 32/44] Displaying DistributionSet Details in Tooltip Signed-off-by: venu1278 --- .../ui/common/table/AbstractTable.java | 6 +- .../hawkbit/ui/components/ProxyTarget.java | 488 ++++--- .../CreateOrUpdateFilterTable.java | 448 +++--- .../targettable/TargetBeanQuery.java | 330 ++--- .../management/targettable/TargetTable.java | 109 +- .../ui/rollout/rollout/ProxyRollout.java | 317 +++-- .../ui/rollout/rollout/RolloutBeanQuery.java | 10 +- .../ui/rollout/rollout/RolloutListGrid.java | 1228 ++++++++--------- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 6 +- 9 files changed, 1468 insertions(+), 1474 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index 7e62eef1f..843d86ca3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -324,9 +324,9 @@ public abstract class AbstractTable extends Table { } columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, - i18n.get("header.assigned.ds"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, - i18n.get("header.installed.ds"), 0.1F)); + i18n.get("header.assigned.ds"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + i18n.get("header.installed.ds"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java index 084890f87..9ac39616d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java @@ -10,11 +10,9 @@ package org.eclipse.hawkbit.ui.components; import java.net.URI; import java.security.SecureRandom; -import java.util.Set; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; @@ -28,293 +26,293 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; * */ public class ProxyTarget extends Target { - private static final long serialVersionUID = -8891449133620645310L; - private String controllerId; - private URI address = null; - private Long lastTargetQuery = null; - private Long installationDate; + private static final long serialVersionUID = -8891449133620645310L; + private String controllerId; + private URI address = null; + private Long lastTargetQuery = null; + private Long installationDate; - private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; + private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; - private DistributionSet installedDistributionSet; + private DistributionSet installedDistributionSet; - private DistributionSet assignedDistributionSet; + private DistributionSet assignedDistributionSet; - private TargetIdName targetIdName; + private TargetIdName targetIdName; - private String assignedDistNameVersion; + private String assignedDistNameVersion; - private String installedDistNameVersion; + private String installedDistNameVersion; - private String pollStatusToolTip; + private String pollStatusToolTip; - private String createdByUser; + private String createdByUser; - private String createdDate; + private String createdDate; - private String lastModifiedDate; + private String lastModifiedDate; - private String modifiedByUser; + private String modifiedByUser; - private Status status; + private Status status; - /** - * @param controllerId - */ - public ProxyTarget() { - super(null); - final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE; - targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString()); - } + /** + * @param controllerId + */ + public ProxyTarget() { + super(null); + final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE; + targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString()); + } - /** - * @return the createdByUser - */ - public String getCreatedByUser() { - return createdByUser; - } + /** + * @return the createdByUser + */ + public String getCreatedByUser() { + return createdByUser; + } - /** - * @param createdByUser - * the createdByUser to set - */ - public void setCreatedByUser(final String createdByUser) { - this.createdByUser = createdByUser; - } + /** + * @param createdByUser + * the createdByUser to set + */ + public void setCreatedByUser(final String createdByUser) { + this.createdByUser = createdByUser; + } - /** - * @return the createdDate - */ - public String getCreatedDate() { - return createdDate; - } + /** + * @return the createdDate + */ + public String getCreatedDate() { + return createdDate; + } - /** - * @param createdDate - * the createdDate to set - */ - public void setCreatedDate(final String createdDate) { - this.createdDate = createdDate; - } + /** + * @param createdDate + * the createdDate to set + */ + public void setCreatedDate(final String createdDate) { + this.createdDate = createdDate; + } - /** - * @return the modifiedByUser - */ - public String getModifiedByUser() { - return modifiedByUser; - } + /** + * @return the modifiedByUser + */ + public String getModifiedByUser() { + return modifiedByUser; + } - /** - * @param modifiedByUser - * the modifiedByUser to set - */ - public void setModifiedByUser(final String modifiedByUser) { - this.modifiedByUser = modifiedByUser; - } + /** + * @param modifiedByUser + * the modifiedByUser to set + */ + public void setModifiedByUser(final String modifiedByUser) { + this.modifiedByUser = modifiedByUser; + } - /** - * @return the lastModifiedDate - */ - public String getLastModifiedDate() { - return lastModifiedDate; - } + /** + * @return the lastModifiedDate + */ + public String getLastModifiedDate() { + return lastModifiedDate; + } - /** - * @param lastModifiedDate - * the lastModifiedDate to set - */ - public void setLastModifiedDate(final String lastModifiedDate) { - this.lastModifiedDate = lastModifiedDate; - } + /** + * @param lastModifiedDate + * the lastModifiedDate to set + */ + public void setLastModifiedDate(final String lastModifiedDate) { + this.lastModifiedDate = lastModifiedDate; + } - /** - * @return the assignedDistNameVersion - */ - public String getAssignedDistNameVersion() { - return assignedDistNameVersion; - } + /** + * @return the assignedDistNameVersion + */ + public String getAssignedDistNameVersion() { + return assignedDistNameVersion; + } - /** - * @param assignedDistNameVersion - * the assignedDistNameVersion to set - */ - public void setAssignedDistNameVersion(final String assignedDistNameVersion) { - this.assignedDistNameVersion = assignedDistNameVersion; - } + /** + * @param assignedDistNameVersion + * the assignedDistNameVersion to set + */ + public void setAssignedDistNameVersion(final String assignedDistNameVersion) { + this.assignedDistNameVersion = assignedDistNameVersion; + } - /** - * @return the installedDistNameVersion - */ - public String getInstalledDistNameVersion() { - return installedDistNameVersion; - } + /** + * @return the installedDistNameVersion + */ + public String getInstalledDistNameVersion() { + return installedDistNameVersion; + } - /** - * @param installedDistNameVersion - * the installedDistNameVersion to set - */ - public void setInstalledDistNameVersion(final String installedDistNameVersion) { - this.installedDistNameVersion = installedDistNameVersion; - } + /** + * @param installedDistNameVersion + * the installedDistNameVersion to set + */ + public void setInstalledDistNameVersion(final String installedDistNameVersion) { + this.installedDistNameVersion = installedDistNameVersion; + } - /** - * GET - ID. - * - * @return String as ID. - */ - @Override - public String getControllerId() { - return controllerId; - } + /** + * GET - ID. + * + * @return String as ID. + */ + @Override + public String getControllerId() { + return controllerId; + } - /** - * SET - ID. - * - * @param controllerId - * as ID - */ - @Override - public void setControllerId(final String controllerId) { - this.controllerId = controllerId; - } + /** + * SET - ID. + * + * @param controllerId + * as ID + */ + @Override + public void setControllerId(final String controllerId) { + this.controllerId = controllerId; + } - /** - * @return the ipAddress - */ - public URI getAddress() { - return address; - } + /** + * @return the ipAddress + */ + public URI getAddress() { + return address; + } - /** - * @param ipAddress - * the ipAddress to set - */ - public void setAddress(final URI address) { - this.address = address; - } + /** + * @param ipAddress + * the ipAddress to set + */ + public void setAddress(final URI address) { + this.address = address; + } - /** - * @return the lastTargetQuery - */ - public Long getLastTargetQuery() { - return lastTargetQuery; - } + /** + * @return the lastTargetQuery + */ + public Long getLastTargetQuery() { + return lastTargetQuery; + } - /** - * @param lastTargetQuery - * the lastTargetQuery to set - */ - public void setLastTargetQuery(final Long lastTargetQuery) { - this.lastTargetQuery = lastTargetQuery; - } + /** + * @param lastTargetQuery + * the lastTargetQuery to set + */ + public void setLastTargetQuery(final Long lastTargetQuery) { + this.lastTargetQuery = lastTargetQuery; + } - /** - * @return the installationDate - */ - public Long getInstallationDate() { - return installationDate; - } + /** + * @return the installationDate + */ + public Long getInstallationDate() { + return installationDate; + } - /** - * @param installationDate - * the installationDate to set - */ - public void setInstallationDate(final Long installationDate) { - this.installationDate = installationDate; - } + /** + * @param installationDate + * the installationDate to set + */ + public void setInstallationDate(final Long installationDate) { + this.installationDate = installationDate; + } - /** - * @return the updateStatus - */ - public TargetUpdateStatus getUpdateStatus() { - return updateStatus; - } + /** + * @return the updateStatus + */ + public TargetUpdateStatus getUpdateStatus() { + return updateStatus; + } - /** - * @param updateStatus - * the updateStatus to set - */ - public void setUpdateStatus(final TargetUpdateStatus updateStatus) { - this.updateStatus = updateStatus; - } + /** + * @param updateStatus + * the updateStatus to set + */ + public void setUpdateStatus(final TargetUpdateStatus updateStatus) { + this.updateStatus = updateStatus; + } - /** - * @return the installedDistributionSet - */ - public DistributionSet getInstalledDistributionSet() { - return installedDistributionSet; - } + /** + * @return the installedDistributionSet + */ + public DistributionSet getInstalledDistributionSet() { + return installedDistributionSet; + } - /** - * @param installedDistributionSet - * the installedDistributionSet to set - */ - public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) { - this.installedDistributionSet = installedDistributionSet; - } + /** + * @param installedDistributionSet + * the installedDistributionSet to set + */ + public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) { + this.installedDistributionSet = installedDistributionSet; + } - /** - * @return the assignedDistributionSet - */ - public DistributionSet getAssignedDistributionSet() { - return assignedDistributionSet; - } + /** + * @return the assignedDistributionSet + */ + public DistributionSet getAssignedDistributionSet() { + return assignedDistributionSet; + } - /** - * @param assignedDistributionSet - * the assignedDistributionSet to set - */ - public void setAssignedDistributionSet(DistributionSet assignedDistributionSet) { - this.assignedDistributionSet = assignedDistributionSet; - } + /** + * @param assignedDistributionSet + * the assignedDistributionSet to set + */ + public void setAssignedDistributionSet(DistributionSet assignedDistributionSet) { + this.assignedDistributionSet = assignedDistributionSet; + } - /** - * @return the targetIdName - */ - @Override - public TargetIdName getTargetIdName() { - if (this.targetIdName == null) { - return super.getTargetIdName(); - } - return this.targetIdName; - } + /** + * @return the targetIdName + */ + @Override + public TargetIdName getTargetIdName() { + if (this.targetIdName == null) { + return super.getTargetIdName(); + } + return this.targetIdName; + } - /** - * @param targetIdName - * the targetIdName to set - */ - public void setTargetIdName(final TargetIdName targetIdName) { - this.targetIdName = targetIdName; - } + /** + * @param targetIdName + * the targetIdName to set + */ + public void setTargetIdName(final TargetIdName targetIdName) { + this.targetIdName = targetIdName; + } - /** - * @return the pollStatusToolTip - */ - public String getPollStatusToolTip() { - return pollStatusToolTip; - } + /** + * @return the pollStatusToolTip + */ + public String getPollStatusToolTip() { + return pollStatusToolTip; + } - /** - * @param pollStatusToolTip - * the pollStatusToolTip to set - */ - public void setPollStatusToolTip(final String pollStatusToolTip) { - this.pollStatusToolTip = pollStatusToolTip; - } + /** + * @param pollStatusToolTip + * the pollStatusToolTip to set + */ + public void setPollStatusToolTip(final String pollStatusToolTip) { + this.pollStatusToolTip = pollStatusToolTip; + } - /** - * @return the status - */ - public Status getStatus() { - return status; - } + /** + * @return the status + */ + public Status getStatus() { + return status; + } - /** - * @param status - * the status to set - */ - public void setStatus(final Status status) { - this.status = status; - } + /** + * @param status + * the status to set + */ + public void setStatus(final Status status) { + this.status = status; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index d067b388b..cf8a514d4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -57,259 +57,259 @@ import com.vaadin.ui.themes.ValoTheme; @ViewScope public class CreateOrUpdateFilterTable extends Table { - private static final long serialVersionUID = 6887304217281629713L; + private static final long serialVersionUID = 6887304217281629713L; - @Autowired - private I18N i18n; + @Autowired + private I18N i18n; - @Autowired - private transient EventBus.SessionEventBus eventBus; + @Autowired + private transient EventBus.SessionEventBus eventBus; - @Autowired - private FilterManagementUIState filterManagementUIState; + @Autowired + private FilterManagementUIState filterManagementUIState; - private LazyQueryContainer container; + private LazyQueryContainer container; - private static final int PROPERTY_DEPT = 3; + private static final int PROPERTY_DEPT = 3; - private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; - private static final String INSTALL_DIST_SET = "installedDistributionSet"; + private static final String INSTALL_DIST_SET = "installedDistributionSet"; - /** - * Initialize the Action History Table. - */ - @PostConstruct - public void init() { - setStyleName("sp-table"); - setSizeFull(); - setImmediate(true); - setHeight(100.0f, Unit.PERCENTAGE); - addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); - addStyleName(ValoTheme.TABLE_SMALL); - setColumnCollapsingAllowed(true); - addCustomGeneratedColumns(); - restoreOnLoad(); - populateTableData(); - setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); - setSelectable(false); - eventBus.subscribe(this); - setItemDescriptionGenerator(new TooltipGenerator()); - } + /** + * Initialize the Action History Table. + */ + @PostConstruct + public void init() { + setStyleName("sp-table"); + setSizeFull(); + setImmediate(true); + setHeight(100.0f, Unit.PERCENTAGE); + addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); + addStyleName(ValoTheme.TABLE_SMALL); + setColumnCollapsingAllowed(true); + addCustomGeneratedColumns(); + restoreOnLoad(); + populateTableData(); + setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); + setSelectable(false); + eventBus.subscribe(this); + setItemDescriptionGenerator(new TooltipGenerator()); + } - @PreDestroy - void destroy() { - eventBus.unsubscribe(this); - } + @PreDestroy + void destroy() { + eventBus.unsubscribe(this); + } - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final CustomFilterUIEvent custFUIEvent) { - if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW - || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { - UI.getCurrent().access(() -> populateTableData()); - } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { - UI.getCurrent().access(() -> onQuery()); - } - } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final CustomFilterUIEvent custFUIEvent) { + if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW + || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { + UI.getCurrent().access(() -> populateTableData()); + } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { + UI.getCurrent().access(() -> onQuery()); + } + } - private void restoreOnLoad() { - if (filterManagementUIState.isCreateFilterViewDisplayed()) { - filterManagementUIState.setFilterQueryValue(null); - } else { - filterManagementUIState.getTfQuery() - .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); - } - } + private void restoreOnLoad() { + if (filterManagementUIState.isCreateFilterViewDisplayed()) { + filterManagementUIState.setFilterQueryValue(null); + } else { + filterManagementUIState.getTfQuery() + .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); + } + } - /** - * Create a empty HierarchicalContainer. - */ - private LazyQueryContainer createContainer() { - // ADD all the filters to the query config - final Map queryConfig = prepareQueryConfigFilters(); + /** + * Create a empty HierarchicalContainer. + */ + private LazyQueryContainer createContainer() { + // ADD all the filters to the query config + final Map queryConfig = prepareQueryConfigFilters(); - // Create TargetBeanQuery factory with the query config. - final BeanQueryFactory targetQF = new BeanQueryFactory<>(CustomTargetBeanQuery.class); - targetQF.setQueryConfiguration(queryConfig); + // Create TargetBeanQuery factory with the query config. + final BeanQueryFactory targetQF = new BeanQueryFactory<>(CustomTargetBeanQuery.class); + targetQF.setQueryConfiguration(queryConfig); - // create lazy query container with lazy defination and query - final LazyQueryContainer targetTableContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), - targetQF); - targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); + // create lazy query container with lazy defination and query + final LazyQueryContainer targetTableContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), + targetQF); + targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); - return targetTableContainer; + return targetTableContainer; - } + } - private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap<>(); - if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) { - queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue()); - } - queryConfig.put(SPUIDefinitions.FILTER_BY_INVALID_QUERY, - filterManagementUIState.getIsFilterByInvalidFilterQuery()); - return queryConfig; - } + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap<>(); + if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) { + queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue()); + } + queryConfig.put(SPUIDefinitions.FILTER_BY_INVALID_QUERY, + filterManagementUIState.getIsFilterByInvalidFilterQuery()); + return queryConfig; + } - /** - * populate campaign data. - * - */ - public void populateTableData() { - container = createContainer(); - setContainerDataSource(container); - addContainerproperties(); - setColumnProperties(); - setPageLength(30); - setCollapsibleColumns(); - } + /** + * populate campaign data. + * + */ + public void populateTableData() { + container = createContainer(); + setContainerDataSource(container); + addContainerproperties(); + setColumnProperties(); + setPageLength(30); + setCollapsibleColumns(); + } - private void setCollapsibleColumns() { - setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true); - setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true); + private void setCollapsibleColumns() { + setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true); + setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true); - setColumnCollapsed(ASSIGN_DIST_SET, true); - setColumnCollapsed(INSTALL_DIST_SET, true); - } + setColumnCollapsed(ASSIGN_DIST_SET, true); + setColumnCollapsed(INSTALL_DIST_SET, true); + } - /** - * Create a empty HierarchicalContainer. - */ - private void addContainerproperties() { - /* Create HierarchicalContainer container */ - container.addContainerProperty(SPUILabelDefinitions.NAME, String.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); - container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); - container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); - container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null); - container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); + /** + * Create a empty HierarchicalContainer. + */ + private void addContainerproperties() { + /* Create HierarchicalContainer container */ + container.addContainerProperty(SPUILabelDefinitions.NAME, String.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); + container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); + container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); + container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null); + container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); - container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true); - container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true); - } + container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true); + container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true); + } - private List getVisbleColumns() { - final List columnList = new ArrayList<>(); - columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); - columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, - i18n.get("header.assigned.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, - i18n.get("header.installed.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); - return columnList; - } + private List getVisbleColumns() { + final List columnList = new ArrayList<>(); + columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); + columnList.add( + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, + i18n.get("header.assigned.ds"), 0.125F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + i18n.get("header.installed.ds"), 0.125F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); + return columnList; + } - private Component getStatusIcon(final Object itemId) { - final Item row1 = getItem(itemId); - final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 - .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); - final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); - label.setContentMode(ContentMode.HTML); - if (targetStatus == TargetUpdateStatus.PENDING) { - label.setDescription("Pending"); - label.setStyleName("statusIconYellow"); - label.setValue(FontAwesome.ADJUST.getHtml()); - } else if (targetStatus == TargetUpdateStatus.REGISTERED) { - label.setDescription("Registered"); - label.setStyleName("statusIconLightBlue"); - label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml()); - } else if (targetStatus == TargetUpdateStatus.ERROR) { - label.setDescription(i18n.get("label.error")); - label.setStyleName("statusIconRed"); - label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); - } else if (targetStatus == TargetUpdateStatus.IN_SYNC) { - label.setStyleName("statusIconGreen"); - label.setDescription("In-Synch"); - label.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); - } else if (targetStatus == TargetUpdateStatus.UNKNOWN) { - label.setStyleName("statusIconBlue"); - label.setDescription(i18n.get("label.unknown")); - label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml()); - } - return label; - } + private Component getStatusIcon(final Object itemId) { + final Item row1 = getItem(itemId); + final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 + .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); + final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + label.setContentMode(ContentMode.HTML); + if (targetStatus == TargetUpdateStatus.PENDING) { + label.setDescription("Pending"); + label.setStyleName("statusIconYellow"); + label.setValue(FontAwesome.ADJUST.getHtml()); + } else if (targetStatus == TargetUpdateStatus.REGISTERED) { + label.setDescription("Registered"); + label.setStyleName("statusIconLightBlue"); + label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml()); + } else if (targetStatus == TargetUpdateStatus.ERROR) { + label.setDescription(i18n.get("label.error")); + label.setStyleName("statusIconRed"); + label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); + } else if (targetStatus == TargetUpdateStatus.IN_SYNC) { + label.setStyleName("statusIconGreen"); + label.setDescription("In-Synch"); + label.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); + } else if (targetStatus == TargetUpdateStatus.UNKNOWN) { + label.setStyleName("statusIconBlue"); + label.setDescription(i18n.get("label.unknown")); + label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml()); + } + return label; + } - private void setColumnProperties() { - final List columnList = getVisbleColumns(); - final List swColumnIds = new ArrayList<>(); - for (final TableColumn column : columnList) { - setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader()); - setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio()); - swColumnIds.add(column.getColumnPropertyId()); - } - setVisibleColumns(swColumnIds.toArray()); - } + private void setColumnProperties() { + final List columnList = getVisbleColumns(); + final List swColumnIds = new ArrayList<>(); + for (final TableColumn column : columnList) { + setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader()); + setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio()); + swColumnIds.add(column.getColumnPropertyId()); + } + setVisibleColumns(swColumnIds.toArray()); + } - protected void addCustomGeneratedColumns() { - addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); - } + protected void addCustomGeneratedColumns() { + addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); + } - private void onQuery() { - populateTableData(); - eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); - } + private void onQuery() { + populateTableData(); + eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); + } - public class TooltipGenerator implements ItemDescriptionGenerator { - private static final long serialVersionUID = 688730421728162456L; + public class TooltipGenerator implements ItemDescriptionGenerator { + private static final long serialVersionUID = 688730421728162456L; - @Override - public String generateDescription(Component source, Object itemId, Object propertyId) { - final DistributionSet distributionSet; - final Item item = getItem(itemId); - if (propertyId != null) { - if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } - } - return null; - } + @Override + public String generateDescription(Component source, Object itemId, Object propertyId) { + final DistributionSet distributionSet; + final Item item = getItem(itemId); + if (propertyId != null) { + if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } + } + return null; + } - private String getDSDetails(final DistributionSet distributionSet) { - StringBuilder swModuleNames = new StringBuilder(); - StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = (Set)distributionSet.getModules(); - swModules.forEach(swModule -> { - swModuleNames.append(swModule.getName()); - swModuleNames.append(" , "); - swModuleVendors.append(swModule.getVendor()); - swModuleVendors.append(" , "); - }); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("
    "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append(" Required Migration step : ") - .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append("
  • "); - - stringBuilder.append("
"); - return stringBuilder.toString(); - } + private String getDSDetails(final DistributionSet distributionSet) { + StringBuilder swModuleNames = new StringBuilder(); + StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = (Set) distributionSet.getModules(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("
    "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" Required Migration step : ") + .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append("
  • "); - } + stringBuilder.append("
"); + return stringBuilder.toString(); + } + + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index 943efc262..d127b4198 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -42,188 +42,188 @@ import com.google.common.base.Strings; * */ public class TargetBeanQuery extends AbstractBeanQuery { - private static final long serialVersionUID = -5645680058303167558L; - private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); - private Collection status = null; - private String[] targetTags = null; - private Long distributionId = null; - private String searchText = null; - private Boolean noTagClicked = Boolean.FALSE; - private transient TargetManagement targetManagement; - private transient I18N i18N; - private Long pinnedDistId = null; - private TargetFilterQuery targetFilterQuery; - private ManagementUIState managementUIState; + private static final long serialVersionUID = -5645680058303167558L; + private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); + private Collection status = null; + private String[] targetTags = null; + private Long distributionId = null; + private String searchText = null; + private Boolean noTagClicked = Boolean.FALSE; + private transient TargetManagement targetManagement; + private transient I18N i18N; + private Long pinnedDistId = null; + private TargetFilterQuery targetFilterQuery; + private ManagementUIState managementUIState; - /** - * Parametric Constructor. - * - * @param definition - * as Def - * @param queryConfig - * as Config - * @param sortIds - * as sort - * @param sortStates - * as Sort status - */ - public TargetBeanQuery(final QueryDefinition definition, final Map queryConfig, - final Object[] sortIds, final boolean[] sortStates) { - super(definition, queryConfig, sortIds, sortStates); + /** + * Parametric Constructor. + * + * @param definition + * as Def + * @param queryConfig + * as Config + * @param sortIds + * as sort + * @param sortStates + * as Sort status + */ + public TargetBeanQuery(final QueryDefinition definition, final Map queryConfig, + final Object[] sortIds, final boolean[] sortStates) { + super(definition, queryConfig, sortIds, sortStates); - if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) { - status = (Collection) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS); - targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG); - noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG); - distributionId = (Long) queryConfig.get(SPUIDefinitions.FILTER_BY_DISTRIBUTION); - searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); - targetFilterQuery = (TargetFilterQuery) queryConfig.get(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY); - if (!Strings.isNullOrEmpty(searchText)) { - searchText = String.format("%%%s%%", searchText); - } - pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION); - } + if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) { + status = (Collection) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS); + targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG); + noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG); + distributionId = (Long) queryConfig.get(SPUIDefinitions.FILTER_BY_DISTRIBUTION); + searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); + targetFilterQuery = (TargetFilterQuery) queryConfig.get(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY); + if (!Strings.isNullOrEmpty(searchText)) { + searchText = String.format("%%%s%%", searchText); + } + pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION); + } - if (HawkbitCommonUtil.checkBolArray(sortStates)) { - // Initalize Sor - sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]); - // Add sort. - for (int targetId = 1; targetId < sortIds.length; targetId++) { - sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId])); - } - } - } + if (HawkbitCommonUtil.checkBolArray(sortStates)) { + // Initalize Sor + sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]); + // Add sort. + for (int targetId = 1; targetId < sortIds.length; targetId++) { + sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId])); + } + } + } - @Override - protected ProxyTarget constructBean() { - return new ProxyTarget(); - } + @Override + protected ProxyTarget constructBean() { + return new ProxyTarget(); + } - @Override - protected List loadBeans(final int startIndex, final int count) { - Slice targetBeans; - final List proxyTargetBeans = new ArrayList<>(); - if (pinnedDistId != null) { - targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet( - new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, - distributionId, status, searchText, noTagClicked, targetTags); - } else if (null != targetFilterQuery) { - targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery, - new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); - } else if (!anyFilterSelected()) { - targetBeans = getTargetManagement().findTargetsAll( - new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); - } else { - targetBeans = getTargetManagement().findTargetByFilters( - new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), status, - searchText, distributionId, noTagClicked, targetTags); - } - for (final Target targ : targetBeans) { - final ProxyTarget prxyTarget = new ProxyTarget(); - prxyTarget.setTargetIdName(targ.getTargetIdName()); - prxyTarget.setName(targ.getName()); - prxyTarget.setDescription(targ.getDescription()); - prxyTarget.setControllerId(targ.getControllerId()); - prxyTarget.setInstallationDate(targ.getTargetInfo().getInstallationDate()); - prxyTarget.setAddress(targ.getTargetInfo().getAddress()); - prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); - prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); - prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); - prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); - prxyTarget.setCreatedAt(targ.getCreatedAt()); - prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); + @Override + protected List loadBeans(final int startIndex, final int count) { + Slice targetBeans; + final List proxyTargetBeans = new ArrayList<>(); + if (pinnedDistId != null) { + targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet( + new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, + distributionId, status, searchText, noTagClicked, targetTags); + } else if (null != targetFilterQuery) { + targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery, + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); + } else if (!anyFilterSelected()) { + targetBeans = getTargetManagement().findTargetsAll( + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); + } else { + targetBeans = getTargetManagement().findTargetByFilters( + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), status, + searchText, distributionId, noTagClicked, targetTags); + } + for (final Target targ : targetBeans) { + final ProxyTarget prxyTarget = new ProxyTarget(); + prxyTarget.setTargetIdName(targ.getTargetIdName()); + prxyTarget.setName(targ.getName()); + prxyTarget.setDescription(targ.getDescription()); + prxyTarget.setControllerId(targ.getControllerId()); + prxyTarget.setInstallationDate(targ.getTargetInfo().getInstallationDate()); + prxyTarget.setAddress(targ.getTargetInfo().getAddress()); + prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); + prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); + prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); + prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); + prxyTarget.setCreatedAt(targ.getCreatedAt()); + prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); - if (pinnedDistId == null) { - prxyTarget.setInstalledDistributionSet(null); - prxyTarget.setAssignedDistributionSet(null); + if (pinnedDistId == null) { + prxyTarget.setInstalledDistributionSet(null); + prxyTarget.setAssignedDistributionSet(null); - } else { - final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); - final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); - prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( - installedDistributionSet.getName(), installedDistributionSet.getVersion())); - prxyTarget.setInstalledDistributionSet(installedDistributionSet); - final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); - prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( - assignedDistributionSet.getName(), assignedDistributionSet.getVersion())); - prxyTarget.setAssignedDistributionSet(assignedDistributionSet); - } + } else { + final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); + final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); + prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( + installedDistributionSet.getName(), installedDistributionSet.getVersion())); + prxyTarget.setInstalledDistributionSet(installedDistributionSet); + final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); + prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( + assignedDistributionSet.getName(), assignedDistributionSet.getVersion())); + prxyTarget.setAssignedDistributionSet(assignedDistributionSet); + } - prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); - prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); - prxyTarget.setTargetInfo(targ.getTargetInfo()); - prxyTarget.setPollStatusToolTip( - HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); - proxyTargetBeans.add(prxyTarget); - } - return proxyTargetBeans; - } + prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); + prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); + prxyTarget.setTargetInfo(targ.getTargetInfo()); + prxyTarget.setPollStatusToolTip( + HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); + proxyTargetBeans.add(prxyTarget); + } + return proxyTargetBeans; + } - private Boolean isTagSelected() { - if (targetTags == null && !noTagClicked) { - return false; - } - return true; - } + private Boolean isTagSelected() { + if (targetTags == null && !noTagClicked) { + return false; + } + return true; + } - @Override - protected void saveBeans(final List addedTargets, final List modifiedTargets, - final List removedTargets) { - // CRUD operations on Target will be done through repository methods - } + @Override + protected void saveBeans(final List addedTargets, final List modifiedTargets, + final List removedTargets) { + // CRUD operations on Target will be done through repository methods + } - private Boolean anyFilterSelected() { - if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()) { - return false; - } - return true; - } + private Boolean anyFilterSelected() { + if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()) { + return false; + } + return true; + } - @Override - public int size() { - final long totSize = getTargetManagement().countTargetsAll(); - long size; - if (null != targetFilterQuery) { - size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery); - } else if (!anyFilterSelected()) { - size = totSize; - } else { - size = getTargetManagement().countTargetByFilters(status, searchText, distributionId, noTagClicked, - targetTags); - } + @Override + public int size() { + final long totSize = getTargetManagement().countTargetsAll(); + long size; + if (null != targetFilterQuery) { + size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery); + } else if (!anyFilterSelected()) { + size = totSize; + } else { + size = getTargetManagement().countTargetByFilters(status, searchText, distributionId, noTagClicked, + targetTags); + } - final ManagementUIState tmpManagementUIState = getManagementUIState(); - tmpManagementUIState.setTargetsCountAll(totSize); - if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { - tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); - size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES; - } else { - tmpManagementUIState.setTargetsTruncated(null); - } + final ManagementUIState tmpManagementUIState = getManagementUIState(); + tmpManagementUIState.setTargetsCountAll(totSize); + if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { + tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); + size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES; + } else { + tmpManagementUIState.setTargetsTruncated(null); + } - return (int) size; - } + return (int) size; + } - private TargetManagement getTargetManagement() { - if (targetManagement == null) { - targetManagement = SpringContextHelper.getBean(TargetManagement.class); - } - return targetManagement; - } + private TargetManagement getTargetManagement() { + if (targetManagement == null) { + targetManagement = SpringContextHelper.getBean(TargetManagement.class); + } + return targetManagement; + } - private ManagementUIState getManagementUIState() { - if (managementUIState == null) { - managementUIState = SpringContextHelper.getBean(ManagementUIState.class); - } - return managementUIState; - } + private ManagementUIState getManagementUIState() { + if (managementUIState == null) { + managementUIState = SpringContextHelper.getBean(ManagementUIState.class); + } + return managementUIState; + } - private I18N getI18N() { - if (i18N == null) { - i18N = SpringContextHelper.getBean(I18N.class); - } - return i18N; - } + private I18N getI18N() { + if (i18N == null) { + i18N = SpringContextHelper.getBean(I18N.class); + } + return i18N; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index f119229b0..a1e759950 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -43,7 +43,6 @@ import org.eclipse.hawkbit.ui.filter.target.CustomTargetFilter; import org.eclipse.hawkbit.ui.filter.target.TargetSearchTextFilter; import org.eclipse.hawkbit.ui.filter.target.TargetStatusFilter; import org.eclipse.hawkbit.ui.filter.target.TargetTagFilter; -import org.eclipse.hawkbit.ui.filtermanagement.CreateOrUpdateFilterTable.TooltipGenerator; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; @@ -96,7 +95,6 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.UI; import com.vaadin.ui.themes.ValoTheme; -import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; /** * Concrete implementation of Target table. @@ -113,9 +111,9 @@ public class TargetTable extends AbstractTable implements private static final int PROPERTY_DEPT = 3; private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed"; - - private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; - private static final String INSTALL_DIST_SET = "installedDistributionSet"; + + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; + private static final String INSTALL_DIST_SET = "installedDistributionSet"; @Autowired private transient TargetManagement targetManagement; @@ -1082,61 +1080,60 @@ public class TargetTable extends AbstractTable implements private boolean isFilteredByTags() { return !managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty(); } - - + /** * tooltip for assignedDS and installedDS */ - + protected class TooltipGenerator implements ItemDescriptionGenerator { - private static final long serialVersionUID = 688730421728162456L; + private static final long serialVersionUID = 688730421728162456L; - @Override - public String generateDescription(Component source, Object itemId, Object propertyId) { - final DistributionSet distributionSet; - final Item item = getItem(itemId); - if (propertyId != null) { - if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } - } - return null; - } + @Override + public String generateDescription(Component source, Object itemId, Object propertyId) { + final DistributionSet distributionSet; + final Item item = getItem(itemId); + if (propertyId != null) { + if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } + } + return null; + } - private String getDSDetails(final DistributionSet distributionSet) { - StringBuilder swModuleNames = new StringBuilder(); - StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = (Set)distributionSet.getModules(); - swModules.forEach(swModule -> { - swModuleNames.append(swModule.getName()); - swModuleNames.append(" , "); - swModuleVendors.append(swModule.getVendor()); - swModuleVendors.append(" , "); - }); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("
    "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append(" Required Migration step : ") - .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append("
  • "); - stringBuilder.append("
"); - return stringBuilder.toString(); - } - } + private String getDSDetails(final DistributionSet distributionSet) { + StringBuilder swModuleNames = new StringBuilder(); + StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = (Set) distributionSet.getModules(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("
    "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" Required Migration step : ") + .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append("
  • "); + stringBuilder.append("
"); + return stringBuilder.toString(); + } + } } \ No newline at end of file diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java index a010a3ba4..04c6659a5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java @@ -22,197 +22,196 @@ import com.vaadin.server.FontAwesome; */ public class ProxyRollout extends Rollout { - private static final long serialVersionUID = 4539849939617681918L; + private static final long serialVersionUID = 4539849939617681918L; - private String distributionSetNameVersion; + private String distributionSetNameVersion; - private String createdDate; + private String createdDate; - private String modifiedDate; + private String modifiedDate; - private Long numberOfGroups; + private Long numberOfGroups; - private Boolean isActionRecieved = Boolean.FALSE; - - private Boolean isRequiredMigrationStep = Boolean.FALSE; + private Boolean isActionRecieved = Boolean.FALSE; - private String totalTargetsCount; + private Boolean isRequiredMigrationStep = Boolean.FALSE; - private RolloutRendererData rolloutRendererData; - - private String discription; + private String totalTargetsCount; - private String type; - - private Set swModules; - - - - /** - * @return the isRequiredMigrationStep - */ + private RolloutRendererData rolloutRendererData; - public Boolean getIsRequiredMigrationStep() { - return isRequiredMigrationStep; - } + private String discription; - /** - * @param isRequiredMigrationStep - * the isRequiredMigrationStep to set - */ + private String type; - public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) { - this.isRequiredMigrationStep = isRequiredMigrationStep; - } + private Set swModules; - - /** - * @return the discription - */ + /** + * @return the isRequiredMigrationStep + */ - public String getDiscription() { - return discription; - } + public Boolean getIsRequiredMigrationStep() { + return isRequiredMigrationStep; + } - /** - * @param discription - * the discription to set - */ + /** + * @param isRequiredMigrationStep + * the isRequiredMigrationStep to set + */ - public void setDiscription(String discription) { - this.discription = discription; - } + public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) { + this.isRequiredMigrationStep = isRequiredMigrationStep; + } - /** - * @return the type - */ - public String getType() { - return type; - } + /** + * @return the discription + */ - /** - * @param type - * the type to set - */ + public String getDiscription() { + return discription; + } - public void setType(String type) { - this.type = type; - } - /** - * - * @return the Set of Software modules - */ - public Set getSwModules() { - return swModules; - } - /** - * @param swModules - * Set to set - */ - public void setSwModules(Set swModules) { - this.swModules = swModules; - } + /** + * @param discription + * the discription to set + */ - public RolloutRendererData getRolloutRendererData() { - return rolloutRendererData; - } + public void setDiscription(String discription) { + this.discription = discription; + } - public void setRolloutRendererData(RolloutRendererData rendererData) { - this.rolloutRendererData = rendererData; - } + /** + * @return the type + */ + public String getType() { + return type; + } - /** - * @return the distributionSetNameVersion - */ - public String getDistributionSetNameVersion() { - return distributionSetNameVersion; - } + /** + * @param type + * the type to set + */ - /** - * @param distributionSetNameVersion - * the distributionSetNameVersion to set - */ - public void setDistributionSetNameVersion(final String distributionSetNameVersion) { - this.distributionSetNameVersion = distributionSetNameVersion; - } + public void setType(String type) { + this.type = type; + } - /** - * @return the numberOfGroups - */ - public Long getNumberOfGroups() { - return numberOfGroups; - } + /** + * + * @return the Set of Software modules + */ + public Set getSwModules() { + return swModules; + } - /** - * @param numberOfGroups - * the numberOfGroups to set - */ - public void setNumberOfGroups(final Long numberOfGroups) { - this.numberOfGroups = numberOfGroups; - } + /** + * @param swModules + * Set to set + */ + public void setSwModules(Set swModules) { + this.swModules = swModules; + } - /** - * @return the createdDate - */ - public String getCreatedDate() { - return createdDate; - } + public RolloutRendererData getRolloutRendererData() { + return rolloutRendererData; + } - /** - * @param createdDate - * the createdDate to set - */ - public void setCreatedDate(final String createdDate) { - this.createdDate = createdDate; - } + public void setRolloutRendererData(RolloutRendererData rendererData) { + this.rolloutRendererData = rendererData; + } - /** - * @return the modifiedDate - */ - public String getModifiedDate() { - return modifiedDate; - } + /** + * @return the distributionSetNameVersion + */ + public String getDistributionSetNameVersion() { + return distributionSetNameVersion; + } - /** - * @param modifiedDate - * the modifiedDate to set - */ - public void setModifiedDate(final String modifiedDate) { - this.modifiedDate = modifiedDate; - } + /** + * @param distributionSetNameVersion + * the distributionSetNameVersion to set + */ + public void setDistributionSetNameVersion(final String distributionSetNameVersion) { + this.distributionSetNameVersion = distributionSetNameVersion; + } - /** - * @return the isActionRecieved - */ - public Boolean getIsActionRecieved() { - return isActionRecieved; - } + /** + * @return the numberOfGroups + */ + public Long getNumberOfGroups() { + return numberOfGroups; + } - /** - * @param isActionRecieved - * the isActionRecieved to set - */ - public void setIsActionRecieved(final Boolean isActionRecieved) { - this.isActionRecieved = isActionRecieved; - } + /** + * @param numberOfGroups + * the numberOfGroups to set + */ + public void setNumberOfGroups(final Long numberOfGroups) { + this.numberOfGroups = numberOfGroups; + } - /** - * @return the totalTargetsCount - */ - public String getTotalTargetsCount() { - return totalTargetsCount; - } + /** + * @return the createdDate + */ + public String getCreatedDate() { + return createdDate; + } - /** - * @param totalTargetsCount - * the totalTargetsCount to set - */ - public void setTotalTargetsCount(final String totalTargetsCount) { - this.totalTargetsCount = totalTargetsCount; - } + /** + * @param createdDate + * the createdDate to set + */ + public void setCreatedDate(final String createdDate) { + this.createdDate = createdDate; + } - public String getAction() { - return FontAwesome.CIRCLE_O.getHtml(); - } + /** + * @return the modifiedDate + */ + public String getModifiedDate() { + return modifiedDate; + } + + /** + * @param modifiedDate + * the modifiedDate to set + */ + public void setModifiedDate(final String modifiedDate) { + this.modifiedDate = modifiedDate; + } + + /** + * @return the isActionRecieved + */ + public Boolean getIsActionRecieved() { + return isActionRecieved; + } + + /** + * @param isActionRecieved + * the isActionRecieved to set + */ + public void setIsActionRecieved(final Boolean isActionRecieved) { + this.isActionRecieved = isActionRecieved; + } + + /** + * @return the totalTargetsCount + */ + public String getTotalTargetsCount() { + return totalTargetsCount; + } + + /** + * @param totalTargetsCount + * the totalTargetsCount to set + */ + public void setTotalTargetsCount(final String totalTargetsCount) { + this.totalTargetsCount = totalTargetsCount; + } + + public String getAction() { + return FontAwesome.CIRCLE_O.getHtml(); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java index 41f69acb1..8a9675564 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java @@ -138,11 +138,11 @@ public class RolloutBeanQuery extends AbstractBeanQuery { final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus(); proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus); proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets())); - - proxyRollout.setDescription(distributionSet.getDescription()); - proxyRollout.setType(distributionSet.getType().getName()); - proxyRollout.setIsRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); - proxyRollout.setSwModules(distributionSet.getModules()); + + proxyRollout.setDescription(distributionSet.getDescription()); + proxyRollout.setType(distributionSet.getType().getName()); + proxyRollout.setIsRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); + proxyRollout.setSwModules(distributionSet.getModules()); proxyRolloutList.add(proxyRollout); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index c68bbf700..1ad0bfc35 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -70,619 +70,619 @@ import com.vaadin.ui.renderers.HtmlRenderer; @ViewScope public class RolloutListGrid extends AbstractGrid { - private static final long serialVersionUID = 4060904914954370524L; - - private static final String UPDATE_OPTION = "Update"; - - private static final String RESUME_OPTION = "Resume"; - - private static final String PAUSE_OPTION = "Pause"; - - private static final String START_OPTION = "Start"; - - private static final String DS_TYPE = "type"; - - private static final String SW_MODULES = "swModules"; - - private static final String IS_REQUIRED_MIGRATION_STEP = "isRequiredMigrationStep"; - - private static final String ROLLOUT_RENDERER_DATA = "rolloutRendererData"; - - @Autowired - private transient RolloutManagement rolloutManagement; - - @Autowired - private AddUpdateRolloutWindowLayout addUpdateRolloutWindow; - - @Autowired - private UINotification uiNotification; - - @Autowired - private transient RolloutUIState rolloutUIState; - - @Autowired - private transient SpPermissionChecker permissionChecker; - - private transient Map statusIconMap = new EnumMap<>(RolloutStatus.class); - - /** - * Handles the RolloutEvent to refresh Grid. - * - */ - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final RolloutEvent event) { - switch (event) { - case FILTER_BY_TEXT: - case CREATE_ROLLOUT: - case UPDATE_ROLLOUT: - case SHOW_ROLLOUTS: - refreshGrid(); - break; - default: - return; - } - } - - /** - * Handles the RolloutChangeEvent to refresh the item in the grid. - * - * @param rolloutChangeEvent - * the event which contains the rollout which has been changed - */ - @SuppressWarnings("unchecked") - @EventBusListenerMethod(scope = EventScope.SESSION) - public void onEvent(final RolloutChangeEvent rolloutChangeEvent) { - if (!rolloutUIState.isShowRollOuts()) { - return; - } - final Rollout rollout = rolloutManagement.findRolloutWithDetailedStatus(rolloutChangeEvent.getRolloutId()); - final TotalTargetCountStatus totalTargetCountStatus = rollout.getTotalTargetCountStatus(); - final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource(); - final Item item = rolloutContainer.getItem(rolloutChangeEvent.getRolloutId()); - if (item == null) { - return; - } - item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus()); - item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus); - final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue(); - final int groupsCreated = rollout.getRolloutGroupsCreated(); - if (groupsCreated != 0) { - item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated)); - } else if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) { - item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS) - .setValue(Long.valueOf(rollout.getRolloutGroups().size())); - } - item.getItemProperty(ROLLOUT_RENDERER_DATA) - .setValue(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString())); - - } - - @Override - protected Container createContainer() { - final BeanQueryFactory rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class); - return new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf); - } - - @Override - protected void addContainerProperties() { - final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource(); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); - rolloutGridContainer.addContainerProperty(DS_TYPE, String.class, null, false, false); - rolloutGridContainer.addContainerProperty(SW_MODULES, Set.class, null, false, false); - rolloutGridContainer.addContainerProperty(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false); - rolloutGridContainer.addContainerProperty(IS_REQUIRED_MIGRATION_STEP, boolean.class, null, false, false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, - false); - - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Long.class, 0, false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false, - false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, - TotalTargetCountStatus.class, null, false, false); - - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.ACTION, String.class, - FontAwesome.CIRCLE_O.getHtml(), false, false); - - } - - @Override - protected void setColumnExpandRatio() { - - getColumn(ROLLOUT_RENDERER_DATA).setMinimumWidth(40); - getColumn(ROLLOUT_RENDERER_DATA).setMaximumWidth(150); - - getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40); - getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150); - - getColumn(SPUILabelDefinitions.VAR_STATUS).setMinimumWidth(75); - getColumn(SPUILabelDefinitions.VAR_STATUS).setMaximumWidth(75); - - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100); - - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40); - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100); - - getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75); - getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75); - - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280); - - setFrozenColumnCount(getColumns().size()); - } - - @Override - protected void setColumnHeaderNames() { - getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); - getColumn(DS_TYPE).setHeaderCaption("Type"); - getColumn(SW_MODULES).setHeaderCaption("swModules"); - getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption("IsRequiredMigrationStep"); - getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset")); - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); - getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); - getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy")); - getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); - getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); - getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description")); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) - .setHeaderCaption(i18n.get("header.detail.status")); - getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); - getColumn(SPUILabelDefinitions.ACTION).setHeaderCaption(i18n.get("upload.action")); - } - - @Override - protected String getGridId() { - return SPUIComponetIdProvider.ROLLOUT_LIST_GRID_ID; - } - - @Override - protected void setColumnProperties() { - final List columnList = new ArrayList<>(); - columnList.add(ROLLOUT_RENDERER_DATA); - columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); - columnList.add(DS_TYPE); - columnList.add(SW_MODULES); - columnList.add(IS_REQUIRED_MIGRATION_STEP); - columnList.add(SPUILabelDefinitions.VAR_STATUS); - columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); - columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); - columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS); - columnList.add(SPUILabelDefinitions.ACTION); - - columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE); - columnList.add(SPUILabelDefinitions.VAR_CREATED_USER); - columnList.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); - columnList.add(SPUILabelDefinitions.VAR_MODIFIED_BY); - columnList.add(SPUILabelDefinitions.VAR_DESC); - setColumnOrder(columnList.toArray()); - alignColumns(); - } - - @Override - protected void setHiddenColumns() { - final List columnsToBeHidden = new ArrayList<>(); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY); - columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC); - columnsToBeHidden.add(IS_REQUIRED_MIGRATION_STEP); - columnsToBeHidden.add(DS_TYPE); - columnsToBeHidden.add(SW_MODULES); - for (final Object propertyId : columnsToBeHidden) { - getColumn(propertyId).setHidden(true); - } - - } - - @Override - protected CellDescriptionGenerator getDescriptionGenerator() { - return cell -> getDescription(cell); - } - - @Override - protected void addColumnRenderes() { - getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(), - new TotalTargetGroupsConverter()); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), - new TotalTargetCountStatusConverter()); - - createRolloutStatusToFontMap(); - getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); - - getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event))); - - final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class); - customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event)); - getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer); - - } - - private void createRolloutStatusToFontMap() { - statusIconMap.put(RolloutStatus.FINISHED, - new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN)); - statusIconMap.put(RolloutStatus.PAUSED, - new StatusFontIcon(FontAwesome.PAUSE, SPUIStyleDefinitions.STATUS_ICON_BLUE)); - statusIconMap.put(RolloutStatus.RUNNING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_YELLOW)); - statusIconMap.put(RolloutStatus.READY, - new StatusFontIcon(FontAwesome.DOT_CIRCLE_O, SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE)); - statusIconMap.put(RolloutStatus.STOPPED, - new StatusFontIcon(FontAwesome.STOP, SPUIStyleDefinitions.STATUS_ICON_RED)); - statusIconMap.put(RolloutStatus.CREATING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_GREY)); - statusIconMap.put(RolloutStatus.STARTING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_BLUE)); - statusIconMap.put(RolloutStatus.ERROR_CREATING, - new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); - statusIconMap.put(RolloutStatus.ERROR_STARTING, - new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); - } - - private void alignColumns() { - setCellStyleGenerator(new CellStyleGenerator() { - private static final long serialVersionUID = 5573570647129792429L; - - @Override - public String getStyle(final CellReference cellReference) { - final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION }; - if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) { - return "centeralign"; - } - return null; - } - }); - } - - private void onClickOfRolloutName(final RendererClickEvent event) { - rolloutUIState.setRolloutId((long) event.getItemId()); - final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId()) - .getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); - rolloutUIState.setRolloutName(rolloutName); - final String ds = (String) getContainerDataSource().getItem(event.getItemId()) - .getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue(); - rolloutUIState.setRolloutDistributionSet(ds); - eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS); - } - - private void onClickOfActionBtn(final RendererClickEvent event) { - final ContextMenu contextMenu = createContextMenu((Long) event.getItemId()); - contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent()); - contextMenu.open(event.getClientX(), event.getClientY()); - } - - private ContextMenu createContextMenu(final Long rolloutId) { - final ContextMenu context = new ContextMenu(); - context.addItemClickListener(event -> menuItemClicked(event)); - final Item row = getContainerDataSource().getItem(rolloutId); - final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS) - .getValue(); - - switch (rolloutStatus) { - case READY: - final ContextMenuItem startItem = context.addItem(START_OPTION); - startItem.setData(new ContextMenuData(rolloutId, ACTION.START)); - break; - case RUNNING: - final ContextMenuItem pauseItem = context.addItem(PAUSE_OPTION); - pauseItem.setData(new ContextMenuData(rolloutId, ACTION.PAUSE)); - break; - case PAUSED: - final ContextMenuItem resumeItem = context.addItem(RESUME_OPTION); - resumeItem.setData(new ContextMenuData(rolloutId, ACTION.RESUME)); - break; - case STARTING: - case CREATING: - case ERROR_CREATING: - case ERROR_STARTING: - // do not provide any action on these statuses - return context; - default: - break; - } - getUpdateMenuItem(context, rolloutId); - return context; - } - - private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) { - // Add 'Update' option only if user has update permission - if (!permissionChecker.hasRolloutUpdatePermission()) { - return; - } - final ContextMenuItem cancelItem = context.addItem(UPDATE_OPTION); - cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE)); - } - - private void menuItemClicked(final ContextMenuItemClickEvent event) { - final ContextMenuItem item = (ContextMenuItem) event.getSource(); - final ContextMenuData contextMenuData = (ContextMenuData) item.getData(); - final Item row = getContainerDataSource().getItem(contextMenuData.getRolloutId()); - final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); - switch (contextMenuData.getAction()) { - case PAUSE: - rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); - uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); - break; - case RESUME: - rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); - uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName)); - break; - case START: - rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName)); - uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName)); - break; - case UPDATE: - onUpdate(contextMenuData); - break; - default: - break; - } - } - - private void onUpdate(final ContextMenuData contextMenuData) { - addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId()); - final Window addTargetWindow = addUpdateRolloutWindow.getWindow(); - addTargetWindow.setCaption(i18n.get("caption.update.rollout")); - UI.getCurrent().addWindow(addTargetWindow); - addTargetWindow.setVisible(Boolean.TRUE); - } - - private void refreshGrid() { - ((LazyQueryContainer) getContainerDataSource()).refresh(); - } - - /** - * Generator to generate fontIcon by String. - */ - public final class FontIconGenerator extends PropertyValueGenerator { - - private static final long serialVersionUID = 2544026030795375748L; - private final FontAwesome fontIcon; - - public FontIconGenerator(final FontAwesome icon) { - this.fontIcon = icon; - } - - @Override - public String getValue(final Item item, final Object itemId, final Object propertyId) { - return fontIcon.getHtml(); - } - - @Override - public Class getType() { - return String.class; - } - } - - private String getDescription(final CellReference cell) { - if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { - return cell.getProperty().getValue().toString().toLowerCase(); - } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { - return SPUILabelDefinitions.ACTION.toLowerCase(); - } else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) { - return ((RolloutRendererData) cell.getProperty().getValue()).getName(); - } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { - return DistributionBarHelper - .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); - } else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) { - return getDSDetails((Item) cell.getItem()); - } - return null; - } - - private String getDSDetails(final Item rolloutItem) { - StringBuilder swModuleNames = new StringBuilder(); - StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = (Set) rolloutItem.getItemProperty(SW_MODULES).getValue(); - swModules.forEach(swModule -> { - swModuleNames.append(swModule.getName()); - swModuleNames.append(" , "); - swModuleVendors.append(swModule.getVendor()); - swModuleVendors.append(" , "); - }); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("
    "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Description : ") - .append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Type : ") - .append((String) rolloutItem.getItemProperty(DS_TYPE).getValue()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); - stringBuilder.append("Required Migration step : ") - .append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No"); - stringBuilder.append("
  • "); - - stringBuilder.append("
  • "); - stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append("
  • "); - - stringBuilder.append("
  • "); - stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append("
  • "); - - stringBuilder.append("
"); - return stringBuilder.toString(); - } - - enum ACTION { - PAUSE, RESUME, START, UPDATE - } - - /** - * Represents data of context menu item. - * - */ - public static class ContextMenuData { - - private Long rolloutId; - - private ACTION action; - - /** - * Set rollout if and action. - * - * @param rolloutId - * id of rollout - * @param action - * user action {@link ACTION} - */ - public ContextMenuData(final Long rolloutId, final ACTION action) { - this.action = action; - this.rolloutId = rolloutId; - } - - /** - * @return the rolloutId - */ - public Long getRolloutId() { - return rolloutId; - } - - /** - * @param rolloutId - * the rolloutId to set - */ - public void setRolloutId(final Long rolloutId) { - this.rolloutId = rolloutId; - } - - /** - * @return the action - */ - public ACTION getAction() { - return action; - } - - /** - * @param action - * the action to set - */ - public void setAction(final ACTION action) { - this.action = action; - } - } - - /** - * - * Converter to convert {@link RolloutStatus} to string. - * - */ - class RolloutStatusConverter implements Converter { - - private static final long serialVersionUID = -1217685750825632678L; - - @Override - public RolloutStatus convertToModel(final String value, final Class targetType, - final Locale locale) { - return null; - } - - @Override - public String convertToPresentation(final RolloutStatus value, final Class targetType, - final Locale locale) { - return convertRolloutStatusToString(value); - } - - @Override - public Class getModelType() { - return RolloutStatus.class; - } - - @Override - public Class getPresentationType() { - return String.class; - } - - private String convertRolloutStatusToString(final RolloutStatus value) { - final StatusFontIcon statusFontIcon = statusIconMap.get(value); - final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon); - return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), - SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID); - } - } - - /** - * Converter to convert {@link TotalTargetCountStatus} to formatted string - * with status and count details. - * - */ - class TotalTargetCountStatusConverter implements Converter { - - private static final long serialVersionUID = -5794528427855153924L; - - @Override - public TotalTargetCountStatus convertToModel(final String value, - final Class targetType, final Locale locale) - throws com.vaadin.data.util.converter.Converter.ConversionException { - return null; - } - - @Override - public String convertToPresentation(final TotalTargetCountStatus value, - final Class targetType, final Locale locale) - throws com.vaadin.data.util.converter.Converter.ConversionException { - return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); - } - - @Override - public Class getModelType() { - return TotalTargetCountStatus.class; - } - - @Override - public Class getPresentationType() { - return String.class; - } - } - - /** - * Converter to convert 0 to empty, if total target groups is zero. - * - */ - class TotalTargetGroupsConverter implements Converter { - - private static final long serialVersionUID = 6589305227035220369L; - - @Override - public Long convertToModel(final String value, final Class targetType, final Locale locale) - throws com.vaadin.data.util.converter.Converter.ConversionException { - return null; - } - - @Override - public String convertToPresentation(final Long value, final Class targetType, - final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { - if (value == 0) { - return ""; - } - return value.toString(); - } - - @Override - public Class getModelType() { - return Long.class; - } - - @Override - public Class getPresentationType() { - return String.class; - } - - } + private static final long serialVersionUID = 4060904914954370524L; + + private static final String UPDATE_OPTION = "Update"; + + private static final String RESUME_OPTION = "Resume"; + + private static final String PAUSE_OPTION = "Pause"; + + private static final String START_OPTION = "Start"; + + private static final String DS_TYPE = "type"; + + private static final String SW_MODULES = "swModules"; + + private static final String IS_REQUIRED_MIGRATION_STEP = "isRequiredMigrationStep"; + + private static final String ROLLOUT_RENDERER_DATA = "rolloutRendererData"; + + @Autowired + private transient RolloutManagement rolloutManagement; + + @Autowired + private AddUpdateRolloutWindowLayout addUpdateRolloutWindow; + + @Autowired + private UINotification uiNotification; + + @Autowired + private transient RolloutUIState rolloutUIState; + + @Autowired + private transient SpPermissionChecker permissionChecker; + + private transient Map statusIconMap = new EnumMap<>(RolloutStatus.class); + + /** + * Handles the RolloutEvent to refresh Grid. + * + */ + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final RolloutEvent event) { + switch (event) { + case FILTER_BY_TEXT: + case CREATE_ROLLOUT: + case UPDATE_ROLLOUT: + case SHOW_ROLLOUTS: + refreshGrid(); + break; + default: + return; + } + } + + /** + * Handles the RolloutChangeEvent to refresh the item in the grid. + * + * @param rolloutChangeEvent + * the event which contains the rollout which has been changed + */ + @SuppressWarnings("unchecked") + @EventBusListenerMethod(scope = EventScope.SESSION) + public void onEvent(final RolloutChangeEvent rolloutChangeEvent) { + if (!rolloutUIState.isShowRollOuts()) { + return; + } + final Rollout rollout = rolloutManagement.findRolloutWithDetailedStatus(rolloutChangeEvent.getRolloutId()); + final TotalTargetCountStatus totalTargetCountStatus = rollout.getTotalTargetCountStatus(); + final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource(); + final Item item = rolloutContainer.getItem(rolloutChangeEvent.getRolloutId()); + if (item == null) { + return; + } + item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus()); + item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus); + final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue(); + final int groupsCreated = rollout.getRolloutGroupsCreated(); + if (groupsCreated != 0) { + item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated)); + } else if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) { + item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS) + .setValue(Long.valueOf(rollout.getRolloutGroups().size())); + } + item.getItemProperty(ROLLOUT_RENDERER_DATA) + .setValue(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString())); + + } + + @Override + protected Container createContainer() { + final BeanQueryFactory rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class); + return new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf); + } + + @Override + protected void addContainerProperties() { + final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource(); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); + rolloutGridContainer.addContainerProperty(DS_TYPE, String.class, null, false, false); + rolloutGridContainer.addContainerProperty(SW_MODULES, Set.class, null, false, false); + rolloutGridContainer.addContainerProperty(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false); + rolloutGridContainer.addContainerProperty(IS_REQUIRED_MIGRATION_STEP, boolean.class, null, false, false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, + false); + + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Long.class, 0, false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false, + false); + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, + TotalTargetCountStatus.class, null, false, false); + + rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.ACTION, String.class, + FontAwesome.CIRCLE_O.getHtml(), false, false); + + } + + @Override + protected void setColumnExpandRatio() { + + getColumn(ROLLOUT_RENDERER_DATA).setMinimumWidth(40); + getColumn(ROLLOUT_RENDERER_DATA).setMaximumWidth(150); + + getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40); + getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150); + + getColumn(SPUILabelDefinitions.VAR_STATUS).setMinimumWidth(75); + getColumn(SPUILabelDefinitions.VAR_STATUS).setMaximumWidth(75); + + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100); + + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40); + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100); + + getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75); + getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75); + + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280); + + setFrozenColumnCount(getColumns().size()); + } + + @Override + protected void setColumnHeaderNames() { + getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); + getColumn(DS_TYPE).setHeaderCaption("Type"); + getColumn(SW_MODULES).setHeaderCaption("swModules"); + getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption("IsRequiredMigrationStep"); + getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset")); + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); + getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); + getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy")); + getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); + getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); + getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description")); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) + .setHeaderCaption(i18n.get("header.detail.status")); + getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); + getColumn(SPUILabelDefinitions.ACTION).setHeaderCaption(i18n.get("upload.action")); + } + + @Override + protected String getGridId() { + return SPUIComponetIdProvider.ROLLOUT_LIST_GRID_ID; + } + + @Override + protected void setColumnProperties() { + final List columnList = new ArrayList<>(); + columnList.add(ROLLOUT_RENDERER_DATA); + columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); + columnList.add(DS_TYPE); + columnList.add(SW_MODULES); + columnList.add(IS_REQUIRED_MIGRATION_STEP); + columnList.add(SPUILabelDefinitions.VAR_STATUS); + columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); + columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); + columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS); + columnList.add(SPUILabelDefinitions.ACTION); + + columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE); + columnList.add(SPUILabelDefinitions.VAR_CREATED_USER); + columnList.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); + columnList.add(SPUILabelDefinitions.VAR_MODIFIED_BY); + columnList.add(SPUILabelDefinitions.VAR_DESC); + setColumnOrder(columnList.toArray()); + alignColumns(); + } + + @Override + protected void setHiddenColumns() { + final List columnsToBeHidden = new ArrayList<>(); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY); + columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC); + columnsToBeHidden.add(IS_REQUIRED_MIGRATION_STEP); + columnsToBeHidden.add(DS_TYPE); + columnsToBeHidden.add(SW_MODULES); + for (final Object propertyId : columnsToBeHidden) { + getColumn(propertyId).setHidden(true); + } + + } + + @Override + protected CellDescriptionGenerator getDescriptionGenerator() { + return cell -> getDescription(cell); + } + + @Override + protected void addColumnRenderes() { + getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(), + new TotalTargetGroupsConverter()); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), + new TotalTargetCountStatusConverter()); + + createRolloutStatusToFontMap(); + getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); + + getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event))); + + final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class); + customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event)); + getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer); + + } + + private void createRolloutStatusToFontMap() { + statusIconMap.put(RolloutStatus.FINISHED, + new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN)); + statusIconMap.put(RolloutStatus.PAUSED, + new StatusFontIcon(FontAwesome.PAUSE, SPUIStyleDefinitions.STATUS_ICON_BLUE)); + statusIconMap.put(RolloutStatus.RUNNING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_YELLOW)); + statusIconMap.put(RolloutStatus.READY, + new StatusFontIcon(FontAwesome.DOT_CIRCLE_O, SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE)); + statusIconMap.put(RolloutStatus.STOPPED, + new StatusFontIcon(FontAwesome.STOP, SPUIStyleDefinitions.STATUS_ICON_RED)); + statusIconMap.put(RolloutStatus.CREATING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_GREY)); + statusIconMap.put(RolloutStatus.STARTING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_BLUE)); + statusIconMap.put(RolloutStatus.ERROR_CREATING, + new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); + statusIconMap.put(RolloutStatus.ERROR_STARTING, + new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); + } + + private void alignColumns() { + setCellStyleGenerator(new CellStyleGenerator() { + private static final long serialVersionUID = 5573570647129792429L; + + @Override + public String getStyle(final CellReference cellReference) { + final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION }; + if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) { + return "centeralign"; + } + return null; + } + }); + } + + private void onClickOfRolloutName(final RendererClickEvent event) { + rolloutUIState.setRolloutId((long) event.getItemId()); + final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId()) + .getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); + rolloutUIState.setRolloutName(rolloutName); + final String ds = (String) getContainerDataSource().getItem(event.getItemId()) + .getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue(); + rolloutUIState.setRolloutDistributionSet(ds); + eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS); + } + + private void onClickOfActionBtn(final RendererClickEvent event) { + final ContextMenu contextMenu = createContextMenu((Long) event.getItemId()); + contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent()); + contextMenu.open(event.getClientX(), event.getClientY()); + } + + private ContextMenu createContextMenu(final Long rolloutId) { + final ContextMenu context = new ContextMenu(); + context.addItemClickListener(event -> menuItemClicked(event)); + final Item row = getContainerDataSource().getItem(rolloutId); + final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS) + .getValue(); + + switch (rolloutStatus) { + case READY: + final ContextMenuItem startItem = context.addItem(START_OPTION); + startItem.setData(new ContextMenuData(rolloutId, ACTION.START)); + break; + case RUNNING: + final ContextMenuItem pauseItem = context.addItem(PAUSE_OPTION); + pauseItem.setData(new ContextMenuData(rolloutId, ACTION.PAUSE)); + break; + case PAUSED: + final ContextMenuItem resumeItem = context.addItem(RESUME_OPTION); + resumeItem.setData(new ContextMenuData(rolloutId, ACTION.RESUME)); + break; + case STARTING: + case CREATING: + case ERROR_CREATING: + case ERROR_STARTING: + // do not provide any action on these statuses + return context; + default: + break; + } + getUpdateMenuItem(context, rolloutId); + return context; + } + + private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) { + // Add 'Update' option only if user has update permission + if (!permissionChecker.hasRolloutUpdatePermission()) { + return; + } + final ContextMenuItem cancelItem = context.addItem(UPDATE_OPTION); + cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE)); + } + + private void menuItemClicked(final ContextMenuItemClickEvent event) { + final ContextMenuItem item = (ContextMenuItem) event.getSource(); + final ContextMenuData contextMenuData = (ContextMenuData) item.getData(); + final Item row = getContainerDataSource().getItem(contextMenuData.getRolloutId()); + final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); + switch (contextMenuData.getAction()) { + case PAUSE: + rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); + uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); + break; + case RESUME: + rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); + uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName)); + break; + case START: + rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName)); + uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName)); + break; + case UPDATE: + onUpdate(contextMenuData); + break; + default: + break; + } + } + + private void onUpdate(final ContextMenuData contextMenuData) { + addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId()); + final Window addTargetWindow = addUpdateRolloutWindow.getWindow(); + addTargetWindow.setCaption(i18n.get("caption.update.rollout")); + UI.getCurrent().addWindow(addTargetWindow); + addTargetWindow.setVisible(Boolean.TRUE); + } + + private void refreshGrid() { + ((LazyQueryContainer) getContainerDataSource()).refresh(); + } + + /** + * Generator to generate fontIcon by String. + */ + public final class FontIconGenerator extends PropertyValueGenerator { + + private static final long serialVersionUID = 2544026030795375748L; + private final FontAwesome fontIcon; + + public FontIconGenerator(final FontAwesome icon) { + this.fontIcon = icon; + } + + @Override + public String getValue(final Item item, final Object itemId, final Object propertyId) { + return fontIcon.getHtml(); + } + + @Override + public Class getType() { + return String.class; + } + } + + private String getDescription(final CellReference cell) { + if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { + return cell.getProperty().getValue().toString().toLowerCase(); + } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { + return SPUILabelDefinitions.ACTION.toLowerCase(); + } else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) { + return ((RolloutRendererData) cell.getProperty().getValue()).getName(); + } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { + return DistributionBarHelper + .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); + } else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) { + return getDSDetails((Item) cell.getItem()); + } + return null; + } + + private String getDSDetails(final Item rolloutItem) { + StringBuilder swModuleNames = new StringBuilder(); + StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = (Set) rolloutItem.getItemProperty(SW_MODULES).getValue(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("
    "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Description : ") + .append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append(" DistributionSet Type : ") + .append((String) rolloutItem.getItemProperty(DS_TYPE).getValue()); + stringBuilder.append("
  • "); + stringBuilder.append("
  • "); + stringBuilder.append("Required Migration step : ") + .append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No"); + stringBuilder.append("
  • "); + + stringBuilder.append("
  • "); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append("
  • "); + + stringBuilder.append("
  • "); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append("
  • "); + + stringBuilder.append("
"); + return stringBuilder.toString(); + } + + enum ACTION { + PAUSE, RESUME, START, UPDATE + } + + /** + * Represents data of context menu item. + * + */ + public static class ContextMenuData { + + private Long rolloutId; + + private ACTION action; + + /** + * Set rollout if and action. + * + * @param rolloutId + * id of rollout + * @param action + * user action {@link ACTION} + */ + public ContextMenuData(final Long rolloutId, final ACTION action) { + this.action = action; + this.rolloutId = rolloutId; + } + + /** + * @return the rolloutId + */ + public Long getRolloutId() { + return rolloutId; + } + + /** + * @param rolloutId + * the rolloutId to set + */ + public void setRolloutId(final Long rolloutId) { + this.rolloutId = rolloutId; + } + + /** + * @return the action + */ + public ACTION getAction() { + return action; + } + + /** + * @param action + * the action to set + */ + public void setAction(final ACTION action) { + this.action = action; + } + } + + /** + * + * Converter to convert {@link RolloutStatus} to string. + * + */ + class RolloutStatusConverter implements Converter { + + private static final long serialVersionUID = -1217685750825632678L; + + @Override + public RolloutStatus convertToModel(final String value, final Class targetType, + final Locale locale) { + return null; + } + + @Override + public String convertToPresentation(final RolloutStatus value, final Class targetType, + final Locale locale) { + return convertRolloutStatusToString(value); + } + + @Override + public Class getModelType() { + return RolloutStatus.class; + } + + @Override + public Class getPresentationType() { + return String.class; + } + + private String convertRolloutStatusToString(final RolloutStatus value) { + final StatusFontIcon statusFontIcon = statusIconMap.get(value); + final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon); + return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), + SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID); + } + } + + /** + * Converter to convert {@link TotalTargetCountStatus} to formatted string + * with status and count details. + * + */ + class TotalTargetCountStatusConverter implements Converter { + + private static final long serialVersionUID = -5794528427855153924L; + + @Override + public TotalTargetCountStatus convertToModel(final String value, + final Class targetType, final Locale locale) + throws com.vaadin.data.util.converter.Converter.ConversionException { + return null; + } + + @Override + public String convertToPresentation(final TotalTargetCountStatus value, + final Class targetType, final Locale locale) + throws com.vaadin.data.util.converter.Converter.ConversionException { + return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); + } + + @Override + public Class getModelType() { + return TotalTargetCountStatus.class; + } + + @Override + public Class getPresentationType() { + return String.class; + } + } + + /** + * Converter to convert 0 to empty, if total target groups is zero. + * + */ + class TotalTargetGroupsConverter implements Converter { + + private static final long serialVersionUID = 6589305227035220369L; + + @Override + public Long convertToModel(final String value, final Class targetType, final Locale locale) + throws com.vaadin.data.util.converter.Converter.ConversionException { + return null; + } + + @Override + public String convertToPresentation(final Long value, final Class targetType, + final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { + if (value == 0) { + return ""; + } + return value.toString(); + } + + @Override + public Class getModelType() { + return Long.class; + } + + @Override + public Class getPresentationType() { + return String.class; + } + + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 46a76fb17..df4a1309e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -103,9 +103,9 @@ public final class HawkbitCommonUtil { private static final String TARGET_TAG_DROP_REMOVE_SCRIPT = "var m = document.getElementById('show-filter-drop-hint'); if(m) { document.head.removeChild(m); } "; private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }"; private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } "; - + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; - private static final String INSTALL_DIST_SET = "installedDistributionSet"; + private static final String INSTALL_DIST_SET = "installedDistributionSet"; /** * Define empty string. @@ -1041,7 +1041,7 @@ public final class HawkbitCommonUtil { targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null, false, true); targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); - + targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true); targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true); From 8dcfc8412d7f2ae72fbf59ce87a9be777bc9f069 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 28 Apr 2016 16:05:37 +0200 Subject: [PATCH 33/44] Fix: Return trimmed username Signed-off-by: SirWayne --- .../hawkbit/ui/common/UserDetailsFormatter.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java index 04ad0c51a..d4a733de3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/UserDetailsFormatter.java @@ -88,12 +88,10 @@ public final class UserDetailsFormatter { * name to max 12 characters. @see * {@link UserDetailsFormatter#loadAndFormatUsername(String, int)} * - * @param baseEntity - * the entity * @return the formatted user name (max 12 characters) cannot be */ - public static String loadAndFormatCurrentUsername() { - return loadAndFormatUsername(getCurrentUser().getUsername(), 12); + public static String formatCurrentUsername() { + return loadAndFormatUsername(getCurrentUser().getUsername(), 5); } /** @@ -114,6 +112,10 @@ public final class UserDetailsFormatter { */ public static String loadAndFormatUsername(final String username, final int expectedNameLength) { final UserDetails userDetails = loadUserByUsername(username); + return formatUserName(expectedNameLength, userDetails); + } + + private static String formatUserName(final int expectedNameLength, final UserDetails userDetails) { if (!(userDetails instanceof UserPrincipal)) { return userDetails.getUsername(); } @@ -134,7 +136,7 @@ public final class UserDetailsFormatter { if (StringUtils.isEmpty(trimmedUsername)) { return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength); } - return firstAndLastname; + return trimmedUsername; } /** From f203e31d00258195d55ddd7950a884fa21e800fb Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 28 Apr 2016 16:20:13 +0200 Subject: [PATCH 34/44] use constants for html tags used often Signed-off-by: Michael Hirsch --- .../CreateOrUpdateFilterTable.java | 41 +++++++++++-------- .../management/targettable/TargetTable.java | 41 +++++++++++-------- .../ui/rollout/rollout/RolloutListGrid.java | 37 +++++++++-------- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 5 +++ 4 files changed, 72 insertions(+), 52 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index cf8a514d4..debd35056 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -8,6 +8,11 @@ */ package org.eclipse.hawkbit.ui.filtermanagement; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; + import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -263,7 +268,7 @@ public class CreateOrUpdateFilterTable extends Table { private static final long serialVersionUID = 688730421728162456L; @Override - public String generateDescription(Component source, Object itemId, Object propertyId) { + public String generateDescription(final Component source, final Object itemId, final Object propertyId) { final DistributionSet distributionSet; final Item item = getItem(itemId); if (propertyId != null) { @@ -279,35 +284,35 @@ public class CreateOrUpdateFilterTable extends Table { } private String getDSDetails(final DistributionSet distributionSet) { - StringBuilder swModuleNames = new StringBuilder(); - StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = (Set) distributionSet.getModules(); + final StringBuilder swModuleNames = new StringBuilder(); + final StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = distributionSet.getModules(); swModules.forEach(swModule -> { swModuleNames.append(swModule.getName()); swModuleNames.append(" , "); swModuleVendors.append(swModule.getVendor()); swModuleVendors.append(" , "); }); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("
    "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + final StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(HTML_UL_OPEN_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription()); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append(" Required Migration step : ") .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append("
"); + stringBuilder.append(HTML_UL_CLOSE_TAG); return stringBuilder.toString(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index a1e759950..0055e06e4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -8,6 +8,11 @@ */ package org.eclipse.hawkbit.ui.management.targettable; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -1089,7 +1094,7 @@ public class TargetTable extends AbstractTable implements private static final long serialVersionUID = 688730421728162456L; @Override - public String generateDescription(Component source, Object itemId, Object propertyId) { + public String generateDescription(final Component source, final Object itemId, final Object propertyId) { final DistributionSet distributionSet; final Item item = getItem(itemId); if (propertyId != null) { @@ -1105,34 +1110,34 @@ public class TargetTable extends AbstractTable implements } private String getDSDetails(final DistributionSet distributionSet) { - StringBuilder swModuleNames = new StringBuilder(); - StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = (Set) distributionSet.getModules(); + final StringBuilder swModuleNames = new StringBuilder(); + final StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = distributionSet.getModules(); swModules.forEach(swModule -> { swModuleNames.append(swModule.getName()); swModuleNames.append(" , "); swModuleVendors.append(swModule.getVendor()); swModuleVendors.append(" , "); }); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("
    "); - stringBuilder.append("
  • "); - stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + final StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(HTML_UL_OPEN_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription()); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append(" Required Migration step : ") .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append("
  • "); - stringBuilder.append("
"); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_UL_CLOSE_TAG); return stringBuilder.toString(); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index 1ad0bfc35..7f3877a9a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -8,6 +8,11 @@ */ package org.eclipse.hawkbit.ui.rollout.rollout; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; + import java.util.ArrayList; import java.util.Arrays; import java.util.EnumMap; @@ -477,14 +482,14 @@ public class RolloutListGrid extends AbstractGrid { return DistributionBarHelper .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); } else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) { - return getDSDetails((Item) cell.getItem()); + return getDSDetails(cell.getItem()); } return null; } private String getDSDetails(final Item rolloutItem) { - StringBuilder swModuleNames = new StringBuilder(); - StringBuilder swModuleVendors = new StringBuilder(); + final StringBuilder swModuleNames = new StringBuilder(); + final StringBuilder swModuleVendors = new StringBuilder(); final Set swModules = (Set) rolloutItem.getItemProperty(SW_MODULES).getValue(); swModules.forEach(swModule -> { swModuleNames.append(swModule.getName()); @@ -492,30 +497,30 @@ public class RolloutListGrid extends AbstractGrid { swModuleVendors.append(swModule.getVendor()); swModuleVendors.append(" , "); }); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("
    "); - stringBuilder.append("
  • "); + final StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(HTML_UL_OPEN_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append(" DistributionSet Description : ") .append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append(" DistributionSet Type : ") .append((String) rolloutItem.getItemProperty(DS_TYPE).getValue()); - stringBuilder.append("
  • "); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("Required Migration step : ") .append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No"); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_OPEN_TAG); stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append("
  • "); + stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append("
"); + stringBuilder.append(HTML_UL_CLOSE_TAG); return stringBuilder.toString(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index df4a1309e..0e71567af 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -73,6 +73,11 @@ public final class HawkbitCommonUtil { */ public static final String SPAN_CLOSE = ""; + public static final String HTML_LI_CLOSE_TAG = ""; + public static final String HTML_LI_OPEN_TAG = "
  • "; + public static final String HTML_UL_CLOSE_TAG = ""; + public static final String HTML_UL_OPEN_TAG = "
      "; + private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class); private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } "; From 345e9a7cf3bf4cf25f7fbaf0ffe1409550cb0076 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 28 Apr 2016 16:24:13 +0200 Subject: [PATCH 35/44] Rename method Signed-off-by: SirWayne --- .../main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java index 690cb51a2..5a822ff86 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java @@ -193,7 +193,7 @@ public final class DashboardMenu extends CustomComponent { final MenuItem settingsItem = settings.addItem("", new ThemeResource("images/profile-pic-57px.jpg"), null); final String formattedTenant = UserDetailsFormatter.formatCurrentTenant(); - final String formattedUsername = UserDetailsFormatter.loadAndFormatCurrentUsername(); + final String formattedUsername = UserDetailsFormatter.formatCurrentUsername(); String tenantAndUsernameHtml = ""; if (!StringUtils.isEmpty(formattedTenant)) { tenantAndUsernameHtml += formattedTenant + "
      "; From 607c98b819be9c64c8ef4dff1c8ff455044429af Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 29 Apr 2016 07:21:43 +0200 Subject: [PATCH 36/44] remove current tenant null check cause not all queries have current tenant and must set it for tenant indenpendent queries like SystemManagement Signed-off-by: Michael Hirsch --- .../eclipse/hawkbit/MultiTenantJpaTransactionManager.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java index a45c846a9..597aee5e8 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit; import javax.persistence.EntityManager; import javax.transaction.Transaction; -import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.persistence.config.PersistenceUnitProperties; import org.springframework.beans.factory.annotation.Autowired; @@ -41,11 +40,8 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { final EntityManager em = emHolder.getEntityManager(); final String currentTenant = tenantAware.getCurrentTenant(); - if (currentTenant == null) { - throw new TenantNotExistException("Tenant Unknown. Canceling transaction."); + if (currentTenant != null) { + em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); } - - em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); - } } From c1b9fb48e89a49c02910709e8d9f9b460c2987d7 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 29 Apr 2016 08:44:29 +0200 Subject: [PATCH 37/44] No need to get EM if no tenant has to be set. Signed-off-by: Kai Zimmermann --- .../eclipse/hawkbit/MultiTenantJpaTransactionManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java index 597aee5e8..b3821e5f3 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java @@ -35,12 +35,11 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { protected void doBegin(final Object transaction, final TransactionDefinition definition) { super.doBegin(transaction, definition); - final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager - .getResource(getEntityManagerFactory()); - final EntityManager em = emHolder.getEntityManager(); - final String currentTenant = tenantAware.getCurrentTenant(); if (currentTenant != null) { + final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager + .getResource(getEntityManagerFactory()); + final EntityManager em = emHolder.getEntityManager(); em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); } } From 3c548c9121f70a742d82a5ef38b796d613d09f7e Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 29 Apr 2016 10:18:45 +0200 Subject: [PATCH 38/44] use vaadin-version placeholder in case of hard-coded vaadin version Signed-off-by: Michael Hirsch --- examples/hawkbit-device-simulator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/hawkbit-device-simulator/pom.xml b/examples/hawkbit-device-simulator/pom.xml index a23051124..c74eace3e 100644 --- a/examples/hawkbit-device-simulator/pom.xml +++ b/examples/hawkbit-device-simulator/pom.xml @@ -139,7 +139,7 @@ com.vaadin vaadin-bom - 7.6.3 + ${vaadin.version} pom import From 8e2ea76c8ca4709c68dd0908d6abbc7291128ee2 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Fri, 29 Apr 2016 16:10:10 +0530 Subject: [PATCH 39/44] fix_assigned_installed_ds_tooltip_gliches Signed-off-by: venu1278 --- .../ui/common/table/AbstractTable.java | 4 - .../CreateOrUpdateFilterTable.java | 72 ++-------------- .../management/targettable/TargetTable.java | 73 ++--------------- .../AssignInstalledDSTooltipGenerator.java | 82 +++++++++++++++++++ 4 files changed, 97 insertions(+), 134 deletions(-) create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index 843d86ca3..1808cf070 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -323,10 +323,6 @@ public abstract class AbstractTable extends Table { return columnList; } columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); - columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, - i18n.get("header.assigned.ds"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, - i18n.get("header.installed.ds"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index debd35056..6e4933d69 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -8,27 +8,22 @@ */ package org.eclipse.hawkbit.ui.filtermanagement; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; +import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -99,7 +94,7 @@ public class CreateOrUpdateFilterTable extends Table { setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); setSelectable(false); eventBus.subscribe(this); - setItemDescriptionGenerator(new TooltipGenerator()); + setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator()); } @PreDestroy @@ -188,13 +183,13 @@ public class CreateOrUpdateFilterTable extends Table { container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null); container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); - container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); - container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null); container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true); container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true); + container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); + container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); } private List getVisbleColumns() { @@ -205,12 +200,12 @@ public class CreateOrUpdateFilterTable extends Table { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); columnList.add( new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n.get("header.assigned.ds"), 0.125F)); columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n.get("header.installed.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); return columnList; } @@ -263,58 +258,5 @@ public class CreateOrUpdateFilterTable extends Table { populateTableData(); eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); } - - public class TooltipGenerator implements ItemDescriptionGenerator { - private static final long serialVersionUID = 688730421728162456L; - - @Override - public String generateDescription(final Component source, final Object itemId, final Object propertyId) { - final DistributionSet distributionSet; - final Item item = getItem(itemId); - if (propertyId != null) { - if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } - } - return null; - } - - private String getDSDetails(final DistributionSet distributionSet) { - final StringBuilder swModuleNames = new StringBuilder(); - final StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = distributionSet.getModules(); - swModules.forEach(swModule -> { - swModuleNames.append(swModule.getName()); - swModuleNames.append(" , "); - swModuleVendors.append(swModule.getVendor()); - swModuleVendors.append(" , "); - }); - final StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(HTML_UL_OPEN_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append(" Required Migration step : ") - .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - - stringBuilder.append(HTML_UL_CLOSE_TAG); - return stringBuilder.toString(); - } - - } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 0055e06e4..6232ebcf8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -8,11 +8,6 @@ */ package org.eclipse.hawkbit.ui.management.targettable; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; -import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -59,6 +54,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.TargetTableFilters; +import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; @@ -117,9 +113,7 @@ public class TargetTable extends AbstractTable implements private static final int PROPERTY_DEPT = 3; private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed"; - private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; - private static final String INSTALL_DIST_SET = "installedDistributionSet"; - + @Autowired private transient TargetManagement targetManagement; @@ -147,7 +141,7 @@ public class TargetTable extends AbstractTable implements addActionHandler(this); actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall")); actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear")); - setItemDescriptionGenerator(new TooltipGenerator()); + setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator()); } /** @@ -341,6 +335,11 @@ public class TargetTable extends AbstractTable implements if (!isMaximized()) { columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F)); columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F)); + }else{ + columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, + i18n.get("header.assigned.ds"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + i18n.get("header.installed.ds"), 0.1F)); } return columnList; @@ -1085,60 +1084,4 @@ public class TargetTable extends AbstractTable implements private boolean isFilteredByTags() { return !managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty(); } - - /** - * tooltip for assignedDS and installedDS - */ - - protected class TooltipGenerator implements ItemDescriptionGenerator { - private static final long serialVersionUID = 688730421728162456L; - - @Override - public String generateDescription(final Component source, final Object itemId, final Object propertyId) { - final DistributionSet distributionSet; - final Item item = getItem(itemId); - if (propertyId != null) { - if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { - distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); - return getDSDetails(distributionSet); - } - } - return null; - } - - private String getDSDetails(final DistributionSet distributionSet) { - final StringBuilder swModuleNames = new StringBuilder(); - final StringBuilder swModuleVendors = new StringBuilder(); - final Set swModules = distributionSet.getModules(); - swModules.forEach(swModule -> { - swModuleNames.append(swModule.getName()); - swModuleNames.append(" , "); - swModuleVendors.append(swModule.getVendor()); - swModuleVendors.append(" , "); - }); - final StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(HTML_UL_OPEN_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append(" Required Migration step : ") - .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_LI_OPEN_TAG); - stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); - stringBuilder.append(HTML_LI_CLOSE_TAG); - stringBuilder.append(HTML_UL_CLOSE_TAG); - return stringBuilder.toString(); - } - } } \ No newline at end of file diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java new file mode 100644 index 000000000..5a3b91a7a --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +package org.eclipse.hawkbit.ui.utils; + +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; + +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; +import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; + +import java.util.Set; + +import com.vaadin.data.Item; +import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; +import com.vaadin.ui.Component; +import com.vaadin.ui.Table; + +public class AssignInstalledDSTooltipGenerator implements ItemDescriptionGenerator { + private static final long serialVersionUID = 688730421728162456L; + + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; + private static final String INSTALL_DIST_SET = "installedDistributionSet"; + + @Override + public String generateDescription(final Component source, final Object itemId, final Object propertyId) { + final DistributionSet distributionSet; + final Item item = ((Table)source).getItem(itemId); + if (propertyId != null) { + if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) { + distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue(); + return getDSDetails(distributionSet); + } + } + return null; + } + + private String getDSDetails(final DistributionSet distributionSet) { + final StringBuilder swModuleNames = new StringBuilder(); + final StringBuilder swModuleVendors = new StringBuilder(); + final Set swModules = distributionSet.getModules(); + swModules.forEach(swModule -> { + swModuleNames.append(swModule.getName()); + swModuleNames.append(" , "); + swModuleVendors.append(swModule.getVendor()); + swModuleVendors.append(" , "); + }); + final StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(HTML_UL_OPEN_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription()); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName()); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append(" Required Migration step : ") + .append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No"); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString()); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_LI_OPEN_TAG); + stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString()); + stringBuilder.append(HTML_LI_CLOSE_TAG); + stringBuilder.append(HTML_UL_CLOSE_TAG); + return stringBuilder.toString(); + } + } + + From 59bec04c58c7649f2b1be5c10e842b92453200ae Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 29 Apr 2016 12:52:27 +0200 Subject: [PATCH 40/44] add null check for distribution set Signed-off-by: Michael Hirsch --- .../AssignInstalledDSTooltipGenerator.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java index 5a3b91a7a..c4e78b3e5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/AssignInstalledDSTooltipGenerator.java @@ -9,9 +9,6 @@ package org.eclipse.hawkbit.ui.utils; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.SoftwareModule; - import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG; import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG; import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG; @@ -19,21 +16,24 @@ import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG; import java.util.Set; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; + import com.vaadin.data.Item; import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; import com.vaadin.ui.Component; import com.vaadin.ui.Table; -public class AssignInstalledDSTooltipGenerator implements ItemDescriptionGenerator { +public class AssignInstalledDSTooltipGenerator implements ItemDescriptionGenerator { private static final long serialVersionUID = 688730421728162456L; - + private static final String ASSIGN_DIST_SET = "assignedDistributionSet"; private static final String INSTALL_DIST_SET = "installedDistributionSet"; @Override public String generateDescription(final Component source, final Object itemId, final Object propertyId) { final DistributionSet distributionSet; - final Item item = ((Table)source).getItem(itemId); + final Item item = ((Table) source).getItem(itemId); if (propertyId != null) { if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) { distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue(); @@ -47,6 +47,9 @@ public class AssignInstalledDSTooltipGenerator implements ItemDescriptionGenera } private String getDSDetails(final DistributionSet distributionSet) { + if (distributionSet == null) { + return null; + } final StringBuilder swModuleNames = new StringBuilder(); final StringBuilder swModuleVendors = new StringBuilder(); final Set swModules = distributionSet.getModules(); @@ -77,6 +80,4 @@ public class AssignInstalledDSTooltipGenerator implements ItemDescriptionGenera stringBuilder.append(HTML_UL_CLOSE_TAG); return stringBuilder.toString(); } - } - - +} From a946f51da4149bcf050e2cdb4e268345758a618d Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 29 Apr 2016 12:57:25 +0200 Subject: [PATCH 41/44] fix installed and assigned distribution set setting on the proxy target Signed-off-by: Michael Hirsch --- .../targettable/TargetBeanQuery.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index d127b4198..e48004d7a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -134,22 +134,21 @@ public class TargetBeanQuery extends AbstractBeanQuery { prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ)); prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); - if (pinnedDistId == null) { - prxyTarget.setInstalledDistributionSet(null); - prxyTarget.setAssignedDistributionSet(null); + final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); + final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); + final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); - } else { - final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); - final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); + prxyTarget.setInstalledDistributionSet(installedDistributionSet); + prxyTarget.setAssignedDistributionSet(assignedDistributionSet); + + if (installedDistributionSet != null) { prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( installedDistributionSet.getName(), installedDistributionSet.getVersion())); - prxyTarget.setInstalledDistributionSet(installedDistributionSet); - final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); + } + if (assignedDistributionSet != null) { prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( assignedDistributionSet.getName(), assignedDistributionSet.getVersion())); - prxyTarget.setAssignedDistributionSet(assignedDistributionSet); } - prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); prxyTarget.setTargetInfo(targ.getTargetInfo()); From 054dca1a64ff649adbea1c12cf3eaa57ed94cbd1 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 2 May 2016 17:08:01 +0200 Subject: [PATCH 42/44] Added driver hint --- examples/hawkbit-example-app/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/hawkbit-example-app/README.md b/examples/hawkbit-example-app/README.md index ecbec93c3..2b8e60643 100644 --- a/examples/hawkbit-example-app/README.md +++ b/examples/hawkbit-example-app/README.md @@ -13,7 +13,11 @@ We have have described several options for you to get access to the example. ``` java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar ``` + +(Note: if you intend to user another database than H2 you have to add the JDBC driver to your class path). + Or: + ``` run org eclipse.hawkbit.app.Start ``` From 6763cb9aff208aa6b079685ec543ca4802416af7 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 2 May 2016 17:08:43 +0200 Subject: [PATCH 43/44] Grammar --- examples/hawkbit-example-app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/hawkbit-example-app/README.md b/examples/hawkbit-example-app/README.md index 2b8e60643..cfd15c433 100644 --- a/examples/hawkbit-example-app/README.md +++ b/examples/hawkbit-example-app/README.md @@ -14,7 +14,7 @@ We have have described several options for you to get access to the example. java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar ``` -(Note: if you intend to user another database than H2 you have to add the JDBC driver to your class path). +_(Note: you have to add the JDBC driver also to your class path if you intend to use another database than H2.)_ Or: From ecc21025328d520c73b7dc8bb8ca8be4f2af0f26 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 2 May 2016 17:14:53 +0200 Subject: [PATCH 44/44] Added credential hint --- examples/hawkbit-example-app/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/hawkbit-example-app/README.md b/examples/hawkbit-example-app/README.md index cfd15c433..068acdd15 100644 --- a/examples/hawkbit-example-app/README.md +++ b/examples/hawkbit-example-app/README.md @@ -4,9 +4,9 @@ The hawkBit example application is a standalone spring-boot application with an We have have described several options for you to get access to the example. ## Try out the example application in our hawkBit sandbox on Bluemix -- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI -- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header) -- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE +- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI (username: admin, passwd: admin) +- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header; username: admin, passwd: admin) +- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE (authentication disabled) ## On your own workstation ### Run