Search in sources :

Example 51 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgDataType.

/**
 ********************************************************************************************
 * Get the argument data type for the command argument specified at the specified row in the
 * command data
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @return Argument data type for the command argument specified at the specified row in the
 *         command data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
public String getCommandArgDataType(int argumentNumber, int row) {
    String argDataType = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid and that the argument data type exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getDataType() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument data type
            argDataType = tableInfo.getData()[row][commandArguments.get(argumentNumber).getDataType()];
        }
    }
    return argDataType;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 52 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgByColumnName.

/**
 ********************************************************************************************
 * Get the argument value (as a string) for the column belonging to the specified command
 * argument at the specified row in the command data. Macro expansion is controlled by the
 * input flag
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @param columnName
 *            name of the argument column for which the value is requested
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Argument value (as a string) for the column belonging to the specified command
 *         argument at the specified row in the command data; null if the argument number, row
 *         index, or column name is invalid
 ********************************************************************************************
 */
private String getCommandArgByColumnName(int argumentNumber, int row, String columnName, boolean expandMacros) {
    String argValue = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid
        if (argumentNumber < commandArguments.size()) {
            AssociatedColumns cmdColumns = commandArguments.get(argumentNumber);
            // Get the index of the specified column
            int tgtColumn = typeDefn.getColumnIndexByUserName(columnName);
            // Check if the column belongs to the specified command argument
            if (tgtColumn == cmdColumns.getName() || tgtColumn == cmdColumns.getDataType() || tgtColumn == cmdColumns.getArraySize() || tgtColumn == cmdColumns.getBitLength() || tgtColumn == cmdColumns.getDescription() || tgtColumn == cmdColumns.getUnits() || tgtColumn == cmdColumns.getEnumeration() || tgtColumn == cmdColumns.getMinimum() || tgtColumn == cmdColumns.getMaximum() || cmdColumns.getOther().contains(tgtColumn)) {
                // Get the reference to the table information
                TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
                // Get the argument value
                argValue = tableInfo.getData()[row][tgtColumn];
                // Check if any macros should be expanded
                if (expandMacros) {
                    // Expand any macros
                    argValue = macroHandler.getMacroExpansion(argValue);
                }
            }
        }
    }
    return argValue;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 53 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getStructureDescription.

/**
 ********************************************************************************************
 * Get the variable description at the specified row in the structure data. Macro expansion is
 * controlled by the input flag
 *
 * @param row
 *            table data row index
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Variable description at the specified row in the structure data; null if the row
 *         index is invalid or no column has the 'Description' input type
 ********************************************************************************************
 */
private String getStructureDescription(int row, boolean expandMacros) {
    String description = null;
    // Get the table type definition for the structure table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getStructureTypeNameByRow(row));
    // Check if the table type exists and represents a structure
    if (typeDefn != null && typeDefn.isStructure()) {
        // Get the reference to the table information
        TableInformation tableInfo = getTableInformation(TYPE_STRUCTURE);
        // Get the index of the first column with the 'Description' input type
        int column = typeDefn.getColumnIndexByInputType(InputDataType.DESCRIPTION);
        // Check if the column exists
        if (column != -1) {
            // Get the description
            description = tableInfo.getData()[row][column];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                description = macroHandler.getMacroExpansion(description);
            }
        }
    }
    return description;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 54 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getTableData.

/**
 ********************************************************************************************
 * Get the data at the row and column indicated for the table type specified. The column is
 * specified by name. Macro expansion is controlled by the input flag
 *
 * @param tableType
 *            table type (case insensitive). All structure table types are combined and are
 *            referenced by the type name "Structure", and all command table types are combined
 *            and are referenced by the type name "Command"
 *
 * @param columnName
 *            column name (case insensitive)
 *
 * @param row
 *            table data row index
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Contents of the specified table's array at the row and column name provided; returns
 *         null if an instance of the table type, the column name, or the row doesn't exist
 ********************************************************************************************
 */
private String getTableData(String tableType, String columnName, int row, boolean expandMacros) {
    String tableData = null;
    // Get the reference to the table information class for the requested table type
    TableInformation tableInfo = getTableInformation(tableType);
    // Check that the table type exists and the row index is valid
    if (tableInfo != null && row < tableInfo.getData().length) {
        // Get the type definition based on the table's specific type name
        TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getTypeNameByRow(tableType, row));
        // Get the column index matching the requested column name
        int column = typeDefn.getColumnIndexByUserName(columnName);
        // Check that the column name exists in the table
        if (column != -1) {
            // Store the contents of the table at the specified row and column
            tableData = tableInfo.getData()[row][column];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros in the data
                tableData = macroHandler.getMacroExpansion(tableData);
            }
            // Check if the data field contains a message ID
            if (typeDefn.getInputTypes()[column].equals(InputDataType.MESSAGE_ID)) {
                // Remove the auto-assignment protection flag, if present
                tableData = CcddMessageIDHandler.removeProtectionFlag(tableData);
            }
        }
    }
    return tableData;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 55 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getTableInformation.

/**
 ********************************************************************************************
 * Get the table information for the table type specified
 *
 * @param tableType
 *            table type (case insensitive). All structure table types are combined and are
 *            referenced by the type name "Structure", and all command table types are combined
 *            and are referenced by the type name "Command". The table type is converted to the
 *            generic type ("Structure" or "Command") if the specified type is a representative
 *            of the generic type
 *
 * @return Table information class for the type specified; return null if an instance of the
 *         table type doesn't exist
 ********************************************************************************************
 */
private TableInformation getTableInformation(String tableType) {
    TableInformation tableInfo = null;
    // Get the type definition based on the table type name
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(tableType);
    // Check if the type exists
    if (typeDefn != null) {
        // Check if the specified table type represents a structure
        if (typeDefn.isStructure()) {
            // Set the type name to indicate a structure
            tableType = TYPE_STRUCTURE;
        } else // Check if the specified table type represents a command table
        if (typeDefn.isCommand()) {
            // Set the type name to indicate a command table
            tableType = TYPE_COMMAND;
        }
    }
    // Step through the available table information instances
    for (TableInformation info : tableInformation) {
        // sensitivity
        if (info.getType().equalsIgnoreCase(tableType)) {
            // Store the table information reference and stop searching
            tableInfo = info;
            break;
        }
    }
    return tableInfo;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Aggregations

TypeDefinition (CCDD.CcddTableTypeHandler.TypeDefinition)64 TableInformation (CCDD.CcddClassesDataTable.TableInformation)30 ArrayList (java.util.ArrayList)24 CCDDException (CCDD.CcddClassesDataTable.CCDDException)18 AssociatedColumns (CCDD.CcddClassesDataTable.AssociatedColumns)10 SQLException (java.sql.SQLException)9 JSONArray (org.json.simple.JSONArray)8 JSONObject (org.json.simple.JSONObject)8 TableTypeDefinition (CCDD.CcddClassesDataTable.TableTypeDefinition)6 IOException (java.io.IOException)6 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)5 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)4 ArrayListMultiple (CCDD.CcddClassesComponent.ArrayListMultiple)4 FileEnvVar (CCDD.CcddClassesComponent.FileEnvVar)3 FieldInformation (CCDD.CcddClassesDataTable.FieldInformation)3 Component (java.awt.Component)3 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 Insets (java.awt.Insets)3 ResultSet (java.sql.ResultSet)3