attrfixedval
Use the attrfixedval
program to obtain and set restricted values of profile and request attributes.
Usage
attrfixedval.exe <Action>
where <Action> is one of:
Option | Description |
---|---|
add <attrkey> <value>[<viewable value>] | Add <value>/<viewable value> as a restricted value to attribute <attrkey>. |
-delete <attrkey> <value> | Delete restricted value <value> from attribute <attrkey>. |
-deleteall <attrkey> | Delete all restricted values from attribute <attrkey>. |
-parentval <parent value> | For -add and -delete actions, specify the value of a parent attribute. |
-list [<attrkey>] | List all restricted attribute values for attribute <attrkey>; if <attrkey> is omitted, then restricted attribute values for all attributes are listed. The list is in the form of a KVGroup, with each attribute having its own sub-KVGroup containing KVPairs for the value/viewable value pairs, and optionally a parent value. See Examples. |
-batchadd <attrkey> <datasource> | Import the value/viewable value pairs from <datasource>, and add them to attribute <attrkey>. |
-batchreplace <attrkey> <datasource> | Import the value/viewable value pairs from <datasource>, and use them to replace existing restricted values. |
For the batch operations, the <datasource> is in the form:
<file name>;<type=csv|csv|dbdump|flr|kvg>
The format should be one of the following:
csv
– comma-separated values, with the headers named VALUE , VIEWVALUE , and if the attribute has a parent attribute, PARENTVALUE; for example:VALUE,VIEWVALUE,PARENTVALUE NY,"New York", USA CA,"California", USA
dbdump
– database dump file, either gzipped or uncompressed, with the fields VALUE , VIEWVALUE , PARENTVALUE .flr
– fixed-length records, each record being 2000 characters long, with the first 1000 character field for VALUE and the second 1000 character field for VIEWVALUE ;kvg
– single KVGroup containing either:One to three KVPairs; a required pair with a VALUE key, an optional pair with a VIEWVALUE key, and an optional pair with a PARENTVALUE key.
Or
One or more KVGroups, where each group is formatted as in 1; for example:
"" "" = { "" "" = { "VALUE" = "F" "VIEWVALUE" = "Full time" } "" "" = { "VALUE" = "P" "VIEWVALUE" = "Part time" } }
Or,
"" "" = { "" "" = { "VALUE" = "AL" "VIEWVALUE" = "Alberta" "PARENTVALUE" ="CA" } "" "" = { "VALUE" = "QC" "VIEWVALUE" = "Quebec" "PARENTVALUE" ="CA" } }
See Accessing flat-file databases for more information about the connection string used for importing data.
Examples
To import the value/viewable value pairs from the email.csv file and add them to the EMAIL profile and request attribute:
attrfixedval -batchadd EMAIL email.csv;type=csv
To add a value to the STATE attribute, which is related to the COUNTRY parent attribute:
attrfixedval.exe -add STATE CA California -parentval USA
To list values for STATE:
attrfixedval.exe -list STATE
This would return something like:
# KVGROUP-V1.0 "STATE" "" = { "AB" "Alberta" = { "parent" = "CANADA" } "CA" "California" = { "parent" = "US" } "NSW" "New South Wales" = { "parent" = "AUSTRALIA" } "NY" "New York" = { "parent" = "USA" } "QC" "Quebec" = { "parent" = "CANADA" } "QLD" "Queensland" = { "parent" = "AUSTRALIA" } "TX" "Texas" = { "parent" = "USA" } }
Bravura Security Fabric includes a data access library to access flat-file databases, such as CSV. PSLang (pslang.pdf)can use this library to batch-load records from plain or gzipped files.
Connection string
Databases are accessed using an ODBC-style connection string. The string specifies one of a number of providers, each of which knows how to talk to a certain kind of data source. Connection strings look something like:
filename;type=sometype;attr1=value1;attr2=value2;attr3=value3
The filename only has meaning to the provider, and doesn’t necessarily have to be a file.
The type parameter can currently specify one of the following providers:
csv
Comma Separated Value. The first record in the file has the field names.The CSV provider can use the following parameter:
separator The character to use to separate fields from one another. The separator can be a tab, but you must insert an actual tab character into the string to use it.
flr
– A fixed-length record file. Records are a specified number of bytes long. Field offsets and lengths must be specified, since there are no delimiters. Note that the end of lines are not treated specially; they are treated as just another byte.The
flr
provider can use the following parameters:length
– The length of a single record in bytes. This parameter is required.field
– Specifies a field, and looks like NAME,offset1,offset2. This means that a field named NAME will be read that starts at offset1 and ends at offset2. This parameter is required and can be specified multiple times to define more than one field in the file.trim
– Used to automatically trim leading, trailing, or leading and trailing spaces from data.
kvg
– A KVGroup. If the KVGroup contains only sub-KVGroups, then each sub-KVGroup is treated as a record, with its contents (both KVGroups and KVPairs) treated as fields. If the KVGroup contains both sub-KVGroups and KVPairs, or only KVPairs, then the main KVGroup is treated as a single record with its sub-KVGroups and KVPairs as its fields.For any object that is treated as a field, its key name is used as the field name. For a KVPair that is treated as a field, its value is treated as the field value. For a KVGroup that is treated as a field, its contents are treated collectively as the field value.
For a KVGroup whose sub-KVGroups are treated as records, the sub-KVGroups are scanned to collect all the unique field names. When accessing a record that does not include all of the fields, the flat-file library returns empty strings for those fields.
The CSV provider can read in gzipped files as well as plain files.
Connection string examples
The following example opens a csv file named sqldump.csv, and uses tab as the separator instead of comma. Note that you need to specify the actual tab character. The \t is used here just to illustrate.
sqldump.csv;type=csv;separator=\t
The following example open a csv file that include quoted values:
sqldump.csv;type=csv;quotation=\"
The following example opens a fixed-length record file with records 60 bytes long. Two fields will be read out – one called ID made up of bytes 0 through 19 inclusive (20 bytes long), and another from bytes 20 through 34 inclusive (15 bytes long). Spaces are not trimmed.
users.dat;type=flr;length=60;field=ID,0,19;field=NAME,20,34