Skip to content

Commit

Permalink
review: deprecate WithSelectedFields in things model in favor in same…
Browse files Browse the repository at this point in the history
… interface in base model

Signed-off-by: Johannes Schneider <johannes.schneider@bosch.io>
  • Loading branch information
jokraehe committed Apr 8, 2022
1 parent d9da396 commit 81ec8fe
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.base.model.signals.commands;
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.base.model.signals.commands;

import java.util.Optional;
import java.util.Optional;

import org.eclipse.ditto.json.JsonFieldSelector;

/**
* Command enabled for field selecting.
* @since 2.4.0
*/
public interface WithSelectedFields {
/**
* Command enabled for field selecting.
*
* @since 2.4.0
*/
public interface WithSelectedFields {

/**
* Returns the selected fields which are to be included in the JSON of the retrieved entity.
*
* @return the selected fields.
*/
default Optional<JsonFieldSelector> getSelectedFields() {
return Optional.empty();
}
/**
* Returns the selected fields which are to be included in the JSON of the retrieved entity.
*
* @return the selected fields.
*/
default Optional<JsonFieldSelector> getSelectedFields() {
return Optional.empty();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.gateway.service.endpoints.routes.AbstractRoute;
import org.eclipse.ditto.gateway.service.endpoints.routes.RouteBaseProperties;
import org.eclipse.ditto.gateway.service.endpoints.routes.things.ThingsParameter;
import org.eclipse.ditto.gateway.service.security.authentication.AuthenticationResult;
import org.eclipse.ditto.gateway.service.security.authentication.jwt.JwtAuthenticationResult;
import org.eclipse.ditto.json.JsonFactory;
Expand Down Expand Up @@ -121,7 +120,7 @@ private Route policyId(final RequestContext ctx, final DittoHeaders dittoHeaders
return pathEndOrSingleSlash(() ->
concat(
// GET /policies/<policyId>?fields=<fieldsString>
get(() -> parameterOptional(ThingsParameter.FIELDS.toString(), fieldsString ->
get(() -> parameterOptional(PoliciesParameter.FIELDS.toString(), fieldsString ->
handlePerRequest(ctx, RetrievePolicy.of(policyId, dittoHeaders,
calculateSelectedFields(fieldsString).orElse(null)))
)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
/*
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.things.model.signals.commands;
/*
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.things.model.signals.commands;

import java.util.Optional;
import java.util.Optional;

import org.eclipse.ditto.json.JsonFieldSelector;
import org.eclipse.ditto.json.JsonFieldSelector;

public interface WithSelectedFields extends org.eclipse.ditto.base.model.signals.commands.WithSelectedFields {
/**
* @deprecated since 2.4.0 use {@link org.eclipse.ditto.base.model.signals.commands.WithSelectedFields} instead.
*/
public interface WithSelectedFields extends org.eclipse.ditto.base.model.signals.commands.WithSelectedFields {

@Override
default Optional<JsonFieldSelector> getSelectedFields() {
return Optional.empty();
}
@Override
default Optional<JsonFieldSelector> getSelectedFields() {
return Optional.empty();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableCommand;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.AbstractCommand;
import org.eclipse.ditto.base.model.signals.commands.WithNamespace;
import org.eclipse.ditto.base.model.signals.commands.WithSelectedFields;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonCollectors;
import org.eclipse.ditto.json.JsonFactory;
Expand All @@ -38,16 +45,9 @@
import org.eclipse.ditto.json.JsonObjectBuilder;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableCommand;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.things.model.ThingConstants;
import org.eclipse.ditto.things.model.ThingId;
import org.eclipse.ditto.base.model.signals.commands.AbstractCommand;
import org.eclipse.ditto.base.model.signals.commands.WithNamespace;
import org.eclipse.ditto.things.model.signals.commands.ThingCommand;
import org.eclipse.ditto.things.model.signals.commands.WithSelectedFields;
import org.eclipse.ditto.things.model.signals.commands.exceptions.MissingThingIdsException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
package org.eclipse.ditto.things.model.signals.commands.query;

import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.signals.commands.WithSelectedFields;
import org.eclipse.ditto.things.model.signals.commands.ThingCommand;
import org.eclipse.ditto.things.model.signals.commands.WithSelectedFields;

/**
* Aggregates all {@link org.eclipse.ditto.things.model.signals.commands.ThingCommand}s which query the state of things (read, ...).
Expand Down

0 comments on commit 81ec8fe

Please sign in to comment.