Ejemplo n.º 1
0
  private boolean checkAndHandleIfVisibleDsSwitchesFromCompleteToIncomplete(
      final List<DistributionSetUpdateEvent> events,
      final List<DistributionSetIdName> visibleItemIds) {
    final List<DistributionSet> setsThatAreVisibleButNotCompleteAnymore =
        events
            .stream()
            .map(event -> event.getEntity())
            .filter(set -> !set.isComplete())
            .filter(set -> visibleItemIds.contains(DistributionSetIdName.generate(set)))
            .collect(Collectors.toList());

    if (!setsThatAreVisibleButNotCompleteAnymore.isEmpty()) {
      refreshDistributions();

      if (setsThatAreVisibleButNotCompleteAnymore
          .stream()
          .anyMatch(
              set -> set.getId().equals(managementUIState.getLastSelectedDsIdName().getId()))) {
        managementUIState.setLastSelectedDistribution(null);
        managementUIState.setLastSelectedEntity(null);
      }

      return true;
    }

    return false;
  }
Ejemplo n.º 2
0
  @EventBusListenerMethod(scope = EventScope.SESSION)
  void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) {

    final List<DistributionSetIdName> visibleItemIds =
        (List<DistributionSetIdName>) getVisibleItemIds();

    if (allOfThemAffectCompletedSetsThatAreNotVisible(eventContainer.getEvents(), visibleItemIds)) {
      refreshDistributions();
    } else if (!checkAndHandleIfVisibleDsSwitchesFromCompleteToIncomplete(
        eventContainer.getEvents(), visibleItemIds)) {
      updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds);
    }

    final DistributionSetIdName lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
    // refresh the details tabs only if selected ds is updated
    if (lastSelectedDsIdName != null) {
      final Optional<DistributionSet> selectedSetUpdated =
          eventContainer
              .getEvents()
              .stream()
              .map(event -> event.getEntity())
              .filter(set -> set.getId().equals(lastSelectedDsIdName.getId()))
              .findFirst();

      if (selectedSetUpdated.isPresent()) {
        // update table row+details layout
        eventBus.publish(
            this,
            new DistributionTableEvent(
                BaseEntityEventType.SELECTED_ENTITY, selectedSetUpdated.get()));
      }
    }
  }