Refactor TargetIdName, DistributionSetIdName, SoftwareModuleIdName entities (#407)

* - Move TargetIdName, DistributionSetIdName, SoftwareModuleIdName to ui
entity package

- Refactor tables. Use the entity id instead of the *idname entity

- Remove expensive getEntity() calls from remote events

- Fix some NPE, if entity is deleted from another session

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Add TagretFilter Query client resource

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Fix methode signature for feign

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* fix sonar issue after merge

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* remove ds set id name after merging from rollout view

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
Dennis Melzer
2017-01-31 09:19:59 +01:00
committed by Kai Zimmermann
parent 59f218e841
commit 9980fd5619
62 changed files with 876 additions and 1139 deletions

View File

@@ -126,8 +126,8 @@ public interface DistributionSetManagement {
* @return the new persisted {@link DistributionSet}
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSet#getModules()} or
* if a provided linked entity does not exists (
* {@link DistributionSet#getModules()} or
* {@link DistributionSet#getType()})
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
* is {@link DistributionSet} does not contain mandatory
@@ -163,8 +163,8 @@ public interface DistributionSetManagement {
* to be created
* @return the new {@link DistributionSet}s
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSet#getModules()} or
* if a provided linked entity does not exists (
* {@link DistributionSet#getModules()} or
* {@link DistributionSet#getType()})
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
* is {@link DistributionSet} does not contain mandatory
@@ -181,8 +181,8 @@ public interface DistributionSetManagement {
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSetType#getMandatoryModuleTypes()} or
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
@@ -196,8 +196,8 @@ public interface DistributionSetManagement {
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists
* ({@link DistributionSetType#getMandatoryModuleTypes()} or
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
@@ -426,7 +426,7 @@ public interface DistributionSetManagement {
* @param distributionSetFilterBuilder
* has details of filters to be applied
* @param assignedOrInstalled
* the controllerID of the Target to be ordered by
* the id of the Target to be ordered by
* @return {@link DistributionSet}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
@@ -707,4 +707,14 @@ public interface DistributionSetManagement {
DistributionSetType assignMandatorySoftwareModuleTypes(@NotNull Long dsTypeId,
@NotEmpty Collection<Long> softwareModuleTypes);
/**
* Retrieves all distribution set without details.
*
* @param ids
* the ids to for
* @return the found {@link DistributionSet}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
List<DistributionSet> findDistributionSetAllById(@NotNull Collection<Long> ids);
}

View File

@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
@@ -179,7 +178,7 @@ public interface TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
/**
* Deletes target with the given IDs.
*
@@ -192,52 +191,6 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTarget(@NotEmpty String controllerID);
/**
* Finds all targets for all the given parameters but returns not the full
* target but {@link TargetIdName}.
*
* @param pageRequest
* the pageRequest to enhance the query for paging and sorting
* @param filterByStatus
* find targets having this {@link TargetUpdateStatus}s. Set to
* <code>null</code> in case this is not required.
* @param overdueState
* find targets that are overdue (targets that did not respond
* during the configured intervals: poll_itvl + overdue_itvl).
* @param filterBySearchText
* to find targets having the text anywhere in name or
* description. Set <code>null</code> in case this is not
* required.
* @param installedOrAssignedDistributionSetId
* to find targets having the {@link DistributionSet} as
* installed or assigned. Set to <code>null</code> in case this
* is not required.
* @param filterByTagNames
* to find targets which are having any one in this tag names.
* Set <code>null</code> in case this is not required.
* @param selectTargetWithNoTag
* flag to select targets with no tag assigned
*
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<TargetIdName> findAllTargetIdsByFilters(@NotNull Pageable pageRequest,
Collection<TargetUpdateStatus> filterByStatus, Boolean overdueState, String filterBySearchText,
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... filterByTagNames);
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
* and returns not the full target but {@link TargetIdName}.
*
* @param pageRequest
* the pageRequest to enhance the query for paging and sorting
* @param rsqlParam
* filter definition in RSQL syntax
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest, @NotNull String rsqlParam);
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
* and that don't have the specified distribution set in their action
@@ -351,9 +304,9 @@ public interface TargetManagement {
@NotNull Pageable pageReq);
/**
* Find {@link Target} based on given ID returns found Target without
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
* possible.
* Find {@link Target}s based a given IDs. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
*
* @param controllerIDs
* to look for.
@@ -363,9 +316,9 @@ public interface TargetManagement {
List<Target> findTargetByControllerID(@NotEmpty Collection<String> controllerIDs);
/**
* Find {@link Target} based on given ID returns found Target without
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
* possible.
* Find a {@link Target} based a given ID. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
*
* @param controllerId
* to look for.
@@ -639,4 +592,27 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
Target updateTarget(@NotNull TargetUpdate update);
/**
* Find a {@link Target} based a given ID. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
*
* @param id
* to look for
* @return {@link Target} or <code>null</code> if it does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Target findTargetById(Long id);
/**
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
* and {@link Target#getActions()} possible
*
* @param ids
* the ids to for
* @return the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Target> findTargetAllById(@NotNull Collection<Long> ids);
}

View File

@@ -1,73 +0,0 @@
/**
* 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.repository.model;
import java.io.Serializable;
/**
* To hold software module name and Id.
*
*/
public class SoftwareModuleIdName implements Serializable {
private static final long serialVersionUID = -6317413180936148514L;
private final Long id;
private final String name;
/**
* @param id
* if the {@link SoftwareModule}
* @param name
* of the {@link SoftwareModule}
*/
public SoftwareModuleIdName(final Long id, final String name) {
super();
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
@Override
public int hashCode() {// NOSONAR - as this is generated
final int prime = 31;
int result = 1;
result = prime * result + (id == null ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {// NOSONAR - as this is generated
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SoftwareModuleIdName other = (SoftwareModuleIdName) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
}

View File

@@ -41,13 +41,6 @@ public interface Target extends NamedEntity {
*/
List<Action> getActions();
/**
* @return {@link TargetIdName} view of the {@link Target}.
*/
default TargetIdName getTargetIdName() {
return new TargetIdName(getId(), getControllerId(), getName());
}
/**
* @return the targetInfo object
*/

View File

@@ -1,93 +0,0 @@
/**
* 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.repository.model;
import java.io.Serializable;
/**
* ID class of the {@link Target} which contains the
* {@link Target#getControllerId()} and the {@link Target#getName()} in one
* object. Often it's necessary to remember the IDs of the {@link Target} and
* the resolve for e.g. the UI the name of the target, this is very costly
* operation, so it's much better if the ID and the name of the {@link Target}
* is already in memory available.
*/
public class TargetIdName implements Serializable {
private static final long serialVersionUID = 1L;
private final long targetId;
private String controllerId;
private String name;
/**
* @param targetId
* the ID of the target.
* @param controllerId
* the {@link Target#getControllerId()}
* @param name
* the {@link Target#getName()}
*/
public TargetIdName(final long targetId, final String controllerId, final String name) {
this.targetId = targetId;
this.controllerId = controllerId;
this.name = name;
}
public String getControllerId() {
return controllerId;
}
public String getName() {
return name;
}
public void setControllerId(final String id) {
controllerId = id;
}
public void setName(final String name) {
this.name = name;
}
public long getTargetId() {
return targetId;
}
@Override
// Exception squid:S864 - generated code
@SuppressWarnings("squid:S864")
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (targetId ^ targetId >>> 32);
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TargetIdName other = (TargetIdName) obj;
return targetId == other.targetId;
}
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
// id in the dom
return controllerId;
}
}