Codota Logo
RulesRepository.getState
Code IndexAdd Codota to your IDE (free)

How to use
getState
method
in
org.drools.repository.RulesRepository

Best Java code snippets using org.drools.repository.RulesRepository.getState (Showing top 12 results out of 315)

  • Common ways to obtain RulesRepository
private void myMethod () {
RulesRepository r =
  • Codota IconSession session;new RulesRepository(session)
  • Smart code suggestions by Codota
}
origin: org.drools/guvnor-repository

/**
 * This will change the status of this module, and all the contained
 * assets. No new versions are created of anything.
 *
 * @param newState The status tag to change it to.
 */
public void changeStatus(String newState) {
  StateItem stateItem = rulesRepository.getState(newState);
  updateState(stateItem);
  for (Iterator<AssetItem> iter = getAssets(); iter.hasNext(); ) {
    iter.next().updateState(stateItem);
  }
}
origin: org.chtijbug.drools/guvnor-repository

/**
 * This will change the status of this module, and all the contained
 * assets. No new versions are created of anything.
 *
 * @param newState The status tag to change it to.
 */
public void changeStatus(String newState) {
  StateItem stateItem = rulesRepository.getState(newState);
  updateState(stateItem);
  for (Iterator<AssetItem> iter = getAssets(); iter.hasNext(); ) {
    iter.next().updateState(stateItem);
  }
}
origin: org.drools/guvnor-repository

/**
 * Sets this object's rule node's state property to refer to the specified state node
 *
 * @param stateName the name of the state to set the rule node to
 * @throws RulesRepositoryException
 */
public void updateState(String stateName) throws RulesRepositoryException {
  try {
    //now set the state property of the rule
    checkout();
    StateItem stateItem = this.rulesRepository.getState( stateName );
    this.updateState( stateItem );
  } catch ( Exception e ) {
    log.error( "Caught exception",
          e );
    throw new RulesRepositoryException( e );
  }
}
origin: org.chtijbug.drools/guvnor-repository

/**
 * Sets this object's rule node's state property to refer to the specified state node
 *
 * @param stateName the name of the state to set the rule node to
 * @throws RulesRepositoryException
 */
public void updateState(String stateName) throws RulesRepositoryException {
  try {
    //now set the state property of the rule
    checkout();
    StateItem stateItem = this.rulesRepository.getState( stateName );
    this.updateState( stateItem );
  } catch ( Exception e ) {
    log.error( "Caught exception",
          e );
    throw new RulesRepositoryException( e );
  }
}
origin: org.drools/guvnor-repository

/**
 * Finds the AssetItem's linked to the requested state. Similar to finding
 * by category.
 *
 * @param filter an AssetItem filter
 */
public AssetItemPageResult findAssetsByState(String stateName,
                       boolean seekArchivedAsset,
                       int skip,
                       int numRowsToReturn,
                       RepositoryFilter filter) throws RulesRepositoryException {
  StateItem item = this.getState(stateName);
  try {
    return loadLinkedAssets(seekArchivedAsset,
        skip,
        numRowsToReturn,
        item.getNode(),
        filter);
  } catch (RepositoryException e) {
    throw new RulesRepositoryException(e);
  }
}
origin: org.chtijbug.drools/guvnor-repository

/**
 * Finds the AssetItem's linked to the requested state. Similar to finding
 * by category.
 *
 * @param filter an AssetItem filter
 */
