-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter messages according to metrics in Data view
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
- Loading branch information
Claudio Mezzasalma
committed
Aug 6, 2019
1 parent
2e066c5
commit 5347f69
Showing
6 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
...astore/api/src/main/java/org/eclipse/kapua/service/datastore/model/query/OrPredicate.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,29 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 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.datastore.model.query; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Query "or" aggregation definition | ||
* | ||
* @since 1.0 | ||
*/ | ||
public interface OrPredicate extends StorablePredicate { | ||
|
||
/** | ||
* Get the {@link StorablePredicate} list | ||
* | ||
* @return | ||
*/ | ||
List<StorablePredicate> getPredicates(); | ||
} |
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
90 changes: 90 additions & 0 deletions
90
...c/main/java/org/eclipse/kapua/service/datastore/internal/model/query/OrPredicateImpl.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,90 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 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.datastore.internal.model.query; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.eclipse.kapua.service.datastore.client.DatamodelMappingException; | ||
import org.eclipse.kapua.service.datastore.internal.schema.SchemaUtil; | ||
import org.eclipse.kapua.service.datastore.model.query.OrPredicate; | ||
import org.eclipse.kapua.service.datastore.model.query.StorablePredicate; | ||
|
||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
/** | ||
* Implementation of query "or" aggregation | ||
* | ||
* @since 1.0 | ||
*/ | ||
public class OrPredicateImpl implements OrPredicate { | ||
|
||
private List<StorablePredicate> predicates = new ArrayList<StorablePredicate>(); | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
public OrPredicateImpl() { | ||
} | ||
|
||
/** | ||
* Creates an "or" predicate for the given predicates collection | ||
* | ||
* @param predicates | ||
*/ | ||
public OrPredicateImpl(Collection<StorablePredicate> predicates) { | ||
predicates.addAll(predicates); | ||
} | ||
|
||
@Override | ||
public List<StorablePredicate> getPredicates() { | ||
return this.predicates; | ||
} | ||
|
||
/** | ||
* Add the storable predicate to the predicates collection | ||
* | ||
* @param predicate | ||
* @return | ||
*/ | ||
public OrPredicate addPredicate(StorablePredicate predicate) { | ||
this.predicates.add(predicate); | ||
return this; | ||
|
||
} | ||
|
||
/** | ||
* Clear the predicates collection | ||
* | ||
* @return | ||
*/ | ||
public OrPredicate clearPredicates() { | ||
this.predicates.clear(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ObjectNode toSerializedMap() throws DatamodelMappingException { | ||
ObjectNode rootNode = SchemaUtil.getObjectNode(); | ||
ObjectNode termNode = SchemaUtil.getObjectNode(); | ||
ArrayNode conditionsNode = SchemaUtil.getArrayNode(); | ||
for (StorablePredicate predicate : predicates) { | ||
conditionsNode.add(predicate.toSerializedMap()); | ||
} | ||
termNode.set(PredicateConstants.SHOULD_KEY, conditionsNode); | ||
rootNode.set(PredicateConstants.BOOL_KEY, termNode); | ||
return rootNode; | ||
} | ||
|
||
} |
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