• Rename file names to include categories

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #47536  by skreisel
 
Hi there.

Wanted to check out if this is at all possible, before I start to learn Java... Am using the latest COMMUNITY version.

Use case is: rename a document to append the documents name with categories, including their parents, as in:

filename = "xyz.pdf"
categories = "a" "b/b1" "c/c1/c2"
result then is = "xyz [a b_b1 c_c1_c2].pdf"

There has been a bit on scripting and renaming on this forum previously viewtopic.php?t=21830.

Wondering because:
  • Be possible at all, because the categories and their parents may not be exposed?
  • Output not parsable via scripting, to e.g. get rid of backslashes to make names filesystem congruent?
BTW: I know that one can customize thesaurus(es). But is it possible to import categories and their structures via e.g. text files - or via database; manually adding categories and their structures may be somewhat tedious?

Cheers

Stefan
 #47552  by jllort
 
Should be added an automation event when you assign category to a node. I can give you the clues about how doing it in the source code.
 #47562  by jllort
 
I think the easies is understanding one event and then follow same steps in the addCategory method.

Folder creation event analysis:
* In AutomationRule.java class you have the event definition https://github.com/openkm/document-mana ... nRule.java
* DbFolderModule are set the events what call automation ( 2 lines involved )
https://github.com/openkm/document-mana ... e.java#L97
https://github.com/openkm/document-mana ... .java#L106

You might understanding these lines:
Code: Select all
// AUTOMATION - PRE
Map<String, Object> env = new HashMap<String, Object>();
env.put(AutomationUtils.PARENT_UUID, parentUuid);
env.put(AutomationUtils.PARENT_PATH, parentPath);
env.put(AutomationUtils.PARENT_NODE, parentFolder);
AutomationManager.getInstance().fireEvent(AutomationRule.EVENT_FOLDER_CREATE, AutomationRule.AT_PRE, env);
parentFolder = (NodeFolder) env.get(AutomationUtils.PARENT_NODE);

// Create node
NodeFolder fldNode = BaseFolderModule.create(auth.getName(), parentFolder, name, fld.getCreated(), new HashSet<String>(),
		new HashSet<String>(), new HashSet<NodeProperty>(), new ArrayList<NodeNote>(), null);

// AUTOMATION - POST
env.put(AutomationUtils.FOLDER_NODE, fldNode);
AutomationManager.getInstance().fireEvent(AutomationRule.EVENT_FOLDER_CREATE, AutomationRule.AT_POST, env);
The key is that between this method and automation you are sharing variables into environment Map. This environment map will be used later for automation events ( actions and validations ). I suggest you undestanding these two clases
AddKeyword.java -> https://github.com/openkm/document-mana ... yword.java
PathContains.java -> https://github.com/openkm/document-mana ... tains.java
AutomationsUtils.java -> https://github.com/openkm/document-mana ... Utils.java

In your case you should add the event into the class DBpropertyModule in the line 82 https://github.com/openkm/document-mana ... e.java#L82

I suggest debug current implementation, for example ( folder and document creation ) and if you understand how the code works you can quickly extend the current code.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.