[#1509] Sync Target type with SW and DS types (Mgmt Layer) (#1513)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2023-12-13 11:48:51 +02:00
committed by GitHub
parent 71a5319019
commit 4b5a7d6e7d
10 changed files with 105 additions and 82 deletions

View File

@@ -13,6 +13,7 @@ import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.builder.AbstractTargetTypeUpdateCreate;
import org.eclipse.hawkbit.repository.builder.TargetTypeCreate;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.TargetTypeKeyOrNameRequiredException;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetType;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -42,10 +43,12 @@ public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTy
@Override
public JpaTargetType build() {
final JpaTargetType result = new JpaTargetType(name, description, colour);
if (key == null && name == null) {
throw new TargetTypeKeyOrNameRequiredException("Key or name of the target type shall be specified!");
}
final JpaTargetType result = new JpaTargetType(key == null ? name : key, name == null ? key : name, description, colour);
findDistributionSetTypeWithExceptionIfNotFound(compatible).forEach(result::addCompatibleDistributionSetType);
return result;
}
@@ -62,5 +65,4 @@ public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTy
return type;
}
}
}

View File

@@ -67,7 +67,7 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType,
}
/**
* Constructor
* Constructor, legacy support where <code>key</code> is set to passed <code>name</code>.
*
* @param name
* of the type
@@ -76,6 +76,7 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType,
* @param colour
* of the type
*/
@Deprecated
public JpaTargetType(final String name, final String description, final String colour) {
this(name, name, description, colour);
}