use of CCDD.CcddClassesDataTable.GroupInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getGroupTables.
/**
********************************************************************************************
* Get an array containing the table members, including the member table ancestor tables, for
* the specified group
*
* @param groupName
* group name
*
* @return Array containing the table members for the specified group; an empty array if the
* group has no table members, or the group doesn't exist
********************************************************************************************
*/
public String[] getGroupTables(String groupName) {
String[] groupTables = new String[0];
// Get a reference to the group's information
GroupInformation groupInfo = groupHandler.getGroupInformationByName(groupName);
// Check if the group exists
if (groupInfo != null) {
// Get the list of the group's tables
groupTables = groupInfo.getTablesAndAncestors().toArray(new String[0]);
}
return groupTables;
}
use of CCDD.CcddClassesDataTable.GroupInformation in project CCDD by nasa.
the class CcddCommonTreeHandler method adjustExpansionState.
/**
********************************************************************************************
* Adjust the tree expansion state to account for the tree filter selection status
*
* @param expState
* string representing the desired tree expansion state
*
* @param isByGroup
* true if the tree is filtered by group/application
*
* @param isByGroupChanged
* true if the group filter status changed
*
* @param isByType
* true if the tree is filtered by table type
*
* @param isByTypeChanged
* true if the table type filter status changed
*
* @param isApp
* true if the groups are to be treated as possible applications; false if the
* application distinction doesn't apply
*
* @param topNodePrefixes
* initial portion of the node path that provide the overall division of the tree
*
* @param groupHandler
* reference to the group handler
*
* @param tableTypeHandler
* reference to the table type handler
*
* @return String representing the tree expansion state with adjustments made to account for
* the change in filter selection status
********************************************************************************************
*/
protected String adjustExpansionState(String expState, boolean isByGroup, boolean isByGroupChanged, boolean isByType, boolean isByTypeChanged, boolean isApp, List<String> topNodePrefixes, CcddGroupHandler groupHandler, CcddTableTypeHandler tableTypeHandler) {
// Break the expansion state into the separate visible nodes
String[] paths = expState.split(Pattern.quote("],"));
// Clear the expansion state
expState = "";
// Create the path termination regular expression
String termPattern = "(\\],|,.*)";
// Initialize the group name regular expression pattern assuming there is no filtering by
// groups
String groupPattern = "(())";
// Check if the tree has changed to or is already being filtered by groups
if ((isByGroup && !isByGroupChanged) || (!isByGroup && isByGroupChanged)) {
// Initialize the group name regular expression pattern with group filtering enabled
groupPattern = "(, (";
// Step through each group
for (GroupInformation grpInfo : groupHandler.getGroupInformation()) {
// Add the group name to the pattern
groupPattern += Pattern.quote(grpInfo.getName()) + "|";
}
// Finish the group name pattern
groupPattern = CcddUtilities.removeTrailer(groupPattern, "|") + "))";
}
// Initialize the type name regular expression pattern assuming there is no filtering by
// types
String typePattern = "(())";
// Check if the tree has changed to or is already being filtered by types
if ((isByType && !isByTypeChanged) || (!isByType && isByTypeChanged)) {
// Initialize the type name regular expression pattern with type filtering enabled
typePattern = "(, (";
// Step through each table type
for (String type : tableTypeHandler.getTypes()) {
// Add the type name to the pattern
typePattern += Pattern.quote(type) + "|";
}
// Finish the type name pattern
typePattern = CcddUtilities.removeTrailer(typePattern, "|") + "))";
}
// Step through each visible path in the tree
for (String path : paths) {
// Add the path terminator that was removed when the expansion state was split
path += "],";
// Step through the prototype and instance nodes
for (String prefix : topNodePrefixes) {
// Set the flag to true if the path contains the group and/or a type nodes
boolean matchesEither = path.matches(Pattern.quote(prefix) + groupPattern + typePattern + termPattern);
// Set the flag to true if the path contains a group node but no type node
boolean matchesGroup = groupPattern.equals("(())") ? false : typePattern.equals("(())") ? path.matches(Pattern.quote(prefix) + groupPattern + termPattern) || path.matches(Pattern.quote(prefix) + termPattern) : path.matches(Pattern.quote(prefix) + groupPattern + "[^" + typePattern + "]" + termPattern) || path.matches(Pattern.quote(prefix) + typePattern + termPattern);
// Set the flag to true if the path contains a type node but no group node
boolean matchesType = typePattern.equals("(())") ? false : groupPattern.equals("(())") ? path.matches(Pattern.quote(prefix) + typePattern + termPattern) || path.matches(Pattern.quote(prefix) + termPattern) : path.matches(Pattern.quote(prefix) + "[^" + groupPattern + "]" + typePattern + termPattern) || path.matches(Pattern.quote(prefix) + groupPattern + termPattern);
// Check if the path contains a group or type node
if (matchesEither) {
// Check if the group filter changed to enabled
if (isByGroup && isByGroupChanged) {
// Check if the groups are to treated as possible applications
if (isApp) {
// Update the node path with the group name
path = path.replaceAll(Pattern.quote(prefix) + typePattern + termPattern, prefix + "$1$3");
} else // All groups are to treated equally
{
String newPath = "";
// Step through each group
for (GroupInformation grpInfo : groupHandler.getGroupInformation()) {
// Check if the tree is filtered by type
if (isByType) {
// Update the node path with the group name and append it to
// new path
newPath += path.replaceAll(Pattern.quote(prefix) + typePattern + termPattern, prefix + ", " + grpInfo.getName() + "$3");
}
// Update the node path with the group name and append it to new
// path
newPath += path.replaceAll(Pattern.quote(prefix) + typePattern + termPattern, prefix + ", " + grpInfo.getName() + "$1$3");
}
// Check if type filtering is enabled and that the path contains a type
if (isByType && matchesType) {
// Blank the original path; only the new path items are applicable
path = "";
}
// Add the new group nodes to the path
path += newPath;
}
} else // Check if the group filter changed to disabled
if (!isByGroup && isByGroupChanged) {
// Remove the group name form the path
path = path.replaceAll((isApp ? groupPattern : "") + Pattern.quote(prefix) + (isApp ? "" : groupPattern) + typePattern + termPattern, prefix + "$3$5");
} else // Check if the type filter changed to enabled
if (isByType && isByTypeChanged) {
String newPath = "";
// Step through each table type
for (String type : tableTypeHandler.getTypes()) {
// Modify the existing path to include the new type node
newPath += path.replaceAll(Pattern.quote(prefix) + groupPattern + termPattern, prefix + "$1, " + type + "$3");
}
// Add the new type nodes to the path
path += newPath;
} else // Check if the type filter changed to disabled
if (!isByType && isByTypeChanged) {
// Remove the type name form the path
path = path.replaceAll(Pattern.quote(prefix) + groupPattern + typePattern + termPattern, prefix + "$1$5");
}
break;
} else // Check if group filtering is disabled and the path contains a group
if (!isByGroup && matchesGroup) {
// Blank the path
path = "";
} else // Check if type filtering is disabled and the path contains a type
if (!isByType && matchesType) {
// Blank the path
path = "";
}
}
// Check that the path isn't already in the updated expansion state
if (!expState.contains(path)) {
// Add the path to the expansion state
expState += path;
}
}
return expState;
}
use of CCDD.CcddClassesDataTable.GroupInformation in project CCDD by nasa.
the class CcddApplicationSchedulerInput method getAvailableRates.
/**
********************************************************************************************
* Get an array of the available rates
*
* @return Array of rates
********************************************************************************************
*/
@Override
public String[] getAvailableRates() {
// List of all the current rates
List<String> rates = new ArrayList<String>();
// Step through each application in the application tree
for (GroupInformation appInfo : applicationTree.getGroupHandler().getGroupInformation()) {
// Set the field handler to contain the current application's information
fieldHndlr.setFieldInformation(appInfo.getFieldInformation());
// Get the scheduler rate of the current application
FieldInformation rateInfo = fieldHndlr.getFieldInformationByName(CcddFieldHandler.getFieldGroupName(appInfo.getName()), "Schedule Rate");
// Check if the application had a schedule rate assigned
if (rateInfo != null && !rates.contains(rateInfo.getValue())) {
// Add the rate to the list of current rates
rates.add(rateInfo.getValue());
}
}
// Sort the list of rates from greatest to least
Collections.sort(rates, Collections.reverseOrder(new Comparator<String>() {
/**
************************************************************************************
* Override the compare method to sort from greatest to least
************************************************************************************
*/
@Override
public int compare(String string1, String string2) {
// Compare the integer value of the strings
return Integer.valueOf(string1).compareTo(Integer.valueOf(string2));
}
}));
return rates.toArray(new String[rates.size()]);
}
use of CCDD.CcddClassesDataTable.GroupInformation in project CCDD by nasa.
the class CcddWebDataAccessHandler method getCommandInformation.
/**
********************************************************************************************
* Get the information for each command matching the specified filters
*
* @param groupFilter
* group (or application) name. A table must belong to the specified group in order
* for its telemetered variables to be returned; blank to get all telemetered
* variables (regardless of group)
*
* @return JSON encoded string containing information for each command matching the specified
* filters
*
* @throws CCDDException
* If the supplied group name is unrecognized
********************************************************************************************
*/
@SuppressWarnings("unchecked")
private String getCommandInformation(String groupFilter) throws CCDDException {
JSONArray commandsJA = new JSONArray();
TypeDefinition typeDefn = null;
int commandNameIndex = -1;
int commandCodeIndex = -1;
int commandDescriptionIndex = -1;
List<AssociatedColumns> commandArguments = null;
List<String> groupTables = null;
// Table type name for the previous table type loaded
String lastType = "";
// Check if a group name filter is specified
if (!groupFilter.isEmpty()) {
// Create a group handler and extract the table names belonging to the group
CcddGroupHandler groupHandler = new CcddGroupHandler(ccddMain, null, ccddMain.getMainFrame());
GroupInformation groupInfo = groupHandler.getGroupInformationByName(groupFilter);
// Check if the group doesn't exist
if (groupInfo == null) {
throw new CCDDException("unrecognized group name");
}
// Get the tables associated with the group
groupTables = groupInfo.getTablesAndAncestors();
}
// Step through each command table
for (String commandTable : dbTable.getPrototypeTablesOfType(TYPE_COMMAND)) {
// requested that the table is a member of the group
if (groupFilter.isEmpty() || groupTables.contains(commandTable)) {
// Get the information from the database for the specified table
TableInformation tableInfo = dbTable.loadTableData(commandTable, false, false, false, ccddMain.getMainFrame());
// Check if the table loaded successfully
if (!tableInfo.isErrorFlag()) {
// every table
if (!tableInfo.getType().equals(lastType)) {
String descColName;
commandDescriptionIndex = -1;
// Store the table type name
lastType = tableInfo.getType();
// Get the table's type definition
typeDefn = tableTypeHandler.getTypeDefinition(tableInfo.getType());
// Get the command name column
commandNameIndex = typeDefn.getColumnIndexByUserName(typeDefn.getColumnNameByInputType(InputDataType.COMMAND_NAME));
// Get the command name column
commandCodeIndex = typeDefn.getColumnIndexByUserName(typeDefn.getColumnNameByInputType(InputDataType.COMMAND_CODE));
// Check if a command description column exists
if ((descColName = typeDefn.getColumnNameByInputType(InputDataType.DESCRIPTION)) != null) {
// Get the command description column
commandDescriptionIndex = typeDefn.getColumnIndexByUserName(descColName);
}
// Get the list containing command argument column indices for each
// argument grouping
commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
}
// values
if (!isReplaceMacro) {
// Replace all macros in the table
tableInfo.setData(ccddMain.getMacroHandler().replaceAllMacros(tableInfo.getData()));
}
// Step through each command in the command table
for (int row = 0; row < tableInfo.getData().length; row++) {
JSONObject commandJO = new JSONObject();
String cellValue;
// on this row is skipped
if (!(cellValue = tableInfo.getData()[row][commandNameIndex]).isEmpty()) {
JSONArray commandArgumentsJA = new JSONArray();
// Store the name of the command table from which this command is taken
commandJO.put("Command Table Name", commandTable);
// Store the command name in the JSON output
commandJO.put(typeDefn.getColumnNamesUser()[commandNameIndex], cellValue);
// Check if the command code is present
if (!(cellValue = tableInfo.getData()[row][commandCodeIndex]).isEmpty()) {
// Store the command code in the JSON output
commandJO.put(typeDefn.getColumnNamesUser()[commandCodeIndex], cellValue);
}
// Check if the command description is present
if (commandDescriptionIndex != -1 && !(cellValue = tableInfo.getData()[row][commandDescriptionIndex]).isEmpty()) {
// Store the command description in the JSON output
commandJO.put(typeDefn.getColumnNamesUser()[commandDescriptionIndex], cellValue);
}
// command row
for (AssociatedColumns cmdArgument : commandArguments) {
JSONObject commandArgumentJO = new JSONObject();
// all associated argument values are skipped
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getName()]).isEmpty()) {
// Store the command argument name in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getName()], cellValue);
// Check if the command argument data type column has a value
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getDataType()]).isEmpty()) {
// Store the data type in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getDataType()], cellValue);
}
// Check if the command argument array size column has a value
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getArraySize()]).isEmpty()) {
// Store the array size in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getArraySize()], cellValue);
}
// Check if the command argument bit length column has a value
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getBitLength()]).isEmpty()) {
// Store the bit length in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getBitLength()], cellValue);
}
// Check if the command argument enumeration column has a value
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getEnumeration()]).isEmpty()) {
// Store the enumeration in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getEnumeration()], cellValue);
}
// Check if the command argument minimum column has a value
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getMinimum()]).isEmpty()) {
// Store the minimum value in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getMinimum()], cellValue);
}
// Check if the command argument maximum column has a value
if (!(cellValue = tableInfo.getData()[row][cmdArgument.getMaximum()]).isEmpty()) {
// Store the maximum value in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[cmdArgument.getMaximum()], cellValue);
}
// argument
for (int otherArg : cmdArgument.getOther()) {
// Check if the other argument column has a value
if (!(cellValue = tableInfo.getData()[row][otherArg]).isEmpty()) {
// Store the value in the JSON output
commandArgumentJO.put(typeDefn.getColumnNamesUser()[otherArg], cellValue);
}
}
}
// Store the command arguments in the JSON array
commandArgumentsJA.add(commandArgumentJO);
}
// Check if the command has an argument
if (!commandArgumentsJA.isEmpty()) {
// Store the command arguments in the JSON output
commandJO.put("Arguments", commandArgumentsJA);
}
}
// Add the command to the JSON array
commandsJA.add(commandJO);
}
}
}
}
return commandsJA.toString();
}
use of CCDD.CcddClassesDataTable.GroupInformation in project CCDD by nasa.
the class CcddApplicationSchedulerTableHandler method validateApplicationData.
/**
********************************************************************************************
* Check all the stored application information for inconsistencies. Update or flag the
* application for removal if any changes are found
*
* @return List of invalid applications
********************************************************************************************
*/
private List<Variable> validateApplicationData() {
List<Variable> removedApps = new ArrayList<Variable>();
// Create a group tree
CcddGroupTreeHandler groupTree = new CcddGroupTreeHandler(ccddMain, null, ccddMain.getMainFrame());
// Get a list of the current group's names
String[] groupNames = groupTree.getGroupHandler().getGroupNames(true);
// Create a data field handler to interact with the groups' fields
CcddFieldHandler fieldHandler = new CcddFieldHandler(ccddMain);
// Step through each application
for (Variable app : applications) {
boolean isValid = false;
// Step through the group names
for (String name : groupNames) {
// Check if the group's name matches the application's name
if (app.getFullName().equals(name)) {
// Get the group's information and set the data field handler to contain the
// current group's information
GroupInformation groupInfo = groupTree.getGroupHandler().getGroupInformationByName(name);
fieldHandler.setFieldInformation(groupInfo.getFieldInformation());
// Get the application data field owner name
String application = CcddFieldHandler.getFieldGroupName(groupInfo.getName());
// Get the application's schedule rate
FieldInformation appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.SCHEDULE_RATE.getFieldName());
// Check if the application's rate equals its field's rate
if (Float.valueOf(appInfo.getValue()) == app.getRate()) {
ApplicationData appData = (ApplicationData) app;
// Set the applications's validity to true
isValid = true;
// Get the run time field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.EXECUTION_TIME.getFieldName());
// Check if the application's run time changed
if (appInfo != null && Integer.valueOf(appInfo.getValue()) != app.getSize()) {
// Update the run time to what the field has set
app.setSize(Integer.valueOf(appInfo.getValue()));
}
// Get the execution priority field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.PRIORITY.getFieldName());
// Check if the application's priority changed
if (appInfo != null && Integer.valueOf(appInfo.getValue()) != appData.getPriority()) {
// Update the application's priority
appData.setPriority(Integer.valueOf(appInfo.getValue()));
}
// Get the message rate field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.MESSAGE_RATE.getFieldName());
// Check if the application's message rate changed
if (appInfo != null && Integer.valueOf(appInfo.getValue()) != appData.getMessageRate()) {
// Update the application's message rate
appData.setMessageRate(Integer.valueOf(appInfo.getValue()));
}
// Get the wake-up name field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.WAKE_UP_NAME.getFieldName());
// Check if the application's wake-up name changed
if (appInfo != null && !appInfo.getValue().equals(appData.getWakeUpName())) {
// Update the application's wake-up name
appData.setWakeUpName(appInfo.getValue());
}
// Get the wake-up ID field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.WAKE_UP_ID.getFieldName());
// Check if the application's wake-up ID changed
if (appInfo != null && !appInfo.getValue().equals(appData.getWakeUpID())) {
// Update the application's wake-up ID
appData.setWakeUpID(appInfo.getValue());
}
// Get the HK send rate field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.HK_SEND_RATE.getFieldName());
// Check if the application's HK send rate changed
if (appInfo != null && Integer.valueOf(appInfo.getValue()) != appData.getHkSendRate()) {
// Update the application's HK send rate
appData.setHkSendRate(Integer.valueOf(appInfo.getValue()));
}
// Get the HK wake-up name field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.HK_WAKE_UP_NAME.getFieldName());
// Check if the application's HK wake-up name changed
if (appInfo != null && !appInfo.getValue().equals(appData.getHkWakeUpName())) {
// Update the application's HK wake-up name
appData.setHkWakeUpName(appInfo.getValue());
}
// Get the HK wake-up ID field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.HK_WAKE_UP_ID.getFieldName());
// Check if the application's HK wake-up ID changed
if (appInfo != null && !appInfo.getValue().equals(appData.getHkWakeUpID())) {
// Update the application's HK wake-up ID
appData.setHkWakeUpID(appInfo.getValue());
}
// Get the schedule group field information
appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.SCH_GROUP.getFieldName());
// Check if the application's schedule group changed
if (appInfo != null && !appInfo.getValue().equals(appData.getSchGroup())) {
// Update the application's schedule group
appData.setSchGroup(appInfo.getValue());
}
}
break;
}
}
// Check if the application is invalid
if (!isValid) {
// Add the application to the list of removed applications
removedApps.add(app);
}
}
return removedApps;
}
Aggregations