Repository API query signatures Entity free (#403)

* Migrated target management queries to IDs inetsead of full entities

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Added missing comment.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* refactored target,DS,cont,deploy,rg mangement.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Adde versioning documentation.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Rollout, Dist and Software mgmt refactored

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Readded line that was remove by incident. 

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed broken tests.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Query management refactored

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix bug of auto assign DS delete

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Switch to collection

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed compile error

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Small glitches

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed test after merge

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-01-11 14:32:55 +01:00
committed by GitHub
parent 824ef2982f
commit 889d1492fb
97 changed files with 1126 additions and 1289 deletions

View File

@@ -239,8 +239,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
final int deleteSWModuleTypeCount = artifactUploadState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) {
softwareManagement
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
softwareManagement.deleteSoftwareModuleType(
softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName).getId());
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));

View File

@@ -227,7 +227,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version,
swMgmtService.findSoftwareModuleTypeByName(type));
swMgmtService.findSoftwareModuleTypeByName(type).getId());
if (swModule != null) {
uiNotifcation.displayValidationError(

View File

@@ -32,7 +32,7 @@ public class SoftwareModuleFilters implements Serializable {
private String searchText;
public Optional<SoftwareModuleType> getSoftwareModuleType() {
return softwareModuleType == null ? Optional.empty() : Optional.of(softwareModuleType);
return Optional.ofNullable(softwareModuleType);
}
public void setSoftwareModuleType(final SoftwareModuleType softwareModuleType) {
@@ -40,7 +40,7 @@ public class SoftwareModuleFilters implements Serializable {
}
public Optional<String> getSearchText() {
return searchText == null ? Optional.empty() : Optional.of(searchText);
return Optional.ofNullable(searchText);
}
public void setSearchText(final String searchText) {

View File

@@ -183,7 +183,7 @@ public class SoftwareModuleDetailsTable extends Table {
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet,
final Set<SoftwareModule> alreadyAssignedSwModules) {
final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules);
if (distributionSetManagement.isDistributionSetInUse(distributionSet)) {
if (distributionSetManagement.isDistributionSetInUse(distributionSet.getId())) {
uiNotification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned",
distributionSet.getName(), distributionSet.getVersion()));
} else {

View File

@@ -406,7 +406,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
final DistributionSetTypeUpdate update = entityFactory.distributionSetType().update(existingType.getId())
.description(tagDesc.getValue())
.colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
if (distributionSetManagement.countDistributionSetsByType(existingType) <= 0 && null != itemIds
if (distributionSetManagement.countDistributionSetsByType(existingType.getId()) <= 0 && null != itemIds
&& !itemIds.isEmpty()) {
update.mandatory(itemIds.stream().filter(itemId -> isMandatoryModuleType(selectedTable.getItem(itemId)))
@@ -509,7 +509,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
if (null != selectedTypeTag) {
tagDesc.setValue(selectedTypeTag.getDescription());
typeKey.setValue(selectedTypeTag.getKey());
if (distributionSetManagement.countDistributionSetsByType(selectedTypeTag) <= 0) {
if (distributionSetManagement.countDistributionSetsByType(selectedTypeTag.getId()) <= 0) {
distTypeSelectLayout.setEnabled(true);
selectedTable.setEnabled(true);
} else {

View File

@@ -345,7 +345,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
return false;
}
if (distributionSetManagement.isDistributionSetInUse(ds)) {
if (distributionSetManagement.isDistributionSetInUse(ds.getId())) {
notification.displayValidationError(
i18n.get("message.error.notification.ds.target.assigned", ds.getName(), ds.getVersion()));
return false;

View File

@@ -37,6 +37,7 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -275,8 +276,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final int deleteSWModuleTypeCount = manageDistUIState.getSelectedDeleteSWModuleTypes().size();
for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
softwareManagement
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
softwareManagement.deleteSoftwareModuleType(
softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName).getId());
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
@@ -370,7 +371,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
}
dsManagement.deleteDistributionSet(deletedIds);
dsManagement.deleteDistributionSet(Lists.newArrayList(deletedIds));
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.dist.deleted", deletedIds.length));
@@ -461,7 +462,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
final int deleteDistTypeCount = manageDistUIState.getSelectedDeleteDistSetTypes().size();
for (final String deleteDistTypeName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
dsManagement.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
dsManagement
.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName).getId());
}
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
+ i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));

View File

@@ -60,7 +60,7 @@ public class ManageDistFilters implements Serializable {
}
public Optional<String> getSearchText() {
return searchText == null ? Optional.empty() : Optional.of(searchText);
return Optional.ofNullable(searchText);
}
public void setSearchText(final String searchText) {

View File

@@ -34,7 +34,7 @@ public class ManageSoftwareModuleFilters implements Serializable {
* @return the softwareModuleType
*/
public Optional<SoftwareModuleType> getSoftwareModuleType() {
return softwareModuleType == null ? Optional.empty() : Optional.of(softwareModuleType);
return Optional.ofNullable(softwareModuleType);
}
/**
@@ -49,7 +49,7 @@ public class ManageSoftwareModuleFilters implements Serializable {
* @return the searchText
*/
public Optional<String> getSearchText() {
return searchText == null ? Optional.empty() : Optional.of(searchText);
return Optional.ofNullable(searchText);
}
/**

View File

@@ -242,7 +242,7 @@ public class DistributionSetSelectWindow
setContent(layout);
final Long targetsCount = targetManagement.countTargetsByTargetFilterQueryAndNonDS(distributionSetId,
targetFilterQuery);
targetFilterQuery.getQuery());
Label mainTextLabel;
if (targetsCount == 0) {
mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.none"));

View File

@@ -122,7 +122,7 @@ public class FilterManagementUIState implements Serializable {
* @return the tfQuery
*/
public Optional<TargetFilterQuery> getTfQuery() {
return targetFilterQuery == null ? Optional.empty() : Optional.of(targetFilterQuery);
return Optional.ofNullable(targetFilterQuery);
}
/**
@@ -142,7 +142,7 @@ public class FilterManagementUIState implements Serializable {
}
public Optional<String> getCustomFilterSearchText() {
return targetFilterSearchText == null ? Optional.empty() : Optional.of(targetFilterSearchText);
return Optional.ofNullable(targetFilterSearchText);
}
public void setCustomFilterSearchText(final String updateCustomFilterSearchText) {

View File

@@ -220,7 +220,7 @@ public class ActionHistoryTable extends TreeTable {
if (target != null) {
/* service method to create action history for target */
final List<ActionWithStatusCount> actionHistory = deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
.findActionsWithStatusCountByTargetOrderByIdDesc(target.getControllerId());
addDetailsToContainer(actionHistory);
}
@@ -437,9 +437,9 @@ public class ActionHistoryTable extends TreeTable {
new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName()));
final Page<ActionStatus> actionStatusList;
if (managementUIState.isActionHistoryMaximized()) {
actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action);
actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, actionId);
} else {
actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action);
actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, actionId);
}
final List<ActionStatus> content = actionStatusList.getContent();
/*
@@ -793,9 +793,8 @@ public class ActionHistoryTable extends TreeTable {
// service call to cancel the active action
private boolean cancelActiveAction(final Long actionId) {
if (actionId != null) {
final Action activeAction = deploymentManagement.findAction(actionId);
try {
deploymentManagement.cancelAction(activeAction, target);
deploymentManagement.cancelAction(actionId);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Cancel action not allowed exception :{}", e);
@@ -808,9 +807,8 @@ public class ActionHistoryTable extends TreeTable {
// service call to cancel the active action
private boolean forceQuitActiveAction(final Long actionId) {
if (actionId != null) {
final Action activeAction = deploymentManagement.findAction(actionId);
try {
deploymentManagement.forceQuitAction(activeAction);
deploymentManagement.forceQuitAction(actionId);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Force Cancel action not allowed exception :{}", e);

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.management.footer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -381,10 +380,11 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
private void deleteAllDistributions(final ConfirmationTab tab) {
final Set<Long> deletedIds = new HashSet<>();
managementUIState.getDeletedDistributionList().forEach(distIdName -> deletedIds.add(distIdName.getId()));
distributionSetManagement.deleteDistributionSet(deletedIds.toArray(new Long[deletedIds.size()]));
final Collection<Long> deletedIds = managementUIState.getDeletedDistributionList().stream()
.map(DistributionSetIdName::getId).collect(Collectors.toList());
distributionSetManagement.deleteDistributionSet(deletedIds);
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.REMOVE_ENTITY, deletedIds));
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
@@ -411,7 +411,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
}
}
private void unPinDeletedDS(final Set<Long> deletedDsIds, final Long pinnedDsId) {
private void unPinDeletedDS(final Collection<Long> deletedDsIds, final Long pinnedDsId) {
if (deletedDsIds.contains(pinnedDsId)) {
managementUIState.getTargetTableFilters().setPinnedDistId(null);
eventBus.publish(this, PinUnpinEvent.UNPIN_DISTRIBUTION);

View File

@@ -60,7 +60,7 @@ public class DistributionTableFilters implements Serializable {
}
public Optional<Long> getDistId() {
return distId == null ? Optional.empty() : Optional.of(distId);
return Optional.ofNullable(distId);
}
public void setDistId(final Long distId) {
@@ -68,7 +68,7 @@ public class DistributionTableFilters implements Serializable {
}
public Optional<String> getPinnedTargetId() {
return pinnedTargetId == null ? Optional.empty() : Optional.of(pinnedTargetId);
return Optional.ofNullable(pinnedTargetId);
}
public void setPinnedTargetId(final String pinnedTargetId) {
@@ -76,7 +76,7 @@ public class DistributionTableFilters implements Serializable {
}
public Optional<String> getSearchText() {
return searchText == null ? Optional.empty() : Optional.of(searchText);
return Optional.ofNullable(searchText);
}
public void setSearchText(final String searchText) {

View File

@@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
@@ -44,7 +43,7 @@ public class TargetTableFilters implements Serializable {
/**
* Custom target filter query use dto filter target table.
*/
private TargetFilterQuery targetFilterQuery;
private Long targetFilterQuery;
/**
* Flag for NO TAG button status.
*/
@@ -61,7 +60,7 @@ public class TargetTableFilters implements Serializable {
* @return the progressBarCurrentValue
*/
public Optional<Float> getProgressBarCurrentValue() {
return progressBarCurrentValue != null ? Optional.of(progressBarCurrentValue) : Optional.empty();
return Optional.ofNullable(progressBarCurrentValue);
}
/**
@@ -76,7 +75,7 @@ public class TargetTableFilters implements Serializable {
* @return the targetsCreatedCount
*/
public Optional<Long> getTargetsCreatedCount() {
return targetsCreatedCount != null ? Optional.of(targetsCreatedCount) : Optional.empty();
return Optional.ofNullable(targetsCreatedCount);
}
/**
@@ -96,15 +95,15 @@ public class TargetTableFilters implements Serializable {
}
public Optional<String> getSearchText() {
return searchText == null ? Optional.empty() : Optional.of(searchText);
return Optional.ofNullable(searchText);
}
public Optional<DistributionSetIdName> getDistributionSet() {
return distributionSet == null ? Optional.empty() : Optional.of(distributionSet);
return Optional.ofNullable(distributionSet);
}
public Optional<Long> getPinnedDistId() {
return pinnedDistId == null ? Optional.empty() : Optional.of(pinnedDistId);
return Optional.ofNullable(pinnedDistId);
}
public void setSearchText(final String searchText) {
@@ -151,15 +150,15 @@ public class TargetTableFilters implements Serializable {
/**
* @return the targetFilterQuery
*/
public Optional<TargetFilterQuery> getTargetFilterQuery() {
return targetFilterQuery == null ? Optional.empty() : Optional.of(targetFilterQuery);
public Optional<Long> getTargetFilterQuery() {
return Optional.ofNullable(targetFilterQuery);
}
/**
* @param targetFilterQuery
* the targetFilterQuery to set
*/
public void setTargetFilterQuery(final TargetFilterQuery targetFilterQuery) {
public void setTargetFilterQuery(final Long targetFilterQuery) {
this.targetFilterQuery = targetFilterQuery;
}
@@ -167,7 +166,7 @@ public class TargetTableFilters implements Serializable {
return isOverdueFilterEnabled;
}
public void setOverdueFilterEnabled(boolean isOverdueFilterEnabled) {
public void setOverdueFilterEnabled(final boolean isOverdueFilterEnabled) {
this.isOverdueFilterEnabled = isOverdueFilterEnabled;
}

View File

@@ -120,7 +120,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId,
new FilterParams(distributionId, status, overdueState, searchText, noTagClicked, targetTags));
} else if (null != targetFilterQuery) {
targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery,
targetBeans = getTargetManagement().findTargetsByTargetFilterQuery(targetFilterQuery.getId(),
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
} else if (!isAnyFilterSelected()) {
targetBeans = getTargetManagement().findTargetsAll(
@@ -189,7 +189,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
final long totSize = getTargetManagement().countTargetsAll();
long size;
if (null != targetFilterQuery) {
size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery);
size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery.getId());
} else if (!isAnyFilterSelected()) {
size = totSize;
} else {

View File

@@ -53,7 +53,7 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
protected void filterClicked(final Button clickedButton) {
final TargetFilterQuery targetFilterQuery = this.targetFilterQueryManagement
.findTargetFilterQueryById((Long) clickedButton.getData());
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery);
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery.getId());
this.eventBus.publish(this, TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY);
}

View File

@@ -119,8 +119,7 @@ public class TargetFilterQueryButtons extends Table {
}
private boolean isClickedByDefault(final Long id) {
return managementUIState.getTargetTableFilters().getTargetFilterQuery().map(q -> q.getId().equals(id))
.orElse(false);
return managementUIState.getTargetTableFilters().getTargetFilterQuery().map(q -> q.equals(id)).orElse(false);
}
private Button createFilterButton(final Long id, final String name, final Object itemId) {

View File

@@ -137,7 +137,7 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
private String calculateFinishedPercentage(final RolloutGroup rolloutGroup) {
return HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup, getRolloutManagement()
.getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup));
.getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup.getId()));
}
@Override

View File

@@ -84,8 +84,8 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
}
return rolloutGroup.map(group -> getProxyRolloutGroupTargetsList(getRolloutGroupManagement()
.findAllTargetsWithActionStatus(new PageRequest(startIndex / count, count), group).getContent()))
.orElse(Collections.emptyList());
.findAllTargetsWithActionStatus(new PageRequest(startIndex / count, count), group.getId())
.getContent())).orElse(Collections.emptyList());
}
private static List<ProxyTarget> getProxyRolloutGroupTargetsList(
@@ -136,7 +136,7 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
if (rolloutGroup.isPresent()) {
firstPageTargetSets = getRolloutGroupManagement().findAllTargetsWithActionStatus(
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), rolloutGroup.get());
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), rolloutGroup.get().getId());
size = firstPageTargetSets.getTotalElements();
}
getRolloutUIState().setRolloutGroupTargetsTotalCount(size);

