It's all about the answers!

Ask a question

Custom policies and default policies


Sripriya Karimpuzhasriram (134752) | asked Aug 04 '11, 1:42 a.m.
Hi,

I was writing a custom policy in which i came across a situation where i would like to re-use the logic of one of the already available default policies. Is this possible? Can one policy call another policy? If so, can you please provide me with the snippet code of how I can actually do that?

Regards,
Sripriya.

4 answers



permanent link
Gili Mendel (1.8k56) | answered Aug 05 '11, 8:58 a.m.
JAZZ DEVELOPER
Policies do not "call" other policies. If you want to re-use a function... you can extend a policy.

Which policy do you want to re-use and how?

permanent link
Sripriya Karimpuzhasriram (134752) | answered Aug 08 '11, 1:58 a.m.
I would like to write a new custom policy that will check for a particular "asset type" and will invoke the Relationship Validation Policy by passing parameters such as:

1. Operator
2. Number of related assets
3. Related Asset Type
4. Relationships

Is this possible?

permanent link
Gili Mendel (1.8k56) | answered Aug 08 '11, 11:04 a.m.
JAZZ DEVELOPER
I am not sure that I fully understood, but the following is a general guideline:

Extend the RelationshipValidationPolicy class. It is defined in the com.ibm.ram.repository.jar (you can get it from .... <wasinstall>/profiles/AppSrvxx/installedApps/RAM1WebApplication.ear/com.ibm.ram.repository.web.war/WEB-INF)


Make sure to override the getID() class.

If you need more configuration... make sure to call the super.getConfigurationDetail (Locale) ... and add to what's already there.

the parameters for that methond is defined as following.


public static final String RELATIONSHIP_FIELD = "ram_relationship_name"; //$NON-NLS-1$
public static final String RELATIONSHIP_ASSET_TYPE = "ram_relationship_asset_type"; //$NON-NLS-1$
public static final String RELATIONSHIP_ASSET_STATE = "ram_relationship_state"; //$NON-NLS-1$
public static final String RELATIONSHIP_CARDINALITY_TYPE = "ram_cardinality_type"; //$NON-NLS-1$
public static final String RELATIONSHIP_CARDINALITY_VALUE = "ram_cardinality_value"; //$NON-NLS-1$



From your test() method... you can test your asset type (use the getRelationshipTypes() method, and call super.test() as needed ... look at the result and go from there.

permanent link
Sripriya Karimpuzhasriram (134752) | answered Aug 09 '11, 8:35 a.m.
Thanks for the help! I will get back to you if I get stuck again :)

Regards,
Sripriya

Your answer


Register or to post 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.