How to create a subCategory in RAM using Java API
I have a method which is intended to create a subcategory .. but it fails with the following error:-
com.ibm.ram.common.data.exception.RAMRuntimeException at com.ibm.ram.client.RAMSession.putCategorySchema(RAMSession.java:3776) at com.ibm.ram.client.RAMSession.put(RAMSession.java:5041) at com.cof.custom.policy.CustomPolicyUtility.categorizeSubCategoryAssets(CustomPolicyUtility.java:488) at com.cof.custom.policy.CustomPolicyUtility.manageAssets(CustomPolicyUtility.java:425) at com.cof.custom.policy.CustomPolicyUtility.main(CustomPolicyUtility.java:755) Caused by: java.lang.NullPointerException at com.ibm.ram.client.RAMSession.putCategorySchema(RAMSession.java:3666) ... 4 more Exception in thread "main" com.ibm.ram.common.data.exception.RAMRuntimeException at com.ibm.ram.client.RAMSession.putCategorySchema(RAMSession.java:3776) at com.ibm.ram.client.RAMSession.put(RAMSession.java:5041) My code goes like this :- CategorySchema categorySchema = session.getCategorySchema(CustomPolicyConstants.BUSINESS_CAPABILITY_CATALOG); RAMCategory bcCategory = (RAMCategory)categorySchema.getCategory(CustomPolicyConstants.BUSINESS_CAPABILITIES_ASSET_TYPE); SubCategory subCategory = bcCategory.createSubCategory("NewSubCategory4"); getRAMSession().put(categorySchema, new RAMStatusMonitor()); Can anyone please shed light on this and let me know what am I doing wrong? Thanks in advance for all your help. |
11 answers
a) The entire name of the jar that starts with the name com.ibm.ram.common?
Ans. The full name of the jar is com.ibm.ram.common_7.5.11.v20121127_0009 b) Are there any files in this directory labeled something like testfix12RamClient.xml? What are they named? Ans. No. c) Open the ramclient.jar and go to the META-INF\MANIFEST.MF file and tell me what the Created-By: entry in the manifest says? Ans. IBM Rational CCB, build RAM7512-I20121126_1908 Comments Ah, you are using an internal build that has never been published. I'm not sure why it is failing.
Did you do a session.release() somewhere between the
|
But the sub-category ultimately shows up in the catalog schema hierarchy when I create an asset under that newly created sub-category. But is should show up after I create the sub-category.
|
Should I be using a different build which was already published?
May I know the benefits of using a published build? I have not done any session.release() anywhere in the code. |
This is the code that I am using
/** * */ package com.cof.custom.policy; import com.ibm.ram.client.RAMAsset; import com.ibm.ram.client.RAMAssetQueryBuilder; import com.ibm.ram.client.RAMCategory; import com.ibm.ram.client.RAMCategorySchema; import com.ibm.ram.client.RAMSession; import com.ibm.ram.client.RAMSubCategory; import com.ibm.ram.client.status.RAMStatusMonitor; import com.ibm.ram.common.data.AssetSearchResult; import com.ibm.ram.common.data.Relationship; import com.ibm.ram.common.data.SearchResult; /** * @author fvz857 * */ public class TestCreateSubCategory { public static RAMSession getRAMSession() { RAMSession session = new RAMSession("https://10.42.102.20:11602/ram.ws","fvz857", "fvz857"); return session; } public static void categorizeSubCategoryAssets() { RAMCategorySchema categorySchema = getRAMSession().getCategorySchema(CustomPolicyConstants.BUSINESS_CAPABILITY_CATALOG); RAMCategory bcCategory = (RAMCategory)categorySchema.getCategory(CustomPolicyConstants.BUSINESS_CAPABILITIES_ASSET_TYPE); RAMSubCategory sub = (RAMSubCategory) bcCategory.getSubCategory("Manage Delinquencies"); RAMSubCategory subCategory = sub.createSubCategory("New Delinquencies"); getRAMSession().put(categorySchema, new RAMStatusMonitor()); } public static void main(String z[]){ categorizeSubCategoryAssets(); } } Comments public static RAMSession getRAMSession() {
|
Thank you so much for your help. It works and I am not getting the NPE. But the newly-created sub-category does not show-up in the catalog hierarchy. What else do I need to do to achieve that?
Comments I don't know what that means. What is the "catalog hierarchy" and how are you getting it?
|
It is the view that is available on RAM Web Client when searching for an asset. The left-side of the screen provides a "Visual Browse" view which can be used to browse to a particular asset.
The search can be filtered by either Category or Type or State or Community. When the user clicks on "Category", the category hierarchy is displayed. Category Software Development Kind Process[1] Schema[1] Service[1] Web Application[3] I was referring the above structure as the "Category schema" hierarchy. My requirement is that when the user creates a subcategory, that should show up on this hierarchy in the current location.i.e. under the correct category or subcategory. Comments That is a cached view. It is refreshed approximately once every ten minutes.
My understanding is that the category is missing from the visual browse. Does it show up on the search page when you drill down to it?
|
Thanks for your help. Yes, I have checked the schema pages and verified that the category schema is updated but still not able to see the subcategory in the left view.
To do that I am going to Administration -> Category Schema to check the "update" column in the resulting view. Do you think that there are any filters that is set which is preventing the subcategory from getting displayed ? However, when I try to create a new Asset, it shows up in the "Available categories" tree under the "Categories" tab. After an asset is created under the newly created subCategory, then it shows up on the left side Category Schema view. Can there be any settings which determines that if there are no assets created under a sub-category, then that subCategory will not be displayed? Please help. Comments For Visual Browse top category to show up there must be at least one asset that has some child node of the category assigned to it. Until then nothing shows. But once there is at least one then it will show them all. BUT you need to close the visual browser after making the change. The categories for the visualbrowse are only retrieved once, when the browser is started. You need to close and reopen it to see the new sub-category.
|
So, I am trying to categorize the subcategory asset object with the newly created sub-category to be compliant with the fact that "there must be at least one asset that has some child node of the category assigned to it."
But it fails with the following error :- Exception in thread "main" com.ibm.ram.common.data.exception.RAMRuntimeException: Subcategory Business Capability Catalog/Business Capabilities/Move Money & Process Payments/My Buss Cap Asset5 was not found for the asset My Buss Cap Asset5[1.0]. at com.ibm.ram.client.RAMAsset.categorize(RAMAsset.java:2300) at com.cof.custom.policy.CustomPolicyUtility.createUpdateSubCategory(CustomPolicyUtility.java:531) at com.cof.custom.policy.CustomPolicyUtility.categorizeSubCategoryAssets(CustomPolicyUtility.java:493) at com.cof.custom.policy.CustomPolicyUtility.manageAssets(CustomPolicyUtility.java:424) at com.cof.custom.policy.CustomPolicyUtility.main(CustomPolicyUtility.java:849) My program is as follows:- public static void createUpdateSubCategory(RAMCategory category, RAMSubCategory subCategory, RAMAsset assetObj){ RAMSubCategory matchedCategory = null; if(!isAssetExistsInCategory(subCategory, assetObj)){ matchedCategory= subCategory.createSubCategory(assetObj.getName()); try{ assetObj.categorize(category, subCategory.getName() + "/" + assetObj.getName()); }catch(Exception e){ assetObj.categorize(matchedCategory); } session.put(assetObj, new RAMStatusMonitor()); session.put(categorySchema, new RAMStatusMonitor()); }else{ matchedCategory = (RAMSubCategory)subCategory.getSubCategory(assetObj.getName()); assetObj.categorize(matchedCategory); session.put(assetObj, new RAMStatusMonitor()); } session.release(); } Thanks in advance for your help. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
What is the exact version of the RAM client that you are using? I can't find out which version that the line numbers shown match up with.