diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagFields.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagFields.java new file mode 100644 index 000000000..17ae18761 --- /dev/null +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagFields.java @@ -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 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 getSubEntityAttributes() { + return Collections.unmodifiableList(subEntityAttributes); + } + + @Override + public String getFieldName() { + return fieldName; + } +} \ No newline at end of file diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/TargetTagFields.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/TargetTagFields.java new file mode 100644 index 000000000..f0043ea8d --- /dev/null +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/TargetTagFields.java @@ -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 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 getSubEntityAttributes() { + return Collections.unmodifiableList(subEntityAttributes); + } + + @Override + public String getFieldName() { + return fieldName; + } +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java index 2e0df2f13..bc12bcaa7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java @@ -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; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java index f8dcd3d4f..005381919 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java @@ -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; diff --git a/hawkbit-runtime/hawkbit-update-server/pom.xml b/hawkbit-runtime/hawkbit-update-server/pom.xml index 531c2b53d..b75a5dc20 100644 --- a/hawkbit-runtime/hawkbit-update-server/pom.xml +++ b/hawkbit-runtime/hawkbit-update-server/pom.xml @@ -96,7 +96,7 @@ org.mariadb.jdbc mariadb-java-client - + test org.eclipse.hawkbit