Small refactoring + additional classes
Signed-off-by: Stanislav Trailov <Stanislav.Trailov@bosch.io>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2023 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Arrays;
|
||||
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
|
||||
* filtering over distribution set fields also.
|
||||
*/
|
||||
public enum DistributionSetTagFields implements FieldNameProvider {
|
||||
/**
|
||||
* The id field.
|
||||
*/
|
||||
ID("id"),
|
||||
|
||||
/**
|
||||
* The name field.
|
||||
*/
|
||||
NAME("name"),
|
||||
/**
|
||||
* The description field.
|
||||
*/
|
||||
DESCRIPTION("description"),
|
||||
/**
|
||||
* The controllerId field.
|
||||
*/
|
||||
COLOUR("colour"),
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
DISTRIBUTIONSET("assignedToDistributionSet",
|
||||
DistributionSetFields.ID.getFieldName(), DistributionSetFields.NAME.getFieldName());
|
||||
|
||||
private final String fieldName;
|
||||
|
||||
private final List<String> subEntityAttributes;
|
||||
|
||||
private DistributionSetTagFields(final String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
this.subEntityAttributes = Collections.emptyList();
|
||||
}
|
||||
|
||||
private 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2023 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Arrays;
|
||||
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 Target in order
|
||||
* filtering over target fields also.
|
||||
*/
|
||||
public enum TargetTagFields implements FieldNameProvider {
|
||||
/**
|
||||
* The id field.
|
||||
*/
|
||||
ID("id"),
|
||||
|
||||
/**
|
||||
* The name field.
|
||||
*/
|
||||
NAME("name"),
|
||||
/**
|
||||
* The description field.
|
||||
*/
|
||||
DESCRIPTION("description"),
|
||||
/**
|
||||
* The controllerId field.
|
||||
*/
|
||||
COLOUR("colour"),
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
TARGET("assignedToTargets",
|
||||
TargetFields.ID.getFieldName(), TargetFields.NAME.getFieldName());
|
||||
|
||||
private final String fieldName;
|
||||
|
||||
private final List<String> subEntityAttributes;
|
||||
|
||||
private TargetTagFields(final String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
this.subEntityAttributes = Collections.emptyList();
|
||||
}
|
||||
|
||||
private TargetTagFields(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;
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
@@ -26,10 +24,8 @@ import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cz.jirutka.rsql.parser.RSQLParser;
|
||||
import cz.jirutka.rsql.parser.ast.RSQLOperators;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
|
||||
@@ -35,7 +33,6 @@ import org.eclipse.hawkbit.utils.TenantConfigHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<!-- <scope>test</scope>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
|
||||
Reference in New Issue
Block a user