use of CCDD.CcddTableTypeHandler.TypeDefinition 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;
}
use of CCDD.CcddTableTypeHandler.TypeDefinition 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]);
}
use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getTableColumnNamesByType.
/**
********************************************************************************************
* Get the table column names for the table type specified
*
* @param typeName
* table type name
*
* @return Array containing the names of the columns of the table type specified
********************************************************************************************
*/
public String[] getTableColumnNamesByType(String typeName) {
String[] columnNames = null;
// Get the type definition based on the table type name
TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(typeName);
// Check if the table type exists
if (typeDefn != null) {
// Store the names of the columns for this table type definition
columnNames = typeDefn.getColumnNamesVisible();
}
return columnNames;
}
use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getCommandArgColumnNames.
/**
********************************************************************************************
* Get the array of column names belonging to the specified command argument 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 Array of column names belonging to the specified command argument at the specified
* row in the command data; null if the argument number or row index is invalid
********************************************************************************************
*/
public String[] getCommandArgColumnNames(int argumentNumber, int row) {
List<String> argColumns = new ArrayList<String>();
// 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);
// Add the argument name column name (this column must be present)
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getName()]);
// Check if the argument data type column is present
if (cmdColumns.getDataType() != -1) {
// Add the argument data type column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getDataType()]);
}
// Check if the argument array size column is present
if (cmdColumns.getArraySize() != -1) {
// Add the argument array size column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getArraySize()]);
}
// Check if the argument bit length column is present
if (cmdColumns.getBitLength() != -1) {
// Add the argument bit length column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getBitLength()]);
}
// Check if the argument description column is present
if (cmdColumns.getDescription() != -1) {
// Add the argument description column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getDescription()]);
}
// Check if the argument units column is present
if (cmdColumns.getUnits() != -1) {
// Add the argument units column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getUnits()]);
}
// Check if the argument enumeration column is present
if (cmdColumns.getEnumeration() != -1) {
// Add the argument enumeration column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getEnumeration()]);
}
// Check if the argument minimum column is present
if (cmdColumns.getMinimum() != -1) {
// Add the argument minimum column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getMinimum()]);
}
// Check if the argument maximum column is present
if (cmdColumns.getMaximum() != -1) {
// Add the argument maximum column name
argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getMaximum()]);
}
// Step through the other columns associated with this command argument
for (Integer otherColumn : cmdColumns.getOther()) {
// Add the argument column name
argColumns.add(typeDefn.getColumnNamesUser()[otherColumn]);
}
}
}
return argColumns.toArray(new String[0]);
}
use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.
the class CcddVariableSizeAndConversionHandler method createVariableNameList.
/**
********************************************************************************************
* Create a pair of lists that show a variable's full name before and after converting any
* commas and brackets to underscores. Check if duplicate variable names result from the
* conversion; if a duplicate is found append an underscore to the duplicate's name. Once all
* variable names are processed trim the list to include only those variables that are modified
* to prevent a duplicate. These lists are used by getFullVariableName() so that it always
* returns a unique name
*
* @param varPathSeparator
* character(s) to place between variables path members
*
* @param excludeDataTypes
* true to remove the data types from the variable path + name
*
* @param typeNameSeparator
* character(s) to place between data types and variable names
********************************************************************************************
*/
private void createVariableNameList(String varPathSeparator, boolean excludeDataTypes, String typeNameSeparator) {
String varPathColumnsDb = "";
String varPathColumnsUser = "";
convertedVariableName = new ArrayList<String>();
userDefinedVariablePathKey = new ArrayList<String>();
userDefinedVariableName = new ArrayList<String>();
// Step through each variable
for (int index = 0; index < structureAndVariablePaths.size(); index++) {
String fullName = null;
// returned
if (isVariable.get(index)) {
// Convert the variable path + name using underscores to separate the variables in
// the path, and retain the data types
fullName = convertVariableName(structureAndVariablePaths.get(index), varPathSeparator, excludeDataTypes, typeNameSeparator);
// Compare the converted variable name to those already added to the list
while (convertedVariableName.contains(fullName)) {
// A matching name already exists; append an underscore to this variable's name
fullName += "_";
}
}
// Add the variable name to the converted variable name list
convertedVariableName.add(fullName);
}
// Check if the user-defined variable name list should be (re)created
if (conversionLists == null) {
conversionLists = new ArrayList<ConversionListStorage>();
// Step through each table type definition
for (TypeDefinition typeDefn : ccddMain.getTableTypeHandler().getTypeDefinitions()) {
// Check if the table type represents a structure
if (typeDefn.isStructure()) {
// Get the index of the column containing the variable path
int variablePathIndex = typeDefn.getColumnIndexByInputType(InputDataType.VARIABLE_PATH);
// Check if the variable path column is present
if (variablePathIndex != -1) {
// Append the database and user column names to the search criteria
varPathColumnsDb += typeDefn.getColumnNamesDatabase()[variablePathIndex] + ",";
varPathColumnsUser += ValuesColumn.COLUMN_NAME.getColumnName() + " = '" + typeDefn.getColumnNamesUser()[variablePathIndex] + "' OR ";
}
}
}
// Check if any variable path column exists
if (!varPathColumnsDb.isEmpty()) {
// Remove the unneeded trailing text
varPathColumnsDb = CcddUtilities.removeTrailer(varPathColumnsDb, ",");
varPathColumnsUser = CcddUtilities.removeTrailer(varPathColumnsUser, " OR ");
// Get the references in the prototype tables that contain user-defined (i.e.,
// non-blank) variable paths. This accounts for root tables with user-defined paths
String[] matches = dbCommand.getList(DatabaseListCommand.SEARCH, new String[][] { { "_search_text_", ".+" }, { "_case_insensitive_", "false" }, { "_allow_regex_", "true" }, { "_selected_tables_", SearchType.DATA.toString() }, { "_columns_", varPathColumnsDb } }, ccddMain.getMainFrame());
// Step through each variable path
for (String match : matches) {
// Split the reference into table name, column name, table type, and context
String[] tblColDescAndCntxt = match.split(TABLE_DESCRIPTION_SEPARATOR, 4);
// Create a reference to the search result's database table name and row data
// to shorten comparisons below
String[] rowData = CcddUtilities.splitAndRemoveQuotes(tblColDescAndCntxt[SearchResultsQueryColumn.CONTEXT.ordinal()]);
// Set the viewable table name (with capitalization intact)
String[] tableNameAndType = tblColDescAndCntxt[SearchResultsQueryColumn.COMMENT.ordinal()].split(",", 2);
// Get the table's type definition and from that the variable name, data type,
// and variable path column indices
TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(tableNameAndType[1]);
int variableNameIndex = typeDefn.getColumnIndexByInputType(InputDataType.VARIABLE);
int dataTypeIndex = typeDefn.getColumnIndexByInputType(InputDataType.PRIM_AND_STRUCT);
int variablePathIndex = typeDefn.getColumnIndexByInputType(InputDataType.VARIABLE_PATH);
// Add the variable path to the lists (program- and user-defined)
userDefinedVariablePathKey.add(tableNameAndType[0] + "," + rowData[dataTypeIndex] + "." + rowData[variableNameIndex]);
userDefinedVariableName.add(rowData[variablePathIndex]);
}
// Get the references in the custom values table for all user-defined variable
// paths. This accounts for child tables with user-defined paths
matches = dbCommand.getList(DatabaseListCommand.VAR_PATH, new String[][] { { "_match_column_name_", varPathColumnsUser } }, ccddMain.getMainFrame());
// Step through each variable path
for (String match : matches) {
// Split the reference into table name and variable path
String[] tableNameAndPath = match.split(TABLE_DESCRIPTION_SEPARATOR, 2);
// Add the variable path to the lists (program- and user-defined)
userDefinedVariablePathKey.add(tableNameAndPath[0]);
userDefinedVariableName.add(tableNameAndPath[1]);
}
}
}
// Create the storage for the new conversion list
ConversionListStorage conversionList = new ConversionListStorage(varPathSeparator, excludeDataTypes, typeNameSeparator, convertedVariableName);
// Check if the number of stored conversion lists has reached the maximum allowed
if (conversionLists.size() == ModifiableSizeInfo.MAX_STORED_CONVERSIONS.getSize() && ModifiableSizeInfo.MAX_STORED_CONVERSIONS.getSize() > 1) {
// Remove the second converted variable name list from the conversion lists. This
// assumes that the first one likely contains the list built using the separators
// stored in the program preferences
conversionLists.remove(1);
}
// Add the new variable name conversion list to the list of conversions
conversionLists.add(conversionList);
}
Aggregations