Working Material The Regulatory Authority Information System RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Contents 1 2 3 4 Introduction......................................................................................................................1 1.1 Overview....................................................................................................................1 RAIS Advanced Customizations ....................................................................................4 2.1 Creating Custom Protectors ....................
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 1 Introduction This document is part of the official programmer’s guide of RAIS 3.0 with SQL Extensions, released May 2006. This part is intended to assist RAIS 3.0 Administrators and Developers in advanced customizations of RAIS 3.0. 1.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization The descriptions of the main types of queries are given in the following table.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization • Copy custom objects into the RAIS 3.0 Creator: After custom objects have been validated, they need to be copied into the RAIS Creator in order to be automatically included in the RAIS 3.0 front-end upon next creator runs. If custom objects would not be copied into the creator, they clearly would be lost. • Eventually adjust the RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 2 RAIS Advanced Customizations This section describes advanced customization of RAIS 3.0. The RAIS 3.0 Creator has been designed to allow for customizations of the RAIS 3.0 back-end (i.e. adding tables and fields) and appropriately adjusting the RAIS 3.0 Input Forms. Advanced customizations, for example new queries or new consistency checks, require manual intervention on parts of the RAIS 3.0 Creator Source Code as well as RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 2.1.1 Examples 2.1.1.1 Protecting deletion of important facilities This example shows how to prevent deletion of an important facility, called Waste Management. This type of facility will be required in most countries to allow for storage of sources managed as waste. The standard installation of RAIS 3.0 does not provide for a protector table for facilities. So, in a first step, we have to create this table.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Then select and expand the group node Common Tables and click the button Add Table. Enter the protector table name [Protector Facility], select the option Simple Table (without History), select the menu Setup and the menu node Common Tables and click Apply. The new table will be displayed in the creator form. Select the table [Protector Facility], click the button Edit Selected Table and add the following fields.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization This is to prevent unintended modification of system fields. If you need to correct field attributes, disable the system field option, modify appropriately and enable the system field option again. Click the Apply button to continue. Create the field Deleting Text. Please check spelling and system field option. Create the field Renaming Text. Please check spelling and system field option.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Create the field Operation Code. Please check spelling and system field option. Close the table properties form in order to return to the RAIS Creator main form. Accept the table group and create a new RAIS 3.0 front-end and back-end. Please take care to create an unlocked front-end. Open the RAIS 3.0 front-end after creation has been completed. Expand the menu node Common Tables in the Regulatory System menu; the new protector appears.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization It’s empty, of course, we only created the table. Next step is to populate our new protector. Navigate to the protector and click the Add button to create a new protecting record, just as if you create any other new record in RAIS and add “1” to the field “Operation Code”. After the new protection record has been created, the left side list box displays by default the primary key value of the facility to be protected.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Test also the behavior when modifying the record. Please note that only a warning message is displayed, hence modifications are allowed. 2.1.2 Hiding protector tables from the Regulatory System menu The new protector we have been creating appears in the Regulatory System menu. Protectors defined by default in the standard version of RAIS 3.0 are not displayed; they are hidden.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization letter M. This letter makes the menu node for our protector appear under the menu group Common Tables. A hidden menu group exists in RAIS for hiding all protectors, having the key prefix Y. Rename the key of the new protector to something like Y99, meanwhile taking care that this key is not yet used. 2.1.3 Comments It is allowed to extend the table definition of protectors to include for instance a category of facilities to be protected.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization To compensate for shifting of primary keys, the concept of evaluators has been introduced in RAIS 3.0. Evaluators are tables containing primary key values of special records. The evaluator table [Evaluator Unknown GM] for instance only contains one record, relating the [unknown] record in the table [Generator Model]. Additionally, a relationship between both tables is defined.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Select the table [Evaluator Waste Management], click the button Edit Selected Table and add the following fields. Create the field Facility. Please enter only field definitions and take care to select the option [System Field] after you have entered all field attributes. Please note that some fields turn disabled after system field option has been activated.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization This is to prevent unintended modification of system fields. If you need to correct field attributes, disable the system field option, modify appropriately and enable the system field option again. Click the Apply button to continue. Close the table properties form in order to return to the RAIS Creator main form. Accept the table group and create a new RAIS 3.0 front-end and back-end. Please take care to create an unlocked front-end.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization here, please create a new preselection list query for the form [Evaluator Waste Management] (see section 2.5). To test that our evaluator is working, please create the following query and execute it. Select * from [Facility] where [Facility].[PK Facility ID] in (select [Evaluator Waste Management].[FK Facility ID] from [Evaluator Waste Management]) Now consolidate your backend with any other backend.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization As it is seen, query and statistics results depend very much on evaluators. For example, a query default query shows all sources in the country using the evaluator from the example above, depends on it very much. If a new status for source would be added by user in setup, this query may show incorrect results as new status is not considered by the evaluator.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization open in design mode, please lookup the table name and open the form called “SUB EDIT table name”. Consistency checks are stored in the table [Propagator – Consistency Checks] Form Name Query Name Message Name of the form that will trigger the consistency check Query that will be evaluated Message to be displayed upon non successful evaluation 2.3.1 Examples 2.3.1.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Form Name Query Name Message SUB EDIT Generator Consistency Check – Generator Type No Generator Type selected. Now let’s test this: open the RAIS Interface and enter a new generator, without specifying the generator type.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 2.3.1.2 Duplicate generator serial number Example 1 was really simple. Let’s have a look at something more challenging: implement a consistency check warning about duplicate serial numbers. Serial numbers are optional only within RAIS 3.0. They hence may not be unique, as this would allow for only one generator with unknown serial number to be entered in the whole database.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization and again run and analyze it. It returns only a record set if our first step query returns no record set. That’s the consistency check we wanted to have. Add the following record to the table [Propagator – Consistency Checks] Form Name Query Name Message SUB EDIT Generator Consistency Check – Generator Duplicate Serial Number Duplicate Serial Number.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 2.3.2 Comments No restrictions apply on how many consistency checks may be attached to one form, one consistency check may even be reused throughout different forms. To avoid for loss or overwriting of custom consistency checks after RAIS updates, it is highly recommended to use the prefix “CUSTOM - ” for all your custom consistency checks names; this prefix is not used by RAIS developers. Section 3.1.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Field Name Parameter Name Parent FK Region ID Region ID Not used any more This simply makes the value of the control [Region ID] (located in the main input form) be propagated into the field [FK Region ID] of a new facility. 2.4.1.2 Propagating Visual Basic expressions In this example, we automatically set the current date to be the default date when entering new historical records for workers.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Form Name Field Name Query Name Replacements Name of the form that contains the combo box Name of the combo box Name of the query used to fill the combo box Replaces expressions in the original SQL statement. This has been removed in RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization If a combo box field has no query attached, RAIS automatically detects the foreign table this field is bound to and creates a query for displaying the first two fields of that foreign table. Ordering will always be ascending on the second field. Please note that [Replacements] are not used anymore and should be left blank for compatibility. 2.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization The red box in the picture above highlights the field that will be shown in the main screen if the corresponding query will be added to the table Propogator – Menu Selector as described before. 2.7 Creating Custom Functions and Modules RAIS 3.0 allows for adding functions und procedures, according Microsoft Access Visual Basic syntax and requirements. RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Exit Function Dim r Dim d Dim k Dim a Dim m r = DFirst("[System Region]", "[System - State]") If r <> "" Then r = "-" & r d = DFirst("[System district]", "[System - State]") If d <> "" Then d = "-" & d Forms.input.Form.[ChildForm].Form.[Details].Controls("Regulatory Authority Number") ="" k = Forms.input.Form.[ChildForm].Form.[Details].
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Retrieving r is done by looking up the region identifier upon the primary key of the region, thus r= forms![input]![region id] or as an equivalent: r = Forms("Input").Controls("region id”) Similar, we may retrieve the district code d=forms![input]![district id] or as an equivalent: r = Forms("Input").Controls("district id”) Let us say that retrieving n equals retrieving the primary key of the facility that is about to be created.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization If d <> "" Then d = "-" & d Forms("Input").Controls("ChildForm").Controls("Details").Controls("Regulatory Authority Number") = " " n = Forms("Input").Controls("ChildForm").Controls("Details").Controls ("PK Facility ID") n = "-" & n BuildFacilityRAN = "FAC" & r & d & n End Function Let us check this function by creating a new facility.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Another way to test is by means of queries. Create a new query, having the following SQL statement SELECT RAIS_IV("regulatory authority number") AS Expr1; Run this query in datasheet view, and you will see that again the new authority number is displayed. Later sections in this document will make use of especially this functionality. 2.7.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Custom forms, as well as standard RAIS forms, allow for public access of all of their control elements as well as public variables and functions or procedures. The general syntax for accessing control elements is: forms![form name].
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Manual creation of RAIS tables shall be avoided as the RAIS 3.0 Creator is fully covering this task. Only creation of static tables – tables where no fields are added by the creator – was discussed in this section. To avoid loss or overwriting of static tables after RAIS updates, it is highly recommended to use the prefix “CUSTOM -” for all static table names; this prefix is not used by RAIS developers.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Letter Z is reserved for future RAIS development. Example: Open the table Treview and create a new record with the following field values PDI ID PDI Key Image Index Menu Name N/A Test Menu P 1 Input Next create a new record with these field values PDI ID PDI Key Image Index Menu Name N/A Test Sub Menu P01 2 Input Result The new menu now appears in our treeview.
RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Image Index If this is the first menu entry for use with custom forms, the RAIS Creator must be enhanced to cope with custom forms. Locate the function ShowTab(n As Long) in the module section of the form [Input].
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization After the new menu has been validated, records that have been added to both the [Propagator – Menu Selector] and [Treeview] tables need be copied to the RAIS 3.0 Creator. The new form created [Custom – Hello World] also needs to be copied to the Creator (see section 3.2 for more details). Notes: Do not modify any of the menu entries created by the RAIS Creator.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization AddExecutableMenu v, "Calculations", "Calculations" AddExecutableMenu v, "Local Settings", "Options" AddExecutableMenu v, "Backend Connection", "Connection" AddExecutableMenu v, "About RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization CommandBars("RAIS Menu Bar").Controls(5).Controls(1).Enabled = Not b CommandBars("RAIS Menu Bar").Controls(5).Controls(2).Enabled = Not b CommandBars("RAIS Menu Bar").Controls(5).Controls(3).Enabled = Not b CommandBars("RAIS Menu Bar").Controls(5).Controls(4).Enabled = Not b If BelongsToGroup(CurrentUser, "RAIS Regulators") Then CommandBars("RAIS Menu Bar").Controls(3).Enabled = b CommandBars("RAIS Menu Bar").Controls(2).
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 2.10.2 Comments If forms are opened with the parameter acDialog, they may not loose focus. You may remove this parameter if you want to allow custom forms to be opened and user switching to the RAIS Interface forms or other custom forms. 2.11 Creating Custom Queries and Statistics The process of creating custom queries or statistics is among the complicate tasks of advanced customizations of RAIS.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Select * from [generators history] where ( ([fk generator type id] = forms![query parameter form]![list 5]) and ([status date] between CVDate(forms![query parameter form]![start date]) and CVDate(forms![query parameter form]![end date]))); When designing queries, we recommend using only static filtering in a first step. Note that RAIS 3.0 currently allows only for foreign keys and date values to be used as parameter values, i.e.
RAIS 3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 2.11.1.2 Statistic for practice profile Let us now have a look at how the statistical query for displaying the practice profile has been inserted into the RAIS 3.0 interface. The menu entry will not be located in a menu group node, so only one entry is required in the table [Treeview] – with the key P – for the menu leave (linked to a query parameter form).
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Query 0 Form Image Index Query Parameter Form 0 And again only one entry in the table [Propagator – Report Definitions] Menu Item Query Title Grouping Widths P Statistics - Practice Profile Practice Profile 0 0 We may check the result by simply opening the RAIS Front-End, navigating to Practice Profile in the Statistics menu. 2.11.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization After copying the new report from the front end to the creator, modification of the creator is necessary for the new report to be created upon the next creation run See section 3.2 for details. 2.12 Customizing Search Functionality The search form allows for searching of information items as for instance facilities, sources and workers. Information items may be searched by parts of the regulatory authority number or their names.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization Please note that SQL statements shall always return search result in the form Primary Key, Name. Also note that the field Search SQL may contain either an SQL statement or a named query.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization • • • Design the needed customization in an unlocked front-end Test, debug and validate the new customization Copy the final new custom form in the RAIS 3.0 Creator Note: When modifying the way how multiple selection form appears, one should be aware that all modifications should be done both in Unallocation and Allocation forms. Also, please consider that junction functions are very complex by nature; one should not usually modify them.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 3 Copying customizations from a front-end to the creator 3.1 Copying Queries Queries are most easily copied by a simple Drag-and-Drop operation from the Front-End into the Creator. If the query to be copied already exists in the Creator, MS Access will ask for a new name. This may easily be avoided by first deleting the query to be copied from the creator, as a new query from the Front-End is going to supersede that very query.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization [RAN - ] [Calculation - ] [Export Selection - ] [Exportable Selection - ] [Exported Selection - ] [Exported Overall Selection - ] [Import Selection - ] [Importable Selection - ] [Imported Selection - ] [Imported Overall Selection - ] [Menu Selection – ] 3.1.2 Complex, multiple selection managing queries Allocation and un-allocation queries are required for managing multiple selection fields.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization new name. This may easily be avoided by first deleting the form to be copied from the creator, as a new form from the Front-End is going to supersede that very form. Please note that both Front-End and Creator need be opened in design mode in order to execute Drag-and-Drop operations. Please note that the RAIS Creator often uses form templates.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization In order for the custom forms to be created upon next run of the creator, it is necessary to modify the creator source code as described below: • • • Open the RAIS Creator in design mode Locate the function [Public Sub FormCreateTemplates] in the module [RAIS Form Creator Functions] Include a line DoCmd.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 3.4 Copying modules Copying modules from the Front-End into the Creator is most easily achieved by a simple Drag-and-Drop operation from the Front-End into the Creator. If the module to be copied already exists in the Creator, MS Access will ask for a new name. This may easily be avoided by first deleting the module to be copied from the creator, as a new module from the FrontEnd is going to supersede that very module.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4 Entity Relationship Diagrams The following Entity-Relationship Diagrams are based on the database model contained in the original distribution of RAIS, common to all official IAEA languages. Only the major entities (information items) and their relations are detailed in the following sections. The reader should be aware that these diagrams may vary, depending upon customizations of database tables with the RAIS Creator.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4. Authorization Types: are defined by relationship from the authorization table to a type-defining table (see section 4.3). Should authorization type specific data be necessary, then they are embedded in the particular type defining table. This is the case, for example, for import, export, transport and transfer authorizations. 4.1 Facilities and Departments 4.1.1 Facilities 4.1.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.2 Sources 4.2.1 Radiation Generators 4.2.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.2.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.2.5 Source-Equipment Association 4.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.3.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.6 Enforcements 4.
RAIS 3.0 Programmer’s Guide – Part I : Advanced Customization 4.