Fix code smells.

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
Marcel Mager (INST-IOT/ESB)
2016-09-23 09:57:23 +02:00
parent 52576a4489
commit ab7c2d6a61
7 changed files with 69 additions and 38 deletions

View File

@@ -17,6 +17,12 @@ import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/**
* Service that calculates non-persistent timestamps , e.g. the point a time a
* target is declared as overdue.<br>
* Therefore tenant specific configuration may be considered.
*
*/
@Service @Service
public class TimestampCalculator { public class TimestampCalculator {
@@ -33,10 +39,8 @@ public class TimestampCalculator {
* value * value
*/ */
public long calculateOverdueTimestamp() { public long calculateOverdueTimestamp() {
long overdueTs = Instant.now().toEpochMilli() // return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis()
- getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis() //
- getDurationForKey(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL).toMillis(); - getDurationForKey(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL).toMillis();
return overdueTs;
} }
private Duration getDurationForKey(TenantConfigurationKey key) { private Duration getDurationForKey(TenantConfigurationKey key) {

View File

@@ -446,8 +446,8 @@ public final class RSQLUtility {
final Object transformedValue = transformedValues.get(0); final Object transformedValue = transformedValues.get(0);
final String value; final String value;
if (virtualPropertyLookup != null) { // if lookup is available, // if lookup is available, replace macros ...
// replace macros ... if (virtualPropertyLookup != null) {
value = substitutor.replace(values.get(0)); value = substitutor.replace(values.get(0));
} else { } else {
value = values.get(0); value = values.get(0);
@@ -596,7 +596,7 @@ public final class RSQLUtility {
/** /**
* Adapts the <code>VirtualPropertyLookup</code> to <code>StrLookup</code>. * Adapts the <code>VirtualPropertyLookup</code> to <code>StrLookup</code>.
*/ */
final static class StrLookupAdapter extends StrLookup<String> { static final class StrLookupAdapter extends StrLookup<String> {
private VirtualPropertyLookup virtualPropertyLookup; private VirtualPropertyLookup virtualPropertyLookup;

View File

@@ -24,5 +24,5 @@ public interface VirtualPropertyLookup {
* @return the value for the placeholder; may be <code>null</code> if no * @return the value for the placeholder; may be <code>null</code> if no
* value could be found for the given placeholder; * value could be found for the given placeholder;
*/ */
public String lookup(String placeholder); String lookup(String placeholder);
} }

View File

@@ -76,7 +76,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder; String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString); String resolvedPlaceholders = substitutor.replace(testString);
assertFalse(resolvedPlaceholders.contains(placeholder)); assertFalse("NOW_TS has to be resolved!", resolvedPlaceholders.contains(placeholder));
} }
@Test @Test
@@ -86,7 +86,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder; String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString); String resolvedPlaceholders = substitutor.replace(testString);
assertFalse(resolvedPlaceholders.contains(placeholder)); assertFalse("OVERDUE_TS has to be resolved!", resolvedPlaceholders.contains(placeholder));
} }
@Test @Test
@@ -96,7 +96,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder; String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString); String resolvedPlaceholders = substitutor.replace(testString);
assertFalse(resolvedPlaceholders.contains(placeholder)); assertFalse("overdue_ts has to be resolved!", resolvedPlaceholders.contains(placeholder));
} }
@Test @Test
@@ -106,7 +106,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder; String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString); String resolvedPlaceholders = substitutor.replace(testString);
assertTrue(resolvedPlaceholders.contains(placeholder)); assertTrue("unknown should not be resolved!", resolvedPlaceholders.contains(placeholder));
} }
@Test @Test
@@ -117,6 +117,6 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + escaptedPlaceholder; String testString = "lhs=lt=" + escaptedPlaceholder;
String resolvedPlaceholders = substitutor.replace(testString); String resolvedPlaceholders = substitutor.replace(testString);
assertTrue(resolvedPlaceholders.contains(placeholder)); assertTrue("Escaped OVERDUE_TS should not be resolved!", resolvedPlaceholders.contains(placeholder));
} }
} }

