0% found this document useful (0 votes)
324 views

API Dev Guide

API developer's guide is confidential, unpublished property of Fair Isaac corporation. Information in this document is subject to change without notice. If you find any problems in this documentation, please report them in writing.

Uploaded by

zeller2010
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
324 views

API Dev Guide

API developer's guide is confidential, unpublished property of Fair Isaac corporation. Information in this document is subject to change without notice. If you find any problems in this documentation, please report them in writing.

Uploaded by

zeller2010
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

BestPractices

API DEVELOPERS GUIDE

6.5

Fair Isaac Blaze Advisor


API Developers Guide

This document is the confidential, unpublished property of Fair Isaac Corporation. Receipt or possession of it does not convey rights to divulge, reproduce, use, or allow others to use it except as expressly provided in the license agreement between user and Fair Isaac Corporation. The information in this document is subject to change without notice. If you find any problems in this documentation, please report them to us in writing. Fair Isaac Corporation does not warrant that this documentation is error-free, nor are there any other warranties with respect to the documentation except as may be provided in the license agreement. 2005-2008 Fair Isaac Corporation. All rights reserved. Fair Isaac is a registered trademark of Fair Isaac Corporation in the United States and may be a trademark or registered trademark of Fair Isaac Corporation in other countries. Other product and company names herein may be trademarks of their respective owners. Blaze Advisor business rules management system is covered by Fair Isaac U.S. Patents: 6865566, 6965889, 66968328, 6944604, and others listed in Fair Isaac documentation.

Product Name: Blaze Advisor 6.5 for Java - Service Pack 5 Last Revised 12/20/2007 Version 6.5 Template LG5.0

Fair Isaac Confidential and Proprietary Information

Contents

Contents

CHAPTER 1

ROM and PROM APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

TheRepositoryObjectModel(ROM)...................................................7 ConnectingtoaRepository.........................................................7 ExploringtheROMModel..........................................................8 RepositoryItemTypingAttributes...................................................8 ProjectRepositoryObjectModel(PROM) ...............................................9 ThePROMProject(NdPromProject) .................................................9 ExploringthePROMModel .......................................................10 PROMItemContent(NdPromItemContent) ............................................11 NdPromEntity(anditssubinterfaces)...............................................11 NdPromTemplate................................................................12 NdPromInstance.................................................................12 NdPromProvider .................................................................12 EntityObjectModel .................................................................12 AccessingEntityContent ..........................................................12 SRLEntityObjectModel ..........................................................14 RuleflowObjectModel ............................................................15 QuestionSetObjectModel.........................................................15 CommonROMAPIandPROMAPITasks .............................................15 SpecifyingaLocation(NdLocation) .................................................15 CreatingDirectories ..............................................................16 CreatingaPROMProject..........................................................17 LoadingaPROMProject ..........................................................18 CreatinganSRLRuleset ...........................................................18 CreatinganSRLFunction(NdPromSrlFunction)......................................20 CreatingaRuleflow(NdPromFlowRuleflow) ........................................21 CreatingaQuestionSet(NdPromAaiQuestionSet) ....................................22 CreatinganSRLClass(NdPromSrlClassContent) .....................................23 CreatinganSRLEnumeration(NdPromSrlEnumerationContent).......................24
CHAPTER 2

Metaphor APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

LoadingaMetaphorInstance.........................................................25 CreatingaMetaphorModel ..........................................................25 DecisionTableEditingAPI...........................................................26 Example:DisplayanOverviewofaDecisionTable ...................................28 DecisionTreeEditingAPI............................................................28 Example:CreateaSubtree.........................................................30 ScoreModelEditingAPI.............................................................31 Example:ListContentsofaScoreModel ............................................34

Fair Isaac Confidential and Proprietary Information

Contents

CHAPTER 3

Custom Provider API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

ResponsibilitiesofProviderClasses.................................................... 37 OverviewoftheCustomProviderAPI ................................................. 38 NdTemplateValueProviderInterface............................................... 38 NdDefaultTemplateValueProvider ................................................. 39 NdConstrainedListProviderInterface............................................... 39 NdDefaultConstrainedListProvider................................................ 40 NdDesignProviderInterface ...................................................... 40 NdProvidesDefaultValueInterface ................................................. 41 CreatingCustomProviderClasses..................................................... 41 SimpleValueListProvider ........................................................ 42 SimpleSRLandDisplayListProvider.............................................. 43 CustomizingProviderBehaviorUsingArguments................................... 45 DefiningArgumentDescriptors................................................. 46 ProcessingArguments......................................................... 49 TheExampleBaseClass.............................................................. 50 CustomProviderImplementationGuidelines ........................................... 51
CHAPTER 4

............................................. RMA API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

TheRMARepository(NdRmaRepository) .............................................. 53 RMAProject(NdRmaProject) ..................................................... 54 RMAEntry(NdRmaEntry)........................................................... 56 RMADirectory(NdRmaDirectory).................................................... 57 RMAFiles.......................................................................... 57 File(NdRmaFile) ................................................................ 58 ProjectFile(NdRmaProject) ....................................................... 58 TemplateFile(NdRmaTemplateFile)............................................... 58 InstanceFile(NdRmaInstanceFile)................................................. 58 EditableFile(NdRmaEditableFile)................................................. 59 FileContent(NdRmaFileContent)..................................................... 59 RMATemplate(NdRmaTemplate) ................................................. 59 RMAInstance(NdRmaInstance) ................................................... 60 DisplayingtheContentsofanInstance........................................... 61 EditingtheContentsofanInstance.............................................. 61 InstanceElementNode(NdInstanceElementNode)...................................... 62 Versioning ......................................................................... 63 VersioningOperations(NdRmaEntryVersioningOperations).......................... 64 VersioningInformation(NdRmaEntryVersioningInfo)................................ 64 RMAQuery........................................................................ 65 QueryInstance(NdRmaQueryInstance) ............................................ 65 QueryResults(NdRmaQueryResultItem) ........................................... 66 EntryExclusionFilter(NdRmaEntryExclusionFilter) ..................................... 66
CHAPTER 5

Base Repository and Version Management APIs . . . . . . . . 69

StorageLayerInterfaces.............................................................. 69 AbouttheWorkspace ................................................................ 69 VersionManagementClientInterfaces ................................................. 70 VersionManagementSystemInterfaces ................................................ 71

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

AdministrationInterfaces ............................................................71 RepositoryConnections .............................................................71 RepositoryConfigurations...........................................................72 RepositoryEntryFilters..............................................................72

Fair Isaac Confidential and Proprietary Information

Contents

Fair Isaac Confidential and Proprietary Information

CHAPTER 1

ROM and PROM APIs


TheROMandPROMAPIsallowyoutoprogrammaticallyread,modifyandcreate entriesintherepository.YoucanusetheAPIstonavigatearepository,modifyorcreate aproject,createdirectoriesandaddthemtoaproject,inspectandmodifythecontents ofarepositoryitem,createfixedentities,andperformvariousversioningoperations. ThePROMAPIprovidestheabilitytoloadtemplatesandprovidersandtoload,create, andmodifyinstances.ThePROMAPIalsosupportstheabilitytoprogrammatically createandmodifyentitieswithfixedcontent.Thetermfixedcontent,asusedinthis chapter,signifiesthatanentityscontentdoesnotcontaindynamicelementslike placeholders. TheEntityCreationexamplecontainsJavacodewhichdemonstrateshowtousethe ROMandPROMAPIstocreateanamedobjectandaddittoanexistingproject;aswell ashowtocreateanewprojectwithseveralentities.Theexampleislocatedin
<ADVISOR_HOME>/examples/ExamplesRepository/API Examples/PROM API/ Entity Creation.

The Repository Object Model (ROM)


TheRepositoryObjectModel(ROM),isalayerthatisusedtoaccesstherepositorys rawdata.ROMmodelstherepositorywithitshierarchyofdirectoriesanditemswithin thedirectories.Itdefinestypingforrepositoryitems.ROMprovidesmethodsfor connectingtotherepository,navigatingandfindingitemsintherepository,aswellas forreadingandwritingitems.ROMaccessesitemsonlyasrawdata,whichare representedasstrings.Allreadandwriteoperationsaccesstherepositorydirectly, ratherthanbeingcached.

Connecting to a Repository
TheNdRomConnectionManagerinterfaceprovidesmethodstoconnectanddisconnect fromarepository.PassanNdWorkspaceConnectionobjecttothe newRepositoryConnectionManager()methodofNdRomFactorytoobtainan NdRomConnectionManagerinstance.Theconnectioncontext(NdRomConnectionContext) isusedtoaccessROMonceyouareconnected. Theexamplecodebelowshowshowtoobtainaconnectiontoafilebasedrepository.
//NdFileRepositoryConnection extends NdWorkspaceConnection NdFileRepositoryConnection connection = new NdFileRepositoryConnection(); // Change the path to the repository as appropriate. The repository should exist.

Fair Isaac Confidential and Proprietary Information

CHAPTER 1: ROM and PROM APIs

connection.setRepositoryFolder("C:/repository"); // Connect to repository NdRomConnectionManager connectionMgr = NdRomFactory.newRepositoryConnectionManager(connection); connectionMgr.connect(); NdRomConnectionContext conContext = connectionMgr.getConnectionContext(); NdRomDirectory romRoot = conContext.getRoot();

Todisconnectfromtherepository,callthedisconnect()methodof NdRomConnectionManager.Toshutdowntheconnectionmanager,callitsshutdown() method.

Exploring the ROM Model


Theorganizationoftherepositoryissimilartothatofafilesystem.Itcontainsa hierarchyofdirectorieswithasinglerootdirectory.Directoriescontainitemsandother directories.Arepositoryitem,likeafileinafilesystem,hascontentbutdoesnot containotheritemsordirectories.Directoriesanditemsarebothrepositoryentries.This relationshipisrepresentedintheROMAPIwiththeclassesNdRomDirectoryand NdRomItem,whichbothextendNdRomEntry. AclientcanexploretheROMstartingfromtherootdirectory,whichcanbeobtainedby callingthegetRoot()methodonNdRomConnectionContext.Fromtheroot,oranyother directory,youcancallgetEntries()togetalldirectoriesanditemscontainedinthe directory.
// connContext is an NdRomConnetcionContext // romRoot is the root directory of the repository. NdRomDirectory romRoot = connContext.getRoot(); NdRomEntry[] allEntriesInRepository = romRoot.getEntries();

Ifyouknowthelocationofarepositoryitem,youcanlookuptheentrybycalling lookupEntry(NdLocation)onthedirectory.Thelocationisspecifiedfromtheroot directory.NdLocationisdiscussedinSpecifyingaLocation(NdLocation)onpage15.


NdLocation itemLocation = NdLocationFactory.createLocation( "/Prom API Example/Cross-sell Rules/crossSell"); NdRomItem rulesetItem = (NdRomItem) romRoot.lookupEntry(itemLocation);

Repository Item Typing Attributes


Arepositoryschemaelementdescribesaparticulartypeofrepositoryitem.Thetyping informationconsistsoffourattributes:theschemaelementtype,itssubtype,content type,andtarget.Thetypesignifiesthenatureoftheitem;anSRLruleset,forexample.A subtypeisasubcategoryofthetype.Forexample,adecisiontableisasubtypeofan SRLruleset.Thecontenttypespecifieswhethertheitemcontainsfixedcontent,orisa template,oraprovider,orisaninstanceoftheindicatedtypeandsubtype.Thetarget indicatesthepurposeoftheitem.AnitemusedinarulesprojecthasanSRLtarget.An itemusedforrepositoryoperationshasaRepositorytarget. Hereisalistofrepositoryitemsandtheirtypinginformationbytype,subtype,content type,andtarget.

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

Decision Tree Template: SRL ruleset, Decision tree, Template, SRL Decision Tree Instance: SRL ruleset, Decision tree, Instance, SRL Ruleset Template Instance: SRL Ruleset, No subtype, Instance, SRL SRL Class: SRL Class, No subtype, Fixed, SRL SRL Function with Fixed Content: Function, No subtype, Fixed, SRL Custom Date Provider: Date, No subtype, Provider, SRL Project: Project, No subtype, Fixed, Repository

IntheROM,thefourtypingattributesareaggregatedintoNdRomSchemaElementInfo, whichisaccessedfromNdRomSchemaElement.Theschemaelementsaremanagedby NdRomSchemaManager.Itcontainsalistofallschemaelementsknowntotheconnected repositoryandcanlookuptheschemaelementforanyrepositoryitem. NdRomSchemaManagerisobtainedfromNdRomConnectionContext. Thiscoderetrievesthetypeandsubtypeattributesofarepositoryitem.


// connContext is an NdPromConnectionContext & rulesetItem is an NdRomItem NdRomSchemaManager schemaManager = connContext.getSchemaManager(); NdRomSchemaElement schemaElement = schemaManager.lookup(rulesetItem); NdRomSchemaElementInfo info = schemaElement.getSchemaElementInfo(); int type = info.getType(); int subtype = info.getSubType();

NdRomSchemaManagerisalsousedtoobtainanNdRomSchemaElementofaparticulartype. YoucanobtainaninstanceofNdPromItemFactoryfromtheschemaelementwhichisthe factoryassociatedwiththatparticulartypeofrepositoryitem.Thefactorycanbeused tocreateanNdPromIteminaprojectfromentitycontent.


/ project is an NdPromProject NdPromSrlEnumerationContent enumeration = NdPromBomConstructContentFactory.newSrlEnumerationContent(project); NdRomSchemaElement schemaElement = schemaManager.lookupSchemaElement( TYPE_SRL_ENUMERATION, SUB_TYPE_NONE, CONTENT_TYPE_FIXED, TARGET_SRL); NdPromItemFactory factory = schemaElement.getItemFactory(); NdPromItem enumItem = factory.newItem((NdPromEntity)enumeration, project); ...

Theintegerconstantsfortherepositoryschematypingattributes,includingthoseinthe codeabove,aredeclaredintheNdRomSchemaConstantsinterface.

Project Repository Object Model (PROM)


TheProjectRepositoryObjectModel(PROM),isalayerontopoftheROMthatisused toaccesstheobjectsinarepositorywithaprojectincontext.Thecontentofarepository itemisrepresentedasanobject.Thecontentisalsocachedinmemory,whichmeans explicitloadandsaveoperationsarenecessarytosyncupthecontentinmemoryand thatinstorage.

The PROM Project (NdPromProject)


Aproject,representedbyNdPromProject,bydefinitionincludesacollectionof referencestorepositorydirectoriesandotherprojectswhicharesubprojectsofthe

Fair Isaac Confidential and Proprietary Information

CHAPTER 1: ROM and PROM APIs

project.Suchadefinitioneffectivelydefinesascope,whichincludesallthedirectories includedbythisproject,andallthedirectoriesincludedbyitssubprojects.Aninstance ofNdPromProjectgivesaccesstoalltherepositoryentriesinthescope.Theserepository directoriesandrepositoryitemsandtheircontentsformthePROM. TocreateaninstanceofNdPromProjectforanexistingprojectrepositoryitem,first obtainaninstanceofNdRomProjectbypassingthelocationoftheprojectrepositoryitem tothelookupEntry()methodoftheNdRomDirectoryinterface.Use NdPromProjectFactory,whichisobtainedfromNdRomConnectionContext,tocreatethe NdPromProjectinstance.ThecodebelowloadsaPROMprojectfromtheworkspace.


// connContext is an NdRomConnectionContext // /directory represents a directory directly under the repository root NdRomDirectory root = connContext.getRoot(); NdLocation location = NdLocationFactory.createLocation(/directory/projectItem); NdRomProject romProject = (NdRomProject)root.lookupEntry(location); NdPromProjectFactory factory = context.getProjectFactory(); NdPromProject project = factory.createProject(romProject);

Tocreateanewprojectatalocation,theclientshouldusethesameprojectfactory.The followingisanexampleofcreatinganewproject.Thenewprojectrepositoryitemis createdinthedirectory.


NdLocation location = NdLocationFactory.createLocation(/directory); NdPromProjectFactory factory = context.getProjectFactory(); NdPromProject project = factory.createProject(location); project.save();

ThetopicsofloadingandcreatingaprojectarediscussedingreaterdetailinLoadinga PROMProjectonpage18andCreatingaPROMProjectonpage17.
NdPromProjectonlydefinesascope.Itisnotspecifictoanydomain.Ithasa subinterfaceNdPromRulesProject,whichcanprovideadditionalinformationand servicesspecifictotherulesdomain.

Exploring the PROM Model


UsingthegetDirectories(),getSubProjects(),andlookupEntry()methodsdefined inNdPromProject,theclientcanexplorethePROM.Therepositorydirectoryand repositoryiteminthePROMaredefinedasNdPromDirectoryandNdPromItem,which extendfromNdRomDirectoryandNdRomItem,respectively. ThePROMAPIbuildsontherawaccesstotherepositorywhichisdefinedinROMAPI byprovidingaccesstotherepositorywithtypingandcaching.ThegetItemContent() methodinNdPromItemreturnsatypedobject.ThisisdifferentfromNdRomItemwhich hascontentthatisalwaysaString. ThecontentofarepositoryitemisonlyloadedafterthegetItemContent()methodis called.Thecontentisloadedtocache.Onceloaded,anychangetothecontentisnot persistedtothestorageuntilthesave()methodofNdPromItemiscalled.Anychangein thestorageisnotreflectedintheloadedcontentuntilrevert()iscalledand getItemContent()iscalledagaintoloadthecontentfromstorage.

10

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

TheaddItem()methodandremoveItem()methodinNdPromDirectoryonlyaffectthein memoryobjectmodeluntilthesave()methodiscalledontheNdPromItem. Thefollowingisanexampleofloadingarepositoryitem:


// project is an NdPromProject NdLocation location = NdLocationFactory.createLocation(item/location); NdPromItem item = (NdPromItem)project.lookupEntry(location); NdPromItemContent content = item.getItemContent();

Hereisanexampleofcreatingarepositoryitemandaddingittoaprojectdirectory.
// project is an NdPromProject NdLocation location = NdLocationFactory.createLocation(directory); NdPromDirectory directory = (NdPromDirectory)project.lookupEntry(location); NdPromItem item = factory.newItem(content, project); directory.addItem(item); item.save();

NotethatcontentisaspecifictypeofNdPromItemContent,suchasthe NdPromEnumerationContentdiscussedinRepositoryItemTypingAttributesonpage 8.factoryisthespecificNdPromItemFactoryassociatedwiththatparticulartypeof repositoryitem,whichisdiscussedinthesamesection.RefertoCommonROMAPI andPROMAPITasksonpage15forseveralmoreexamplesofcreatingrepository items.directoryisanNdPromDirectorythathasbeenpreviouslyaddedtotheproject, asdescribedinCreatingDirectoriesonpage16. Thefollowingisanexampleofdeletinganexistingrepositoryitem.Notethattheitemis removedinPROMandthensavedinordertopersistthechangetostorage.


// project is an NdPromProject NdLocation parentLoc = NdLocationFactory.createLocation(directory/item); NdPromDirectory directory = (NdPromDirectory)project.lookupEntry(parentLoc); NdLocation itemLoc = NdLocationFactory.createLocation(item/location); NdPromItem item = (NdPromItem)project.lookupEntry(itemLoc); directory.removeItem(item); item.save();

PROM Item Content (NdPromItemContent)


NdPromItemContentisthecontentofarepositoryitem.Aninstanceofthisinterface representswhatthecontentreallyisdisregardingitspersistentformat.Forexample,if thecontentisanSRLruleset,thecontentobjectisaninstanceofNdPromSrlRuleset althoughitmayactuallybepersistedasatemplate.(FromtheAPIReferenceentryfor the NdPromItemContentinterface.TheAPIReferenceisavailablebyselectingAPI ReferencefromtheBuilder Helpmenu.)

NdPromEntity (and its sub-interfaces)


Ifthecontentoftherepositoryitemisanentity,thecontentobjectmustbeaspecific instanceofNdPromEntity.Forexample,ifthecontentoftherepositoryitemisanSRL function,thecontentobjectisaninstanceofNdPromSrlFunction,whichextends NdPromEntity.

Fair Isaac Confidential and Proprietary Information

11

CHAPTER 1: ROM and PROM APIs

MoredetailsoftheentityAPIcanbefoundinEntityObjectModelonpage12.

NdPromTemplate
IfthecontentoftherepositoryitemisanInnovatortemplateofanentity,thecontent objectmustbeanNdPromTemplateobject.NdPromTemplategivestheclientaccesstothe templatizedentitythroughgetEntityContent()method,whichreturnsaspecific instanceofNdPromEntityContent.Forexample,ifthecontentoftherepositoryitemis anInnovatortemplateofanSRLruleset,getEntityContent()methodreturnsan instanceofNdPromSrlRulesetContent,whichextendsNdPromEntityContent.

NdPromInstance
Ifthecontentoftherepositoryitemisaninstanceoftemplate,thecontentobjectmustbe anNdPromInstanceobject.NdPromInstancegivestheclientaccesstotheinstantiation objectmodel,i.e.,atreeofinstancenodes.Itallowsaccesstotheentityresolvedfrom thisinstanceanditslinkedtemplate.Theresolvedentitycanbeobtainedthrough getResolvedEntity()method,whichreturnsaspecificinstanceofNdPromEntity.For example,ifthecontentoftherepositoryitemisanInnovatorinstanceofanSRLruleset, getResolvedEntity()returnsaninstanceofNdPromSrlRuleset,whichextends NdPromEntity.

NdPromProvider
Ifthecontentoftherepositoryitemisaprovider,thecontentobjectmustbean NdPromProviderobject.NdPromProvidergivesclientaccesstotheprovidersdefinition, includingtheproviderclassname.

Entity Object Model


Theentityobjectmodelisusedtoaccessentitiesandtheirfields.Asdescribedin PROMItemContent(NdPromItemContent)onpage11,anentitycanbeobtainedas thecontentofanentityrepositoryitemloadedasanobjectinPROM.Anentitycanalso beobtainedasthetemplatizedcontentofanInnovatortemplateandastheresolved contentofanInnovatorinstance.

