Fixed the issue for metadata not getting updated and also the refresh of

page not displaying the distribution details in deployment and
distribution view.

Signed-off-by: Gaurav <gaurav.sahay@in.bosch.com>
This commit is contained in:
Gaurav
2016-07-28 14:07:19 +02:00
parent 5bc4b04039
commit bf28a8dde8
12 changed files with 1936 additions and 1958 deletions

View File

@@ -1,486 +1,504 @@
/** /**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others. * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package org.eclipse.hawkbit.repository; package org.eclipse.hawkbit.repository;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException; import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException; import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule; import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
/** /**
* Service for managing {@link SoftwareModule}s. * Service for managing {@link SoftwareModule}s.
* *
*/ */
public interface SoftwareManagement { public interface SoftwareManagement {
/** /**
* Counts {@link SoftwareModule}s with given * Counts {@link SoftwareModule}s with given
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
* and {@link SoftwareModule#getType()} that are not marked as deleted. * and {@link SoftwareModule#getType()} that are not marked as deleted.
* *
* @param searchText * @param searchText
* to search for in name and version * to search for in name and version
* @param type * @param type
* to filter the result * to filter the result
* @return number of found {@link SoftwareModule}s * @return number of found {@link SoftwareModule}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModuleByFilters(String searchText, SoftwareModuleType type); Long countSoftwareModuleByFilters(String searchText, SoftwareModuleType type);
/** /**
* Count all {@link SoftwareModule}s in the repository that are not marked * Count all {@link SoftwareModule}s in the repository that are not marked
* as deleted. * as deleted.
* *
* @return number of {@link SoftwareModule}s * @return number of {@link SoftwareModule}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModulesAll(); Long countSoftwareModulesAll();
/** /**
* Counts {@link SoftwareModule}s with given {@link SoftwareModuleType}. * Counts {@link SoftwareModule}s with given {@link SoftwareModuleType}.
* *
* @param type * @param type
* to count * to count
* @return number of found {@link SoftwareModule}s * @return number of found {@link SoftwareModule}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModulesByType(@NotNull SoftwareModuleType type); Long countSoftwareModulesByType(@NotNull SoftwareModuleType type);
/** /**
* @return number of {@link SoftwareModuleType}s in the repository. * @return number of {@link SoftwareModuleType}s in the repository.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModuleTypesAll(); Long countSoftwareModuleTypesAll();
/** /**
* Create {@link SoftwareModule}s in the repository. * Create {@link SoftwareModule}s in the repository.
* *
* @param swModules * @param swModules
* {@link SoftwareModule}s to create * {@link SoftwareModule}s to create
* @return SoftwareModule * @return SoftwareModule
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if a given entity already exists * if a given entity already exists
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModule> swModules); List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModule> swModules);
/** /**
* *
* @param swModule * @param swModule
* SoftwareModule to create * SoftwareModule to create
* @return SoftwareModule * @return SoftwareModule
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if a given entity already exists * if a given entity already exists
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModule createSoftwareModule(@NotNull SoftwareModule swModule); SoftwareModule createSoftwareModule(@NotNull SoftwareModule swModule);
/** /**
* creates a list of software module meta data entries. * creates a list of software module meta data entries.
* *
* @param metadata * @param metadata
* the meta data entries to create or update * the meta data entries to create or update
* @return the updated or created software module meta data entries * @return the updated or created software module meta data entries
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* in case one of the meta data entry already exists for the * in case one of the meta data entry already exists for the
* specific key * specific key
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
List<SoftwareModuleMetadata> createSoftwareModuleMetadata(@NotNull Collection<SoftwareModuleMetadata> metadata); List<SoftwareModuleMetadata> createSoftwareModuleMetadata(@NotNull Collection<SoftwareModuleMetadata> metadata);
/** /**
* creates or updates a single software module meta data entry. * creates or updates a single software module meta data entry.
* *
* @param metadata * @param metadata
* the meta data entry to create or update * the meta data entry to create or update
* @return the updated or created software module meta data entry * @return the updated or created software module meta data entry
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* in case the meta data entry already exists for the specific * in case the meta data entry already exists for the specific
* key * key
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata); SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata);
/** /**
* Creates multiple {@link SoftwareModuleType}s. * Creates multiple {@link SoftwareModuleType}s.
* *
* @param types * @param types
* to create * to create
* @return created {@link Entity} * @return created {@link Entity}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types); List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types);
/** /**
* Creates new {@link SoftwareModuleType}. * Creates new {@link SoftwareModuleType}.
* *
* @param type * @param type
* to create * to create
* @return created {@link Entity} * @return created {@link Entity}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleType type); SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleType type);
/** /**
* Deletes the given {@link SoftwareModule} {@link Entity}. * Deletes the given {@link SoftwareModule} {@link Entity}.
* *
* @param bsm * @param bsm
* is the {@link SoftwareModule} to be deleted * is the {@link SoftwareModule} to be deleted
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModule(@NotNull SoftwareModule bsm); void deleteSoftwareModule(@NotNull SoftwareModule bsm);
/** /**
* deletes a software module meta data entry. * deletes a software module meta data entry.
* *
* @param id * @param id
* the ID of the software module meta data to delete * the ID of the software module meta data to delete
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
void deleteSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotNull String key); void deleteSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotNull String key);
/** /**
* Deletes {@link SoftwareModule}s which is any if the given ids. * Deletes {@link SoftwareModule}s which is any if the given ids.
* *
* @param ids * @param ids
* of the Software Modules to be deleted * of the Software Modules to be deleted
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModules(@NotNull Collection<Long> ids); void deleteSoftwareModules(@NotNull Collection<Long> ids);
/** /**
* Deletes or marks as delete in case the type is in use. * Deletes or marks as delete in case the type is in use.
* *
* @param type * @param type
* to delete * to delete
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModuleType(@NotNull SoftwareModuleType type); void deleteSoftwareModuleType(@NotNull SoftwareModuleType type);
/** /**
* @param pageable * @param pageable
* the page request to page the result set * the page request to page the result set
* @param set * @param set
* to search for * to search for
* @return all {@link SoftwareModule}s that are assigned to given * @return all {@link SoftwareModule}s that are assigned to given
* {@link DistributionSet}. * {@link DistributionSet}.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull DistributionSet set); Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull DistributionSet set);
/** /**
* @param pageable * @param pageable
* the page request to page the result set * the page request to page the result set
* @param set * @param set
* to search for * to search for
* @param type * @param type
* to filter * to filter
* @return all {@link SoftwareModule}s that are assigned to given * @return all {@link SoftwareModule}s that are assigned to given
* {@link DistributionSet} filtered by {@link SoftwareModuleType}. * {@link DistributionSet} filtered by {@link SoftwareModuleType}.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModule> findSoftwareModuleByAssignedToAndType(@NotNull Pageable pageable, @NotNull DistributionSet set, Page<SoftwareModule> findSoftwareModuleByAssignedToAndType(@NotNull Pageable pageable, @NotNull DistributionSet set,
@NotNull SoftwareModuleType type); @NotNull SoftwareModuleType type);
/** /**
* Filter {@link SoftwareModule}s with given * Filter {@link SoftwareModule}s with given
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
* and {@link SoftwareModule#getType()} that are not marked as deleted. * and {@link SoftwareModule#getType()} that are not marked as deleted.
* *
* @param pageable * @param pageable
* page parameter * page parameter
* @param searchText * @param searchText
* to be filtered as "like" on {@link SoftwareModule#getName()} * to be filtered as "like" on {@link SoftwareModule#getName()}
* @param type * @param type
* to be filtered as "like" on {@link SoftwareModule#getType()} * to be filtered as "like" on {@link SoftwareModule#getType()}
* @return the page of found {@link SoftwareModule} * @return the page of found {@link SoftwareModule}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText, Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText,
SoftwareModuleType type); SoftwareModuleType type);
/** /**
* Finds {@link SoftwareModule} by given id. * Finds {@link SoftwareModule} by given id.
* *
* @param id * @param id
* to search for * to search for
* @return the found {@link SoftwareModule}s or <code>null</code> if not * @return the found {@link SoftwareModule}s or <code>null</code> if not
* found. * found.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER) + SpringEvalExpressions.IS_CONTROLLER)
SoftwareModule findSoftwareModuleById(@NotNull Long id); SoftwareModule findSoftwareModuleById(@NotNull Long id);
/** /**
* retrieves {@link SoftwareModule} by their name AND version AND type.. * retrieves {@link SoftwareModule} by their name AND version AND type..
* *
* @param name * @param name
* of the {@link SoftwareModule} * of the {@link SoftwareModule}
* @param version * @param version
* of the {@link SoftwareModule} * of the {@link SoftwareModule}
* @param type * @param type
* of the {@link SoftwareModule} * of the {@link SoftwareModule}
* @return the found {@link SoftwareModule} or <code>null</code> * @return the found {@link SoftwareModule} or <code>null</code>
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version, SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version,
@NotNull SoftwareModuleType type); @NotNull SoftwareModuleType type);
/** /**
* finds a single software module meta data by its id. * finds a single software module meta data by its id.
* *
* @param id * @param id
* the id of the software module meta data containing the meta * the id of the software module meta data containing the meta
* data key and the ID of the software module * data key and the ID of the software module
* @return the found SoftwareModuleMetadata or {@code null} if not exits * @return the found SoftwareModuleMetadata or {@code null} if not exits
* @throws EntityNotFoundException * @throws EntityNotFoundException
* in case the meta data does not exists for the given key * in case the meta data does not exists for the given key
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotEmpty String key); SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotEmpty String key);
/** /**
* finds all meta data by the given software module id. * finds all meta data by the given software module id.
* *
* @param swId * @param swId
* the software module id to retrieve the meta data from * the software module id to retrieve the meta data from
* @param pageable * @param pageable
* the page request to page the result * the page request to page the result
* @return a paged result of all meta data entries for a given software * @return a paged result of all meta data entries for a given software
* module id * module id
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long swId, Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long swId,
@NotNull Pageable pageable); @NotNull Pageable pageable);
/** /**
* finds all meta data by the given software module id. * finds all meta data by the given software module id.
* *
* @param softwareModuleId * @param softwareModuleId
* the software module id to retrieve the meta data from * the software module id to retrieve the meta data from
* @param spec * @param spec
* the specification to filter the result * the specification to filter the result
* @param pageable * @param pageable
* the page request to page the result * the page request to page the result
* @return a paged result of all meta data entries for a given software * @return a paged result of all meta data entries for a given software
* module id * module id
* *
* @throws RSQLParameterUnsupportedFieldException * @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the * if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException * @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong * if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long softwareModuleId, Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long softwareModuleId,
@NotNull String rsqlParam, @NotNull Pageable pageable); @NotNull String rsqlParam, @NotNull Pageable pageable);
/** /**
* Filter {@link SoftwareModule}s with given * Filter {@link SoftwareModule}s with given
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
* search text and {@link SoftwareModule#getType()} that are not marked as * search text and {@link SoftwareModule#getType()} that are not marked as
* deleted and sort them by means of given distribution set related modules * deleted and sort them by means of given distribution set related modules
* on top of the list. * on top of the list.
* *
* After that the modules are sorted by {@link SoftwareModule#getName()} and * After that the modules are sorted by {@link SoftwareModule#getName()} and
* {@link SoftwareModule#getVersion()} in ascending order. * {@link SoftwareModule#getVersion()} in ascending order.
* *
* @param pageable * @param pageable
* page parameter * page parameter
* @param orderByDistributionId * @param orderByDistributionId
* the ID of distribution set to be ordered on top * the ID of distribution set to be ordered on top
* @param searchText * @param searchText
* filtered as "like" on {@link SoftwareModule#getName()} * filtered as "like" on {@link SoftwareModule#getName()}
* @param type * @param type
* filtered as "equal" on {@link SoftwareModule#getType()} * filtered as "equal" on {@link SoftwareModule#getType()}
* @return the page of found {@link SoftwareModule} * @return the page of found {@link SoftwareModule}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
@NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, @NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText,
SoftwareModuleType type); SoftwareModuleType type);
/** /**
* Retrieves all software modules. Deleted ones are filtered. * Retrieves all software modules. Deleted ones are filtered.
* *
* @param pageable * @param pageable
* pagination parameter * pagination parameter
* @return the found {@link SoftwareModule}s * @return the found {@link SoftwareModule}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<SoftwareModule> findSoftwareModulesAll(@NotNull Pageable pageable); Slice<SoftwareModule> findSoftwareModulesAll(@NotNull Pageable pageable);
/** /**
* Retrieves all software modules with a given list of ids * Retrieves all software modules with a given list of ids
* {@link SoftwareModule#getId()}. * {@link SoftwareModule#getId()}.
* *
* @param ids * @param ids
* to search for * to search for
* @return {@link List} of found {@link SoftwareModule}s * @return {@link List} of found {@link SoftwareModule}s
*/ */
List<SoftwareModule> findSoftwareModulesById(@NotEmpty Collection<Long> ids); List<SoftwareModule> findSoftwareModulesById(@NotEmpty Collection<Long> ids);
/** /**
* Retrieves all {@link SoftwareModule}s with a given specification. * Retrieves all {@link SoftwareModule}s with a given specification.
* *
* @param spec * @param spec
* the specification to filter the software modules * the specification to filter the software modules
* @param pageable * @param pageable
* pagination parameter * pagination parameter
* @return the found {@link SoftwareModule}s * @return the found {@link SoftwareModule}s
* *
* @throws RSQLParameterUnsupportedFieldException * @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the * if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException * @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong * if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModule> findSoftwareModulesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable); Page<SoftwareModule> findSoftwareModulesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
/** /**
* retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType} * retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
* . * .
* *
* @param pageable * @param pageable
* page parameters * page parameters
* @param type * @param type
* to be filtered on * to be filtered on
* @return the found {@link SoftwareModule}s * @return the found {@link SoftwareModule}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull SoftwareModuleType type); Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull SoftwareModuleType type);
/** /**
* *
* @param id * @param id
* to search for * to search for
* @return {@link SoftwareModuleType} in the repository with given * @return {@link SoftwareModuleType} in the repository with given
* {@link SoftwareModuleType#getId()} * {@link SoftwareModuleType#getId()}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModuleType findSoftwareModuleTypeById(@NotNull Long id); SoftwareModuleType findSoftwareModuleTypeById(@NotNull Long id);
/** /**
* *
* @param key * @param key
* to search for * to search for
* @return {@link SoftwareModuleType} in the repository with given * @return {@link SoftwareModuleType} in the repository with given
* {@link SoftwareModuleType#getKey()} * {@link SoftwareModuleType#getKey()}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull String key); SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull String key);
/** /**
* *
* @param name * @param name
* to search for * to search for
* @return all {@link SoftwareModuleType}s in the repository with given * @return all {@link SoftwareModuleType}s in the repository with given
* {@link SoftwareModuleType#getName()} * {@link SoftwareModuleType#getName()}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModuleType findSoftwareModuleTypeByName(@NotNull String name); SoftwareModuleType findSoftwareModuleTypeByName(@NotNull String name);
/** /**
* @param pageable * @param pageable
* parameter * parameter
* @return all {@link SoftwareModuleType}s in the repository. * @return all {@link SoftwareModuleType}s in the repository.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable); Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable);
/** /**
* Retrieves all {@link SoftwareModuleType}s with a given specification. * Retrieves all {@link SoftwareModuleType}s with a given specification.
* *
* @param spec * @param spec
* the specification to filter the software modules types * the specification to filter the software modules types
* @param pageable * @param pageable
* pagination parameter * pagination parameter
* @return the found {@link SoftwareModuleType}s * @return the found {@link SoftwareModuleType}s
* *
* @throws RSQLParameterUnsupportedFieldException * @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the * if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException * @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong * if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable); Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/** /**
* Retrieves software module including details ( * Retrieves software module including details (
* {@link SoftwareModule#getArtifacts()}). * {@link SoftwareModule#getArtifacts()}).
* *
* @param id * @param id
* parameter * parameter
* @param isDeleted * @param isDeleted
* parameter * parameter
* @return the found {@link SoftwareModule}s * @return the found {@link SoftwareModule}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id); SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id);
/** /**
* Updates existing {@link SoftwareModule}. Update-able values are * Updates existing {@link SoftwareModule}. Update-able values are
* {@link SoftwareModule#getDescription()} * {@link SoftwareModule#getDescription()}
* {@link SoftwareModule#getVendor()}. * {@link SoftwareModule#getVendor()}.
* *
* @param sm * @param sm
* to update * to update
* *
* @return the saved {@link Entity}. * @return the saved {@link Entity}.
* *
* @throws NullPointerException * @throws NullPointerException
* of {@link SoftwareModule#getId()} is <code>null</code> * of {@link SoftwareModule#getId()} is <code>null</code>
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModule updateSoftwareModule(@NotNull SoftwareModule sm); SoftwareModule updateSoftwareModule(@NotNull SoftwareModule sm);
/** /**
* updates a distribution set meta data value if corresponding entry exists. * updates a distribution set meta data value if corresponding entry exists.
* *
* @param metadata * @param metadata
* the meta data entry to be updated * the meta data entry to be updated
* @return the updated meta data entry * @return the updated meta data entry
* @throws EntityNotFoundException * @throws EntityNotFoundException
* in case the meta data entry does not exists and cannot be * in case the meta data entry does not exists and cannot be
* updated * updated
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata); SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata);
/** /**
* Updates existing {@link SoftwareModuleType}. Update-able value is * Updates existing {@link SoftwareModuleType}. Update-able value is
* {@link SoftwareModuleType#getDescription()} and * {@link SoftwareModuleType#getDescription()} and
* {@link SoftwareModuleType#getColour()}. * {@link SoftwareModuleType#getColour()}.
* *
* @param sm * @param sm
* to update * to update
* @return updated {@link Entity} * @return updated {@link Entity}
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm); SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm);
} /**
* finds all meta data by the given software module id.
*
* @param softwareModuleId
* the software module id to retrieve the meta data from
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong
* @return result of all meta data entries for a given software
* module id
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
List<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(Long softwareModuleId);
}

View File

@@ -173,39 +173,36 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
@Override @Override
@Modifying @Modifying
@Transactional(isolation = Isolation.READ_UNCOMMITTED) @Transactional(isolation = Isolation.READ_UNCOMMITTED)
public void deleteDistributionSet(final Long... distributionSetIDs) { public void deleteDistributionSet(final Long... distributionSetIDs) {
final List<Long> toHardDelete = new ArrayList<>(); final List<Long> toHardDelete = new ArrayList<>();
final List<Long> assigned = distributionSetRepository final List<Long> assigned = distributionSetRepository
.findAssignedToTargetDistributionSetsById(distributionSetIDs); .findAssignedToTargetDistributionSetsById(distributionSetIDs);
assigned.addAll(distributionSetRepository assigned.addAll(distributionSetRepository.findAssignedToRolloutDistributionSetsById(distributionSetIDs));
.findAssignedToRolloutDistributionSetsById(distributionSetIDs));
// soft delete assigned // soft delete assigned
if (!assigned.isEmpty()) { if (!assigned.isEmpty()) {
distributionSetRepository.deleteDistributionSet(assigned distributionSetRepository.deleteDistributionSet(assigned.toArray(new Long[assigned.size()]));
.toArray(new Long[assigned.size()])); }
}
// mark the rest as hard delete // mark the rest as hard delete
for (final Long setId : distributionSetIDs) { for (final Long setId : distributionSetIDs) {
if (!assigned.contains(setId)) { if (!assigned.contains(setId)) {
toHardDelete.add(setId); toHardDelete.add(setId);
} }
} }
// hard delete the rest if exixts // hard delete the rest if exixts
if (!toHardDelete.isEmpty()) { if (!toHardDelete.isEmpty()) {
// don't give the delete statement an empty list, JPA/Oracle cannot // don't give the delete statement an empty list, JPA/Oracle cannot
// handle the empty list // handle the empty list
distributionSetRepository.deleteByIdIn(toHardDelete); distributionSetRepository.deleteByIdIn(toHardDelete);
} }
afterCommit.afterCommit(() -> eventBus afterCommit.afterCommit(
.post(new DistributionDeletedEvent(tenantAware () -> eventBus.post(new DistributionDeletedEvent(tenantAware.getCurrentTenant(), distributionSetIDs)));
.getCurrentTenant(), distributionSetIDs)));
} }
@Override @Override
@Modifying @Modifying
@@ -530,6 +527,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
@Transactional(isolation = Isolation.READ_UNCOMMITTED) @Transactional(isolation = Isolation.READ_UNCOMMITTED)
@Modifying @Modifying
public void deleteDistributionSetMetadata(final DistributionSet distributionSet, final String key) { public void deleteDistributionSetMetadata(final DistributionSet distributionSet, final String key) {
entityManager.merge((JpaDistributionSet) distributionSet).setLastModifiedAt(0L);
distributionSetMetadataRepository.delete(new DsMetadataCompositeKey(distributionSet, key)); distributionSetMetadataRepository.delete(new DsMetadataCompositeKey(distributionSet, key));
} }
@@ -544,6 +542,15 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
pageable); pageable);
} }
@Override
public List<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId) {
return new ArrayList<DistributionSetMetadata>(distributionSetMetadataRepository
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
distributionSetId)));
}
@Override @Override
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId, public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
final String rsqlParam, final Pageable pageable) { final String rsqlParam, final Pageable pageable) {

View File

@@ -222,7 +222,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
populateLog(); populateLog();
populateDescription(); populateDescription();
populateDetailsWidget(); populateDetailsWidget();
populateMetadataDetails();
} }
protected void populateLog() { protected void populateLog() {

View File

@@ -40,38 +40,36 @@ import com.vaadin.ui.themes.ValoTheme;
@SpringComponent @SpringComponent
@VaadinSessionScope @VaadinSessionScope
public class DistributionSetMetadatadetailslayout extends Table{ public class DistributionSetMetadatadetailslayout extends Table {
private static final long serialVersionUID = 2913758299611837718L; private static final long serialVersionUID = 2913758299611837718L;
private DistributionSetManagement distributionSetManagement;
private DistributionSetManagement distributionSetManagement;
private DsMetadataPopupLayout dsMetadataPopupLayout; private DsMetadataPopupLayout dsMetadataPopupLayout;
private static final String METADATA_KEY = "Key"; private static final String METADATA_KEY = "Key";
private static final String VIEW ="view"; private static final String VIEW = "view";
private SpPermissionChecker permissionChecker; private SpPermissionChecker permissionChecker;
private transient EntityFactory entityFactory; private transient EntityFactory entityFactory;
private I18N i18n; private I18N i18n;
private Long selectedDistSetId; private Long selectedDistSetId;
/** /**
* *
* @param i18n * @param i18n
* @param permissionChecker * @param permissionChecker
* @param distributionSetManagement * @param distributionSetManagement
* @param dsMetadataPopupLayout * @param dsMetadataPopupLayout
*/ */
public void init(final I18N i18n, final SpPermissionChecker permissionChecker, public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
final DistributionSetManagement distributionSetManagement, final DistributionSetManagement distributionSetManagement,
final DsMetadataPopupLayout dsMetadataPopupLayout, final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory) {
final EntityFactory entityFactory) {
this.i18n = i18n; this.i18n = i18n;
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
this.distributionSetManagement = distributionSetManagement; this.distributionSetManagement = distributionSetManagement;
@@ -80,7 +78,6 @@ public class DistributionSetMetadatadetailslayout extends Table{
createDSMetadataTable(); createDSMetadataTable();
addCustomGeneratedColumns(); addCustomGeneratedColumns();
} }
/** /**
* Populate software module metadata. * Populate software module metadata.
@@ -90,35 +87,15 @@ public class DistributionSetMetadatadetailslayout extends Table{
public void populateDSMetadata(final DistributionSet distributionSet) { public void populateDSMetadata(final DistributionSet distributionSet) {
removeAllItems(); removeAllItems();
if (null == distributionSet) { if (null == distributionSet) {
return; return;
} }
selectedDistSetId = distributionSet.getId(); selectedDistSetId = distributionSet.getId();
final List<DistributionSetMetadata> dsMetadataList = distributionSet.getMetadata(); final List<DistributionSetMetadata> dsMetadataList = distributionSetManagement
.findDistributionSetMetadataByDistributionSetId(selectedDistSetId);
if (null != dsMetadataList && !dsMetadataList.isEmpty()) { if (null != dsMetadataList && !dsMetadataList.isEmpty()) {
dsMetadataList.forEach(dsMetadata -> setDSMetadataProperties(dsMetadata)); dsMetadataList.forEach(dsMetadata -> setDSMetadataProperties(dsMetadata));
} }
}
/**
* Create metadata .
*
* @param metadataKeyName
*/
public void createMetadata(final String metadataKeyName){
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
final Item item = metadataContainer.addItem(metadataKeyName);
item.getItemProperty(METADATA_KEY).setValue(metadataKeyName);
}
/**
* Delete metadata.
*
* @param metadataKeyName
*/
public void deleteMetadata(final String metadataKeyName){
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
metadataContainer.removeItem(metadataKeyName);
} }
private void createDSMetadataTable() { private void createDSMetadataTable() {
@@ -131,9 +108,9 @@ public class DistributionSetMetadatadetailslayout extends Table{
setContainerDataSource(getDistSetContainer()); setContainerDataSource(getDistSetContainer());
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT); setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
addDSMetadataTableHeader(); addDSMetadataTableHeader();
setSizeFull(); setSizeFull();
//same as height of other tabs in details tabsheet // same as height of other tabs in details tabsheet
setHeight(116,Unit.PIXELS); setHeight(116, Unit.PIXELS);
} }
private IndexedContainer getDistSetContainer() { private IndexedContainer getDistSetContainer() {
@@ -141,7 +118,7 @@ public class DistributionSetMetadatadetailslayout extends Table{
container.addContainerProperty(METADATA_KEY, String.class, ""); container.addContainerProperty(METADATA_KEY, String.class, "");
setColumnExpandRatio(METADATA_KEY, 0.7f); setColumnExpandRatio(METADATA_KEY, 0.7f);
setColumnAlignment(METADATA_KEY, Align.LEFT); setColumnAlignment(METADATA_KEY, Align.LEFT);
if (permissionChecker.hasUpdateDistributionPermission()) { if (permissionChecker.hasUpdateDistributionPermission()) {
container.addContainerProperty(VIEW, Label.class, ""); container.addContainerProperty(VIEW, Label.class, "");
setColumnExpandRatio(VIEW, 0.2F); setColumnExpandRatio(VIEW, 0.2F);
@@ -154,39 +131,36 @@ public class DistributionSetMetadatadetailslayout extends Table{
setColumnHeader(METADATA_KEY, i18n.get("header.key")); setColumnHeader(METADATA_KEY, i18n.get("header.key"));
} }
private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata) {
private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata){
final Item item = getContainerDataSource().addItem(dsMetadata.getKey()); final Item item = getContainerDataSource().addItem(dsMetadata.getKey());
item.getItemProperty(METADATA_KEY).setValue(dsMetadata.getKey()); item.getItemProperty(METADATA_KEY).setValue(dsMetadata.getKey());
} }
private void addCustomGeneratedColumns() { private void addCustomGeneratedColumns() {
addGeneratedColumn(METADATA_KEY, addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
(source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
} }
private Button customMetadataDetailButton(final String metadataKey) { private Button customMetadataDetailButton(final String metadataKey) {
final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View " final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
+ metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class); "View " + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
viewIcon.setData(metadataKey); viewIcon.setData(metadataKey);
viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link" viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
+ " " + "text-style"); + " " + "text-style");
viewIcon.addClickListener(event -> showMetadataDetails(selectedDistSetId, metadataKey)); viewIcon.addClickListener(event -> showMetadataDetails(selectedDistSetId, metadataKey));
return viewIcon; return viewIcon;
} }
private static String getDetailLinkId(final String name) { private static String getDetailLinkId(final String name) {
return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name) return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name).toString();
.toString();
} }
private void showMetadataDetails(final Long selectedDistSetId , final String metadataKey) { private void showMetadataDetails(final Long selectedDistSetId, final String metadataKey) {
DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId); final DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
/* display the window */ /* display the window */
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(distSet, UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(distSet,
entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "") )); entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "")));
} }
} }

