@Test public void getMultipleFactHandleTest() { HashSet<String> factSet = new HashSet<String>(); int numFacts = 4; for( int i = 0; i < numFacts; ++i ) { factSet.add("" + random.nextInt()); } for( String fact : factSet ) { ksession.insert(fact); } GetFactHandlesCommand command = new GetFactHandlesCommand(); Object result = runner.execute(command, context); verifyThatCollectionContainsTheseFactHandle(factSet, result); }
public Collection<FactHandle> execute( Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>(); if ( filter != null ) { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( this.filter ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult( this.outIdentifier, disconnectedFactHandles ); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles( this.filter ); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } else { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, disconnectedFactHandles); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles(); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } }
GetFactHandlesCommand implements
    ExecutableCommand<Collection<FactHandle>> { public Collection<FactHandle> execute( Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>(); if ( filter != null ) { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( this.filter ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult( this.outIdentifier, disconnectedFactHandles ); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles( this.filter ); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } else { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, disconnectedFactHandles); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles(); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } } }
GetFactHandlesCommand implements
    ExecutableCommand<Collection<FactHandle>> { public Collection<FactHandle> execute( Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>(); if ( filter != null ) { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( this.filter ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult( this.outIdentifier, disconnectedFactHandles ); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles( this.filter ); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } else { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, disconnectedFactHandles); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles(); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } } GetFactHandlesCommand();  GetFactHandlesCommand(ObjectFilter filter);  GetFactHandlesCommand(ObjectFilter filter, boolean disconnected);  GetFactHandlesCommand(boolean disconnected); }
GetFactHandlesCommand implements
    ExecutableCommand<Collection<FactHandle>> { public Collection<FactHandle> execute( Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>(); if ( filter != null ) { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( this.filter ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult( this.outIdentifier, disconnectedFactHandles ); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles( this.filter ); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } else { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, disconnectedFactHandles); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles(); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } } GetFactHandlesCommand();  GetFactHandlesCommand(ObjectFilter filter);  GetFactHandlesCommand(ObjectFilter filter, boolean disconnected);  GetFactHandlesCommand(boolean disconnected); boolean isDisconnected(); void setDisconnected( boolean disconnected ); Collection<FactHandle> execute( Context context ); String getOutIdentifier(); void setOutIdentifier(String outIdentifier); String toString(); }
GetFactHandlesCommand implements
    ExecutableCommand<Collection<FactHandle>> { public Collection<FactHandle> execute( Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>(); if ( filter != null ) { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( this.filter ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult( this.outIdentifier, disconnectedFactHandles ); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles( this.filter ); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } else { Collection<InternalFactHandle> factHandles = ksession.getFactHandles( ); if(factHandles != null && disconnected){ for(InternalFactHandle factHandle: factHandles){ InternalFactHandle handle = factHandle.clone(); handle.disconnect(); disconnectedFactHandles.add(handle); } if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, disconnectedFactHandles); } return disconnectedFactHandles; } else { Collection<FactHandle> ksessionFactHandles = ksession.getFactHandles(); if (outIdentifier != null) { ((RegistryContext) context).lookup( ExecutionResultImpl.class ).setResult(this.outIdentifier, new ArrayList<FactHandle>(ksessionFactHandles)); } return ksessionFactHandles; } } } GetFactHandlesCommand();  GetFactHandlesCommand(ObjectFilter filter);  GetFactHandlesCommand(ObjectFilter filter, boolean disconnected);  GetFactHandlesCommand(boolean disconnected); boolean isDisconnected(); void setDisconnected( boolean disconnected ); Collection<FactHandle> execute( Context context ); String getOutIdentifier(); void setOutIdentifier(String outIdentifier); String toString();  }