Small serach fields refactoring (add lombok & style) (#1823)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-08-23 12:24:29 +03:00
committed by GitHub
parent ac34b952d9
commit 55cc600114
23 changed files with 238 additions and 693 deletions

View File

@@ -9,110 +9,57 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import lombok.Getter;
import java.util.Collections;
import java.util.List;
/**
* Sort and search fields for actions.
*/
@Getter
public enum ActionFields implements FieldNameProvider, FieldValueConverter<ActionFields> {
/**
* The status field.
*/
STATUS("active"),
/**
* The detailed action status
*/
DETAILSTATUS("status"),
/**
* The last action status code
*/
LASTSTATUSCODE("lastActionStatusCode"),
/**
* The id field.
*/
ID("id"),
/**
* The weight field.
*/
STATUS("active"),
DETAILSTATUS("status"),
LASTSTATUSCODE("lastActionStatusCode"),
WEIGHT("weight"),
/**
* The target field
*/
TARGET("target", TargetFields.ID.getFieldName(), TargetFields.NAME.getFieldName(),
TARGET("target",
TargetFields.ID.getFieldName(), TargetFields.NAME.getFieldName(),
TargetFields.UPDATESTATUS.getFieldName(), TargetFields.IPADDRESS.getFieldName()),
/**
* The distribution set field
*/
DISTRIBUTIONSET("distributionSet", DistributionSetFields.ID.getFieldName(),
DISTRIBUTIONSET("distributionSet",
DistributionSetFields.ID.getFieldName(),
DistributionSetFields.NAME.getFieldName(), DistributionSetFields.VERSION.getFieldName(),
DistributionSetFields.TYPE.getFieldName()),
/**
* The rollout field
*/
ROLLOUT("rollout", RolloutFields.ID.getFieldName(), RolloutFields.NAME.getFieldName()),
/**
* The rollout field
*/
ROLLOUTGROUP("rolloutGroup", RolloutGroupFields.ID.getFieldName(), RolloutGroupFields.NAME.getFieldName()),
/**
* The weight field.
*/
EXTERNALREF("externalRef");
private static final String ACTIVE = "pending";
private static final String INACTIVE = "finished";
private final String fieldName;
private final List<String> subEntityAttributes;
private List<String> subEntityAttributes;
private ActionFields(final String fieldName) {
ActionFields(final String fieldName) {
this.fieldName = fieldName;
this.subEntityAttributes = Collections.emptyList();
}
private ActionFields(final String fieldName, final String... subEntityAttributes) {
ActionFields(final String fieldName, final String... subEntityAttributes) {
this.fieldName = fieldName;
this.subEntityAttributes = Arrays.asList(subEntityAttributes);
}
@Override
public List<String> getSubEntityAttributes() {
return subEntityAttributes;
}
@Override
public String getFieldName() {
return fieldName;
this.subEntityAttributes = List.of(subEntityAttributes);
}
@Override
public Object convertValue(final ActionFields e, final String value) {
if (STATUS == e) {
return convertStatusValue(value);
}
return value;
return STATUS == e ? convertStatusValue(value) : value;
}
@Override
public String[] possibleValues(final ActionFields e) {
if (STATUS == e) {
return new String[] { ACTIVE, INACTIVE };
}
return new String[0];
return STATUS == e ? new String[] { ACTIVE, INACTIVE } : new String[0];
}
private static Object convertStatusValue(final String value) {

View File

@@ -9,33 +9,20 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Sort fields for {@link ActionStatusRest}.
*
*
*
*
* Sort and search fields for action status.
*/
@Getter
public enum ActionStatusFields implements FieldNameProvider {
/**
* The id field.
*/
ID("id"),
/**
* The reportedAt field.
*/
REPORTEDAT("createdAt");
private final String fieldName;
private ActionStatusFields(final String fieldName) {
ActionStatusFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}
}

View File

@@ -9,8 +9,9 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
@@ -19,104 +20,47 @@ import java.util.Optional;
/**
* Describing the fields of the DistributionSet model which can be used in the
* REST API e.g. for sorting etc.
*
*
*
*
*/
@Getter
public enum DistributionSetFields implements FieldNameProvider {
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The createdAt field.
*/
CREATEDAT("createdAt"),
/**
* The lastModifiedAt field.
*/
LASTMODIFIEDAT("lastModifiedAt"),
/**
* The version field.
*/
VERSION("version"),
/**
* The complete field.
*/
COMPLETE("complete"),
/**
* The id field.
*/
ID("id"),
/**
* The module field.
*/
MODULE("modules", SoftwareModuleFields.ID.getFieldName(), SoftwareModuleFields.NAME.getFieldName()),
/**
* The tags field.
*/
TAG("tags.name"),
/**
* The sw type key field.
*/
TYPE("type.key"),
/**
* The metadata.
*/
NAME("name"),
DESCRIPTION("description"),
CREATEDAT("createdAt"),
LASTMODIFIEDAT("lastModifiedAt"),
VERSION("version"),
COMPLETE("complete"),
MODULE("modules", SoftwareModuleFields.ID.getFieldName(), SoftwareModuleFields.NAME.getFieldName()),
TAG("tags.name"),
METADATA("metadata", new SimpleImmutableEntry<>("key", "value")),
/**
* The valid field.
*/
VALID("valid");
private final String fieldName;
private boolean mapField;
private Entry<String, String> subEntityMapTuple;
private final Entry<String, String> subEntityMapTuple;
private final List<String> subEntityAttributes;
private DistributionSetFields(final String fieldName) {
this(fieldName, false, null, Collections.emptyList());
DistributionSetFields(final String fieldName) {
this(fieldName, null, Collections.emptyList());
}
private DistributionSetFields(final String fieldName, final String... subEntityAttributes) {
this(fieldName, false, null, Arrays.asList(subEntityAttributes));
DistributionSetFields(final String fieldName, final String... subEntityAttributes) {
this(fieldName, null, List.of(subEntityAttributes));
}
private DistributionSetFields(final String fieldName, final Entry<String, String> subEntityMapTuple) {
this(fieldName, true, subEntityMapTuple, Collections.emptyList());
DistributionSetFields(final String fieldName, final Entry<String, String> subEntityMapTuple) {
this(fieldName, subEntityMapTuple, Collections.emptyList());
}
private DistributionSetFields(final String fieldName, final boolean mapField,
final Entry<String, String> subEntityMapTuple, List<String> subEntityAttributes) {
DistributionSetFields(final String fieldName, final Entry<String, String> subEntityMapTuple, List<String> subEntityAttributes) {
this.fieldName = fieldName;
this.mapField = mapField;
this.subEntityMapTuple = subEntityMapTuple;
this.subEntityAttributes = subEntityAttributes;
}
@Override
public List<String> getSubEntityAttributes() {
return Collections.unmodifiableList(subEntityAttributes);
}
@Override
public Optional<Entry<String, String>> getSubEntityMapTuple() {
return Optional.ofNullable(subEntityMapTuple);
}
@Override
public boolean isMap() {
return mapField;
}
@Override
public String getFieldName() {
return fieldName;
}
}
}

View File

@@ -9,37 +9,25 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Sort fields for DistributionSetMetadata.
*
*
*
*
*/
@Getter
public enum DistributionSetMetadataFields implements FieldNameProvider {
/**
* The value field.
*/
VALUE("value"),
/**
* The key field.
*/
KEY("key");
KEY("key"),
VALUE("value");
private final String fieldName;
private DistributionSetMetadataFields(final String fieldName) {
DistributionSetMetadataFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
@Override
public String identifierFieldName() {
return KEY.getFieldName();
}
}
}

View File

@@ -9,62 +9,37 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import lombok.Getter;
import java.util.Collections;
import java.util.List;
/**
* Describing the fields of the Tag model which can be used in the REST API e.g.
* for sorting etc.
* Additionally here were added fields for DistributionSet in order
* Additionally, here were added fields for DistributionSet in order
* filtering over distribution set fields also.
*/
@Getter
public enum DistributionSetTagFields implements FieldNameProvider {
/**
* The id field.
*/
ID(TagFields.ID.getFieldName()),
/**
* The name field.
*/
NAME(TagFields.NAME.getFieldName()),
/**
* The description field.
*/
DESCRIPTION(TagFields.DESCRIPTION.getFieldName()),
/**
* The controllerId field.
*/
COLOUR(TagFields.COLOUR.getFieldName()),
/**
* Distribution set fields
*/
DISTRIBUTIONSET("assignedToDistributionSet",
DistributionSetFields.ID.getFieldName(), DistributionSetFields.NAME.getFieldName());
private final String fieldName;
private final List<String> subEntityAttributes;
private DistributionSetTagFields(final String fieldName) {
DistributionSetTagFields(final String fieldName) {
this.fieldName = fieldName;
this.subEntityAttributes = Collections.emptyList();
}
private DistributionSetTagFields(final String fieldName, final String... subEntityAttributes) {
DistributionSetTagFields(final String fieldName, final String... subEntityAttributes) {
this.fieldName = fieldName;
this.subEntityAttributes = Arrays.asList(subEntityAttributes);
}
@Override
public List<String> getSubEntityAttributes() {
return Collections.unmodifiableList(subEntityAttributes);
}
@Override
public String getFieldName() {
return fieldName;
this.subEntityAttributes = List.of(subEntityAttributes);
}
}

View File

@@ -9,42 +9,23 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Describing the fields of the DistributionSetType model which can be used in
* the REST API e.g. for sorting etc.
*
*
*
*
*/
@Getter
public enum DistributionSetTypeFields implements FieldNameProvider {
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The type key field.
*/
ID("id"),
KEY("key"),
/**
* The id field.
*/
ID("id");
NAME("name"),
DESCRIPTION("description");
private final String fieldName;
private DistributionSetTypeFields(final String fieldName) {
DistributionSetTypeFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}

View File

@@ -15,7 +15,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
/**
* An interface for declaring the name of the field described in the database
@@ -29,6 +29,7 @@ public interface FieldNameProvider {
* Separator for the sub attributes
*/
String SUB_ATTRIBUTE_SEPARATOR = ".";
String SUB_ATTRIBUTE_SPLIT_REGEX = "\\" + SUB_ATTRIBUTE_SEPARATOR;
/**
* @return the string representation of the underlying persistence field
@@ -39,39 +40,36 @@ public interface FieldNameProvider {
/**
* Returns the sub attributes
*
* @param propertyFieldName
* the given field
* @param propertyFieldName the given field
* @return array consisting of sub attributes
*/
default String[] getSubAttributes(final String propertyFieldName) {
if (isMap()) {
final String[] subAttributes = propertyFieldName.split("\\" + SUB_ATTRIBUTE_SEPARATOR, 2);
// [0] fieldname |[1] keyname
final String[] subAttributes = propertyFieldName.split(SUB_ATTRIBUTE_SPLIT_REGEX, 2);
// [0] field name | [1] key name
final String mapKeyName = subAttributes.length == 2 ? subAttributes[1] : null;
if (StringUtils.isEmpty(mapKeyName)) {
if (ObjectUtils.isEmpty(mapKeyName)) {
return new String[] { getFieldName() };
}
return new String[] { getFieldName(), mapKeyName };
}
return propertyFieldName.split("\\" + SUB_ATTRIBUTE_SEPARATOR);
return propertyFieldName.split(SUB_ATTRIBUTE_SPLIT_REGEX);
}
/**
* Contains the sub entity the given field.
*
* @param propertyField
* the given field
* @param propertyField the given field
* @return <code>true</code> contains <code>false</code> contains not
*/
default boolean containsSubEntityAttribute(final String propertyField) {
final List<String> subEntityAttributes = getSubEntityAttributes();
if (subEntityAttributes.contains(propertyField)) {
return true;
}
for (final String attribute : subEntityAttributes) {
final String[] graph = attribute.split("\\" + SUB_ATTRIBUTE_SEPARATOR);
for (final String attribute : subEntityAttributes) {
final String[] graph = attribute.split(SUB_ATTRIBUTE_SPLIT_REGEX);
for (final String subAttribute : graph) {
if (subAttribute.equalsIgnoreCase(propertyField)) {
return true;
@@ -102,7 +100,7 @@ public interface FieldNameProvider {
* @return <code>true</code> is a map <code>false</code> is not a map
*/
default boolean isMap() {
return false;
return getSubEntityMapTuple().isPresent();
}
/**
@@ -113,4 +111,4 @@ public interface FieldNameProvider {
default String identifierFieldName() {
return "id";
}
}
}

View File

@@ -13,25 +13,19 @@ package org.eclipse.hawkbit.repository;
* A value convert which converts given string based values into an object which
* can be used for building generic queries. Mapping external API values e.g.
* REST API to inside representation on database. E.g. mapping 'pending' or
* 'finished' values in rest queries to {@link TargetAction#isActive()} boolean
* 'finished' values in rest queries to Action#isActive boolean
* value.
*
*
*
* @param <T>
* the enum parameter
*
* @param <T> the enum parameter
*/
public interface FieldValueConverter<T extends Enum<T>> {
/**
* converts the given {@code value} into the representation to build a
* Converts the given {@code value} into the representation to build a
* generic query.
*
* @param e
* the enum to build the value for
* @param value
* the value in string representation
* @param e the enum to build the value for
* @param value the value in string representation
* @return the converted object or {@code null} if conversation fails, if
* given enum does not need to be converted the the unmodified
* {@code value} is returned.
@@ -41,10 +35,8 @@ public interface FieldValueConverter<T extends Enum<T>> {
/**
* returns the possible values associated with the given enum type.
*
* @param e
* the enum type to retrieve the possible values
* @param e the enum type to retrieve the possible values
* @return the possible values for a specific enum or {@code null}
*/
String[] possibleValues(final T e);
}
}

View File

@@ -9,60 +9,35 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import lombok.Getter;
import java.util.Collections;
import java.util.List;
/**
* Describing the fields of the Rollout model which can be used in the REST API
* e.g. for sorting etc.
*
* Describing the fields of the Rollout model which can be used in the REST API e.g. for sorting etc.
*/
@Getter
public enum RolloutFields implements FieldNameProvider {
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The id field.
*/
ID("id"),
/**
* The status field.
*/
NAME("name"),
DESCRIPTION("description"),
STATUS("status"),
/**
* The Distribution set field.
*/
DISTRIBUTIONSET("distributionSet", DistributionSetFields.ID.getFieldName(),
DistributionSetFields.NAME.getFieldName(), DistributionSetFields.VERSION.getFieldName(),
DistributionSetFields.TYPE.getFieldName());
private final String fieldName;
private final List<String> subEntityAttributes;
private RolloutFields(final String fieldName) {
RolloutFields(final String fieldName) {
this.fieldName = fieldName;
this.subEntityAttributes = Collections.emptyList();
}
private RolloutFields(final String fieldName, final String... subEntityAttributes) {
RolloutFields(final String fieldName, final String... subEntityAttributes) {
this.fieldName = fieldName;
this.subEntityAttributes = Arrays.asList(subEntityAttributes);
this.subEntityAttributes = List.of(subEntityAttributes);
}
@Override
public List<String> getSubEntityAttributes() {
return Collections.unmodifiableList(subEntityAttributes);
}
@Override
public String getFieldName() {
return fieldName;
}
}
}

View File

@@ -9,33 +9,21 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Describing the fields of the RolloutGroup model which can be used in the REST
* API e.g. for sorting etc.
*
* Describing the fields of the RolloutGroup model which can be used in the REST API e.g. for sorting etc.
*/
@Getter
public enum RolloutGroupFields implements FieldNameProvider {
/**
* The name field.
*/
ID("id"),
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The id field.
*/
ID("id");
DESCRIPTION("description");
private final String fieldName;
private RolloutGroupFields(final String fieldName) {
RolloutGroupFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}

View File

@@ -9,60 +9,34 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Map.Entry;
import java.util.Optional;
/**
* Describing the fields of the SoftwareModule model which can be used in the
* REST API e.g. for sorting etc.
*
*
*
*
* Describing the fields of the SoftwareModule model which can be used in the REST API e.g. for sorting etc.
*/
@Getter
public enum SoftwareModuleFields implements FieldNameProvider {
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The description field.
*/
VERSION("version"),
/**
* The type field of the software module.
*/
TYPE("type.key"),
/**
* The id field.
*/
ID("id"),
/**
* The metadata.
*/
TYPE("type.key"),
NAME("name"),
DESCRIPTION("description"),
VERSION("version"),
METADATA("metadata", new SimpleImmutableEntry<>("key", "value"));
private final String fieldName;
private boolean mapField;
private Entry<String, String> subEntityMapTuple;
private SoftwareModuleFields(final String fieldName) {
this(fieldName, false, null);
SoftwareModuleFields(final String fieldName) {
this(fieldName, null);
}
private SoftwareModuleFields(final String fieldName, final Entry<String, String> subEntityMapTuple) {
this(fieldName, true, subEntityMapTuple);
}
private SoftwareModuleFields(final String fieldName, final boolean mapField,
final Entry<String, String> subEntityMapTuple) {
SoftwareModuleFields(final String fieldName, final Entry<String, String> subEntityMapTuple) {
this.fieldName = fieldName;
this.mapField = mapField;
this.subEntityMapTuple = subEntityMapTuple;
}
@@ -70,14 +44,4 @@ public enum SoftwareModuleFields implements FieldNameProvider {
public Optional<Entry<String, String>> getSubEntityMapTuple() {
return Optional.ofNullable(subEntityMapTuple);
}
@Override
public boolean isMap() {
return mapField;
}
@Override
public String getFieldName() {
return fieldName;
}
}
}

View File

@@ -9,40 +9,24 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Sort fields for SoftwareModuleMetadata.
*
*
*
*
*/
@Getter
public enum SoftwareModuleMetadataFields implements FieldNameProvider {
/**
* The value field.
*/
VALUE("value"),
/**
* The key field.
*/
KEY("key"),
/**
* The target visible field.
*/
VALUE("value"),
TARGETVISIBLE("targetVisible");
private final String fieldName;
private SoftwareModuleMetadataFields(final String fieldName) {
SoftwareModuleMetadataFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
@Override
public String identifierFieldName() {
return KEY.getFieldName();

View File

@@ -9,44 +9,23 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Describing the fields of the SoftwareModuleType model which can be used in
* the REST API e.g. for sorting etc.
*
*
*
*
* Describing the fields of the SoftwareModuleType model which can be used in the REST API e.g. for sorting etc.
*/
@Getter
public enum SoftwareModuleTypeFields implements FieldNameProvider {
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The type key field.
*/
KEY("key"),
/**
* The id field.
*/
ID("id"),
/**
* The max ds assignments field.
*/
KEY("key"),
NAME("name"),
DESCRIPTION("description"),
MAXASSIGNMENTS("maxAssignments");
private final String fieldName;
private SoftwareModuleTypeFields(final String fieldName) {
SoftwareModuleTypeFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}

View File

@@ -9,38 +9,22 @@
*/
package org.eclipse.hawkbit.repository;
/**
* Describing the fields of the Tag model which can be used in the REST API e.g.
* for sorting etc.
*
*/
public enum TagFields implements FieldNameProvider {
/**
* The id field.
*/
ID("id"),
import lombok.Getter;
/**
* The name field.
*/
/**
* Describing the fields of the Tag model which can be used in the REST API e.g. for sorting etc.
*/
@Getter
public enum TagFields implements FieldNameProvider {
ID("id"),
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The controllerId field.
*/
COLOUR("colour");
private final String fieldName;
private TagFields(final String fieldName) {
TagFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}

View File

@@ -9,8 +9,9 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
@@ -19,114 +20,48 @@ import java.util.Optional;
/**
* Describing the fields of the Target model which can be used in the REST API
* e.g. for sorting etc.
*
*/
@Getter
public enum TargetFields implements FieldNameProvider {
/**
* The controllerId field.
*/
ID("controllerId"),
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The createdAt field.
*/
CREATEDAT("createdAt"),
/**
* The createdAt field.
*/
LASTMODIFIEDAT("lastModifiedAt"),
/**
* The controllerId field.
*/
CONTROLLERID("controllerId"),
/**
* The updateStatus field.
*/
UPDATESTATUS("updateStatus"),
/**
* The ip-address field.
*/
IPADDRESS("address"),
/**
* The attribute map of target info.
*/
ATTRIBUTE("controllerAttributes", true),
/**
* distribution sets which is assigned to the target.
*/
ATTRIBUTE("controllerAttributes"),
ASSIGNEDDS("assignedDistributionSet", "name", "version"),
/**
* distribution sets which is installed on the target.
*/
INSTALLEDDS("installedDistributionSet", "name", "version"),
/**
* The tags field.
*/
TAG("tags.name"),
/**
* Last time the DDI or DMF client polled.
*/
LASTCONTROLLERREQUESTAT("lastTargetQuery"),
/**
* The metadata.
*/
METADATA("metadata", new SimpleImmutableEntry<>("key", "value")),
/**
* The target type.
*/
TARGETTYPE("targetType", TargetTypeFields.KEY.getFieldName(), TargetTypeFields.NAME.getFieldName());
private final String fieldName;
private List<String> subEntityAttribues;
private boolean mapField;
private Entry<String, String> subEntityMapTuple;
private final List<String> subEntityAttributes;
private final Entry<String, String> subEntityMapTuple;
private TargetFields(final String fieldName) {
this(fieldName, false, Collections.emptyList(), null);
TargetFields(final String fieldName) {
this(fieldName, Collections.emptyList(), null);
}
private TargetFields(final String fieldName, final boolean isMapField) {
this(fieldName, isMapField, Collections.emptyList(), null);
TargetFields(final String fieldName, final String... subEntityAttributes) {
this(fieldName, List.of(subEntityAttributes), null);
}
private TargetFields(final String fieldName, final String... subEntityAttribues) {
this(fieldName, false, Arrays.asList(subEntityAttribues), null);
TargetFields(final String fieldName, final Entry<String, String> subEntityMapTuple) {
this(fieldName, Collections.emptyList(), subEntityMapTuple);
}
private TargetFields(final String fieldName, final Entry<String, String> subEntityMapTuple) {
this(fieldName, true, Collections.emptyList(), subEntityMapTuple);
}
private TargetFields(final String fieldName, final boolean mapField, final List<String> subEntityAttribues,
final Entry<String, String> subEntityMapTuple) {
TargetFields(final String fieldName, final List<String> subEntityAttributes, final Entry<String, String> subEntityMapTuple) {
this.fieldName = fieldName;
this.mapField = mapField;
this.subEntityAttribues = subEntityAttribues;
this.subEntityAttributes = subEntityAttributes;
this.subEntityMapTuple = subEntityMapTuple;
}
@Override
public List<String> getSubEntityAttributes() {
return subEntityAttribues;
}
@Override
public Optional<Entry<String, String>> getSubEntityMapTuple() {
return Optional.ofNullable(subEntityMapTuple);
@@ -134,11 +69,6 @@ public enum TargetFields implements FieldNameProvider {
@Override
public boolean isMap() {
return mapField;
return this == ATTRIBUTE || getSubEntityMapTuple().isPresent();
}
@Override
public String getFieldName() {
return fieldName;
}
}
}

View File

@@ -9,55 +9,34 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import lombok.Getter;
import java.util.Collections;
import java.util.List;
/**
* Describing the fields of the Target model which can be used in the REST API
* e.g. for sorting etc.
*
* Describing the fields of the Target model which can be used in the REST API e.g. for sorting etc.
*/
@Getter
public enum TargetFilterQueryFields implements FieldNameProvider {
/**
* The id field.
*/
ID("id"),
/**
* The name field.
*/
NAME("name"),
/**
* Distribution set for auto-assignment.
*/
AUTOASSIGNDISTRIBUTIONSET("autoAssignDistributionSet", "name", "version");
private final String fieldName;
private List<String> subEntityAttributes;
private TargetFilterQueryFields(final String fieldName) {
TargetFilterQueryFields(final String fieldName) {
this(fieldName, Collections.emptyList());
}
private TargetFilterQueryFields(final String fieldName, final String... subEntityAttribues) {
this(fieldName, Arrays.asList(subEntityAttribues));
TargetFilterQueryFields(final String fieldName, final String... subEntityAttribues) {
this(fieldName, List.of(subEntityAttribues));
}
private TargetFilterQueryFields(final String fieldName, final List<String> subEntityAttribues) {
TargetFilterQueryFields(final String fieldName, final List<String> subEntityAttribues) {
this.fieldName = fieldName;
this.subEntityAttributes = subEntityAttribues;
}
@Override
public String getFieldName() {
return fieldName;
}
@Override
public List<String> getSubEntityAttributes() {
return subEntityAttributes;
}
}

View File

@@ -9,32 +9,23 @@
*/
package org.eclipse.hawkbit.repository;
import lombok.Getter;
/**
* Sort fields for TargetMetadata.
*
*/
@Getter
public enum TargetMetadataFields implements FieldNameProvider {
/**
* The value field.
*/
VALUE("value"),
/**
* The key field.
*/
KEY("key");
KEY("key"),
VALUE("value");
private final String fieldName;
private TargetMetadataFields(final String fieldName) {
TargetMetadataFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
@Override
public String identifierFieldName() {
return KEY.getFieldName();

View File

@@ -9,29 +9,18 @@
*/
package org.eclipse.hawkbit.repository;
/**
* Describing the fields of the Tag model which can be used in the REST API e.g.
* for sorting etc.
* Additionally, here were added fields for Target in order
* filtering over target fields also.
*/
public enum TargetTagFields implements FieldNameProvider {
/**
* The id field.
*/
ID(TagFields.ID.getFieldName()),
import lombok.Getter;
/**
* The name field.
*/
/**
* Describing the fields of the Tag model which can be used in the REST API e.g. for sorting etc.
* Additionally, here were added fields for Target in order filtering over target fields also.
*/
@Getter
public enum TargetTagFields implements FieldNameProvider {
ID(TagFields.ID.getFieldName()),
NAME(TagFields.NAME.getFieldName()),
/**
* The description field.
*/
DESCRIPTION(TagFields.DESCRIPTION.getFieldName()),
/**
* The controllerId field.
*/
COLOUR(TagFields.COLOUR.getFieldName());
private final String fieldName;
@@ -39,9 +28,4 @@ public enum TargetTagFields implements FieldNameProvider {
TargetTagFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}

View File

@@ -9,37 +9,22 @@
*/
package org.eclipse.hawkbit.repository;
/**
* Describing the fields of the TargetType model which can be used in
* the REST API
*/
public enum TargetTypeFields implements FieldNameProvider {
/**
* The name field.
*/
KEY("key"),
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
import lombok.Getter;
/**
* The id field.
*/
ID("id");
/**
* Describing the fields of the TargetType model which can be used in the REST API
*/
@Getter
public enum TargetTypeFields implements FieldNameProvider {
ID("id"),
KEY("key"),
NAME("name"),
DESCRIPTION("description");
private final String fieldName;
TargetTypeFields(final String fieldName) {
this.fieldName = fieldName;
}
@Override
public String getFieldName() {
return fieldName;
}
}