<< Back to GOCDB/Documentation_Index
The XML input module is used to insert PROM objects and links between PROM objects directly into the database. It is most commonly used for CRUD operations that cannot easily be accomplished in the web portal and to populate a new GOCDB system with an initial data set. The properties of the objects and their relationships to each other are reflected in the structure of an XML input file (a nested/hierarchical structure used to insert data according to established parent-child object relationships). Data for many objects and links can be defined within a single input file.
XML Input File Formatting Rules
The formatting rules of an input XML document are as follows:
- Element names and attribute values ARE case-sensitive.
- The root element name is NOT significant (e.g. <results> is used for the Sample and Seed data).
- The root element can contain one or more child Object elements (e.g. <service_endpoint>) to be inserted into the database.
- An Object element MUST be named after an object that is already declared using the <object_type_name> value in the ‘$GOCDB_HOME/config/gocdb_schema.xml’ file. (In turn, the <abstract_class> that encloses the <object_type_name> is used to map the object and its properties directly to a database table – see ‘gocdb_schema.xml’ for more information).
- Object elements MUST have a ‘gridID’ attribute of type integer. This value SHOULD always be ‘0’ to signify that the inserted object(s) belong to that grid. When inserting nested parent-child objects, the gridID value MUST be identical.
- An Object element MUST contain one or more child elements that MUST be of the following type (ordering is NOT significant and multiples of both types ARE allowed):
- a) A property of the object (e.g. <short_name> containing a site's name). This is a leaf element that MUST NOT nest child elements. The property element’s name must match one of the defined field names for this object type in the gocdb_schema.xml file. Property elements do NOT specify the ‘gridID’ attribute. Each property element will be inserted into a single field (row+column combination) in the database.
- b) A nested child Object element(s).
- A nested child Object element can only have a SINGLE parent element in that particular nesting hierarchy/branch. If an Object has many parents, each parent-child relationship needs to be defined directly beneath the root element as a new parent-child branch (a child object can only be enclosed by a single parent).
- A property element MAY define the key="primary" attribute to signify that this property value must NOT BE NULL and IS UNIQUE within the database (it effectively marks a PK - primary key property). Important: If an object already exists in the database that defines the same property value, then the properties of that object will be updated with the values given in the XML file rather than a new object being inserted.
- An Object element MUST NOT define the key=”primary” attribute.
- To UPDATE selected properties of an object use the key="primary" attribute to identify the object and fill in the child property elements. You can specify just the corresponding leaf elements (you do not need to provide all leaf elements, only the specified object properties specified will be updated).
The GOCDB web portal and programmatic interface use implicit definitions for entities such as a site, service endpoint, user or downtime. Each of these entities are made up of a specific group of PROM objects linked together in a particular way. For example the service endpoint entity as viewed through the web portal and programmatic interface is made up of the following components:
(Note: PROM object types and link types are described in gocdb_schema.xml)
- A PROM object of type service_endpoint describing the service endpoint itself
- A link between a service_type PROM object and the above service_endpoint PROM object. The link must be of type 4 meaning that the child service_endpoint has the type defined in the parent service_type.
- A link of type 6 (parent site provides child endpoint) between the service_endpoint and it's hosting site
- A link of type 43 (child service_endpoint has parent tag) between the service_endpoint and a tag object. (This link is used to define whether a service endpoint is "Visible to EGI" or not).
The full set of definitions for each entity is available below.
If an entity isn't created as expected then it won't appear in the web portal or programmatic interface. For example inserting a service_endpoint object through XML Input without the supporting objects detailed above will render it invisible to the web portal and the programmatic interface. Conversely when adding a service endpoint through the web portal, the above objects and links are created based on the user's input from the form.
Primary Keys and Cardinality
Implicit primary keys are used to uniquely identify objects within the XML Input module. For example, a site should be uniquely identified by it's SHORT_NAME property. Primary keys aren't explicitly defined or enforced within the system. Implicit primary keys for complex GOCDB entities (e.g. site, service endpoint etc) are defined below.
Primary keys for other objects are listed here:
|PROM Object Type||Primary Key Field|
When creating a link between two objects XML Input will perform a cardinality check. Each link type defined in gocdb_schema.xml has a cardinality property limiting the number of instances of the link. The cardinality options available are:
|n||Many parents to many children||Many service endpoints may be linked to many downtimes (link type 15)|
|1||One parent to many children||Many sites may have one timezone (link type 1)||In XML Input if an existing relationship of this type prevents a new link being created the existing relationship is revoked then the new one added.|
|mix[n]||OBSOLETE||N/A||This link type is now obsolete and isn't enforced|
Each type of GOCDB entity is described in one of the following links. The link contains the PROM objects and links that make the entity up as well as XML Input specific cardinality rules and primary keys.
The XML input file example below demonstrates the rules defined above.
<?xml version="1.0" encoding="UTF-8"?> <results> <!-- The root element name is not significant --> <!-- 'service_type' is an Object element. It refers to the value of an <abstract_class><object_type_name> element that is defined in gocdb_schema.xml. Object elements have the 'grid_id' attribute. The 'name' and 'description' leaf elements map to an object's attributes these elements have no children). key="primary" signifies that the name attribute is NOT NULL and UNIQUE in the database (it is a Primary key). If a 'service_type' object already exists in the database with a name of 'Site-BDII', its description will be updated and a new service_type will NOT be added. --> <service_type grid_id="0"> <name key="primary">Site-BDII</name> <description> [Site service] This service collects and publishes site's data for the Information System. All sites MUST install one Site-BDII. </description> </service_type> <service_type grid_id="0"> <name key="primary">CE</name> <description> [Site service] The LCG Compute Element. Currently the standard CE within the gLite middleware stack. Soon to be replaced by the CREAM CE. </description> </service_type> <!-- 'group' is the name of the object used to define ROCs/NGIs. --> <group grid_id="0"> <!-- 'name' and 'email' are leaf elements that map to object attributes (see above). --> <name key="primary">AsiaPacific</name> <email>email@example.com</email> <!-- Parent 'group' object is related to the child 'group_type' object. This relationship is defined in gocdb_schema.xml file using the <abstract_class> and <linktype> elements. --> <group_type grid_id="0"> <name key="primary">ROC</name> <description>Regional Operation Centre</description> </group_type> <!-- A parent group (NGI) has a child 'site' object ('site' is nested in 'group'). --> <site grid_id="0"> <!-- The site's SHORT_NAME attribute uniquely identifies this site --> <SHORT_NAME key="primary">YAS-FTP</SHORT_NAME> <!-- A site has a single domain --> <domain grid_id="0"> <name key="primary">myurl.com</name> </domain> <!-- A site can have one or more child 'service_endpoint' objects --> <service_endpoint grid_id="0"> <!-- A service_endpoint has the following attributes --> <ENDPOINT key="primary">myce.myurl.comCE</ENDPOINT> <HOSTNAME>myce.myurl.com</HOSTNAME> <HOST_IP>111.222.333.441</HOST_IP> <HOST_OS>RH7</HOST_OS> <HOST_ARCH>86x32</HOST_ARCH> <HOST_DN>/C=AU/O=YAS/O=host/OU=FTP/CN=myce.myurl.com</HOST_DN> <DESCRIPTION>YAS-FTP Computing Element.</DESCRIPTION> <PRODUCTION_LEVEL>N</PRODUCTION_LEVEL> <IS_MONITORED>N</IS_MONITORED> <!-- A 'service_endoint' object can define a child 'endpoint_location'. --> <endpoint_location grid_id="0"> <URL>http://some.endpoint.url.ac.uk/endpoint1</URL> <WSDL>http://some.wsdl.url.ac.uk/wsdl_1</WSDL> </endpoint_location> </service_endpoint> <service_endpoint grid_id="0"> <ENDPOINT key="primary">mysbdii.myurl.comSite-BDII</ENDPOINT> <HOSTNAME>mysbdii.myurl.com</HOSTNAME> <HOST_IP>111.222.333.442</HOST_IP> <HOST_DN>/C=AU/O=YAS/O=host/OU=FTP/CN=mysbdii.myurl.com</HOST_DN> <HOST_OS>RH7</HOST_OS> <HOST_ARCH>86x32</HOST_ARCH> <DESCRIPTION>YAS-FTP Site BDII</DESCRIPTION> <PRODUCTION_LEVEL>N</PRODUCTION_LEVEL> <IS_MONITORED>N</IS_MONITORED> <endpoint_location grid_id="0"> <URL>http://some.endpoint.url.ac.uk/endpoint2</URL> <WSDL>http://some.wsdl.url.ac.uk/wsdl_2</WSDL> </endpoint_location> </service_endpoint> </site> </group> <!-- If an Object has many parents, each parent-child relationship needs to be defined directly beneath the root element as a new parent-child branch (i.e. start a new nesting branch as a child object can only be enclosed by a single parent). In this example, 'service_type' is a parent to 'service_endpoint'. We can't define this relationship in the nesting branch above because 'site' is defined as the parent. --> <service_type grid_id="0"> <name key="primary">CE</name> <service_endpoint grid_id="0"> <ENDPOINT key="primary">myce.myurl.comCE</ENDPOINT> </service_endpoint> </service_type> <service_type grid_id="0"> <name key="primary">Site-BDII</name> <service_endpoint grid_id="0"> <ENDPOINT key="primary">mysbdii.myurl.comSite-BDII</ENDPOINT> </service_endpoint> </service_type> <!-- On initial insertion of NEW objects, ensure that ALL MANDATORY parent-child relationships are inserted/established (e.g. between service_endpoint and tag). This is neccessary so that subsequent SQL SELECT statements can successfully (INNER) JOIN across data tables when viewing object graphs in the portal. --> <tag grid_id="0"> <name key="primary">EGI</name> <service_endpoint grid_id="0"> <ENDPOINT key="primary">myce.myurl.comCE</ENDPOINT> </service_endpoint> <service_endpoint grid_id="0"> <ENDPOINT key="primary">mysbdii.myurl.comSite-BDII</ENDPOINT> </service_endpoint> </tag> </results>