View File

@@ -50,7 +50,7 @@ public class RolloutUIState implements Serializable {
* @return the searchText
*/
public Optional<String> getSearchText() {
return null != searchText ? Optional.of(searchText) : Optional.empty();
return Optional.ofNullable(searchText);
}
/**
@@ -65,7 +65,7 @@ public class RolloutUIState implements Serializable {
* @return the rolloutId
*/
public Optional<Long> getRolloutId() {
return rolloutId != null ? Optional.of(rolloutId) : Optional.empty();
return Optional.ofNullable(rolloutId);
}
/**
@@ -80,7 +80,7 @@ public class RolloutUIState implements Serializable {
* @return the rolloutGroup
*/
public Optional<RolloutGroup> getRolloutGroup() {
return rolloutGroup == null ? Optional.empty() : Optional.of(rolloutGroup);
return Optional.ofNullable(rolloutGroup);
}
/**
@@ -140,7 +140,7 @@ public class RolloutUIState implements Serializable {
* @return the rolloutName
*/
public Optional<String> getRolloutName() {
return rolloutName == null ? Optional.empty() : Optional.of(rolloutName);
return Optional.ofNullable(rolloutName);
}
/**
@@ -185,7 +185,7 @@ public class RolloutUIState implements Serializable {
* @return rolloutDistributionSet
*/
public Optional<String> getRolloutDistributionSet() {
return rolloutDistributionSet == null ? Optional.empty() : Optional.of(rolloutDistributionSet);
return Optional.ofNullable(rolloutDistributionSet);
}
/**