If you wish to convert folders to categories to change the structure of Asset Bank this can be accomplished by running database statements. Before proceeding please ensure that the database is backed up so that this process can be rolled back if necessary. These instructions will move all assets into a newly created folder (as all assets must be in at least one folder) and then convert all of the original folders to categories.
All assets must be in at least one folder so before starting you should add a new folder through the front end of Asset Bank called 'Transfer' (name must be unique so if you already have an folder called transfer pick a different unique name and use it in Transfers place going forward). Then determine the ID of this new folder by running:
SELECT Id FROM CM_Category WHERE Name='Transfer' AND CategoryTypeId=2;
You will also need to determine the id of the application user by running the following...
SELECT Id FROM AssetBankUser WHERE Username='application';
Using the ID of the new folder from the first statement and the ID of the application user from the second run the following statement (replacing AL_ID with the ID of the new folder and USER_ID with the ID of the application user).
INSERT INTO CM_ItemInCategory (SELECT AL_ID, Id, '1', USER_ID from Asset);
Using the id of the new folder make sure it can't be deleted (replace NEW_ID with the actual id of the folder):
UPDATE CM_Category SET CannotBeDeleted=1 WHERE Id=NEW_ID;
The user permissions need to be removed from the folders which are now categories. Again, please run the following and replace NEW_ID with the ID of the new folder:
DELETE FROM CategoryVisibleToGroup WHERE CategoryId IN (SELECT Id FROM CM_Category WHERE Id!=NEW_ID);
Convert the actual folder entries to category entries, again replace NEW_ID with the ID of the new folder...
UPDATE CM_Category SET CategoryTypeId=1, WorkflowName=NULL, IsRestrictive=0, CanAssignIfNotLeaf=1, CannotBeDeleted=0 WHERE CategoryTypeId=2 AND Id!=NEW_ID;
Remove the unnecessary permissions from what will now be categories...
UPDATE CM_ItemInCategory SET IsApproved=NULL, LastApprovedByUserId=NULL WHERE CategoryId IN (SELECT Id FROM CM_Category WHERE CategoryTypeId=1);
If you want to ensure empty categories aren't shown on the homepage make sure the setting show-empty-categories is set to "false".
If you want to hide folders from non-admin users you would also need to set the following:
If you want to display empty folders on the homepage or browse pages set the following:
Finally, you should also edit the 'Categories' attribute (Admin > Attributes > Categories ) and tick 'Include in keyword searches' so that the folders that assets are in are also included in the search index.
- Restart Asset Bank (by restarting the Asset Bank webapp or the Tomcat service).
- Perform a reindex of existing assets (from the Admin>Attributes menu).