-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for MatchPredicates in Device REST API
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
- Loading branch information
Claudio Mezzasalma
committed
Aug 5, 2020
1 parent
890e9bd
commit e89ce59
Showing
14 changed files
with
281 additions
and
13 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...src/main/java/org/eclipse/kapua/commons/model/query/predicate/AbstractMatchPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Eurotech and/or its affiliates 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 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.commons.model.query.predicate; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.kapua.model.query.predicate.MatchPredicate; | ||
|
||
/** | ||
* {@link MatchPredicate} implementation. | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
public class AbstractMatchPredicate<T> implements MatchPredicate<T> { | ||
|
||
protected List<String> attributeNames; | ||
protected T matchTerm; | ||
|
||
@Override | ||
public List<String> getAttributeNames() { | ||
return attributeNames; | ||
} | ||
|
||
@Override | ||
public T getMatchTerm() { | ||
return matchTerm; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
service/api/src/main/java/org/eclipse/kapua/model/query/predicate/MatchPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Eurotech and/or its affiliates 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 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.model.query.predicate; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* {@link MatchPredicate} definition. | ||
* | ||
* @param <T> Attribute value type. | ||
* @since 1.2.0 | ||
*/ | ||
public interface MatchPredicate<T> extends QueryPredicate { | ||
|
||
/** | ||
* Gets the name of the {@link org.eclipse.kapua.model.KapuaEntityAttributes} to compare. | ||
* | ||
* @return The name name of the {@link org.eclipse.kapua.model.KapuaEntityAttributes} to compare. | ||
* @since 1.0.0 | ||
*/ | ||
List<String> getAttributeNames(); | ||
|
||
/** | ||
* Gets the value to compare the results. | ||
* | ||
* @return The value to compare the results. | ||
* @since 1.0.0 | ||
*/ | ||
T getMatchTerm(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...try/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceMatchPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Eurotech and/or its affiliates 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 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.device.registry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; | ||
|
||
public class DeviceMatchPredicate<T> extends AbstractMatchPredicate<T> { | ||
|
||
/** | ||
* Constructor. | ||
* <p> | ||
* | ||
* @param matchTerm | ||
* @since 1.2.0 | ||
*/ | ||
public DeviceMatchPredicate(T matchTerm) { | ||
this.attributeNames = new ArrayList<>(Arrays.asList( | ||
DeviceAttributes.CLIENT_ID, | ||
DeviceAttributes.DISPLAY_NAME, | ||
DeviceAttributes.SERIAL_NUMBER, | ||
DeviceAttributes.MODEL_ID, | ||
DeviceAttributes.MODEL_NAME, | ||
DeviceAttributes.BIOS_VERSION, | ||
DeviceAttributes.FIRMWARE_VERSION, | ||
DeviceAttributes.OS_VERSION, | ||
DeviceAttributes.JVM_VERSION, | ||
DeviceAttributes.OSGI_FRAMEWORK_VERSION, | ||
DeviceAttributes.APPLICATION_FRAMEWORK_VERSION, | ||
DeviceAttributes.CONNECTION_INTERFACE, | ||
DeviceAttributes.CONNECTION_IP) | ||
); | ||
this.matchTerm = matchTerm; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.