diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/ActivityMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/ActivityMap.java index 7907e4c7f..20860b735 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/ActivityMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/ActivityMap.java @@ -1,12 +1,12 @@ /* * Copyright 2015 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,16 +15,11 @@ */ package li.strolch.agent.api; -import java.util.List; - import li.strolch.model.activity.Activity; -import li.strolch.model.query.ActivityQuery; -import li.strolch.persistence.api.StrolchTransaction; /** * @author Robert von Burg */ public interface ActivityMap extends ElementMap { - public List doQuery(StrolchTransaction tx, ActivityQuery query); } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/AuditTrail.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/AuditTrail.java index 0bf8c689b..564cb638b 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/AuditTrail.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/AuditTrail.java @@ -1,12 +1,12 @@ /* * Copyright 2013 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.utils.collections.DateRange; @@ -28,43 +27,41 @@ import li.strolch.utils.collections.DateRange; */ public interface AuditTrail { - public boolean isEnabled(); + boolean isEnabled(); - public boolean hasAudit(StrolchTransaction tx, String type, Long id); + boolean hasAudit(StrolchTransaction tx, String type, Long id); - public long querySize(StrolchTransaction tx, DateRange dateRange); + long querySize(StrolchTransaction tx, DateRange dateRange); - public long querySize(StrolchTransaction tx, String type, DateRange dateRange); + long querySize(StrolchTransaction tx, String type, DateRange dateRange); - public Set getTypes(StrolchTransaction tx); + Set getTypes(StrolchTransaction tx); /** * Retrieves the audit with the given id, or null if it does not exist - * + * * @param tx - * the open transaction + * the open transaction * @param id - * the id of the element to retrieve - * + * the id of the element to retrieve + * * @return the element with the type and id, or null if it does not exist */ - public Audit getBy(StrolchTransaction tx, String type, Long id); + Audit getBy(StrolchTransaction tx, String type, Long id); - public List getAllElements(StrolchTransaction tx, String type, DateRange dateRange); + List getAllElements(StrolchTransaction tx, String type, DateRange dateRange); - public void add(StrolchTransaction tx, Audit audit); + void add(StrolchTransaction tx, Audit audit); - public void addAll(StrolchTransaction tx, List audits); + void addAll(StrolchTransaction tx, List audits); - public void update(StrolchTransaction tx, Audit audit); + void update(StrolchTransaction tx, Audit audit); - public void updateAll(StrolchTransaction tx, List audits); + void updateAll(StrolchTransaction tx, List audits); - public void remove(StrolchTransaction tx, Audit audit); + void remove(StrolchTransaction tx, Audit audit); - public void removeAll(StrolchTransaction tx, List audits); + void removeAll(StrolchTransaction tx, List audits); - public long removeAll(StrolchTransaction tx, String type, DateRange dateRange); - - public List doQuery(StrolchTransaction tx, AuditQuery query); + long removeAll(StrolchTransaction tx, String type, DateRange dateRange); } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/ElementMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/ElementMap.java index 18d2a6328..904b8f88b 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/ElementMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/ElementMap.java @@ -364,8 +364,6 @@ public interface ElementMap { * @param element * the element to update * - * @return the replaced element - * * @throws StrolchPersistenceException * if the element does not exist */ @@ -379,8 +377,6 @@ public interface ElementMap { * @param elements * the elements to update * - * @return the replaced elements - * * @throws StrolchPersistenceException * if any of the elements don't yet exist */ diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/OrderMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/OrderMap.java index 839d3531b..1c668cd82 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/OrderMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/OrderMap.java @@ -1,12 +1,12 @@ /* * Copyright 2013 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,16 +15,11 @@ */ package li.strolch.agent.api; -import java.util.List; - import li.strolch.model.Order; -import li.strolch.model.query.OrderQuery; -import li.strolch.persistence.api.StrolchTransaction; /** * @author Robert von Burg */ public interface OrderMap extends ElementMap { - public List doQuery(StrolchTransaction tx, OrderQuery query); } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/ResourceMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/ResourceMap.java index b7d5f9e0e..8ae1f4791 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/ResourceMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/ResourceMap.java @@ -1,12 +1,12 @@ /* * Copyright 2013 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,16 +15,11 @@ */ package li.strolch.agent.api; -import java.util.List; - import li.strolch.model.Resource; -import li.strolch.model.query.ResourceQuery; -import li.strolch.persistence.api.StrolchTransaction; /** * @author Robert von Burg */ public interface ResourceMap extends ElementMap { - public List doQuery(StrolchTransaction tx, ResourceQuery query); } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingActivityMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingActivityMap.java index 98ca08386..ab8c04594 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingActivityMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingActivityMap.java @@ -15,18 +15,11 @@ */ package li.strolch.agent.impl; -import java.util.HashSet; -import java.util.List; - import li.strolch.agent.api.ActivityMap; import li.strolch.agent.api.AuditTrail; import li.strolch.agent.api.ElementMap; import li.strolch.model.Tags; import li.strolch.model.activity.Activity; -import li.strolch.model.query.ActivityQuery; -import li.strolch.model.visitor.ActivityVisitor; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.utils.dbc.DBC; /** * This is the {@link AuditTrail} for {@link Activity Activities} @@ -49,18 +42,4 @@ public class AuditingActivityMap extends AuditingElementMapFacade impl protected ActivityMap getElementMap() { return (ActivityMap) super.getElementMap(); } - - @Override - public List doQuery(StrolchTransaction tx, ActivityQuery query) { - ActivityVisitor activityVisitor = query.getVisitor(); - DBC.PRE.assertNotNull("activityVisitor on query", activityVisitor); - query.setVisitor(activity -> { - if (this.read == null) - this.read = new HashSet<>(); - this.read.add(activity); - return activity.accept(activityVisitor); - }); - - return getElementMap().doQuery(tx, query); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java index a871716a5..bd5cf4dab 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java @@ -19,8 +19,6 @@ import java.util.*; import li.strolch.agent.api.AuditTrail; import li.strolch.model.audit.Audit; -import li.strolch.model.audit.AuditVisitor; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.utils.collections.DateRange; import li.strolch.utils.dbc.DBC; @@ -40,16 +38,16 @@ import li.strolch.utils.dbc.DBC; */ public class AuditingAuditMapFacade implements AuditTrail { - private AuditTrail auditTrail; + private final AuditTrail auditTrail; - private Set read; - private Set created; - private Set updated; - private Set deleted; + private final Set read; + private final Set created; + private final Set updated; + private final Set deleted; private long deletedAll; - private Map deletedAllByType; + private final Map deletedAllByType; - private boolean observeAccessReads; + private final boolean observeAccessReads; public AuditingAuditMapFacade(AuditTrail auditTrail, boolean observeAccessReads) { DBC.PRE.assertNotNull("auditTrail must be set!", auditTrail); //$NON-NLS-1$ @@ -195,15 +193,4 @@ public class AuditingAuditMapFacade implements AuditTrail { this.deletedAll += removed; return removed; } - - @Override - public List doQuery(StrolchTransaction tx, AuditQuery query) { - AuditVisitor auditVisitor = query.getVisitor(); - query.setVisitor(audit -> { - this.read.add(audit); - return auditVisitor.visitAudit(audit); - }); - - return this.auditTrail.doQuery(tx, query); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java index e5a17ebe8..b715d619c 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java @@ -15,18 +15,11 @@ */ package li.strolch.agent.impl; -import java.util.HashSet; -import java.util.List; - import li.strolch.agent.api.AuditTrail; import li.strolch.agent.api.ElementMap; import li.strolch.agent.api.OrderMap; import li.strolch.model.Order; import li.strolch.model.Tags; -import li.strolch.model.query.OrderQuery; -import li.strolch.model.visitor.OrderVisitor; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.utils.dbc.DBC; /** * This is the {@link AuditTrail} for {@link Order Orders} @@ -49,18 +42,4 @@ public class AuditingOrderMap extends AuditingElementMapFacade implements protected OrderMap getElementMap() { return (OrderMap) super.getElementMap(); } - - @Override - public List doQuery(StrolchTransaction tx, OrderQuery query) { - OrderVisitor orderVisitor = query.getVisitor(); - DBC.PRE.assertNotNull("orderVisitor on query", orderVisitor); - query.setVisitor(order -> { - if (this.read == null) - this.read = new HashSet<>(); - this.read.add(order); - return order.accept(orderVisitor); - }); - - return getElementMap().doQuery(tx, query); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java index d85c20c2e..1f726b409 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java @@ -15,18 +15,11 @@ */ package li.strolch.agent.impl; -import java.util.HashSet; -import java.util.List; - import li.strolch.agent.api.AuditTrail; import li.strolch.agent.api.ElementMap; import li.strolch.agent.api.ResourceMap; import li.strolch.model.Resource; import li.strolch.model.Tags; -import li.strolch.model.query.ResourceQuery; -import li.strolch.model.visitor.ResourceVisitor; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.utils.dbc.DBC; /** * This is the {@link AuditTrail} for {@link Resource Resources} @@ -49,18 +42,4 @@ public class AuditingResourceMap extends AuditingElementMapFacade impl protected ResourceMap getElementMap() { return (ResourceMap) super.getElementMap(); } - - @Override - public List doQuery(StrolchTransaction tx, ResourceQuery query) { - ResourceVisitor resourceVisitor = query.getVisitor(); - DBC.PRE.assertNotNull("resourceVisitor on query", resourceVisitor); - query.setVisitor(resource -> { - if (this.read == null) - this.read = new HashSet<>(); - this.read.add(resource); - return resource.accept(resourceVisitor); - }); - - return getElementMap().doQuery(tx, query); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedActivityMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedActivityMap.java index e61b36ec8..55a6c7158 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedActivityMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedActivityMap.java @@ -17,17 +17,12 @@ package li.strolch.agent.impl; import static li.strolch.model.StrolchModelConstants.INTERPRETATION_ACTIVITY_REF; -import java.util.List; - import li.strolch.agent.api.ActivityMap; import li.strolch.agent.api.StrolchRealm; import li.strolch.model.activity.Activity; import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.ActivityQuery; import li.strolch.persistence.api.ActivityDao; import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryActivityQueryVisitor; -import li.strolch.runtime.query.inmemory.InMemoryQuery; public class CachedActivityMap extends CachedElementMap implements ActivityMap { @@ -44,11 +39,4 @@ public class CachedActivityMap extends CachedElementMap implements Act protected ActivityDao getDbDao(StrolchTransaction tx) { return tx.getPersistenceHandler().getActivityDao(tx); } - - @Override - public List doQuery(StrolchTransaction tx, ActivityQuery activityQuery) { - InMemoryActivityQueryVisitor visitor = new InMemoryActivityQueryVisitor(); - InMemoryQuery query = visitor.visit(activityQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedAuditTrail.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedAuditTrail.java index 78bb4f3f9..c79a4cf47 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedAuditTrail.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedAuditTrail.java @@ -19,7 +19,6 @@ import java.text.MessageFormat; import java.util.List; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.AuditDao; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.utils.collections.DateRange; @@ -99,9 +98,4 @@ public class CachedAuditTrail extends TransientAuditTrail { } return removed; } - - @Override - public List doQuery(StrolchTransaction tx, AuditQuery query) { - return getDbDao(tx).doQuery(query); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedElementMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedElementMap.java index 7250280ac..ac4727255 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedElementMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedElementMap.java @@ -32,7 +32,7 @@ import li.strolch.persistence.api.StrolchTransaction; */ public abstract class CachedElementMap extends TransientElementMap { - private StrolchRealm realm; + private final StrolchRealm realm; public CachedElementMap(StrolchRealm realm) { super(); diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedOrderMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedOrderMap.java index 70f99f760..e5fb1cc99 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedOrderMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedOrderMap.java @@ -18,17 +18,13 @@ package li.strolch.agent.impl; import static li.strolch.model.StrolchModelConstants.INTERPRETATION_ORDER_REF; import java.util.Date; -import java.util.List; import li.strolch.agent.api.OrderMap; import li.strolch.agent.api.StrolchRealm; import li.strolch.model.Order; import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.OrderQuery; import li.strolch.persistence.api.OrderDao; import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryOrderQueryVisitor; -import li.strolch.runtime.query.inmemory.InMemoryQuery; public class CachedOrderMap extends CachedElementMap implements OrderMap { @@ -52,11 +48,4 @@ public class CachedOrderMap extends CachedElementMap implements OrderMap protected OrderDao getDbDao(StrolchTransaction tx) { return tx.getPersistenceHandler().getOrderDao(tx); } - - @Override - public List doQuery(StrolchTransaction tx, OrderQuery orderQuery) { - InMemoryOrderQueryVisitor visitor = new InMemoryOrderQueryVisitor(); - InMemoryQuery query = visitor.visit(orderQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedResourceMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedResourceMap.java index b9e9bce28..deab2840a 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedResourceMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/CachedResourceMap.java @@ -17,17 +17,12 @@ package li.strolch.agent.impl; import static li.strolch.model.StrolchModelConstants.INTERPRETATION_RESOURCE_REF; -import java.util.List; - import li.strolch.agent.api.ResourceMap; import li.strolch.agent.api.StrolchRealm; import li.strolch.model.Resource; import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.ResourceQuery; import li.strolch.persistence.api.ResourceDao; import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryQuery; -import li.strolch.runtime.query.inmemory.InMemoryResourceQueryVisitor; public class CachedResourceMap extends CachedElementMap implements ResourceMap { @@ -44,11 +39,4 @@ public class CachedResourceMap extends CachedElementMap implements Res protected ResourceDao getDbDao(StrolchTransaction tx) { return tx.getPersistenceHandler().getResourceDao(tx); } - - @Override - public List doQuery(StrolchTransaction tx, ResourceQuery resourceQuery) { - InMemoryResourceQueryVisitor visitor = new InMemoryResourceQueryVisitor(); - InMemoryQuery query = visitor.visit(resourceQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/NoStrategyAuditTrail.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/NoStrategyAuditTrail.java index 446229be8..15be7555f 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/NoStrategyAuditTrail.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/NoStrategyAuditTrail.java @@ -20,7 +20,6 @@ import java.util.Set; import li.strolch.agent.api.AuditTrail; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.utils.collections.DateRange; @@ -29,7 +28,7 @@ import li.strolch.utils.collections.DateRange; */ public class NoStrategyAuditTrail implements AuditTrail { - private String realm; + private final String realm; public NoStrategyAuditTrail(String realm) { this.realm = realm; @@ -104,9 +103,4 @@ public class NoStrategyAuditTrail implements AuditTrail { public long removeAll(StrolchTransaction tx, String type, DateRange dateRange) { return 0; } - - @Override - public List doQuery(StrolchTransaction tx, AuditQuery query) { - throw new IllegalStateException("Audit trail is not enabled for realm " + this.realm); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientActivityMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientActivityMap.java index ff19d55fa..97b18acd8 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientActivityMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientActivityMap.java @@ -2,15 +2,9 @@ package li.strolch.agent.impl; import static li.strolch.model.StrolchModelConstants.INTERPRETATION_ACTIVITY_REF; -import java.util.List; - import li.strolch.agent.api.ActivityMap; import li.strolch.model.activity.Activity; import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.ActivityQuery; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryActivityQueryVisitor; -import li.strolch.runtime.query.inmemory.InMemoryQuery; public class TransientActivityMap extends TransientElementMap implements ActivityMap { @@ -18,11 +12,4 @@ public class TransientActivityMap extends TransientElementMap implemen protected void assertIsRefParam(Parameter refP) { ElementMapHelpers.assertIsRefParam(INTERPRETATION_ACTIVITY_REF, refP); } - - @Override - public List doQuery(StrolchTransaction tx, ActivityQuery activityQuery) { - InMemoryActivityQueryVisitor visitor = new InMemoryActivityQueryVisitor(); - InMemoryQuery query = visitor.visit(activityQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientAuditTrail.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientAuditTrail.java index 30bf188f3..558db1365 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientAuditTrail.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientAuditTrail.java @@ -4,16 +4,13 @@ import java.util.*; import li.strolch.agent.api.AuditTrail; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryAuditQuery; -import li.strolch.runtime.query.inmemory.InMemoryAuditQueryVisitor; import li.strolch.utils.collections.DateRange; import li.strolch.utils.collections.MapOfMaps; public class TransientAuditTrail implements AuditTrail { - private MapOfMaps auditMap; + private final MapOfMaps auditMap; public TransientAuditTrail() { this.auditMap = new MapOfMaps<>(); @@ -140,11 +137,4 @@ public class TransientAuditTrail implements AuditTrail { return toRemoveList.size(); } - - @Override - public List doQuery(StrolchTransaction tx, AuditQuery auditQuery) { - InMemoryAuditQueryVisitor visitor = new InMemoryAuditQueryVisitor<>(); - InMemoryAuditQuery query = visitor.toInMemory(auditQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientOrderMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientOrderMap.java index c16b46fd0..eb9a7a030 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientOrderMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientOrderMap.java @@ -3,15 +3,11 @@ package li.strolch.agent.impl; import static li.strolch.model.StrolchModelConstants.INTERPRETATION_ORDER_REF; import java.util.Date; -import java.util.List; import li.strolch.agent.api.OrderMap; import li.strolch.model.Order; import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.OrderQuery; import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryOrderQueryVisitor; -import li.strolch.runtime.query.inmemory.InMemoryQuery; public class TransientOrderMap extends TransientElementMap implements OrderMap { @@ -26,11 +22,4 @@ public class TransientOrderMap extends TransientElementMap implements Ord protected void assertIsRefParam(Parameter refP) { ElementMapHelpers.assertIsRefParam(INTERPRETATION_ORDER_REF, refP); } - - @Override - public List doQuery(StrolchTransaction tx, OrderQuery orderQuery) { - InMemoryOrderQueryVisitor visitor = new InMemoryOrderQueryVisitor(); - InMemoryQuery query = visitor.visit(orderQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientResourceMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientResourceMap.java index c8a6ad780..1dc62b411 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientResourceMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/TransientResourceMap.java @@ -2,15 +2,9 @@ package li.strolch.agent.impl; import static li.strolch.model.StrolchModelConstants.INTERPRETATION_RESOURCE_REF; -import java.util.List; - import li.strolch.agent.api.ResourceMap; import li.strolch.model.Resource; import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.ResourceQuery; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.runtime.query.inmemory.InMemoryQuery; -import li.strolch.runtime.query.inmemory.InMemoryResourceQueryVisitor; public class TransientResourceMap extends TransientElementMap implements ResourceMap { @@ -18,11 +12,4 @@ public class TransientResourceMap extends TransientElementMap implemen protected void assertIsRefParam(Parameter refP) { ElementMapHelpers.assertIsRefParam(INTERPRETATION_RESOURCE_REF, refP); } - - @Override - public List doQuery(StrolchTransaction tx, ResourceQuery resourceQuery) { - InMemoryResourceQueryVisitor visitor = new InMemoryResourceQueryVisitor(); - InMemoryQuery query = visitor.visit(resourceQuery); - return query.doQuery(tx, this); - } } diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ActionSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ActionSelection.java deleted file mode 100644 index f94c6cc15..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ActionSelection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.Arrays; -import java.util.List; - -import li.strolch.model.audit.AccessType; -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class ActionSelection extends AuditSelection { - - private StringSelection actionSelection; - private List accessTypes; - - public ActionSelection(AuditQuery query) { - super(query); - } - - public ActionSelection actions(StringMatchMode matchMode, String... actions) { - this.actionSelection = new StringSelection(matchMode, actions); - return this; - } - - public ActionSelection accessTypes(List accessTypes) { - this.accessTypes = accessTypes; - return this; - } - - public ActionSelection accessTypes(AccessType... accessTypes) { - this.accessTypes = Arrays.asList(accessTypes); - return this; - } - - public List getAccessTypes() { - return this.accessTypes; - } - - public StringSelection getActionSelection() { - return this.actionSelection; - } - - public boolean isWildcardActionType() { - return this.accessTypes == null || this.accessTypes.isEmpty(); - } - - public boolean isWildcardAction() { - return this.actionSelection == null || this.actionSelection.isWildCard(); - } - - @Override - public void accept(AuditQueryVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityQuery.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityQuery.java deleted file mode 100644 index 688f59ced..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityQuery.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.activity.Action; -import li.strolch.model.activity.Activity; -import li.strolch.model.query.ordering.StrolchQueryOrdering; -import li.strolch.model.visitor.ActivityVisitor; -import li.strolch.utils.dbc.DBC; - -/** - *

- * {@link ActivityQuery} is the user API to query {@link Activity Activities} in Strolch. The {@link Navigation} is used - * to navigate to a type of activity on which any further {@link Selection Selections} will be performed. The - * {@link ActivityVisitor} is used to transform the returned object into a domain specific object (if required). This - * mechanism allows you to query e.g. a specific {@link Action} instead of having to return all the elements and then - * performing this transformation. - *

- * - *

- * The {@link ActivityVisitor} is intended for situations where the query result should not be {@link Activity} but some - * other object type. For instance in a restful API, the result might have to be mapped to a POJO, thus using this - * method can perform the mapping step for you - *

- * - * @param - * defines the return type of this query. Depending on the user {@link ActivityVisitor} this query can return - * an {@link Activity}, or any type of object to which the visitor mapped the activity - * - * @author Robert von Burg - */ -public class ActivityQuery extends StrolchElementQuery { - - protected ActivityVisitor visitor; - protected StrolchQueryOrdering ordering; - - public ActivityQuery() { - super(); - setIdentityVisitor(); - } - - public ActivityQuery(Navigation navigation) { - super(navigation); - setIdentityVisitor(); - } - - private void setIdentityVisitor() { - @SuppressWarnings("unchecked") - ActivityVisitor identityVisitor = t -> (U) t; - this.visitor = identityVisitor; - } - - public ActivityVisitor getVisitor() { - return this.visitor; - } - - @Override - public ActivityQuery internal() { - super.internal(); - return this; - } - - public ActivityQuery setVisitor(ActivityVisitor visitor) { - DBC.PRE.assertNotNull("visitor", visitor); - this.visitor = visitor; - return this; - } - - public StrolchQueryOrdering getOrdering() { - return this.ordering; - } - - public ActivityQuery setOrdering(StrolchQueryOrdering ordering) { - this.ordering = ordering; - return this; - } - - @Override - public ActivityQuery with(Selection selection) { - super.with(selection); - return this; - } - - @Override - public ActivityQuery not(Selection selection) { - super.not(selection); - return this; - } - - @Override - public ActivityQuery withAny() { - super.withAny(); - return this; - } - - @Override - public void accept(ActivityQueryVisitor visitor) { - super.accept(visitor); - if (this.ordering != null) - this.ordering.accept(visitor); - } - - public static ActivityQuery query(String type) { - return new ActivityQuery<>(new StrolchTypeNavigation(type)); - } - - public static ActivityQuery query(String type, StrolchQueryOrdering ordering) { - return new ActivityQuery(new StrolchTypeNavigation(type)).setOrdering(ordering); - } - - public static ActivityQuery query(String type, ActivityVisitor activityVisitor) { - return new ActivityQuery(new StrolchTypeNavigation(type)).setVisitor(activityVisitor); - } - - public static ActivityQuery query(String type, ActivityVisitor activityVisitor, - StrolchQueryOrdering ordering) { - return new ActivityQuery(new StrolchTypeNavigation(type)).setVisitor(activityVisitor).setOrdering(ordering); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityQueryVisitor.java deleted file mode 100644 index 35b72e8fd..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityQueryVisitor.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.query.ordering.StrolchQueryOrderingVisitor; - -/** - * @author Robert von Burg - */ -public interface ActivityQueryVisitor - extends ActivitySelectionVisitor, ParameterSelectionVisitor, StrolchQueryOrderingVisitor { - - // marker interface -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivitySelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ActivitySelection.java deleted file mode 100644 index 4d2fdf3b8..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivitySelection.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - * - */ -public abstract class ActivitySelection implements Selection { - - @Override - public void accept(QueryVisitor visitor) { - accept((ActivitySelectionVisitor) visitor); - } - - @Override - public boolean hasSelection() { - return true; - } - - public abstract void accept(ActivitySelectionVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivitySelectionVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ActivitySelectionVisitor.java deleted file mode 100644 index 3a2dab8fc..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivitySelectionVisitor.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public interface ActivitySelectionVisitor extends StrolchRootElementSelectionVisitor { - - public void visit(ActivityStateSelection selection); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityStateSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityStateSelection.java deleted file mode 100644 index 3ee4620ab..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ActivityStateSelection.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.State; - -/** - * @author Robert von Burg - */ -public class ActivityStateSelection extends ActivitySelection { - - private State state; - - public ActivityStateSelection(State state) { - this.state = state; - } - - public State getState() { - return this.state; - } - - @Override - public void accept(ActivitySelectionVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/AndSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/AndSelection.java deleted file mode 100644 index 9ece8189a..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/AndSelection.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.List; - -/** - * @author Robert von Burg - */ -public class AndSelection extends BooleanSelection { - - public AndSelection() { - super(); - } - - public AndSelection(Selection... selections) { - super(selections); - } - - public AndSelection(List selections) { - super(selections); - } - - @Override - public AndSelection with(Selection selection) { - super.with(selection); - return this; - } - - @Override - public AndSelection with(List selections) { - super.with(selections); - return this; - } - - @Override - public AndSelection with(Selection... selections) { - super.with(selections); - return this; - } - - @Override - public void accept(QueryVisitor visitor) { - visitor.visitAnd(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/AnySelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/AnySelection.java deleted file mode 100644 index 79762b54c..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/AnySelection.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public class AnySelection implements Selection { - - @Override - public void accept(QueryVisitor visitor) { - visitor.visitAny(); - } - - @Override - public boolean hasSelection() { - return true; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/AuditQuery.java b/li.strolch.agent/src/main/java/li/strolch/model/query/AuditQuery.java deleted file mode 100644 index 9154634f3..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/AuditQuery.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.ArrayList; -import java.util.List; - -import li.strolch.model.audit.Audit; -import li.strolch.model.audit.AuditVisitor; -import li.strolch.model.audit.NoStrategyAuditVisitor; -import li.strolch.utils.collections.DateRange; -import li.strolch.utils.dbc.DBC; - -/** - * - *

- * The {@link AuditVisitor} is intended for situations where the query result should not be {@link Audit} but some other - * object type. For instance in a restful API, the result might have to be mapped to a POJO, thus using this method can - * perform the mapping step for you - *

- * - * @author Robert von Burg - */ -public class AuditQuery implements StrolchQuery { - - protected String elementTypeSelection; - protected List selections; - protected DateRange dateRange; - protected long limit; - protected AuditVisitor auditVisitor; - - public AuditQuery(AuditVisitor auditVisitor, String elementTypeSelection, DateRange dateRange) { - DBC.PRE.assertNotNull("auditVisitor", auditVisitor); - DBC.PRE.assertNotEmpty("No elementTypeSelection (navigation) set!", elementTypeSelection); //$NON-NLS-1$ - DBC.PRE.assertFalse("dateRange may not be unbounded!", dateRange.isUnbounded()); - this.auditVisitor = auditVisitor; - this.elementTypeSelection = elementTypeSelection; - this.dateRange = dateRange; - this.selections = new ArrayList<>(); - } - - public AuditVisitor getVisitor() { - return this.auditVisitor; - } - - public AuditQuery setVisitor(AuditVisitor auditVisitor) { - DBC.PRE.assertNotNull("auditVisitor", auditVisitor); - this.auditVisitor = auditVisitor; - return this; - } - - public String getElementTypeSelection() { - return this.elementTypeSelection; - } - - public DateRange getDateRange() { - return this.dateRange; - } - - public long getLimit() { - return limit; - } - - public AuditQuery limit(long limit) { - this.limit = limit; - return this; - } - - public ActionSelection action() { - ActionSelection selection = new ActionSelection(this); - this.selections.add(selection); - return selection; - } - - public ElementSelection element() { - ElementSelection selection = new ElementSelection(this); - this.selections.add(selection); - return selection; - } - - public IdentitySelection identity() { - IdentitySelection selection = new IdentitySelection(this); - this.selections.add(selection); - return selection; - } - - public void accept(AuditQueryVisitor visitor) { - visitor.visit(this); - for (AuditSelection selection : this.selections) { - selection.accept(visitor); - } - } - - /** - * @see li.strolch.privilege.model.Restrictable#getPrivilegeName() - */ - @Override - public String getPrivilegeName() { - return StrolchQuery.class.getName(); - } - - /** - * @see li.strolch.privilege.model.Restrictable#getPrivilegeValue() - */ - @Override - public Object getPrivilegeValue() { - return getClass().getName(); - } - - public static AuditQuery query(String elementTypeSelection, DateRange dateRange) { - return new AuditQuery<>(new NoStrategyAuditVisitor(), elementTypeSelection, dateRange); - } - - public static AuditQuery query(String elementTypeSelection, DateRange dateRange, AuditVisitor orderVisitor) { - return new AuditQuery<>(orderVisitor, elementTypeSelection, dateRange); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/AuditQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/AuditQueryVisitor.java deleted file mode 100644 index e60d82c9a..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/AuditQueryVisitor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public interface AuditQueryVisitor { - - public void visit(ElementSelection selection); - - public void visit(IdentitySelection selection); - - public void visit(ActionSelection selection); - - public void visit(AuditQuery auditQuery); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/AuditSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/AuditSelection.java deleted file mode 100644 index 2dd8c287d..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/AuditSelection.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public abstract class AuditSelection { - - private AuditQuery query; - - public AuditSelection(AuditQuery query) { - super(); - this.query = query; - } - - public AuditQuery query() { - return this.query; - } - - public abstract void accept(AuditQueryVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/BooleanSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/BooleanSelection.java deleted file mode 100644 index 120673e00..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/BooleanSelection.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author Robert von Burg - */ -public abstract class BooleanSelection implements Selection { - - protected List selections; - - public BooleanSelection() { - this.selections = new ArrayList<>(1); - } - - public BooleanSelection(List selections) { - this.selections = selections; - } - - public BooleanSelection(Selection leftHandSide, Selection rightHandSide) { - this.selections = new ArrayList<>(2); - this.selections.add(leftHandSide); - this.selections.add(rightHandSide); - } - - public BooleanSelection(Selection... selections) { - this.selections = new ArrayList(); - for (Selection selection : selections) { - this.selections.add(selection); - } - } - - @Override - public boolean hasSelection() { - if (this.selections == null || this.selections.isEmpty()) - return false; - - for (Selection selection : this.selections) { - if (selection.hasSelection()) { - return true; - } - } - - return false; - } - - public List getSelections() { - return Collections.unmodifiableList(this.selections); - } - - public BooleanSelection with(Selection selection) { - this.selections.add(selection); - return this; - } - - public BooleanSelection with(Selection... selections) { - for (Selection selection : selections) { - this.selections.add(selection); - } - return this; - } - - public BooleanSelection with(List selections) { - this.selections.addAll(selections); - return this; - } - - @Override - public abstract void accept(QueryVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/DateSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/DateSelection.java deleted file mode 100644 index 0d0b0c67d..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/DateSelection.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.Date; - -import li.strolch.utils.collections.DateRange; - -/** - * @author Robert von Burg - */ -public class DateSelection extends OrderSelection { - - private DateRange dateRange; - - public DateSelection() { - this.dateRange = new DateRange(); - } - - public DateSelection(DateRange dateRange) { - this.dateRange = dateRange; - } - - public DateSelection from(Date from, boolean inclusive) { - this.dateRange.from(from, inclusive); - return this; - } - - public DateSelection to(Date to, boolean inclusive) { - this.dateRange.to(to, inclusive); - return this; - } - - public Date getFromDate() { - return this.dateRange.getFromDate(); - } - - public Date getToDate() { - return this.dateRange.getToDate(); - } - - public boolean isFromBounded() { - return this.dateRange.isFromBounded(); - } - - public boolean isToBounded() { - return this.dateRange.isToBounded(); - } - - public boolean isUnbounded() { - return this.dateRange.isUnbounded(); - } - - public boolean isBounded() { - return this.dateRange.isBounded(); - } - - public boolean contains(Date date) { - return this.dateRange.contains(date); - } - - public DateRange getDateRange() { - return this.dateRange; - } - - @Override - public void accept(OrderSelectionVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ElementSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ElementSelection.java deleted file mode 100644 index 4cdcdd0a6..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ElementSelection.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class ElementSelection extends AuditSelection { - - private StringSelection elementSubTypeSelection; - private StringSelection elementAccessedSelection; - - public ElementSelection(AuditQuery query) { - super(query); - } - - public ElementSelection elementAccessed(StringMatchMode matchMode, String... elementsAccessed) { - this.elementAccessedSelection = new StringSelection(matchMode, elementsAccessed); - return this; - } - - public StringSelection getElementAccessedSelection() { - return this.elementAccessedSelection; - } - - public boolean isElementAccessedWildcard() { - return this.elementAccessedSelection == null || this.elementAccessedSelection.isWildCard(); - } - - public ElementSelection elementSubTypes(StringMatchMode matchMode, String... elementSubTypes) { - this.elementSubTypeSelection = new StringSelection(matchMode, elementSubTypes); - return this; - } - - public StringSelection getElementSubTypeSelection() { - return this.elementSubTypeSelection; - } - - public boolean isElementSubTypesWildcard() { - return this.elementSubTypeSelection == null || this.elementSubTypeSelection.isWildCard(); - } - - @Override - public void accept(AuditQueryVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/IdSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/IdSelection.java deleted file mode 100644 index c65beaf43..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/IdSelection.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class IdSelection extends StrolchElementSelection { - - private List ids; - private StringMatchMode matchMode; - - /** - * Instantiate using {@link StringMatchMode#es()} - * - * @param id - */ - public IdSelection(String id) { - this.ids = new ArrayList<>(1); - this.ids.add(id); - this.matchMode = StringMatchMode.es(); - } - - /** - * @param id - * @param matchMode - */ - public IdSelection(String id, StringMatchMode matchMode) { - this.ids = new ArrayList<>(1); - this.ids.add(id); - this.matchMode = matchMode; - } - - /** - * Instantiate using {@link StringMatchMode#es()} - * - * @param matchMode - * @param ids - */ - public IdSelection(String... ids) { - this.matchMode = StringMatchMode.es(); - this.ids = Arrays.asList(ids); - } - - /** - * @param matchMode - * @param ids - */ - public IdSelection(StringMatchMode matchMode, String... ids) { - this.matchMode = matchMode; - this.ids = Arrays.asList(ids); - } - - /** - * @param ids - * @param matchMode - */ - public IdSelection(List ids, StringMatchMode matchMode) { - this.matchMode = matchMode; - this.ids = ids; - } - - /** - * Instantiate using {@link StringMatchMode#es()} - * - * @param ids - * @param matchMode - */ - public IdSelection(List ids) { - this.matchMode = StringMatchMode.es(); - this.ids = ids; - } - - /** - * @return the ids - */ - public List getIds() { - return this.ids; - } - - /** - * @return the matchMode - */ - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - /** - * @param id - * - * @return - */ - public IdSelection with(String id) { - this.ids.add(id); - return this; - } - - @Override - public void accept(StrolchElementSelectionVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/IdentitySelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/IdentitySelection.java deleted file mode 100644 index 21092e090..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/IdentitySelection.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class IdentitySelection extends AuditSelection { - - private StringSelection usernameSelection; - private StringSelection firstnameSelection; - private StringSelection lastnameSelection; - - public IdentitySelection(AuditQuery query) { - super(query); - } - - public IdentitySelection usernames(StringMatchMode matchMode, String... usernames) { - this.usernameSelection = new StringSelection(matchMode, usernames); - return this; - } - - public IdentitySelection firstnames(StringMatchMode matchMode, String... firstnames) { - this.firstnameSelection = new StringSelection(matchMode, firstnames); - return this; - } - - public IdentitySelection lastnames(StringMatchMode matchMode, String... lastnames) { - this.lastnameSelection = new StringSelection(matchMode, lastnames); - return this; - } - - /** - * @return the firstnameSelection - */ - public StringSelection getFirstnameSelection() { - return this.firstnameSelection; - } - - /** - * @return the lastnameSelection - */ - public StringSelection getLastnameSelection() { - return this.lastnameSelection; - } - - /** - * @return the usernameSelection - */ - public StringSelection getUsernameSelection() { - return this.usernameSelection; - } - - public boolean isFirstnameWildcard() { - return this.firstnameSelection == null || this.firstnameSelection.isWildCard(); - } - - public boolean isLastnameWildcard() { - return this.lastnameSelection == null || this.lastnameSelection.isWildCard(); - } - - public boolean isUsernameWildcard() { - return this.usernameSelection == null || this.usernameSelection.isWildCard(); - } - - public boolean isWildcard() { - return isFirstnameWildcard() && isLastnameWildcard() && isUsernameWildcard(); - } - - @Override - public void accept(AuditQueryVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/NameSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/NameSelection.java deleted file mode 100644 index 41ce77a0e..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/NameSelection.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class NameSelection extends StrolchElementSelection { - - private StringMatchMode matchMode; - private String name; - - /** - * @param name - * @param matchMode - */ - public NameSelection(String name, StringMatchMode matchMode) { - this.name = name; - this.matchMode = matchMode; - } - - /** - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * @return the matchMode - */ - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - @Override - public void accept(StrolchElementSelectionVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/Navigation.java b/li.strolch.agent/src/main/java/li/strolch/model/query/Navigation.java deleted file mode 100644 index b184bdd02..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/Navigation.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public interface Navigation { - - public void accept(QueryVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/NotSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/NotSelection.java deleted file mode 100644 index a6ea2e0cf..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/NotSelection.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public class NotSelection extends BooleanSelection { - - /** - * @param selection - */ - public NotSelection(Selection selection) { - super(selection); - } - - /** - * @throws UnsupportedOperationException - * because a {@link NotSelection} can only work on a single {@link Selection} - */ - @Override - public NotSelection with(Selection selection) { - throw new UnsupportedOperationException("NotSelection can only have a single selection"); //$NON-NLS-1$ - } - - public Selection getSelection() { - return this.selections.get(0); - } - - @Override - public void accept(QueryVisitor visitor) { - visitor.visitNot(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/OrSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/OrSelection.java deleted file mode 100644 index 813274f95..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/OrSelection.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.List; - -/** - * @author Robert von Burg - */ -public class OrSelection extends BooleanSelection { - - public OrSelection() { - super(); - } - - public OrSelection(List selections) { - super(selections); - } - - public OrSelection(Selection... selections) { - super(selections); - } - - @Override - public OrSelection with(Selection selection) { - super.with(selection); - return this; - } - - @Override - public OrSelection with(List selections) { - super.with(selections); - return this; - } - - @Override - public OrSelection with(Selection... selections) { - super.with(selections); - return this; - } - - @Override - public void accept(QueryVisitor visitor) { - visitor.visitOr(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderQuery.java b/li.strolch.agent/src/main/java/li/strolch/model/query/OrderQuery.java deleted file mode 100644 index 7c9baee29..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderQuery.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.Order; -import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.ordering.StrolchQueryOrdering; -import li.strolch.model.visitor.OrderVisitor; -import li.strolch.utils.dbc.DBC; - -/** - *

- * {@link OrderQuery} is the user API to query {@link Order Orders} in Strolch. The {@link Navigation} is used to - * navigate to a type of order on which any further {@link Selection Selections} will be performed. The - * {@link OrderVisitor} is used to transform the returned object into a domain specific object (if required). This - * mechanism allows you to query only the values of a {@link Parameter} instead of having to return all the elements and - * then performing this transformation. - *

- * - *

- * The {@link OrderVisitor} is intended for situations where the query result should not be {@link Order} but some other - * object type. For instance in a restful API, the result might have to be mapped to a POJO, thus using this method can - * perform the mapping step for you - *

- * - * @param - * defines the return type of this query. Depending on the user {@link OrderVisitor} this query can return an - * {@link Order}, or any type of object to which the visitor mapped the order - * - * @author Robert von Burg - */ -public class OrderQuery extends StrolchElementQuery { - - protected OrderVisitor orderVisitor; - protected StrolchQueryOrdering ordering; - - public OrderQuery() { - super(); - setIdentityVisitor(); - } - - public OrderQuery(Navigation navigation) { - super(navigation); - setIdentityVisitor(); - } - - private void setIdentityVisitor() { - @SuppressWarnings("unchecked") - OrderVisitor identityVisitor = t -> (U) t; - this.orderVisitor = identityVisitor; - } - - public OrderVisitor getVisitor() { - return this.orderVisitor; - } - - @Override - public OrderQuery internal() { - super.internal(); - return this; - } - - public OrderQuery setVisitor(OrderVisitor visitor) { - DBC.PRE.assertNotNull("visitor", visitor); - this.orderVisitor = visitor; - return this; - } - - public StrolchQueryOrdering getOrdering() { - return this.ordering; - } - - public OrderQuery setOrdering(StrolchQueryOrdering ordering) { - this.ordering = ordering; - return this; - } - - @Override - public OrderQuery with(Selection selection) { - super.with(selection); - return this; - } - - @Override - public OrderQuery not(Selection selection) { - super.not(selection); - return this; - } - - @Override - public OrderQuery withAny() { - super.withAny(); - return this; - } - - @Override - public void accept(OrderQueryVisitor visitor) { - DBC.PRE.assertNotNull("orderVisitor", this.orderVisitor); - super.accept(visitor); - if (this.ordering != null) - this.ordering.accept(visitor); - } - - public static OrderQuery query(String type) { - return new OrderQuery<>(new StrolchTypeNavigation(type)); - } - - public static OrderQuery query(String type, StrolchQueryOrdering ordering) { - return new OrderQuery(new StrolchTypeNavigation(type)).setOrdering(ordering); - } - - public static OrderQuery query(String type, OrderVisitor orderVisitor) { - return new OrderQuery(new StrolchTypeNavigation(type)).setVisitor(orderVisitor); - } - - public static OrderQuery query(String type, OrderVisitor orderVisitor, StrolchQueryOrdering ordering) { - return new OrderQuery(new StrolchTypeNavigation(type)).setVisitor(orderVisitor).setOrdering(ordering); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/OrderQueryVisitor.java deleted file mode 100644 index 313555197..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderQueryVisitor.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.query.ordering.StrolchQueryOrderingVisitor; - -/** - * @author Robert von Burg - */ -public interface OrderQueryVisitor extends OrderSelectionVisitor, ParameterSelectionVisitor, - StrolchQueryOrderingVisitor { - - // marker interface -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/OrderSelection.java deleted file mode 100644 index 4a904d612..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderSelection.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - * - */ -public abstract class OrderSelection implements Selection { - - @Override - public void accept(QueryVisitor visitor) { - accept((OrderSelectionVisitor) visitor); - } - - @Override - public boolean hasSelection() { - return true; - } - - public abstract void accept(OrderSelectionVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java deleted file mode 100644 index c216fe255..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public interface OrderSelectionVisitor extends StrolchRootElementSelectionVisitor { - - public void visit(DateSelection selection); - - public void visit(OrderStateSelection selection); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderStateSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/OrderStateSelection.java deleted file mode 100644 index 24dde94ad..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/OrderStateSelection.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.State; - -/** - * @author Robert von Burg - */ -public class OrderStateSelection extends OrderSelection { - - private State state; - - public OrderStateSelection(State state) { - this.state = state; - } - - public State getState() { - return this.state; - } - - @Override - public void accept(OrderSelectionVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterBagSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterBagSelection.java deleted file mode 100644 index c1910d2ea..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterBagSelection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public class ParameterBagSelection implements Selection { - - private String bagKey; - - public ParameterBagSelection(String bagKey) { - this.bagKey = bagKey; - } - - /** - * @return the bagKey - */ - public String getBagKey() { - return this.bagKey; - } - - @Override - public boolean hasSelection() { - return true; - } - - @Override - public void accept(QueryVisitor visitor) { - accept((StrolchRootElementSelectionVisitor) visitor); - } - - public void accept(StrolchRootElementSelectionVisitor visitor) { - visitor.visit(this); - } - - @SuppressWarnings("nls") - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append(getClass().getSimpleName() + " [bagKey="); - builder.append(this.bagKey); - builder.append("]"); - return builder.toString(); - } - - public static class NullParameterBagSelection extends ParameterBagSelection { - - public NullParameterBagSelection(String bagKey) { - super(bagKey); - } - - @Override - public void accept(StrolchRootElementSelectionVisitor visitor) { - visitor.visit(this); - } - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterSelection.java deleted file mode 100644 index 2e8cc01c2..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterSelection.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import li.strolch.utils.StringMatchMode; -import li.strolch.utils.collections.DateRange; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public abstract class ParameterSelection implements Selection { - - private String bagKey; - private String paramKey; - - public ParameterSelection(String bagKey, String paramKey) { - this.bagKey = bagKey; - this.paramKey = paramKey; - } - - /** - * @return the bagKey - */ - public String getBagKey() { - return this.bagKey; - } - - /** - * @return the paramKey - */ - public String getParamKey() { - return this.paramKey; - } - - @Override - public boolean hasSelection() { - return true; - } - - @Override - public void accept(QueryVisitor visitor) { - accept((ParameterSelectionVisitor) visitor); - } - - @SuppressWarnings("nls") - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append(getClass().getSimpleName() + " [bagKey="); - builder.append(this.bagKey); - builder.append(", paramKey="); - builder.append(this.paramKey); - builder.append("]"); - return builder.toString(); - } - - public abstract void accept(ParameterSelectionVisitor visitor); - - public static StringParameterSelection stringSelection(String bagKey, String paramKey, String value, - StringMatchMode matchMode) { - return new StringParameterSelection(bagKey, paramKey, value, matchMode); - } - - public static IntegerParameterSelection integerSelection(String bagKey, String paramKey, int value) { - return new IntegerParameterSelection(bagKey, paramKey, value); - } - - public static BooleanParameterSelection booleanSelection(String bagKey, String paramKey, boolean value) { - return new BooleanParameterSelection(bagKey, paramKey, value); - } - - public static FloatParameterSelection floatSelection(String bagKey, String paramKey, double value) { - return new FloatParameterSelection(bagKey, paramKey, value); - } - - public static LongParameterSelection longSelection(String bagKey, String paramKey, long value) { - return new LongParameterSelection(bagKey, paramKey, value); - } - - public static DateParameterSelection dateSelection(String bagKey, String paramKey, Date value) { - return new DateParameterSelection(bagKey, paramKey, value); - } - - public static DateRangeParameterSelection dateRangeSelection(String bagKey, String paramKey, DateRange dateRange) { - return new DateRangeParameterSelection(bagKey, paramKey, dateRange); - } - - public static StringListParameterSelection stringListSelection(String bagKey, String paramKey, String value) { - return new StringListParameterSelection(bagKey, paramKey, Arrays.asList(value)); - } - - public static StringListParameterSelection stringListSelection(String bagKey, String paramKey, List value) { - return new StringListParameterSelection(bagKey, paramKey, value); - } - - public static IntegerListParameterSelection integerListSelection(String bagKey, String paramKey, Integer value) { - return new IntegerListParameterSelection(bagKey, paramKey, Arrays.asList(value)); - } - - public static IntegerListParameterSelection integerListSelection(String bagKey, String paramKey, - List value) { - return new IntegerListParameterSelection(bagKey, paramKey, value); - } - - public static FloatListParameterSelection floatListSelection(String bagKey, String paramKey, Double value) { - return new FloatListParameterSelection(bagKey, paramKey, Arrays.asList(value)); - } - - public static FloatListParameterSelection floatListSelection(String bagKey, String paramKey, List value) { - return new FloatListParameterSelection(bagKey, paramKey, value); - } - - public static LongListParameterSelection longListSelection(String bagKey, String paramKey, Long value) { - return new LongListParameterSelection(bagKey, paramKey, Arrays.asList(value)); - } - - public static LongListParameterSelection longListSelection(String bagKey, String paramKey, List value) { - return new LongListParameterSelection(bagKey, paramKey, value); - } - - public static NullParameterSelection nullSelection(String bagKey, String paramKey) { - return new NullParameterSelection(bagKey, paramKey); - } - - public static AnyTypeParameterSelection anyTypeSelection(String bagKey, String paramKey, String value, - StringMatchMode matchMode) { - return new AnyTypeParameterSelection(bagKey, paramKey, value, matchMode); - } - - public static class AnyTypeParameterSelection extends ParameterSelection { - - private StringMatchMode matchMode; - private String value; - - public AnyTypeParameterSelection(String bagKey, String paramKey, String value, StringMatchMode matchMode) { - super(bagKey, paramKey); - this.value = value; - this.matchMode = matchMode; - } - - public String getValue() { - return this.value; - } - - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class NullParameterSelection extends ParameterSelection { - - public NullParameterSelection(String bagKey, String paramKey) { - super(bagKey, paramKey); - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class StringParameterSelection extends ParameterSelection { - - private StringMatchMode matchMode; - private String value; - - public StringParameterSelection(String bagKey, String paramKey, String value, StringMatchMode matchMode) { - super(bagKey, paramKey); - this.value = value; - this.matchMode = matchMode; - } - - public String getValue() { - return this.value; - } - - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class IntegerParameterSelection extends ParameterSelection { - - private Integer value; - - public IntegerParameterSelection(String bagKey, String paramKey, Integer value) { - super(bagKey, paramKey); - this.value = value; - } - - public Integer getValue() { - return this.value; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class BooleanParameterSelection extends ParameterSelection { - - private Boolean value; - - public BooleanParameterSelection(String bagKey, String paramKey, Boolean value) { - super(bagKey, paramKey); - this.value = value; - } - - public Boolean getValue() { - return this.value; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class LongParameterSelection extends ParameterSelection { - - private Long value; - - public LongParameterSelection(String bagKey, String paramKey, Long value) { - super(bagKey, paramKey); - this.value = value; - } - - public Long getValue() { - return this.value; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class FloatParameterSelection extends ParameterSelection { - - private Double value; - - public FloatParameterSelection(String bagKey, String paramKey, Double value) { - super(bagKey, paramKey); - this.value = value; - } - - public Double getValue() { - return this.value; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class DateParameterSelection extends ParameterSelection { - - private Date value; - - public DateParameterSelection(String bagKey, String paramKey, Date value) { - super(bagKey, paramKey); - this.value = value; - } - - public Date getValue() { - return this.value; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class DateRangeParameterSelection extends ParameterSelection { - - private DateRange dateRange; - - public DateRangeParameterSelection(String bagKey, String paramKey, DateRange dateRange) { - super(bagKey, paramKey); - DBC.PRE.assertFalse("dateRange must be set!", dateRange == null); //$NON-NLS-1$ - this.dateRange = dateRange; - } - - public DateRange getDateRange() { - return this.dateRange; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class DurationParameterSelection extends ParameterSelection { - - private Long value; - - public DurationParameterSelection(String bagKey, String paramKey, Long value) { - super(bagKey, paramKey); - this.value = value; - } - - public Long getValue() { - return this.value; - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static abstract class AbstractListParameterSelection extends ParameterSelection { - - private List value; - - public AbstractListParameterSelection(String bagKey, String paramKey, List value) { - super(bagKey, paramKey); - this.value = value; - } - - public List getValue() { - return this.value; - } - - @Override - public abstract void accept(ParameterSelectionVisitor visitor); - } - - public static class StringListParameterSelection extends AbstractListParameterSelection { - - public StringListParameterSelection(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class IntegerListParameterSelection extends AbstractListParameterSelection { - - public IntegerListParameterSelection(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class FloatListParameterSelection extends AbstractListParameterSelection { - - public FloatListParameterSelection(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } - - public static class LongListParameterSelection extends AbstractListParameterSelection { - - public LongListParameterSelection(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - - @Override - public void accept(ParameterSelectionVisitor visitor) { - visitor.visit(this); - } - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java deleted file mode 100644 index 5ef0bd3fa..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.query.ParameterSelection.AnyTypeParameterSelection; -import li.strolch.model.query.ParameterSelection.BooleanParameterSelection; -import li.strolch.model.query.ParameterSelection.DateParameterSelection; -import li.strolch.model.query.ParameterSelection.DateRangeParameterSelection; -import li.strolch.model.query.ParameterSelection.DurationParameterSelection; -import li.strolch.model.query.ParameterSelection.FloatListParameterSelection; -import li.strolch.model.query.ParameterSelection.FloatParameterSelection; -import li.strolch.model.query.ParameterSelection.IntegerListParameterSelection; -import li.strolch.model.query.ParameterSelection.IntegerParameterSelection; -import li.strolch.model.query.ParameterSelection.LongListParameterSelection; -import li.strolch.model.query.ParameterSelection.LongParameterSelection; -import li.strolch.model.query.ParameterSelection.NullParameterSelection; -import li.strolch.model.query.ParameterSelection.StringListParameterSelection; -import li.strolch.model.query.ParameterSelection.StringParameterSelection; - -/** - * @author Robert von Burg - */ -public interface ParameterSelectionVisitor extends QueryVisitor { - - public void visit(StringParameterSelection selection); - - public void visit(IntegerParameterSelection selection); - - public void visit(BooleanParameterSelection selection); - - public void visit(LongParameterSelection selection); - - public void visit(FloatParameterSelection selection); - - public void visit(DateParameterSelection selection); - - public void visit(DurationParameterSelection selection); - - public void visit(DateRangeParameterSelection selection); - - public void visit(StringListParameterSelection selection); - - public void visit(IntegerListParameterSelection selection); - - public void visit(FloatListParameterSelection selection); - - public void visit(LongListParameterSelection selection); - - public void visit(NullParameterSelection selection); - - public void visit(AnyTypeParameterSelection selection); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/QueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/QueryVisitor.java deleted file mode 100644 index 7846915ed..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/QueryVisitor.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.visitor.StrolchVisitor; - -/** - * @author Robert von Burg - */ -public interface QueryVisitor extends StrolchVisitor { - - public void visitAny(); - - public void visitAnd(AndSelection andSelection); - - public void visitOr(OrSelection orSelection); - - public void visitNot(NotSelection notSelection); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ResourceQuery.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ResourceQuery.java deleted file mode 100644 index f5721af77..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ResourceQuery.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.Resource; -import li.strolch.model.parameter.Parameter; -import li.strolch.model.query.ordering.StrolchQueryOrdering; -import li.strolch.model.visitor.ResourceVisitor; -import li.strolch.utils.dbc.DBC; - -/** - *

- * {@link ResourceQuery} is the user API to query {@link Resource Resources} in Strolch. The {@link Navigation} is used - * to navigate to a type of resource on which any further {@link Selection Selections} will be performed. The - * {@link ResourceVisitor} is used to transform the returned object into a domain specific object (if required). This - * mechanism allows you to query only the values of a {@link Parameter} instead of having to return all the elements and - * then performing this transformation. - *

- * - *

- * The {@link ResourceVisitor} is intended for situations where the query result should not be {@link Resource} but some - * other object type. For instance in a restful API, the result might have to be mapped to a POJO, thus using this - * method can perform the mapping step for you - *

- * - * @param - * defines the return type of this query. Depending on the user {@link ResourceVisitor} this query can return - * a {@link Resource}, or any type of object to which the visitor mapped the resource - * - * @author Robert von Burg - */ -public class ResourceQuery extends StrolchElementQuery { - - protected ResourceVisitor resourceVisitor; - protected StrolchQueryOrdering ordering; - - public ResourceQuery() { - super(); - setIdentityVisitor(); - } - - public ResourceQuery(Navigation navigation) { - super(navigation); - setIdentityVisitor(); - } - - private void setIdentityVisitor() { - @SuppressWarnings("unchecked") - ResourceVisitor identityVisitor = t -> (U) t; - this.resourceVisitor = identityVisitor; - } - - public ResourceVisitor getVisitor() { - return this.resourceVisitor; - } - - @Override - public ResourceQuery internal() { - super.internal(); - return this; - } - - public ResourceQuery setVisitor(ResourceVisitor visitor) { - DBC.PRE.assertNotNull("visitor", visitor); - this.resourceVisitor = visitor; - return this; - } - - public StrolchQueryOrdering getOrdering() { - return this.ordering; - } - - public ResourceQuery setOrdering(StrolchQueryOrdering ordering) { - this.ordering = ordering; - return this; - } - - @Override - public ResourceQuery with(Selection selection) { - super.with(selection); - return this; - } - - @Override - public ResourceQuery not(Selection selection) { - super.not(selection); - return this; - } - - @Override - public ResourceQuery withAny() { - super.withAny(); - return this; - } - - @Override - public void accept(ResourceQueryVisitor visitor) { - DBC.PRE.assertNotNull("resourceVisitor", this.resourceVisitor); - super.accept(visitor); - if (this.ordering != null) - this.ordering.accept(visitor); - } - - public static ResourceQuery query(String type) { - return new ResourceQuery<>(new StrolchTypeNavigation(type)); - } - - public static ResourceQuery query(String type, StrolchQueryOrdering ordering) { - return new ResourceQuery(new StrolchTypeNavigation(type)).setOrdering(ordering); - } - - public static ResourceQuery query(String type, ResourceVisitor resourceVisitor) { - return new ResourceQuery(new StrolchTypeNavigation(type)).setVisitor(resourceVisitor); - } - - public static ResourceQuery query(String type, ResourceVisitor resourceVisitor, - StrolchQueryOrdering ordering) { - return new ResourceQuery(new StrolchTypeNavigation(type)).setVisitor(resourceVisitor).setOrdering(ordering); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java deleted file mode 100644 index 0badac2b9..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.query.ordering.StrolchQueryOrderingVisitor; - -/** - * @author Robert von Burg - */ -public interface ResourceQueryVisitor extends StrolchRootElementSelectionVisitor, ParameterSelectionVisitor, - StrolchQueryOrderingVisitor { - - // marker interface -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/Selection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/Selection.java deleted file mode 100644 index 83514b733..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/Selection.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public interface Selection { - - public void accept(QueryVisitor visitor); - - public boolean hasSelection(); - - public default Selection not() { - return new NotSelection(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StringSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StringSelection.java deleted file mode 100644 index 8fa88be1b..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StringSelection.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class StringSelection { - - private StringMatchMode matchMode; - private String[] values; - - public StringSelection() { - // - } - - /** - * @param matchMode - * @param values - */ - public StringSelection(StringMatchMode matchMode, String[] values) { - this.matchMode = matchMode; - this.values = values; - } - - /** - * @return the matchMode - */ - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - /** - * @param matchMode - * the matchMode to set - */ - public void setMatchMode(StringMatchMode matchMode) { - this.matchMode = matchMode; - } - - /** - * @return the values - */ - public String[] getValues() { - return this.values; - } - - /** - * @param values - * the values to set - */ - public void setValues(String... values) { - this.values = values; - } - - /** - * @return - */ - public boolean isWildCard() { - return this.values == null || this.values.length == 0; - } - - public boolean matches(String value) { - for (String sel : this.values) { - if (this.matchMode.matches(value, sel)) - return true; - } - return false; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementQuery.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementQuery.java deleted file mode 100644 index ac4822480..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementQuery.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import static li.strolch.model.StrolchModelConstants.INTERNAL; - -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public abstract class StrolchElementQuery implements StrolchQuery { - - private String privilegeValue; - - protected Navigation navigation; - protected Selection selection; - - public StrolchElementQuery() { - this.privilegeValue = getClass().getName(); - } - - public StrolchElementQuery(Navigation navigation) { - this(); - this.navigation = navigation; - } - - /** - * Marks this query as an internal query, thus allowing it to be performed without the authenticated user to need - * the required privilege - * - * @return this object for chaining - */ - public StrolchElementQuery internal() { - this.privilegeValue = INTERNAL; - return this; - } - - public void setPrivilegeValue(String privilegeValue) { - this.privilegeValue = privilegeValue; - } - - public void setNavigation(Navigation navigation) { - this.navigation = navigation; - } - - public boolean hasNavigation() { - return this.navigation != null; - } - - public Navigation getNavigation() { - return this.navigation; - } - - public boolean hasSelection() { - return this.selection != null && this.selection.hasSelection(); - } - - public Selection getSelection() { - return this.selection; - } - - public StrolchElementQuery with(Selection selection) { - assertNoSelectionYetSet(); - this.selection = selection; - return this; - } - - private void assertNoSelectionYetSet() { - String msg = "A selection is already set! Use a cascaded boolean operators to perform multiple selections"; //$NON-NLS-1$ - DBC.PRE.assertNull(msg, this.selection); - } - - public StrolchElementQuery withAny() { - assertNoSelectionYetSet(); - this.selection = new AnySelection(); - return this; - } - - public AndSelection and() { - assertNoSelectionYetSet(); - AndSelection and = new AndSelection(); - this.selection = and; - return and; - } - - public OrSelection or() { - assertNoSelectionYetSet(); - OrSelection or = new OrSelection(); - this.selection = or; - return or; - } - - public StrolchElementQuery not(Selection selection) { - assertNoSelectionYetSet(); - this.selection = new NotSelection(selection); - return this; - } - - public void accept(T visitor) { - DBC.PRE.assertNotNull("No navigation set!", this.navigation); //$NON-NLS-1$ - DBC.PRE.assertNotNull("No selection defined!", this.selection); //$NON-NLS-1$ - this.navigation.accept(visitor); - this.selection.accept(visitor); - } - - /** - * @see li.strolch.privilege.model.Restrictable#getPrivilegeName() - */ - @Override - public String getPrivilegeName() { - return StrolchQuery.class.getName(); - } - - /** - * @see li.strolch.privilege.model.Restrictable#getPrivilegeValue() - */ - @Override - public Object getPrivilegeValue() { - return this.privilegeValue; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementSelection.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementSelection.java deleted file mode 100644 index 0d33dc4bc..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementSelection.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public abstract class StrolchElementSelection implements Selection { - - @Override - public void accept(QueryVisitor visitor) { - accept((StrolchElementSelectionVisitor) visitor); - } - - @Override - public boolean hasSelection() { - return true; - } - - public abstract void accept(StrolchElementSelectionVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementSelectionVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementSelectionVisitor.java deleted file mode 100644 index b7bf67fdb..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchElementSelectionVisitor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -/** - * @author Robert von Burg - */ -public interface StrolchElementSelectionVisitor extends QueryVisitor { - - public void visit(StrolchTypeNavigation navigation); - - public void visit(IdSelection selection); - - public void visit(NameSelection selection); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchQuery.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchQuery.java deleted file mode 100644 index de1d56cf5..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchQuery.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.privilege.model.Restrictable; - -/** - * @author Robert von Burg - */ -public interface StrolchQuery extends Restrictable { - - // marker interface -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java deleted file mode 100644 index 3a2c3cace..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.model.query.ParameterBagSelection.NullParameterBagSelection; - -/** - * @author Robert von Burg - */ -public interface StrolchRootElementSelectionVisitor extends StrolchElementSelectionVisitor { - - public void visit(ParameterBagSelection selection); - - public void visit(NullParameterBagSelection selection); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchTypeNavigation.java b/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchTypeNavigation.java deleted file mode 100644 index 66a7d8340..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/StrolchTypeNavigation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query; - -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class StrolchTypeNavigation implements Navigation { - - private String type; - - public StrolchTypeNavigation(String type) { - DBC.PRE.assertNotEmpty("type", type); - this.type = type; - } - - public String getType() { - return this.type; - } - - @Override - public void accept(QueryVisitor visitor) { - accept((StrolchElementSelectionVisitor) visitor); - } - - public void accept(StrolchElementSelectionVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByIdComparator.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByIdComparator.java deleted file mode 100644 index 4454a5a36..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByIdComparator.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - */ -package li.strolch.model.query.ordering; - -import java.util.Comparator; - -import li.strolch.model.StrolchRootElement; - -/** - * @author Robert von Burg - */ -public class ByIdComparator implements Comparator { - - private boolean ascending; - - public ByIdComparator(boolean ascending) { - this.ascending = ascending; - } - - @Override - public int compare(T o1, T o2) { - return this.ascending ? o1.getId().compareTo(o2.getId()) : o2.getId().compareTo(o1.getId()); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByNameComparator.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByNameComparator.java deleted file mode 100644 index e3b6bdb0e..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByNameComparator.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - */ -package li.strolch.model.query.ordering; - -import java.util.Comparator; - -import li.strolch.model.StrolchRootElement; - -/** - * @author Robert von Burg - */ -public class ByNameComparator implements Comparator { - - private boolean ascending; - - public ByNameComparator(boolean ascending) { - this.ascending = ascending; - } - - @Override - public int compare(T o1, T o2) { - return this.ascending ? o1.getName().compareTo(o2.getName()) : o2.getName().compareTo(o1.getName()); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByParamComparator.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByParamComparator.java deleted file mode 100644 index 0ad95363f..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/ByParamComparator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - */ -package li.strolch.model.query.ordering; - -import java.util.Comparator; - -import li.strolch.exception.StrolchException; -import li.strolch.model.StrolchRootElement; -import li.strolch.model.parameter.Parameter; - -/** - * @author Robert von Burg - */ -public class ByParamComparator implements Comparator { - - private String bagKey; - private String paramKey; - private boolean ascending; - - public ByParamComparator(String bagKey, String paramKey, boolean ascending) { - this.bagKey = bagKey; - this.paramKey = paramKey; - this.ascending = ascending; - } - - @Override - public int compare(T o1, T o2) { - - Parameter param1 = o1.getParameter(bagKey, paramKey); - if (param1 == null) - throw new StrolchException("Sorting parameter bag=" + bagKey + ", param=" + paramKey + " does not exist on " - + o1.getLocator()); - - Parameter param2 = o2.getParameter(bagKey, paramKey); - if (param2 == null) - throw new StrolchException("Sorting parameter bag=" + bagKey + ", param=" + paramKey + " does not exist on " - + o2.getLocator()); - - return this.ascending ? param1.compareTo(param2) : param2.compareTo(param1); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderById.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderById.java deleted file mode 100644 index 16997388f..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderById.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query.ordering; - -/** - * @author Robert von Burg - */ -public class OrderById extends StrolchQueryOrdering { - - /** - * Creates this ordering with ascending order - */ - public OrderById() { - super(true); - } - - /** - * Creates this ordering the given ascending order - * - * @param ascending - * true for ascending, false for descending order - */ - public OrderById(boolean ascending) { - super(ascending); - } - - @Override - public void accept(StrolchQueryOrderingVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderByName.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderByName.java deleted file mode 100644 index 5f55003f3..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderByName.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query.ordering; - -/** - * @author Robert von Burg - */ -public class OrderByName extends StrolchQueryOrdering { - - /** - * Creates this ordering with ascending order - */ - public OrderByName() { - super(true); - } - - /** - * Creates this ordering the given ascending order - * - * @param ascending - * true for ascending, false for descending order - */ - public OrderByName(boolean ascending) { - super(ascending); - } - - @Override - public void accept(StrolchQueryOrderingVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderByParameter.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderByParameter.java deleted file mode 100644 index 1dd8e621c..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/OrderByParameter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query.ordering; - -import li.strolch.model.ParameterBag; -import li.strolch.model.parameter.Parameter; - -/** - * @author Robert von Burg - */ -public class OrderByParameter extends StrolchQueryOrdering { - - private String bagKey; - private String paramKey; - - /** - * Creates this ordering with the given bagKey and paramKey with ascending order - * - * @param bagKey - * the {@link ParameterBag} in which to retrieve the {@link Parameter} for ordering - * @param paramKey - * the {@link Parameter} with which to order - */ - public OrderByParameter(String bagKey, String paramKey) { - super(true); - this.bagKey = bagKey; - this.paramKey = paramKey; - } - - /** - * Creates this ordering with the given bagKey and paramKey and ascending order - * - * @param ascending - * true for ascending, false for descending order - * @param bagKey - * the {@link ParameterBag} in which to retrieve the {@link Parameter} for ordering - * @param paramKey - * the {@link Parameter} with which to order - */ - public OrderByParameter(boolean ascending, String bagKey, String paramKey) { - super(ascending); - this.bagKey = bagKey; - this.paramKey = paramKey; - } - - public String getBagKey() { - return this.bagKey; - } - - public String getParamKey() { - return this.paramKey; - } - - @Override - public void accept(StrolchQueryOrderingVisitor visitor) { - visitor.visit(this); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/StrolchQueryOrdering.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/StrolchQueryOrdering.java deleted file mode 100644 index 03e3b2f6d..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/StrolchQueryOrdering.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query.ordering; - -/** - * @author Robert von Burg - */ -public abstract class StrolchQueryOrdering { - - private boolean ascending; - - public StrolchQueryOrdering(boolean ascending) { - this.ascending = ascending; - } - - public boolean isAscending() { - return this.ascending; - } - - public void setAscending(boolean ascending) { - this.ascending = ascending; - } - - public abstract void accept(StrolchQueryOrderingVisitor visitor); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/StrolchQueryOrderingVisitor.java b/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/StrolchQueryOrderingVisitor.java deleted file mode 100644 index 76f0bd9e2..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/model/query/ordering/StrolchQueryOrderingVisitor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.model.query.ordering; - -/** - * @author Robert von Burg - */ -public interface StrolchQueryOrderingVisitor { - - public StrolchQueryOrderingVisitor visit(OrderById orderById); - - public StrolchQueryOrderingVisitor visit(OrderByName orderByName); - - public StrolchQueryOrderingVisitor visit(OrderByParameter orderByParameter); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java index 841020394..6b46bd39d 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java @@ -1,18 +1,3 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package li.strolch.persistence.api; import static li.strolch.agent.api.StrolchAgent.getUniqueId; @@ -28,7 +13,6 @@ import java.util.stream.Stream; import li.strolch.agent.api.*; import li.strolch.agent.impl.*; -import li.strolch.exception.StrolchAccessDeniedException; import li.strolch.exception.StrolchException; import li.strolch.exception.StrolchModelException; import li.strolch.handler.operationslog.OperationsLog; @@ -45,7 +29,6 @@ import li.strolch.model.parameter.Parameter; import li.strolch.model.parameter.StringListParameter; import li.strolch.model.parameter.StringParameter; import li.strolch.model.policy.PolicyDef; -import li.strolch.model.query.*; import li.strolch.model.timedstate.StrolchTimedState; import li.strolch.model.timevalue.IValue; import li.strolch.policy.PolicyHandler; @@ -58,7 +41,6 @@ import li.strolch.privilege.model.Restrictable; import li.strolch.runtime.privilege.PrivilegeHandler; import li.strolch.runtime.privilege.TransactedRestrictable; import li.strolch.service.api.Command; -import li.strolch.utils.I18nMessage; import li.strolch.utils.collections.MapOfMaps; import li.strolch.utils.dbc.DBC; import li.strolch.utils.helper.StringHelper; @@ -73,10 +55,10 @@ public abstract class AbstractTransaction implements StrolchTransaction { protected static final Logger logger = LoggerFactory.getLogger(AbstractTransaction.class); - private ComponentContainer container; - private PrivilegeHandler privilegeHandler; - - private InternalStrolchRealm realm; + private final ComponentContainer container; + private final PrivilegeHandler privilegeHandler; + private final InternalStrolchRealm realm; + private final TransactionResult txResult; private ObjectFilter objectFilter; private MapOfMaps resourceCache; @@ -88,19 +70,18 @@ public abstract class AbstractTransaction implements StrolchTransaction { private boolean suppressUpdates; private boolean suppressAudits; private boolean suppressAuditsForAudits; - private TransactionResult txResult; private List commands; - private List flushedCommands; - private Set lockedElements; + private final List flushedCommands; + private final Set lockedElements; private AuditingOrderMap orderMap; private AuditingResourceMap resourceMap; private AuditingActivityMap activityMap; private AuditingAuditMapFacade auditTrail; - private String action; - private Certificate certificate; + private final String action; + private final Certificate certificate; private PrivilegeContext privilegeContext; public AbstractTransaction(ComponentContainer container, StrolchRealm realm, Certificate certificate, String action, @@ -446,64 +427,6 @@ public abstract class AbstractTransaction implements StrolchTransaction { return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, defaultDef, this); } - private void assertQueryAllowed(StrolchQuery query) { - try { - getPrivilegeContext().validateAction(query); - } catch (AccessDeniedException e) { - - String username = getCertificate().getUsername(); - if (getContainer().hasComponent(OperationsLog.class)) { - String realmName = getRealmName(); - String queryName = query.getPrivilegeValue().equals(INTERNAL) ? - (getClass().getName() + " (INTERNAL)") : - query.getPrivilegeValue().toString(); - LogMessage logMessage = new LogMessage(realmName, username, - Locator.valueOf(AGENT, PrivilegeHandler.class.getSimpleName(), query.getPrivilegeName(), - queryName), LogSeverity.Exception, LogMessageState.Information, - ResourceBundle.getBundle("strolch-agent"), "agent.query.failed.access.denied") - .value("user", username).value("query", queryName).withException(e); - - OperationsLog operationsLog = getContainer().getComponent(OperationsLog.class); - operationsLog.addMessage(logMessage); - } - - String queryName = query.getPrivilegeValue().equals(INTERNAL) ? - (getClass().getSimpleName() + " (INTERNAL)") : - query.getClass().getSimpleName(); - I18nMessage i18n = new I18nMessage(ResourceBundle.getBundle("strolch-agent", getCertificate().getLocale()), - "agent.search.failed.access.denied").value("user", username).value("query", queryName); - throw new StrolchAccessDeniedException(this.certificate, query, i18n, e); - } - } - - @Override - public List doQuery(OrderQuery query) { - assertQueryAllowed(query); - DBC.PRE.assertNotNull("orderVisitor", query.getVisitor()); - return getOrderMap().doQuery(this, query); - } - - @Override - public List doQuery(ResourceQuery query) { - assertQueryAllowed(query); - DBC.PRE.assertNotNull("resourceVisitor", query.getVisitor()); - return getResourceMap().doQuery(this, query); - } - - @Override - public List doQuery(ActivityQuery query) { - assertQueryAllowed(query); - DBC.PRE.assertNotNull("activityVisitor", query.getVisitor()); - return getActivityMap().doQuery(this, query); - } - - @Override - public List doQuery(AuditQuery query) { - assertQueryAllowed(query); - DBC.PRE.assertNotNull("auditVisitor", query.getVisitor()); - return getAuditTrail().doQuery(this, query); - } - @Override public T findElement(Locator locator) throws StrolchModelException, ClassCastException { return findElement(locator, false); diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AuditDao.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AuditDao.java index 593aeced5..93cb14b92 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AuditDao.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AuditDao.java @@ -1,12 +1,12 @@ /* * Copyright 2013 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.utils.collections.DateRange; /** @@ -52,6 +51,4 @@ public interface AuditDao { void removeAll(List audits); long removeAll(String type, DateRange dateRange); - - List doQuery(AuditQuery query); } diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java index 2523c7806..c582ebc45 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/StrolchTransaction.java @@ -30,18 +30,10 @@ import li.strolch.model.activity.Action; import li.strolch.model.activity.Activity; import li.strolch.model.audit.AccessType; import li.strolch.model.audit.Audit; -import li.strolch.model.audit.AuditVisitor; import li.strolch.model.parameter.Parameter; import li.strolch.model.parameter.StringListParameter; import li.strolch.model.parameter.StringParameter; import li.strolch.model.policy.PolicyDef; -import li.strolch.model.query.ActivityQuery; -import li.strolch.model.query.AuditQuery; -import li.strolch.model.query.OrderQuery; -import li.strolch.model.query.ResourceQuery; -import li.strolch.model.visitor.ActivityVisitor; -import li.strolch.model.visitor.OrderVisitor; -import li.strolch.model.visitor.ResourceVisitor; import li.strolch.policy.StrolchPolicy; import li.strolch.privilege.base.AccessDeniedException; import li.strolch.privilege.base.PrivilegeException; @@ -236,10 +228,10 @@ public interface StrolchTransaction extends AutoCloseable { * the element from which to retrieve the {@link PolicyDef * @param * the type of policy to return + * @param clazz + * the type of policy to return * * @return the policy - * @param clazz - * the type of policy to return */ T getPolicy(PolicyContainer element, Class clazz); @@ -624,60 +616,6 @@ public interface StrolchTransaction extends AutoCloseable { */ Audit auditFrom(AccessType accessType, StrolchRootElement element); - /** - *

- * Performs the given {@link OrderQuery} and each returned {@link Order} is passed through the {@link OrderVisitor} - * attached to the {@link OrderQuery} and the return value of the visitor is added to the return list - *

- * - * @param query - * the query to perform - * - * @return the result list of elements as returned by the {@link OrderVisitor}, never null - */ - List doQuery(OrderQuery query); - - /** - *

- * Performs the given {@link ResourceQuery} and each returned {@link Resource} is passed through the {@link - * ResourceVisitor} attached to the {@link ResourceQuery} and the return value of the visitor is added to the return - * list - *

- * - * @param query - * the query to perform - * - * @return the result list of elements as returned by the {@link ResourceVisitor}, never null - */ - List doQuery(ResourceQuery query); - - /** - *

- * Performs the given {@link ActivityQuery} and each returned {@link Activity} is passed through the {@link - * ActivityVisitor} attached to the {@link ActivityQuery} and the return value of the visitor is added to the return - * list - *

- * - * @param query - * the query to perform - * - * @return the result list of elements as returned by the {@link ActivityVisitor}, never null - */ - List doQuery(ActivityQuery query); - - /** - *

- * Performs the given {@link AuditQuery} and each returned {@link Audit} is passed through the {@link AuditVisitor} - * attached to the {@link AuditQuery} and the return value of the visitor is added to the return list - *

- * - * @param query - * the query to perform - * - * @return the result list of elements as returned by the {@link AuditVisitor}, never null - */ - List doQuery(AuditQuery query); - /** *

* Used to find a {@link StrolchElement} by a {@link Locator}, throwing exception if the element is not found diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ActivityStateSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ActivityStateSelector.java deleted file mode 100644 index 2d7a66f51..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ActivityStateSelector.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.State; -import li.strolch.model.activity.Activity; - -/** - * @author Robert von Burg - */ -public class ActivityStateSelector implements Selector { - - private State state; - - /** - * @param state - */ - public ActivityStateSelector(State state) { - this.state = state; - } - - @Override - public boolean select(Activity element) { - return this.state.equals(element.getState()); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ActivityTypeNavigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ActivityTypeNavigator.java deleted file mode 100644 index 2701a3249..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ActivityTypeNavigator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.stream.Stream; - -import li.strolch.agent.api.ElementMap; -import li.strolch.model.activity.Activity; -import li.strolch.persistence.api.StrolchTransaction; - -/** - * @author Robert von Burg - */ -public class ActivityTypeNavigator extends StrolchTypeNavigator { - - public ActivityTypeNavigator(String type) { - super(type); - } - - @Override - public > Stream navigate(StrolchTransaction tx, U elementMap) { - return tx.streamActivities(this.type); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AndSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AndSelector.java deleted file mode 100644 index 100a7fb43..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AndSelector.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.model.StrolchElement; - -/** - * @author Robert von Burg - */ -public class AndSelector extends BooleanSelector { - - public AndSelector() { - super(); - } - - public AndSelector(List> selectors) { - super(selectors); - } - - @Override - public AndSelector with(Selector selector) { - super.with(selector); - return this; - } - - @Override - public boolean select(T element) { - if (this.selectors == null || this.selectors.isEmpty()) - return true; - - for (Selector selector : this.selectors) { - if (!selector.select(element)) - return false; - } - - return true; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AnySelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AnySelector.java deleted file mode 100644 index e75ac935b..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AnySelector.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.StrolchElement; - -/** - * @author Robert von Burg - */ -public class AnySelector implements Selector { - - @Override - public boolean select(T element) { - return true; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditNavigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditNavigator.java deleted file mode 100644 index e7e233827..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditNavigator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.agent.api.AuditTrail; -import li.strolch.model.audit.Audit; -import li.strolch.persistence.api.StrolchTransaction; - -/** - * @author Robert von Burg - */ -public interface AuditNavigator { - - public List navigate(StrolchTransaction tx, AuditTrail auditTrail); -} \ No newline at end of file diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditSelector.java deleted file mode 100644 index a76e282cf..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditSelector.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.HashSet; -import java.util.Set; - -import li.strolch.model.audit.AccessType; -import li.strolch.model.audit.Audit; -import li.strolch.model.query.ActionSelection; -import li.strolch.model.query.ElementSelection; -import li.strolch.model.query.IdentitySelection; -import li.strolch.model.query.StringSelection; - -/** - * @author Robert von Burg - */ -public abstract class AuditSelector { - - public abstract boolean select(Audit audit); - - public static AuditSelector selectorFor(ElementSelection selection) { - return new ElementSelector(selection); - } - - public static AuditSelector selectorFor(IdentitySelection selection) { - return new IdentitySelector(selection); - } - - public static AuditSelector selectorFor(ActionSelection selection) { - return new ActionSelector(selection); - } - - private static class ElementSelector extends AuditSelector { - private StringSelection elementSubTypeSelection; - private StringSelection elementAccessedSelection; - - public ElementSelector(ElementSelection selection) { - this.elementSubTypeSelection = selection.getElementSubTypeSelection(); - this.elementAccessedSelection = selection.getElementAccessedSelection(); - } - - @Override - public boolean select(Audit audit) { - - if (this.elementSubTypeSelection != null) { - if (!this.elementSubTypeSelection.matches(audit.getElementSubType())) - return false; - } - - if (this.elementAccessedSelection != null) { - if (!this.elementAccessedSelection.matches(audit.getElementAccessed())) - return false; - } - - return true; - } - } - - public static class IdentitySelector extends AuditSelector { - - private StringSelection firstnameSelection; - private StringSelection lastnameSelection; - private StringSelection usernameSelection; - - public IdentitySelector(IdentitySelection selection) { - this.firstnameSelection = selection.getFirstnameSelection(); - this.lastnameSelection = selection.getLastnameSelection(); - this.usernameSelection = selection.getUsernameSelection(); - } - - @Override - public boolean select(Audit audit) { - - if (this.firstnameSelection != null) { - if (!this.firstnameSelection.matches(audit.getFirstname())) - return false; - } - - if (this.lastnameSelection != null) { - if (!this.lastnameSelection.matches(audit.getLastname())) - return false; - } - - if (this.usernameSelection != null) { - if (!this.usernameSelection.matches(audit.getUsername())) - return false; - } - - return true; - } - } - - public static class ActionSelector extends AuditSelector { - - private Set accessTypes; - private StringSelection actionSelection; - - public ActionSelector(ActionSelection selection) { - if (selection.getAccessTypes() != null && !selection.getAccessTypes().isEmpty()) - this.accessTypes = new HashSet<>(selection.getAccessTypes()); - this.actionSelection = selection.getActionSelection(); - } - - @Override - public boolean select(Audit audit) { - - if (this.accessTypes != null) { - if (!this.accessTypes.contains(audit.getAccessType())) - return false; - } - - if (this.actionSelection != null) { - if (!this.actionSelection.matches(audit.getAction())) - return false; - } - - return true; - } - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditTypeNavigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditTypeNavigator.java deleted file mode 100644 index 92507f091..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/AuditTypeNavigator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.agent.api.AuditTrail; -import li.strolch.model.audit.Audit; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.utils.collections.DateRange; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class AuditTypeNavigator implements AuditNavigator { - - private String type; - private DateRange dateRange; - - public AuditTypeNavigator(String type, DateRange dateRange) { - DBC.PRE.assertNotNull("type", type); - DBC.PRE.assertNotNull("dateRange", dateRange); - this.type = type; - this.dateRange = dateRange; - } - - @Override - public List navigate(StrolchTransaction tx, AuditTrail auditTrail) { - return auditTrail.getAllElements(tx, this.type, this.dateRange); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/BooleanSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/BooleanSelector.java deleted file mode 100644 index e2eb4d093..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/BooleanSelector.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import li.strolch.model.StrolchElement; - -/** - * @author Robert von Burg - */ -public abstract class BooleanSelector implements Selector { - - protected List> selectors; - - public BooleanSelector() { - this.selectors = new ArrayList<>(1); - } - - public BooleanSelector(Selector selector) { - this.selectors = Arrays.asList(selector); - } - - public BooleanSelector(Selector leftHandSide, Selector rightHandSide) { - this.selectors = new ArrayList<>(2); - this.selectors.add(leftHandSide); - this.selectors.add(rightHandSide); - } - - public BooleanSelector(List> selectors) { - this.selectors = selectors; - } - - public BooleanSelector with(Selector selector) { - this.selectors.add(selector); - return this; - } - - @Override - public abstract boolean select(T element); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/DateSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/DateSelector.java deleted file mode 100644 index e7529ca9a..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/DateSelector.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.Order; -import li.strolch.utils.collections.DateRange; - -/** - * @author Robert von Burg - */ -public class DateSelector implements Selector { - - private DateRange dateRange; - - public DateSelector(DateRange dateRange) { - this.dateRange = dateRange; - } - - /** - * @return the dateRange - */ - public DateRange getDateRange() { - return this.dateRange; - } - - @Override - public boolean select(Order element) { - return this.dateRange.contains(element.getDate()); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/IdSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/IdSelector.java deleted file mode 100644 index 07bc02aa7..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/IdSelector.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.model.StrolchElement; -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class IdSelector implements Selector { - - private StringMatchMode matchMode; - private List ids; - - /** - * @param ids - * @param matchMode - */ - public IdSelector(List ids, StringMatchMode matchMode) { - this.ids = ids; - this.matchMode = matchMode; - } - - /** - * @return the ids - */ - public List getIds() { - return this.ids; - } - - /** - * @return the matchMode - */ - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - /** - * @param id - * @return - */ - public IdSelector with(String id) { - this.ids.add(id); - return this; - } - - @Override - public boolean select(StrolchElement element) { - if (this.ids.isEmpty()) - return true; - - String elemId = element.getId(); - if (this.ids.size() == 1) - return this.matchMode.matches(elemId, this.ids.get(0)); - - for (String id : this.ids) { - if (this.matchMode.matches(elemId, id)) - return true; - } - - return false; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryActivityQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryActivityQueryVisitor.java deleted file mode 100644 index f0ad4a61e..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryActivityQueryVisitor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.model.activity.Activity; -import li.strolch.model.query.ActivityQuery; -import li.strolch.model.query.ActivityQueryVisitor; -import li.strolch.model.query.ActivityStateSelection; -import li.strolch.model.query.StrolchTypeNavigation; -import li.strolch.model.visitor.ActivityVisitor; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class InMemoryActivityQueryVisitor extends InMemoryQueryVisitor implements ActivityQueryVisitor { - - public InMemoryActivityQueryVisitor() { - super(); - } - - @Override - protected InMemoryQueryVisitor newInstance() { - return new InMemoryActivityQueryVisitor(); - } - - public InMemoryQuery visit(ActivityQuery activityQuery) { - ActivityVisitor activityVisitor = activityQuery.getVisitor(); - DBC.PRE.assertNotNull("ActivityVisitor may not be null!", activityVisitor); //$NON-NLS-1$ - - activityQuery.accept(this); - - Navigator navigator = getNavigator(); - if (navigator == null) { - String msg = "Query is missing a navigation!"; //$NON-NLS-1$ - throw new QueryException(msg); - } - - List> selectors = getSelectors(); - if (selectors.isEmpty()) - return new InMemoryQuery<>(navigator, null, activityVisitor, getComparator()); - - DBC.PRE.assertTrue("Invalid query as it may only contain one selector!", selectors.size() == 1); //$NON-NLS-1$ - return new InMemoryQuery<>(navigator, selectors.get(0), activityVisitor, getComparator()); - } - - @Override - public void visit(StrolchTypeNavigation navigation) { - setNavigator(new ActivityTypeNavigator(navigation.getType())); - } - - @Override - public void visit(ActivityStateSelection selection) { - addSelector(new ActivityStateSelector(selection.getState())); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryAuditQuery.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryAuditQuery.java deleted file mode 100644 index 9b5ab3d8e..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryAuditQuery.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.ArrayList; -import java.util.List; - -import li.strolch.agent.api.AuditTrail; -import li.strolch.model.audit.Audit; -import li.strolch.model.audit.AuditVisitor; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.utils.dbc.DBC; - -/** - * @param - * - * @author Robert von Burg - */ -public class InMemoryAuditQuery { - - private AuditTypeNavigator navigator; - private List selectors; - private AuditVisitor auditVisitor; - private long limit; - - public InMemoryAuditQuery(AuditTypeNavigator navigator, long limit, List selectors, - AuditVisitor auditVisitor) { - DBC.PRE.assertNotNull("Navigator must be set!", navigator); //$NON-NLS-1$ - DBC.PRE.assertNotNull("selectors must be set!", selectors); //$NON-NLS-1$ - DBC.PRE.assertNotNull("auditVisitor must be set!", auditVisitor); //$NON-NLS-1$ - this.navigator = navigator; - this.limit = limit; - this.selectors = selectors; - this.auditVisitor = auditVisitor; - } - - public List doQuery(StrolchTransaction tx, AuditTrail auditTrail) { - - List result = new ArrayList<>(); - List elements = this.navigator.navigate(tx, auditTrail); - - elements.sort((a1, a2) -> a2.getDate().compareTo(a1.getDate())); - - for (Audit audit : elements) { - - if (!this.selectors.isEmpty()) { - boolean nok = false; - for (AuditSelector selector : this.selectors) { - if (!selector.select(audit)) { - nok = true; - break; - } - } - - if (nok) - continue; - } - - U returnValue = this.auditVisitor.visitAudit(audit); - DBC.INTERIM.assertNotNull("Visitor may not return null in query!", returnValue); //$NON-NLS-1$ - result.add(returnValue); - - if (this.limit > 0 && result.size() >= this.limit) - break; - } - - return result; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryAuditQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryAuditQueryVisitor.java deleted file mode 100644 index 12697a2f0..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryAuditQueryVisitor.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.ArrayList; -import java.util.List; - -import li.strolch.model.audit.AuditVisitor; -import li.strolch.model.query.*; -import li.strolch.utils.collections.DateRange; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class InMemoryAuditQueryVisitor implements AuditQueryVisitor { - - private AuditTypeNavigator navigator; - private List selectors; - - public InMemoryAuditQuery toInMemory(AuditQuery auditQuery) { - AuditVisitor auditVisitor = auditQuery.getVisitor(); - DBC.PRE.assertNotNull("auditVisitor", auditVisitor); //$NON-NLS-1$ - - this.selectors = new ArrayList<>(); - auditQuery.accept(this); - - if (this.navigator == null) { - String msg = "Query is missing a navigation!"; //$NON-NLS-1$ - throw new QueryException(msg); - } - - long limit = auditQuery.getLimit(); - - return new InMemoryAuditQuery<>(this.navigator, limit, this.selectors, auditVisitor); - } - - @Override - public void visit(ElementSelection selection) { - this.selectors.add(AuditSelector.selectorFor(selection)); - } - - @Override - public void visit(IdentitySelection selection) { - this.selectors.add(AuditSelector.selectorFor(selection)); - } - - @Override - public void visit(ActionSelection selection) { - this.selectors.add(AuditSelector.selectorFor(selection)); - } - - @Override - public void visit(AuditQuery auditQuery) { - String type = auditQuery.getElementTypeSelection(); - DateRange dateRange = auditQuery.getDateRange(); - this.navigator = new AuditTypeNavigator(type, dateRange); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryOrderQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryOrderQueryVisitor.java deleted file mode 100644 index 133189e45..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryOrderQueryVisitor.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.model.Order; -import li.strolch.model.query.DateSelection; -import li.strolch.model.query.OrderQuery; -import li.strolch.model.query.OrderQueryVisitor; -import li.strolch.model.query.OrderStateSelection; -import li.strolch.model.query.StrolchTypeNavigation; -import li.strolch.model.visitor.OrderVisitor; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class InMemoryOrderQueryVisitor extends InMemoryQueryVisitor implements OrderQueryVisitor { - - public InMemoryOrderQueryVisitor() { - super(); - } - - @Override - protected InMemoryQueryVisitor newInstance() { - return new InMemoryOrderQueryVisitor(); - } - - public InMemoryQuery visit(OrderQuery orderQuery) { - OrderVisitor orderVisitor = orderQuery.getVisitor(); - DBC.PRE.assertNotNull("OrderVisitor may not be null!", orderVisitor); //$NON-NLS-1$ - - orderQuery.accept(this); - - Navigator navigator = getNavigator(); - if (navigator == null) { - String msg = "Query is missing a navigation!"; //$NON-NLS-1$ - throw new QueryException(msg); - } - - List> selectors = getSelectors(); - if (selectors.isEmpty()) - return new InMemoryQuery<>(navigator, null, orderVisitor, getComparator()); - - DBC.PRE.assertTrue("Invalid query as it may only contain one selector!", selectors.size() == 1); //$NON-NLS-1$ - return new InMemoryQuery<>(navigator, selectors.get(0), orderVisitor, getComparator()); - } - - @Override - public void visit(StrolchTypeNavigation navigation) { - setNavigator(new OrderTypeNavigator(navigation.getType())); - } - - @Override - public void visit(DateSelection selection) { - addSelector(new DateSelector(selection.getDateRange())); - } - - @Override - public void visit(OrderStateSelection selection) { - addSelector(new OrderStateSelector(selection.getState())); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryQuery.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryQuery.java deleted file mode 100644 index 3348bd0d1..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryQuery.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import li.strolch.agent.api.ElementMap; -import li.strolch.model.StrolchRootElement; -import li.strolch.model.visitor.StrolchElementVisitor; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class InMemoryQuery { - - private Navigator navigator; - private Selector selector; - private StrolchElementVisitor elementVisitor; - private Comparator comparator; - - public InMemoryQuery(Navigator navigator, Selector selector, StrolchElementVisitor elementVisitor, - Comparator comparator) { - this.navigator = navigator; - this.selector = selector; - this.elementVisitor = elementVisitor; - this.comparator = comparator; - } - - /** - * @param navigator - * the navigator to set - */ - public void setNavigator(Navigator navigator) { - this.navigator = navigator; - } - - /** - * @param selector - * the selector to set - */ - public void setSelector(Selector selector) { - this.selector = selector; - } - - /** - * @param elementVisitor - * the elementVisitor to set - */ - public void setElementVisitor(StrolchElementVisitor elementVisitor) { - this.elementVisitor = elementVisitor; - } - - public List doQuery(StrolchTransaction tx, ElementMap elementMap) { - - if (this.selector == null) - return Collections.emptyList(); - - Stream elements = this.navigator.navigate(tx, elementMap); - if (this.comparator != null) - elements = elements.sorted(this.comparator); - - return elements.filter(element -> this.selector.select(element)).map(element -> { - U returnValue = element.accept(this.elementVisitor); - DBC.INTERIM.assertNotNull("Visitor may not return null in query!", returnValue); //$NON-NLS-1$ - - if (returnValue instanceof StrolchRootElement) { - @SuppressWarnings("unchecked") - U ret = (U) ((StrolchRootElement) returnValue).getClone(true); - returnValue = ret; - } - return returnValue; - }).collect(Collectors.toList()); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryQueryVisitor.java deleted file mode 100644 index 4723243b5..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryQueryVisitor.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import li.strolch.model.StrolchRootElement; -import li.strolch.model.query.AndSelection; -import li.strolch.model.query.BooleanSelection; -import li.strolch.model.query.IdSelection; -import li.strolch.model.query.NameSelection; -import li.strolch.model.query.NotSelection; -import li.strolch.model.query.OrSelection; -import li.strolch.model.query.ParameterBagSelection; -import li.strolch.model.query.ParameterBagSelection.NullParameterBagSelection; -import li.strolch.model.query.ParameterSelection.AnyTypeParameterSelection; -import li.strolch.model.query.ParameterSelection.BooleanParameterSelection; -import li.strolch.model.query.ParameterSelection.DateParameterSelection; -import li.strolch.model.query.ParameterSelection.DateRangeParameterSelection; -import li.strolch.model.query.ParameterSelection.DurationParameterSelection; -import li.strolch.model.query.ParameterSelection.FloatListParameterSelection; -import li.strolch.model.query.ParameterSelection.FloatParameterSelection; -import li.strolch.model.query.ParameterSelection.IntegerListParameterSelection; -import li.strolch.model.query.ParameterSelection.IntegerParameterSelection; -import li.strolch.model.query.ParameterSelection.LongListParameterSelection; -import li.strolch.model.query.ParameterSelection.LongParameterSelection; -import li.strolch.model.query.ParameterSelection.NullParameterSelection; -import li.strolch.model.query.ParameterSelection.StringListParameterSelection; -import li.strolch.model.query.ParameterSelection.StringParameterSelection; -import li.strolch.model.query.ParameterSelectionVisitor; -import li.strolch.model.query.Selection; -import li.strolch.model.query.StrolchRootElementSelectionVisitor; -import li.strolch.model.query.ordering.OrderById; -import li.strolch.model.query.ordering.OrderByName; -import li.strolch.model.query.ordering.OrderByParameter; -import li.strolch.model.query.ordering.StrolchQueryOrderingVisitor; -import li.strolch.runtime.query.inmemory.ParameterBagSelector.NullParameterBagSelector; -import li.strolch.runtime.query.inmemory.ParameterSelector.StringParameterSelector; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public abstract class InMemoryQueryVisitor - implements StrolchRootElementSelectionVisitor, ParameterSelectionVisitor, StrolchQueryOrderingVisitor { - - private Navigator navigator; - private Comparator comparator; - private List> selectors; - private boolean any; - - public InMemoryQueryVisitor() { - this.selectors = new ArrayList<>(); - } - - public List> getSelectors() { - return Collections.unmodifiableList(this.selectors); - } - - public Navigator getNavigator() { - return this.navigator; - } - - public Comparator getComparator() { - return this.comparator; - } - - /** - * @param navigator - */ - protected void setNavigator(StrolchTypeNavigator navigator) { - this.navigator = navigator; - } - - /** - * Returns a new instance of this concrete type for performing recursive {@link BooleanSelection BooleanSelections} - * - * @return a new instance of this concrete type - */ - protected abstract InMemoryQueryVisitor newInstance(); - - private void assertNotAny() { - DBC.INTERIM.assertFalse("Not allowed to use further Selections with Any!", this.any); //$NON-NLS-1$ - } - - protected void addSelector(Selector selector) { - assertNotAny(); - this.selectors.add(selector); - } - - @Override - public void visitAny() { - DBC.PRE.assertEmpty("Only one selection allowed when using Any!", this.selectors); //$NON-NLS-1$ - addSelector(new AnySelector()); - this.any = true; - } - - @Override - public void visitAnd(AndSelection andSelection) { - assertNotAny(); - InMemoryQueryVisitor query = newInstance(); - List selections = andSelection.getSelections(); - for (Selection selection : selections) { - selection.accept(query); - } - AndSelector andSelector = new AndSelector<>(query.getSelectors()); - addSelector(andSelector); - } - - @Override - public void visitOr(OrSelection orSelection) { - assertNotAny(); - InMemoryQueryVisitor query = newInstance(); - List selections = orSelection.getSelections(); - for (Selection selection : selections) { - selection.accept(query); - } - OrSelector orSelector = new OrSelector<>(query.getSelectors()); - addSelector(orSelector); - } - - @Override - public void visitNot(NotSelection notSelection) { - assertNotAny(); - InMemoryQueryVisitor query = newInstance(); - List selections = notSelection.getSelections(); - for (Selection selection : selections) { - selection.accept(query); - } - List> notSelectors = query.getSelectors(); - if (!notSelectors.isEmpty()) { - NotSelector notSelector = new NotSelector<>(notSelectors.get(0)); - addSelector(notSelector); - } - } - - @Override - public void visit(IdSelection selection) { - addSelector(new IdSelector(selection.getIds(), selection.getMatchMode())); - } - - @Override - public void visit(NameSelection selection) { - addSelector(new NameSelector(selection.getName(), selection.getMatchMode())); - } - - @Override - public void visit(StringParameterSelection selection) { - StringParameterSelector stringSelector = // - ParameterSelector. stringSelector( // - selection.getBagKey(), // - selection.getParamKey(), // - selection.getValue(), // - selection.getMatchMode()); - - addSelector(stringSelector); - } - - @Override - public void visit(IntegerParameterSelection selection) { - addSelector(ParameterSelector. integerSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(BooleanParameterSelection selection) { - addSelector(ParameterSelector. booleanSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(LongParameterSelection selection) { - addSelector(ParameterSelector. longSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(FloatParameterSelection selection) { - addSelector(ParameterSelector. floatSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(DateParameterSelection selection) { - addSelector(ParameterSelector. dateSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(DurationParameterSelection selection) { - addSelector(ParameterSelector. durationSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(DateRangeParameterSelection selection) { - addSelector(ParameterSelector. dateRangeSelector(selection.getBagKey(), selection.getParamKey(), - selection.getDateRange())); - } - - @Override - public void visit(StringListParameterSelection selection) { - addSelector(ParameterSelector. stringListSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(IntegerListParameterSelection selection) { - addSelector(ParameterSelector. integerListSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(FloatListParameterSelection selection) { - addSelector(ParameterSelector. floatListSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(LongListParameterSelection selection) { - addSelector(ParameterSelector. longListSelector(selection.getBagKey(), selection.getParamKey(), - selection.getValue())); - } - - @Override - public void visit(NullParameterSelection selection) { - addSelector(ParameterSelector. nullSelector(selection.getBagKey(), selection.getParamKey())); - } - - @Override - public void visit(NullParameterBagSelection selection) { - addSelector(new NullParameterBagSelector(selection.getBagKey())); - } - - @Override - public void visit(ParameterBagSelection selection) { - addSelector(new ParameterBagSelector(selection.getBagKey())); - } - - @Override - public void visit(AnyTypeParameterSelection selection) { - addSelector(ParameterSelector. anyTypeSelection(selection.getBagKey(), selection.getParamKey(), - selection.getValue(), selection.getMatchMode())); - } - - @Override - public InMemoryQueryVisitor visit(OrderById ordering) { - this.comparator = new InMemoryStrolchQueryOrderingVisitor().visit(ordering).getComparator(); - return this; - } - - @Override - public InMemoryQueryVisitor visit(OrderByName ordering) { - this.comparator = new InMemoryStrolchQueryOrderingVisitor().visit(ordering).getComparator(); - return this; - } - - @Override - public InMemoryQueryVisitor visit(OrderByParameter ordering) { - this.comparator = new InMemoryStrolchQueryOrderingVisitor().visit(ordering).getComparator(); - return this; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryResourceQueryVisitor.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryResourceQueryVisitor.java deleted file mode 100644 index 95d3aea38..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryResourceQueryVisitor.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.model.Resource; -import li.strolch.model.query.ResourceQuery; -import li.strolch.model.query.ResourceQueryVisitor; -import li.strolch.model.query.StrolchTypeNavigation; -import li.strolch.model.visitor.ResourceVisitor; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class InMemoryResourceQueryVisitor extends InMemoryQueryVisitor - implements ResourceQueryVisitor { - - public InMemoryResourceQueryVisitor() { - super(); - } - - @Override - protected InMemoryQueryVisitor newInstance() { - return new InMemoryResourceQueryVisitor(); - } - - public InMemoryQuery visit(ResourceQuery resourceQuery) { - ResourceVisitor resourceVisitor = resourceQuery.getVisitor(); - DBC.PRE.assertNotNull("ResourceVisitor may not be null!", resourceVisitor); //$NON-NLS-1$ - - resourceQuery.accept(this); - - Navigator navigator = getNavigator(); - if (navigator == null) { - String msg = "Query is missing a navigation!"; //$NON-NLS-1$ - throw new QueryException(msg); - } - - List> selectors = getSelectors(); - if (selectors.isEmpty()) - return new InMemoryQuery<>(navigator, null, resourceVisitor, getComparator()); - - DBC.INTERIM.assertTrue("Invalid query as it may only contain one selector!", selectors.size() == 1); //$NON-NLS-1$ - return new InMemoryQuery<>(navigator, selectors.get(0), resourceVisitor, getComparator()); - } - - @Override - public void visit(StrolchTypeNavigation navigation) { - setNavigator(new ResourceTypeNavigator(navigation.getType())); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryStrolchQueryOrderingVisitor.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryStrolchQueryOrderingVisitor.java deleted file mode 100644 index 6be3c5c89..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/InMemoryStrolchQueryOrderingVisitor.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.Comparator; - -import li.strolch.model.StrolchRootElement; -import li.strolch.model.query.ordering.ByIdComparator; -import li.strolch.model.query.ordering.ByNameComparator; -import li.strolch.model.query.ordering.ByParamComparator; -import li.strolch.model.query.ordering.OrderById; -import li.strolch.model.query.ordering.OrderByName; -import li.strolch.model.query.ordering.OrderByParameter; -import li.strolch.model.query.ordering.StrolchQueryOrderingVisitor; - -/** - * @author Robert von Burg - */ -public class InMemoryStrolchQueryOrderingVisitor implements StrolchQueryOrderingVisitor { - - private Comparator comparator; - - public Comparator getComparator() { - return this.comparator; - } - - @Override - public InMemoryStrolchQueryOrderingVisitor visit(OrderById ordering) { - this.comparator = new ByIdComparator<>(ordering.isAscending()); - return this; - } - - @Override - public InMemoryStrolchQueryOrderingVisitor visit(OrderByName ordering) { - this.comparator = new ByNameComparator<>(ordering.isAscending()); - return this; - } - - @Override - public InMemoryStrolchQueryOrderingVisitor visit(OrderByParameter ordering) { - this.comparator = new ByParamComparator<>(ordering.getBagKey(), ordering.getParamKey(), ordering.isAscending()); - return this; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/NameSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/NameSelector.java deleted file mode 100644 index 862982d71..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/NameSelector.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.StrolchElement; -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class NameSelector implements Selector { - - private StringMatchMode matchMode; - private String name; - - public NameSelector(String name, StringMatchMode matchMode) { - this.name = name; - this.matchMode = matchMode; - } - - @Override - public boolean select(T element) { - String name = element.getName(); - return this.matchMode.matches(name, this.name); - } - - /** - * @return the matchMode - */ - public StringMatchMode getMatchMode() { - return this.matchMode; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/Navigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/Navigator.java deleted file mode 100644 index 4fb3f0f81..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/Navigator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.stream.Stream; - -import li.strolch.agent.api.ElementMap; -import li.strolch.model.StrolchRootElement; -import li.strolch.persistence.api.StrolchTransaction; - -/** - * @author Robert von Burg - */ -public interface Navigator { - - public > Stream navigate(StrolchTransaction tx, U elementMap); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/NotSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/NotSelector.java deleted file mode 100644 index 0ab6b2bbf..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/NotSelector.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.StrolchElement; -import li.strolch.utils.dbc.DBC; - -/** - * @author Robert von Burg - */ -public class NotSelector extends BooleanSelector { - - /** - * @param selector - */ - NotSelector(Selector selector) { - super(selector); - } - - /** - * @throws UnsupportedOperationException - * because a {@link NotSelector} can only work on a single {@link Selector} - */ - @Override - public NotSelector with(Selector selector) { - throw new UnsupportedOperationException("NotSelector can only have a single Selector"); //$NON-NLS-1$ - } - - @Override - public boolean select(T element) { - if (this.selectors == null || this.selectors.isEmpty()) - return true; - DBC.PRE.assertTrue("Only one selector allowed!", this.selectors.size() == 1); //$NON-NLS-1$ - return !this.selectors.get(0).select(element); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrSelector.java deleted file mode 100644 index 40fd62555..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrSelector.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.List; - -import li.strolch.model.StrolchElement; - -/** - * @author Robert von Burg - */ -public class OrSelector extends BooleanSelector { - - public OrSelector() { - super(); - } - - public OrSelector(List> selectors) { - super(selectors); - } - - @Override - public OrSelector with(Selector selector) { - super.with(selector); - return this; - } - - @Override - public boolean select(T element) { - if (this.selectors == null || this.selectors.isEmpty()) - return true; - - for (Selector selector : this.selectors) { - if (selector.select(element)) - return true; - } - - return false; - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrderStateSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrderStateSelector.java deleted file mode 100644 index 1a329189d..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrderStateSelector.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.Order; -import li.strolch.model.State; - -/** - * @author Robert von Burg - */ -public class OrderStateSelector implements Selector { - - private State state; - - /** - * @param state - */ - public OrderStateSelector(State state) { - this.state = state; - } - - @Override - public boolean select(Order element) { - return this.state.equals(element.getState()); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrderTypeNavigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrderTypeNavigator.java deleted file mode 100644 index 38e908a3b..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/OrderTypeNavigator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.stream.Stream; - -import li.strolch.agent.api.ElementMap; -import li.strolch.model.Order; -import li.strolch.persistence.api.StrolchTransaction; - -/** - * @author Robert von Burg - */ -public class OrderTypeNavigator extends StrolchTypeNavigator { - - public OrderTypeNavigator(String type) { - super(type); - } - - @Override - public > Stream navigate(StrolchTransaction tx, U elementMap) { - return tx.streamOrders(this.type); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ParameterBagSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ParameterBagSelector.java deleted file mode 100644 index fb0321472..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ParameterBagSelector.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.StrolchRootElement; - -/** - * @author Robert von Burg - */ -public class ParameterBagSelector implements Selector { - - protected String bagKey; - - public ParameterBagSelector(String bagKey) { - this.bagKey = bagKey; - } - - @Override - public boolean select(T element) { - return element.hasParameterBag(this.bagKey); - } - - public static class NullParameterBagSelector extends ParameterBagSelector { - - public NullParameterBagSelector(String bagKey) { - super(bagKey); - } - - @Override - public boolean select(T element) { - return !element.hasParameterBag(this.bagKey); - } - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java deleted file mode 100644 index 1a9903c64..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ParameterSelector.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.Date; -import java.util.List; - -import li.strolch.model.ParameterBag; -import li.strolch.model.ParameterBagContainer; -import li.strolch.model.parameter.BooleanParameter; -import li.strolch.model.parameter.DateParameter; -import li.strolch.model.parameter.DurationParameter; -import li.strolch.model.parameter.FloatParameter; -import li.strolch.model.parameter.IntegerParameter; -import li.strolch.model.parameter.ListParameter; -import li.strolch.model.parameter.LongParameter; -import li.strolch.model.parameter.Parameter; -import li.strolch.model.parameter.StringParameter; -import li.strolch.utils.StringMatchMode; -import li.strolch.utils.collections.DateRange; - -/** - * @author Robert von Burg - */ -public abstract class ParameterSelector implements Selector { - - protected String bagKey; - protected String paramKey; - - public ParameterSelector(String bagKey, String key) { - this.bagKey = bagKey; - this.paramKey = key; - } - - @Override - public abstract boolean select(ParameterBagContainer element); - - public static StringParameterSelector stringSelector(String bagKey, - String paramKey, String value, StringMatchMode matchMode) { - return new StringParameterSelector<>(bagKey, paramKey, value, matchMode); - } - - public static IntegerParameterSelector integerSelector(String bagKey, - String paramKey, int value) { - return new IntegerParameterSelector<>(bagKey, paramKey, value); - } - - public static BooleanParameterSelector booleanSelector(String bagKey, - String paramKey, boolean value) { - return new BooleanParameterSelector<>(bagKey, paramKey, value); - } - - public static FloatParameterSelector floatSelector(String bagKey, - String paramKey, double value) { - return new FloatParameterSelector<>(bagKey, paramKey, value); - } - - public static LongParameterSelector longSelector(String bagKey, - String paramKey, long value) { - return new LongParameterSelector<>(bagKey, paramKey, value); - } - - public static DateParameterSelector dateSelector(String bagKey, - String paramKey, Date value) { - return new DateParameterSelector<>(bagKey, paramKey, value); - } - - public static DurationParameterSelector durationSelector(String bagKey, - String paramKey, Long value) { - return new DurationParameterSelector<>(bagKey, paramKey, value); - } - - public static DateRangeParameterSelector dateRangeSelector(String bagKey, - String paramKey, DateRange dateRange) { - return new DateRangeParameterSelector<>(bagKey, paramKey, dateRange); - } - - public static StringListParameterSelector stringListSelector(String bagKey, - String paramKey, List value) { - return new StringListParameterSelector<>(bagKey, paramKey, value); - } - - public static IntegerListParameterSelector integerListSelector(String bagKey, - String paramKey, List value) { - return new IntegerListParameterSelector<>(bagKey, paramKey, value); - } - - public static FloatListParameterSelector floatListSelector(String bagKey, - String paramKey, List value) { - return new FloatListParameterSelector<>(bagKey, paramKey, value); - } - - public static LongListParameterSelector longListSelector(String bagKey, - String paramKey, List value) { - return new LongListParameterSelector<>(bagKey, paramKey, value); - } - - public static NullParameterSelector nullSelector(String bagKey, - String paramKey) { - return new NullParameterSelector<>(bagKey, paramKey); - } - - public static AnyTypeParameterSelector anyTypeSelection(String bagKey, - String paramKey, String value, StringMatchMode matchMode) { - return new AnyTypeParameterSelector<>(bagKey, paramKey, value, matchMode); - } - - public static class AnyTypeParameterSelector extends ParameterSelector { - - private StringMatchMode matchMode; - private String value; - - public AnyTypeParameterSelector(String bagKey, String key, String value, StringMatchMode matchMode) { - super(bagKey, key); - this.value = value; - this.matchMode = matchMode; - } - - @Override - public boolean select(ParameterBagContainer element) { - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (bag == null) { - return false; - } - - Parameter parameter = bag.getParameter(this.paramKey); - if (parameter == null) - return false; - - String valueAsString = parameter.getValueAsString(); - return this.matchMode.matches(valueAsString, this.value); - } - } - - public static class NullParameterSelector extends ParameterSelector { - - public NullParameterSelector(String bagKey, String key) { - super(bagKey, key); - } - - @Override - public boolean select(ParameterBagContainer element) { - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (bag == null) { - return false; - } - - return !bag.hasParameter(this.paramKey); - } - } - - public static class StringParameterSelector extends ParameterSelector { - - private StringMatchMode matchMode; - private String value; - - public StringParameterSelector(String bagKey, String paramKey, String value, StringMatchMode matchMode) { - super(bagKey, paramKey); - this.value = value; - this.matchMode = matchMode; - } - - public StringMatchMode getMatchMode() { - return this.matchMode; - } - - @Override - public boolean select(ParameterBagContainer element) { - - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - StringParameter param = bag.getParameter(this.paramKey); - String paramValue = param.getValue(); - - return this.matchMode.matches(paramValue, this.value); - } - } - - public static class IntegerParameterSelector extends ParameterSelector { - - private Integer value; - - public IntegerParameterSelector(String bagKey, String paramKey, Integer value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - IntegerParameter param = bag.getParameter(this.paramKey); - return param.getValue().equals(this.value); - } - } - - public static class BooleanParameterSelector extends ParameterSelector { - - private Boolean value; - - public BooleanParameterSelector(String bagKey, String paramKey, Boolean value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - BooleanParameter param = bag.getParameter(this.paramKey); - return param.getValue().equals(this.value); - } - } - - public static class FloatParameterSelector extends ParameterSelector { - - private Double value; - - public FloatParameterSelector(String bagKey, String paramKey, Double value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - FloatParameter param = bag.getParameter(this.paramKey); - return param.getValue().equals(this.value); - } - } - - public static class LongParameterSelector extends ParameterSelector { - - private Long value; - - public LongParameterSelector(String bagKey, String paramKey, Long value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - LongParameter param = bag.getParameter(this.paramKey); - return param.getValue().equals(this.value); - } - } - - public static class DateParameterSelector extends ParameterSelector { - - private Date value; - - public DateParameterSelector(String bagKey, String paramKey, Date value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - DateParameter param = bag.getParameter(this.paramKey); - return param.getValue().equals(this.value); - } - } - - public static class DateRangeParameterSelector extends ParameterSelector { - - private DateRange dateRange; - - public DateRangeParameterSelector(String bagKey, String paramKey, DateRange dateRange) { - super(bagKey, paramKey); - this.dateRange = dateRange; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - DateParameter param = bag.getParameter(this.paramKey); - Date value = param.getValue(); - - return this.dateRange.contains(value); - } - } - - public static class DurationParameterSelector extends ParameterSelector { - - private Long value; - - public DurationParameterSelector(String bagKey, String paramKey, Long value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - DurationParameter param = bag.getParameter(this.paramKey); - return param.getValue().equals(this.value); - } - } - - public static abstract class AbstractListParameterSelector - extends ParameterSelector { - - private List value; - - public AbstractListParameterSelector(String bagKey, String paramKey, List value) { - super(bagKey, paramKey); - this.value = value; - } - - @Override - public boolean select(ParameterBagContainer element) { - if (!element.hasParameterBag(this.bagKey)) - return false; - - ParameterBag bag = element.getParameterBag(this.bagKey); - if (!bag.hasParameter(this.paramKey)) - return false; - - ListParameter param = bag.getParameter(this.paramKey); - return param.getValue().containsAll(this.value); - } - } - - public static class StringListParameterSelector - extends AbstractListParameterSelector { - - public StringListParameterSelector(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - } - - public static class IntegerListParameterSelector - extends AbstractListParameterSelector { - - public IntegerListParameterSelector(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - } - - public static class FloatListParameterSelector - extends AbstractListParameterSelector { - - public FloatListParameterSelector(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - } - - public static class LongListParameterSelector - extends AbstractListParameterSelector { - - public LongListParameterSelector(String bagKey, String paramKey, List value) { - super(bagKey, paramKey, value); - } - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/QueryException.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/QueryException.java deleted file mode 100644 index 6bcc957c2..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/QueryException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.exception.StrolchException; - -/** - * @author Robert von Burg - * - */ -public class QueryException extends StrolchException { - - - - public QueryException(String message, Throwable cause) { - super(message, cause); - } - - public QueryException(String message) { - super(message); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ResourceTypeNavigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ResourceTypeNavigator.java deleted file mode 100644 index 1536d1793..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/ResourceTypeNavigator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import java.util.stream.Stream; - -import li.strolch.agent.api.ElementMap; -import li.strolch.model.Resource; -import li.strolch.persistence.api.StrolchTransaction; - -/** - * @author Robert von Burg - */ -public class ResourceTypeNavigator extends StrolchTypeNavigator { - - public ResourceTypeNavigator(String type) { - super(type); - } - - @Override - public > Stream navigate(StrolchTransaction tx, U elementMap) { - return tx.streamResources(this.type); - } -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/Selector.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/Selector.java deleted file mode 100644 index 5635a0899..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/Selector.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.StrolchElement; - -/** - * @author Robert von Burg - * - */ -public interface Selector { - - public boolean select(T element); -} diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/StrolchTypeNavigator.java b/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/StrolchTypeNavigator.java deleted file mode 100644 index bf3796c6e..000000000 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/query/inmemory/StrolchTypeNavigator.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import li.strolch.model.StrolchRootElement; - -/** - * @author Robert von Burg - */ -public abstract class StrolchTypeNavigator implements Navigator { - - protected String type; - - public StrolchTypeNavigator(String type) { - this.type = type; - } - - public String getType() { - return this.type; - } -} diff --git a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/AuditQueryTest.java b/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/AuditQueryTest.java deleted file mode 100644 index a925d2d2a..000000000 --- a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/AuditQueryTest.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import static li.strolch.agent.ComponentContainerTest.PATH_REALM_CONTAINER; -import static org.junit.Assert.assertEquals; - -import java.sql.SQLException; -import java.util.*; - -import li.strolch.RuntimeMock; -import li.strolch.agent.api.StrolchAgent; -import li.strolch.model.ModelGenerator; -import li.strolch.model.Tags; -import li.strolch.model.audit.AccessType; -import li.strolch.model.audit.Audit; -import li.strolch.model.audit.AuditVisitor; -import li.strolch.model.audit.NoStrategyAuditVisitor; -import li.strolch.model.query.AuditQuery; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.privilege.model.Certificate; -import li.strolch.runtime.StrolchConstants; -import li.strolch.runtime.privilege.PrivilegeHandler; -import li.strolch.utils.StringMatchMode; -import li.strolch.utils.collections.DateRange; -import org.junit.BeforeClass; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Robert von Burg - */ -@SuppressWarnings("nls") -public class AuditQueryTest { - - public static final String PATH_RUNTIME = "target/" + AuditQueryTest.class.getSimpleName(); - - private static Date past; - private static Date earlier; - private static Date current; - private static Date later; - private static Date future; - - protected static final Logger logger = LoggerFactory.getLogger(AuditQueryTest.class); - - @BeforeClass - public static void beforeClass() throws SQLException { - - Calendar cal = Calendar.getInstance(); - cal.clear(); - cal.set(2000, 1, 1); - past = cal.getTime(); - cal.set(2000, 4, 1); - earlier = cal.getTime(); - cal.set(2000, 6, 1); - current = cal.getTime(); - cal.set(2000, 8, 1); - later = cal.getTime(); - cal.set(2000, 11, 1); - future = cal.getTime(); - } - - private static Certificate login(StrolchAgent agent) { - PrivilegeHandler privilegeHandler = agent.getContainer().getPrivilegeHandler(); - return privilegeHandler.authenticate("test", "test".toCharArray()); - } - - @Test - public void shouldQueryTypeAndDateRange() throws Exception { - try { - RuntimeMock.runInStrolch(PATH_RUNTIME, PATH_REALM_CONTAINER, agent -> { - - AuditVisitor visitor = new NoStrategyAuditVisitor(); - - AuditQuery query = new AuditQuery<>(visitor, Tags.AUDIT, - new DateRange().from(earlier, true).to(later, true)); - performQuery(agent, query, Arrays.asList(0L, 1L, 2L, 3L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(current, true).to(current, true)); - performQuery(agent, query, Arrays.asList(1L, 3L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(current, true)); - performQuery(agent, query, Arrays.asList(1L, 2L, 3L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().to(current, true)); - performQuery(agent, query, Arrays.asList(0L, 1L, 3L, 4L)); - - query = new AuditQuery<>(visitor, Tags.RESOURCE, new DateRange().from(past, true).to(future, true)); - performQuery(agent, query, Arrays.asList()); - - }); - - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw e; - } - } - - @Test - public void shouldQueryAudits() throws Exception { - try { - RuntimeMock.runInStrolch(PATH_RUNTIME, PATH_REALM_CONTAINER, agent -> { - - AuditVisitor visitor = new NoStrategyAuditVisitor(); - - AuditQuery query = new AuditQuery<>(visitor, Tags.AUDIT, - new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE, AccessType.READ); - performQuery(agent, query, Arrays.asList(0L, 1L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE); - performQuery(agent, query, Arrays.asList(0L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE, AccessType.READ) - .actions(StringMatchMode.EQUALS_CASE_SENSITIVE, "create", "read"); - performQuery(agent, query, Arrays.asList(0L, 1L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE, AccessType.READ) - .actions(StringMatchMode.EQUALS_CASE_SENSITIVE, "read"); - performQuery(agent, query, Arrays.asList(1L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementAccessed(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "crea"); - performQuery(agent, query, Arrays.asList(0L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementAccessed(StringMatchMode.CONTAINS_CASE_SENSITIVE, "crea"); - performQuery(agent, query, Arrays.asList()); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementAccessed(StringMatchMode.EQUALS_CASE_INSENSITIVE, "create"); - performQuery(agent, query, Arrays.asList(0L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier"); - performQuery(agent, query, Arrays.asList(0L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier", "later"); - performQuery(agent, query, Arrays.asList(0L, 2L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier") - .firstnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "enn"); - performQuery(agent, query, Arrays.asList(0L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier") - .firstnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "enn") - .lastnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "kennedy"); - performQuery(agent, query, Arrays.asList(0L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().firstnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "enn") - .lastnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "kennedy"); - performQuery(agent, query, Arrays.asList(0L, 1L, 2L, 3L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementSubTypes(StringMatchMode.EQUALS_CASE_SENSITIVE, "Foo"); - performQuery(agent, query, Arrays.asList(0L, 1L, 2L, 3L, 4L)); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementSubTypes(StringMatchMode.EQUALS_CASE_SENSITIVE, "Bar"); - performQuery(agent, query, Arrays.asList()); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.limit(1).element().elementSubTypes(StringMatchMode.EQUALS_CASE_SENSITIVE, "Foo"); - performQuery(agent, query, Arrays.asList(2L)); - - }); - - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw e; - } - } - - private void performQuery(StrolchAgent agent, AuditQuery query, List expected) throws SQLException { - - Certificate certificate = login(agent); - try (StrolchTransaction tx = agent.getContainer().getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - - tx.setSuppressAudits(true); - tx.getAuditTrail().addAll(tx, getAudits()); - - List result = tx.doQuery(query); - Set ids = new HashSet<>(); - for (Audit audit : result) { - ids.add(audit.getId()); - } - - assertEquals(new HashSet<>(expected), new HashSet<>(ids)); - } - } - - private static List getAudits() { - List audits = new ArrayList<>(); - int i = 0; - - Audit randomAudit; - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setUsername("earlier"); - randomAudit.setDate(earlier); - randomAudit.setAccessType(AccessType.CREATE); - randomAudit.setAction("create"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - audits.add(randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(current); - randomAudit.setUsername("current"); - randomAudit.setAccessType(AccessType.READ); - randomAudit.setAction("read"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - audits.add(randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(later); - randomAudit.setUsername("later"); - randomAudit.setAccessType(AccessType.UPDATE); - randomAudit.setAction("update"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - audits.add(randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(current); - randomAudit.setUsername("current"); - randomAudit.setAccessType(AccessType.DELETE); - randomAudit.setAction("delete"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - audits.add(randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(current); - randomAudit.setUsername("current"); - randomAudit.setAccessType(AccessType.CREATE); - randomAudit.setAction("create"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - audits.add(randomAudit); - - return audits; - } -} diff --git a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryActivityQueryTest.java b/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryActivityQueryTest.java deleted file mode 100644 index a6f75ba3b..000000000 --- a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryActivityQueryTest.java +++ /dev/null @@ -1,344 +0,0 @@ -package li.strolch.runtime.query.inmemory; - -import static java.util.Arrays.asList; -import static li.strolch.agent.ComponentContainerTest.PATH_EMPTY_CONTAINER; -import static li.strolch.model.query.ParameterSelection.*; -import static li.strolch.utils.StringMatchMode.ci; -import static li.strolch.utils.StringMatchMode.es; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import li.strolch.RuntimeMock; -import li.strolch.agent.api.StrolchAgent; -import li.strolch.model.ModelGenerator; -import li.strolch.model.ParameterBag; -import li.strolch.model.State; -import li.strolch.model.Version; -import li.strolch.model.activity.Action; -import li.strolch.model.activity.Activity; -import li.strolch.model.activity.TimeOrdering; -import li.strolch.model.parameter.*; -import li.strolch.model.query.*; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.privilege.model.Certificate; -import li.strolch.runtime.StrolchConstants; -import li.strolch.runtime.privilege.PrivilegeHandler; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class InMemoryActivityQueryTest { - - public static final String PATH_RUNTIME = "target/" + InMemoryActivityQueryTest.class.getSimpleName(); - private static RuntimeMock runtimeMock; - private static Certificate certificate; - - private static Certificate login(StrolchAgent agent) { - PrivilegeHandler privilegeHandler = agent.getContainer().getPrivilegeHandler(); - return privilegeHandler.authenticate("test", "test".toCharArray()); - } - - @BeforeClass - public static void beforeClass() { - runtimeMock = new RuntimeMock(PATH_RUNTIME, PATH_EMPTY_CONTAINER); - runtimeMock.mockRuntime(); - runtimeMock.startContainer(); - - certificate = login(runtimeMock.getAgent()); - - try (StrolchTransaction tx = openTx(false)) { - getActivities().forEach(tx::add); - tx.add(getBallActivity()); - tx.commitOnClose(); - } - } - - private static StrolchTransaction openTx(boolean readOnly) { - return runtimeMock.getAgent().getContainer().getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", readOnly); - } - - @AfterClass - public static void afterClass() { - if (runtimeMock != null) - runtimeMock.close(); - } - - @Test - public void shouldQueryById() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery activityQuery = ActivityQuery.query("MyType1"); - activityQuery.with(new IdSelection("@1")); - - List result = tx.doQuery(activityQuery); - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - } - } - - @Test - public void shouldQueryByIdOr() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery activityQuery = ActivityQuery.query("MyType2"); - activityQuery.or().with(new IdSelection("@3"), new IdSelection("@4")); - - List result = tx.doQuery(activityQuery); - assertEquals(2, result.size()); - assertEquals("@3", result.get(0).getId()); - assertEquals("@4", result.get(1).getId()); - } - } - - @Test - public void shouldQueryByIdAnd() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery activityQuery = ActivityQuery.query("MyType2"); - activityQuery.and().with(new IdSelection("@3"), new NameSelection("Activity 3", es())); - - List result = tx.doQuery(activityQuery); - assertEquals(1, result.size()); - assertEquals("@3", result.get(0).getId()); - } - } - - @Test - public void shouldNotQueryByIdAnd() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery activityQuery = ActivityQuery.query("MyType1"); - activityQuery.and().with(new IdSelection("@3"), new NameSelection("@4", es())); - - List result = tx.doQuery(activityQuery); - assertEquals(0, result.size()); - } - } - - @Test - public void shouldQueryByParameter() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with( - // - stringSelection("parameters", "color", "red", es()), - booleanSelection("parameters", "forChildren", true), - floatSelection("parameters", "diameter", 22.0)); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByListParameter() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery; - List result; - - // string list - { - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("a", "z"))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("a"))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("c", "b", "a"))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // integer list - { - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(1, 5))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(1))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(3, 2, 1))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // float list - { - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(4.0, 8.0))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(4.0))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(6.2, 5.1, 4.0))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // long list - { - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(8L, 11L))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(8L))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(10L, 9L, 8L))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - } - - @Test - public void shouldQueryByNullParameter1() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "color")); - - List result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - } - } - - @Test - public void shouldQueryByNullParameter2() { - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "weight")); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByNullParameter3() { - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery = ActivityQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "weight")); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByName() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery = ActivityQuery.query("Ball"); - ballQuery.with(new NameSelection("ball ", ci())); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByState() { - - try (StrolchTransaction tx = openTx(true)) { - - ActivityQuery ballQuery = ActivityQuery.query("MyType1"); - ballQuery.with(new ActivityStateSelection(State.STOPPED)); - - List result = tx.doQuery(ballQuery); - assertEquals(2, result.size()); - - ballQuery = ActivityQuery.query("MyType2"); - ballQuery.with(new ActivityStateSelection(State.STOPPED)); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - private static Activity getBallActivity() { - Activity res1 = new Activity("childrensBall", "Ball 1", "Ball", TimeOrdering.SERIES); - Version.setInitialVersionFor(res1, "test"); - ParameterBag bag = new ParameterBag("parameters", "Ball Details", "Parameters"); - bag.addParameter(new StringParameter("color", "Color", "red")); - bag.addParameter(new BooleanParameter("forChildren", "Color", true)); - bag.addParameter(new FloatParameter("diameter", "Color", 22.0)); - bag.addParameter(new StringListParameter("stringListValues", "List of String Values", asList("a", "b", "c"))); - bag.addParameter(new IntegerListParameter("intListValues", "List of Integer Values", asList(1, 2, 3))); - bag.addParameter(new FloatListParameter("floatListValues", "List of Float Values", asList(4.0, 5.1, 6.2))); - bag.addParameter(new LongListParameter("longListValues", "List of Long Values", asList(8L, 9L, 10L))); - res1.addParameterBag(bag); - return res1; - } - - private static List getActivities() { - - Activity activity1 = ModelGenerator.createActivity("@1", "Activity 1", "MyType1", TimeOrdering.SERIES); - ((Action) activity1.getElement("action_" + activity1.getId())).setState(State.STOPPED); - - Activity activity2 = ModelGenerator.createActivity("@2", "Activity 2", "MyType1", TimeOrdering.SERIES); - ((Action) activity2.getElement("action_" + activity2.getId())).setState(State.STOPPED); - - Activity activity3 = ModelGenerator.createActivity("@3", "Activity 3", "MyType2", TimeOrdering.SERIES); - ((Action) activity3.getElement("action_" + activity3.getId())).setState(State.STOPPED); - - Activity activity4 = ModelGenerator.createActivity("@4", "Activity 4", "MyType2", TimeOrdering.SERIES); - ((Action) activity4.getElement("action_" + activity4.getId())).setState(State.PLANNING); - - Activity activity5 = ModelGenerator.createActivity("@5", "Activity 5", "MyType3", TimeOrdering.SERIES); - ((Action) activity5.getElement("action_" + activity5.getId())).setState(State.ERROR); - - Activity activity6 = ModelGenerator.createActivity("@6", "Activity 6", "MyType3", TimeOrdering.SERIES); - ((Action) activity6.getElement("action_" + activity6.getId())).setState(State.CLOSED); - - List activities = new ArrayList<>(); - activities.add(activity1); - activities.add(activity2); - activities.add(activity3); - activities.add(activity4); - activities.add(activity5); - activities.add(activity6); - - for (Activity activity : activities) { - Version.setInitialVersionFor(activity, "test"); - } - - return activities; - } -} diff --git a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryOrderQueryTest.java b/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryOrderQueryTest.java deleted file mode 100644 index ca2ab5fdd..000000000 --- a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryOrderQueryTest.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import static java.util.Arrays.asList; -import static li.strolch.agent.ComponentContainerTest.PATH_EMPTY_CONTAINER; -import static li.strolch.model.query.ParameterSelection.*; -import static li.strolch.utils.StringMatchMode.ci; -import static li.strolch.utils.StringMatchMode.es; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import li.strolch.RuntimeMock; -import li.strolch.agent.api.StrolchAgent; -import li.strolch.model.*; -import li.strolch.model.parameter.*; -import li.strolch.model.query.*; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.privilege.model.Certificate; -import li.strolch.runtime.StrolchConstants; -import li.strolch.runtime.privilege.PrivilegeHandler; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * @author Robert von Burg - */ -@SuppressWarnings("nls") -public class InMemoryOrderQueryTest { - - public static final String PATH_RUNTIME = "target/" + InMemoryOrderQueryTest.class.getSimpleName(); - private static RuntimeMock runtimeMock; - private static Certificate certificate; - - private static Certificate login(StrolchAgent agent) { - PrivilegeHandler privilegeHandler = agent.getContainer().getPrivilegeHandler(); - return privilegeHandler.authenticate("test", "test".toCharArray()); - } - - @BeforeClass - public static void beforeClass() { - runtimeMock = new RuntimeMock(PATH_RUNTIME, PATH_EMPTY_CONTAINER); - runtimeMock.mockRuntime(); - runtimeMock.startContainer(); - - certificate = login(runtimeMock.getAgent()); - - try (StrolchTransaction tx = openTx(false)) { - getOrders().forEach(tx::add); - tx.add(getBallOrder()); - tx.commitOnClose(); - } - } - - private static StrolchTransaction openTx(boolean readOnly) { - return runtimeMock.getAgent().getContainer().getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", readOnly); - } - - @AfterClass - public static void afterClass() { - if (runtimeMock != null) - runtimeMock.close(); - } - - @Test - public void shouldQueryById() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery orderQuery = OrderQuery.query("MyType1"); - orderQuery.with(new IdSelection("@1")); - - List result = tx.doQuery(orderQuery); - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - } - } - - @Test - public void shouldQueryByIdOr() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery orderQuery = OrderQuery.query("MyType2"); - orderQuery.or().with(new IdSelection("@3"), new IdSelection("@4")); - - List result = tx.doQuery(orderQuery); - assertEquals(2, result.size()); - assertEquals("@3", result.get(0).getId()); - assertEquals("@4", result.get(1).getId()); - } - } - - @Test - public void shouldQueryByIdAnd() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery orderQuery = OrderQuery.query("MyType2"); - orderQuery.and().with(new IdSelection("@3"), new NameSelection("Order 3", es())); - - List result = tx.doQuery(orderQuery); - assertEquals(1, result.size()); - assertEquals("@3", result.get(0).getId()); - } - } - - @Test - public void shouldNotQueryByIdAnd() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery orderQuery = OrderQuery.query("MyType1"); - orderQuery.and().with(new IdSelection("@3"), new NameSelection("@4", es())); - - List result = tx.doQuery(orderQuery); - assertEquals(0, result.size()); - } - } - - @Test - public void shouldQueryByParameter() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with( - // - stringSelection("parameters", "color", "red", es()), - booleanSelection("parameters", "forChildren", true), - floatSelection("parameters", "diameter", 22.0)); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByListParameter() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery; - List result; - - // string list - { - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("a", "z"))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("a"))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("c", "b", "a"))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // integer list - { - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(1, 5))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(1))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(3, 2, 1))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // float list - { - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(4.0, 8.0))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(4.0))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(6.2, 5.1, 4.0))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // long list - { - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(8L, 11L))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(8L))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(10L, 9L, 8L))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - } - - @Test - public void shouldQueryByNullParameter1() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "color")); - - List result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - } - } - - @Test - public void shouldQueryByNullParameter2() { - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "weight")); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByNullParameter3() { - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery = OrderQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "weight")); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByName() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery = OrderQuery.query("Ball"); - ballQuery.with(new NameSelection("ball ", ci())); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByState() { - - try (StrolchTransaction tx = openTx(true)) { - - OrderQuery ballQuery = OrderQuery.query("MyType1"); - ballQuery.with(new OrderStateSelection(State.STOPPED)); - - List result = tx.doQuery(ballQuery); - assertEquals(2, result.size()); - - ballQuery = OrderQuery.query("MyType2"); - ballQuery.with(new OrderStateSelection(State.STOPPED)); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - private static Order getBallOrder() { - Order o1 = new Order("childrensBall", "Ball 1", "Ball"); - Version.setInitialVersionFor(o1, "test"); - ParameterBag bag = new ParameterBag("parameters", "Ball Details", "Parameters"); - bag.addParameter(new StringParameter("color", "Color", "red")); - bag.addParameter(new BooleanParameter("forChildren", "Color", true)); - bag.addParameter(new FloatParameter("diameter", "Color", 22.0)); - bag.addParameter(new StringListParameter("stringListValues", "List of String Values", asList("a", "b", "c"))); - bag.addParameter(new IntegerListParameter("intListValues", "List of Integer Values", asList(1, 2, 3))); - bag.addParameter(new FloatListParameter("floatListValues", "List of Float Values", asList(4.0, 5.1, 6.2))); - bag.addParameter(new LongListParameter("longListValues", "List of Long Values", asList(8L, 9L, 10L))); - o1.addParameterBag(bag); - return o1; - } - - private static List getOrders() { - Order res1 = ModelGenerator.createOrder("@1", "Order 1", "MyType1", new Date(), State.STOPPED); - Order res2 = ModelGenerator.createOrder("@2", "Order 2", "MyType1", new Date(), State.STOPPED); - Order res3 = ModelGenerator.createOrder("@3", "Order 3", "MyType2", new Date(), State.STOPPED); - Order res4 = ModelGenerator.createOrder("@4", "Order 4", "MyType2", new Date(), State.PLANNING); - Order res5 = ModelGenerator.createOrder("@5", "Order 5", "MyType3", new Date(), State.ERROR); - Order res6 = ModelGenerator.createOrder("@6", "Order 6", "MyType3", new Date(), State.CLOSED); - List orders = new ArrayList<>(); - orders.add(res1); - orders.add(res2); - orders.add(res3); - orders.add(res4); - orders.add(res5); - orders.add(res6); - - for (Order order : orders) { - Version.setInitialVersionFor(order, "test"); - } - return orders; - } -} diff --git a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryResourceQueryTest.java b/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryResourceQueryTest.java deleted file mode 100644 index 1735e0b47..000000000 --- a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/InMemoryResourceQueryTest.java +++ /dev/null @@ -1,315 +0,0 @@ -package li.strolch.runtime.query.inmemory; - -import static java.util.Arrays.asList; -import static li.strolch.agent.ComponentContainerTest.PATH_EMPTY_CONTAINER; -import static li.strolch.model.query.ParameterSelection.*; -import static li.strolch.utils.StringMatchMode.ci; -import static li.strolch.utils.StringMatchMode.es; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import li.strolch.RuntimeMock; -import li.strolch.agent.api.StrolchAgent; -import li.strolch.model.ModelGenerator; -import li.strolch.model.ParameterBag; -import li.strolch.model.Resource; -import li.strolch.model.Version; -import li.strolch.model.parameter.*; -import li.strolch.model.query.IdSelection; -import li.strolch.model.query.NameSelection; -import li.strolch.model.query.ParameterSelection; -import li.strolch.model.query.ResourceQuery; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.privilege.model.Certificate; -import li.strolch.runtime.StrolchConstants; -import li.strolch.runtime.privilege.PrivilegeHandler; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class InMemoryResourceQueryTest { - - public static final String PATH_RUNTIME = "target/" + InMemoryResourceQueryTest.class.getSimpleName(); - private static RuntimeMock runtimeMock; - private static Certificate certificate; - - private static Certificate login(StrolchAgent agent) { - PrivilegeHandler privilegeHandler = agent.getContainer().getPrivilegeHandler(); - return privilegeHandler.authenticate("test", "test".toCharArray()); - } - - @BeforeClass - public static void beforeClass() { - runtimeMock = new RuntimeMock(PATH_RUNTIME, PATH_EMPTY_CONTAINER); - runtimeMock.mockRuntime(); - runtimeMock.startContainer(); - - certificate = login(runtimeMock.getAgent()); - - try (StrolchTransaction tx = openTx(false)) { - getResources().forEach(tx::add); - tx.add(getBallResource()); - tx.commitOnClose(); - } - } - - private static StrolchTransaction openTx(boolean readOnly) { - return runtimeMock.getAgent().getContainer().getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", readOnly); - } - - @AfterClass - public static void afterClass() { - if (runtimeMock != null) - runtimeMock.close(); - } - - @Test - public void shouldQueryById() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery resourceQuery = ResourceQuery.query("MyType1"); - resourceQuery.with(new IdSelection("@1")); - - List result = tx.doQuery(resourceQuery); - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - } - } - - @Test - public void shouldQueryByIdOr() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery resourceQuery = ResourceQuery.query("MyType2"); - resourceQuery.or().with(new IdSelection("@3"), new IdSelection("@4")); - - List result = tx.doQuery(resourceQuery); - assertEquals(2, result.size()); - assertEquals("@3", result.get(0).getId()); - assertEquals("@4", result.get(1).getId()); - } - } - - @Test - public void shouldQueryByIdAnd() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery resourceQuery = ResourceQuery.query("MyType2"); - resourceQuery.and().with(new IdSelection("@3"), new NameSelection("Res 3", es())); - - List result = tx.doQuery(resourceQuery); - assertEquals(1, result.size()); - assertEquals("@3", result.get(0).getId()); - } - } - - @Test - public void shouldNotQueryByIdAnd() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery resourceQuery = ResourceQuery.query("MyType1"); - resourceQuery.and().with(new IdSelection("@3"), new NameSelection("@4", es())); - - List result = tx.doQuery(resourceQuery); - assertEquals(0, result.size()); - } - } - - @Test - public void shouldQueryByParameter() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with( - // - stringSelection("parameters", "color", "red", es()), - booleanSelection("parameters", "forChildren", true), - floatSelection("parameters", "diameter", 22.0)); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByListParameter() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery ballQuery; - List result; - - // string list - { - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("a", "z"))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("a"))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(stringListSelection("parameters", "stringListValues", asList("c", "b", "a"))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // integer list - { - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(1, 5))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(1))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(integerListSelection("parameters", "intListValues", asList(3, 2, 1))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // float list - { - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(4.0, 8.0))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(4.0))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(floatListSelection("parameters", "floatListValues", asList(6.2, 5.1, 4.0))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - - // long list - { - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(8L, 11L))); - result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(8L))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - - ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with(longListSelection("parameters", "longListValues", asList(10L, 9L, 8L))); - result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - } - - @Test - public void shouldQueryByNullParameter1() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "color")); - - List result = tx.doQuery(ballQuery); - assertEquals(0, result.size()); - } - } - - @Test - public void shouldQueryByNullParameter2() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "weight")); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByNullParameter3() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery ballQuery = ResourceQuery.query("Ball"); - ballQuery.and().with( // - ParameterSelection.nullSelection("parameters", "weight")); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - @Test - public void shouldQueryByName() { - - try (StrolchTransaction tx = openTx(true)) { - - ResourceQuery ballQuery = ResourceQuery.query("Ball"); - ballQuery.with(new NameSelection("ball ", ci())); - - List result = tx.doQuery(ballQuery); - assertEquals(1, result.size()); - } - } - - private static Resource getBallResource() { - Resource res1 = new Resource("childrensBall", "Ball 1", "Ball"); - Version.setInitialVersionFor(res1, "test"); - ParameterBag bag = new ParameterBag("parameters", "Ball Details", "Parameters"); - bag.addParameter(new StringParameter("color", "Color", "red")); - bag.addParameter(new BooleanParameter("forChildren", "Color", true)); - bag.addParameter(new FloatParameter("diameter", "Color", 22.0)); - bag.addParameter(new StringListParameter("stringListValues", "List of String Values", asList("a", "b", "c"))); - bag.addParameter(new IntegerListParameter("intListValues", "List of Integer Values", asList(1, 2, 3))); - bag.addParameter(new FloatListParameter("floatListValues", "List of Float Values", asList(4.0, 5.1, 6.2))); - bag.addParameter(new LongListParameter("longListValues", "List of Long Values", asList(8L, 9L, 10L))); - res1.addParameterBag(bag); - return res1; - } - - private static List getResources() { - Resource res1 = ModelGenerator.createResource("@1", "Res 1", "MyType1"); - Resource res2 = ModelGenerator.createResource("@2", "Res 2", "MyType1"); - Resource res3 = ModelGenerator.createResource("@3", "Res 3", "MyType2"); - Resource res4 = ModelGenerator.createResource("@4", "Res 4", "MyType2"); - Resource res5 = ModelGenerator.createResource("@5", "Res 5", "MyType3"); - Resource res6 = ModelGenerator.createResource("@6", "Res 6", "MyType3"); - List resources = new ArrayList<>(); - resources.add(res1); - resources.add(res2); - resources.add(res3); - resources.add(res4); - resources.add(res5); - resources.add(res6); - - for (Resource resource : resources) { - Version.setInitialVersionFor(resource, "test"); - } - - return resources; - } -} diff --git a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/QueryTest.java b/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/QueryTest.java deleted file mode 100644 index 5dc22928b..000000000 --- a/li.strolch.agent/src/test/java/li/strolch/runtime/query/inmemory/QueryTest.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.runtime.query.inmemory; - -import static li.strolch.model.ModelGenerator.*; -import static li.strolch.model.query.ParameterSelection.integerSelection; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import li.strolch.RuntimeMock; -import li.strolch.agent.ComponentContainerTest; -import li.strolch.agent.api.ComponentContainer; -import li.strolch.model.Order; -import li.strolch.model.Resource; -import li.strolch.model.activity.Activity; -import li.strolch.model.activity.TimeOrdering; -import li.strolch.model.parameter.IntegerParameter; -import li.strolch.model.query.*; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.privilege.model.Certificate; -import li.strolch.runtime.StrolchConstants; -import li.strolch.utils.StringMatchMode; -import org.junit.Test; - -/** - * @author Robert von Burg - */ -@SuppressWarnings("nls") -public class QueryTest { - - public static final String PATH_EMPTY_RUNTIME = "target/QueryTest/"; //$NON-NLS-1$ - - private Certificate login(ComponentContainer container) { - return container.getPrivilegeHandler().authenticate("test", "test".toCharArray()); - } - - @Test - public void shouldQueryResourceWithParamValue() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Resource res1 = createResource("@1", "Test Resource", "MyType"); - IntegerParameter iP = new IntegerParameter("nbOfBooks", "Number of Books", 33); - res1.addParameter(BAG_ID, iP); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(res1); - tx.commitOnClose(); - } - - ResourceQuery query = ResourceQuery.query("MyType"); - List elementAndSelections = new ArrayList<>(); - elementAndSelections.add(new IdSelection("@1")); - elementAndSelections.add(integerSelection(BAG_ID, "nbOfBooks", 33)); - query.and().with(elementAndSelections); - - InMemoryResourceQueryVisitor resourceQuery = new InMemoryResourceQueryVisitor(); - InMemoryQuery inMemoryQuery = resourceQuery.visit(query); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = inMemoryQuery.doQuery(tx, tx.getResourceMap()); - } - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - }); - } - - @Test - public void shouldQueryOrderWithParamValue() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Order o1 = createOrder("@1", "Test Order", "MyType"); - IntegerParameter iP = new IntegerParameter("nbOfBooks", "Number of Books", 33); - o1.addParameter(BAG_ID, iP); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(o1); - tx.commitOnClose(); - } - - OrderQuery query = OrderQuery.query("MyType"); - List elementAndSelections = new ArrayList<>(); - elementAndSelections.add(new IdSelection("@1")); - elementAndSelections.add(integerSelection(BAG_ID, "nbOfBooks", 33)); - query.and().with(elementAndSelections); - - InMemoryOrderQueryVisitor orderQuery = new InMemoryOrderQueryVisitor(); - InMemoryQuery inMemoryQuery = orderQuery.visit(query); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = inMemoryQuery.doQuery(tx, tx.getOrderMap()); - } - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - }); - } - - @Test - public void shouldQueryActivityWithParamValue() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Activity a1 = createActivity("@1", "Test Activity", "MyType", TimeOrdering.SERIES); - IntegerParameter iP = new IntegerParameter("nbOfBooks", "Number of Books", 33); - a1.addParameter(BAG_ID, iP); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(a1); - tx.commitOnClose(); - } - - ActivityQuery query = ActivityQuery.query("MyType"); - List elementAndSelections = new ArrayList<>(); - elementAndSelections.add(new IdSelection("@1")); - elementAndSelections.add(integerSelection(BAG_ID, "nbOfBooks", 33)); - query.and().with(elementAndSelections); - - InMemoryActivityQueryVisitor orderQuery = new InMemoryActivityQueryVisitor(); - InMemoryQuery inMemoryQuery = orderQuery.visit(query); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = inMemoryQuery.doQuery(tx, tx.getActivityMap()); - } - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - }); - } - - @Test - public void shouldQueryContainsString() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Resource res1 = createResource("@1", "Test Resource", "MyType"); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(res1); - tx.commitOnClose(); - } - - ResourceQuery query = ResourceQuery.query("MyType"); - query.and().with(ParameterSelection - .stringSelection(BAG_ID, PARAM_STRING_ID, "olch", StringMatchMode.CONTAINS_CASE_SENSITIVE)); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = tx.doQuery(query); - } - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - }); - } - - @Test - public void shouldNotQueryContainsString() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Resource res1 = createResource("@1", "Test Resource", "MyType"); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(res1); - tx.commitOnClose(); - } - - ResourceQuery query = ResourceQuery.query("MyType"); - query.and().with(ParameterSelection - .stringSelection(BAG_ID, PARAM_STRING_ID, "str", StringMatchMode.CONTAINS_CASE_SENSITIVE)); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = tx.doQuery(query); - } - assertEquals(0, result.size()); - }); - } - - @Test - public void shouldQueryCaseInsensitiveString() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Resource res1 = createResource("@1", "Test Resource", "MyType"); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(res1); - tx.commitOnClose(); - } - - ResourceQuery query = ResourceQuery.query("MyType"); - query.and().with(ParameterSelection - .stringSelection(BAG_ID, PARAM_STRING_ID, "strolch", StringMatchMode.EQUALS_CASE_INSENSITIVE)); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = tx.doQuery(query); - } - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - }); - } - - @Test - public void shouldNotQueryCaseInsensitiveString() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Resource res1 = createResource("@1", "Test Resource", "MyType"); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(res1); - tx.commitOnClose(); - } - - ResourceQuery query = ResourceQuery.query("MyType"); - query.and().with(ParameterSelection - .stringSelection(BAG_ID, PARAM_STRING_ID, "strolch", StringMatchMode.EQUALS_CASE_SENSITIVE)); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = tx.doQuery(query); - } - assertEquals(0, result.size()); - }); - } - - @Test - public void shouldQueryNot() throws Exception { - - RuntimeMock.runInStrolch(PATH_EMPTY_RUNTIME, ComponentContainerTest.PATH_EMPTY_CONTAINER, agent -> { - ComponentContainer container = agent.getContainer(); - - Certificate certificate = login(container); - - Resource res1 = createResource("@1", "Test Resource", "MyType"); - Resource res2 = createResource("@2", "Test Resource", "MyType"); - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - tx.add(res1); - tx.add(res2); - tx.commitOnClose(); - } - - { - ResourceQuery query = ResourceQuery.query("MyType"); - query.not(new IdSelection("@1")); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = tx.doQuery(query); - } - assertEquals(1, result.size()); - assertEquals("@2", result.get(0).getId()); - } - - { - ResourceQuery query = ResourceQuery.query("MyType"); - query.not(new IdSelection("@2")); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", false)) { - result = tx.doQuery(query); - } - assertEquals(1, result.size()); - assertEquals("@1", result.get(0).getId()); - } - - { - ResourceQuery query = ResourceQuery.query("MyType"); - query.not(new IdSelection("@1", "@2")); - List result; - try (StrolchTransaction tx = container.getRealm(StrolchConstants.DEFAULT_REALM) - .openTx(certificate, "test", true)) { - result = tx.doQuery(query); - } - assertEquals(0, result.size()); - } - }); - } -} diff --git a/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditDao.java b/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditDao.java index d5ffa00f1..b1bb6adca 100644 --- a/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditDao.java +++ b/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditDao.java @@ -26,11 +26,9 @@ import java.util.*; import li.strolch.model.audit.AccessType; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.AuditDao; import li.strolch.persistence.api.StrolchPersistenceException; import li.strolch.utils.collections.DateRange; -import li.strolch.utils.helper.StringHelper; /** * @author Robert von Burg @@ -294,14 +292,6 @@ public class PostgreSqlAuditDao implements AuditDao { } } - @Override - public List doQuery(AuditQuery query) { - - PostgreSqlAuditQueryVisitor queryVisitor = new PostgreSqlAuditQueryVisitor(FIELDS); - query.accept(queryVisitor); - return null; - } - private void setAuditFields(Audit audit, PreparedStatement ps) throws SQLException { // 1 id = ?, diff --git a/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditQueryVisitor.java b/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditQueryVisitor.java deleted file mode 100644 index 187b9848e..000000000 --- a/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlAuditQueryVisitor.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.persistence.postgresql; - -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import li.strolch.model.audit.AccessType; -import li.strolch.model.query.*; -import li.strolch.utils.StringMatchMode; - -/** - * @author Robert von Burg - */ -public class PostgreSqlAuditQueryVisitor implements AuditQueryVisitor { - - protected StringBuilder sql; - protected StringBuilder sb; - protected List values; - - protected long limit; - - protected String indent; - private String sqlAsString; - - /** - * @param fields - */ - public PostgreSqlAuditQueryVisitor(String fields) { - this.indent = ""; - this.sql = new StringBuilder(); - this.sb = new StringBuilder(); - this.values = new ArrayList<>(); - - this.sql.append("select "); - this.sql.append(fields); - this.sql.append("\nfrom\n"); - this.sql.append(" "); - this.sql.append(PostgreSqlAuditDao.TABLE_NAME); - this.indent = " "; - } - - public String getSql() { - if (this.sqlAsString != null) - return this.sqlAsString; - - this.sql.append("\nwhere\n"); - this.sql.append(this.sb.toString()); - - this.sql.append("ORDER BY date DESC\n"); - - if (limit != 0) - this.sql.append("LIMIT " + limit + "\n"); - - this.sqlAsString = this.sql.toString(); - return this.sqlAsString; - } - - @Override - public void visit(AuditQuery auditQuery) { - ensureAnd(); - this.sb.append(this.indent); - this.sb.append(PostgreSqlAuditDao.ELEMENT_TYPE); - this.sb.append(" = ?\n"); - this.limit = auditQuery.getLimit(); - ensureAnd(); - this.values.add(auditQuery.getElementTypeSelection()); - PostgreSqlHelper.toSql(this.indent, this.sb, this.values, PostgreSqlAuditDao.DATE, auditQuery.getDateRange()); - } - - @Override - public void visit(ElementSelection selection) { - if (!selection.isElementSubTypesWildcard()) { - StringSelection sel = selection.getElementSubTypeSelection(); - toSql(PostgreSqlAuditDao.ELEMENT_SUB_TYPE, sel.getMatchMode(), sel.getValues()); - } - - if (!selection.isElementAccessedWildcard()) { - StringSelection sel = selection.getElementAccessedSelection(); - toSql(PostgreSqlAuditDao.ELEMENT_ACCESSED, sel.getMatchMode(), sel.getValues()); - } - } - - @Override - public void visit(IdentitySelection selection) { - if (selection.isWildcard()) - return; - - if (!selection.isFirstnameWildcard()) { - StringSelection sel = selection.getFirstnameSelection(); - toSql(PostgreSqlAuditDao.FIRSTNAME, sel.getMatchMode(), sel.getValues()); - } - - if (!selection.isLastnameWildcard()) { - StringSelection sel = selection.getLastnameSelection(); - toSql(PostgreSqlAuditDao.LASTNAME, sel.getMatchMode(), sel.getValues()); - } - - if (!selection.isUsernameWildcard()) { - StringSelection sel = selection.getUsernameSelection(); - toSql(PostgreSqlAuditDao.USERNAME, sel.getMatchMode(), sel.getValues()); - } - } - - @Override - public void visit(ActionSelection selection) { - if (!selection.isWildcardAction()) { - StringSelection sel = selection.getActionSelection(); - toSql(PostgreSqlAuditDao.ACTION, sel.getMatchMode(), sel.getValues()); - } - - if (!selection.isWildcardActionType()) { - - List accessTypes = selection.getAccessTypes(); - ensureAnd(); - this.sb.append(this.indent); - if (accessTypes.size() == 1) { - this.sb.append(PostgreSqlAuditDao.ACCESS_TYPE + " = ?"); - this.sb.append(PostgreSqlAuditDao.ACCESS_TYPE_TYPE); - this.sb.append("\n"); - this.values.add(accessTypes.get(0).name()); - } else { - this.sb.append(PostgreSqlAuditDao.ACCESS_TYPE + " in ("); - for (int i = 0; i < accessTypes.size(); i++) { - this.sb.append("?"); - this.sb.append(PostgreSqlAuditDao.ACCESS_TYPE_TYPE); - this.values.add(accessTypes.get(i).name()); - if (i < accessTypes.size() - 1) - this.sb.append(", "); - } - this.sb.append(" )\n"); - this.sb.append("\n"); - } - } - } - - private void toSql(String column, StringMatchMode mm, String[] values) { - ensureAnd(); - this.sb.append(this.indent); - this.sb.append(PostgreSqlHelper.toSql(column, this.indent, mm, this.values, values)); - } - - public void setValues(PreparedStatement ps) throws SQLException { - for (int i = 0; i < this.values.size(); i++) { - ps.setObject(i + 1, this.values.get(i)); - } - } - - private void ensureAnd() { - if (this.sb.length() > 0) { - this.sb.append(this.indent); - this.sb.append("and \n"); - } - } -} diff --git a/li.strolch.persistence.postgresql/src/test/java/li/strolch/persistence/postgresql/dao/test/AuditQueryTest.java b/li.strolch.persistence.postgresql/src/test/java/li/strolch/persistence/postgresql/dao/test/AuditQueryTest.java deleted file mode 100644 index ba88cb7a8..000000000 --- a/li.strolch.persistence.postgresql/src/test/java/li/strolch/persistence/postgresql/dao/test/AuditQueryTest.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright 2013 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.persistence.postgresql.dao.test; - -import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE; -import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH; -import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.*; -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.sql.*; -import java.util.Date; -import java.util.*; - -import li.strolch.agent.api.AuditTrail; -import li.strolch.agent.api.StrolchRealm; -import li.strolch.model.ModelGenerator; -import li.strolch.model.Tags; -import li.strolch.model.audit.AccessType; -import li.strolch.model.audit.Audit; -import li.strolch.model.audit.AuditVisitor; -import li.strolch.model.audit.NoStrategyAuditVisitor; -import li.strolch.model.query.AuditQuery; -import li.strolch.persistence.api.PersistenceHandler; -import li.strolch.persistence.api.StrolchTransaction; -import li.strolch.persistence.postgresql.DataType; -import li.strolch.persistence.postgresql.PostgreSqlAuditQueryVisitor; -import li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler; -import li.strolch.privilege.model.Certificate; -import li.strolch.runtime.StrolchConstants; -import li.strolch.testbase.runtime.RuntimeMock; -import li.strolch.utils.StringMatchMode; -import li.strolch.utils.collections.DateRange; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Robert von Burg - */ -public class AuditQueryTest { - - private static final Logger logger = LoggerFactory.getLogger(AuditQueryTest.class); - private static RuntimeMock runtimeMock; - - private static Date past; - private static Date earlier; - private static Date current; - private static Date later; - private static Date future; - - @BeforeClass - public static void beforeClass() throws Exception { - - dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL, DB_USERNAME, DB_PASSWORD); - dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL, DB_USERNAME, DB_PASSWORD); - - File rootPath = new File(RUNTIME_PATH); - File configSrc = new File(CONFIG_SRC); - runtimeMock = new RuntimeMock(); - runtimeMock.mockRuntime(rootPath, configSrc); - new File(rootPath, DB_STORE_PATH_DIR).mkdir(); - runtimeMock.startContainer(); - - PostgreSqlPersistenceHandler persistenceHandler = (PostgreSqlPersistenceHandler) runtimeMock.getContainer() - .getComponent(PersistenceHandler.class); - assertEquals(DataType.xml, persistenceHandler.getDataType()); - - Calendar cal = Calendar.getInstance(); - cal.clear(); - cal.set(2000, 1, 1); - past = cal.getTime(); - cal.set(2000, 4, 1); - earlier = cal.getTime(); - cal.set(2000, 6, 1); - current = cal.getTime(); - cal.set(2000, 8, 1); - later = cal.getTime(); - cal.set(2000, 11, 1); - future = cal.getTime(); - - Certificate cert = runtimeMock.getPrivilegeHandler().authenticate("test", "test".toCharArray()); - StrolchRealm realm = runtimeMock.getRealm(StrolchConstants.DEFAULT_REALM); - int i = 0; - try (StrolchTransaction tx = realm.openTx(cert, "test", false)) { - tx.setSuppressAudits(true); - AuditTrail auditTrail = tx.getAuditTrail(); - - Audit randomAudit; - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setUsername("earlier"); - randomAudit.setDate(earlier); - randomAudit.setAccessType(AccessType.CREATE); - randomAudit.setAction("create"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - auditTrail.add(tx, randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(current); - randomAudit.setUsername("current"); - randomAudit.setAccessType(AccessType.READ); - randomAudit.setAction("read"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - auditTrail.add(tx, randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(later); - randomAudit.setUsername("later"); - randomAudit.setAccessType(AccessType.UPDATE); - randomAudit.setAction("update"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - auditTrail.add(tx, randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(current); - randomAudit.setUsername("current"); - randomAudit.setAccessType(AccessType.DELETE); - randomAudit.setAction("delete"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - auditTrail.add(tx, randomAudit); - - randomAudit = ModelGenerator.randomAudit(); - randomAudit.setId(i++); - randomAudit.setDate(current); - randomAudit.setUsername("current"); - randomAudit.setAccessType(AccessType.CREATE); - randomAudit.setAction("create"); - randomAudit.setElementAccessed(randomAudit.getAccessType().name()); - auditTrail.add(tx, randomAudit); - - tx.commitOnClose(); - } - } - - @AfterClass - public static void afterClass() { - if (runtimeMock != null) - runtimeMock.destroyRuntime(); - } - - public Connection openConn() throws SQLException { - String url = "jdbc:postgresql://localhost/testdb"; - String username = "testuser"; - String password = "test"; - Connection connection = DriverManager.getConnection(url, username, password); - connection.setAutoCommit(false); - return connection; - } - - @Test - public void shouldQueryTypeAndDateRange() throws SQLException { - - AuditVisitor visitor = new NoStrategyAuditVisitor(); - - AuditQuery query = new AuditQuery<>(visitor, Tags.AUDIT, - new DateRange().from(earlier, true).to(later, true)); - performQuery(query, Arrays.asList("0", "1", "2", "3", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(current, true).to(current, true)); - performQuery(query, Arrays.asList("1", "3", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(current, true)); - performQuery(query, Arrays.asList("1", "2", "3", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().to(current, true)); - performQuery(query, Arrays.asList("0", "1", "3", "4")); - - query = new AuditQuery<>(visitor, Tags.RESOURCE, new DateRange().from(past, true).to(future, true)); - performQuery(query, Arrays.asList()); - } - - @Test - public void shouldQueryAudits() throws SQLException { - - AuditVisitor visitor = new NoStrategyAuditVisitor(); - - AuditQuery query = new AuditQuery<>(visitor, Tags.AUDIT, - new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE, AccessType.READ); - performQuery(query, Arrays.asList("0", "1", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE); - performQuery(query, Arrays.asList("0", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE, AccessType.READ) - .actions(StringMatchMode.EQUALS_CASE_SENSITIVE, "create", "read"); - performQuery(query, Arrays.asList("0", "1", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.action().accessTypes(AccessType.CREATE, AccessType.READ) - .actions(StringMatchMode.EQUALS_CASE_SENSITIVE, "read"); - performQuery(query, Arrays.asList("1")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementAccessed(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "crea"); - performQuery(query, Arrays.asList("0", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementAccessed(StringMatchMode.CONTAINS_CASE_SENSITIVE, "crea"); - performQuery(query, Arrays.asList()); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementAccessed(StringMatchMode.EQUALS_CASE_INSENSITIVE, "create"); - performQuery(query, Arrays.asList("0", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier"); - performQuery(query, Arrays.asList("0")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier", "later"); - performQuery(query, Arrays.asList("0", "2")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier") - .firstnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "enn"); - performQuery(query, Arrays.asList("0")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().usernames(StringMatchMode.EQUALS_CASE_INSENSITIVE, "earlier") - .firstnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "enn") - .lastnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "kennedy"); - performQuery(query, Arrays.asList("0")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.identity().firstnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "enn") - .lastnames(StringMatchMode.CONTAINS_CASE_INSENSITIVE, "kennedy"); - performQuery(query, Arrays.asList("0", "1", "2", "3", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementSubTypes(StringMatchMode.EQUALS_CASE_SENSITIVE, "Foo"); - performQuery(query, Arrays.asList("0", "1", "2", "3", "4")); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.element().elementSubTypes(StringMatchMode.EQUALS_CASE_SENSITIVE, "Bar"); - performQuery(query, Arrays.asList()); - - query = new AuditQuery<>(visitor, Tags.AUDIT, new DateRange().from(past, true).to(future, true)); - query.limit(1).element().elementSubTypes(StringMatchMode.EQUALS_CASE_SENSITIVE, "Foo"); - performQuery(query, Arrays.asList("2")); - } - - private void performQuery(AuditQuery query, List expected) throws SQLException { - PostgreSqlAuditQueryVisitor visitor = new PostgreSqlAuditQueryVisitor("id"); - query.accept(visitor); - List ids = queryIds(visitor); - assertEquals(new HashSet<>(expected), new HashSet<>(ids)); - } - - private List queryIds(PostgreSqlAuditQueryVisitor visitor) throws SQLException { - String sql = visitor.getSql(); - logger.info("\n" + sql); - List ids = new ArrayList<>(); - try (Connection con = openConn()) { - try (PreparedStatement ps = con.prepareStatement(sql)) { - visitor.setValues(ps); - - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - ids.add(rs.getString(1)); - } - } - } - } - - return ids; - } -} diff --git a/li.strolch.persistence.xml/src/main/java/li/strolch/persistence/xml/XmlAuditDao.java b/li.strolch.persistence.xml/src/main/java/li/strolch/persistence/xml/XmlAuditDao.java index 6a72b6e53..444aeabd3 100644 --- a/li.strolch.persistence.xml/src/main/java/li/strolch/persistence/xml/XmlAuditDao.java +++ b/li.strolch.persistence.xml/src/main/java/li/strolch/persistence/xml/XmlAuditDao.java @@ -23,7 +23,6 @@ import java.util.function.Predicate; import li.strolch.model.Tags; import li.strolch.model.audit.Audit; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.AuditDao; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.utils.collections.DateRange; @@ -146,9 +145,4 @@ public class XmlAuditDao implements AuditDao { Predicate predicate = file -> dateRange.contains(new Date(file.lastModified())); return this.tx.getObjectDao().removeAllBy(getTypeRef(type), predicate); } - - @Override - public List doQuery(AuditQuery query) { - throw new UnsupportedOperationException("not yet supported!"); - } } diff --git a/li.strolch.rest/src/main/java/li/strolch/rest/endpoint/AuditsService.java b/li.strolch.rest/src/main/java/li/strolch/rest/endpoint/AuditsService.java index aa2c4a1d1..a13851ef9 100644 --- a/li.strolch.rest/src/main/java/li/strolch/rest/endpoint/AuditsService.java +++ b/li.strolch.rest/src/main/java/li/strolch/rest/endpoint/AuditsService.java @@ -16,21 +16,19 @@ package li.strolch.rest.endpoint; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.google.gson.JsonArray; -import li.strolch.model.audit.Audit; -import li.strolch.model.json.AuditToJsonVisitor; -import li.strolch.model.query.AuditQuery; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.privilege.model.Certificate; import li.strolch.rest.RestfulStrolchComponent; import li.strolch.rest.StrolchRestfulConstants; -import li.strolch.rest.model.AuditQueryData; -import li.strolch.rest.model.visitor.ToAuditQueryVisitor; @Path("strolch/audits") public class AuditsService { @@ -53,19 +51,4 @@ public class AuditsService { return Response.ok(dataJ.toString(), MediaType.APPLICATION_JSON).build(); } } - - @GET - @Path("query") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response queryAudits(@BeanParam AuditQueryData query, @Context HttpServletRequest request) { - Certificate cert = (Certificate) request.getAttribute(StrolchRestfulConstants.STROLCH_CERTIFICATE); - - try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getContext())) { - AuditQuery auditQuery = new ToAuditQueryVisitor().create(query); - JsonArray dataJ = new JsonArray(); - tx.getAuditTrail().doQuery(tx, auditQuery).forEach(a -> a.accept(new AuditToJsonVisitor())); - return Response.ok(dataJ.toString(), MediaType.APPLICATION_JSON).build(); - } - } } diff --git a/li.strolch.rest/src/main/java/li/strolch/rest/model/visitor/ToAuditQueryVisitor.java b/li.strolch.rest/src/main/java/li/strolch/rest/model/visitor/ToAuditQueryVisitor.java deleted file mode 100644 index d09fd85e6..000000000 --- a/li.strolch.rest/src/main/java/li/strolch/rest/model/visitor/ToAuditQueryVisitor.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015 Robert von Burg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package li.strolch.rest.model.visitor; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -import li.strolch.model.audit.AccessType; -import li.strolch.model.audit.Audit; -import li.strolch.model.query.ActionSelection; -import li.strolch.model.query.AuditQuery; -import li.strolch.rest.model.AuditQueryData; -import li.strolch.utils.StringMatchMode; -import li.strolch.utils.collections.DateRange; -import li.strolch.utils.helper.StringHelper; -import li.strolch.utils.iso8601.ISO8601FormatFactory; - -public class ToAuditQueryVisitor { - - public li.strolch.model.query.AuditQuery create(AuditQueryData query) { - - // validate element type - String elementType = query.getElementType(); - if (StringHelper.isEmpty(elementType)) { - throw new IllegalArgumentException("elementType on AuditQueryData is empty!"); - } - - // validate date range - if (query.getFromDate() == null || query.getToDate() == null) { - throw new IllegalArgumentException("fromDate or toDate must be set!"); - } - Date fromDate = ISO8601FormatFactory.getInstance().parseDate(query.getFromDate()); - Date toDate = ISO8601FormatFactory.getInstance().parseDate(query.getToDate()); - DateRange dr = new DateRange().from(fromDate, true).to(toDate, false); - - // create query - AuditQuery auditQuery = AuditQuery.query(elementType, dr); - - // limit - auditQuery.limit(query.getLimit()); - - // element - String elementSubType = query.getElementSubType(); - if (StringHelper.isNotEmpty(elementSubType)) { - auditQuery.element().elementSubTypes(StringMatchMode.ci(), elementSubType); - } - String elementId = query.getElementId(); - if (StringHelper.isNotEmpty(elementId)) { - auditQuery.element().elementAccessed(StringMatchMode.ci(), elementId); - } - - // action - String actionS = query.getAction(); - ActionSelection actionSelection = auditQuery.action(); - if (StringHelper.isNotEmpty(actionS)) - actionSelection.actions(StringMatchMode.ci(), actionS); - String accessTypesS = query.getAccessTypes(); - if (StringHelper.isNotEmpty(accessTypesS)) { - String[] accessTypes = accessTypesS.split("\\|"); - List accessTypeList = Arrays.stream(accessTypes).map(AccessType::valueOf) - .collect(Collectors.toList()); - actionSelection.accessTypes(accessTypeList); - } - - // identity - li.strolch.model.query.IdentitySelection identitySelection = auditQuery.identity(); - if (StringHelper.isNotEmpty(query.getFirstname())) - identitySelection.firstnames(StringMatchMode.ci(), query.getFirstname()); - if (StringHelper.isNotEmpty(query.getLastname())) - identitySelection.lastnames(StringMatchMode.ci(), query.getLastname()); - if (StringHelper.isNotEmpty(query.getUsername())) - identitySelection.usernames(StringMatchMode.ci(), query.getUsername()); - - return auditQuery; - } -} diff --git a/li.strolch.soql/src/main/java/li/strolch/soql/core/QueryProcessor.java b/li.strolch.soql/src/main/java/li/strolch/soql/core/QueryProcessor.java index a6671c0cf..7cea1d250 100644 --- a/li.strolch.soql/src/main/java/li/strolch/soql/core/QueryProcessor.java +++ b/li.strolch.soql/src/main/java/li/strolch/soql/core/QueryProcessor.java @@ -4,7 +4,6 @@ import java.util.*; import li.strolch.model.StrolchRootElement; import li.strolch.model.Tags; -import li.strolch.model.query.StrolchElementQuery; import li.strolch.persistence.api.StrolchTransaction; import li.strolch.search.ActivitySearch; import li.strolch.search.OrderSearch; @@ -26,9 +25,6 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker; */ public class QueryProcessor { - // Map of queries to retrieve the input objects - protected Map> queries; - // Map of entities the input objects are taken from private Map> inputCollections;