congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
RulesRepository.loadCategory
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: org.chtijbug.drools/guvnor-repository

/**
 * Rename a category.
 *
 * @param originalPath The full path to the category.
 * @param newName      The new name (just the name, not the path).
 */
public void renameCategory(String originalPath,
              String newName) {
  try {
    Node node = loadCategory(originalPath).getNode();
    String sourcePath = node.getPath();
    String destPath = node.getParent().getPath() + "/" + newName;
    this.session.move(sourcePath,
        destPath);
    save();
  } catch (RepositoryException e) {
    log.error(e.getMessage(),
        e);
    throw new RulesRepositoryException(e);
  }
}
origin: org.drools/guvnor-repository

/**
 * Rename a category.
 *
 * @param originalPath The full path to the category.
 * @param newName      The new name (just the name, not the path).
 */
public void renameCategory(String originalPath,
              String newName) {
  try {
    Node node = loadCategory(originalPath).getNode();
    String sourcePath = node.getPath();
    String destPath = node.getParent().getPath() + "/" + newName;
    this.session.move(sourcePath,
        destPath);
    save();
  } catch (RepositoryException e) {
    log.error(e.getMessage(),
        e);
    throw new RulesRepositoryException(e);
  }
}
origin: org.chtijbug.drools/guvnor-repository

/**
 * This will retrieve a list of RuleItem objects - that are allocated to the
 * provided category. Only the latest versions of each RuleItem will be
 * returned (you will have to delve into the assets deepest darkest history
 * yourself... mahahahaha).
 * <p/>
 * Pass in startRow of 0 to start at zero, numRowsToReturn can be set to -1
 * should you want it all.
 *
 * @param filter an AssetItem filter
 */
public AssetItemPageResult findAssetsByCategory(String categoryTag,
                        boolean seekArchivedAsset,
                        int skip,
                        int numRowsToReturn,
                        RepositoryFilter filter) throws RulesRepositoryException {
  CategoryItem item = this.loadCategory(categoryTag);
  try {
    return loadLinkedAssets(seekArchivedAsset,
        skip,
        numRowsToReturn,
        item.getNode(),
        filter);
  } catch (RepositoryException e) {
    throw new RulesRepositoryException(e);
  }
}
origin: org.drools/guvnor-repository

/**
 * This method sets the categories in one hit, making the
 * ASSUMPTION that the categories were previously set up !
 * (via CategoryItem of course !).
 */
public void updateCategoryList(String[] categories) {
  this.checkIsUpdateable();
  try {
    Value[] newCats = new Value[categories.length];
    for ( int i = 0; i < categories.length; i++ ) {
      CategoryItem item = this.rulesRepository.loadCategory( categories[i] );
      newCats[i] = this.node.getSession().getValueFactory().createValue( item.getNode() );
    }
    updateCategories( newCats );
  } catch ( RepositoryException e ) {
    throw new RulesRepositoryException(e);
  }
}
origin: org.chtijbug.drools/guvnor-repository

/**
 * This method sets the categories in one hit, making the
 * ASSUMPTION that the categories were previously set up !
 * (via CategoryItem of course !).
 */