Accessing Entity Content


Theentityobjectmodelcontainstwocomplementarysetsofinterfacesforaccessingthe contentofentities.TheAPIReferencereferstothesesetsofclassesastheentityobject modelsstringbasedandcontentbasedAPIs. TheinterfacesofthestringbasedAPIrepresentanyfieldthatistextinnatureasa String.Thissetofinterfacesisusedtoaccessentitiesthatarenottemplatized,butare resolvedentities.Itprovidesreadonlyaccess.Itisprimarilyusedforinspectingthe objectmodel. TheinterfacesofthecontentbasedAPIrepresentanyfieldthatistextinnatureby NdPromTextContent,whichisadatastructurethatmaycontaindynamicelementslike

12

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

placeholders.ThesubinterfacesofNdPromTextContentrepresentspecializedtext content.Forexample,thebodyofanSRLfunctionisrepresentedby NdPromSrlBodyTextContent.ThecontentbasedAPIisusedtoaccesstemplatized entities.Itprovidesmethodstoreadandwritethecontentofbothtemplatizedand fixedcontententities. ThesetwosetsofAPIsarealmostparalleltoeachother.Thenamingconventionisthat theinterfacenamesandmethodnamesinthecontentbasedAPIhavethewordContent appendedtotheircounterpartsinthestringbasedAPI.Forexample,thecontentbased counterparttothestringbasedinterfaceNdPromSRLRulesetis NdPromSRLRulesetContent.NdPromSrlRuleisthestringbasedcorrelaryto NdPromSrlRuleContent,andsoon. Thefollowingcodedemonstrateshowtoaccessarulesetusingstringbasedinterfaces. ArulesetisrepresentedbythestringbasedNdPromSrlRulesetinterface.Themethod getName()returnstherulesetnameasaString.
// item is an NdPromItem NdPromSrlRuleset ruleset = (NdPromSrlRuleset) item.getItemContent(); String name = ruleset.getName();

ThegetSrlRulesetItems()methodreturnstherulesetitemsasanarrayof NdPromSrlRulesetItem.
NdPromSrlRulesetItem[] items = ruleset.getSrlRulesetItems();

AnSRLrule(NdPromSrlRule)isobtainedfromthearrayofrulesetitems.NdPromSrlRule andtheothertypesofrulesetitems,suchasNdPromSrlPattern,subclass NdPromSrlRulesetItem.


// assumes the ruleset item is a rule NdPromSrlRule rule = (NdPromSrlRule) NdPromSrlRulesetItem[0];

Therulebody(NdPromSrlRuleBody)isobtainedfromaruleinarulesetthatisnot templatizedusingthegetSrlRuleBody()method.
NdPromSrlRuleBody ruleBody = rule.getSrlRuleBody();

Hereiscodewhichperformssimilarworkusingthecorrespondingcontentbased interfaces.TherulesetnameisobtainedasanNdPromTextContentobject. NdPromSrlRuleContentextendsNdPromSrlRuleContentandrepresentsanSRLrule whichcouldbeeithertemplatizedorcontainfixedcontent.Similarly,the NdPromSrlRuleBodyTextContentruleBodycancontaintemplatizedcontentorfixed content.


// item is an NdPromItem NdPromSrlRulesetContent ruleset = (NdPromSrlRulesetContent) item.getItemContent(); NdPromTextContent name = ruleset.getNameContent(); NdPromSrlRulesetItemContent[] items = ruleset.getSrlRulesetItemContents(); // assumes the ruleset item content is a rule NdPromSrlRuleContent rule = NdPromSrlRulesetItemContent[0]; NdPromSrlRuleBodyTextContent ruleBody = rule.getRuleBodyContent();

Asalreadymentioned,thecontentbasedAPIcontainsmethodsforcreatingand modifyingtheentitycontent.UsethestaticnewTextContent()methodofthe

Fair Isaac Confidential and Proprietary Information

13

CHAPTER 1: ROM and PROM APIs

