Changeset 536


Ignore:
Timestamp:
04/14/14 17:41:55 (5 years ago)
Author:
jls17
Message:
  • added new constructor to URLLink class to create links from CARServerObject-instances with a specific link-caption
  • replaced the function call in ARInside.cpp with the new URLLink class constructor
  • removed the GetURL function from the CARField class
Location:
branches/work_311
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/work_311/ARInside.cpp

    r528 r536  
    10531053        if (field.Exists()) 
    10541054        { 
    1055                 return field.GetURL(linkText, fromRootLevel); 
     1055                return URLLink(linkText, field, fromRootLevel); 
    10561056        } 
    10571057 
  • branches/work_311/core/ARField.cpp

    r359 r536  
    9494} 
    9595 
    96 string CARField::GetURL(const string& linkText, int rootLevel, bool showImage) const 
    97 { 
    98         CPageParams file(PAGE_DETAILS, this); 
    99         return CWebUtil::Link((linkText.empty() ? GetName() : linkText), file, "", rootLevel); 
    100 } 
    101  
    102 string CARField::GetURL(int rootLevel, bool showImage) const 
    103 { 
    104         return GetURL("", rootLevel, showImage); 
    105 } 
    106  
    10796string CARField::GetName() 
    10897{ 
  • branches/work_311/core/ARField.h

    r359 r536  
    5959        const ARPropList& GetPropList() const; 
    6060 
    61         // helpers 
    62         string GetURL(const string& linkText, int rootLevel, bool showImage = true) const; 
    63         string GetURL(int rootLevel, bool showImage = true) const; 
    64  
    6561        // class type support 
    6662        int GetServerObjectTypeXML() const { return AR_STRUCT_ITEM_XML_FIELD; } 
  • branches/work_311/output/URLLink.cpp

    r532 r536  
    5757        URLLink::URLLink(const CARServerObject &workflowObject, int rootLevel, bool showImage) 
    5858        { 
    59                 InitObj(workflowObject, rootLevel, showImage); 
     59                InitObj(workflowObject.GetName(), workflowObject, rootLevel, showImage); 
     60        } 
     61        URLLink::URLLink(const std::string &caption, const CARServerObject &workflowObject, int rootLevel, bool showImage) 
     62        { 
     63                InitObj((caption.empty() ? workflowObject.GetName() : caption), workflowObject, rootLevel, showImage); 
    6064        } 
    6165 
     
    9195        } 
    9296 
    93         void URLLink::InitObj(const CARServerObject &workflowObject, int rootLevel, bool showImage) 
     97        void URLLink::InitObj(const std::string &caption, const CARServerObject &workflowObject, int rootLevel, bool showImage) 
    9498        { 
    9599                CPageParams linkToPage(PAGE_DETAILS, &workflowObject); 
    96                 Init(workflowObject.GetName(), linkToPage, (showImage ? ImageTag(workflowObject, rootLevel) : ImageTag(ImageTag::NoImage, 0)), rootLevel, true, URLLink::TARGET_MODE_SELF); 
     100                Init(caption, linkToPage, (showImage ? ImageTag(workflowObject, rootLevel) : ImageTag(ImageTag::NoImage, 0)), rootLevel, true, URLLink::TARGET_MODE_SELF); 
    97101        } 
    98102 
     
    129133                if (workflowObject.Exists()) 
    130134                { 
    131                         InitObj(workflowObject, rootLevel, showImage); 
     135                        InitObj(workflowObject.GetName(), workflowObject, rootLevel, showImage); 
    132136                } 
    133137                else 
  • branches/work_311/output/URLLink.h

    r532 r536  
    4141                URLLink(const std::string &caption, unsigned int page, int rootLevel); 
    4242                URLLink(const CARServerObject &workflowObject, int rootLevel, bool showImage = true); 
     43                URLLink(const std::string &caption, const CARServerObject &workflowObject, int rootLevel, bool showImage = true); 
    4344 
    4445                std::ostream& ToStream(std::ostream &strm) const; 
     
    5152        protected: 
    5253                void Init(const std::string &caption, const CPageParams &linkToPage, const OUTPUT::ImageTag &image, int rootLevel, bool validate, OUTPUT::URLLink::LinkTargetMode target); 
    53                 void InitObj(const CARServerObject &workflowObject, int rootLevel, bool showImage); 
     54                void InitObj(const std::string &caption, const CARServerObject &workflowObject, int rootLevel, bool showImage); 
    5455                void InitDirect(const std::string &linkHTML); 
    5556                static void AddCaption(std::ostream &strm, const std::string &caption, bool validate); 
  • branches/work_311/output/URLLinkTest.cpp

    r532 r536  
    109109} 
    110110 
     111TEST_F(URLLinkTests, SpecificCaptionForObject) 
     112{ 
     113        // This construct is normally used for fields to show a different link name than  
     114        // the fields name. But currently we can't test with a field, because of the 
     115        // CARSchema dependency of the CARField class. So we'll test with an escalation 
     116        // instead. 
     117        CFakeServerObject fakeWorkflow("TheTestObj", AR_STRUCT_ITEM_XML_ESCALATION); 
     118         
     119        stringstream strm; 
     120        strm << URLLink("RealTestObj", fakeWorkflow, rootLevel, false); 
     121        string result = strm.str(); 
     122 
     123        ASSERT_STREQ("<a href=\"../escalation/TheTestObj.htm\">RealTestObj</a>", result.c_str()); 
     124} 
     125 
     126TEST_F(URLLinkTests, NoSpecificCaptionForObject) 
     127{ 
     128        CFakeServerObject fakeWorkflow("TheTestObj", AR_STRUCT_ITEM_XML_ESCALATION); 
     129         
     130        stringstream strm; 
     131        strm << URLLink("", fakeWorkflow, rootLevel, false); 
     132        string result = strm.str(); 
     133 
     134        ASSERT_STREQ("<a href=\"../escalation/TheTestObj.htm\">TheTestObj</a>", result.c_str()); 
     135} 
     136 
    111137TEST_F(URLLinkTests, CheckedObject) 
    112138{ 
Note: See TracChangeset for help on using the changeset viewer.