Class XTCEDatabaseConverter


  • public class XTCEDatabaseConverter
    extends XTCEDatabaseParser
    Class to implement the capability to convert/upgrade an XTCE document from the 1.1 version to the 1.2 version. This conversion is still under construction. The XTCE 1.2 schema is only a proposal at this stage and is expected to get some additional work before ultimate release/voting in September of 2017. As a result, this logic should not be considered "ready". It is only a first cut to get some of the work out of the way.
    Author:
    dovereem
    • Constructor Detail

      • XTCEDatabaseConverter

        public XTCEDatabaseConverter​(File file,
                                     boolean useXInclude)
                              throws XTCEDatabaseException
        Constructor Create and initialize an instance of the XTCE Database Converter for schema 1.1 to 1.2. The provided file is loaded and if successful, the user can begin the conversion with the upgrade() method, or select specific step methods.
        Parameters:
        file - File containing the XTCE database XML file to load and use for the conversion operation.
        useXInclude - boolean indicating if XInclude processing should be enabled during load.
        Throws:
        XTCEDatabaseException - thrown in the event that the file cannot be suitably loaded for conversion.
    • Method Detail

      • getMessages

        public List<String> getMessages()
        Retrieve the messages that were generated, if any, during the file conversion/upgrade activity.
        Returns:
        List of String objects containing the messages. This return will never be null, but it can be an empty list.
      • upgrade

        public long upgrade()
        Perform all of the conversion/upgrade steps except saving the result.
        Returns:
        long containing the number of elements/attributes that were modified during the conversion operation. This is not particularly useful to know, but might be of interest to user display messages.
      • convertTwosComplement

        public long convertTwosComplement()
        Convert the twosComplement value change. Changing the value of an attribute
        Returns:
        long containing the number of encoding attributes that were changed on IntegerDataEncoding elements.
      • convertEnumerationAlarmValue

        public long convertEnumerationAlarmValue()
        Convert the EnumerationAlarm attribute name. Changing the name of an attribute
        Returns:
        long containing the number of enumerationValue attributes that were changed to enumerationLabel.
      • convertMessageContainRef

        public long convertMessageContainRef()
        Convert the MessageSet ContainerRef element to ContainerRef. Changing the name of an element
        Returns:
        long containing the number of ContainRef elements that were renamed to ContainerRef in the MessageSet.
      • convertEmptyUnitSets

        public long convertEmptyUnitSets()
        Convert the empty UnitSet elements by removing them to reduce size. Removing an element
        Returns:
        long containing the number of UnitSet elements that were removed.
      • convertValidRangeCalibratedAttribute

        public long convertValidRangeCalibratedAttribute()
        Convert the validRangeAppliesToCalibrated attribute by relocating it. Move an attribute from one element to another
        Returns:
        long containing the number of ContainRef elements that were renamed to ContainerRef in the MessageSet.
      • convertErrorDetectCRC

        public long convertErrorDetectCRC()
        Convert the ErrorDetectCorrect CRC Polynomial element. Removing the contents of an element This conversion requires user interaction in that there is not enough information in XTCE 1.1 to completely define the CRC algorithm uniqueness to make the XTCE 1.2 representation complete. I think I have enough information to perform an auto-convert entirely if the polynomial resembles either CRC-CCITT, CRC-16-ANSI, and CRC-32 POSIX/ISO 3309, but I need to make an assumption that someone is not using an odd reflect/remainder/init/XOR setting(s). Not sure if I should do this or not.
        Returns:
        long containing the number of CRC Polynomial elements that had their contents removed.
      • convertAlarmFormToRangeForm

        public long convertAlarmFormToRangeForm()
        Convert the alarmForm attribute name. Changing the name of an attribute This only applies to a very small number of users who incorporated the original XTCE 1.2 proposal with extensions provided by this toolkit. Pure XTCE 1.1 users would not have any cases of this conversion.
        Returns:
        long containing the number of alarmForm attributes that were changed to rangeForm.
      • convertBlockMetaCommandStepArguments

        public long convertBlockMetaCommandStepArguments()
        Convert the ArgumentList to ArgumentAssignmentList in the BlockMetaCommand elements. CHanging the name of an element and also the child elements and attributes.
        Returns:
        long containing the number of ArgumentList elements that were changed to ArgumentAssignmentList elements with modified child elements and attributes.
      • convertTimeOfDayEpoch

        public long convertTimeOfDayEpoch()
        Convert the timeOfDay attribute value to the Epoch text content. Removing an attribute and relocating data This only applies to a very small number of users who incorporated the original XTCE 1.2 proposal with extensions provided by this toolkit. Pure XTCE 1.1 users would not have any cases of this conversion.
        Returns:
        long containing the number of timeOfDay attributes that were changed to Epoch element content.
      • save

        public boolean save()
        Conclude the conversion/upgrade by saving the XML content to an automatically generated filename. The file will be overwritten if it already exists. The old file name will be used to create the new file name. First it will try to replace the ".xml" extension with "-1.2.xml". If that does not succeed, then the file name will receive "-1.2.xml" at the end to make the new file name.
        Returns:
        boolean indicating if the save operation was successful.
      • save

        public boolean save​(File xmlFile)
        Conclude the conversion/upgrade by saving the XML content to a provided file. The file will be overwritten if it already exists.
        Parameters:
        xmlFile - File containing the path and name to the target filename to save.
        Returns:
        boolean indicating if the save operation was successful.