git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/storagehub-model@167148 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7c6a489248
commit
397add5f3e
|
@ -1,5 +1,8 @@
|
||||||
package org.gcube.common.storagehub.model.expressions;
|
package org.gcube.common.storagehub.model.expressions;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
|
||||||
|
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
|
||||||
public interface Expression<T> {
|
public interface Expression<T> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class GenericSearchableItem extends SearchableItem<Item>{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GenericSearchableItem() {
|
protected GenericSearchableItem() {
|
||||||
super(Item.class);
|
super(Item.class,"nthl:workspaceItem");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final SearchableField<String> title = new SearchableField<String>(String.class, "jcr:title");
|
public final SearchableField<String> title = new SearchableField<String>(String.class, "jcr:title");
|
||||||
|
|
|
@ -6,6 +6,8 @@ public final class SearchableField<T> {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
protected SearchableField() {}
|
||||||
|
|
||||||
protected SearchableField(Class<T> _class, String name) {
|
protected SearchableField(Class<T> _class, String name) {
|
||||||
this.type = _class;
|
this.type = _class;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -4,10 +4,20 @@ import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
|
||||||
public class SearchableItem<T extends Item> {
|
public class SearchableItem<T extends Item> {
|
||||||
|
|
||||||
Class<T> type;
|
private Class<T> type;
|
||||||
|
private String nodeValue;
|
||||||
|
|
||||||
protected SearchableItem(Class<T> _class){
|
protected SearchableItem(Class<T> _class, String nodeValue){
|
||||||
this.type = _class;
|
this.type = _class;
|
||||||
|
this.nodeValue = nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<T> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodeValue() {
|
||||||
|
return nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ public class And implements Expression<Boolean>{
|
||||||
|
|
||||||
private List<Expression<Boolean>> expressions = new ArrayList<>();
|
private List<Expression<Boolean>> expressions = new ArrayList<>();
|
||||||
|
|
||||||
|
protected And() {}
|
||||||
|
|
||||||
public And(Expression<Boolean> first , Expression<Boolean> second , Expression<Boolean> ... others ) {
|
public And(Expression<Boolean> first , Expression<Boolean> second , Expression<Boolean> ... others ) {
|
||||||
expressions = Arrays.asList(first, second);
|
expressions = Arrays.asList(first, second);
|
||||||
if (others !=null && others.length>0)
|
if (others !=null && others.length>0)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.gcube.common.storagehub.model.expressions.logical;
|
||||||
|
|
||||||
|
import org.gcube.common.storagehub.model.Path;
|
||||||
|
import org.gcube.common.storagehub.model.expressions.Expression;
|
||||||
|
|
||||||
|
public class ISDescendant implements Expression<Boolean>{
|
||||||
|
|
||||||
|
private Path path;
|
||||||
|
|
||||||
|
public ISDescendant(Path path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,8 @@ public class Contains implements Expression<Boolean> {
|
||||||
private SearchableField<String> searchableField;
|
private SearchableField<String> searchableField;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
protected Contains() {}
|
||||||
|
|
||||||
public Contains(SearchableField<String> searchableField, String value) {
|
public Contains(SearchableField<String> searchableField, String value) {
|
||||||
super();
|
super();
|
||||||
this.searchableField = searchableField;
|
this.searchableField = searchableField;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.gcube.common.storagehub.model.items;
|
package org.gcube.common.storagehub.model.items;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.common.storagehub.model.items.nodes.Content;
|
import org.gcube.common.storagehub.model.items.nodes.Content;
|
||||||
|
|
||||||
public abstract class AbstractFileItem extends Item{
|
public abstract class AbstractFileItem extends Item{
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.common.storagehub.model.query;
|
|
||||||
|
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
|
||||||
|
|
||||||
public interface ItemFilter<I extends Item> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package org.gcube.common.storagehub.model.query;
|
|
||||||
|
|
||||||
public interface OrderBy {
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@ public class Queries {
|
||||||
private static Map<Class<?>,SearchableItem<?>> searchableRegistry = new HashMap<>();
|
private static Map<Class<?>,SearchableItem<?>> searchableRegistry = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
searchableRegistry.put(GenericSearchableItem.class, GenericSearchableItem.get());
|
searchableRegistry.put(Item.class, GenericSearchableItem.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Item> Query<SearchableItem<?>> queryFor(Class<T> searchable) {
|
public static <T extends Item> Query<SearchableItem<?>> queryFor(Class<T> searchable) {
|
||||||
|
|
|
@ -1,13 +1,63 @@
|
||||||
package org.gcube.common.storagehub.model.query;
|
package org.gcube.common.storagehub.model.query;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.common.storagehub.model.expressions.Expression;
|
||||||
|
import org.gcube.common.storagehub.model.expressions.SearchableField;
|
||||||
import org.gcube.common.storagehub.model.expressions.SearchableItem;
|
import org.gcube.common.storagehub.model.expressions.SearchableItem;
|
||||||
|
|
||||||
public class Query<T extends SearchableItem<?>> {
|
public class Query<T extends SearchableItem<?>> {
|
||||||
|
|
||||||
private T searchableItem;
|
private T searchableItem;
|
||||||
|
|
||||||
public Query(T searchableItem) {
|
private Expression<Boolean> expression;
|
||||||
|
|
||||||
|
private int limit = -1;
|
||||||
|
|
||||||
|
private int offset =-1;
|
||||||
|
|
||||||
|
private List<SearchableField<?>> orderFields = null;
|
||||||
|
|
||||||
|
protected Query(T searchableItem) {
|
||||||
this.searchableItem = searchableItem;
|
this.searchableItem = searchableItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExpression(Expression<Boolean> expression) {
|
||||||
|
this.expression= expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(SearchableField<?> ... fields ) {
|
||||||
|
if (fields!=null && fields.length>0)
|
||||||
|
this.orderFields = Arrays.asList(fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLimit(int limit) {
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(int offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getSearchableItem() {
|
||||||
|
return searchableItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression<Boolean> getExpression() {
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLimit() {
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SearchableField<?>> getOrderFields() {
|
||||||
|
return orderFields;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue