SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irm_get_swc_property.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 SAS Institute Inc. Cary, NC, USA
3*/
4
5/**
6 \file
7
8 \brief Returns the value of a given property for the specified Software Component
9
10 \param [in] swc_name Name of the Software Component
11 \param [in] property Name of the property to retrieve
12 \param [in] debug controls whether debug information is printed to the log. Values: True/False. (Default: false)
13 \param [in] pattern_match_flg Flag (Y/N). Controls whether pattern match (Y) or exact match (N) is performed. (Default: N)
14 \param [out] outvar Name of the output macro variable storing the value of the requested property. (Default: swc_property_value)
15 \param [out] out_ds optional Name of the output table storing the list of matched properties. (Default: <i>&lt;blank&gt;</i>)
16
17 \details
18 This macro will query the specified Software Component metadata object and returns the value of the requested property/properties.<br>
19 Pattern match (through regular expression) is performed if <i>pattern_match_flg = Y</i>. <br>
20 In this case the input parameter <i>property</i> can contain the wildcard symbol:
21 - special wildcard character * is automatically converted into regular expression (.*), unless it has been escaped using backslash (i.e. \\*)
22 - special dot character . is automatically escaped --> \\.
23
24 When pattern matching is enabled, the output macro variable (specified with the outvar parameter) is a semi-colon separated list of &lt;property_name&gt;=&lt;property-value&gt;
25
26 <b>Example</b><br>
27 Retrieve all registered IRM federated areas:
28
29 \code
30 %let swc_property_value =;
31 %irm_get_swc_property(swc_name = IRM Mid-Tier Server
32 , property = com.sas.solutions.risk.irm.fa.(?!readonly.)*
33 , debug = true
34 , outvar = swc_property_value
35 , out_ds = irm_federated_areas
36 , pattern_match_flg = Y
37 );
38 %put swc_property_value: %superq(swc_property_value);
39 \endcode
40
41 Sample output macro variable and result table:
42
43 \code
44 swc_property_value: com.sas.solutions.risk.irm.fa.0.3.4=/sas/config/Lev1/AppData/SASIRM/fa.0.3.4;com.sas.solutions.risk.irm.fa.ifrs9.2017.10=/sas/repositories/fa_ifrs9/irm
45 \endcode
46
47
48 | swc_name | uri_Property | property_name | property_value |
49 |---------------------|-----------------------------------|---------------------------------------------|----------------------------------------------|
50 | IRM Mid-Tier Server | OMSOBJ:Property\A5PUZKI1.AC0002LD | com.sas.solutions.risk.irm.fa.0.3.4 | /sas/config/Lev1/AppData/SASIRM/fa.0.3.4 |
51 | IRM Mid-Tier Server | OMSOBJ:Property\A5PUZKI1.AC0004SL | com.sas.solutions.risk.irm.fa.ifrs9.2017.10 | /sas/repositories/fa_ifrs9/irm |
52
53 Note the use of negative lookahead expression <i>(?!readonly.)</i> to exclude from the match any property that would look like <i>com.sas.solutions.risk.irm.fa.readonly.*</i>
54
55
56 \ingroup macroUtils
57
58 \author SAS Institute Inc.
59 \date 2016
60*/
61%macro irm_get_swc_property(swc_name =
62 , property =
63 , debug = false
64 , pattern_match_flg = N
65 , outvar = swc_property_value
66 , out_ds =
67 );
68
69 %if(not %symexist(&outvar.)) %then
70 %global &outvar.;
71
72 %let &outvar. =;
73
74 %if(%sysevalf(%superq(pattern_match_flg) =, boolean)) %then
75 %let pattern_match_flg = N;
76 %else
77 %let pattern_match_flg = %upcase(&pattern_match_flg.);
78
79 data
80 %if(%sysevalf(%superq(out_ds) ne, boolean)) %then
81 &out_ds.;
82 %else
83 _null_;
84 ;
85 length
86 swc_name
87 uri_swc
88 uri_PropertySets
89 uri_Property
90 property_name $256.
91 property_value $1024.
92 outvar $4000.
93 ;
94 keep
95 swc_name
96 uri_Property
97 property_name
98 property_value
99 ;
100 swc_name = "&swc_name.";
101 /* Get the Software Component URI */
102 rc_swc = metadata_getnobj("omsobj:SoftwareComponent?@Name='&swc_name.'", 1, uri_swc);
103 %if(%upcase(&debug.) eq TRUE) %then
104 put rc_swc= uri_swc=;
105 ;
106
107 if rc_swc = 1 then do;
108 /* Get the Property Sets URI */
109 rc_PropertySets = metadata_getnasn(uri_swc, "PropertySets", 1, uri_PropertySets);
110 %if(%upcase(&debug.) eq TRUE) %then
111 put rc_PropertySets= uri_PropertySets=;
112 ;
113
114 if(rc_PropertySets > 0) then do;
115 n = 0;
116 rc_property = 1;
117 /* Loop through all properties */
118 do while(rc_property > 0);
119 n = n + 1;
120 call missing(uri_Property, property_name, property_value);
121 /* Get the Property URI */
122 rc_property = metadata_getnasn(uri_PropertySets, "SetProperties", n, uri_Property);
123 /* Get the Property Name */
124 rc_property_name = metadata_getattr(uri_Property, "Name", property_name);
125 /* Get the Property Value */
126 rc_property_value = metadata_getattr(uri_Property, "DefaultValue", property_value);
127
128 %if(%upcase(&debug.) eq TRUE) %then %do;
129 put;
130 put "--> " uri_Property=;
131 put "----> " property_name=;
132 put "----> " property_value=;
133 %end;
134 %if(&pattern_match_flg. = Y) %then %do;
135 /* Quote special character -> Convert . to \. (only if the . is not already preceded by an escape backslash) */
136 %let property = %sysfunc(prxchange(s/(?<!\\)[.]/\./i, -1, %superq(property)));
137 /* Convert * to regex multi-character wildcard -> (.*) (only if the * is not preceded by an escape backslash) */
138 %let property = %sysfunc(prxchange(s/(?<!\\)[*]/(.*)/i, -1, %superq(property)));
139 if(prxmatch("/^&property.$/i", strip(property_name))) then do;
140 outvar = catx(";", outvar, catx("=", property_name, property_value));
141 output;
142 end;
143 %end;
144 %else %do;
145 if(upcase(strip(property_name)) = "%upcase(&property.)") then do;
146 call symput("&outvar.", property_value);
147 output;
148 stop;
149 end;
150 %end;
151 end;
152 end;
153 end;
154 %if(&pattern_match_flg. = Y) %then %do;
155 call symput("&outvar.", strip(outvar));
156 %end;
157 run;
158
159%mend;