Remove TargetInfo entity (#453)

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-03-17 12:18:43 +01:00
committed by GitHub
parent 67d17fe661
commit 602fb78168
89 changed files with 1166 additions and 1462 deletions

View File

@@ -27,8 +27,6 @@ import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
@@ -372,15 +370,15 @@ public interface DeploymentManagement {
/**
* Starts all scheduled actions of an RolloutGroup parent.
*
* @param rollout
* @param rolloutId
* the rollout the actions belong to
* @param rolloutGroupParent
* @param rolloutGroupParentId
* the parent rollout group the actions should reference. null
* references the first group
* @return the amount of started actions
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long startScheduledActionsByRolloutGroupParent(@NotNull Rollout rollout, RolloutGroup rolloutGroupParent);
long startScheduledActionsByRolloutGroupParent(@NotNull Long rolloutId, Long rolloutGroupParentId);
/**
* All {@link ActionStatus} entries in the repository.
@@ -391,4 +389,29 @@ public interface DeploymentManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<ActionStatus> findActionStatusAll(@NotNull Pageable pageable);
/**
* Returns {@link DistributionSet} that is assigned to given {@link Target}.
*
* @param controllerId
* of target
* @return assigned {@link DistributionSet}
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
Optional<DistributionSet> getAssignedDistributionSet(@NotEmpty String controllerId);
/**
* Returns {@link DistributionSet} that is installed on given
* {@link Target}.
*
* @param controllerId
* of target
* @return installed {@link DistributionSet}
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
Optional<DistributionSet> getInstalledDistributionSet(@NotEmpty String controllerId);
}

View File

@@ -39,7 +39,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

View File

@@ -18,7 +18,7 @@ import java.util.List;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.report.model.DataReportSeries;
import org.eclipse.hawkbit.repository.report.model.InnerOuterDataReportSeries;
@@ -183,8 +183,8 @@ public interface ReportManagement {
/**
* Generates a report as a {@link ListReportSeries} targets polled based on
* the {@link TargetInfo#getLastTargetQuery()} within an hour, day, week,
* month, year, more than a year, never.
* the {@link Target#getLastTargetQuery()} within an hour, day, week, month,
* year, more than a year, never.
*
* The order of the numbers within the {@link DataReportSeries} is the order
* hour, day, week, month, year, more than a year, never.

View File

@@ -168,6 +168,21 @@ public interface TagManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable);
/**
* Returns all {@link TargetTag}s assigned to {@link Target} with given ID.
*
* @param pageable
* page parameter
* @param controllerId
*
* @return {@link TargetTag}s assigned to {@link Target} with given ID
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable, @NotEmpty String controllerId);
/**
* Retrieves all target tags based on the given specification.
*

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.validation.constraints.NotNull;
@@ -26,7 +27,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.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
@@ -108,7 +108,7 @@ public interface TargetManagement {
/**
* Counts number of targets with given
* {@link TargetInfo#getInstalledDistributionSet()}.
* {@link Target#getInstalledDistributionSet()}.
*
* @param distId
* to search for
@@ -342,9 +342,7 @@ public interface TargetManagement {
List<Target> findTargetByControllerID(@NotEmpty Collection<String> controllerIDs);
/**
* Find a {@link Target} based a given ID. The returned target will not
* contain details (e.g {@link Target#getTags()} and
* {@link Target#getActions()})
* Find a {@link Target} based a given ID.
*
* @param controllerId
* to look for.
@@ -353,21 +351,6 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Optional<Target> findTargetByControllerID(@NotEmpty String controllerId);
/**
* Find {@link Target} based on given ID returns found Target with details,
* i.e. {@link Target#getTags()} and {@link Target#getActions()} are
* possible.
*
* Note: try to use {@link #findTargetByControllerID(String)} as much as
* possible.
*
* @param controllerId
* to look for.
* @return {@link Target}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Optional<Target> findTargetByControllerIDWithDetails(@NotEmpty String controllerId);
/**
* Filter {@link Target}s for all the given parameters. If all parameters
* except pageable are null, all available {@link Target}s are returned.
@@ -523,8 +506,7 @@ public interface TargetManagement {
* order:
* <p>
* 1) {@link Target}s which have the given {@link DistributionSet} as
* {@link Target#getTargetInfo()}
* {@link TargetInfo#getInstalledDistributionSet()}
* {@link Target#getTarget()} {@link Target#getInstalledDistributionSet()}
* <p>
* 2) {@link Target}s which have the given {@link DistributionSet} as
* {@link Target#getAssignedDistributionSet()}
@@ -549,20 +531,6 @@ public interface TargetManagement {
Slice<Target> findTargetsAllOrderByLinkedDistributionSet(@NotNull Pageable pageable,
@NotNull Long orderByDistributionId, FilterParams filterParams);
/**
* retrieves a list of {@link Target}s by their controller ID with details,
* i.e. {@link Target#getTags()} are possible.
*
* Note: try to use {@link #findTargetByControllerID(String)} as much as
* possible.
*
* @param controllerIDs
* {@link Target}s Names parameter
* @return the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Target> findTargetsByControllerIDsWithTags(@NotNull List<String> controllerIDs);
/**
* Find targets by tag name.
*
@@ -656,4 +624,16 @@ public interface TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Target> findTargetAllById(@NotNull Collection<Long> ids);
/**
* Get controller attributes of given {@link Target}.
*
* @param controllerId
* of the target
* @return controller attributes as key/value pairs
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
Map<String, String> getControllerAttributes(@NotEmpty String controllerId);
}

View File

@@ -8,14 +8,12 @@
*/
package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Optional;
/**
* Builder to update an existing {@link Rollout} entry. Defines all fields that
* can be updated.

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository.builder;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.hibernate.validator.constraints.NotEmpty;
@@ -52,7 +51,7 @@ public interface TargetCreate {
/**
* @param address
* for {@link TargetInfo#getAddress()}
* for {@link Target#getAddress()}
*
* @throws IllegalArgumentException
* If the given string violates RFC&nbsp;2396
@@ -63,14 +62,14 @@ public interface TargetCreate {
/**
* @param lastTargetQuery
* for {@link TargetInfo#getLastTargetQuery()}
* for {@link Target#getLastTargetQuery()}
* @return updated builder instance
*/
TargetCreate lastTargetQuery(Long lastTargetQuery);
/**
* @param status
* for {@link TargetInfo#getUpdateStatus()}
* for {@link Target#getUpdateStatus()}
* @return updated builder instance
*/
TargetCreate status(TargetUpdateStatus status);

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.repository.builder;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.hibernate.validator.constraints.NotEmpty;
@@ -43,7 +42,7 @@ public interface TargetUpdate {
/**
* @param address
* for {@link TargetInfo#getAddress()}
* for {@link Target#getAddress()}
*
* @throws IllegalArgumentException
* If the given string violates RFC&nbsp;2396
@@ -54,14 +53,14 @@ public interface TargetUpdate {
/**
* @param lastTargetQuery
* for {@link TargetInfo#getLastTargetQuery()}
* for {@link Target#getLastTargetQuery()}
* @return updated builder instance
*/
TargetUpdate lastTargetQuery(Long lastTargetQuery);
/**
* @param status
* for {@link TargetInfo#getUpdateStatus()}
* for {@link Target#getUpdateStatus()}
* @return updated builder instance
*/
TargetUpdate status(TargetUpdateStatus status);

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
import org.eclipse.hawkbit.repository.model.Rollout;
/**

View File

@@ -29,7 +29,7 @@ public class TargetPollEvent extends RemoteTenantAwareEvent {
public TargetPollEvent(final Target target, final String applicationId) {
super(target.getControllerId(), target.getTenant(), applicationId);
this.controllerId = target.getControllerId();
this.targetAdress = target.getTargetInfo().getAddress().toString();
this.targetAdress = target.getAddress().toString();
}
public String getControllerId() {

View File

@@ -72,8 +72,7 @@ public interface DistributionSetType extends NamedEntity {
* @return <code>true</code> if found
*/
default boolean containsMandatoryModuleType(final Long softwareModuleTypeId) {
return getMandatoryModuleTypes().stream().filter(element -> element.getId().equals(softwareModuleTypeId))
.findAny().isPresent();
return getMandatoryModuleTypes().stream().anyMatch(element -> element.getId().equals(softwareModuleTypeId));
}
/**
@@ -97,8 +96,7 @@ public interface DistributionSetType extends NamedEntity {
* @return <code>true</code> if found
*/
default boolean containsOptionalModuleType(final Long softwareModuleTypeId) {
return getOptionalModuleTypes().stream().filter(element -> element.getId().equals(softwareModuleTypeId))
.findAny().isPresent();
return getOptionalModuleTypes().stream().anyMatch(element -> element.getId().equals(softwareModuleTypeId));
}
/**

View File

@@ -8,9 +8,10 @@
*/
package org.eclipse.hawkbit.repository.model;
import javax.validation.constraints.NotNull;
import java.util.List;
import javax.validation.constraints.NotNull;
/**
* Represents information to validate the correct distribution of targets to
* rollout groups.

View File

@@ -8,8 +8,8 @@
*/
package org.eclipse.hawkbit.repository.model;
import java.util.List;
import java.util.Set;
import java.net.URI;
import java.util.concurrent.TimeUnit;
/**
* <p>
@@ -21,31 +21,11 @@ import java.util.Set;
*/
public interface Target extends NamedEntity {
/**
* @return currently assigned {@link DistributionSet}.
*/
DistributionSet getAssignedDistributionSet();
/**
* @return business identifier of the {@link Target}
*/
String getControllerId();
/**
* @return immutable set of assigned {@link TargetTag}s.
*/
Set<TargetTag> getTags();
/**
* @return immutable {@link Action} history of the {@link Target}.
*/
List<Action> getActions();
/**
* @return the targetInfo object
*/
TargetInfo getTargetInfo();
/**
* @return the securityToken
*/
@@ -58,4 +38,41 @@ public interface Target extends NamedEntity {
return new TargetWithActionType(getControllerId());
}
/**
* @return the address under which the target can be reached
*/
URI getAddress();
/**
* @return time in {@link TimeUnit#MILLISECONDS} GMT when the {@link Target}
* polled the server the last time or <code>null</code> if target
* has never queried yet.
*/
Long getLastTargetQuery();
/**
* @return time in {@link TimeUnit#MILLISECONDS} GMT when
* {@link #getInstalledDistributionSet()} was applied.
*/
Long getInstallationDate();
/**
* @return current status of the {@link Target}.
*/
TargetUpdateStatus getUpdateStatus();
/**
* @return the poll time which holds the last poll time of the target, the
* next poll time and the overdue time. In case the
* {@link #lastTargetQuery} is not set e.g. the target never polled
* before this method returns {@code null}
*/
PollStatus getPollStatus();
/**
* @return <code>true</code> if the {@link Target} has not jet provided
* {@link #getControllerAttributes()}.
*/
boolean isRequestControllerAttributes();
}

View File

@@ -1,72 +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;
import java.net.URI;
import java.text.AttributedCharacterIterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public interface TargetInfo extends Serializable {
/**
* @return the address under which the target can be reached
*/
URI getAddress();
/**
* @return {@link Target} this info element belongs to.
*/
Target getTarget();
/**
* @return time in {@link TimeUnit#MILLISECONDS} GMT when the {@link Target}
* polled the server the last time or <code>null</code> if target
* has never queried yet.
*/
Long getLastTargetQuery();
/**
* @return {@link AttributedCharacterIterator} that have been provided by
* the {@link Target} itself, e.g. hardware revision, serial number,
* mac address etc.
*/
Map<String, String> getControllerAttributes();
/**
* @return time in {@link TimeUnit#MILLISECONDS} GMT when
* {@link #getInstalledDistributionSet()} was applied.
*/
Long getInstallationDate();
/**
* @return current status of the {@link Target}.
*/
TargetUpdateStatus getUpdateStatus();
/**
* @return currently installed {@link DistributionSet}.
*/
DistributionSet getInstalledDistributionSet();
/**
* @return the poll time which holds the last poll time of the target, the
* next poll time and the overdue time. In case the
* {@link #lastTargetQuery} is not set e.g. the target never polled
* before this method returns {@code null}
*/
PollStatus getPollStatus();
/**
* @return <code>true</code> if the {@link Target} has not jet provided
* {@link #getControllerAttributes()}.
*/
boolean isRequestControllerAttributes();
}