Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user