public static TablePropertyDefinition[] getDefaultDefinitionsByInheritanceLevel(InheritanceLevel inheritanceLevel) { List<TablePropertyDefinition> resultDefinitions = new ArrayList<TablePropertyDefinition>(); for (TablePropertyDefinition propertyDefinition : DefaultPropertyDefinitions.getDefaultDefinitions()) { if (ArrayUtils.contains(propertyDefinition.getInheritanceLevel(), inheritanceLevel)) { resultDefinitions.add(propertyDefinition); } } return resultDefinitions.toArray(new TablePropertyDefinition[0]); }
/** * Checks if property with given name is suitable for given level. Checks according to the property * definitions in {@link DefaultPropertyDefinitions}. * * @param currentLevel current level of current property. * @param propertyName name of the property to check. * @return true if property with income name can be defined in income level. */ public static boolean isPropertySuitableForLevel(InheritanceLevel currentLevel, String propertyName) { final Logger log = LoggerFactory.getLogger(PropertiesChecker.class); boolean result = false; TablePropertyDefinition propertyDefinition = TablePropertyDefinitionUtils.getPropertyByName(propertyName); if (propertyDefinition != null) { InheritanceLevel[] inheritanceLevels = propertyDefinition.getInheritanceLevel(); if (inheritanceLevels != null && inheritanceLevels.length > 0) { if (Arrays.asList(inheritanceLevels).contains(currentLevel)) { result = true; } } else { log.debug("Inheritance levels were not defined for property with name [{}].", propertyName); } } else { log.debug("There is no such property in Definitions with name [{}].", propertyName); } return result; }
public static TablePropertyDefinition[] getDefaultDefinitionsForTable(String tableType, InheritanceLevel inheritanceLevel, boolean ignoreSystem) { List<TablePropertyDefinition> resultDefinitions = new ArrayList<TablePropertyDefinition>(); for (TablePropertyDefinition propertyDefinition : DefaultPropertyDefinitions.getDefaultDefinitions()) { String name = propertyDefinition.getName(); if (PropertiesChecker.isPropertySuitableForTableType(name, tableType) && (inheritanceLevel == null // any // level || ArrayUtils.contains(propertyDefinition.getInheritanceLevel(), inheritanceLevel)) && (!ignoreSystem || (ignoreSystem && !propertyDefinition.isSystem()))) { resultDefinitions.add(propertyDefinition); } } return resultDefinitions.toArray(new TablePropertyDefinition[resultDefinitions.size()]); }