View File

@@ -14,22 +14,39 @@ package org.eclipse.hawkbit.ui.management.event;
* *
*/ */
public enum ManagementUIEvent { public enum ManagementUIEvent {
SHOW_COUNT_MESSAGE, // //
UPDATE_COUNT, // SHOW_COUNT_MESSAGE,
UPDATE_FILTERCOUNT_MESSAGE, // //
HIDE_TARGET_TAG_LAYOUT, // UPDATE_COUNT,
SHOW_TARGET_TAG_LAYOUT, // //
HIDE_DISTRIBUTION_TAG_LAYOUT, // UPDATE_FILTERCOUNT_MESSAGE,
SHOW_DISTRIBUTION_TAG_LAYOUT, // //
MAX_ACTION_HISTORY, // HIDE_TARGET_TAG_LAYOUT,
MIN_ACTION_HISTORY, // //
CLOSE_SAVE_ACTIONS_WINDOW, // SHOW_TARGET_TAG_LAYOUT,
UNASSIGN_TARGET_TAG, // //
UNASSIGN_DISTRIBUTION_TAG, // HIDE_DISTRIBUTION_TAG_LAYOUT,
ASSIGN_TARGET_TAG, // //
ASSIGN_DISTRIBUTION_TAG, // SHOW_DISTRIBUTION_TAG_LAYOUT,
TARGET_TABLE_FILTER, // //
RESET_SIMPLE_FILTERS, // MAX_ACTION_HISTORY,
//
MIN_ACTION_HISTORY,
//
CLOSE_SAVE_ACTIONS_WINDOW,
//
UNASSIGN_TARGET_TAG,
//
UNASSIGN_DISTRIBUTION_TAG,
//
ASSIGN_TARGET_TAG,
//
ASSIGN_DISTRIBUTION_TAG,
//
TARGET_TABLE_FILTER,
//
RESET_SIMPLE_FILTERS,
//
RESET_TARGET_FILTER_QUERY RESET_TARGET_FILTER_QUERY
} }

View File

@@ -14,14 +14,24 @@ package org.eclipse.hawkbit.ui.management.event;
* *
*/ */
public enum TargetFilterEvent { public enum TargetFilterEvent {
FILTER_BY_TEXT, // //
FILTER_BY_TAG, // FILTER_BY_TEXT,
REMOVE_FILTER_BY_TEXT, // //
REMOVE_FILTER_BY_TAG, // FILTER_BY_TAG,
FILTER_BY_STATUS, // //
FILTER_BY_DISTRIBUTION, // REMOVE_FILTER_BY_TEXT,
REMOVE_FILTER_BY_STATUS, // //
REMOVE_FILTER_BY_DISTRIBUTION, // REMOVE_FILTER_BY_TAG,
FILTER_BY_TARGET_FILTER_QUERY, // //
FILTER_BY_STATUS,
//
FILTER_BY_DISTRIBUTION,
//
REMOVE_FILTER_BY_STATUS,
//
REMOVE_FILTER_BY_DISTRIBUTION,
//
FILTER_BY_TARGET_FILTER_QUERY,
//
REMOVE_FILTER_BY_TARGET_FILTER_QUERY REMOVE_FILTER_BY_TARGET_FILTER_QUERY
} }

View File

@@ -52,7 +52,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private Sort sort = new Sort(TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); private Sort sort = new Sort(TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
private transient Collection<TargetUpdateStatus> status = null; private transient Collection<TargetUpdateStatus> status = null;
private transient Boolean overdueState = null; private transient Boolean overdueState;
private String[] targetTags = null; private String[] targetTags = null;
private Long distributionId = null; private Long distributionId = null;
private String searchText = null; private String searchText = null;