NdPromTextContentFactoryclasstocreateNdPromTextContentfortextbasedentity propertiessuchasnameandcomment.
ruleset.setNameContent (NdPromTextContentFactory.newTextContent("Ruleset name"); rule.setNameContent (NdPromTextContentFactory.newTextContent("Rule name"); rule.setCommentContent (NdPromTextContentFactory.newTextContent("// Sample rule");

ThisexampleusesthestringbasedAPItofindaparticularruleinaruleset,thenitcasts theruletoanNdPromSrlRuleContentobject,whichiscontentbased,inordertochange therulebodycontent.


// project is an NdPromProject NdLocation rulesetLocation = NdLocationFactory.createLocation("Cross-sell Rules/crossSell"); NdPromItem rulesetPromItem = (NdPromItem)project.lookupEntry(rulesetLocation); NdPromSrlRuleset ruleset = (NdPromSrlRuleset) rulesetPromItem.getItemContent(); NdPromSrlRulesetItem[] rulesetItems = ruleset.getSrlRulesetItems(); for (int i=0; i<rulesetItems.length; i++) { if (rulesetItems[i] instanceof NdPromSrlRule) { String ruleName = ((NdPromSrlRule)rulesetItems[i]).getName(); if (ruleName.equals("rule1")) { // The string-based NdPromSrlRulesetItem ruleset item is cast to // content-based interfaces are used exclusively. NdPromSrlRuleContent rule = (NdPromSrlRuleContent) rulesetItems[i]; // replace rule text NdPromSrlRuleBodyTextContent ruleBody = NdPromSrlConstructContentFactory.newSrlRuleBodyContent("rule body replacement text"); rule.setSrlRuleBodyContent(ruleBody); // print new rule text NdPromSrlRuleBodyTextContent ruleBodyTextContent = rule.getSrlRuleBodyContent(); System.out.println("The replacement rule body text is + ruleBodyTextContent.generate()); } } }

SRL Entity Object Model


TheobjectmodelforSRLentitiesisinthe
com.blazesoft.template.repository.objects.rules package.Itcontainsthe

interfacesfortheSRLentitiesaswellasvariousconstructsliketheexpressionsand statements. TheSRLentitiesinclude: SRLruleset(NdPromSrlRuleset) Therulesetitemswithinaruleset(NdPromSrlRulesetItem),whichare: SRLrule(NdPromSrlRule) SRLeventrule(NdPromSrlEventRule) SRLnamedobject(NdPromSrlNamedObject) SRLpattern(NdPromSrlPattern) SRLvariable(NdPromSrlVariable) SRLfunction(NdPromSrlFunction)

14

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

SRLreasoncodelist(NdPromSrlReasonCodeList) ForexamplesonhowtocreateSRLentities,seeCreatinganSRLRulesetonpage18, CreatinganSRLEnumeration(NdPromSrlEnumerationContent)onpage24and CreatinganSRLFunction(NdPromSrlFunction)onpage20.

Ruleflow Object Model


Theobjectmodelforruleflowisinthe
com.blazesoft.template.repository.objects.flowpackage.Itcontainstheinterfaces forvariousruleflowconstructsincludingtheruleflowentityitself.

Foranexampleofhowtocreatearuleflow,seeCreatingaRuleflow (NdPromFlowRuleflow)onpage21.

Question Set Object Model


Theobjectmodelforquestionsetisinthe
com.blazesoft.template.repository.objects.aaipackage.Itcontainstheinterfaces

forvariousquestionsetconstructsincludingthequestionsetitself.Bothstringbased APIandcontentbasedAPIexistfortheseconstructs. Foranexampleofhowtocreateaquestionset,seeCreatingaQuestionSet (NdPromAaiQuestionSet)onpage22.

Common ROM API and PROM API Tasks


ThissectiondescribeshowtoperformselectedtasksusingtheROMandPROMAPIs. Alltheexamplesofcreatingentitiesareconfinedtoentitiesthatarenottemplatized; thatis,theydonotcontaindynamiccontent.

Specifying a Location (NdLocation)


TheNdLocationinterfacedescribesthelocationofentitieswithinarepository.The interfacecandescribethelocationofarepositoryitem,whichisreferredtoasanexternal location.Theinterfacecanalsodescribethelocationofanentitydefinedwithina repositoryitem.Thattypeoflocationiscalledacompoundlocation.Itiscomposedofan externallocationdescribingthelocationoftherepositoryitemandaninternallocation whichdescribesthelocationoftheentitywithintherepositoryitem.Internallocations areintendedforusewithtemplates,astheydefinethepathfromtherootofthe templatedocumenttoaninnertemplateortemplateparameter.Thediscussionofthe NdLocationinterfaceinthischapterisconfinedtoexternallocations.
NdLocationFactorycontainsthesestaticmethods,aswellasothers,whichareusedto createanNdLocation.
static NdLocation createLocation(String[] components, boolean absolute) static NdLocation createLocation(String location)

Fair Isaac Confidential and Proprietary Information

15

CHAPTER 1: ROM and PROM APIs

Inthefirstmethod,ifthelocationisabsolute(inwhichcasethevalueoftheboolean absoluteistrue),eachelementintheStringarrayrepresentsthenameofoneofthe repositoryfoldersinapathfromtherootoftherepositorytotheiteminquestion,with thelastelementofthearraybeingthestoragenameoftheitem.Whenthelocationis relative(thevalueofthebooleanabsoluteisfalse),theelementsintheStringarray representadirectorypaththatisprocessedinthecontextofanotherlocation. Thefollowingtwomethodcallsareequivalent.TheycreateanNdLocationthatisa relativelocation.


NdLocation topDirectoryLocation = NdLocationFactory.createLocation(String[] {"Prom API Example"}, false);

NdLocation topDirectoryLocation = NdLocationFactory.createLocation("Prom API Example");

Thesemethodcallsarealsoequivalent.TheycreateanNdLocationthatisanabsolute location.
// projectFactory is an NdPromProjectFactory NdPromProject project = projectFactory.createProject(NdLocationFactory.createLocation( new String[]{"PROM API Example", "Entity Creation"}, true)); NdPromProject project = projectFactory.createProject(NdLocationFactory.createLocation( "/PROM API Example/Entity Creation"));

InthefirstmethodcallthecomponentsareelementsinaStringarray.Thelatter methodcallrepresentsthecomponentsinaString.Theleading/characterindicates thatthelocationisabsolute. Whetheryoushouldspecifythelocationasabsoluteorrelativewilldependonthetask athand.Asmentioned,relativelocationsareprocessedinthecontextofanother location.Whenadirectoryiscreatedthelocationisprocessedinthecontextofaparent directoryortherootoftherepository.Forthisreason,youmustusearelativelocation whencreatedadirectory.Whenlookinguparepositoryitemordirectoryinaproject usingthelookupEntry()methodoftheNdPromProjectinterface,thelocationisrelative sincetheprojectprovidesthecontext.ThelookupEntry()methodofthe NdRomDirectoryinterface,however,looksuptheentryfromtherootoftherespository whenthesuppliedlocationisabsolute.Ifthelocationisrelativethelookupisperformed fromthedirectory.TheNdPromProjectinterfaceaddDirectory()method,whichisused toaddadirectorytotheproject,requiresanabsolutelocation.TheBlazeAdvisorAPI ReferenceentryforeachmethodthattakesanNdLocationparameterspecifieswhetherto useanabsoluteorarelativelocation.

Creating Directories
YoucancreatedirectorieswiththecreateDirectory()methodofthe NdRomMutableDirectoryclass.NdRomMutableDirectoryisarepositorydirectorythatis mutable.NdRomMutableDirectoryextendsNdRomDirectory.Amutabledirectoryallows entriestobeaddedordeleted.Recallthatadirectorycontainsentries,whichareeither otherdirectoriesorrepositoryitems.NdRomMutableDirectoryhasmethodsforcreating both.ThedeleteEntry()methodphysicallydeletesthegivenrepositoryentryfromthe directory.
NdRomDirectory createDirectory(NdLocation location) NdRomItem createItem(NdLocation location)

16

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

void deleteEntry(String name)

Tocreateadirectoryundertherepositoryrootdirectory,obtaintheroot NdRomDirectorybycallinggetRoot()ontherepositorycontextobject (NdRomConnectionContext).CallcreateDirectory()ontherootdirectorywiththe NdLocationparameterthatspecfiesthelocationofthenewdirectory.Wheneveryou createadirectory,thelocationmustberelativeandcontainonlyoneelementinthe Stringarray.TheabsoluteparametertocreateLocation()isfalsewhenthelocation isrelative.AnewdirectoryisalwayscreatedwiththeNdRomMutableDirectoryobjectof theparentdirectoryandthereforethelocationisrelativetotheparentdirectory.See SpecifyingaLocation(NdLocation)onpage15fordiscussionofrelativeandabsolute locations.
// conContext is an NdRomConnectionContext NdRomDirectory romRoot = conContext.getRoot(); NdLocation topDirectoryLocation = NdLocationFactory.createLocation( new String[]{"Prom API Example"}, false);
NdRomDirectory topDirectory = ((NdRomMutableDirectory) romRoot).createDirectory(topDirectoryLocation);

((NdRomMutableDirectory) topDirectory).setDisplayName("PROM API Example");

Thedirectoryiscreatedinstorageimmediately.NotethatromRootmustbecastto NdRomMutableDirectory.NdRomDirectorydoesnotcontainmethodsforcreating repositoryentries.SetthedirectorysdisplaynameintheGUIwithsetDisplayName(). Thestepsaresimilarforcreatingadirectoryinanotherdirectory.First,createan NdLocationthatisarelativelocationwithonecomponent.PasstheNdLocationobjectto theNdRomMutableDirectorycreateDirectory()methodoftheNdRomMutableDirectory objectobtainedfortheparentdirectory.


// topDirectory is an NdRomDirectory
NdLocation projectLocation = NdLocationFactory.createLocation(new String[]{"Entity Creation"}, false);

NdRomDirectory entityCreationDirectory = ((NdRomMutableDirectory) topDirectory).createDirectory(projectLocation);

AddthedirectorytoaPROMprojectandobtainanNdPromDirectory.
// project is an NdPromProject NdPromDirectory projectDirectory = project.addDirectory(entityCreationDirectory.getLocation());

Thenextsection,CreatingaPROMProjectonpage17,completesthediscussionof creatingadirectorystructureforyourproject.

Creating a PROM Project


TocreateaPROMproject(NdPromProject),firstobtainanNdPromProjectFactory instancebycallingthegetProjectFactory()methodoftheconnectioncontextobject (NdRomConnectionContext).CreateanNdPromProjectbypassinganNdLocationtothe factoryscreateProject()method.TheNdLocationmustbeanabsolutelocation. SpecifyeachdirectorycomponentintheStringarray,includingthetopleveldirectory containedintherepositorysrootdirectory. ThiscodecreatesaPROMprojectintheEntity Creationdirectoryandaddsthe directorytotheproject.

Fair Isaac Confidential and Proprietary Information

17

CHAPTER 1: ROM and PROM APIs

// Create a PROM project in the "Entity Creation" directory // conContext is an NdRomConnectionContext // entityCreationDirectory is an NdRomDirectory NdPromProjectFactory projectFactory = conContext.getProjectFactory(); NdPromProject project = projectFactory.createProject(NdLocationFactory.createLocation( new String[]{"Prom API Example", "Entity Creation"}, true)); project.setDisplayName("Entity Creation"); // Add directory to project NdPromDirectory projectDirectory = project.addDirectory(entityCreationDirectory.getLocation());

Whentheprojectissaved,arepositoryitemoftypeProjectiscreatedintheEntity Creationdirectory(entityCreationDirectory).Notethatthedirectorymuststillbe addedtotheprojectbypassingthedirectorylocationtotheNdPromProject addDirectory()method.Asyoucreatemoredirectoriesforyourproject,eachdirectory mustbeaddedtotheprojectinthismanner. Inlikefashion,youcanaddanydirectorywithintherepositorytoaproject.The NdLocationmustbeanabsolutelocation.Allrepositorydirectoriesthataretraversed fromtherepositoryrootmustbenamedincomponentparametersStringarray.


NdLocation salariesLocation = NdLocationFactory.createLocation( new String[]{"Business Object Models","Java","Imported Java BOMs","Salaries"}, true); NdPromDirectory salariesDirectory = project.addDirectory(salariesLocation);

Loading a PROM Project


ToloadanexistingPROMproject(NdPromProject),obtainanNdPromProjectFactory instancebycallingthegetProjectFactory()methodontheconnectioncontext (NdRomConnectionContext).Createalocation(NdLocation)whichincludesthedirectory componentsfromtherepositoryrootaswellasthePROMprojectrepositoryitem.The NdLocationmustbeanabsolutelocation.ObtainanNdRomProjectbycalling lookupEntry()ontheROMrootdirectory.CreatethePROMprojectbypassingthe NdRomProjectobjecttothefactoryscreateProject()method.
// conContext is an NdRomConnectionContext NdPromProjectFactory projectFactory = conContext.getProjectFactory(); NdLocation projectLocation = NdLocationFactory.createLocation( new String[]{"PROM API Example", "Entity Creation", "Entity Creation"}, true)); NdRomProject romProject = (NdRomProject)romRoot.lookupEntry(projectLocation); NdPromProject project = projectFactory.createProject(romProject);

Note WhenyouusethePROMAPItoworkwithmultipleprojects,youcanreleasethe resourcesthataprojectholdsontobycallingthedispose()methodofthe NdPromProjectinterface.Toaccesstheprojectaftercallingdispose()youmustloadthe projectagain.

Creating an SRL Ruleset


Theinterfacesforcreatingarulesetandrulesetitemsaredefinedbytheobjectmodelfor SRLentitiesintheblazesoft.template.repository.objects.rulespackage.The objectmodelisintroducedinEntityObjectModelonpage12.Thepackagecontainsa factoryclassnamedNdPromSrlConstructContentFactorywhichisusedtocreate contentbasedobjectsforvariousSRLconstructs.

18

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

TheexampleinthissectioncreatesafixedcontentSRLruleset.ThepublicPROMAPIs inthecurrentreleaseofBlazeAdvisordonotsupportcreatingtemplatizedcontent. TheNdPromSrlConstructContentFactorymethodnewSrlRulesetContent()isusedto createaruleset,whichisanNdPromSrlRulesetContentobject.Amongthemethods availableinNdPromSrlRulesetContentaresetNameContent(),setCommentContent(), andinsertSrlRulesetItemContentAt().Thelatermethodisusedtoaddtheruleset itemstotheruleset. Rulesetitems(NdPromSrlRulesetItem)arecontainedwithinaruleset.Arulesetisa repositoryitem,butrulesetitemsarenotrepositoryitems.Thetwosensesofthetermitem shouldnotconfused.Thecontentofrulesetitemsarerepresentedbythe NdPromSrlRulesetItemContentinterfaceandincludeSRLrule (NdPromSrlRuleContent),SRLnamedobject(NdPromSrlNamedObjectContent),SRL pattern(NdPromSrlPatternContent),SRLeventrule(NdPromSrlEventRuleContent),and SRLvariable(NdPromSrlVariableContent). Creatingarulesetandrulesetitemsfollowsthegeneralpatternofcreatingtheruleset withtherewSrlRulesetContent()ofNdPromSrlConstructContentFactoryinterface; creatingeachrulesetitemwiththeappropriateNdPromSrlConstructContentFactory method;creatingthecontentfortherulesetitem,usuallywithmethodsof NdPromSrlConstructContentFactoryandNdPromTextContentFactory;settingthe contentontherulesetitem;andtheninsertingtherulesetitemintotherulesetand savingtheruleset. AruleiscreatedwiththenewSrlRuleContent()methodofthe NdPromSrlConstructContentFactoryinterface.ThenewTextContent()and newSrlRuleBodyContent()methodsoftheNdPromTextContentFactoryinterfaceare usedtocreatecontentfortherulenameandrulebody,respectively.Aftersettingthe contentontherule,theruleisaddedtotherulesetwiththerulesets insertSrlRulesetItemContentAt()method. BothNdPromPattern(apattern)andNdPromParameter(aparameter)extendthe NdPromSrlTypedContentinterfaceandcontaintypedcontent.Typedcontentcanbea simpletypereferencetoaprimitivetype,aclass,oranenumeration.Typedcontentis obtainedwiththeNdPromSrlConstructContentFactoryinterface newSrlGenericTypeContent()method.Thetypedcontentissetonthepatternwith setSrlGenericTypeContent()methodwhichisinheritedfrom NdPromSrlTypedContent.Theexamplecodeshowshowtosetacollectionanda constraintonapattern.
// project is an NdPromProject // Create 'Cross-sell' ruleset, with rule and two patterns, in 'Cross-sell Rules' directory NdPromSrlRulesetContent ruleset = NdPromSrlConstructContentFactory.newSrlRulesetContent(project); ruleset.setNameContent(NdPromTextContentFactory.newTextContent("crossSell")); // Create 'rule1' rule NdPromSrlRuleContent rule = NdPromSrlConstructContentFactory.newSrlRuleContent(project); // set rule name rule.setNameContent(NdPromTextContentFactory.newTextContent("rule1")); // set rule body String ruleBodyString = "if boughtProducts.primaryDemographic = promoProducts.primaryDemographic \n" + "then { \n" +

Fair Isaac Confidential and Proprietary Information

19

CHAPTER 1: ROM and PROM APIs

"print(\"Shopper: \"shopper.name\", bought: \"boughtProducts.name\", rec: \"promoProducts.name).\n" +

"shopper.recommendedProducts.append(promoProducts),\n ignore(boughtProducts).\n}"; NdPromSrlRuleBodyTextContent ruleBody = NdPromSrlConstructContentFactory.newSrlRuleBodyContent(ruleBodyString); rule.setSrlRuleBodyContent(ruleBody); // A rule is a ruleset item (NdPromSrlRuleContent extends NdPromSrlRulesetItemContent) ruleset.insertSrlRulesetItemContentAt(rule, 0); // Add 'shopper' parameter to ruleset NdPromSrlParameterContent parameter = NdPromSrlConstructContentFactory.newSrlParameterContent(); parameter.setNameContent(NdPromTextContentFactory.newTextContent("shopper")); NdPromSrlGenericTypeContent parameterType = NdPromSrlConstructContentFactory.newSrlGenericTypeContent("Shopper"); parameter.setSrlGenericTypeContent(parameterType); ruleset.insertSrlParameterContentAt(parameter,0); // Create 'boughtProducts' pattern NdPromSrlPatternContent boughtPattern = NdPromSrlConstructContentFactory.newSrlPatternContent(project); boughtPattern.setNameContent(NdPromTextContentFactory.newTextContent("boughtProducts")); NdPromSrlGenericTypeContent patternType = NdPromSrlConstructContentFactory.newSrlGenericTypeContent("Product"); boughtPattern.setSrlGenericTypeContent(patternType); // set collection NdPromSrlCollectionTextContent collection = NdPromSrlConstructContentFactory.newSrlCollectionContent("shopper.purchasedProducts"); boughtPattern.setSrlCollectionContent(collection); // A pattern is a ruleset item (NdPromSrlPatternContent extends NdPromSrlRulesetItemContent) ruleset.insertSrlRulesetItemContentAt(boughtPattern, 0); // Create 'promoProducts' pattern NdPromSrlPatternContent promoPattern = NdPromSrlConstructContentFactory.newSrlPatternContent(project); promoPattern.setNameContent(NdPromTextContentFactory.newTextContent("promoProducts")); //set the type NdPromSrlGenericTypeContent patternType1 = NdPromSrlConstructContentFactory.newSrlGenericTypeContent("Product"); promoPattern.setSrlGenericTypeContent(patternType1); //set the constraint NdPromSrlConstraintTextContent constraint = NdPromSrlConstructContentFactory.newSrlConstraintContent("promotion = true"); promoPattern.setSrlConstraintContent(constraint); ruleset.insertSrlRulesetItemContentAt(promoPattern, 1); // Create NdPromItem for the ruleset, add to a PROM directory and save. // schemaManager is an NdRomSchemaManager NdRomSchemaElement schemaElement = schemaManager.lookupSchemaElement(TYPE_SRL_RULESET, SUB_TYPE_NONE, CONTENT_TYPE_FIXED, TARGET_SRL); NdPromItemFactory rulesetFactory = schemaElement.getItemFactory(); NdPromItem rulesetItem = rulesetFactory.newItem((NdPromItemContent)ruleset, project); // crossSellDiretory is an NdPromDirectory crossSellDirectory.addItem(rulesetItem); rulesetItem.save(); // project is an NdPromProject project.save();

Creating an SRL Function (NdPromSrlFunction)


AnSRLfunction(NdPromSrlFunction)isdefinedintheobjectmodelforSRLentitiesin theblazesoft.template.repository.objects.rulespackage.Thepackagecontainsa factoryclassnamedNdPromSrlConstructContentFactory.TocreateafixedcontentSRL

20

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

function,usethefactorytocreateafunctionobject(NdPromSrlFunctionContent)andset thefunctionname.DefineaStringthatcontainsthebodyofthefunction.Usethe NdPromSrlConstructContentFactoryfactoryagaintocreatethefunctionbodyas contentbasedNdPromSrlBodyTextContentfromtheString.Setthefunctionbodyon thefunctionobject.Finally,createanNdPromItemforthefunctionandaddittoaproject directory.


// Create 'main' function in 'Test' directory NdPromSrlFunctionContent function = NdPromSrlConstructContentFactory.newSrlFunctionContent(project); function.setNameContent(NdPromTextContentFactory.newTextContent("main")); String functionBodyString = "s1 is a Shopper initially { \n" + " name = \"Chris Camper\", \n" + " purchasedProducts = an array of Product, \n" + " purchasedProducts.append(tent),\n" + " recommendedProducts = an array of Product.\n" + "}.\n" + "s2 is a Shopper initially { \n" + " name = \"Grace Gardener\", \n" + " purchasedProducts = an array of Product, \n" + " purchasedProducts.append(weeder),\n" + " recommendedProducts = an array of Product.\n" + "}.\n" + "s3 is a Shopper initially { \n" + " name = \"Harry Homeowner\", \n" + " purchasedProducts = an array of Product, \n" + " purchasedProducts.append(bigscreen),\n" + " recommendedProducts = an array of Product.\n" + "}.\n" + "s4 is a Shopper initially { \n" + " name = \"Samantha Socialite\", \n" + " purchasedProducts = an array of Product, \n" + " purchasedProducts.append(tiara),\n" + " recommendedProducts = an array of Product.\n" + "}.\n" + "for each Shopper do { \n" + " apply crossSell(it). \n" + " printRecommendations(it). \n" + "}."; NdPromSrlBodyTextContent functionBody = NdPromSrlConstructContentFactory.newSrlBodyContent(functionBodyString); function.setSrlBodyContent(functionBody); // Create NdPromItem for function and add to "Test" directory schemaManager = project.getRomConnectionContext().getSchemaManager(); schemaElement = schemaManager.lookupSchemaElement(TYPE_SRL_FUNCTION, SUB_TYPE_NONE, CONTENT_TYPE_FIXED, TARGET_SRL); NdPromItemFactory functionItemFactory = schemaElement.getItemFactory(); NdPromItem functionItem = functionItemFactory.newItem((NdPromItemContent)function, project); testDirectory.addItem(functionItem); functionItem.save();

Creating a Ruleflow (NdPromFlowRuleflow)


Thefactoryclassforcreatingvariousruleflowconstructsis NdPromFlowConstructContentFactory.Tocreatearuleflowwithaflowandtask,usethe factorytocreatetheruleflow(NdPromFlowRuleflowContent),thensetthenameofthe ruleflow,asNdTextContent,ontheruleflowobject.Usethesamefactorytocreateaflow (NdPromFlowFlowContent)andsettheflowontheruleflow.Use

Fair Isaac Confidential and Proprietary Information

21

CHAPTER 1: ROM and PROM APIs

NdPromFlowConstructContentFactoryagaintocreateatask(NdPromFlowTaskContent). Setnameandimplementationnameonthetask,theninsertaparameterandflowinput onthetask.Insertthetaskintotheflow.Finally,createanNdPromItemfortheruleflow andsaveitwiththeproject.


// project is an NdPromProject // testDirectory is an NdPromDirectory that has been added to the project NdPromFlowRuleflowContent ruleflow = NdPromFlowConstructContentFactory.newFlowRuleflowContent(project); ruleflow.setNameContent( NdPromTextContentFactory.newTextContent("newRuleflow")); // Create a flow. NdPromFlowFlowContent flow = NdPromFlowConstructContentFactory.newFlowFlowContent(); ruleflow.setFlowFlowContent(flow); // Create a task. NdPromFlowTaskContent task = NdPromFlowConstructContentFactory.newFlowTaskContent(); task.setNameContent( NdPromTextContentFactory.newTextContent("newTask")); task.setImplementationNameContent( NdPromTextContentFactory.newTextContent("newRuleset")); task.insertFlowParameterContentAt( NdPromFlowConstructContentFactory.newFlowParameterContent("param1"), 0); task.insertFlowInputContentAt( NdPromFlowConstructContentFactory.newFlowInputContent("foo"), 0); flow.insertFlowFlowItemContentAt(task, 0); schemaManager = project.getRomConnectionContext().getSchemaManager(); schemaElement = schemaManager.lookupSchemaElement(TYPE_RULEFLOW, SUB_TYPE_NONE, CONTENT_TYPE_FIXED, TARGET_SRL); NdPromItemFactory factory = schemaElement.getItemFactory(); NdPromItem item = factory.newItem((NdPromFlowRuleflow) ruleflow, project); testDirectory.addItem(item); item.save();

Creating a Question Set (NdPromAaiQuestionSet)


Thefactoryclassforcreatingcontentbasedobjectsforvariousquestionsetconstructsis NdPromAaiConstructContentFactory.Tocreateaquestionsetwithaquestion,usethe factorytocreatethequestionset(NdPromAaiQuestionSetContent),thensetthename andcommentasNdTextContentonthequestionset.Createaquestion (NdPromAaiQuestionContent)withthesamefactoryandsetNdTextContentprompt contentonquestion,aswellasNdPromAaiClassPropertyContent.Insertthequestion intothequestionset.Finally,createanNdPromItemforthequestionset.
// project is an NdPromProject // testDirectory is an NdPromDirectory that has been added to the project NdPromAaiQuestionSetContent questionSet = NdPromAaiConstructContentFactory.newAaiQuestionSetContent(project); questionSet.setNameContent( NdPromTextContentFactory.newTextContent("newQuestion")); questionSet.setCommentContent( NdPromTextContentFactory.newTextContent("Sample question set")); // Add a question. NdPromAaiQuestionContent question =

22

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

NdPromAaiConstructContentFactory.newAaiQuestionContent(); question.setPromptContent( NdPromTextContentFactory.newTextContent("What is the driver's age?")); NdPromAaiClassPropertyContent classProperty = question.getAaiClassPropertyContent(); classProperty.setClassNameContent( NdPromTextContentFactory.newTextContent("Driver")); classProperty.setPropertyNameContent( NdPromTextContentFactory.newTextContent("age")); questionSet.insertAaiQuestionContentAt(question, 0); schemaManager = project.getRomConnectionContext().getSchemaManager(); schemaElement = schemaManager.lookupSchemaElement(TYPE_QUESTION_SET, SUB_TYPE_NONE, CONTENT_TYPE_FIXED, TARGET_SRL); NdPromItemFactory factory = schemaElement.getItemFactory(); NdPromItem item = factory.newItem((NdPromAaiQuestionSet) questionSet, project); testDirectory.addItem(item); item.save();

Creating an SRL Class (NdPromSrlClassContent)


Thecom.blazesoft.template.repository.objects.bompackagecontainsinterfacesfor thebusinessobjectmodel,whichincludestheSRLclass.TheNdPromSrlClassContent interfaceprovidescontentsectionbasedread/writeaccesstothepropertiesofanSRL classdefinition.NdPromSrlClassContentclasscontentiscreatedwiththe newSrlClassContent()methodoftheNdPromBomConstructContentFactoryclass, whichisincludedinthepackage.TheinsertSrlPropertyContentAt()method (inheritedfromNdPromSrlPropertiesContainerContent)isusedtoinsertproperty content(NdPromSrlPropertyContent)intotheclasscontent (NdPromSrlClassContent).ThenewSrlPropertyContent()methodofthe NdPromBomConstructContentFactoryclassisusedtocreateNdPromSrlPropertyContent. Thenameandtypeofthepropertycontent,whichcorrespondtoafieldnameandtype, issetwiththeNdPromSrlPropertyContentinterfacesetNameContent()and setSrlGenericType()methods. ThiscodecreatesclasscontentfortheSRLclass,insertsafielddefinitionintothe content,andsavestheclassasaPROMitemintheappropriatedirectorywhichhas beenpreviouslyaddedtotheproject.
NdPromSrlClassContent classContent = NdPromBomConstructContentFactory.newSrlClassContent(project); NdPromTextContent className = NdPromTextContentFactory.newTextContent("SimpleSRLClass"); classContent.setNameContent(className); NdPromSrlPropertyContent prop = NdPromBomConstructContentFactory.newSrlPropertyContent(); NdPromTextContent propName = NdPromTextContentFactory.newTextContent("customerName"); prop.setNameContent(propName); NdPromSrlGenericTypeContent propType = NdPromSrlConstructContentFactory.newSrlGenericTypeContent("string"); prop.setSrlGenericTypeContent(propType); classContent.insertSrlPropertyContentAt(prop, 0); // Save the new class. // project is an NdPromProject & targetDirectory is an NdPromDirectory schemaElement = schemaManager.lookupSchemaElement(TYPE_SRL_CLASS, SUB_TYPE_NONE,

Fair Isaac Confidential and Proprietary Information

23

CHAPTER 1: ROM and PROM APIs

CONTENT_TYPE_FIXED, TARGET_SRL); factory = schemaElement.getItemFactory(); NdPromItem classItem = factory.newItem((NdPromEntity)classContent, project); targetDirectory.addItem(classItem); classItem.save();

Creating an SRL Enumeration (NdPromSrlEnumerationContent)


Asnotedintheprevioussection,thefactoryclassforcreatingvariouscontentbased constructsinthebusinessobjectmodelisNdPromBomConstructContentFactory,which ispartofthecom.blazesoft.template.repository.objects.bompackage.Tocreatean SRLenumerationandenumerationitems,usethefactorytocreatetheenumeration object(NdPromSrlEnumerationContent),thensetthenameontheenumerationobject. UseNdPromBomConstructContentFactorytocreateSRLenumerationitems (NdPromSrlEnumerationItemContent)andinserteachitemintotheenumeration.Create theNdPromItemfortheenumerationandaddtheNdPromItemtoanexistingproject directoryandsave.
// Create 'DemographicSegments' enumeration with four enumeration items. NdPromSrlEnumerationContent enumeration = NdPromBomConstructContentFactory.newSrlEnumerationContent(project); // Create content-based NdPromTextContent text and set the enumeration name. NdPromTextContent enumName = NdPromTextContentFactory.newTextContent("DemographicSegments"); enumeration.setNameContent(enumName); // Create SRL enumeration items NdPromSrlEnumerationItemContent enumItem1 = NdPromBomConstructContentFactory.newSrlEnumerationItemContent("outdoorsman"); NdPromSrlEnumerationItemContent enumItem2 = NdPromBomConstructContentFactory.newSrlEnumerationItemContent("homeowner"); NdPromSrlEnumerationItemContent enumItem3 = NdPromBomConstructContentFactory.newSrlEnumerationItemContent("gardener"); NdPromSrlEnumerationItemContent enumItem4 = NdPromBomConstructContentFactory.newSrlEnumerationItemContent("socialite"); // Insert the SRL enumeration items on the SRL enumeration enumeration.insertSrlEnumerationItemContentAt(enumItem1, 0); enumeration.insertSrlEnumerationItemContentAt(enumItem2, 1); enumeration.insertSrlEnumerationItemContentAt(enumItem3, 2); enumeration.insertSrlEnumerationItemContentAt(enumItem4, 3); // Create the NdPromItem for the enumeration // project is an NdPromProject NdRomSchemaManager schemaManager = project.getRomConnectionContext().getSchemaManager(); NdRomSchemaElement schemaElement = schemaManager.lookupSchemaElement(TYPE_SRL_ENUMERATION, SUB_TYPE_NONE, CONTENT_TYPE_FIXED, TARGET_SRL); NdPromItemFactory enumItemFactory = schemaElement.getItemFactory(); NdPromItem enumItem = enumItemFactory.newItem((NdPromEntity)enumeration, project); // Add the SRL enumeration to an existing project directory // projectDirectory is a NdPromDirectory projectDirectory.addItem(enumItem); // Save the SRL enumeration enumItem.save();

24

Fair Isaac Confidential and Proprietary Information

CHAPTER 2

Metaphor APIs
TheMetaphorAPIsprovideprogramaticaccesstotheBlazeAdvisormetaphors: decisiontable,decisiontree,andscoremodel.TheAPIsenableyoutoexamineandedit thecontentsofmetaphorinstancesaswellascreatenewinstances.Thischapter providesanintroductiontosomeofthosecapabilities.ConsulttheBlazeAdvisorAPI Referenceformoredetailedinformation.TheAPIReferenceisavailablebyselectingAPI ReferencefromtheBuilder Helpmenu.

Loading a Metaphor Instance


TheinitialstepsforloadinganinstanceisthesameforeachtypeofBlazeAdvisor metaphor.Theprocedureforconnectingtoyourrepositoryandopeningtheprojectthat containsyourmetaphorinstanceisdetailedinChapter1,ROMandPROMAPIs. Onceaprojecthasbeenopened,youcanloadthemetaphorinstanceinthisfashion:
NdLocation location = NdLocationFactory.createLocation("directory/instanceFileName"); NdPromItem promItem = (NdPromItem)(project.lookupEntry(location)); NdPromItemContent content = promItem.getItemContent(); NdInstantiationElement instantiationElt = null; if (content instanceof NdInstantiation) { instantiationElt = (NdInstantiationElement)content; }

IntheexamplecodethroughoutthischapterinstantiationEltwillrefertothe instance.Iftheinstanceisglobal(i.e.themetaphorinstanceisadirectchildofa repositorydirectory),thenthisissufficient.Themetaphorinstancewillbewhat instantiationEltrefersto.Otherwise,youneedtonavigatetheinstancetofindthe instantiationelementthatcorrespondstothemetaphorinstance,asshownhere:


instanceElt = instantiationElt.safeLookup(metaphorInstanceName);

TheNdMetaphorSupportclasscontainsmethodstodeterminewhichtypeofmetaphor theinstanceis:isDecisionTableInstance(),isDecisionTreeInstance(),and isScoreModelInstance().


if (NdMetaphorSupport.isDecisionTableInstance(instanceElt)) { // execute code to deal with decision tables }

Creating a Metaphor Model


Eachmetaphormodelhasafactoryclassforcreatinginstancesofitsmetaphormodel.

Fair Isaac Confidential and Proprietary Information

25

CHAPTER 2: Metaphor APIs

NdDecTableModelFactory.createDecTableModel()

Createsanewinstanceofadecisiontablemodel,returnedasanNdDecTableModel.
NdDecTreeModelFactory.createDecTreeModel()

Createsanewinstanceofadecisiontreemodel,returnedasanNdDecTreeModel.
NdScoreModelModelFactory.createScoreModelModel()

Createsanewinstanceofascoremodel,returnedasanNdScoreModelModel. Eachfactoryclasshasamethodtosettheinstantiationelementonthemodel. Foradecisiontable,calltheNdDecTableModelFactory.setDecTableInstance() method. Foradecisiontree,calltheNdDecTreeModelFactory.setDecTreeInstance() method. Forascoremodel,calltheNdScoreModelModelFactory.setScoreModelInstance() method. ThemethodsabovemaythrowanNdMetaphorModelExceptionintheeventsomething iswrongwiththeinstanceandcannotbecorrected.Thisisaterminalerror,andwill preventthemetaphormodelfromusingthemetaphorinstance.Thesemethodsmay alsothrowanNdMetaphorWarningExceptionincaseanerroneoussituationwasfound, butcouldbecorrected.ANdMetaphorModifiedExceptionisthrownwhenthemetaphor instancewasmodifiedbythemetaphormodeltofixpossibleproblems.Thiswould happen,forexample,ifthemetaphortemplatewaschanged. ThedecisiontablemodelinstancedecTableModelinthecodebelowisusedtoeditthe decisiontable,asdescribedinthefollowingsection,DecisionTableEditingAPIon page26.Similarcodeisusedtocreatedecisiontreeandscoremodelinstances.These modelsarediscussedinDecisionTreeEditingAPIonpage28andScoreModel EditingAPIonpage31.
if (NdMetaphorSupport.isDecisionTableInstance(instanceElt)) { NdDecTableModel decTableModel = NdDecTableModelFactory.createDecTableModel(); NdDecTableModelFactory.setDecTableInstance(decTableModel, instanceElt); }

Decision Table Editing API


ThNdDecTableModelinterfaceprovidesmethodsforeditingadecisiontableinstance. NdDecTableModelincludesmethodsforinsertinganddeletingcolumnsandrowsinthe decisiontableinstance,forobtainingthenumberofcolumnsandrows,formoving columnsandrowswithinthetable,andforcopyandpasteofarangeofcells. TheDecisionTableImportexampledemonstrateshowtousetheDecisionTable EditingAPIstocreateaninstanceofasingleaxis(columns)decisiontabletemplateand populateitwithdataobtainedfromaCSVfilethatwasgeneratedinMicrosoftExcel. Theexampleislocatedin<ADVISOR_HOME>/examples/ExamplesRepository/API Examples/Metaphor APIs/Decision Table Import. ThegetTableInfo()methodofNdDecTableModelreturnsanNdDecTableInfoobject, whichcontainsinformationaboutthelayoutofthedecisiontable,includingthenumber

26

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

ofconditionandactionrowsorcolumnsinadecisiontable.ThegetTableLayout() methodofNdDecTableInforeturnsaconstantthatindicatesthelayout,suchas NdDecisionMetaphorConstants.DECTABLE_LAYOUT_SINGLE_AXIS_COLS.


NdDecTableInfo tableInfo = decTableModel.getTableInfo(); int layout = tableInfo.getTableLayout()

ThegetCellFieldValue()methodreturnsacellsfieldvalueandsetCellFieldValue() setsthefieldvalueofthecell.ANdMetaphorModelExceptionisthrownifthevalueisnot oftheappropriatetype.Forexample,theexceptionisthrownifavaluethatisnota numberisusedinacellthathasacelltemplatedisplaynamethatspecifiesanumber, suchas= 'integer'. SeveralofthemethodsinNdDecTableModelaccesscellsinadecisiontablebyrowand columncoordinates.NdDecTableCellCoordinatesrepresentsthecoordinatesofacell. Thisstatementsetsthefieldvalueofthecellatrow2,col3inadecisiontable.Thecell templateforthiscellis= string,whichhasonlyoneplaceholder.Theindexofthe placeholder,orfield,withinthecellis0.
decTableModel.setCellFieldValue(new NdDecTableCellValue(2, 3), 0, "Medical");

Whenyouspecifyanumericrange,setthefirstnumberatplaceholderindex0andthe secondnumberatplaceholderindex1ofthecell.Thecelltemplatedisplaynameforthis cellis'real1' < .. <= 'real2',whichhastwoplaceholders.Thesestatementssetthe range1.0<..<=3.5onthecell.


decTableModel.setCellFieldValue(new NdDecTableCellValue(2, 3), 0, 1.0); decTableModel.setCellFieldValue(new NdDecTableCellValue(2, 3), 1, 3.5);

ThegetCellInfo()methodreturnsanNdDecTableCellInfoobjectthatsuppliesall informationnecessarytorenderandeditacell.ThegetTemplatesInfo()methodof NdDecTableCellInfo returnsanNdRangeTableCellTemplatesInfoobject.


NdRangeTableCellTemplatesInfohasthegetAllowedCellTemplateDisplayNames()

method,whichobtainsthelistofallowedcelltemplatedisplaynamesforthecell.The
getCurrentCellTemplateDisplayName()methodofNdRangeTableCellTemplatesInfo

returnsthecelltemplatedisplaynamethatisselectedforthecell.
// getCellInfo(int row, int column) NdDecTableCellInfo cellInfo = decTableModel.getCellInfo(2, 3); String cellTemplateDisplay Name = cellInfo.getTemplatesInfo().getCurrentCellTemplateDisplayName();

TheNdDecTableCellInfomethodgetRenderingInfo()returnsan NdRangeTableCellRenderingInfoobject.TheisEmpty()methodreturnstrueifthecell hasnocontent.TheisLabel()methodsindicateswhetherthecellcontainsalabel.The getRole()methodoftheNdRangeTableCellRenderingInforeturnsaconstantthat indicatestheroleofthecell. TheselectCellTemplate()methodselectsthecelltemplatedisplaynameonthecellat thespecifiedcoordinates.Thisprocessiscalledbinding.Thecelltemplatedisplayname selectedmustbeoneoftheallowedcelltemplatesspecifiedforthecell,justasauserin theGUIselectsacelltemplatefromadropdownlistofallowedcelltemplates.The allowedcelltemplateshavebeendefinedinthedecisiontablewizardormanuallyin

Fair Isaac Confidential and Proprietary Information

27

CHAPTER 2: Metaphor APIs

thedecisiontabletemplatedesigner.ANdMetaphorModelExceptionisthrownifthecell templateisnotallowedorifthesamecelltemplateisalreadydefinedforthatcell.
decTableModel.selectCellTemplate(new NdDecTableCellCoordinates(row, col), "= 'real'");

Example: Display an Overview of a Decision Table


Thisexamplecodeloopsthoughtherowsandcolumnsofadecisiontableandliststhe labelorroleforeachcell.
for (int row = 0; row < decTableModel.getRowCount(); row++) { for (int col = 0; col < decTableModel.getColumnCount(); col++) { NdDecTableCellInfo info = decTableModel.getCellInfo(row, col); NdRangeTableCellRenderingInfo renderingInfo = info.getRenderingInfo(); if (renderingInfo.isEmpty()) { System.out.print(" "); } else if (renderingInfo.isLabel()) { System.out.print("H"); } else { switch (renderingInfo.getRole()) { case NdDecisionMetaphorConstants.METAPHOR_ACTION: System.out.print("A"); break; case NdDecisionMetaphorConstants.METAPHOR_CONDITION: System.out.print("C"); break; } } } }

Decision Tree Editing API


TheNdDecTreeModelinterfaceprovidesmethodsforeditingadecisiontreeinstancein thecustomarytreeformatasanetworkofnodesandlinks.Theoperationsyouperform wheneditingadecisiontreeintheGUIhavecorrelarymethodsintheAPIwhichare usedinafashionthatshouldbefamiliartoyou. Tobegineditingadecisiontree,obtainanNdDecTreeModelinstanceasdescribedin LoadingaMetaphorInstanceonpage25.Thecodeforobtainingtheinstanceispart ofthedecisiontreeexampleinExample:CreateaSubtreeonpage30 TherootnodeofadecisiontreeisobtainedbycreatinganinstanceofNdDecTreePath. Thisclassrepresentsapath.Thelocationofanodeinatreeisrepresentedbyan NdDecTreePathpathtothenode.Youcanbegintraversingthenodesofatreebyusing thegetNodeOutgoingNodeAt()methodofNdDecTreeModeltoobtainthepathofoneof thenodeschildnodes;andthencontinuetraversingthetreeviaoneofitschildnodes, andsoon.ThesecondparametertothegetNodeOutgoingNodeAt()methodistheindex (base0)ofthechild.
// decTreeModel is an NdDecTreeModel NdDecTreePath root = new NdDecTreePath(); NdDecTreePath path1 = decTreeModel.getNodeOutgoingNodeAt(root, 0); NdDecTreePath path2 = decTreeModel.getNodeOutgoingNodeAt(path1, 0);

28

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

path2isthefirstchildofthefirstchildoftherootnode.Forthedecisiontreediagramed below,thatisthepathtotheModelYearnodeforCharger.

TheimagebelowdepictsaportionofthedecisiontreeintheDecisionTreewith Patternsexamplein<ADVISOR_HOME>/examples/repositories/ExamplesRepository/ Metaphors and Templates/Decision Trees/Decision Tree with Patterns.

Youcanobtaintheincominglinkconditionvalue(Charger)andthenodelabel (ModelYear)withthesemethods:
// returns "Charger" String condition = decTreeModel.getIncomingLinkConditionValue(path2,0)); // returns "Model Year" String label = decTreeModel.getNodeLabel(path2));

Theincominglinkselectedconditionformatlabelisthenameoftemplatethatisused withtheincominglinkconditionvalue.Usethe getIncomingLinkSelectedConditionFormatLabel()methodtoobtainit.


//returns "Model = 'string'" String format = decTreeModel.getIncomingLinkSelectedConditionFormatLabel(path2));

Youcanexamineatemplatetodeterminethenumberofplaceholders.Thereisone placeholderforastringvalueinModel = 'string'.Youcanusethe setIncomingLinkConditionValue()methodtochangethevalueoftheincominglink conditionfromChargertoCorvette.Themiddleparameteristheplaceholderindex.


decTreeModel.setIncomingLinkConditionValue(path2, 0, "Corvette");

Thesetofallowedconditiongrouplabelsforoutgoinglinksforthisnodeisobtained withthegetAllowedConditionGroupLabelsForOutgoingLinks()method.
// returns "Make", "Model", "Model Year" String[] allowedLabels = decTreeModel.getAllowedConditionGroupLabelsForOutgoingLinks(path2);

Youcanchangetheconditiongrouptoanyoftheallowedvaluesusingthe selectConditionGroupForOutgoingLinks()method.
decTreeModel.selectConditionGroupForOutgoingLinks(path2, "Model Year");

CallthegetNodeOutgoingLinksCount()methodtoobtainthenumberofoutgoinglinks.
// returns: 2 int count = decTreeModel.getNodeOutgoingLinksCount(path2));

ThisexamplecodeusesthegetNodeOutgoingNodeAt()methodtoobtainthefirst outgoingchildnode(path3)ofthenodeatpath2.
NdDecTreePath path3 = decTreeModel.getNodeOutgoingNodeAt(path2, 0);

Fair Isaac Confidential and Proprietary Information

29

CHAPTER 2: Metaphor APIs

NdDecTreeNodeRenderingInfocontainsavarietyinformationaboutanode.Welearn

thatpath3,isanactionnode.
NdDecTreeNodeRenderingInfo renderInfo = decTreeModel.getNodeRenderingInformation(path3); // Prints: "Is Rating: 4 an action node? true" System.out.println("Is " + renderInfo.getLabel() + " an action node? " + renderInfo.isActionNode());

ThegetIncomingLinkAllowedConditionFormatLabels()methodofNdDecTableModel returnsanarrayoftheallowedincominglinkconditionformatlabelsforpath3.
// returns: // "Model Year = 'integer'", "Model Year > 'integer'", "Model Year < 'integer'", // "Model Year >= 'integer'", "Model Year <= 'integer', // "Model Year 'integer1' <= .. <= 'integer2', "otherwise" String[] allowedFormats = decTreeModel.getIncomingLinkAllowedConditionFormatLabels(path3);

Tochangetheconditionto1962 - 1964,selecttheappropriateconditionformatlabel fromtheallowedlist.Then,setthevalueoneachplaceholderseparately.


decTreeModel.selectIncomingLinkConditionFormat( path3,"Model Year 'integer1' <= .. <= 'integer2'"); decTreeModel.setIncomingLinkConditionValue(path3,0, "1962"); decTreeModel.setIncomingLinkConditionValue(path3,1, "1964");

Toobtainthecurrentactionvalue(therating),usethegetActionValue()method.
// returns: 4 int actionValue = decTreeModel.getActionValue(path3, 0, 0));

Tochangetheratingfrom4to3andsetthenodelabelappropriately,usethiscode.
decTreeModel.setActionValue(path3, 0, 0, "3.0"); decTreeModel.setNodeLabel(path3, "Rating: 3");

Example: Create a Subtree


Thisexampleremovesasubtreeofnodesfromtheexampledecisiontreediscussedin theprevioussection.Itthenreconstructstheentiresubtree.Theexamplealso demonstrateshowtoconnecttotherepository,findthedecisiontreeinstancerepository item,andhowtouseNdDecTreeModelFactorytoobtainaninstanceofNdDecTreeModel.
public class ReconstructSubtree implements NdRomSchemaConstants { public static void main(String[] argv) throws Exception, NdMetaphorModelException { NdFileRepositoryConnection connection = new NdFileRepositoryConnection(); // change the path to your repository as appropriate connection.setRepositoryFolder("C:/repositories/ExamplesRepository"); NdRomConnectionManager connectionMgr = NdRomFactory.newRepositoryConnectionManager(connection); connectionMgr.connect(); NdRomConnectionContext conContext = connectionMgr.getConnectionContext(); NdRomDirectory romRoot = conContext.getRoot(); NdRomProject romProject = (NdRomProject)romRoot.lookupEntry( NdLocationFactory.createLocation( "/Metaphors and Templates/Decision Trees/Decision Tree with Patterns/Decision Tree with Patterns_java"));

30

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

NdPromProjectFactory projectFactory = conContext.getProjectFactory(); NdPromProject project = projectFactory.createProject(romProject);


NdPromItem decisionTreeInstanceItem = (NdPromItem)project.lookupEntry( NdLocationFactory.createLocation("Decision Tree with Patterns/oldCarsDecisionTree Instance"));

NdPromItemContent content = (NdPromItemContent) decisionTreeInstanceItem.getItemContent(); NdDecTreeModel decTreeModel = null; if (NdMetaphorSupport.isDecisionTreeInstance((NdInstantiationElement)content)) { decTreeModel = NdDecTreeModelFactory.createDecTreeModel(); } else { System.exit(1); } NdDecTreeModelFactory.setDecTreeInstance(decTreeModel, (NdInstantiationElement)content); NdDecTreePath root = new NdDecTreePath(); NdDecTreePath path1 = decTreeModel.getNodeOutgoingNodeAt(root, 0); NdDecTreePath path2 = decTreeModel.getNodeOutgoingNodeAt(path1, 0); NdDecTreeNodeRenderingInfo renderInfo = decTreeModel.getNodeRenderingInformation(path2); // TASK: Delete the subtree at this node; then re-create it. decTreeModel.deleteSubtree(path2); NdDecTreePath newPath = decTreeModel.insertNewNode(path1, 0, "Model"); decTreeModel.selectConditionGroupForOutgoingLinks(newPath, "Model Year"); decTreeModel.selectIncomingLinkConditionFormat(newPath,"Model = 'string'"); decTreeModel.setIncomingLinkConditionValue(newPath,0, "Charger"); // first condition NdDecTreePath cond1 = decTreeModel.insertNewNode(newPath, 0, "Model Year"); decTreeModel.selectIncomingLinkConditionFormat(cond1,"Model Year = 'integer'"); decTreeModel.setIncomingLinkConditionValue(cond1,0, "1968"); decTreeModel.insertAction(cond1, 0); decTreeModel.selectActionFormat(cond1, 0, "adjustRating(arg0, ...) "); decTreeModel.setActionValue(cond1, 0, 0, "4.0"); decTreeModel.setNodeLabel(cond1, "Rating: 4"); // second condition NdDecTreePath cond2 = decTreeModel.insertNewNode(newPath, 1, "Model Year"); decTreeModel.selectIncomingLinkConditionFormat(cond2,"Model Year < 'integer'"); decTreeModel.setIncomingLinkConditionValue(cond2,0, "1968"); decTreeModel.insertAction(cond2, 0); decTreeModel.selectActionFormat(cond2, 0, "adjustRating(arg0, ...) "); decTreeModel.setActionValue(cond2, 0, 0, "0.0"); decTreeModel.setNodeLabel(cond2, "Rating: 0"); decisionTreeInstanceItem.save(); project.save(); } }

Score Model Editing API


TheNdScoreModelModelinterfaceprovidesthemethodsforeditingascoremodel instance.Mostofthemethodsgetandsetstringandintegervaluesonaninstanceusing indicestocharacteristics,tothebinswithincharacteristics,andtotherangeswithin bins.Forexample,toobtainthelabelofthefirstcharacteristicintheAcademicScore scoremodel,supplytheindexvalue0(base0)astheparameterto getCharacteristicLabel().
// returns: "GPA_Score" int chr = 0; String characteristicLabel = scoreModel.getCharacteristicLabel(chr));

Fair Isaac Confidential and Proprietary Information

31

CHAPTER 2: Metaphor APIs

Similarily,toobtainthelabelofthesamecharacteristicsfirstbin,supplytheindexof characteristicandtheindexofthefirstbin(0)asparameterstothegetBinLabel() method.


// returns: "Between 3.6 and 4.0" int bin = 0; String binLabel = scoreModel.getBinLabel(chr, bin));

Toobtainthenumberofcharacteristicsinthescoremodelandnumberofbinsdefined foraparticularcharacteristic,usethegetCharacteristicCount()andgetBinCount() methods.


// returns: 4 int characteristicCount = scoreModel.getCharacteristicCount(); // returns: 5 int binCount = scoreModel.getBinCount(chr);

TheAcademicScoreInstancefileispartoftheBasicScoreModelexamplein
<ADVISOR_HOME>/examples/repositories/ExamplesRepository/ Metaphors and Templates/Score Models/Basic Score Model.

TheNdScoreModelModelinterfaceincludesmethodstoaddanddeletecharacteristics andbins.Othermethodsgetandsetvaluesfor:characteristiclabelsanddescriptions, thecharacteristicbaselinescore,thebinlabel,andthescoreweightandreasoncodefor abin.Thosemethodsare:addNewCharacteristic(),insertNewCharacteristic(), deleteCharacteristic(),addNewBin(),insertNewBin(),deleteBin(),

32

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

getCharacteristicLabel(),setCharacteristicLabel(), getCharacteristicDescription(),setCharacteristicDescription(), getCharacteristicBaselineScore(),setCharacteristicBaselineScore(), getBinLabel(),setBinLabel(),getBinScoreWeight(),setBinScoreWeight(), getBinReasonCodeName(),andsetBinReasonCodeName().

Eachbininascoremodelcontainsoneormoreranges.The
NdRangeTableCellTemplatesInfoclassisusedtosupplyinformationaboutthecurrent

celltemplateusedbyarangetablecell,aswellastheallowedcelltemplatesforthecell. Toobtainacellsrangeformattemplate,firstcallgetRangeFormatTemplatesInfo()to obtainanNdRangeTableCellTemplatesInfoinstance,thencall getCurrentCellTemplateDisplayName()ontheinstance.Thisexamplecodeobtainsthe rangecelltemplateusedintheBetween3.6and4.0bin.Thetemplatedefines placeholdersfortworealvalues.


int range = 0; NdRangeTableCellTemplatesInfo templatesInfo = scoreModel.getRangeFormatTemplatesInfo(chr, bin, range); // returns: "GPA_Score 'real1' <= .. <= 'real2'" String cellTemplate = templatesInfo.getCurrentCellTemplateDisplayName());

TheNdRangeTableCellRenderingInfoclassisusedtosupplytheinformationnecessary torenderatablerangecell.Togetthevaluesfortheplaceholdersinarange,obtainan NdRangeTableCellRenderingInfoinstancebycallinggetRangeRenderingInfo().The getValue()ofNdRangeTableCellRenderingInforeturnstheplaceholdervaluesina Stringarray.


NdRangeTableCellRenderingInfo renderingInfo = scoreModel.getRangeRenderingInfo(chr, bin, range); // returns: 3.6 and 4 String[] cellPHValues = renderingInfo.getValues();

Intheexamplescoremodel,theGPArangeisbetween3.6and4.0,inclusive.Suppose youwanttochangethebintoaccomodatesomeadvancedplacementstudentswhose GPAcanexceed4.0.YouwillchangethebinlabeloftheBetween3.6and4.0binto Greaterthan3.6,aswellasreplacethecellrangetemplateandplaceholdervalue. Youmaywanttobeginbyobtainingthelistofallowedcelltemplatedisplaynamesby callinggetAllowedCellTemplateDisplayNames()onthe NdRangeTableCellTemplatesInfoobject.


String allowedTemplates[] = templatesInfo.getAllowedCellTemplateDisplayNames(); for (int template = 0; template < allowedTemplates.length; template++) { System.out.println(allowedTemplates[template]); }

Fortheexample,theprintoutputofthiscodeis:
GPA_Score GPA_Score GPA_Score GPA_Score GPA_Score GPA_Score GPA_Score 'real1' <= .. < 'real2' > 'real' < 'real' >= 'real' <= 'real' 'real1' < .. <= 'real2' 'real1' < .. < 'real2'

Fair Isaac Confidential and Proprietary Information

33

CHAPTER 2: Metaphor APIs

TheappropriatecelltemplateisGPA_Score >= 'real':GPAisgreaterthanthe placeholdervalue,inclusive.Fortheexample,thevalueoftheplaceholderwillbe3.6. Thefollowingcodesetsthenewbinlabel,selectstheappropriatetemplateforrange cell,andsetsthevalueofthesingleplaceholderdefinedinthetemplate.


scoreModel.setBinLabel(chr, bin, "Greater than 3.6"); scoreModel.selectRangeFormat(chr, bin, range, "GPA_Score >= 'real'"); scoreModel.setRangeFieldValue(chr, bin, range, 0, "3.6");

AfterrunningthecompletedAPIapplicationandreopeningtheprojectintheGUI,you canconfirmthatthebinisredefined.

TheNdScoreModelModelinterfacehasaseveralothermethodsthatpertaintoranges whichhavenotbeendiscussed,including:getRangeCount(),getRangeDescription(), deleteRange(),andinsertNewRange(). TheNdScoreModelModelinterfacehasmethodswhichareusedtomovecharacteristics, bins,andrangesinascoremodel.Thosemethodsare:moveBinUp(),moveBinDown(), moveCharacteristicsUp(),moveCharacteristicsDown(),moveRangeUp(), moveRangeDown().

Example: List Contents of a Score Model


Theexamplecodebelowcanbeusedwithanyscoremodeltolistallofthemodels characteristicsandbins;aswelltherangecelltemplatenamesdefinedforeachbinand thecorrespondingplaceholdervalues.
NdRangeTableCellTemplatesInfo templatesInfo; NdRangeTableCellRenderingInfo renderingInfo; String[] cellPHValues; int characteristicCount = scoreModel.getCharacteristicCount(); for (int chr = 0 ; chr < characteristicCount; chr++) {
System.out.println("\n" + "Characteristic: " + scoreModel.getCharacteristicLabel(chr));

int binCount = scoreModel.getBinCount(chr); for (int bin = 0; bin < binCount; bin++) { System.out.print(" Bin #" + bin + " '" + scoreModel.getBinLabel(chr, bin)); System.out.print("' Weight: " + scoreModel.getBinScoreWeight(chr, bin));

34

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

System.out.println(" Reason Code: " + scoreModel.getBinReasonCodeName(chr, bin)); int rangeCount = scoreModel.getRangeCount(chr, bin); for (int range = 0; range < rangeCount; range++) { templatesInfo = scoreModel.getRangeFormatTemplatesInfo(chr, bin, range); System.out.print(" "); System.out.println(templatesInfo.getCurrentCellTemplateDisplayName() + " ("); renderingInfo = scoreModel.getRangeRenderingInfo(chr, bin, range); cellPHValues = renderingInfo.getValues(); for (int ph = 0; ph < cellPHValues.length; ph++) { System.out.print(cellPHValues[ph]); if (ph < cellPHValues.length - 1) { System.out.print(" - "); }

} System.out.println(")"); } } }

ThisistheoutputofthecodewhenrunagainsttheAcademicScorescoremodel:
Characteristic: GPA_Score Bin #0 'Between 3.6 and 4.0' Weight: 50 Reason Code: ACAD01 GPA_Score 'real1' <= .. <= 'real2' (3.6 - 4) Bin #1 'Between 2.9 and 3.6' Weight: 30 Reason Code: ACAD02 GPA_Score 'real1' <= .. < 'real2' (2.9 - 3.6) Bin #2 'Between 2.1 and 2.9' Weight: 20 Reason Code: ACAD03 GPA_Score 'real1' <= .. < 'real2' (2.1 - 2.9) Bin #3 'Less than 2.1 ' Weight: 5 Reason Code: ACAD05 GPA_Score 'real1' <= .. < 'real2' (0 - 2.1) Bin #4 'All Other' Weight: 0 Reason Code: UEXP Characteristic: SAT_Score Bin #0 'Greater than 1400' Weight: 50 Reason Code: ACAD01 SAT_Score >= 'real' (1,400) Bin #1 'Between 1200 and 1400' Weight: 30 Reason Code: ACAD02 SAT_Score 'real1' <= .. < 'real2' (1,200 - 1,400) Bin #2 'Between 1000 and 1200' Weight: 20 Reason Code: ACAD03 SAT_Score 'real1' <= .. < 'real2' (1,000 - 1,200) Bin #3 'Between 800 and 1000' Weight: 10 Reason Code: ACAD04 SAT_Score 'real1' <= .. < 'real2' (800 - 1,000) Bin #4 'Less than 800' Weight: 5 Reason Code: ACAD05 SAT_Score 'real1' <= .. < 'real2' (0 - 800) Bin #5 'All Other' Weight: 0 Reason Code: UEXP <..portion removed..> Characteristic: Academic Honors Bin #0 'National Honors' Weight: 50 Reason Code: ACAD01 Academic Honors = 'string' (AP_Scholar) Academic Honors = 'string' (National_Merit_Scholar) Academic Honors = 'string' (National_Honors_Scholar) Bin #1 'Local Honors' Weight: 40 Reason Code: ACAD01 Academic Honors = 'string' (Honor_Roll) Academic Honors = 'string' (Deans_Award) Academic Honors = 'string' (Citizenship_Award) Bin #2 'Service Awards' Weight: 20 Reason Code: ACAD02 Academic Honors = 'string' (Merit_Award) Bin #3 'No Awards' Weight: 0 Reason Code: ACAD06 Academic Honors = 'string' (none) Bin #4 'All Other' Weight: 0 Reason Code: UEXP

Fair Isaac Confidential and Proprietary Information

35

CHAPTER 2: Metaphor APIs

36

Fair Isaac Confidential and Proprietary Information

CHAPTER 3

Custom Provider API


Responsibilities of Provider Classes
ProviderclassesareinvokedbytheInnovatorengineaspartoftheprocessof generatingSRLandothercontentfromatemplateandaninstantiationfile.Inthecase ofaruletemplate,thetemplatefileisresponsiblefordefiningthelogicalstructureofthe rules,andfordefiningtheplaceholderswithinthatstructurewhichallowtherulestobe modified.Theinstantiationfileprovidesthevaluesthatwillbesuppliedforthe placeholderswhencontentisgeneratedfromatemplatescontentsection.Providersare responsibleforprovidingtheInnovatorenginewiththevaluesnecessarytoinstantiate atemplatethatcontainsvalueholders.Whenatemplatecontainsonlyfixedcontentand novaluesholders,thenthedatatheInnovatorengineprocessescomesfromthefixed contentsectionandprovidersarenotinvolved.Providersmustimplementthe followingfunctions: Theyareresponsibleforanytransformationofvaluesthatshouldoccurwhena templateisresolvedagainstaninstantiation.Providerbeansareinvokedbythe Innovatorengineduringtheresolvingprocessandarepassedavalueretrieved fromtheinstantiationobjectmodel. TheyareresponsibleforverifyingthatthevaluetobepassedbacktotheInnovator engineisofthecorrecttype. Certaintemplatesmightrequirethatthevaluessuppliedtothetemplatebe constrainedtobeingonevalueoutofasetofenumeratedvalues.Thisisthecase withthecustomprovidersthatarediscussedinthischapter.Ifaprovideris supplyingvaluesforsuchatemplate,theymustimplementanadditionalinterface, theNdConstrainedListProviderinterface,whichallowstheInnovatorengineto determinewhattheconstraintsare.Theprovidershouldreturnalistofthevalues thatareacceptable. Certaintemplatesmightrequirethatthebehaviorofaprovideriscustomizable. Thisisthecasewithvalueholdersintemplates(definedintheparameterselement oftheXMLtemplatedocument)whichoptionallyoverridetheargumentspassedto providersbytheInnovatorengine.Theexamplecustomprovidersdiscussedinthis chapter,aswellastheexamplecustomprovidersinthe <ADVISOR_HOME>/ examples/customProviders/java/stateProvincedirectory,demonstratetheuseof argumentstocustomizehowtheproviderprocessesvalues.

Fair Isaac Confidential and Proprietary Information

37

CHAPTER 3: Custom Provider API

Overview of the Custom Provider API


Thissectionprovidesanoverviewofthemostimportantclassesandinterfacesofthe CustomProviderAPIforbuildingcustomproviders.Thisoverviewdoesnotdescribe allmethodsintheclassesandinterfaces.RefertotheAPIReferenceforinformationon thesemethods.TheAPIReferencefortheInnovatorCustomProviderAPIisavailableby selectingAPI ReferencefromtheBuilder Helpmenu.

NdTemplateValueProvider Interface
AllprovidersimplementtheNdTemplateValueProviderinterface.Theinterface definesthebasicfeaturesofaprovider.Theinterfaceincludesconversionmethods whicheveryprovidermustsupport.Themethodsallowthevaluespassedinfromthe Innovatorenginetobetransformedinamannerdeterminedbytheprovider.The convertToDisplayValue()methodreturnsthevaluethatshouldbeusedfordisplay purposesinanRMAforagiveninstantiationvalue.Conversely, convertFromDisplayValue()returnsthevaluethatshouldbestoredinthe instantiationobjectforagivendisplayvalue.(Theinstantiationobjectisthebinary representationoftheinstantiationfile.)TheconvertToContentValue()methodisused toconvertaninstantiationvaluetothecontentvalue.However,whentheinstantiation valueandSRLvaluearethesame,whichisusuallythecasewithcustomproviders,no translationoccursandthemethodsimplyreturnstheinstancevaluethatispassedtoit. AnNdProviderContextobjectisanargumentinallofthemethodsofthisinterface.The contextargumentallowstheprovidertoobtaininformationaboutthecontextinwhich theproviderisbeinginvoked.TheNdProviderContextclassincludesthe getContentLocale()methodwhichreturnslocaleinformationasajava.util.Locale object.Theconvertmethodscanusethelocaleinformationtoperformlocalebased conversion. ThesetArgs()methodsetsthevaluesofcontrolvariablesthatcustomizethebehavior oftheprovider.Foradiscussionondesigningcustomproviderswithargumentssee CreatingCustomProviderClassesonpage41. ThevalidateInstantiationValue()methodreturnstrueifthesuppliedvaluefrom theinstantiationobjectsatisfiesalloftheconstraintsthattheproviderhasplacedonthe value.Yoursuppliedinstantiationvaluemustbevalid.Thereforethismethodshould returntrue. OthermethodsreturndescriptiveinformationabouttheprovidertotheInnovator engine.getProviderType()returnsthetypeoftheproviderclassasaString. getValueType()returnsaconstantwhichindicatesthetypeofvalueprovidedbythe provider.

38

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

com.blazesoft.template.engine public interface NdTemplateValueProvider { public void checkInstantiationValue(NdProviderContext context, String instantiationValue); public String convertFromDisplayValue(NdProviderContext context, Object displayValue); public String convertFromJavaObject(NdProviderContext context, Object javaObject); public String convertToContentValue(NdProviderContext context, String instantiationValue); public Object convertToDisplayValue(NdProviderContext context, String instantiationValue); public Object convertToJavaObject(NdProviderContext context, String instantiationValue); public Class getDisplayValueClass(NdProviderContext context); public String getProviderType(NdProviderContext context); public Class getValueClass(NdProviderContext context); public int getValueType(NdProviderContext context); public void reset(NdProviderContext context); public void setArgs(NdProviderContext context, NdProviderStaticArg[] args); }

NdDefaultTemplateValueProvider
NdDefaultTemplateValueProviderisanabstractclassthatprovidesdefault implementationsofthemethodsintheNdTemplateValueProviderinterface.The convertmethods(convertToDisplayValue(),etc.)passvalueswithoutchange. validateInstantiationValue()doesnotapplyanyconstraintsontheinstantiation value.Itreturnstrueforanyinstantiationvaluepassedtoit.setArgs()doesnotprocess anyarguments.

Asaconvenience,providerscansubclassthisclassandoverrideonlythosemethods neededtodefinetheirspecificfunctionality.

NdConstrainedListProvider Interface
NdConstrainedListProviderisasubinterfacetotheNdTemplateValueProvider

interface.Thisinterfaceisimplementedbyaproviderwhenthevalueitprovidesmust beconstrainedtooneofadiscretesetofvalues. ThegetAllowedInstantiationValues()methodreturnsanarrayofallthevaluesthat canbelegallystoredinthenodesoftheinstantiationobjectforwhichtheprovideris providingvalues.ThegetAllowedDisplayValues()methodreturnsanarrayofallthe valuesthatcanbelegallydisplayedforthenodesoftheinstantiationobjectforwhichthe providerisprovidingvalues.ThegetAllowedJavaValues()methodreturnsanarray ofallvaluesthatcanbelegallysupplied to a Java client forthenodesoftheinstantiation object.Eachmethodshouldreturnnulliftheproviderdoesnotimplementtheconstraint thatthevaluebeamemberofasetofdiscretevalues.

Fair Isaac Confidential and Proprietary Information

39

CHAPTER 3: Custom Provider API

com.blazesoft.template.engine public interface NdConstrainedListProvider extends NdTemplateValueProvider { public String[] getAllowedInstantiationValues(NdProviderContext context); public Object[] getAllowedDisplayValues(NdProviderContext context); public Object[] getAllowedJavaValues(NdProviderContext context); }

NdDefaultConstrainedListProvider
NdDefaultConstrainedListProviderisanabstractclassthatextends NdDefaultTemplateValueProviderandimplementsthe NdConstrainedListProviderinterface.Itprovidesdefaultimplementationsfortwoof themethodsintheNdConstrainedListProviderinterface, getAllowedDisplayValues()andgetAllowedJavaValues().Providersthatextend NdDefaultContrainedListProvidermustimplement getAllowedInstantiationValues().ThegetAllowedDisplayedValues()method firstinvokesthegetAllowedInstantiationValues()method(onthesubclasswhich

implementsit)toobtainanarrayoftheallowedinstantiationvalues,andtheninvokes
convertToDisplayValue()oneachelementofthearraytogeneratethearrayof alloweddisplayvalues.ThedefaultimplementationofgetAllowedJavaValue()is identicaltogetAllowedDisplayValues().Bothmethodsreturnanarrayofallowed

displayvalues. ThevalidateInstantiationValue()methodoverridesthedefaultimplementation inheritedfromNdDefaultTemplateValueProvider.validateInstantiationValue() invokesthegetAllowedInstantiationValuesmethodandchecksthatthesupplied valuematchesoneoftheitemsinthearrayofallowedvalues.


com.blazesoft.template.engine public abstract class NdDefaultContrainedListProvider extends NdDefaultTemplateValueProvider implements NdConstrainedListProvider { public Object[] getAllowedDisplayValues(NdProviderContext ctxt); public Object[] getAllowedJavaValues(NdProviderContext ctxt); public boolean validateInstantiationValue(NdProviderContext ctxt, String value); }

NdDesignProvider Interface
TheNdDesignProviderinterfacedefinesthemethodsthatsupplymetainformation abouttheprovider.ThisinterfaceisimplementedbyeverystandardBlazeAdvisor provider,aswellastheexamplecustomprovidersinthe<ADVISOR_HOME>/examples/ customProviders/java/stateProvincedirectory.TheCustomProviderAPIdoesnot includeaclassthatprovidesdefaultimplementationofthesemethods.Yourprovider mustimplementeachofthesemethods. TheNdDesignProviderinterfacedefinesthemethodsthatsupplymetainformation abouttheprovider.ThisinterfaceisimplementedbyeverystandardBlazeAdvisor provider,aswellastheexamplecustomprovidersinthe<ADVISOR_HOME>/examples/ customProviders/java/stateProvincedirectory.TheCustomProviderAPIdoesnot

40

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

includeaclassthatprovidesdefaultimplementationofthesemethods.Yourprovider mustimplementeachofthesemethods. ThegetDisplayName()methodreturnsthedisplaynameoftheprovider.Thedisplay nameoftheproviderappearsintheprovidereditor.ThegetDisplayKey()method returnsakeyvaluewhichidentifiestheprovidersiconbitmapanditslabel. getDescription()returnsthedescriptionoftheprovider.Thedescriptionisdisplayed InNew Providerdialogboxwhentheprovidersiconisselected.Thismethodisnotused withcustomproviders,sincecustomprovidericonsdonotappearintheNew Provider dialogbox. ThegetArgumentDescriptors()methodreturnsthedescriptionfortheproviders arguments.Ifnoargumentsaresupportedthismethodmustreturnanarrayofzero length(i.e.,return NdDesignProviderArg[0];).
com.blazesoft.template.engine.provider public interface NdDesignProvider { public String getDisplayName(NdProviderContext context); public String getDescription(NdProviderContext context); public String getDisplayKey(NdProviderContext context); public NdDesignProviderArg[] getArgumentDescriptors(NdProviderContext context); }

NdProvidesDefaultValue Interface
TheNdProvidesDefaultValueinterfacedefinesthewayforvalueproviderstoprovide thedefaultvalues.Providersimplementthisinterfaceiftheyarecapableofprovidinga meaningfuldefaultvalueforthetypeofvaluethattheyrepresent. TheprovideDefaultValue()methodreturnsadefaultvalueforthetypeofvalue representedbythisvalueprovider.provideUniqueDefaultValues()returnsa sequenceofuniquedefaultvaluesforthetypeofvaluerepresentedbythisvalue provider.Iftheprovidercannotgeneratethenumberofvaluesspecifiedinthe numValuesparameter,thenitshouldreturnanarrayofsmallersizethatcontainsallof thevaluesthatitwasabletogenerate.
com.blazesoft.template.engine public interface NdProvidesDefaultValue { public String provideDefaultValue(NdProviderContext context); public String[] provideUniqueDefaultValues(NdProviderContext context, int numValues); }

Creating Custom Provider Classes


Thecustomprovidersinthecustomprovidersexample(seetheexamplein <ADVISOR_HOME>/examples/customProviders/java)demonstratehowtousethe CustomProviderAPItocreateyourownconstrainedvaluelistcustomprovider.This sectionfocusesonthekeyelementsofcreatingcustomproviders,withreferencetothe examplecode.Youmaywanttoopenthesourcecodeinaneditorandchangethe

Fair Isaac Confidential and Proprietary Information

41

CHAPTER 3: Custom Provider API

valuesorattempttoaddcapabilitybyimplementinganappropriateinterface.The sourcecodefortheexamplecustomprovidersisavailableinasubdirectoryofthe exampledirectorynotedabove. Twoverysimplecustomprovidersarepresentedfirst.Thesecustomproviders demonstratesomeoftheessentialfeaturesoftheCustomProviderAPIwithminimal code.Thesourcecodeforthesimplecustomprovidersisnotincludedinthecustom providersexamplefolder.

Simple Value List Provider


TheSimpleValueListProvidercustomproviderprovidesaStringvaluethatis constrainedtooneofadiscretesetofvalues.Thiscustomproviderisfunctionally similartoavaluelistproviderthathasbeenconfiguredtosupplyavaluefromalistof Stringvalues. ThegetAllowedInstantiationValuesmethodreturnsthesetofdiscretevaluesthatis definedfortheprovider.SimpleValueListProviderrequiresverylittlecodebecauseit isderivedfromclassesthatsupplydefaultimplementationsoftheinterfacemethods thatarerequiredforconstrainedlistproviders.
// SimpleValueListProvider.java public class SimpleValueListProvider extends NdDefaultConstrainedListProvider { public final static String PROVINCES_ABBREV[] = {"AB", "BC", "MB", "NB", "NL", "NT", "NS", "NU", "ON", "PE", "QC", "SK", "YT"}; public SimpleValueListProvider() { } public String[] getAllowedInstantiationValues(NdProviderContext context) throws com.blazesoft.template.engine.NdTemplateException { return PROVINCES_ABBREV; } }

Thelistofalloweddisplayvaluesappearsintheprovidereditor,asshownbelow.

42

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

RecallthattheNdContrainedListProviderinterfaceisimplementedbyaprovider whenthevalueitprovidesmustbeconstrainedtooneofadiscretesetofvalues(see NdConstrainedListProviderInterfaceonpage39).Thethreemethodsofthisinterface returntheallowedsetsofinstantiation,display,andJavavalues.Allconstrainedlist providersmustimplementthegetInstantiationValues()methodoftheinterface, whichreturnsaStringarrayofallvaluesthatcanbelegallystoredintheinstantiation objectforwhichtheproviderisprovidingvalues.TheCustomProviderAPIdoesnot supplyadefaultimplementationofthismethodsincethearraywouldalwaysbe uniquetotheprovider. TheInnovatorenginedeterminesthelistofdisplayvalueswhichappearinadrop downlistinanRMAbycallingconvertToDisplayValue()foreveryvalueinthearray returnedbygetInstantiationValues().Thedefaultimplementationof convertToDisplayValue()inNdDefaultTemplateValueProviderreturnsthevalue thatispassedtoit,sonoconversionoccurs.Thedisplayvalueisthesameasthe instantiationvalue.

Simple SRL and Display List Provider


TheSimpleSRLAndDisplayListProvidercustomproviderisaconstrainedlist providerjustasisSimpleValueListCustomProvider.BothprovidersprovideaString valuethatisconstrainedtooneofadiscretesetofvalues.Thekeydifferencebetween thetwoisthatSimpleSRLAndDisplayListCustomProvideralsoprovidesaunique RMAdisplayvalueforeachinstantiationvalue.
DisplayValuesProvideristhebaseclassforthecustomprovidersexamples,whichare

describedinCustomProvidersExampleonpage33ofExamples.pdf. DisplayValuesProviderisdiscussedinTheExampleBaseClassonpage50.

Fair Isaac Confidential and Proprietary Information

43

CHAPTER 3: Custom Provider API

ProvidersthatextendDisplayValuesProvidermustimplement getInstantiationValues() andgetDisplayedValues(). getInstantiationValues()returnsthearrayofallowedinstantiationvalues.The getDisplayedValues()methodreturnsthearrayofvaliddisplayvaluesthat correspondtothearrayofallowedinstantiationvalues.Thetwoarrayscorrespondinthe sensethatforagivenarrayindex,avalidinstantiationvalueandthecorresponding validRMAdisplayvalueforthatinstantiationvaluemaybeobtained.


public class SimpleSRLAndDisplayListProvider extends DisplayValuesProvider implements NdDesignProvider { public final static String PROVINCES_ABBREV[] = { "AB", "BC", "MB", "NB", "NL", "NT", "NS", "NU", "ON", "PE", "QC", "SK", "YT" }; public final static String PROVINCES[] = { "Alberta", "British Columbia", "Manitoba", "New Brunswick", "Newfoundland and Labrador", "Northwest Territories", "Nova Scotia", "Nunavut", "Ontario", "Prince Edward Island", "Quebec", "Saskatchewan", "Yukon" }; private String[] instantiationValues; private String[] displayValues; public SimpleSRLAndDisplayListProvider() { } protected String[] getInstantiationValues() throws NdTemplateException { instantiationValues = PROVINCES_ABBREV; return instantiationValues; } protected String[] getDisplayedValues() throws NdTemplateException { displayValues = PROVINCES; return displayValues; } public NdDesignProviderArg[] getArgumentDescriptors(NdProviderContext parm1) throws com.blazesoft.template.engine.NdTemplateException { return new NdDesignProviderArg[0]; } public String getDisplayName(NdProviderContext parm1) throws com.blazesoft.template.engine.NdTemplateException { return ""; } public String getDescription(NdProviderContext parm1) hrows com.blazesoft.template.engine.NdTemplateException { return "SRL and display value provider for list of Canadian provinces and territories."; } public String getDisplayKey(NdProviderContext parm1) throws com.blazesoft.template.engine.NdTemplateException { return "Custom Provider"; } }

TheDisplayValuesProviderclassoverridesthedefaultimplementationofthe NdTemplateValueProviderinterfaceconvertmethods.Eachofthesemethodsusethe valuelistsreturnedbygetDisplayValues()andgetInstantiationValues()to performthenecessaryvalueconversion.

44

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

AsappliedtotheSimpleSRLAndDisplayListProviderprovider,the convertToDisplayValue()methodreturnsthedisplayvalueinthePROVINCESarray returnedbygetDisplayValues()thatcorrespondstoagiveninstantiationvaluewhich ispresentinthePROVINCES_ABBREVarrayreturnedbygetInstantiationValues().


// from DisplayValuesProvider.java public Object convertToDisplayValue(NdProviderContext context, String value) throws NdTemplateException { String displayValue = ""; String[] displayedValues = getDisplayedValues(); String[] storedValues = getInstantiationValues(); if (displayedValues != null && storedValues != null) { for (int index = 0; index < storedValues.length; index++) { if (storedValues[index].equals(value)) { displayValue = displayedValues[index]; break; } } } return displayValue; }

Customizing Provider Behavior Using Arguments


TheSimpleSRLAndDisplayListProviderproviderdiscussedintheprevioussection (SimpleSRLandDisplayListProvideronpage43)isfunctionallyidenticaltothe defaultbehavioroftheConstantDisplayValuesProviderexampleprovider,as determinedbytheprovidersdefaultargumentsettings.The ConstantDisplayValuesProviderprovidersupportsU.S.statesaswellasCanadian provincesandterritories. TheConstantDisplayValuesProviderprovidersdefaultsettingfortheDisplay Value argumentconfigurestheprovidertodisplaythefullnames,ratherthantheabbreviated names,ofeitherstatesorprovincesintheRMA.ThedefaultList Contentssetting restrictstheprovidertoprovidingvaluesforCanadianprovincesandterritoriesonly. TheList ContentsdropdownlistallowsuserstoselectbetweenState,Province/territory andBoth.Theabilitytocustomizethebehavioroftheprovidersets ConstantDisplayValuesProviderapartfromtheSimpleValueListProviderwhich doesnotsupportproviderarguments.

Fair Isaac Confidential and Proprietary Information

45

CHAPTER 3: Custom Provider API

Providerargumentdescriptorsaredefinedintheproviders getArgumentDescriptors()method.Youcanchangethedefaultvaluesofthe argumentsintheprovidereditor.Youcanoverridethedefaultvaluesinaprovider valueholderbyusingthevalueholdersSet Argumentsdialogbox.Whenargument valueschange,theInnovatorenginecallstheproviderssetArgs()method.setArgs() isalsocalledwheneveravaluemustbeprovidedtoavalueholder.setArgs()ispassed anarrayofproviderarguments.Inthecourseofprocessingthearguments,setArgs() willtypicallysetthevaluesofvariableswhichareusedelsewhereintheprovidercode tocontroltherequiredbehavior.

Defining Argument Descriptors


ThegetArgumentDescriptors()methodofConstantDisplayValuesProvider definestwoNdDesignProviderSelectableArgargumentdescriptors,displayType andlistType.TheNdDesignProviderSelectableArgclassdefinesasinglevalued argumentthatcantakeitsvaluefromalistofchoicespresentedtotheuserinadrop downbox.displayTypedescribesanargumentthatisnamedDisplayTypeinthe constructor,asyoucanobserveinthecodebelowforthegetArgumentDescriptors() method.ThesetArgs()methodidentifiestheargumentbythisname,asdescribedin thenextsection.setDisplayName()setsthelabelfortheargumentintheprovider editor,whichisDisplayValue.setDescription()setsthedescriptionofthe argument.setChoices()setstheactualchoicevaluesthatsetArgs()obtainsusingthe argumentsgetValuemethod.Theargumentisdefinedwithtwochoicevalues:Full nameandAbbreviatedname.(NotethatStringconstantsareusedinplaceof Stringliteralsinthecode.)ThesamevaluesareusedinsetDisplayChoices(),which setsthedisplayedchoicelabelsastheyappearintheprovidereditor.The setDefaultValue()methodiscalledtosetthedefaultvalueoftheargumenttoFull name.setMandatory()setswhetherornottheargumentismandatory.

46

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

ThelistTypeNdDesignProviderSelectableArgissetupinthesamefashion.The nameoftheargumentbeingdefinedisListType.Thelabelfortheargumentinthe providereditorisListContents.Thelistofchoiceswhichwillappearinadropdown boxintheeditorisState,Province/territory.andBoth.Thedefaultchoiceis State. ComparethecodebelowwiththeimageoftheConstantDisplayValuesProvidereditor intheprevioussection(CustomizingProviderBehaviorUsingArgumentsonpage 45).


// from ConstantDisplayValuesProvider.java public NdDesignProviderArg[] getArgumentDescriptors(NdProviderContext parm1) throws com.blazesoft.template.engine.NdTemplateException { NdDesignProviderSelectableArg displayType = new NdDesignProviderSelectableArg("DisplayType"); displayType.setDisplayName("Display Value"); displayType.setDescription("Display the full name or abbreviation"); // displayType.setChoices(new String[] {"Full name", "Abbreviated name"); displayType.setChoices(new String[] {DISPLAY_TYPE_FULL, DISPLAY_TYPE_ABBREV}); displayType.setDisplayChoices(new String[] {DISPLAY_TYPE_FULL, DISPLAY_TYPE_ABBREV}); // displayType.setDefaultValue("Full name"); displayType.setDefaultValue(DISPLAY_TYPE_FULL); displayType.setMandatory(true); NdDesignProviderSelectableArg listType = new NdDesignProviderSelectableArg("ListType"); listType.setDisplayName("List Contents"); listType.setDescription("Display the states, provinces, or both"); // listType.setChoices(new String[] {"State", "Province/territory", "Both"}); listType.setChoices(new String[] {LIST_TYPE_STATE, LIST_TYPE_PROVINCE, LIST_TYPE_BOTH}); listType.setDisplayChoices(new String[] {LIST_TYPE_STATE, LIST_TYPE_PROVINCE, LIST_TYPE_BOTH}); // listType.setDefaultValue("State"); listType.setDefaultValue(LIST_TYPE_STATE); listType.setMandatory(true); return new NdDesignProviderArg[] { listType, displayType } ; }

Asdescribedabove,theConstantDisplayValuesProviderproviderusessingle valuedNdDesignProviderSelectableArg()argumentdescriptorsthatdefine argumentsthatcantaketheirvaluefromalistofchoices.The UserDefinedDisplayValuesProviderproviderinthecustomprovidersexampleuses singlevalueNdDesignProviderTypeArgargumentsdescriptors.Thisclassdefinesa singlevaluedargumentthatisnotrestrictedtoselectionfromapredeterminedsetof choices.Valuesareenteredinatextbox. TheexampleUserDefinedDisplayValuesProviderproviderusesamultivalued argumentdescriptor(NdDesignProviderMultiArg),labeledElement,thatiscomposed oftwosingleargumentsoftypeNdDesignProviderTypedArg,whicharelabeled StoredValueandDisplayedValue.Theuserwhoisconfiguringtheprovidercan createanynumberofElementargumentsintheprovidereditor.EachElementspecifies astateorprovenceabbreviationwiththedisplayedname,suchasABandAlberta.

Fair Isaac Confidential and Proprietary Information

47

CHAPTER 3: Custom Provider API

InthecodebelowforthegetArgumentDescriptors()methodofthe UserDefinedDisplayValuesProvider,thenamesofthetwo NdDesignProviderTypedArgsingleargumentsarespecifiedinthecallstothe constructor.Thenames,StoredValueandDisplayedValue,identifythearguments whentheyareprocessedinthesetArgsmethod.ThesetDisplayName()methodis calledtosetthedisplaynamesofthearguments,whichareContentValueand DisplayValue.Thesevaluesareusedaslabelsforthesingleargumentsinthe Elementshownintheimageabove.setDescription()iscalledtosetthedescriptionof eachargument,butthedescriptiondoesnotappearintheprovidereditor.setType()is calledtosettheargumenttypetoString.setDefaultValue()setsthedefaultvalueof theargumenttoanemptystring. Asmentionedabove,theNdDesignProviderMultiArgclassdescribesaproviders multivaluedargument.ThestorednameoftheargumentissettoElementinthe constructor.ThisisthenamethesetArgs()methodusestoidentifytheargument.The setDisplayName()methodiscalledtosetthedisplaynameoftheelements,whichis Element,asshownintheimageabove.ThesetNewCmdName()methodiscalledtoset thevalueofthetooltip,whichisNewElement.ThesetMultiple()methodiscalled tosetwhethertheargumentcanbemultiple,whichistrueinthecaseofthismultiple argument.ThesetArgumentDescriptors()methodispassedanarrayof NdDesignProviderArgwhichincludesthetwosingleNdDesignProviderTypeArg arguments.Finally,thegetArgumentDescriptors()methodreturnsthe NdDesignProviderArgelementargumentdescriptorthathasbeendefined.
// from UserDefinedDisplayValuesProvider.java public NdDesignProviderArg[] getArgumentDescriptors(NdProviderContext context) throws NdTemplateException { NdDesignProviderTypedArg storedValue = new NdDesignProviderTypedArg("StoredValue"); storedValue.setDisplayName("Content Value"); storedValue.setDescription("SRL value generated during runtime"); storedValue.setType(NdTemplateManager.BUILTIN_STRING_PROVIDER); storedValue.setDefaultValue(""); NdDesignProviderTypedArg displayedValue = new NdDesignProviderTypedArg("DisplayedValue"); displayedValue.setDisplayName("Display Value"); displayedValue.setDescription("Value displayed to the user"); displayedValue.setType(NdTemplateManager.BUILTIN_STRING_PROVIDER);

48

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

displayedValue.setDefaultValue(""); NdDesignProviderMultiArg element = new NdDesignProviderMultiArg("Element"); element.setDisplayName("Element"); element.setDescription("List Element"); element.setDisplayKey("Value"); element.setGroup("Element"); element.setNewCmdName("New Element"); element.setMultiple(true); element.setArgumentDescriptors(new NdDesignProviderArg[]{storedValue, displayedValue}); return new NdDesignProviderArg[]{element}; }

Processing Arguments
Asmentionedabove,thesetArgs()methodofaprovideriscalledbytheInnovator engine.ThesetArgs()methodispassedNdProviderStaticArgargumentswhichare processedinthemethod. TheConstantDisplayValuesProviderproviderdefinestwoStringvariables, displayTypeandlistType.Thevariablesareusedtocustomizethebehaviorofthe provider.TheproviderssetArgs()methodassignsthevalueintheargumentnamed DisplayTypetodisplayTypeandthevalueoftheargumentnamedListTypeto listType.
// from ConstantDisplayValuesProvider.java public void setArgs(NdProviderContext context, NdProviderStaticArg[] args) throws NdTemplateException { if (args != null & args.length > 0) { for (int index = 0; index < args.length; index++) { if (args[index].getName().equals("DisplayType")) { displayType = args[index].getValue(); } else if (args[index].getName().equals("ListType")) { listType = args[index].getValue(); } } } }

TheprovidersgetInstantiationValuesandgetDisplayValuesmethodsuse displayTypeandlistTypetodeterminetheappropropriatearraytoreturn.For example,thegetInstantiationValuesmethodreturnstheSTATE_ABBREVarrayif listTypeequalsStates.ItreturnsthePROVINCE_ABBREVarrayiflistTypeequals Province/territoriesanditconcatenationofbotharraysiflistTypeequalsBoth.


// from ConstantDisplayValuesProvider.java protected String[] getInstantiationValues() throws NdTemplateException { if(listType.equals(LIST_TYPE_STATE)) { initializationValues = STATES_ABBREV; } else if(listType.equals(LIST_TYPE_PROVINCE)) { initializationValues = PROVINCES_ABBREV; }

Fair Isaac Confidential and Proprietary Information

49

CHAPTER 3: Custom Provider API

else { String[] allowedValues = new String[STATES_ABBREV.length + PROVINCES_ABBREV.length]; System.arraycopy(STATES_ABBREV, 0, allowedValues, 0, STATES_ABBREV.length); System.arraycopy(PROVINCES_ABBREV, 0, allowedValues, STATES_ABBREV.length, PROVINCES_ABBREV.length); initializationValues = allowedValues; } return initializationValues; }

The Example Base Class


TheDisplayValuesProviderclassisusefulforcreatingmanycustomproviders.The classisnotpartoftheCustomProviderAPI.Itisincludedwiththecustomproviders example.Thesourcecodeandclassfilesforallexamplecustomprovidersareavailable inthe<ADVISOR_HOME>/examples/customProviders/java/stateProvincefolder.The classextendsNdDefaultContrainedListProvider.Theexamplecustomprovidersin theexampleextendDisplayValuesProvider,whichisanabstractclass. ProvidersthatextendDisplayValuesProviderclassmustimplementthetwoabstract methodsthataredeclaredintheclass,getInstantiationValues()and getDisplayValues().getInstantiationValues()returnsaStringarraythat containstheallowedinstantiationvalues.Theproviderscontentvaluesarethesameas theinstantiationvaluesunlesstheprovideroverridesthedefaultimplementationofthe convertToContent()method,whichensurestheyarethesamevalue.The getDisplayValues()methodreturnsaStringarraythatcontainsthealloweddisplay values.TheStringarraysreturnedbygetInstantiationValues()and getDisplayValues()areconstructedinparallel,suchthatforagivenarrayindex,a validinstantiationvalue(again,thisisalsothecontentorSRLvalue)andthe correspondingvalidRMAdisplayvaluemaybeobtained. Recallthatitistheresponsibilityofaconstrainedlistprovidertodefinethevalid values.Eachproviderisfreetoobtainthevaluesitprovidesinanyfashion.The exampleprovidersdemonstratedifferentmethodsforobtainingvaluelists.The StaticClassMethodProviderobtainsvaluesbycallingstaticaccessormethodsona classthatdefinestheappropriateStringarraysasconstants.Thenameoftheclassthat holdsthevaluesandthenamesoftheappropriateaccessormethodsarespecifiedwhen theproviderisconfiguredintheprovidereditor.The UserDefinedDisplayValuesProvider ispassedvaluesthatauserdefinesinelements intheprovidereditor.ThevaluesarepassedasargumentstotheproviderssetArgs() method.Finally,theConstantDisplayValuesProviderobtainsvaluesfromString arraysdefinedintheclass. TheimplementationsofgetAllowedDisplayValues()andgetAllowedJavaValues() methodsintheDisplayValuesProviderclassbothreturnaStringarrayobtainedby callinggetDisplayedValues().Comparethisimplementationtothedefault implementationdescribedinNdDefaultConstrainedListProvideronpage40,which obtainsdisplayvaluesbyinvokingconvertToDisplay()oneachelementoftheString arrayreturnedbygetAllowedInstantiationValues().

50

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

ThegetAllowedInstantiationValues()methodoftheDisplayValuesProvider classreturnsanarrayofallthevaluesthatcanbelegallystoredinthenodesofthe instantiationobject,asdescribedinNdConstrainedListProviderInterfaceonpage39. ThegetAllowedInstantiationValues()methodcallsgetInstantiationValues()to obtaintheallowedinstantiationvalues.getAllowedInstantiationValues()iscalled bytheprovidersvalidateInstantiationValue()method,whichreturnstrueifits parametervalueiscontainedinthearrayofvalidinstantiationvaluesreturnedbythis method. TheDisplayValuesProviderclassoverridesthedefaultimplementation(in NdDefaultConstrainedListProver)ofalltheNdConstrainedListProverinterface convertmethods.FordescriptionofthesemethodsseeNdTemplateValueProvider Interfaceonpage38.TheDisplayValuesProviderimplementationofthesemethods eachmakeuseoftheallowedinstantiationvaluesreturnedby getInstantiationValues(),aswellasthealloweddisplayvaluesreturnedby getDisplayedValues().

Custom Provider Implementation Guidelines


Whencreatingcustomproviderclassesconsiderthefollowinggeneralimplementation guidelines: CustomProviderclassesgetinstantiatedonceperprojectandperuser.Sofor instance,ifyouhave10concurrentusersofanRMA,thiswillresultinto10 instancesofthatCustomProviderclassbeingcreated. Whenprovidersarecalledbyourcode,theyretypicallyalwaysusedinthis sequence: First,thereset()methodiscalled. Then,thesetArgs()methodiscalled. Finallytheoperationofchoiceiscalled(suchasgetAllowedDisplayValues(), orconvertToContentValue(),orvalidateValue().forinstance). Thebottomlineisthatthereset()andsetArgs()methodsarecalledveryoften. Sometimesjusttogetthetypeofproviderorthetypeofvaluereturnedbythe provider.Socaremustbetakentoavoiddoingcostlyoperationsinthereset()and setArgs()methods.Alsothosemethodsshouldnotthrowanyruntimeexception. Anyoperationthatiscostlytocomputeormayfailshouldbedoneonlyasthe resultofcallingoneoftheothermethods. Ifsomeoperationdonebyacustomproviderclassisverycostly(forinstance, readinginformationfromadatabase,orreturningalistofSRLentitiesofa particulartypeinthecurrentproject),thencaremustbetakentoavoiddoingthe sameoperationtoomanytimes.Cachinginformationinalocal,private,nonstatic Hashtablefieldforinstanceisacommonwaytokeepandreusepreviousresultsif thoseresultsdonotchangebetweeninvocationsoftheprovider. Evenifresultsmaychangebetweeninvocations,youmaystillusecaching techniques,butyoumustalsoworryaboutinvalidatingthecacheifpartofit becomesinvalid.Forinstance,ifyouvereadinformationfromfilesthatresideon

Fair Isaac Confidential and Proprietary Information

51

CHAPTER 3: Custom Provider API

yourfilesystemandkeptthatinformationinsomelocalcache,indexedbythefile location,youshouldinvalidatetheinformationassociatedwiththatfileifyou detectthatfilehasbeenmodified(usingtheLastModifiedattributeofthefilefor instancetodetectwhetherafilehaschanged). Forimplementingcaches,itsimportanttonotethatitisthesameCustomProvider classthatissharedbetweenallRMAsessions,socaremustbetakenifthe informationisstoredinastaticfield.ItmightbeOKtouseastaticfieldforsuch cacheddata,butonlyifthecacheddataisconstantandcanindeedbesharedacross allsessions.Alsothecodethatreadsfromorwritestothatcachemustbe synchronizedtopreventmultiplethreads/sessionstoaccessthatdataatthesame timeinanuncoordinatedfashion(thrashing). Ifthecacheddatacouldgrowtoalargeamountovertime,youcouldadd additionaltechniquestopartiallyreleasethememorykeptbytheoldestpartsof yourcache,suchasusingweakreferencesorweakhashmapstokeepreferencesto cacheddata. Intheparticularcasewherethedatabeingretrievedisstoredinadatabase,you shouldconsidernotonlycachingthedataretrievedfromthatdatabasebutalso sharingorpoolingofconnections(toavoidhavingeachsessionresultintoanew databaseconnection). Intheparticularcasewherethedatabeingretrievedcomesfromthecurrentproject content,youshouldusethenewNdPromProviderUtil.getPromProject()method toretrievethecurrentNdPromProject,andfromthatgetthelistofdirectories,items, andentitiesthatarerelevanttotheprovider(insteadofusingmethodssuchas NdTemplateManager.loadInstantiation()).Themainbenefitsofusingthenew PROMAPIsarethattheygiveafullyobjectifiedviewofwhatsinthecurrent project,aswellascacheallnecessaryinformation.

52

Fair Isaac Confidential and Proprietary Information

CHAPTER 4

RMA API
TheRMAAPIisahighlevelAPIfordevelopersbuildingrulemaintenanceapplications (RMAs).TheAPIisindependentoftheexecutionenvironment,soitisnotlimitedto webbasedapplications,butcanbeusedtobuildRMAsinotherenvironments includingJavaSwing. TheRMAAPIoffersasimplesetofinterfacesgearedtowardseditinginstancesof templates.AswiththePROMAPI,theRMAAPIoperationsarealwaysperformedin thecontextofaproject.TheAPIprovidesasimplemeansofconnectingtoeithera versionedornonversionedrepository,openingaproject,navigatingthecontentsofthe projectinordertofindrelevantinstances,andthenmakingitpossibletoeditandsave thoseinstances.TheAPIalsoallowsthecreationofnewinstancesfromtemplatesfound intheproject,aswelltheexecutionofqueriestofindentriesofinterestwithinthe project.PropercollaborationwiththeversioningsystemisprovidedbytheAPIaswell.

The RMA Repository (NdRmaRepository)


AnRMAapplicationwhichusestheRMAAPIbeginsbyobtaininganinstanceof NdRmaRepositorybypassingarepositoryconnectionobjecttothe connectToRepository()methodofNdRmaRepositoryFactory.TheNdRmaRepository instanceisusedtoopenanRMAproject(seeRMAProject(NdRmaProject)onpage 54).NdRMARepositorysuppliestwomethodsforopeningaproject.
NdRmaProject openProject(String projectFullDisplayPath) NdRmaProject openProject(NdLocation projectAbsoluteLocation)

Bothmethodsacceptaparameterwhichspecifiesthelocationoftheprojectasan absolutelocationfromtherootdirectoryoftherepository.Thedifferencebetweenthe twoisthattheparametertotheopenProject(String projectFullDisplayPath) methodisaStringpathwhichisbuiltwithdisplaynames,astheyappearinthe BuilderIDE.Incontrast,theopenProject(NdLocation projectAbsoluteLocation) methodopenstheprojectatthelocationspecifiedbyanabsoluteNdLocation.File systemnamesareusedwhencreatinganNdLocation,ratherthandisplaynames.The latermethodisusedwhenfilesystemnamesarepreferredoverdisplaynamesandin thosecaseswherethelocationoftheprojectwasobtainedbyusingtheROMandPROM APIs,butitwasdeemedpreferabletodealwiththatprojectasanNdRmaProject.See SpecifyingaLocation(NdLocation)onpage15fordiscussiononcreatinganabsolute NdLocation.

Fair Isaac Confidential and Proprietary Information

53

CHAPTER 4: RMA API

TheNdRmaRepositoryinterfaceconsistsprimarilyofmethodswhichsupplyinformation abouttherepositoryconnectionandtherepository.
boolean isVersionControlled() boolean isPrivateWorkspaceUsed() boolean isConnected() void disconnect() Date getConnectionDate() NdRepositoryConnection getRepositoryConnection()

TheisVersionControlled()methodreturnstrueiftherepositorysupportsversioning operations.isPrivateWorkspaceUsed()returnstrueiftherepositoryusesaprivate workspace.isConnected()returnstrueiftherepositoryisconnected.disconnect() disconnectsfromtherepository.getConnectionDate()returnstheconnectiondate. formatDateForDisplay()returnsthesuppliedDateasalocalizedrepresentationofthe connectiondate.getRepositoryConnection()returnstheNdRepositoryConnection objectthatwasusedtoconnecttotherepository.Youcanobtaininformationaboutthe repositoryconnectionwiththisobject,suchasthenameoftherepositoryortheuser name.


NdRmaRepositoryalsocontainstwoutilitymethodsfordisplayingdates. String formatDateForDisplay(Date date) String formatDateForDisplay(Date date, Locale locale, TimeZone timeZone)

TheformatDateForDisplay(Date date)methodreturnsthesuppliedDateasa localizedString.TheformatDateForDisplay(Date date, Locale locale, TimeZone timeZone)methodincludesparameterstospecifytheLocaleandTimeZoneusedto formatthedate.

RMA Project (NdRmaProject)


AnRMAprojectisrepresentedbyNdRmaProject,whichisobtainedbycalling openProject()methodoftheNdRmaRepositoryinterface.
NdFileRepositoryConnection connection = new NdFileRepositoryConnection(); connection.setUser("Template Developer"); connection.setRepositoryFolder("../../repositories/MerchandisingExampleRepository"); NdRmaRepository rmaRepository = NdRmaRepositoryFactory.connectToRepository(connection); NdRmaProject rmaProject = rmaRepository.openProject("/Business Library/MerchandisingRMA");

TheNdRmaProjectinterfaceprovidesanumberofmethodstonavigatethedirectories referencedbytheproject,aswellastheircontents.
NdRmaDirectory[] getDirectories(boolean includeSystemDirectories) NdRmaDirectory[] getAllDirectories() void resetDirectories() NdRmaDirectory addDirectory(String directoryDisplayName) void deleteDirectory(NdRmaDirectory directory)

ThegetDirectories()methodreturnsthedirectorieswhichareimportedbythe projectandtheprojectssubprojects.getAllDirectories()returnsthedirectories importedbytheprojectandtheprojectssubprojects,aswellasallthesubdirectoriesof theprojectanditssubprojects.

54

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

Thelistofdirectoriesiscachedbytheprojectobject,soeverytimethesemethodsare invokedthesameresultsareassured.Toobtainaccuratelistsintheeventtheproject directoriesintherepositorychange,callresetDirectories()toresetthecachedlists. InvoketheaddDirectory()anddeleteDirectory()methodstoaddadirectoryor removeadirectoryfromtheproject,respectively.Thedirectoryiscreatedattherootof therepository.Anewdirectoryistypicallyusedforsavingqueryinstances. Forconvenience,specificmethodsarealsoprovidedtoobtainalltheentries representingtemplates,instances,querytemplatesandqueryinstancesintheproject.


NdRmaTemplate[] getAllTemplates() NdRmaInstance[] getAllInstances() NdRmaQueryInstance[] getAllQueryInstances() NdRmaTemplate[] getAllQueryTemplates() void setEntryExclusionFilter(NdRmaEntryExclusionFilter exclusionFilter)

ThegetAllTemplates()methodreturnsallthetemplatesintheproject. getAllInstances()returnsalltheinstancesintheproject.getAllQueryInstances() returnsallthequeryinstancesintheproject.getAllQueryTemplates()returnsallthe querytemplatesintheproject.Thesemethodsbydefaultreturnalltheentriesthatare foundwhentraversingthedirectoriesimportedbytheproject.However,aspecial method,setEntryExclusionFilter(),allowsclientcodetoprovidean NdRmaEntryExclusionFiltertoautomaticallyfilteroutunwantedresultswhenthese entrycollectingmethodsareused.PassingnulltosetEntryExclusionFilter()will removethefilterandthusresetthebehaviorofthosemethodstothedefault. Amethodisprovidedforobtaininganentrybyitslocation.
NdRmaEntry lookupEntryByLocation(NdLocation absoluteLocation)

ThelookupEntryByLocation()methodobtainstheNdRmaEntryatthesuppliedabsolute location(NdLocation)fromtherepositoryroot.Themethodisconvenientforswitching totheRMAAPIafterhavingnavigatedtherepositoryusingtheROMandPROMAPIs. NotethatanNdRmaEntrymaybeeitherafileoradirectory.NdRmaEntryhasa complementarymethod,getLocation(),whichreturnstheNdLocationcorresponding totheentry.Foradiscussiononthedistinctionbetweenanabsoluteandrelative NdLocation,seeSpecifyingaLocation(NdLocation)onpage15. Errorsthatmayoccurwhendealingwiththeprojectmaybehandledwiththefollowing methods:


boolean hasErrors() NdRMAException[] getErrors() void clearErrors()

ThehasErrors()methodreturnstrueiferrorswerefoundwhileperformingany operationontheproject.getErrors()returnstheerrorsthatwerefoundwhile performinganyoperationontheproject.clearErrors()clearsthelistoferrorsthat werekeptsincethelastcalltothismethod.Considerclearingthecachedlistoferrors priortoperformingadiscretesetofoperationsontheproject,sothatthesuccessivecalls tohasErrors()andgetErrors()reflectonlytheerrorsintheimmediateset.

Fair Isaac Confidential and Proprietary Information

55

CHAPTER 4: RMA API

NdRmaProjectsupportsversioningbyvirtueofextendingNdRmaEntry,whichhas

methodsforobtainingversioninginformationandversioningoperations. Aprojectinaversionedrepositoryprovidesversioninginformationandsupports versioningoperations,butnotthegetVersion(),promote(),andrestore()methods. (SeeVersioningonpage63.)

RMA Entry (NdRmaEntry)


AnNdRmaEntryiseitheraprojectdirectoryorafileinaproject.Thisissimilartoan NdPromEntryinthePROMAPI,thatiseitheradirectoryoranitem,whichistheROM APIandPROMAPItermforafile. TheNdRmaEntryinterfaceincludesthefollowingmethods:
String getDisplayName() String[] getDisplayPath() NdLocation getLocation() NdRmaDirectory getParentDirectory() NdRmaProject getProject()

ThegetDisplayName()methodreturnsthedisplaynameofthefileasitappearsinthe BuilderIDE.getDisplayPath()returnsthedisplaypathofthefile,asanarrayof String.Eachelementrepresentsanodeinthehierarchy.Thehierarchystartsatthe projectnode.Thelastelementinthearrayisthedisplaynameofthefile.getLocation() returnsanNdLocationobjectthatistheabsolutelocationoftheentryfromtherootof therepository.getParentDirectory()returnsthedirectorythatcontainstheentry.Null isreturnediftheentryhasnoparent;whichwouldbethecaseif,forexample,theentry wereaprojectoroneofthetoplevelprojectdirectories.getProject()returnsthe projecttheentrybelongsto. Anentryalsosuppliesmethodstodealwithversioningandauthorization:
NdRmaEntryVersioningInfo getVersioningInfo() NdRmaEntryVersioningOperations getVersioningOperations() boolean isOperationAllowed(int operationCode)

ThegetVersioningInfo()methodreturnstheversioninginformation (NdRmaEntryVersioningInfo)fortheentry.Iftherepositorydoesnotsupport versioning,orthereisnoversioninginformationfortheentry,thismethodreturnsnull. getVersioningOperations()returnstheversioningoperations (NdRmaEntryVersioningOperations)thatmaybeperformedontheentry.Ifthe repositorydoesnotsupportversioning,ortheentrydoesnotsupportanyversioning operation,thismethodreturnsnull.Forthecurrentrelease,versioningoperationsare supportedforonlytwokindsofentries:instances(NdRmaInstance)andprojects (NdRmaProject).Forprojects,thegetVersion(), promote(), and restore()methods ofNdRmaEntryVersioningOperationsarenotsupported.isOperationAllowed() returnstrueiftherepositoryoperationwhosecodeissuppliedisallowed.Refertothe APIReferenceentryforNdRomOperationtoviewthesetofoperationcodes.TheBlaze AdvisorAPIReferenceisavailablebyselectingAPI ReferencefromtheBuilder Help menu.

56

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

RMA Directory (NdRmaDirectory)


NdRmaDirectoryprovidesthefollowingmethodsinadditiontothoseinheritedfrom NdRmaEntry: boolean hasEntries() NdRmaEntry[] getEntries() void resetEntries() NdRmaDirectory createDirectory(String directoryDisplayName) void deleteEntry(NdRmaEntry entry) NdRmaGloballyDeletedFile[] getGloballyDeletedFiles() void resetGloballyDeletedFiles() boolean hasGloballyDeletedFiles()

ThehasEntries()methodreturnstrueifthedirectoryhasanycontent.getEntries() returnsalltheentriesinthedirectory.Thelistofentriesiscached.Ifanyentryexclusion filterwasdefinedattheprojectlevel,thentheresultprovidedbythesemethodswill dependonthefilter.resetEntries()clearsthecacheofentries.Thisisusefulsothatthe nextcalltogetEntries()returnsanuptodatelistofentries.ThecreateDirectory() methodcreatesasubdirectoryofthespecifiedname.ThedeleteEntry()method deletesthesuppliedentry.getGloballyDeletedFiles()returnsallthefilesinthis directorythathavebeendeletedandthencheckedintotheversioningsystem. resetGloballyDeletedFiles()clearsthecacheoffilesthathavebeendeletedthen checkedintotheversioningsystem.ThehasGloballyDeletedFiles()methodreturns trueifthedirectoryhasanyfilethathasbeendeletedthencheckedintotheversioning system. Versioningoperationsarenotprovidedforadirectoryinthecurrentrelease,even thoughNdRmaDirectoryextendsNdRmaEntry,whichsupportsversioning.However, NdRmaDirectorydoesprovidethefollowingmethodforobtainingversioning informationforalltheentriesinadirectory:
public NdRmaDirectoryVersioningInfos getVersioningInfos()

ThegetVersioningInfos()methodreturnsaninstanceof NdRmaDirectoryVersioningInfoswhichmaybeusedtoobtaintheversioningstatus andlockinformationforalltheentriesinthedirectory.Thismethodisprovidedsothat amoreefficientretrievalofversioninginformationcanbeperformedwhensuch informationisneededformorethanoneentry.TheNdRmaDirectoryVersioningInfos interfaceisdiscussedinVersioningInformation(NdRmaEntryVersioningInfo)on page64.

RMA Files
AsdescribedinRMAEntry(NdRmaEntry)onpage56,anentryinarepositoryis eitheraprojectdirectoryorafileinaproject.Filesarealwayscontainedbyadirectory, withtheexceptionofprojects.ThethreetypesoffilessupportedbytheRMAAPIare listedbelow.EachinterfaceextendsNdRmaFile. Project(NdRmaProject) Templatefile(NdRmaTemplateFile)

Fair Isaac Confidential and Proprietary Information

57

CHAPTER 4: RMA API

Instancefile(NdRmaInstanceFile) Editablefile(NdRmaEditableFile)

File (NdRmaFile)
TheNdRmaFileinterfaceprovidesthefollowingmethods.
Date getLastModifiedDate() boolean isLogicallyDeleted() boolean isNew() void reloadContent()

ThegetLastModifiedDate()methodreturnsthedatethefilewaslastmodified. isLogicallyDeleted()returnstrueifthefilehasbeenlogicallydeleted.Alogically deletedfileisonethatiseitherdeletedlocallyintheworkspaceordeletedgloballyin theversioningsystem.isNew()returnstrueifthefilewasjustcreatedandneversaved. ThereloadContent()methodreloadsthecontentofthefileanddiscardschanges whichhavenotbeensaved.

Project File (NdRmaProject)


Projects(NdRmaProject)arenotincludedinthelistofentriesreturnedbythe getEntries()methodofNdRmaDirectory(seeRMADirectory(NdRmaDirectory)on

page57).Thereasonisthatdirectoriesarefetchedinthecontextofsomeproject,and otherprojectsthatmaybecontainedinthosedirectoriesareinvisibletotherootproject whichprovidesthecontext.


NdRmaProjectextendsNdRmaFilesothatitcansupplyversioninginformation,andso

thatversioningoperationscanbeperformed.Forthecurrentrelease,however,only instancessupportallversioningoperations.Projectssupportsomeversioning operations,asdescribedinVersioningonpage63. ThemethodsavailableinNdRmaProjectarediscussedinRMAProject (NdRmaProject)onpage54.

Template File (NdRmaTemplateFile)


The NdRmaTemplateFileinterfacerepresentsafilewhichcontainsatemplate. NdRmaTemplateFileonlysuppliesonemethod. NdRmaTemplate getTemplate()

ThegetTemplate()methodreturnsthetemplatethatthisfilecontains.

Instance File (NdRmaInstanceFile)


TheNdRmaInstanceFileinterfacerepresentsafilethatcontainsaninstance. NdRmaInstanceFilecontainsonemethod.
NdRmaInstance getInstance()

58

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

TheNdRmaInstance getInstance()returnstheinstancethatthisfilecontains.
NdRmaInstanceFileextendsNdRmaEditableFilewhichprovidestheeditingcapability fortheinstance.NdRmaEditableFileisdiscussedinthefollowingsection.

Editable File (NdRmaEditableFile)


NdRmaEditableFileisimplementedbyfilesthatallowediting.Forthecurrentrelease,

onlyinstancesinstancesareeditable.
void save() NdRmaFile saveAs(NdRmaDirectory targetDirectory, String name) boolean isModified()

Thesave()methodsavesthefile.Ifthefileisreadonly,thismethodwillfail.The saveAs()methodsavesacopyofthefile,withanewname,inthespecifiedtarget directory.ThecopythatiscreatedisreturnedasanNdRmaFile.isModified()returns trueifthefilehasbeenmodified.Afterthefileissaved,isModified()willreturnfalse. SavingamodifiedfilewithanewnameusingsaveAs()willresultinisModified() returningtrue,sinceacopywillhavebeensavedandnottheoriginalfile.

File Content (NdRmaFileContent)


ThefilecontentinterfacesareNdRmaTemplateandNdRmaInstance,aswellas NdRmaQueryTemplateandNdRmaQueryTemplateInstance.Theseinterfacesextend NdRmaFileContent,whichcontainsthefollowingmethod:
NdRmaFile getFile()

TheNdRmaFile getFile()methodreturnsthefilethatcontainsthecontent. TheNdRmaTemplateandNdRmaInstanceinterfacesarediscussedinthefollowing sections.

RMA Template (NdRmaTemplate)


NdRmaTemplateprovidesthefollowingmethodinadditiontothegetFile()method inheritedfromNdRmaFileContent: NdRmaInstance generateInstance(NdRmaDirectory targetDirectory, String instanceDisplayName)

ThegenerateInstance()methodgeneratesanewinstanceofthetemplateinthe specifiedtargetdirectoryandsavesit.Iftheinstanceiscreatedinaversionedrepository itmustbecheckedin.Thenewinstancemaybeedited,asdescribedinEditingthe ContentsofanInstanceonpage61. Versioninginformationregardingthetemplatefilemayobtainedthroughthe NdRmaFile objectwhichisreturnedbycallinggetFile().Forthecurrentrelease, however,versionoperationsarenotsupportedfortemplates.(SeeVersioningon page63.)

Fair Isaac Confidential and Proprietary Information

59

CHAPTER 4: RMA API

RMA Instance (NdRmaInstance)


NdRmaInstanceextendsNdRmaFileContent,andassuch,itinheritsthegetFile() methodswhichultimatelygivesaccesstotheversioninginformationandversioning operationsforthatfile.

AninstancecanbeobtainedbycallingthegetInstance()methodofthe NdRmaInstanceFileinterface.TheNdRmaInstanceFileobjectyouusecanbeobtained bycallingthelookupEntryByLocation(NdLocation location)methodof NdRmaProject,asshowninthecodebelow.Youcanobtainallinstancesinaprojectby callingthegetAllInstances()methodoftheNdRmaProject. Thiscodeshowshowtoobtainaninstancebytwomethods.Thefirstobtainsthe instancespecifiedbyitsabsolutelocationfromtherepositoryroot.Thesecondobtains theinstancebyiteratingthroughallinstancesintheprojecttofinditsdisplayname.


// Obtain an instance by location // rmaProject is an NdRmaProject String instanceLocation = "/Business Library/USA/Merchandising USA"; NdRmaInstance rmaInstance = null; NdLocation location = NdLocationFactory.createLocation(instanceLocation); NdRmaEntry rmaEntry = rmaProject.lookupEntryByLocation(location); if (rmaEntry instanceof NdRmaInstanceFile) { rmaInstance = ((NdRmaInstanceFile)rmaEntry).getInstance(); } // Obtain an instance by display name String instanceName = "Merchandising USA"; NdRmaInstance[] rmaInstances = rmaProject.getAllInstances(true); for (int i = 0; i < rmaInstances.length; i++) { rmaFile = ((NdRmaFileContent)rmaInstances[i]).getFile(); if (rmaFile.getDisplayName().equals(instanceName)) { rmaInstance = rmaInstances[i]; break; } }

Wheninstancesareloadedfromtherepositorysomelinkingerrorsmayoccur.Thiscan happenwhenthetemplateoftheinstancemighthavechanged,ormightnotexist anymore.TheseerrorsaredealtwithusingthefollowingNdRmaInstancemethods:


boolean hasLinkingErrors() NdRMAException[] getLinkingErrors() void clearLinkingErrors() void fixLinkingErrors()

ThehasLinkingErrors()methodreturnstrueiflinkingerrorsoccurredwhileloading theinstance.getLinkingErrors()returnsalistofthelinkingerrorsthatmayhave occurredwhileloadingtheinstance.Ifnoerroroccurred,anemptyarrayisreturned. clearLinkingErrors()clearsthelistoflinkingerrors.Thisisusefulif fixLinkingErrors()isnotcalledandyouwishtoignoretheerrors.Callthe fixLinkingErrors()methodtoautomaticallyfixthelinkingerrorsifthereareany.The listoflinkingerrorsisthencleared.Notethatthismethoddoesnotfixvalidationerrors, whichareerrorsthatmayoccurduringtheeditingoftheinstance.

60

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

Displaying the Contents of an Instance


ThefollowingNdRmaInstancemethodsareusedtogetthecontentsofaninstance:
NdInstanceElementNode[] getInstanceElementNodes() NdInstanceElementNode[] getInstanceElementNodes(NdInstanceElementNode node) NdInstanceElementNode[] getInstanceElementNodesForTOC() NdInstanceElementNode[] getInstanceElementNodesForTOC(NdInstanceElementNode node)

ThegetInstanceElementNodes()methodreturnsthetoplevelnodesoftheinstanceas anarrayofNdInstanceElementNode.Togetthesubnodes,call getInstanceElementNodes(NdInstanceElementNode node)oneachnode. ThegetInstanceElementNodesForTOC()methodreturnstheinstanceelementnodes thatareusedtodisplaythetableofcontentsoftheinstance.(Anexampleofatableof contentsisthetableofcontentsinageneratedRMA.)Avariantofthismethodtakesan NdInstanceElementNodeasaparameterandwillsupplytheinstancenodesforthe passednode.SeeInstanceElementNode(NdInstanceElementNode)onpage62.

Editing the Contents of an Instance


ThefollowingNdRmaInstancemethodsareavailableforeditinganinstance.
setNodeValue(NdInstanceElementNode node, String displayValue) setNodeInstance(NdInstanceElementNode node, String templateDisplayName) addListValue(NdInstanceElementNode list, String displayValue) addListInstance(NdInstanceElementNode list) addListInstance(NdInstanceElementNode list, String templateDisplayName) deleteListNode(NdInstanceElementNode node) moveListNodeUp(NdInstanceElementNode node) moveListNodeDown(NdInstanceElementNode node)

ThesetNodeValue()methodsetsthevalueofthesuppliednodetothepasseddisplay value.setNodeInstance()setstheinstanceofthesuppliednodeusingthesupplied templatedisplaynameforthatinstance.TheaddListValue()methodaddsthesupplied displayvaluetothesuppliedlistnode.ThissortoflistcontainsonlyStringvalues.In contrast,bothaddListInstance()methodsareusedtoaddinstancesoftemplatestothe suppliedlist.TheaddListInstance(NdInstanceElementNode list)methodisused whenthelistmayonlycontaininstancesofthesametemplate.The addListInstance(NdInstanceElementNode list, String displayValue)methodis usedwhenthelistmayonlycontaininstancesofdifferenttemplates.(Examplesofboth usagesarefoundinAddSegmentExample.java,whichispartoftheRMAAPIexample.) deleteListNode()deletesthesuppliednodefromitscontaininglist.moveListNodeUp() movesthenodeupinitscontaininglist(i.e.,itsindexinthelistisdecrementedby1). moveListNodeDown()movesthenodedowninitscontaininglist(i.e.,itsindexinthelist isincrementedby1). Editingerrorsmayoccurduringtheexecutionofanyoftheabovementionedmethods. Aneditingerrorwilloccur,forexample,whenanincorrecttemplatedisplaynameis suppliedtotheaddListInstance(NdInstanceElementNode list, String templateDisplayName)method.Theerrorsmaybeobtainedwiththefollowing NdRmaInstancemethods.

Fair Isaac Confidential and Proprietary Information

61

CHAPTER 4: RMA API

boolean hasEditingErrors() NdRmaException getEditingError(NdInstanceElementNode node) void clearEditingErrors()

ThehasEditingErrors()methodreturnstrueiftheeditingofthisinstancegenerated errors.getEditingError()returnstheeditingerrorthatmayhaveoccurredbycalling oneoftheeditingmethodsonthesuppliednode.Ifnoerroroccurred,nullisreturned. clearEditingErrors()clearsalltheeditingerrorsthatmayhaveoccurred. Whenchangesaremadetoaninstance,thosechangesneedtobevalidatedinorderto verifythattheinstanceconformstotheconstraintsputinplacebythetemplate.The followingNdRmaInstancemethodsarerelatedtovalidation.


void validate() void validate(NdInstanceElementNode) boolean hasValidationErrors() NdRMAException getValidationError(NdInstanceElementNode node) NdRMAException[] getOtherValidationErrors() void clearValidationErrors()

Beginvalidationbycallingoneofthevalidate()methods.Thiswillgeneratealistof validationerrorsincache.YoumaywanttocalltheclearValidationErrors()method beforecallingvalidate()inordertoclearanyexistinglist. Thevalidate()methodtriestovalidatethisinstance.Avariantofvalidate()takesan NdInstanceElementNodeasaparametertoonlyvalidatethatnode,anditssubnodes, andnotthewholeinstance.hasValidationErrors()returnstrueifthevalidationofthis instancegeneratedvalidationerrors.getValidationError()returnsthevalidation errorthatoccurredonthesuppliednode.Ifnoerroroccurredonthatnode,thismethod returnsnull.getOtherValidationErrors()returnsthevalidationerrorsforwhichthere isnoassociatednode.Ifnosucherroroccurred,thismethodreturnsanemptyarray. clearValidationErrors()clearsthelistofeditingerrors.

Instance Element Node (NdInstanceElementNode)


NdInstanceElementNodeisthebaseinterfaceforallnodesreturnedbythe getInstanceElementNodes()andgetInstanceElementNodesForTOC()methodsofthe NdRmaInstanceinterface.TheNdInstanceElementNodeinterfaceprovidesonlyone

method:
NdRmaInstance getInstance()

ThegetInstance()methodreturnstherootinstancethisnodebelongsto. SeveralinterfaceswhichrepresentnodesextendNdInstanceElementNode.These interfacesinclude:


NdWhitespaceNode NdStringNode NdErrorNode NdMetaphorNode

62

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

NdAbstractInstanceNode

TheNdWhitespaceNodeinterfacerepresentsawhitespacenodeandprovidesthe getWhitespace()methodwhichreturnsthewhitespacecharacterofthenode.The NdStringNode interfacerepresentsastringnodeandprovidesthegetString()method whichreturnstheStringvalueofthenode.TheNdErrorNodeinterfacerepresentsan errornodeandprovidesthegetError()methodwhichreturnstheNdErrorforthe node.TheNdMetaphorNodeinterfacewrapstheinformationneededtodisplayoneofthe metaphors(decisiontable,decisiontree,orscoremodel).TheNdAbstractInstanceNode interfacerepresentsagenericinstancenodewhichcouldbeasingleinstancenodeora listnode. TheNdAbstractInstanceNodeinterfacerepresentsagenericinstancenodewhichcould beasingleinstancenodeoralistnode.Severalinterfaceswhichrepresentnodesextend NdAbstractInstanceNode.Theseinterfacesare:
NdInstantiationNode NdInstanceNode NdTableRowNode NdAbstractInstanceListNode NdInstanceListNode NdTableNode

TheNdInstantiationNodeinterfacerepresentsaninstantiationnode.NdInstanceNode representsagenericinstancenodewhichcouldbeasingleinstancenodeoralistnode. NdTableRowNoderepresentsarowinthetable.NdAbstractInstanceListNoderepresents aninstancelistnode,asopposedtoasingleinstancenode.TheNdInstanceListNode andNdTableNodeinterfacesextendNdAbstractInstanceListNode. NdInstanceListNodedefinestheinstancelistnodeinterfaceandNdTableNode representsaninstancelistnodethatwouldbedisplayedinatable.Fordetailsonthese interfacesrefertotheAPIReference.

Versioning
TheRMAAPIsupportsversioningofrepositoryentriesthroughtwointerfaces, NdRmaEntryVersioningOperationsandNdRmaEntryVersioningInfo. TheNdRmaEntryinterfaceprovidesthegetVersioningOperations()methodfor obtainingNdRmaEntryVersioningOperationsfortheentry.Themethodreturnsnullif therepositorydoesnotsupportversioningoriftheentrycannotbeversioned.Inthe currentreleaseonlyinstances(NdRmaInstance)supportallversioningoperations. Projects(NdRmaProject)supportsomeversioningoperations,butnotthegetVersion(), promote(),andrestore()methods. ThegetVersioningInfo()methodofNdRmaEntryobtainsversioninginformation (NdRmaEntryVersioningInfo)whichisprovidedforallentriesinaversioned repository.Themethodreturnsnulliftherepositorydoesnotsupportversioning.

Fair Isaac Confidential and Proprietary Information

63

CHAPTER 4: RMA API

Versioning Operations (NdRmaEntryVersioningOperations)


TheNdRmaEntryVersioningOperationsinterfacedeclaresthefollowingmethods:
void update() void checkOut() void cancelCheckOut() void checkIn(String comment) NdRmaEntry getVersion(String versionId) void promote() void restore()

Theupdate()methodupdatestheentrybyfetchingthelatestversionfromthe versioningsystem.checkOut()checksouttheentryfromtheversioningsystem. cancelCheckOut()cancelsapreviouscheckoutfromtheversioningsystem.checkIn() checkstheentryintotheversioningsystemwiththesuppliedcomment.getVersion() returnsaversionoftheentrythatcorrespondstothesuppliedversionID.promote() promotestheentryintheversioningsystemsothatitbecomesthetopversion. restore()restorestheentrythatwaspreviouslydeleted.

Versioning Information (NdRmaEntryVersioningInfo)


TheNdRmaEntryVersioningInfointerfaceprovidesmethodswhichreturninstancesof classesandinterfacesinthecom.blazesoft.repository.basepackagethatprovide versioninginformation.
NdRepositoryVersionHistory[] getVersioningHistory() NdRepositoryEntryLockInfo getVersioningLockInfo() NdRepositoryVersionResultSet getVersioningStatusInfo()

ThegetVersionHistory()methodreturnsanarrayofNdRepositoryVersionHistory whichrepresentseachelementintherepositoryentrysversioninghistory.Thisclass containsmethodsforobtainingtheversionID,userID,timestamp,comment,location anddeletionstatus. ThegetVersioningLockInfo()methodreturnsNdRepositoryEntryLockInfowhich providescurrentlockinformationontheversionedentry.Thisinterfacehasmethods forobtainingandsettingthestatusofthelock(notlocked,lockedbyuser,lockedby userinanotherworkspace,lockedbyanotheruser),theuserIDoftheownerofthelock, thedateofthelock,andthelocationoftheentry. ThegetVersioningStatusInfo()returnsanNdRepositoryVersionResultSetwhich definestheresultsetreturnedbytheinvocationofmethodsintherepositoryversion managerinterface.Forfurtherinformation,consulttheAPIReferenceentryfor
NdRepositoryVersionResultSet.

Theversioningstatusandlockinformationforallentriesinadirectorycanbeobtained quiteefficientlyusingthegetVersioningInfos()methodoftheNdRmaDirectory interfacewhichreturnsaninstanceofNdRmaDirectoryVersioningInfos.Versioning operationsarenotavailableforthedirectoryitselfinthecurrentrelease. TheNdRmaDirectoryVersioningInfosinterfacecontainsthesemethods:

64

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

NdRepositoryEntryLockInfo[] getVersioningLockInfos() NdRepositoryVersionResultSet[] getVersioningStatusInfos()

ThegetVersioningLockInfos()methodreturnstheversioninglockinformationforall theentriesinthisdirectory.getVersioningStatusInfos()returnsanarrayof NdRepositoryVersionResultSetwhichdefinestheresultsetreturnedbytheinvocation ofmethodsintherepositoryversionmanagerinterface.

RMA Query
TheRMAAPIsupportstheexecutionofexistingqueriesattheprojectlevel.Query resultsarereturnedasanarrayofNdRmaQueryResultItem.Queryresultscanbe instancesaswellasthecontentsofinstances. QueryinstancesareobtainedthroughthegetAllQueryInstances()methodof NdRmaProject(RMAProject(NdRmaProject)onpage54).Themethodreturnsallthe Queryinstancesthatcanbefoundintheproject.
NdRmaQueryInstance[] getAllQueryInstances(boolean includeSystemDirectories)

Query Instance (NdRmaQueryInstance)


TheNdRmaQueryInstanceextendsNdRmaInstance,sothatitcanbedisplayed,edited, andversionedjustlikeanyotherinstance.Theinterfacesuppliesmethodsusedtorun thequeryandgetsitsresults:
void executeQuery() void executeQueryForTOC() int getQueryExecutionStatus() boolean hasQueryResults() NdRmaQueryResultItem[] getQueryResults()

TheexecuteQuery()andexecuteQueryForTOC() methodsexecutethequery.Thelater methodaccumulatesonlytheresultsthatarerelevantforatableofcontents.Both methodsexecutethequerysynchronously.Thismeansthatthethreadinwhichthe methodisinvokedwaitsuntilexecutioniscomplete.Anentryexclusionfiltercanbeset ontheprojecttofilterqueryresults.ThegetQueryExecutionStatus()methodreturns thestatusofthequeryexecution.Thestatuscanbeoneof:EXEC_STATUS_NOT_STARTED, EXEC_STATUS_COMPLETE,EXEC_STATUS_EXECUTING,EXEC_STATUS_CANCELLED,or EXEC_STATUS_ABORTED.hasQueryResults()returnstrueiftheexecutionofthequery deliveredresults.getQueryResults()returnstheresultsofthequeryexecutionasan arrayofNdRmaQueryResultItem. Errorsthatmayoccurwhenexecutingqueriesmaybeobtainedwiththefollowing methods:
boolean hasQueryExecutionErrors() NdRMAException[] getQueryExecutionErrors() void clearQueryExecutionErrors()

Fair Isaac Confidential and Proprietary Information

65

CHAPTER 4: RMA API

ThehasQueryExecutionErrors()methodreturnstrueifanyerroroccurredwhile tryingtoexecutethequery.getQueryExecutionErrors()returnstheerrorsthat occurredduringtheexecutionofthequery.Ifnoerroroccurred,anemptyarraywillbe returned.TheclearQueryExecutionErrors()methodclearstheerrorsthatmayhave occurredduringtheexecutionofthequery.

Query Results (NdRmaQueryResultItem)


TheNdRmaQueryResultIteminterface,usedforreturningqueryresults,isataginterface thatisextendedbyNdRmaInstanceandNdRmaAbstractNode.Thismeansthatquery resultswillconsistofinstances,includingqueryinstances,aswellasinstancecontents.

Entry Exclusion Filter (NdRmaEntryExclusionFilter)


TheNdRmaEntryExclusionFilterinterfaceisusedinfilteringthesetofitemsthatare returnedbyanumberofmethodsintheRMAAPI.Thefilteringisperformedbyyour owncustomexclusionfilterclass,whichmustimplementNdRmaEntryExclusionFilter. Youcanuseanexclusionfiltertofiltertheresultsobtainedfromthe getAllTemplates(),getAllInstances(),getAllQueryTemplates(), getAllQueryInstances(),getAllDirectories(),andgetDirectories()methodsin theNdRmaProjectinterface;aswellasthegetEntries()methodintheNdRmaDirectory interface;andtheexecuteQuery()andexecuteQueryForTOC()methodsinthe NdRmaQueryInstanceinterface. TheNdRmaEntryExclusionFilterinterfacecontainstwomethods.
boolean isEntryToBeExcluded(NdRmaEntry entry) boolean isExcludedDirectoryToBeBrowsed(NdRmaDirectory directory)

TheisEntryToBeExcluded()methodreturnstrueifthesuppliedentryistobeexcluded fromtheresultsofmethodsnavigatingtheproject. isExcludedDirectoryToBeBrowsed() returnstrueifthesupplieddirectory,whichisto beexcludedfromtheresultsofmethodsnavigatingtheproject,shoulditselfbebrowsed incaseitsentriesarenottobeexcluded. HereisanexampleofasimpleimplementationofNdRmaEntryExclusionFilterthat filtersoutentrieswhosepathisinalistofpathstoexclude:


public class RmaEntryExcludedPathsFilter implements NdRmaEntryExclusionFilter { private Vector _excludedPaths; public RmaEntryExcludedPathsFilter(Vector excludedPaths) { _excludedPaths = excludedPaths; } public boolean isEntryToBeExcluded(NdRmaEntry rmaEntry) { NdLocation entryLocation = rmaEntry.getLocation(); entryLocation = rmaEntry.getLocation(); if (entryLocation == null) { return false; }

66

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

String path = entryLocation.toString(); for (int i = 0; i < _excludedPaths.size(); i++) { String excludedPath = (String) _excludedPaths.elementAt(i); // If the path equals an excludedPath or starts with an exludedPath + "/" // then it is either exactly an excluded path, or it is a subdirectory of // one and thus it should be excluded. if (path.equals(excludedPath) || (path.startsWith(excludedPath + "/"))) { return true; } } return false; } public boolean isExcludedDirectoryToBeBrowsed(NdRmaDirectory directory) { // If a directory is to be excluded then so should its contents. return false; } }

Onlyonecustomexclusionfiltermaybesetonaprojectatatime.Usethe setEntryExclusionFilter(RmaEntryExcludedPathsFilter filter)methodof NdRmaProjecttosetthefilter.Youmay,ofcourse,switchtoanotherfilterbycallingthe methodagain.Passnulltothemethodtoindicatethatnofilteringshouldbeperformed. UsethegetEntryExclusionFilter()ofNdRmaProjecttoobtainthecurrent NdRmaEntryExclusionFilter. ThesampleclientcodebelowpassesaVector ofexcludedpathstotheconstructorof thefilterclass.Itsetstheprojectfilterbypassingthefilterto setEntryExclusionFilter().ThecalltogetAllQueryInstances()returnsallquery instancesavailabletotheproject,exceptthoseinthe/Business Library/Asiaand /Business Library/Europedirectoriesandtheirsubdirectories.
// rmaProject is an NdRmaProject Vector excludedPaths = new Vector(); excludedPaths.addElement("/Business Library/Asia"); excludedPaths.addElement("/Business Library/Europe");
RmaEntryExcludedPathsFilter myFilter = new RmaEntryExcludedPathsFilter(excludedPaths);

rmaProject.setEntryExclusionFilter(myFilter); NdRmaQueryInstance[] queries = rmaProject.getAllQueryInstances(true);

Fair Isaac Confidential and Proprietary Information

67

CHAPTER 4: RMA API

68

Fair Isaac Confidential and Proprietary Information

CHAPTER 5

Base Repository and Version Management APIs


ThebaserepositoryandversionmanagementinterfacesandAPIssupport: ImplementingacustomrepositorystoragelayerthatBlazeAdvisorcanmakeuse. Theseinterfacesarereferredtoasthebaserepositoryinterfaces. ImplementinganinterfacetoathirdpartycontentmanagementsystemthatBlaze Advisorcanmakeuseof.Theseinterfacesarereferredtoastheversion managementinterfaces. TheseAPIsareusedtoimplementtherepository,andareseparatefromtheAPIsused byclientsoftherepository.Theyclearlydefinethesemanticsofrepositoryandversion managementoperationssothatallimplementationsbehaveinthesameway.

Storage Layer Interfaces


Thebaserepositorypackageiscom.blazesoft.repository.base.TheJavaDocisinthe Innovatorsection.Thesebaserepositoryinterfacesareresponsibleforthestorageand retrievalofinformationstoredintherepository: NdRepositoryEntry Thisinterfaceisthebaseinterfacefromwhichallotherinterfacesinthestorage layerarederived. NdRepositoryItem Thisinterfaceisusedtorepresententriesinthestoragelayerthathavecontent(i.e. arenotdirectories). NdRepositoryDirectory Thisinterfaceisusedtorepresentdirectorieswithinthestoragelayer. NdRepository Thisinterfacerepresentstheentirerepositoryasitisrepresentedinthestorage layer.

About the Workspace


Theworkspacerepresentstheviewofandinteractionwiththephysicalstoragelayer andtheversionmanager,authorizationmanagerandlockmanagersthathavebeen configuredontherepository.

Fair Isaac Confidential and Proprietary Information

69

CHAPTER 5: Base Repository and Version Management APIs

Youshouldnotneedtoimplementtheworkspaceinterfacesforacustomrepository. BlazeAdvisorincludescompleteimplementationsthatitusesfortheseoperations. Theworkspacelayerisresponsiblefor: Allinteractionswiththeversionmanager.Thisremovestheneedfor implementationsofthestoragelayertobeawareoftheversionmanager,therefore simplifyingtheimplementations. Allinteractionswiththeauthorizationandlockmanagers.Thisremovestheneed fortheversionmanagerimplementationstobeawareoftheseconcepts,therefore simplifyingtheimplementations. Theworkspaceinterfacesareextensionsofthestoragelayerinterfacesthatinclude versioningoperations.Theydelegatetowhateverversionmanagerhasbeenconfigured ontherepository.

Version Management Client Interfaces


TheinterfaceforversionmanagementisNdWorkspaceVersionManager,namedto emphasizethefactthatthisversionmanagerisresponsibleforinteractionsbetween itemsthatexistphysicallyintheworkspaceandtheversioningsystem.Mostofthe methodsreturneitherabooleanvalueoraredeclaredtobevoidmethods.Ifan operationcannotcompletesuccessfully,themethodsareexpectedtothrowan NdRepositoryVersionExceptionthatcancontainanarrayof NdRepositoryVersionResultSetobjectsthatsummarizethestatusoftheoperationfor repositoryentriesthatwereinvolvedintheoperation.Onlythelocation,successstatus andcommandoutputattributesoftheseresultsetswillbeinspectedbyupperlayersof theAdvisorcode. Itshouldbenotedthattheworkspaceversionmanagerisresponsiblefortheversioning ofrepositoryentriesandtheirassociatedrepositoryentryattributes,whichimpliesthat theversioningsystemneedstoknowhowrepositoryentryattributesarerepresentedin thestoragelayer.Forexample,inthefilerepositorythatissuppliedwithAdvisoran entrysattributesarestoredinafilethatisinthesamedirectoryandthathasthefile extension.innovator_attbs. NdWorkspaceVersionManager NdWorkspaceVersionManagerListener Wheneveraworkspaceversionmanagercausesamodificationtobemadetothe workspace,itisresponsibleforsendinganeventtoanylistenersthathave registeredinterestinsuchchanges.Typically,theonlysuchlistenerwouldbethe workspaceitself.Thisallowsimplementationsoftheworkspaceversionmanagerto informtheworkspacethatitneedstosynchronizeitselfwiththecurrentstateofthe repositoryasreflectedinthestoragelayer. NdWorkspaceVersionManagerEvent Thiseventissentwhenevertheworkspaceversionmanagercausesachangetobe madetotherepresentationofarepositoryentryinthestoragelayer.Theevent objectcontainstwoitemsofinformation:

70

Fair Isaac Confidential and Proprietary Information

Fair Isaac Blaze Advisor API Developers Guide

Thelocationoftherepositoryentrythatwasaffected. Anintegercodeindicatingiftherepositoryentrywasmodified,addedtoor removedfromthestoragelayer.

Version Management System Interfaces


Theseinterfacesareusedforaccesstotheversioningsystemoutsidethecontextofa workspace.Theprimaryuseistoprovideamechanism,viathe NdVersioningSystemVersionManagerinterface,forbrowsingthroughthecontentsof theversioningsystem.Theimplementationofthisinterfaceisfreetodeterminehow muchoftheversioningsystemshouldberevealedtotheclientoftheinterface.The mainusethatwillbemadeofthisinterfaceinAdvisorwillbetoallowthebrowsingof itemsthathavebeendeletedintheversioningsystemsuchthattheynolongerappear intheworkspacewheneverarepositoryischeckedout. NdVersioningSystemVersionManager Theimplementationclassforthisinterfacewillbeaconfigurableitemwithinthe versionmanagerconfiguration,whichspecifiesboththeworkspaceandsystem versionmanagers.Theinterfacecontainsthefollowingmethods: NdRepositoryEntryFactory Thisinterfaceisusedtocreaterepositoryentriesthatarereturnedfromthe repositorysystemversionmanager.Thisinterfaceisimplementedbythe workspacelayerandpassedtotherepositorysystemversionmanager.The workspaceimplementationwillcreateworkspaceentrieswhich,sincetheydonot correspondtoentriesinthephysicalstoragelayer,willallbevirtualentries,i.e. theirisVirtualmethodwillreturnatruevalue.

Administration Interfaces
Therearetwoadministrationinterfaces,oneassociatedwiththestoragelayerandthe otherassociatedwiththeversioningsystem.Theyareseparatedoutfromtheother interfacessoasnottoconfusetherolesofsoftwarethataccessesthestoragelayeror versioningsystemfromtheworkspacelayerversussoftwarethatneedstoperform administrativefunctionsonaworkspace. NdRepositoryAdmin NdRepositoryVersionSystemAdmin

Repository Connections
ConnectionsaremadetoarepositoryviaanNdRepositoryConnectioninstance.During theprocessofestablishingaconnectiontoarepository,therepositoryconfiguration willbeloadedfrompersistentstorageintherepository,andwillbeusedtoconfigure therepositoryandanyversioningsystem.

Fair Isaac Confidential and Proprietary Information

71

CHAPTER 5: Base Repository and Version Management APIs

Repository Configurations
RepositoryconfigurationsareserializedintoanXMLdocumentthatisstoredatawell knownlocationwithintherepository.Instancesoftherepositoryconfigurationclassare createdfromthecontentsofthisXMLdocumentviatheBlazedynamicobjectmodel. Forexample,theportionoftherepositoryconfigurationthatspecifiestherepository connectionwillappearasfollows:
<RepositoryConfig> <RepositoryConnection> <Factory>com.blazesoft.repository.file.NdFileRepositoryConnection</Factory> <RepositoryName>MyRep</RepositoryName> <RepositoryFolder>c:\xyz\MyRep</RepositoryFolder> </RepositoryConnection> </RepositoryConfig>

Repository Entry Filters


RepositoryentryfiltersareinstancesofNdRepositoryEntryFilter.Theyfiltertheentries withinadirectorytoremoveanyadministrativefilesthattheversioningsystemmay haveplacedthere,andwhicharenotlogicallypartoftherepositorycontent.The workspaceusesthesefilterstoremoveentriesfromthestoragelayerbeforepresenting theentriestotheROMlayer.

72

Fair Isaac Confidential and Proprietary Information

Index

C
connectingtorepository 7 ConstantDisplayValuesProvider 45, 50 contentbasedAPI 12 create customproviders 41 decisiontable 26 decisiontree 28 enumeration 24 MetaphorModel 25 NdLocation 8 NdPromItem 9 NdRomDirectory 16 PROMproject 17 questionset 22 ruleflow 21 scoremodel 31 SRLclass 23 SRLfunction 20 SRLruleset 18 customprovider implementationguidelines 51 customproviders caching 51 creating 41

M
MetaphorAPIs creatingamodel 25 loadinganinstance 25

N
NdConstrainedListProvider 39 NdContrainedListProvider 43 NdDecTableModelFactory 26 NdDecTreeModelFactory 26 NdDecTreeNodeRenderingInfo 30 NdDecTreePath 28 NdDefaultConstrainedListProvider 40 NdDefaultTemplateValueProvider 39 NdDesignProvider 40 NdDesignProviderMultiArg 47 NdDesignProviderSelectableArg 46 NdDesignProviderTypedArg 47 NdLocation 8 NdMetaphorModelException 26 NdPromEntity 11 NdPromInstance 12 NdPromItemContent 11 NdPromProject 9,52 NdPromProvider 12 NdPromSrlRuleContent 13 NdPromSrlRuleset 13 NdPromTemplate 12 NdPromTextContent 12 NdProviderStaticArg 49 NdProvidesDefaultValue 41 NdRmaEntryExclusionFilter 66 NdRmaQueryInstance 65 NdRmaQueryResultItem 66 NdRomConnectionManager 7 NdRomConnetcionContext 8 NdRomSchemaManager 9 NdScoreModelModelFactory 26 NdTemplateValueProvider 38

D
decisiontables editing 26 decisiontree editing 30 DisplayValuesProvider 43,50

E
edit decisiontable 26 decisiontree 28 scoremodel 31 EntityObjectModel 12 entryexclusionfilter 66

L
loadingaPROMproject 18

P
performance

Fair Isaac Confidential and Proprietary Information

73

Index

customproviders 51 ProjectRepositoryObjectModel (PROM) 9 PROMitemcontent 11 PROMtask createenumeration 24 createquestionset 22 createruleflow 21 createSRLclass 23 createSRLfunction 20 createSRLruleset 18 creatingaPROMProject 17 loadingaPROMproject 18 releaseprojectresources 18

Q
QuestionSetObjectModel 15

R
releasePROMprojectresources 18 repositoryitem findlocation 8 typingattributes 8 RepositoryObjectModel(ROM) 7 RMAquery 65 RuleflowObjectModel 15

S
scoremodel editing 31 SRLEntityObjectModel 14 stringbasedAPI 12

T
typingattributesofrepositoryitem 8

U
UserDefinedDisplayValuesProvider 47

74

Fair Isaac Confidential and Proprietary Information

You might also like