Fix sonar findings (#1951)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
|
||||
import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* A base class which provide basis amqp staff.
|
||||
@@ -63,7 +64,7 @@ public class BaseAmqpService {
|
||||
}
|
||||
|
||||
protected static boolean isMessageBodyEmpty(final Message message) {
|
||||
return message.getBody() == null || message.getBody().length == 0;
|
||||
return ObjectUtils.isEmpty(message.getBody());
|
||||
}
|
||||
|
||||
protected static final void logAndThrowMessageError(final Message message, final String error) {
|
||||
|
||||
@@ -11,10 +11,10 @@ package org.eclipse.hawkbit.ui.simple.view;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.Key;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
@@ -42,50 +42,47 @@ public class ConfigView extends VerticalLayout {
|
||||
public ConfigView(final HawkbitMgmtClient hawkbitClient) {
|
||||
setSpacing(false);
|
||||
final Button saveButton = new Button("Save");
|
||||
hawkbitClient.getTenantManagementRestApi().getTenantConfiguration().getBody().forEach((k, v) -> {
|
||||
Component value = null;
|
||||
if (v.getValue() instanceof String strValue) {
|
||||
TextField tf = new TextField(k, strValue, event -> {
|
||||
final MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
tf.getElement().getStyle().set(WIDTH, PX_300);
|
||||
value = tf;
|
||||
} else if (v.getValue() instanceof Boolean boolValue) {
|
||||
value = new Checkbox(k, boolValue, event -> {
|
||||
final MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
} else if (v.getValue() instanceof Long longValue) {
|
||||
final NumberField nf = new NumberField(k, (double) longValue, event -> {
|
||||
final MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
nf.getElement().getStyle().set(WIDTH, PX_300);
|
||||
value = nf;
|
||||
} else if (v.getValue() instanceof Integer intValue) {
|
||||
final NumberField nf = new NumberField(k, (double) intValue, event -> {
|
||||
MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
nf.getElement().getStyle().set(WIDTH, PX_300);
|
||||
value = nf;
|
||||
} else {
|
||||
log.debug("Unexpected value type: {} -> {} (class: {})", k, v.getValue(),
|
||||
v.getValue() == null ? "null" : v.getValue().getClass());
|
||||
}
|
||||
if (value != null) {
|
||||
add(value);
|
||||
}
|
||||
});
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getTenantManagementRestApi().getTenantConfiguration().getBody()).ifPresent(config ->
|
||||
config.forEach((k, v) -> {
|
||||
if (v.getValue() instanceof String strValue) {
|
||||
final TextField tf = new TextField(k, strValue, event -> {
|
||||
final MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
tf.getElement().getStyle().set(WIDTH, PX_300);
|
||||
add(tf);
|
||||
} else if (v.getValue() instanceof Boolean boolValue) {
|
||||
add(new Checkbox(k, boolValue, event -> {
|
||||
final MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
}));
|
||||
} else if (v.getValue() instanceof Long longValue) {
|
||||
final NumberField nf = new NumberField(k, (double) longValue, event -> {
|
||||
final MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
nf.getElement().getStyle().set(WIDTH, PX_300);
|
||||
add(nf);
|
||||
} else if (v.getValue() instanceof Integer intValue) {
|
||||
final NumberField nf = new NumberField(k, (double) intValue, event -> {
|
||||
MgmtSystemTenantConfigurationValueRequest vre = new MgmtSystemTenantConfigurationValueRequest();
|
||||
vre.setValue(event.getValue());
|
||||
configValue.put(k, vre);
|
||||
});
|
||||
nf.getElement().getStyle().set(WIDTH, PX_300);
|
||||
add(nf);
|
||||
} else {
|
||||
log.debug("Unexpected value type: {} -> {} (class: {})",
|
||||
k, v.getValue(), v.getValue() == null ? "null" : v.getValue().getClass());
|
||||
}
|
||||
}));
|
||||
|
||||
saveButton.addClickListener(click ->
|
||||
configValue.forEach((key, value) ->
|
||||
hawkbitClient.getTenantManagementRestApi().updateTenantConfigurationValue(key, value)));
|
||||
saveButton.addClickListener(click -> configValue.forEach(
|
||||
(key, value) -> hawkbitClient.getTenantManagementRestApi().updateTenantConfigurationValue(key, value)));
|
||||
saveButton.addClickShortcut(Key.ENTER);
|
||||
add(saveButton);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.simple.view;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
@@ -38,6 +40,7 @@ import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.data.renderer.ComponentRenderer;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
|
||||
@@ -75,12 +78,11 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
|
||||
() -> details, DistributionSetDetails::setItem));
|
||||
}
|
||||
},
|
||||
(query, rsqlFilter) -> hawkbitClient.getDistributionSetRestApi()
|
||||
.getDistributionSets(
|
||||
query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.stream(),
|
||||
(query, rsqlFilter) -> Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.getDistributionSets(query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter)
|
||||
.getBody())
|
||||
.stream().flatMap(body -> body.getContent().stream()),
|
||||
e -> new CreateDialog(hawkbitClient).result(),
|
||||
selectionGrid -> {
|
||||
selectionGrid.getSelectedItems().forEach(
|
||||
@@ -115,17 +117,19 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
|
||||
private DistributionSetFilter(final HawkbitMgmtClient hawkbitClient) {
|
||||
name.setPlaceholder("<name filter>");
|
||||
type.setItemLabelGenerator(MgmtDistributionSetType::getName);
|
||||
type.setItems(
|
||||
hawkbitClient.getDistributionSetTypeRestApi()
|
||||
.getDistributionSetTypes(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody()
|
||||
.getContent());
|
||||
type.setItems(Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetTypeRestApi()
|
||||
.getDistributionSetTypes(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody())
|
||||
.map(PagedList::getContent)
|
||||
.orElseGet(Collections::emptyList));
|
||||
tag.setItemLabelGenerator(MgmtTag::getName);
|
||||
tag.setItems(
|
||||
hawkbitClient.getDistributionSetTagRestApi()
|
||||
.getDistributionSetTags(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody()
|
||||
.getContent());
|
||||
tag.setItems(Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetTagRestApi()
|
||||
.getDistributionSetTags(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody())
|
||||
.map(PagedList::getContent)
|
||||
.orElseGet(Collections::emptyList));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,14 +185,12 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
|
||||
lastModifiedBy.setValue(distributionSet.getLastModifiedBy());
|
||||
lastModifiedAt.setValue(new Date(distributionSet.getLastModifiedAt()).toString());
|
||||
|
||||
softwareModulesGrid.setItems(query ->
|
||||
softwareModulesGrid.setItems(query -> Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.getAssignedSoftwareModules(
|
||||
distributionSet.getDsId(),
|
||||
query.getOffset(), query.getLimit(), Constants.NAME_ASC)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.stream());
|
||||
.getBody()).stream().flatMap(body -> body.getContent().stream()));
|
||||
softwareModulesGrid.setSelectionMode(Grid.SelectionMode.NONE);
|
||||
}
|
||||
}
|
||||
@@ -211,11 +213,12 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
|
||||
type = new Select<>(
|
||||
"Type",
|
||||
this::readyToCreate,
|
||||
hawkbitClient.getDistributionSetTypeRestApi()
|
||||
.getDistributionSetTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.toArray(new MgmtDistributionSetType[0]));
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetTypeRestApi()
|
||||
.getDistributionSetTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody())
|
||||
.map(body -> body.getContent().toArray(new MgmtDistributionSetType[0]))
|
||||
.orElseGet(() -> new MgmtDistributionSetType[0]));
|
||||
type.focus();
|
||||
type.setWidthFull();
|
||||
type.setRequiredIndicatorVisible(true);
|
||||
@@ -258,16 +261,18 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
|
||||
private void addCreateClickListener() {
|
||||
create.addClickListener(e -> {
|
||||
close();
|
||||
final long distributionSetId = hawkbitClient.getDistributionSetRestApi()
|
||||
.createDistributionSets(
|
||||
List.of((MgmtDistributionSetRequestBodyPost) new MgmtDistributionSetRequestBodyPost()
|
||||
.setType(type.getValue().getKey())
|
||||
.setName(name.getValue())
|
||||
.setVersion(version.getValue())
|
||||
.setDescription(description.getValue())
|
||||
.setRequiredMigrationStep(requiredMigrationStep.getValue())))
|
||||
.getBody()
|
||||
final long distributionSetId = Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.createDistributionSets(
|
||||
List.of((MgmtDistributionSetRequestBodyPost) new MgmtDistributionSetRequestBodyPost()
|
||||
.setType(type.getValue().getKey())
|
||||
.setName(name.getValue())
|
||||
.setVersion(version.getValue())
|
||||
.setDescription(description.getValue())
|
||||
.setRequiredMigrationStep(requiredMigrationStep.getValue())))
|
||||
.getBody())
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.getDsId();
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.time.ZoneOffset;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -86,12 +87,11 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
|
||||
() -> details, RolloutDetails::setItem));
|
||||
}
|
||||
},
|
||||
(query, rsqlFilter) -> hawkbitClient.getRolloutRestApi()
|
||||
.getRollouts(
|
||||
query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter, "full")
|
||||
.getBody()
|
||||
.getContent()
|
||||
.stream(),
|
||||
(query, rsqlFilter) -> Optional.ofNullable(
|
||||
hawkbitClient.getRolloutRestApi()
|
||||
.getRollouts(
|
||||
query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter, "full")
|
||||
.getBody()).stream().flatMap(page -> page.getContent().stream()),
|
||||
selectionGrid -> new CreateDialog(hawkbitClient).result(),
|
||||
selectionGrid -> {
|
||||
selectionGrid.getSelectedItems().forEach(
|
||||
@@ -163,7 +163,10 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
|
||||
|
||||
private void refresh() {
|
||||
removeAll();
|
||||
init(hawkbitClient.getRolloutRestApi().getRollout(rolloutId).getBody());
|
||||
final MgmtRolloutResponseBody body = hawkbitClient.getRolloutRestApi().getRollout(rolloutId).getBody();
|
||||
if (body != null) {
|
||||
init(body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +239,11 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
|
||||
targetFilter.setValue(rollout.getTargetFilterQuery());
|
||||
final MgmtDistributionSet distributionSetMgmt = hawkbitClient.getDistributionSetRestApi()
|
||||
.getDistributionSet(rollout.getDistributionSetId()).getBody();
|
||||
distributionSet.setValue(distributionSetMgmt.getName() + ":" + distributionSetMgmt.getVersion());
|
||||
if (distributionSetMgmt == null) { // should not be here
|
||||
distributionSet.setValue("n/a (null)");
|
||||
} else {
|
||||
distributionSet.setValue(distributionSetMgmt.getName() + ":" + distributionSetMgmt.getVersion());
|
||||
}
|
||||
actonType.setValue(switch (rollout.getType()) {
|
||||
case SOFT -> Constants.SOFT;
|
||||
case FORCED -> Constants.FORCED;
|
||||
@@ -246,15 +253,16 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
|
||||
startAt.setValue(ObjectUtils.isEmpty(rollout.getStartAt()) ? "" : new Date(rollout.getStartAt()).toString());
|
||||
dynamic.setValue(rollout.isDynamic());
|
||||
|
||||
groupGrid.setItems(query ->
|
||||
hawkbitClient.getRolloutRestApi()
|
||||
.getRolloutGroups(
|
||||
rollout.getRolloutId(),
|
||||
query.getOffset(), query.getPageSize(),
|
||||
null, null, "full")
|
||||
.getBody().getContent().stream()
|
||||
.skip(query.getOffset())
|
||||
.limit(query.getPageSize()));
|
||||
groupGrid.setItems(query -> Optional.ofNullable(
|
||||
hawkbitClient.getRolloutRestApi()
|
||||
.getRolloutGroups(
|
||||
rollout.getRolloutId(),
|
||||
query.getOffset(), query.getPageSize(),
|
||||
null, null, "full")
|
||||
.getBody())
|
||||
.stream().flatMap(body -> body.getContent().stream())
|
||||
.skip(query.getOffset())
|
||||
.limit(query.getPageSize()));
|
||||
groupGrid.setSelectionMode(Grid.SelectionMode.NONE);
|
||||
}
|
||||
}
|
||||
@@ -283,11 +291,12 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
|
||||
distributionSet = new Select<>(
|
||||
"Distribution Set",
|
||||
this::readyToCreate,
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.getDistributionSets(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.toArray(new MgmtDistributionSet[0]));
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getDistributionSetRestApi()
|
||||
.getDistributionSets(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody())
|
||||
.map(body -> body.getContent().toArray(new MgmtDistributionSet[0]))
|
||||
.orElseGet(() -> new MgmtDistributionSet[0]));
|
||||
distributionSet.setRequiredIndicatorVisible(true);
|
||||
distributionSet.setItemLabelGenerator(distributionSetO ->
|
||||
distributionSetO.getName() + ":" + distributionSetO.getVersion());
|
||||
@@ -295,11 +304,12 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
|
||||
targetFilter = new Select<>(
|
||||
"Target Filter",
|
||||
this::readyToCreate,
|
||||
hawkbitClient.getTargetFilterQueryRestApi()
|
||||
.getFilters(0, 30, Constants.NAME_ASC, null, null)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.toArray(new MgmtTargetFilterQuery[0]));
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getTargetFilterQueryRestApi()
|
||||
.getFilters(0, 30, Constants.NAME_ASC, null, null)
|
||||
.getBody())
|
||||
.map(body -> body.getContent().toArray(new MgmtTargetFilterQuery[0]))
|
||||
.orElseGet(() -> new MgmtTargetFilterQuery[0]));
|
||||
targetFilter.setRequiredIndicatorVisible(true);
|
||||
targetFilter.setItemLabelGenerator(MgmtTargetFilterQuery::getName);
|
||||
targetFilter.setWidthFull();
|
||||
|
||||
@@ -12,11 +12,13 @@ package org.eclipse.hawkbit.ui.simple.view;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
@@ -43,6 +45,7 @@ import com.vaadin.flow.component.upload.receivers.FileBuffer;
|
||||
import com.vaadin.flow.data.renderer.ComponentRenderer;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
|
||||
@@ -87,12 +90,12 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
|
||||
}
|
||||
},
|
||||
(query, rsqlFilter) -> hawkbitClient.getSoftwareModuleRestApi()
|
||||
.getSoftwareModules(
|
||||
query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.stream(),
|
||||
(query, rsqlFilter) -> Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleRestApi()
|
||||
.getSoftwareModules(
|
||||
query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter)
|
||||
.getBody())
|
||||
.stream().flatMap(body -> body.getContent().stream()),
|
||||
isParent ? v -> new CreateDialog(hawkbitClient).result() : null,
|
||||
isParent ? selectionGrid -> {
|
||||
selectionGrid.getSelectedItems().forEach(
|
||||
@@ -127,11 +130,11 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
private SoftwareModuleFilter(final HawkbitMgmtClient hawkbitClient) {
|
||||
name.setPlaceholder("<name filter>");
|
||||
type.setItemLabelGenerator(MgmtSoftwareModuleType::getName);
|
||||
type.setItems(
|
||||
hawkbitClient.getSoftwareModuleTypeRestApi()
|
||||
.getTypes(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody()
|
||||
.getContent());
|
||||
type.setItems(Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleTypeRestApi()
|
||||
.getTypes(0, 20, Constants.NAME_ASC, null)
|
||||
.getBody()).map(PagedList::getContent)
|
||||
.orElseGet(Collections::emptyList));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,13 +191,14 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
lastModifiedBy.setValue(softwareModule.getLastModifiedBy());
|
||||
lastModifiedAt.setValue(new Date(softwareModule.getLastModifiedAt()).toString());
|
||||
|
||||
artifactGrid.setItems(query ->
|
||||
hawkbitClient.getSoftwareModuleRestApi()
|
||||
.getArtifacts(
|
||||
softwareModule.getModuleId(), null, null)
|
||||
.getBody().stream()
|
||||
.skip(query.getOffset())
|
||||
.limit(query.getPageSize()));
|
||||
artifactGrid.setItems(query -> Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleRestApi()
|
||||
.getArtifacts(
|
||||
softwareModule.getModuleId(), null, null)
|
||||
.getBody())
|
||||
.stream().flatMap(Collection::stream)
|
||||
.skip(query.getOffset())
|
||||
.limit(query.getPageSize()));
|
||||
artifactGrid.setSelectionMode(Grid.SelectionMode.NONE);
|
||||
}
|
||||
}
|
||||
@@ -215,11 +219,11 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
type = new Select<>(
|
||||
Constants.TYPE,
|
||||
this::readyToCreate,
|
||||
hawkbitClient.getSoftwareModuleTypeRestApi()
|
||||
.getTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody()
|
||||
.getContent()
|
||||
.toArray(new MgmtSoftwareModuleType[0]));
|
||||
Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleTypeRestApi()
|
||||
.getTypes(0, 30, Constants.NAME_ASC, null)
|
||||
.getBody()).map(body -> body.getContent().toArray(new MgmtSoftwareModuleType[0]))
|
||||
.orElseGet(() -> new MgmtSoftwareModuleType[0]));
|
||||
type.setWidthFull();
|
||||
type.setRequiredIndicatorVisible(true);
|
||||
type.setItemLabelGenerator(MgmtSoftwareModuleType::getName);
|
||||
@@ -261,16 +265,17 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
private void addCreateClickListener(final HawkbitMgmtClient hawkbitClient) {
|
||||
create.addClickListener(e -> {
|
||||
close();
|
||||
final long softwareModuleId = hawkbitClient.getSoftwareModuleRestApi().createSoftwareModules(
|
||||
List.of(new MgmtSoftwareModuleRequestBodyPost()
|
||||
.setType(type.getValue().getKey())
|
||||
.setName(name.getValue())
|
||||
.setVersion(version.getValue())
|
||||
.setVendor(vendor.getValue())
|
||||
.setDescription(description.getValue())
|
||||
.setEncrypted(enableArtifactEncryption.getValue())))
|
||||
.getBody()
|
||||
.stream()
|
||||
final long softwareModuleId = Optional.ofNullable(
|
||||
hawkbitClient.getSoftwareModuleRestApi().createSoftwareModules(
|
||||
List.of(new MgmtSoftwareModuleRequestBodyPost()
|
||||
.setType(type.getValue().getKey())
|
||||
.setName(name.getValue())
|
||||
.setVersion(version.getValue())
|
||||
.setVendor(vendor.getValue())
|
||||
.setDescription(description.getValue())
|
||||
.setEncrypted(enableArtifactEncryption.getValue())))
|
||||
.getBody())
|
||||
.stream().flatMap(Collection::stream)
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.getModuleId();
|
||||
|
||||
Reference in New Issue
Block a user