Refactoring after review
- added new method to HawkbitCommenUtil to reduce duplicated code - added early return Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -325,14 +325,14 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
tagData.getName());
|
tagData.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deletedTags.isEmpty()) {
|
if (deletedTags.isEmpty()) {
|
||||||
if (deletedTags.size() == 1) {
|
return null;
|
||||||
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
|
}
|
||||||
} else {
|
if (deletedTags.size() == 1) {
|
||||||
return i18n.get("message.bulk.upload.tag.assignments.failed");
|
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
|
||||||
}
|
} else {
|
||||||
|
return i18n.get("message.bulk.upload.tag.assignments.failed");
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean ifTagsSelected() {
|
private boolean ifTagsSelected() {
|
||||||
|
|||||||
@@ -549,11 +549,7 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
private String convertRolloutStatusToString(final RolloutStatus value) {
|
private String convertRolloutStatusToString(final RolloutStatus value) {
|
||||||
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
||||||
if (statusFontIcon == null) {
|
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final String codePoint = statusFontIcon.getFontIcon() != null
|
|
||||||
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
|
|
||||||
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
|
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
|
||||||
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
|
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setColumnProperties() {
|
protected void setColumnProperties() {
|
||||||
List<Object> columnList = new ArrayList<>();
|
final List<Object> columnList = new ArrayList<>();
|
||||||
columnList.add(SPUILabelDefinitions.VAR_NAME);
|
columnList.add(SPUILabelDefinitions.VAR_NAME);
|
||||||
columnList.add(SPUILabelDefinitions.VAR_STATUS);
|
columnList.add(SPUILabelDefinitions.VAR_STATUS);
|
||||||
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
|
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
|
||||||
@@ -240,7 +240,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
createRolloutGroupStatusToFontMap();
|
createRolloutGroupStatusToFontMap();
|
||||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(),
|
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(),
|
||||||
new RolloutGroupStatusConverter());
|
new RolloutGroupStatusConverter());
|
||||||
|
|
||||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
|
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
|
||||||
new TotalTargetCountStatusConverter());
|
new TotalTargetCountStatusConverter());
|
||||||
if (permissionChecker.hasRolloutTargetsReadPermission()) {
|
if (permissionChecker.hasRolloutTargetsReadPermission()) {
|
||||||
@@ -251,13 +251,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setHiddenColumns() {
|
protected void setHiddenColumns() {
|
||||||
List<Object> columnsToBeHidden = new ArrayList<>();
|
final List<Object> columnsToBeHidden = new ArrayList<>();
|
||||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
|
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
|
||||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
|
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
|
||||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
|
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
|
||||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
|
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
|
||||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
|
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
|
||||||
for (Object propertyId : columnsToBeHidden) {
|
for (final Object propertyId : columnsToBeHidden) {
|
||||||
getColumn(propertyId).setHidden(true);
|
getColumn(propertyId).setHidden(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,14 +267,12 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
return cell -> getDescription(cell);
|
return cell -> getDescription(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onClickOfRolloutGroupName(RendererClickEvent event) {
|
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
|
||||||
rolloutUIState
|
rolloutUIState
|
||||||
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
||||||
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void createRolloutGroupStatusToFontMap() {
|
private void createRolloutGroupStatusToFontMap() {
|
||||||
statusIconMap.put(RolloutGroupStatus.FINISHED,
|
statusIconMap.put(RolloutGroupStatus.FINISHED,
|
||||||
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
|
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
|
||||||
@@ -288,7 +286,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
|
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDescription(CellReference cell) {
|
private String getDescription(final CellReference cell) {
|
||||||
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
||||||
return cell.getProperty().getValue().toString().toLowerCase();
|
return cell.getProperty().getValue().toString().toLowerCase();
|
||||||
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
|
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
|
||||||
@@ -308,7 +306,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStyle(final CellReference cellReference) {
|
public String getStyle(final CellReference cellReference) {
|
||||||
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
|
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
|
||||||
SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS };
|
SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS };
|
||||||
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
|
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
|
||||||
return "centeralign";
|
return "centeralign";
|
||||||
@@ -329,14 +327,16 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
private static final long serialVersionUID = -9205943894818450807L;
|
private static final long serialVersionUID = -9205943894818450807L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
|
public TotalTargetCountStatus convertToModel(final String value,
|
||||||
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
|
||||||
|
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
|
public String convertToPresentation(final TotalTargetCountStatus value,
|
||||||
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
final Class<? extends String> targetType, final Locale locale)
|
||||||
|
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||||
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,14 +381,10 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
|||||||
public Class<String> getPresentationType() {
|
public Class<String> getPresentationType() {
|
||||||
return String.class;
|
return String.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
|
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
|
||||||
StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
||||||
if (statusFontIcon == null) {
|
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String codePoint = statusFontIcon.getFontIcon() != null
|
|
||||||
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
|
|
||||||
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
|
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
|
||||||
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
|
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
|
||||||
|
|
||||||
|
|||||||
@@ -238,11 +238,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
|||||||
|
|
||||||
private String processActionStatus(final Status status) {
|
private String processActionStatus(final Status status) {
|
||||||
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
|
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
|
||||||
if (statusFontIcon == null) {
|
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final String codePoint = statusFontIcon.getFontIcon() != null
|
|
||||||
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
|
|
||||||
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
|
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
|
|||||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||||
import org.eclipse.hawkbit.ui.management.dstable.DistributionTable;
|
import org.eclipse.hawkbit.ui.management.dstable.DistributionTable;
|
||||||
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
|
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
|
||||||
|
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
@@ -1359,12 +1360,12 @@ public final class HawkbitCommonUtil {
|
|||||||
* details of status and count
|
* details of status and count
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(Map<Status, Long> details) {
|
public static String getFormattedString(final Map<Status, Long> details) {
|
||||||
StringBuilder val = new StringBuilder();
|
final StringBuilder val = new StringBuilder();
|
||||||
if (details == null || details.isEmpty()) {
|
if (details == null || details.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (Entry<Status, Long> entry : details.entrySet()) {
|
for (final Entry<Status, Long> entry : details.entrySet()) {
|
||||||
val.append(entry.getKey()).append(":").append(entry.getValue()).append(",");
|
val.append(entry.getKey()).append(":").append(entry.getValue()).append(",");
|
||||||
}
|
}
|
||||||
return val.substring(0, val.length() - 1);
|
return val.substring(0, val.length() - 1);
|
||||||
@@ -1382,8 +1383,8 @@ public final class HawkbitCommonUtil {
|
|||||||
* label id
|
* label id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getStatusLabelDetailsInString(String value, String style, String id) {
|
public static String getStatusLabelDetailsInString(final String value, final String style, final String id) {
|
||||||
StringBuilder val = new StringBuilder();
|
final StringBuilder val = new StringBuilder();
|
||||||
if (!Strings.isNullOrEmpty(value)) {
|
if (!Strings.isNullOrEmpty(value)) {
|
||||||
val.append("value:").append(value).append(",");
|
val.append("value:").append(value).append(",");
|
||||||
}
|
}
|
||||||
@@ -1394,4 +1395,19 @@ public final class HawkbitCommonUtil {
|
|||||||
return val.toString();
|
return val.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive the code point of a given StatusFontIcon.
|
||||||
|
*
|
||||||
|
* @param statusFontIcon
|
||||||
|
* the status font icon
|
||||||
|
* @return the code point of the StatusFontIcon
|
||||||
|
*/
|
||||||
|
public static String getCodePoint(final StatusFontIcon statusFontIcon) {
|
||||||
|
if (statusFontIcon == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint())
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user