Feature target type entity (#1162)
* Added Target Type model Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type JPA model Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type repository model classes Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the name entity from Target Type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Refactored the Target Type models Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added the DB migration script and updated the Target Type models Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type in target Mapper Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Changed the target type ID to Long Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added MYSQL DB migration script and removed the deleted column for target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Updated the DB migration script for target table Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added manyToMany reltation between target type and Ds type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added POSTGRESQL DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added MSSQL SERVER DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added DB2 DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing license header and java docs Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added on delete cascade in DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type specification Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the delete cascade and Added type API Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * fixed API doc build Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type management test Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type events test Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type update and unassign to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added API tests for assigning target type to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing license header Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing docs Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed sonar issues Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed license header build issue Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Updated the attribute name to target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the review comments Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed unused error status variable Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target API to assign target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added the tests for assigning target type to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the review comments for null check Signed-off-by: Anand kumar <anand.kumar@bosch-si.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.TagBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetTypeBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
|
||||
@@ -109,6 +110,11 @@ public interface EntityFactory {
|
||||
*/
|
||||
TargetBuilder target();
|
||||
|
||||
/**
|
||||
* @return {@link TargetTypeBuilder} object
|
||||
*/
|
||||
TargetTypeBuilder targetType();
|
||||
|
||||
/**
|
||||
* @return {@link TargetFilterQueryBuilder} object
|
||||
*/
|
||||
|
||||
@@ -106,4 +106,9 @@ public interface QuotaManagement {
|
||||
*/
|
||||
long getMaxArtifactStorage();
|
||||
|
||||
/**
|
||||
* @return the maximum number of distribution set types per target type
|
||||
*/
|
||||
int getMaxDistributionSetTypesPerTargetType();
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.TargetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -598,6 +599,30 @@ public interface TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Target unAssignTag(@NotEmpty String controllerID, long targetTagId);
|
||||
|
||||
/**
|
||||
* Un-assign a {@link TargetType} assignment to given {@link Target}.
|
||||
*
|
||||
* @param controllerID
|
||||
* to un-assign for
|
||||
* @return the unassigned target
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Target unAssignType(@NotEmpty String controllerID);
|
||||
|
||||
/**
|
||||
* Assign a {@link TargetType} assignment to given {@link Target}.
|
||||
*
|
||||
* @param controllerID
|
||||
* to un-assign for
|
||||
* @return the unassigned target
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if TargetType with given target ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Target assignType(@NotEmpty String controllerID, @NotNull long targetTypeId);
|
||||
|
||||
/**
|
||||
* updates the {@link Target}.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Management service for {@link TargetType}s.
|
||||
*
|
||||
*/
|
||||
public interface TargetTypeManagement {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* as {@link TargetType#getName()}
|
||||
* @return {@link TargetType}
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetType> getByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* @return total count
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
long count();
|
||||
|
||||
/**
|
||||
* @param create
|
||||
* TargetTypeCreate
|
||||
* @return targetType
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
TargetType create(@NotNull @Valid TargetTypeCreate create);
|
||||
|
||||
/**
|
||||
* @param creates
|
||||
* List of TargetTypeCreate
|
||||
* @return List of targetType
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<TargetType> create(@NotEmpty @Valid Collection<TargetTypeCreate> creates);
|
||||
|
||||
/**
|
||||
* @param id targetTypeId
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void delete(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* Page
|
||||
* @return TargetType page
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetType> findAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* Page
|
||||
* @param rsqlParam
|
||||
* query param
|
||||
* @return Target type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetType> findByRsql(@NotNull Pageable pageable, @NotEmpty String rsqlParam);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* Target type ID
|
||||
* @return Target Type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetType> get(long id);
|
||||
|
||||
/**
|
||||
* @param targetId
|
||||
* Target ID
|
||||
* @return Target Type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetType> findByTargetId(long targetId);
|
||||
|
||||
/**
|
||||
* @param targetIds
|
||||
* List of Target ID
|
||||
* @return Target Type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetType> findByTargetIds(Collection<Long> targetIds);
|
||||
|
||||
/**
|
||||
* @param controllerId
|
||||
* Target controller ID
|
||||
* @return Target Type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetType> findByTargetControllerId(String controllerId);
|
||||
|
||||
/**
|
||||
* @param controllerIds
|
||||
* List of Target controller ID
|
||||
* @return Target Type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetType> findByTargetControllerIds(Collection<String> controllerIds);
|
||||
|
||||
|
||||
/**
|
||||
* @param ids
|
||||
* List of Target type ID
|
||||
* @return Target type list
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetType> get(@NotEmpty Collection<Long> ids);
|
||||
|
||||
|
||||
/**
|
||||
* @param update
|
||||
* TargetTypeUpdate
|
||||
* @return Target Type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetType update(@NotNull @Valid TargetTypeUpdate update);
|
||||
|
||||
/**
|
||||
* @param targetTypeId
|
||||
* Target type ID
|
||||
* @param distributionSetTypeIds
|
||||
* Distribution set ID
|
||||
* @return Target type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
TargetType assignCompatibleDistributionSetTypes(long targetTypeId,
|
||||
@NotEmpty Collection<Long> distributionSetTypeIds);
|
||||
|
||||
/**
|
||||
* @param targetTypeId
|
||||
* Target type ID
|
||||
* @param distributionSetTypeIds
|
||||
* Distribution set ID
|
||||
* @return Target type
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
TargetType unassignDistributionSetType(long targetTypeId, long distributionSetTypeIds);
|
||||
|
||||
}
|
||||
@@ -46,6 +46,13 @@ public interface TargetCreate {
|
||||
*/
|
||||
TargetCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
|
||||
/**
|
||||
* @param targetTypeId
|
||||
* for {@link Target#getTargetType()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetCreate targetType(Long targetTypeId);
|
||||
|
||||
/**
|
||||
* @param securityToken
|
||||
* for {@link Target#getSecurityToken()} is generated with a
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
/**
|
||||
* Builder for {@link TargetType}.
|
||||
*
|
||||
*/
|
||||
public interface TargetTypeBuilder {
|
||||
/**
|
||||
* @param id
|
||||
* of the updatable entity
|
||||
* @return builder instance
|
||||
*/
|
||||
TargetTypeUpdate update(long id);
|
||||
|
||||
/**
|
||||
* @return builder instance
|
||||
*/
|
||||
TargetTypeCreate create();
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link TargetType} entry. Defines all fields
|
||||
* that can be set at creation time. Other fields are set by the repository
|
||||
* automatically, e.g. {@link BaseEntity#getCreatedAt()}.
|
||||
*
|
||||
*/
|
||||
public interface TargetTypeCreate {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* for {@link TargetType#getName()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotEmpty String name);
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* for {@link TargetType#getDescription()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
|
||||
/**
|
||||
* @param colour
|
||||
* for {@link TargetType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeCreate colour(@Size(max = TargetType.COLOUR_MAX_SIZE) String colour);
|
||||
|
||||
/**
|
||||
* @param compatible
|
||||
* for {@link TargetType#getCompatibleDistributionSetTypes()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeCreate compatible(@NotEmpty Collection<Long> compatible);
|
||||
|
||||
/**
|
||||
* @param compatible
|
||||
* for {@link TargetType#getCompatibleDistributionSetTypes()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
default TargetTypeCreate compatible(@NotNull final Long compatible) {
|
||||
return compatible(Collections.singletonList(compatible));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param compatible
|
||||
* for {@link TargetType#getCompatibleDistributionSetTypes()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
default TargetTypeCreate compatible(@NotNull final DistributionSetType compatible) {
|
||||
return compatible(compatible.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return peek on current state of {@link TargetType} in the
|
||||
* builder
|
||||
*/
|
||||
TargetType build();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link TargetType} entry. Defines all
|
||||
* fields that can be updated.
|
||||
*
|
||||
*/
|
||||
public interface TargetTypeUpdate {
|
||||
/**
|
||||
* @param description
|
||||
* for {@link TargetType#getDescription()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
|
||||
/**
|
||||
* @param colour
|
||||
* for {@link TargetType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeUpdate colour(@Size(max = TargetType.COLOUR_MAX_SIZE) String colour);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeUpdate name(@Size(max = TargetType.NAME_MAX_SIZE) String name);
|
||||
}
|
||||
@@ -43,6 +43,13 @@ public interface TargetUpdate {
|
||||
*/
|
||||
TargetUpdate securityToken(@Size(min = 1, max = Target.SECURITY_TOKEN_MAX_SIZE) @NotNull String securityToken);
|
||||
|
||||
/**
|
||||
* @param targetTypeId
|
||||
* for {@link Target#getTargetType()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetUpdate targetType(@NotNull Long targetTypeId);
|
||||
|
||||
/**
|
||||
* @param address
|
||||
* for {@link Target#getAddress()}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link TargetType}.
|
||||
*/
|
||||
public class TargetTypeDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetTypeDeletedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for json serialization.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entityId
|
||||
* the entity id
|
||||
* @param entityClass
|
||||
* the entity class
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public TargetTypeDeletedEvent(final String tenant, final Long entityId, final String entityClass,
|
||||
final String applicationId) {
|
||||
super(entityId, tenant, entityClass, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entity.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link TargetType}.
|
||||
*
|
||||
*/
|
||||
public class TargetTypeCreatedEvent extends RemoteEntityEvent<TargetType>
|
||||
implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetTypeCreatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* the TargetType
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public TargetTypeCreatedEvent(final TargetType baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entity.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link TargetType}.
|
||||
*
|
||||
*/
|
||||
public class TargetTypeUpdatedEvent extends RemoteEntityEvent<TargetType>
|
||||
implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetTypeUpdatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* TargetType
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public TargetTypeUpdatedEvent(final TargetType baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
|
||||
/**
|
||||
* the {@link DistributionSetTypeNotInTargetTypeException} is thrown when a
|
||||
* {@link DistributionSetType} is requested as part of a {@link TargetType} but
|
||||
* is not returned in {@link TargetType#getCompatibleDistributionSetTypes()}.
|
||||
*/
|
||||
public class DistributionSetTypeNotInTargetTypeException extends EntityNotFoundException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param distributionSetTypeId
|
||||
* that is not part of given {@link TargetType}
|
||||
* @param targetTypeId
|
||||
* of the {@link TargetType} where given
|
||||
* {@link DistributionSetType} is not part of
|
||||
*/
|
||||
public DistributionSetTypeNotInTargetTypeException(final Long distributionSetTypeId,
|
||||
final Long targetTypeId) {
|
||||
super(DistributionSetType.class.getSimpleName() + " with id {" + distributionSetTypeId + "} is not part of "
|
||||
+ TargetType.class.getSimpleName() + " with id {" + targetTypeId + "}.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
|
||||
/**
|
||||
* Thrown if target type is assigned
|
||||
*/
|
||||
public class TargetTypeInUseException extends AbstractServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_TARGET_TYPE_IN_USE;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetTypeInUseException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public TargetTypeInUseException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public TargetTypeInUseException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public TargetTypeInUseException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,11 @@ public interface Target extends NamedEntity {
|
||||
*/
|
||||
TargetUpdateStatus getUpdateStatus();
|
||||
|
||||
/**
|
||||
* @return Target type {@link TargetType}.
|
||||
*/
|
||||
TargetType getTargetType();
|
||||
|
||||
/**
|
||||
* @return the poll time which holds the last poll time of the target, the
|
||||
* next poll time and the overdue time. In case the
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO 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.util.Set;
|
||||
|
||||
/**
|
||||
* A {@link TargetType} is an abstract definition for
|
||||
* {@link Target}
|
||||
*
|
||||
*/
|
||||
public interface TargetType extends NamedEntity {
|
||||
/**
|
||||
* Maximum length of color in Management UI.
|
||||
*/
|
||||
int COLOUR_MAX_SIZE = 16;
|
||||
|
||||
/**
|
||||
* @return immutable set of optional {@link DistributionSetType}s
|
||||
*/
|
||||
Set<DistributionSetType> getCompatibleDistributionSetTypes();
|
||||
|
||||
/**
|
||||
* @return immutable set of optional {@link Target}s
|
||||
*/
|
||||
Set<Target> getTargets();
|
||||
|
||||
/**
|
||||
* Checks if the given {@link DistributionSetType} is in
|
||||
* {@link #getCompatibleDistributionSetTypes()}.
|
||||
*
|
||||
* @param distributionSetType
|
||||
* search for
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
default boolean containsCompatibleDistributionSetType(final DistributionSetType distributionSetType) {
|
||||
return containsCompatibleDistributionSetType(distributionSetType.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given {@link DistributionSetType} is in
|
||||
* {@link #getCompatibleDistributionSetTypes()}.
|
||||
*
|
||||
* @param distributionSetTypeId
|
||||
* search by {@link DistributionSetType#getId()}
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
default boolean containsCompatibleDistributionSetType(final Long distributionSetTypeId) {
|
||||
return getCompatibleDistributionSetTypes().stream().anyMatch(element -> element.getId().equals(distributionSetTypeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unassigns a distribution set type from target types
|
||||
* @param dsTypeId
|
||||
* @return the resulting target type
|
||||
*/
|
||||
TargetType removeDistributionSetType(final Long dsTypeId);
|
||||
|
||||
/**
|
||||
* @return get color code to be used in management UI views.
|
||||
*/
|
||||
String getColour();
|
||||
}
|
||||
Reference in New Issue
Block a user