import java.util.List;
import java.util.Map;
+import org.openecomp.policy.drools.core.PolicyContainer;
import org.openecomp.policy.drools.event.comm.TopicSink;
import org.openecomp.policy.drools.properties.Lockable;
import org.openecomp.policy.drools.properties.Startable;
*/
public String[] getRecentSinkEvents();
+ /**
+ * @return the underlying policy container
+ */
+ public PolicyContainer getContainer();
+
/**
* Supports this encoder?
*
import org.apache.commons.collections4.queue.CircularFifoQueue;
import org.drools.core.ClassObjectFilter;
+import org.kie.api.definition.KiePackage;
+import org.kie.api.definition.rule.Query;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import org.kie.api.runtime.rule.QueryResults;
}
/**
- * gets the policy container
- * @return the underlying container
+ * {@inheritDoc}
*/
@JsonIgnore
- protected PolicyContainer getContainer() {
+ public PolicyContainer getContainer() {
return this.policyContainer;
}
PolicySession session = getSession(sessionName);
KieSession kieSession = session.getKieSession();
+ boolean found = false;
+ for (KiePackage kiePackage : kieSession.getKieBase().getKiePackages()) {
+ for (Query q : kiePackage.getQueries()) {
+ if (q.getName() != null && q.getName().equals(queryName)) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found)
+ throw new IllegalArgumentException("Invalid Query Name: " + queryName);
+
List<Object> factObjects = new ArrayList<>();
QueryResults queryResults = kieSession.getQueryResults(queryName, queryParams);
import java.util.Map;
import org.openecomp.policy.drools.controller.DroolsController;
+import org.openecomp.policy.drools.core.PolicyContainer;
import org.openecomp.policy.drools.event.comm.TopicSink;
import org.openecomp.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
@Override
public boolean deliver(TopicSink sink, Object event)
throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
- throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
+ throw new IllegalStateException(this.getClass().getCanonicalName() + " invoked");
}
/**
public Object[] getRecentSourceEvents() {
return new String[0];
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PolicyContainer getContainer() {
+ return null;
+ }
/**
* {@inheritDoc}
*/
@Override
public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) throws IllegalStateException {
- throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
+ throw new IllegalStateException(this.getClass().getCanonicalName() + " invoked");
}
/**
boolean delete, Object... queryParams) {
return new ArrayList<Object>();
}
-
}