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());
|
||||
}
|
||||
}
|
||||
if (!deletedTags.isEmpty()) {
|
||||
if (deletedTags.size() == 1) {
|
||||
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
|
||||
} else {
|
||||
return i18n.get("message.bulk.upload.tag.assignments.failed");
|
||||
}
|
||||
if (deletedTags.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (deletedTags.size() == 1) {
|
||||
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() {
|
||||
|
||||
@@ -549,11 +549,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
|
||||
private String convertRolloutStatusToString(final RolloutStatus value) {
|
||||
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
||||
if (statusFontIcon == null) {
|
||||
return null;
|
||||
}
|
||||
final String codePoint = statusFontIcon.getFontIcon() != null
|
||||
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
|
||||
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
|
||||
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
|
||||
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
protected void setColumnProperties() {
|
||||
List<Object> columnList = new ArrayList<>();
|
||||
final List<Object> columnList = new ArrayList<>();
|
||||
columnList.add(SPUILabelDefinitions.VAR_NAME);
|
||||
columnList.add(SPUILabelDefinitions.VAR_STATUS);
|
||||
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
|
||||
@@ -240,7 +240,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
createRolloutGroupStatusToFontMap();
|
||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(),
|
||||
new RolloutGroupStatusConverter());
|
||||
|
||||
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
|
||||
new TotalTargetCountStatusConverter());
|
||||
if (permissionChecker.hasRolloutTargetsReadPermission()) {
|
||||
@@ -251,13 +251,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
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_USER);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
|
||||
for (Object propertyId : columnsToBeHidden) {
|
||||
for (final Object propertyId : columnsToBeHidden) {
|
||||
getColumn(propertyId).setHidden(true);
|
||||
}
|
||||
}
|
||||
@@ -267,14 +267,12 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
return cell -> getDescription(cell);
|
||||
}
|
||||
|
||||
private void onClickOfRolloutGroupName(RendererClickEvent event) {
|
||||
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
|
||||
rolloutUIState
|
||||
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
||||
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void createRolloutGroupStatusToFontMap() {
|
||||
statusIconMap.put(RolloutGroupStatus.FINISHED,
|
||||
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));
|
||||
}
|
||||
|
||||
private String getDescription(CellReference cell) {
|
||||
private String getDescription(final CellReference cell) {
|
||||
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
||||
return cell.getProperty().getValue().toString().toLowerCase();
|
||||
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
|
||||
@@ -308,7 +306,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
public String getStyle(final CellReference cellReference) {
|
||||
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
|
||||
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
|
||||
SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS };
|
||||
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
|
||||
return "centeralign";
|
||||
@@ -329,14 +327,16 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
private static final long serialVersionUID = -9205943894818450807L;
|
||||
|
||||
@Override
|
||||
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
|
||||
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
public TotalTargetCountStatus convertToModel(final String value,
|
||||
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
|
||||
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
public String convertToPresentation(final TotalTargetCountStatus value,
|
||||
final Class<? extends String> targetType, final Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
||||
}
|
||||
|
||||
@@ -381,14 +381,10 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
public Class<String> getPresentationType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
|
||||
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
|
||||
StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
||||
if (statusFontIcon == null) {
|
||||
return null;
|
||||
}
|
||||
String codePoint = statusFontIcon.getFontIcon() != null
|
||||
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
|
||||
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
|
||||
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
|
||||
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
|
||||
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
|
||||
|
||||
|
||||
@@ -238,11 +238,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
||||
|
||||
private String processActionStatus(final Status status) {
|
||||
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
|
||||
if (statusFontIcon == null) {
|
||||
return null;
|
||||
}
|
||||
final String codePoint = statusFontIcon.getFontIcon() != null
|
||||
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
|
||||
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
|
||||
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.ui.management.dstable.DistributionTable;
|
||||
import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
|
||||
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@@ -1359,12 +1360,12 @@ public final class HawkbitCommonUtil {
|
||||
* details of status and count
|
||||
* @return String
|
||||
*/
|
||||
public static String getFormattedString(Map<Status, Long> details) {
|
||||
StringBuilder val = new StringBuilder();
|
||||
public static String getFormattedString(final Map<Status, Long> details) {
|
||||
final StringBuilder val = new StringBuilder();
|
||||
if (details == null || details.isEmpty()) {
|
||||
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(",");
|
||||
}
|
||||
return val.substring(0, val.length() - 1);
|
||||
@@ -1382,8 +1383,8 @@ public final class HawkbitCommonUtil {
|
||||
* label id
|
||||
* @return
|
||||
*/
|
||||
public static String getStatusLabelDetailsInString(String value, String style, String id) {
|
||||
StringBuilder val = new StringBuilder();
|
||||
public static String getStatusLabelDetailsInString(final String value, final String style, final String id) {
|
||||
final StringBuilder val = new StringBuilder();
|
||||
if (!Strings.isNullOrEmpty(value)) {
|
||||
val.append("value:").append(value).append(",");
|
||||
}
|
||||
@@ -1394,4 +1395,19 @@ public final class HawkbitCommonUtil {
|
||||
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