congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
RulesRepository.getState
Code IndexAdd Tabnine 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)

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

  • Creating JSON documents from java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • getContentResolver (Context)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now