public void updateCategoryList(String[] categories) {
  this.checkIsUpdateable();
  try {
    Value[] newCats = new Value[categories.length];
    for ( int i = 0; i < categories.length; i++ ) {
      CategoryItem item = this.rulesRepository.loadCategory( categories[i] );
      newCats[i] = this.node.getSession().getValueFactory().createValue( item.getNode() );
    }
    updateCategories( newCats );
  } catch ( RepositoryException e ) {
    throw new RulesRepositoryException(e);
  }
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testTagItem() throws Exception {
  final CategoryItem root = getRepo().loadCategory("/");
  root.addCategory("TestTag", "nothing to see");
  CategoryItem tagItem1 = getRepo().loadCategory("TestTag");
  assertNotNull(tagItem1);
  assertEquals("TestTag", tagItem1.getName());
  CategoryItem tagItem2 = getRepo().loadCategory("TestTag");
  assertNotNull(tagItem2);
  assertEquals("TestTag", tagItem2.getName());
  assertEquals(tagItem1, tagItem2);
  List originalCats = getRepo().loadCategory("/").getChildTags(); // listCategoryNames();
  assertTrue(originalCats.size() > 0);
  CategoryItem rootCat = (CategoryItem)originalCats.get(0);
  assertNotNull(rootCat.getName());
  assertNotNull(rootCat.getFullPath());
  root.addCategory("FootestTagItem", "nothing");
  List cats = root.getChildTags();
  assertEquals(originalCats.size() + 1, cats.size());
  boolean found = false;
  for (Iterator iter = cats.iterator(); iter.hasNext();) {
    CategoryItem element = (CategoryItem)iter.next();
    if (element.getName().equals("FootestTagItem")) {
      found = true;
      break;
    }
  }
  assertTrue(found);
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testUpdateCategories() {
  getRepo().loadCategory( "/" ).addCategory( "testUpdateCategoriesOnAsset", "la" );
  getRepo().loadCategory( "/" ).addCategory( "testUpdateCategoriesOnAsset2", "la" );
  AssetItem item = getRepo().loadDefaultModule().addAsset( "testUpdateCategoriesOnAsset", "huhuhu" );
  String[] cats = new String[] {"testUpdateCategoriesOnAsset", "testUpdateCategoriesOnAsset2"};
  item.updateCategoryList( cats );
  item.checkin( "aaa" );
  item = getRepo().loadDefaultModule().loadAsset( "testUpdateCategoriesOnAsset" );
  assertEquals(2, item.getCategories().size());
  for ( Iterator iter = item.getCategories().iterator(); iter.hasNext(); ) {
    CategoryItem cat = (CategoryItem) iter.next();
    assertTrue(cat.getName().startsWith( "testUpdateCategoriesOnAsset" ));
  }
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testGetTags() {
    AssetItem ruleItem1 = getDefaultPackage().addAsset("testGetTags", "test content");
    List tags = ruleItem1.getCategories();
    assertNotNull(tags);
    assertEquals(0, tags.size());
    getRepo().loadCategory( "/" ).addCategory( "testGetTagsTestTag", "description" );
    ruleItem1.addCategory("testGetTagsTestTag");
    tags = ruleItem1.getCategories();
    assertEquals(1, tags.size());
    assertEquals("testGetTagsTestTag", ((CategoryItem)tags.get(0)).getName());
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testRemoveTag() {
    AssetItem ruleItem1 = getDefaultPackage().addAsset("testRemoveTag", "test content");
    getRepo().loadCategory( "/" ).addCategory( "TestRemoveCategory", "description" );
    ruleItem1.addCategory("TestRemoveCategory");
    List tags = ruleItem1.getCategories();
    assertEquals(1, tags.size());
    ruleItem1.removeCategory("TestRemoveCategory");
    tags = ruleItem1.getCategories();
    assertEquals(0, tags.size());
    getRepo().loadCategory( "/" ).addCategory( "TestRemoveCategory2", "description" );
    getRepo().loadCategory( "/" ).addCategory( "TestRemoveCategory3", "description" );
    ruleItem1.addCategory("TestRemoveCategory2");
    ruleItem1.addCategory("TestRemoveCategory3");
    ruleItem1.removeCategory("TestRemoveCategory2");
    tags = ruleItem1.getCategories();
    assertEquals(1, tags.size());
    assertEquals("TestRemoveCategory3", ((CategoryItem)tags.get(0)).getName());
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testRemoveCategoryLinkedWithArchived() {
  RulesRepository repo = getRepo();
  repo.loadCategory("/").addCategory("testRemoveCategoryWithArchivedCat", "a");
  AssetItem as = repo.loadDefaultModule().addAsset("testRemoveCategoryWithArchivedAsset",
                           "a",
                           "testRemoveCategoryWithArchivedCat",
                           "drl");
  as.checkin("a");
  as.archiveItem(true);
  repo.loadCategory("testRemoveCategoryWithArchivedCat").remove();
  
  repo.save();
  as.remove();
}
/**
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testRemoveCategoryUneeded() {
  RulesRepository repo = getRepo();
  repo.loadCategory("/").addCategory("testRemoveCat", "a");
  AssetItem as = repo.loadDefaultModule().addAsset("testRemoveCategory", "a", "testRemoveCat", "drl");
  as.checkin("a");
  as.updateCategoryList(new String[] {});
  as.checkin("a");
  as = repo.loadDefaultModule().loadAsset("testRemoveCategory");
  assertEquals(0, as.getCategories().size());
  repo.loadCategory("testRemoveCat").remove();
  repo.save();
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testCreateCateories() throws Exception {
  RulesRepository repo = getRepo();
  // load the root
  CategoryItem root = repo.loadCategory("/");
  CategoryItem item = root.addCategory("testCreateCategories", "this is a top level one");
  assertEquals("testCreateCategories", item.getName());
  assertEquals("testCreateCategories", item.getFullPath());
  item = repo.loadCategory("testCreateCategories");
  assertEquals("testCreateCategories", item.getName());
  item.remove();
  repo.save();
  try {
    repo.loadCategory("testCreateCategories");
    fail("this should not exist");
  } catch (RulesRepositoryException e) {
    assertNotNull(e.getCause());
  }
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testUpdateCategoriesForShareableAsset() {
  getRepo().loadCategory("/").addCategory("testUpdateCategoriesForShareableAssetTag1", "la");
  getRepo().loadCategory("/").addCategory("testUpdateCategoriesForShareableAssetTag2", "la");
  AssetItem asset = getRepo().loadGlobalArea().addAsset("testUpdateCategoriesForShareableAsset", "desc");
  AssetItem linkedAsset = getDefaultPackage().addAssetImportedFromGlobalArea(asset.getName());
  String[] cats = new String[] {"testUpdateCategoriesForShareableAssetTag1", "testUpdateCategoriesForShareableAssetTag2"};
  linkedAsset.updateCategoryList(cats);
  linkedAsset.checkin("aaa");
  asset = getRepo().loadGlobalArea().loadAsset("testUpdateCategoriesForShareableAsset");
  assertEquals(2, asset.getCategories().size());
  for (Iterator iter = asset.getCategories().iterator(); iter.hasNext();) {
    CategoryItem cat = (CategoryItem)iter.next();
    assertTrue(cat.getName().startsWith("testUpdateCategoriesForShareableAssetTag"));
  }
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testFindRulesByCategory() throws Exception {
  getRepo().loadCategory( "/" ).addCategory( "testFindRulesByCat", "yeah" );
  AssetItem as1 = getDefaultPackage().addAsset( "testFindRulesByCategory1", "ya", "testFindRulesByCat", "drl" );
  getDefaultPackage().addAsset( "testFindRulesByCategory2", "ya", "testFindRulesByCat", AssetItem.DEFAULT_CONTENT_FORMAT ).checkin( "version0" );
  as1.checkin( "version0" );
  assertEquals("drl", as1.getFormat());
  List rules = getRepo().findAssetsByCategory( "testFindRulesByCat", 0, -1 ).assets;
  assertEquals(2, rules.size());
  for ( Iterator iter = rules.iterator(); iter.hasNext(); ) {
    AssetItem element = (AssetItem) iter.next();
    assertTrue(element.getName().startsWith( "testFindRulesByCategory" ));
  }
  try {
    getRepo().loadCategory( "testFindRulesByCat" ).remove();
    fail("should not be able to remove");
  } catch (RulesRepositoryException e) {
    //assertTrue(e.getCause() instanceof ReferentialIntegrityException);
    assertNotNull(e.getMessage());
  }
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testGetChildTags() {
  final CategoryItem root = getRepo().loadCategory("/");
  root.addCategory("TestTag", "nothing to see");
  
  CategoryItem tagItem1 = getRepo().loadCategory("TestTag");
  assertNotNull(tagItem1);
  assertEquals("TestTag", tagItem1.getName());
  List childTags = tagItem1.getChildTags();
  assertNotNull(childTags);
  assertEquals(0, childTags.size());
  tagItem1.addCategory("TestChildTag1", "description");
  childTags = tagItem1.getChildTags();
  assertNotNull(childTags);
  assertEquals(1, childTags.size());
  assertEquals("TestChildTag1", ((CategoryItem)childTags.get(0)).getName());
  tagItem1.addCategory("AnotherChild", "ignore me");
  childTags = tagItem1.getChildTags();
  assertNotNull(childTags);
  assertEquals(2, childTags.size());
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testRemoveTagForShareableAsset() {
  getRepo().loadCategory("/").addCategory("testRemoveTagForShareableAssetTag1", "la");
  getRepo().loadCategory("/").addCategory("testRemoveTagForShareableAssetTag2", "description");
  getRepo().loadCategory("/").addCategory("testRemoveTagForShareableAssetTag3", "description");
  AssetItem asset = getRepo().loadGlobalArea().addAsset("testRemoveTagForShareableAsset", "desc");
  AssetItem linkedAsset = getDefaultPackage().addAssetImportedFromGlobalArea(asset.getName());
    getRepo().loadCategory("testRemoveTagForShareableAssetTag2").remove();
    fail("should not be able to remove");
  } catch (RulesRepositoryException e) {
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testGetChildTag() {
  CategoryItem root = getRepo().loadCategory("/");
  CategoryItem tagItem1 = root.addCategory("testGetChildTag", "yeah");
  assertNotNull(tagItem1);
  assertEquals("testGetChildTag", tagItem1.getName());
  // test that child is added if not already in existence
  List childTags = tagItem1.getChildTags();
  assertNotNull(childTags);
  assertEquals(0, childTags.size());
  CategoryItem childTagItem1 = tagItem1.addCategory("TestChildTag1", "woo");
  assertNotNull(childTagItem1);
  assertEquals("TestChildTag1", childTagItem1.getName());
  // test that if already there, it is returned
  CategoryItem childTagItem2 = getRepo().loadCategory("testGetChildTag/TestChildTag1");
  assertNotNull(childTagItem2);
  assertEquals("TestChildTag1", childTagItem2.getName());
  assertEquals(childTagItem1, childTagItem2);
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testGetTag() {
  RulesRepository rulesRepository = getRepo();
  CategoryItem root = rulesRepository.loadCategory( "/" );
  CategoryItem tagItem1 = root.addCategory( "testGetTag",
                       "ho" );
  assertNotNull( tagItem1 );
  assertEquals( "testGetTag",
         tagItem1.getName() );
  assertEquals( "testGetTag",
         tagItem1.getFullPath() );
  CategoryItem tagItem2 = rulesRepository.loadCategory( "testGetTag" );
  assertNotNull( tagItem2 );
  assertEquals( "testGetTag",
         tagItem2.getName() );
  assertEquals( tagItem1,
         tagItem2 );
  //now test getting a tag down in the tag hierarchy
  CategoryItem tagItem3 = tagItem2.addCategory( "TestChildTag1",
                         "ka" );
  assertNotNull( tagItem3 );
  assertEquals( "TestChildTag1",
         tagItem3.getName() );
  assertEquals( "testGetTag/TestChildTag1",
         tagItem3.getFullPath() );
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testFindArchivedAssetsByCategory() {
  getRepo().loadCategory( "/" ).addCategory( "testFindRulesByCatArchive",
                        "yeah" );
  AssetItem as1 = getDefaultPackage().addAsset( "testFindRulesByCategoryArch",
                         "ya",
                         "testFindRulesByCatArchive",
                         "drl" );
  getDefaultPackage().addAsset( "testFindRulesByCategoryArch2",
                 "ya",
                 "testFindRulesByCatArchive",
                 AssetItem.DEFAULT_CONTENT_FORMAT ).checkin( "version0" );
  as1.archiveItem( true );
  as1.checkin( "version0" );
  assertEquals( "drl",
         as1.getFormat() );
  List rules = getRepo().findAssetsByCategory( "testFindRulesByCatArchive", 0, -1  ).assets;
  assertEquals( 1,
         rules.size() );
  List rules1 = getRepo().findAssetsByCategory( "testFindRulesByCatArchive",
                         true, 0, -1  ).assets;
  assertEquals( 2,
         rules1.size() );
}
origin: org.chtijbug.drools/guvnor-repository

@Test
public void testGetFullPath() {
  CategoryItem root = getRepo().loadCategory("/");
  CategoryItem tagItem1 = root.addCategory("testGetFullPath", "foo");
  assertNotNull(tagItem1);
  assertEquals("testGetFullPath", tagItem1.getFullPath());
  CategoryItem childTagItem1 = tagItem1.addCategory("TestChildTag1", "foo");
  assertNotNull(childTagItem1);
  assertEquals("testGetFullPath/TestChildTag1", childTagItem1.getFullPath());
  CategoryItem childTagItem2 = childTagItem1.addCategory("TestChildTag2", "wee");
  assertNotNull(childTagItem2);
  assertEquals("testGetFullPath/TestChildTag1/TestChildTag2", childTagItem2.getFullPath());
}
org.drools.repositoryRulesRepositoryloadCategory

Javadoc

This will return a category for the given category path.

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
  • getState
    Gets a StateItem for the specified state name. If a node for the specified state does not yet exist,
  • listModuleSnapshots
    Return a list of the snapshots available for the given module name.
  • listModules
  • listModuleSnapshots,
  • listModules,
  • loadAssetByUUID,
  • loadGlobalArea,
  • loadModuleByUUID,
  • loadModuleSnapshot,
  • loadState,
  • addNodeIfNew,
  • checkForDataMigration

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • runOnUiThread (Activity)
  • setScale (BigDecimal)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Runner (org.openjdk.jmh.runner)
  • Top 17 Plugins for Android Studio
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