View File

@@ -80,7 +80,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
return; return;
} }
selectedSWModuleId = swModule.getId(); selectedSWModuleId = swModule.getId();
final List<SoftwareModuleMetadata> swMetadataList = swModule.getMetadata(); final List<SoftwareModuleMetadata> swMetadataList = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId);
if (null != swMetadataList && !swMetadataList.isEmpty()) { if (null != swMetadataList && !swMetadataList.isEmpty()) {
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata)); swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
} }
@@ -160,7 +160,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
} }
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) { private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId); final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
/* display the window */ /* display the window */
UI.getCurrent().addWindow( UI.getCurrent().addWindow(
swMetadataPopupLayout.getWindow(swmodule, swMetadataPopupLayout.getWindow(swmodule,

View File

@@ -17,7 +17,6 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -29,7 +28,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken; import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscardEvent; import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscardEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
@@ -68,7 +66,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
private static final String SOFT_MODULE = "softwareModule"; private static final String SOFT_MODULE = "softwareModule";
private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule"; private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule";
@Autowired @Autowired
private ManageDistUIState manageDistUIState; private ManageDistUIState manageDistUIState;
@@ -83,37 +81,20 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
@Autowired @Autowired
private transient DistributionSetManagement distributionSetManagement; private transient DistributionSetManagement distributionSetManagement;
@Autowired @Autowired
private DsMetadataPopupLayout dsMetadataPopupLayout; private DsMetadataPopupLayout dsMetadataPopupLayout;
@Autowired @Autowired
private EntityFactory entityFactory; private EntityFactory entityFactory;
private SoftwareModuleDetailsTable softwareModuleTable; private SoftwareModuleDetailsTable softwareModuleTable;
private DistributionSetMetadatadetailslayout dsMetadataTable; private DistributionSetMetadatadetailslayout dsMetadataTable;
private VerticalLayout tagsLayout; private VerticalLayout tagsLayout;
private final Map<String, StringBuilder> assignedSWModule = new HashMap<>(); private final Map<String, StringBuilder> assignedSWModule = new HashMap<>();
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final MetadataEvent event) {
UI.getCurrent()
.access(() -> {
DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
} else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
}
}
});
}
/** /**
* softwareLayout Initialize the component. * softwareLayout Initialize the component.
@@ -124,8 +105,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(), softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(),
manageDistUIState); manageDistUIState);
dsMetadataTable = new DistributionSetMetadatadetailslayout(); dsMetadataTable = new DistributionSetMetadatadetailslayout();
dsMetadataTable.init(getI18n(), getPermissionChecker(),distributionSetManagement, dsMetadataTable.init(getI18n(), getPermissionChecker(), distributionSetManagement, dsMetadataPopupLayout,
dsMetadataPopupLayout,entityFactory); entityFactory);
super.init(); super.init();
} }
@@ -141,7 +122,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
populateTags(); populateTags();
populateMetadataDetails(); populateMetadataDetails();
} }
private void populateModule() { private void populateModule() {
softwareModuleTable.populateModule(getSelectedBaseEntity()); softwareModuleTable.populateModule(getSelectedBaseEntity());
showUnsavedAssignment(); showUnsavedAssignment();
@@ -271,12 +252,12 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
updateDistributionSetDetailsLayout(null, null); updateDistributionSetDetailsLayout(null, null);
} }
} }
@Override @Override
protected void populateMetadataDetails(){ protected void populateMetadataDetails() {
dsMetadataTable.populateDSMetadata(getSelectedBaseEntity()); dsMetadataTable.populateDSMetadata(getSelectedBaseEntity());
} }
private void updateDistributionSetDetailsLayout(final String type, final Boolean isMigrationRequired) { private void updateDistributionSetDetailsLayout(final String type, final Boolean isMigrationRequired) {
final VerticalLayout detailsTabLayout = getDetailsLayout(); final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents(); detailsTabLayout.removeAllComponents();
@@ -403,26 +384,26 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
protected Boolean isMetadataIconToBeDisplayed() { protected Boolean isMetadataIconToBeDisplayed() {
return true; return true;
} }
@Override @Override
protected String getShowMetadataButtonId() { protected String getShowMetadataButtonId() {
DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState final DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent()
.getLastSelectedDistribution().get() : null; ? manageDistUIState.getLastSelectedDistribution().get() : null;
return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "." return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "."
+ lastselectedDistDS.getVersion(); + lastselectedDistDS.getVersion();
} }
private boolean isDistributionSetSelected(DistributionSet ds) { private boolean isDistributionSetSelected(final DistributionSet ds) {
DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState final DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent()
.getLastSelectedDistribution().get() : null; ? manageDistUIState.getLastSelectedDistribution().get() : null;
return ds != null && lastselectedDistDS != null && lastselectedDistDS.getName().equals(ds.getName()) return ds != null && lastselectedDistDS != null && lastselectedDistDS.getName().equals(ds.getName())
&& lastselectedDistDS.getVersion().endsWith(ds.getVersion()); && lastselectedDistDS.getVersion().endsWith(ds.getVersion());
} }
@Override @Override
protected void showMetadata(ClickEvent event) { protected void showMetadata(final ClickEvent event) {
DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()); final DistributionSet ds = distributionSetManagement
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null)); .findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
} }
} }

View File

@@ -16,8 +16,6 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout; import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
@@ -42,19 +40,19 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
protected SpPermissionChecker permChecker; protected SpPermissionChecker permChecker;
@Override @Override
protected void checkForDuplicate(DistributionSet entity, String value) { protected void checkForDuplicate(final DistributionSet entity, final String value) {
distributionSetManagement.findOne(entity, value); distributionSetManagement.findOne(entity, value);
} }
/** /**
* Create metadata for DistributionSet. * Create metadata for DistributionSet.
*/ */
@Override @Override
protected DistributionSetMetadata createMetadata(DistributionSet entity, String key, String value) { protected DistributionSetMetadata createMetadata(final DistributionSet entity, final String key,
DistributionSetMetadata dsMetaData = distributionSetManagement.createDistributionSetMetadata(entityFactory final String value) {
.generateDistributionSetMetadata(entity, key, value)); final DistributionSetMetadata dsMetaData = distributionSetManagement
.createDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
setSelectedEntity(dsMetaData.getDistributionSet()); setSelectedEntity(dsMetaData.getDistributionSet());
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA, dsMetaData));
return dsMetaData; return dsMetaData;
} }
@@ -62,9 +60,10 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
* Update metadata for DistributionSet. * Update metadata for DistributionSet.
*/ */
@Override @Override
protected DistributionSetMetadata updateMetadata(DistributionSet entity, String key, String value) { protected DistributionSetMetadata updateMetadata(final DistributionSet entity, final String key,
DistributionSetMetadata dsMetaData = distributionSetManagement.updateDistributionSetMetadata(entityFactory final String value) {
.generateDistributionSetMetadata(entity, key, value)); final DistributionSetMetadata dsMetaData = distributionSetManagement
.updateDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
setSelectedEntity(dsMetaData.getDistributionSet()); setSelectedEntity(dsMetaData.getDistributionSet());
return dsMetaData; return dsMetaData;
} }
@@ -73,23 +72,22 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
protected List<DistributionSetMetadata> getMetadataList() { protected List<DistributionSetMetadata> getMetadataList() {
return getSelectedEntity().getMetadata(); return getSelectedEntity().getMetadata();
} }
/** /**
* Update metadata for DistributionSet. * Update metadata for DistributionSet.
*/ */
@Override @Override
protected void deleteMetadata(DistributionSet entity, String key, String value) { protected void deleteMetadata(final DistributionSet entity, final String key, final String value) {
DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value); final DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value);
distributionSetManagement.deleteDistributionSetMetadata(entity, key); distributionSetManagement.deleteDistributionSetMetadata(entity, key);
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA, dsMetaData));
} }
@Override @Override
protected boolean hasCreatePermission() { protected boolean hasCreatePermission() {
return permChecker.hasCreateDistributionPermission(); return permChecker.hasCreateDistributionPermission();
} }
@Override @Override
protected boolean hasUpdatePermission() { protected boolean hasUpdatePermission() {
return permChecker.hasUpdateDistributionPermission(); return permChecker.hasUpdateDistributionPermission();

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.event;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
/** /**
* *
* Metadata Events. * Metadata Events.
@@ -18,21 +19,21 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
public class MetadataEvent { public class MetadataEvent {
public enum MetadataUIEvent { public enum MetadataUIEvent {
CREATE_DISTRIBUTION_SET_METADATA, DELETE_DISTRIBUTION_SET_METADATA, DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA; DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
} }
private MetadataUIEvent metadataUIEvent; private final MetadataUIEvent metadataUIEvent;
private DistributionSetMetadata distributionSetMetadata; private DistributionSetMetadata distributionSetMetadata;
private SoftwareModuleMetadata softwareModuleMetadata; private SoftwareModuleMetadata softwareModuleMetadata;
public MetadataEvent(MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) { public MetadataEvent(final MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
this.metadataUIEvent = metadataUIEvent; this.metadataUIEvent = metadataUIEvent;
this.distributionSetMetadata = distributionSetMetadata; this.distributionSetMetadata = distributionSetMetadata;
} }
public MetadataEvent(MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) { public MetadataEvent(final MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
this.metadataUIEvent = metadataUIEvent; this.metadataUIEvent = metadataUIEvent;
this.softwareModuleMetadata = softwareModuleMetadata; this.softwareModuleMetadata = softwareModuleMetadata;
} }

View File

@@ -37,6 +37,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -84,10 +85,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
@Autowired @Autowired
private transient EntityFactory entityFactory; private transient EntityFactory entityFactory;
@Autowired
private transient DistributionSetTable distributionSetTable;
private TextField distNameTextField; private TextField distNameTextField;
private TextField distVersionTextField; private TextField distVersionTextField;
private TextArea descTextArea; private TextArea descTextArea;
@@ -239,9 +236,10 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success", notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
new Object[] { newDist.getName(), newDist.getVersion() })); new Object[] { newDist.getName(), newDist.getVersion() }));
final Set<DistributionSetIdName> s = new HashSet<>(); final Set<DistributionSetIdName> s = new HashSet<>();
s.add(new DistributionSetIdName(newDist.getId(),newDist.getName(),newDist.getVersion())); s.add(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion()));
final DistributionSetTable distributionSetTable = SpringContextHelper.getBean(DistributionSetTable.class);
distributionSetTable.setValue(s); distributionSetTable.setValue(s);
} }
} }

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstable;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout; import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout; import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout;
@@ -19,7 +18,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken; import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout; import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
@@ -53,48 +51,32 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Autowired @Autowired
private DistributionTagToken distributionTagToken; private DistributionTagToken distributionTagToken;
@Autowired @Autowired
private transient DistributionSetManagement distributionSetManagement; private transient DistributionSetManagement distributionSetManagement;
@Autowired @Autowired
private DsMetadataPopupLayout dsMetadataPopupLayout; private DsMetadataPopupLayout dsMetadataPopupLayout;
@Autowired @Autowired
private EntityFactory entityFactory; private EntityFactory entityFactory;
private SoftwareModuleDetailsTable softwareModuleTable; private SoftwareModuleDetailsTable softwareModuleTable;
private DistributionSetMetadatadetailslayout dsMetadataTable; private DistributionSetMetadatadetailslayout dsMetadataTable;
@Override @Override
protected void init() { protected void init() {
softwareModuleTable = new SoftwareModuleDetailsTable(); softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(getI18n(), false, getPermissionChecker(), null, null, null); softwareModuleTable.init(getI18n(), false, getPermissionChecker(), null, null, null);
dsMetadataTable = new DistributionSetMetadatadetailslayout(); dsMetadataTable = new DistributionSetMetadatadetailslayout();
dsMetadataTable.init(getI18n(), getPermissionChecker(),distributionSetManagement, dsMetadataTable.init(getI18n(), getPermissionChecker(), distributionSetManagement, dsMetadataPopupLayout,
dsMetadataPopupLayout,entityFactory); entityFactory);
super.init(); super.init();
} }
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final MetadataEvent event) {
UI.getCurrent()
.access(() -> {
DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
} else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
}
}
});
}
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final DistributionTableEvent distributionTableEvent) { void onEvent(final DistributionTableEvent distributionTableEvent) {
onBaseEntityEvent(distributionTableEvent); onBaseEntityEvent(distributionTableEvent);
@@ -156,12 +138,11 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
populateMetadataDetails(); populateMetadataDetails();
} }
@Override @Override
protected void populateMetadataDetails(){ protected void populateMetadataDetails() {
dsMetadataTable.populateDSMetadata(getSelectedBaseEntity()); dsMetadataTable.populateDSMetadata(getSelectedBaseEntity());
} }
private void populateDetails(final DistributionSet ds) { private void populateDetails(final DistributionSet ds) {
if (ds != null) { if (ds != null) {
@@ -206,30 +187,32 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
protected String getDetailsHeaderCaptionId() { protected String getDetailsHeaderCaptionId() {
return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID; return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID;
} }
@Override @Override
protected Boolean isMetadataIconToBeDisplayed() { protected Boolean isMetadataIconToBeDisplayed() {
return true; return true;
} }
@Override @Override
protected String getShowMetadataButtonId() { protected String getShowMetadataButtonId() {
DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState final DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent()
.getLastSelectedDistribution().get() : null; ? managementUIState.getLastSelectedDistribution().get() : null;
return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "." return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "."
+ lastselectedDistDS.getVersion(); + lastselectedDistDS.getVersion();
} }
private boolean isDistributionSetSelected(DistributionSet ds) {
DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState private boolean isDistributionSetSelected(final DistributionSet ds) {
.getLastSelectedDistribution().get() : null; final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent()
return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName()) ? managementUIState.getLastSelectedDistribution().get() : null;
return ds != null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
&& lastselectedManageDS.getVersion().endsWith(ds.getVersion()); && lastselectedManageDS.getVersion().endsWith(ds.getVersion());
} }
@Override @Override
protected void showMetadata(ClickEvent event) { protected void showMetadata(final ClickEvent event) {
DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()); final DistributionSet ds = distributionSetManagement
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null)); .findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
} }
} }