private boolean isCategoryProperties(String scope) { return InheritanceLevel.CATEGORY.getDisplayName().equals(scope); }
private boolean isModuleProperties(String scope) { return InheritanceLevel.MODULE.getDisplayName().equals(scope); }
public static InheritanceLevel getEnumByValue(String value) { for (InheritanceLevel level : InheritanceLevel.values()) { if (level.getDisplayName().equals(value)) { return level; } } return null; }
public static boolean isModulePropertyTable(TableSyntaxNode tableSyntaxNode) { boolean result = false; ITableProperties tableProperties = tableSyntaxNode.getTableProperties(); if (tableProperties != null) { String propValue = tableProperties.getScope(); if (StringUtils.isNotEmpty(propValue) && InheritanceLevel.MODULE.getDisplayName().equals(propValue)) { result = true; } } return result; }
private boolean isCategoryPropertyTable(TableSyntaxNode tableSyntaxNode) { boolean result = false; ITableProperties tableProperties = tableSyntaxNode.getTableProperties(); if (tableProperties != null) { String propValue = tableProperties.getScope(); if (StringUtils.isNotEmpty(propValue)) { if (InheritanceLevel.CATEGORY.getDisplayName().equals(propValue)) { result = true; } } } return result; }
private void checkPropertiesLevel(InheritanceLevel currentLevel, TableProperties propertiesInstance, TableSyntaxNode tableSyntaxNode, IBindingContext bindingContext) throws SyntaxNodeException { for (String propertyNameToCheck : propertiesInstance.getAllProperties().keySet()) { if (!PropertiesChecker.isPropertySuitableForLevel(currentLevel, propertyNameToCheck)) { String message = String.format("Property '%s' can`t be defined on the '%s' level", propertyNameToCheck, currentLevel.getDisplayName()); throw SyntaxNodeExceptionUtils.createError(message, tableSyntaxNode); } } }
public static boolean isModulePropertyTable(TableSyntaxNode tableSyntaxNode) { boolean result = false; ITableProperties tableProperties = tableSyntaxNode.getTableProperties(); if (tableProperties != null) { String propValue = tableProperties.getScope(); if (StringUtils.isNotEmpty(propValue) && InheritanceLevel.MODULE.getDisplayName().equals(propValue)) { result = true; } } return result; }
public static boolean isModulePropertyTable(TableSyntaxNode tableSyntaxNode) { boolean result = false; ITableProperties tableProperties = tableSyntaxNode.getTableProperties(); if (tableProperties != null) { String propValue = tableProperties.getScope(); if (StringUtils.isNotEmpty(propValue) && InheritanceLevel.MODULE.getDisplayName().equals(propValue)) { result = true; } } return result; }
@Override protected Map<String, Object> buildProperties() { Map<String, Object> resultProperties = new LinkedHashMap<String, Object>(); resultProperties.put("scope", scopeType); if (InheritanceLevel.CATEGORY.getDisplayName().equals(scopeType)) { String categoryName = buildCategoryName(); if (categoryName != null) { resultProperties.put("category", categoryName); } } for (TableProperty property : propertiesManager.getProperties()) { String name = property.getName(); Object value = property.getValue(); if (value == null || (value != null && (value instanceof String && StringUtils.isEmpty((String) value)))) { continue; } else { resultProperties.put(name.trim(), value); } } return resultProperties; }
private boolean isCategoryPropertyTable(TableSyntaxNode tableSyntaxNode) { boolean result = false; ITableProperties tableProperties = tableSyntaxNode.getTableProperties(); if (tableProperties != null) { String propValue = tableProperties.getScope(); if (StringUtils.isNotEmpty(propValue)) { if (InheritanceLevel.CATEGORY.getDisplayName().equals(propValue)) { result = true; } } } return result; }
private boolean isCategoryPropertyTable(TableSyntaxNode tableSyntaxNode) { boolean result = false; ITableProperties tableProperties = tableSyntaxNode.getTableProperties(); if (tableProperties != null) { String propValue = tableProperties.getScope(); if (StringUtils.isNotEmpty(propValue)) { if (InheritanceLevel.CATEGORY.getDisplayName().equals(propValue)) { result = true; } } } return result; }
@Override protected Map<String, Object> buildProperties() { Map<String, Object> resultProperties = new LinkedHashMap<String, Object>(); resultProperties.put("scope", scopeType); if (InheritanceLevel.CATEGORY.getDisplayName().equals(scopeType)) { String categoryName = buildCategoryName(); if (categoryName != null) { resultProperties.put("category", categoryName); } } for (TableProperty property : propertiesManager.getProperties()) { String name = property.getName(); Object value = property.getValue(); if (value != null && (!(value instanceof String) || StringUtils.isNotEmpty((String) value))) { resultProperties.put(name.trim(), value); } } return resultProperties; }
@Override protected Map<String, Object> buildProperties() { Map<String, Object> resultProperties = new LinkedHashMap<String, Object>(); resultProperties.put("scope", scopeType); if (InheritanceLevel.CATEGORY.getDisplayName().equals(scopeType)) { String categoryName = buildCategoryName(); if (categoryName != null) { resultProperties.put("category", categoryName); } } for (TableProperty property : propertiesManager.getProperties()) { String name = property.getName(); Object value = property.getValue(); if (value != null && (!(value instanceof String) || StringUtils.isNotEmpty((String) value))) { resultProperties.put(name.trim(), value); } } return resultProperties; }
/** * Checks if properties can be defined for given type of table and for given inheritance level. */ private static void checkForErrors(IBindingContext bindingContext, Set<String> propertyNamesToCheck, TableSyntaxNode tableSyntaxNode, InheritanceLevel level) { String tableType = tableSyntaxNode.getType(); String typeName = getTypeName(tableSyntaxNode); for (String propertyNameToCheck : propertyNamesToCheck) { if (!PropertiesChecker.isPropertySuitableForTableType(propertyNameToCheck, tableType)) { String message = String.format("Property '%s' can't be defined in %s Table", propertyNameToCheck, typeName); addError(bindingContext, tableSyntaxNode, message); } else if (level != null && !PropertiesChecker.isPropertySuitableForLevel(level, propertyNameToCheck)) { String message = String.format("Property '%s' can't be defined on the '%s' level", propertyNameToCheck, level.getDisplayName()); addError(bindingContext, tableSyntaxNode, message); } } }
String message = String.format("Value of the property '%s' is neither '%s' or '%s'", SCOPE_PROPERTY_NAME, InheritanceLevel.MODULE.getDisplayName(), InheritanceLevel.CATEGORY.getDisplayName());