Example

This loader example shows how a loader might be defined that reads Core interactions and sets up the data to be displayed in the CCV. Comments are denoted by /** **/.
class ContextInteractionLoader extends ContextNode {
          /** The load method must be implemented by all loader classes. This
          is what is called when the CCV is opened. **/ public ContextNode
          load(Context_ID contextID) throws AppException,
          InformationalException { /**Set up and read the list of interactions
          from core for the context id, the context id in this instance is the
          concern role id for the citizen being displayed **/
          ClientInteraction clientInteractionObj =
          ClientInteractionFactory.newInstance(); ClientInteractionKey
          clientInteractionKey = new ClientInteractionKey();
          ClientInteractionDtls clientInteractionDtls; ListInteractionKey
          listInteractionKey = new ListInteractionKey();
          listInteractionKey.concernRoleID = contextID.context_id;
          InteractionDetailsList interactionDetailsList =
          clientInteractionObj.list(listInteractionKey); /** If sensitivity
          settings do not allow this citizen to be shown then indicate that no
          interactions can be displayed **/ if
          (!ContextUtil.checkUserAuthorizationForParticipant(
          contextID.context_id)) { setLabelAllNotShown(
          ContextUtil.getTextForLocale(BPOCONTEXTINTERACTION.ROOT),
          interactionDetailsList.dtls.size()); return this; } /** Calling the
          setLabelIncludingChildren will display the Interaction label as
          defined in the interaction message file and the number of
          interactions **/ setLabelIncludingChildren(
          ContextUtil.getTextForLocale(BPOCONTEXTINTERACTION.ROOT),
          interactionDetailsList.dtls.size()); /** Set the node type. Node
          types define certain characteristics, including the menu that will
          appear on right click **/ /** See Chapters 3 & 4 for more
          information on Node Types and Menus **/
          setNodeType(CONTEXTNODETYPE.DEFAULTNODE); /** Set the context ID. If
          a context ID is set then this will be used when carrying out a
          specific action. **/ /** Such as opening an new page from a menu
          item click **/ setContextID(0); if
          (interactionDetailsList.dtls.size() == 0) {
          setLabelIncludingChildren(
          ContextUtil.getTextForLocale(BPOCONTEXTINTERACTION.ROOT),
          interactionDetailsList.dtls.size()); /** if there are no
          interactions then add an empty child **/ addDefaultChild(new
          ContextLabelLoader(), ContextUtil.getLocalisableStringForLocale((
          BPOCONTEXT.EMPTY)) .arg(ContextUtil.getTextForLocale(
          BPOCONTEXTINTERACTION.ROOT)).getMessage()); return this; } else {
          Iterator interactionsIter = interactionDetailsList.dtls.iterator();
          InteractionDetails interactionDetails = new InteractionDetails();
          while (interactionsIter.hasNext()) { interactionDetails =
          (InteractionDetails) interactionsIter.next();
          ContextInteractionLoader contextInteractionChild = new
          ContextInteractionLoader(); contextInteractionChild.setLabel(
          curam.util.type.CodeTable.getOneItem( INTERACTIONTYPE.TABLENAME,
          interactionDetails.interactionTypeCode));
          clientInteractionKey.clientInteractionID =
          interactionDetails.clientInteractionID; clientInteractionDtls =
          clientInteractionObj.read(clientInteractionKey); if
          (clientInteractionDtls.relatedType.equals(
          curam.codetable.RELATEDINTERACTIONTYPE.COMMUNICATION)) { /** This is
          a communication interaction so set the corresponding node type and
          menu **/ /** See Chapters 3 & 4 for more information on node
          types and menus **/ contextInteractionChild.setNodeType(
          CONTEXTNODETYPE.COMM_INTERACTION_NODE); /** Set the context id for
          this child node to be the interaction relatedID. This will be used
          when opening any interaction pages from a CCV interaction menu **/
          contextInteractionChild.setContextID(
          clientInteractionDtls.relatedID); } else if
          (clientInteractionDtls.relatedType.equals(
          curam.codetable.RELATEDINTERACTIONTYPE.PAYMENT)) { /** This is a
          payment interaction so set the corresponding node type and menu **/
          /** See Chapters 3 & 4 for more information on node types and
          menus **/ contextInteractionChild.setNodeType(
          CONTEXTNODETYPE.PAY_INTERACTION_NODE); /** Set the context id for
          this child node to be the interaction relatedID. This will be used
          when opening any interaction pages from a CCV interaction menu **/
          contextInteractionChild.setContextID(
          clientInteractionDtls.relatedID); } else {
          contextInteractionChild.setNodeType( CONTEXTNODETYPE.DEFAULTNODE);
          contextInteractionChild.setContextID(0); } /** Add the child to the
          loader **/ addChild(contextInteractionChild); } } return this;
          }