10 Access Oracle JET Metadata

Use the metaLib utility library when you need to access Oracle JET audit metadata.

The utility methods in metaLib (metadata access library) provided by Oracle JAF insulate the rule writer from changes to the format of the metadata.

This audit rule example from the built-in JAF rule set illustrates the usage of metaLib by checking for deprecated components.

function register()
{
  // 'ojtag' signifies that the element name starts with 'oj-'
  return { ojtag : function(ruleCtx, tagName)
                   {
                     let issue, suggestion;
                     const metaLib = context.utils.metaLib;
 
                     // true if the <oj-xx> name represents a JET built-in component
                     if (! ruleCtx.ojTag) { return ; }
                     // method returns the suggested alternative if deprecated
                     suggestion = metaLib.isTagDeprecated(tagName);
                     if (suggestion !== null)
                     {
                       issue = new ruleCtx.Issue(`<${tagName}> is DEPRECATED! : ${suggestion}`);
                       ruleCtx.reporter.addIssue(issue, ruleCtx);
                     }
                   }
        };
};