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