Search in sources :

Example 36 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation 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 37 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getTypeNameByRow.

/**
 ********************************************************************************************
 * Get the the table type name referenced in the specified row of the specified table type
 * data. The data for all structure (command) types are combined. This method provides the
 * means to retrieve the specific table type to which the row data belongs based on its
 * "generic" type
 *
 * @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 row
 *            table data row index
 *
 * @return Type name referenced in the specified row of the specified table type data
 ********************************************************************************************
 */
public String getTypeNameByRow(String tableType, int row) {
    String typeName = "";
    // Get the reference to the table information
    TableInformation tableInfo = getTableInformation(tableType);
    // Check if the row exists
    if (row < tableInfo.getData().length) {
        // Get the table type for the specified row
        typeName = tableInfo.getData()[row][tableInfo.getData()[row].length - TYPE_COLUMN_DELTA];
    }
    return typeName;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation)

Example 38 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation 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)

Example 39 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandName.

/**
 ********************************************************************************************
 * Get the command name at the specified row in the command 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 Command name at the specified row in the command data; null if the row index is
 *         invalid
 ********************************************************************************************
 */
private String getCommandName(int row, boolean expandMacros) {
    String commandName = 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 reference to the table information
        TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
        // Get the command name
        commandName = tableInfo.getData()[row][typeDefn.getColumnIndexByInputType(InputDataType.COMMAND_NAME)];
        // Check if any macros should be expanded
        if (expandMacros) {
            // Expand any macros
            commandName = macroHandler.getMacroExpansion(commandName);
        }
    }
    return commandName;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 40 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getStructureRates.

/**
 ********************************************************************************************
 * Get the variable rate(s) at the specified row in the structure data
 *
 * @param row
 *            table data row index
 *
 * @return Array containing the variable rate(s) at the specified row in the structure data; an
 *         empty array if the row index is invalid
 ********************************************************************************************
 */
public String[] getStructureRates(int row) {
    List<String> rates = new ArrayList<String>();
    // 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);
        // Step through each rate column
        for (int rateIndex : typeDefn.getColumnIndicesByInputType(InputDataType.RATE)) {
            // Add the rate to the list
            rates.add(tableInfo.getData()[row][rateIndex]);
        }
    }
    return rates.toArray(new String[0]);
}
Also used : ArrayList(java.util.ArrayList) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Aggregations

TableInformation (CCDD.CcddClassesDataTable.TableInformation)43 TypeDefinition (CCDD.CcddTableTypeHandler.TypeDefinition)30 ArrayList (java.util.ArrayList)14 AssociatedColumns (CCDD.CcddClassesDataTable.AssociatedColumns)9 CCDDException (CCDD.CcddClassesDataTable.CCDDException)7 FieldInformation (CCDD.CcddClassesDataTable.FieldInformation)3 GroupInformation (CCDD.CcddClassesDataTable.GroupInformation)2 TableModification (CCDD.CcddClassesDataTable.TableModification)2 SQLException (java.sql.SQLException)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)1 ToolTipTreeNode (CCDD.CcddClassesComponent.ToolTipTreeNode)1 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)1 TableTypeDefinition (CCDD.CcddClassesDataTable.TableTypeDefinition)1 DatabaseObject (CCDD.CcddConstants.DatabaseObject)1 UndoableTextField (CCDD.CcddUndoHandler.UndoableTextField)1 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1