Export-Import Utility

Table of Contents

Export and import utilities are available in the RS_HOME/RapidSuite/scripts directory:

ExportUtility.groovy
ImportUtility.groovy

There are certain cases of model changes where the data (either a property or the whole model data in a parent-child hierarchy) is lost. These utilities are basically provided to the user to help export the affected model data to be imported after the model change. They are not meant to help backing up. They instead will help restoring the lost data after model change. During restoring the data back to the repository, there will be user specific cases where user is required to write his/her own import method by using the ones provided with ImportUtility as a guide.

I. Export Utility

ExportUtility allows exporting
    - all properties
    - selected properties
    - relations
    for a given model and all of its children or all user created models.

The output of ExportUtility is an xml file. Below is a sample export file in xml format:

<Data>
  <Objects>
    <Object eventName='Unresponsive' firstNotifiedAt='1225236607000' lastClearedAt='0'
 severity='4' troubleTicketID='' modelName='Notification' id='4756' />
    <Object eventName='Unresponsive' firstNotifiedAt='1225236607000'  lastClearedAt='0'
 severity='4' troubleTicketID='' modelName='Notification' id='4754' />
    <Object eventName='Down' firstNotifiedAt='1225236609000' lastClearedAt='0' severity='1'
 troubleTicketID='' modelName='Notification' id='4760' />
  </Objects>
  <Relations>
    <Relation fromObjectIdentifier='4756' fromModel='Notification' toModel='Notification'
 toObjectIdentifier='4760' name='causedBy' />
    <Relation fromObjectIdentifier='4754' fromModel='Notification' toModel='Notification'
 toObjectIdentifier='4760' name='causedBy' />
    <Relation fromObjectIdentifier='4760' fromModel='Notification' toModel='Notification'
 toObjectIdentifier='4756' name='causes' />
    <Relation fromObjectIdentifier='4760' fromModel='Notification' toModel='Notification'
 toObjectIdentifier='4754' name='causes' />
  </Relations>
</Data>

Below is the list of methods available to export objects/relations or both.

def exportAllData(web,fname)
def exportBothPropertiesAndRelationsForAModelAndItsChildren(web, modelName,fname)
def exportPropertiesForAModelAndItsChildren(web, modelName,fname)
def exportRelationsForAModelAndItsChildren(web, modelName,fname)
def exportIdsAndSelectedPropertiesForAModelAndItsChildren(web, modelName, propList, fname)

Depending on the model change, user has to identify what to export for which parent model and its children.

II. Import Utility

When a model is to be modified resulting in a data loss, first of all, data has to be exported before the model modification is put into effect. Sometimes, during import, massaging the original data may be needed. For example, when the cardinality of a relation is changed from many-to-many to one-to-many, the relations can not be imported as is. Some of the relations will be lost in the process. User has to decide what needs to be done before importing and implement it.

ImportUtility has some basic methods to cover some of the frequent needs and to serve as a guide while the user is writing new methods specific for his/her needs.

Below is the list of methods available to import objects/relations or both:

def importObjects(web, fname)
def importRenamedProperties(web, Map changedPropNameMap, fname)
def importRelations(web, fname)
def importRenamedRelations(web, Map changedRelationNameMap, fname)
def importForTypeChangedProperty(web, changedProp, Map oldValueNewValueMap, fname)
def importBothObjectsAndRelationsForAModelAndItsChildren(web, Map changedRelationNameMap, Map changedPropNameMap, fname)

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.