public AssetItemPageResult findAssetsByState(String stateName,
                       boolean seekArchivedAsset,
                       int skip,
                       int numRowsToReturn,
                       RepositoryFilter filter) throws RulesRepositoryException {
  StateItem item = this.getState(stateName);
  try {
    return loadLinkedAssets(seekArchivedAsset,
        skip,
        numRowsToReturn,
        item.getNode(),
        filter);
  } catch (RepositoryException e) {
    throw new RulesRepositoryException(e);
  }
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testGetState() {
  RulesRepository rulesRepository = getRepo();
  StateItem state0 = rulesRepository.createState( "testGetState" );
  assertNotNull( state0 );
  assertEquals( "testGetState",
         state0.getName() );
  StateItem stateItem1 = rulesRepository.getState( "testGetState" );
  assertNotNull( stateItem1 );
  assertEquals( "testGetState",
         stateItem1.getName() );
  StateItem stateItem2 = rulesRepository.getState( "testGetState" );
  assertNotNull( stateItem2 );
  assertEquals( "testGetState",
         stateItem2.getName() );
  assertEquals( stateItem1,
         stateItem2 );
}
origin: org.chtijbug.drools/guvnor-repository

StateItem state = getRepo().getState( "foobar" );
rules = iteratorToList( pack.getAssetsWithStatus( getRepo().getState( "whee" ) ) );
assertEquals(0, rules.size());
rules = iteratorToList( pack.getAssetsWithStatus(getRepo().getState( StateItem.DRAFT_STATE_NAME )) );
assertEquals(3, rules.size());
rule1.checkin( "latest" );
rules = iteratorToList( pack.getAssetsWithStatus(getRepo().getState( "extractorState" )) );
assertEquals(1, rules.size());
AssetItem rule = (AssetItem) rules.get( 0 );
rules = iteratorToList( pack.getAssetsWithStatus(getRepo().getState( "foobar" )) );
assertEquals(1, rules.size());
AssetItem prior = (AssetItem) rules.get( 0 );
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testIgnoreState() throws Exception {
  ModuleItem pack = getRepo().createModule( "package testIgnoreState", "foo" );
  getRepo().createState( "x" );
  AssetItem rule1 = pack.addAsset( "rule number 1", "yeah man" );
  rule1.updateState( "x" );
  rule1.checkin( "version0" );
  AssetItem rule2 = pack.addAsset( "rule number 2", "no way" );
  rule2.updateState( "x" );
  rule2.checkin( "version0" );
  AssetItem rule3 = pack.addAsset( "rule number 3", "yes way" );
  getRepo().createState( "disabled" );
  rule3.updateState( "disabled" );
  rule3.checkin( "version0" );
  getRepo().save();
  Iterator result = pack.getAssetsWithStatus( getRepo().getState( "x" ), getRepo().getState( "disabled" ) );
  List l = iteratorToList( result );
  assertEquals(2, l.size());
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testStatusStufftestRemoveTagForShareableAsset() {
  getRepo().createState("testStatusStufftestRemoveTagForShareableAssetStatus");
  AssetItem asset = getRepo().loadGlobalArea().addAsset("testStatusStufftestRemoveTagForShareableAsset", "desc");
  AssetItem linkedAsset = getDefaultPackage().addAssetImportedFromGlobalArea(asset.getName());
  StateItem stateItem1 = linkedAsset.getState();
  assertEquals(StateItem.DRAFT_STATE_NAME, stateItem1.getName());
  assertEquals(getRepo().getState(StateItem.DRAFT_STATE_NAME), linkedAsset.getState());
  assertEquals(StateItem.DRAFT_STATE_NAME, linkedAsset.getStateDescription());
  linkedAsset.updateState("testStatusStufftestRemoveTagForShareableAssetStatus");
  assertEquals("testStatusStufftestRemoveTagForShareableAssetStatus", linkedAsset.getState().getName());
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testStatusStuff() {
    AssetItem ruleItem1 = getDefaultPackage().addAsset("testGetState", "test content");
    StateItem stateItem1 = ruleItem1.getState();
    assertEquals(StateItem.DRAFT_STATE_NAME, stateItem1.getName());
    getRepo().createState( "TestState1" );
    ruleItem1.updateState("TestState1");
    assertNotNull(ruleItem1.getState());
    assertEquals("TestState1", ruleItem1.getState().getName());
    ruleItem1 = getDefaultPackage().addAsset( "testGetState2", "wa" );
    assertEquals(StateItem.DRAFT_STATE_NAME, ruleItem1.getStateDescription());
    assertEquals(getRepo().getState( StateItem.DRAFT_STATE_NAME ), ruleItem1.getState());
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testSetStateString() {
    AssetItem ruleItem1 = getDefaultPackage().addAsset("testSetStateString", "test content");
    getRepo().createState( "TestState1" );
    ruleItem1.updateState("TestState1");
    assertNotNull(ruleItem1.getState());
    assertEquals("TestState1", ruleItem1.getState().getName());
    getRepo().createState( "TestState2" );
    ruleItem1.updateState("TestState2");
    assertNotNull(ruleItem1.getState());
    assertEquals("TestState2", ruleItem1.getState().getName());
    ruleItem1 = getDefaultPackage().addAsset("foobar", "test description");
    StateItem stateItem1 = getRepo().getState("TestState1");
    ruleItem1.updateState(stateItem1);
    assertNotNull(ruleItem1.getState());
    assertEquals(ruleItem1.getState().getName(), "TestState1");
    StateItem stateItem2 = getRepo().getState("TestState2");
    ruleItem1.updateState(stateItem2);
    assertNotNull(ruleItem1.getState());
    assertEquals("TestState2", ruleItem1.getState().getName());
}
org.drools.repositoryRulesRepositorygetState

Javadoc

Gets a StateItem for the specified state name. If a node for the specified state does not yet exist, one is first created.

Popular methods of RulesRepository

  • createModule
    Adds a module to the repository.
  • loadModule
    Loads a Module for the specified module name and version. Will throw an exception if the specified m
  • save
    Save any pending changes.
  • <init>
    This requires a JCR session be setup, and the repository be configured.
  • findAssetsByCategory
    This will retrieve a list of RuleItem objects - that are allocated to the provided category. Only th
  • findAssetsByName
    This will search assets, looking for matches against the name.
  • findAssetsByState
    Finds the AssetItem's linked to the requested state. Similar to finding by category.
  • getAreaNode
  • getSession
  • listModuleSnapshots
    Return a list of the snapshots available for the given module name.
  • listModules
  • loadAssetByUUID
    Loads an asset by its UUID (generally the fastest way to load something).
  • listModules,
  • loadAssetByUUID,
  • loadCategory,
  • loadGlobalArea,
  • loadModuleByUUID,
  • loadModuleSnapshot,
  • loadState,
  • addNodeIfNew,
  • checkForDataMigration

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • String (java.lang)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now