public TableProperty(TablePropertyDefinition propDefinition) { this.name = propDefinition.getName(); this.displayName = propDefinition.getDisplayName(); this.type = propDefinition.getType() == null ? String.class : propDefinition.getType().getInstanceClass(); this.group = propDefinition.getGroup(); this.format = propDefinition.getFormat(); this.deprecation = propDefinition.getDeprecation(); this.constraints = propDefinition.getConstraints(); this.description = propDefinition.getDescription(); this.system = propDefinition.isSystem(); this.dimensional = propDefinition.isDimensional(); }
private void applyDomain(TablePropertyDefinition propDef, IDomainAdaptor gatheredDomain) { String propName = propDef.getName(); String key = propName + ADispatcherTableColumn.LOCAL_PARAM_SUFFIX; if (gatheredDomain != null && !propertiesDomains.containsKey(key)) { if (propDef.getExpression() != null) { propertiesDomains.put(propDef.getExpression().getMatchExpression().getContextAttribute(), gatheredDomain); propertiesDomains.put(propName, gatheredDomain); propertiesDomains.put(key, gatheredDomain); } } }
/** * Gets the name of the property by the given display name * * @param displayName * @return name */ public static String getPropertyName(String displayName) { for (TablePropertyDefinition propDefinition : DefaultPropertyDefinitions.getDefaultDefinitions()) { if (propDefinition.getDisplayName().equals(displayName)) { return propDefinition.getName(); } } return null; }
/** * Action that can be use on form. "propNameToAdd" must be specified. */ public void addProperty() { TablePropertyDefinition propDefinition = getPropByName(propNameToAdd); Class<?> propType = propDefinition.getType() == null ? String.class : propDefinition.getType() .getInstanceClass(); properties .add(new TableProperty.TablePropertyBuilder(propDefinition.getName(), propType) .displayName(propDefinition.getDisplayName()).format(propDefinition.getFormat()).build()); possibleToAddProps.remove(propNameToAdd); }
/** * During the construction, we take all the properties from DefaultPropertyDefinitions * that must be included in business search */ public BussinesSearchPropertyBean() { TablePropertyDefinition[] propDefinitions = DefaultPropertyDefinitions.getDefaultDefinitions(); for (TablePropertyDefinition propDefinition : propDefinitions) { if(propDefinition.isBusinessSearch()) { Class<?> propertyType = propDefinition.getType() == null ? null : propDefinition.getType() .getInstanceClass(); propForSearch.add( new TableProperty.TablePropertyBuilder(propDefinition.getName(), propertyType) .displayName(propDefinition.getDisplayName()).group(propDefinition.getGroup()) .format(propDefinition.getFormat()).constraints(propDefinition.getConstraints()) .build()); } } //busSearchResBean = new BussinessSearchResultBean(propForSearch); }
private void initProperties() { List<TableProperty> definedProperties = new ArrayList<TableProperty>(); ITableProperties tableProperties = table.getProperties(); for (String possiblePropertyName : propertiesManager.getPossibleToAddProperties()) { TablePropertyDefinition propDefinition = TablePropertyDefinitionUtils.getPropertyByName(possiblePropertyName); if (propDefinition != null && !propDefinition.isSystem() && propDefinition.getDeprecation() == null) { Object propertyValue = tableProperties.getPropertyValue(possiblePropertyName) != null ? tableProperties.getPropertyValue(possiblePropertyName) : null; if (tableProperties.getTableProperties().containsKey(possiblePropertyName)) { Class<?> propertyType = null; if (propDefinition.getType() != null) { propertyType = propDefinition.getType().getInstanceClass(); } String displayName = propDefinition.getDisplayName(); String format = propDefinition.getFormat(); boolean dimensional = propDefinition.isDimensional(); TableProperty tableProperty = new TableProperty.TablePropertyBuilder(possiblePropertyName, propertyType).value( propertyValue).displayName(displayName).format(format).dimensional(dimensional).build(); definedProperties.add(tableProperty); } } } propertiesManager.setProperties(definedProperties); }
private boolean updateSystemValue(TableEditorModel editorModel, TablePropertyDefinition sysProperty) { boolean result = false; String systemValue = null; if (sysProperty.getSystemValuePolicy().equals(SystemValuePolicy.ON_EACH_EDIT)) { systemValue = SystemValuesManager.getInstance().getSystemValueString( sysProperty.getSystemValueDescriptor()); if (systemValue != null) { try { editorModel.setProperty(sysProperty.getName(), systemValue); result = true; } catch (Exception e) { LOG.error(String.format("Can`t update system property '%s' with value '%s'", sysProperty.getName(), systemValue), e); } } } return result; }
public List<SelectItem> getPropertyList() { List<SelectItem> propertyNames = new ArrayList<SelectItem>(); TablePropertyDefinition[] propDefinitions = TablePropertyDefinitionUtils .getDefaultDefinitionsForTable(TABLE_TYPE, InheritanceLevel.TABLE, true); SelectItem selectItem = new SelectItem(""); selectItem.setLabel(""); propertyNames.add(selectItem); Map<String, List<TablePropertyDefinition>> propGroups = TablePropertyDefinitionUtils .groupProperties(propDefinitions); for (Map.Entry<String, List<TablePropertyDefinition>> entry : propGroups.entrySet()) { List<SelectItem> items = new ArrayList<SelectItem>(); for (TablePropertyDefinition propDefinition : entry.getValue()) { String propName = propDefinition.getName(); if (propDefinition.getDeprecation() == null) { items.add(new SelectItem(propName, propDefinition.getDisplayName())); } } if (!items.isEmpty()) { SelectItemGroup itemGroup = new SelectItemGroup(entry.getKey()); itemGroup.setSelectItems(items.toArray(new SelectItem[items.size()])); propertyNames.add(itemGroup); } } return propertyNames; }
private String getLocalParameterName() { return (getProperty().getName() + ADispatcherTableColumn.LOCAL_PARAM_SUFFIX).intern(); } }
private List<String> getAllPossibleProperties(String tableType) { List<String> possibleProperties = new ArrayList<String>(); TablePropertyDefinition[] propDefinitions = DefaultPropertyDefinitions.getDefaultDefinitions(); for (TablePropertyDefinition propDefinition : propDefinitions) { if (!propDefinition.isSystem()) { String propertyName = propDefinition.getName(); // check if the property can be defined in current type of table // and if property can be defined on TABLE level. if (PropertiesChecker.isPropertySuitableForTableType(propertyName, tableType) && PropertiesChecker.isPropertySuitableForLevel(InheritanceLevel.TABLE, propertyName)) { possibleProperties.add(propDefinition.getName()); } } } return possibleProperties; }
private Object convertAttribute(String attributeName, Object attributeValue) { List<TablePropertyDefinition> dimensionalTableProperties = TablePropertyDefinitionUtils.getDimensionalTableProperties(); for (TablePropertyDefinition property : dimensionalTableProperties) { String contextAttribute = property.getExpression().getMatchExpression().getContextAttribute(); if (contextAttribute.equals(attributeName)) { IOpenClass type = property.getType(); if (type.isArray()) { type = type.getComponentClass(); } IString2DataConvertor converter = String2DataConvertorFactory.getConvertor(type.getInstanceClass()); String argument = HelperFunctions.convertArgument(String.class, attributeValue); return converter.parse(argument, property.getFormat()); } } // Couldn't find property and converter for it return attributeValue; } }
public synchronized void setProperty(String name, String value) throws Exception { Object objectValue = null; if (StringUtils.isNotBlank(value)) { TablePropertyDefinition tablePropeprtyDefinition = TablePropertyDefinitionUtils.getPropertyByName(name); if (tablePropeprtyDefinition != null) { Class<?> type = tablePropeprtyDefinition.getType().getInstanceClass(); IFormatter formatter = FormattersManager.getFormatter(type, tablePropeprtyDefinition.getFormat()); objectValue = formatter.parse(value); } else { objectValue = value; } } setProperty(name, objectValue); }
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()]); }
private void checkPropertiesExistance() { TablePropertyDefinition[] propDefinitions = DefaultPropertyDefinitions.getDefaultDefinitions(); for (TablePropertyDefinition propDefinition : propDefinitions) { if (propDefinition.isDimensional() && getProperty(propDefinition.getName()) == null) { TableProperty property = new TableProperty(propDefinition); getPropertiesManager().addProperty(property); } } }
TablePropertyValidatorsWrapper(TablePropertyDefinition tablePropertyDefinition) { name = tablePropertyDefinition.getName(); constraints = tablePropertyDefinition.getConstraints(); if (constraints != null) { constraintsStr = constraints.getConstraintsStr(); List<Constraint> constraints = this.constraints.getAll(); for (Constraint constraint : constraints) { if (constraint instanceof UniqueActiveTableConstraint) { validatorClasses.add(ActivePropertyValidator.class); } else if (constraint instanceof UniqueInModuleConstraint) { validatorClasses.add(UniquePropertyValueValidator.class); } else if (constraint instanceof RegexpValueConstraint) { validatorClasses.add(RegexpPropertyValidator.class); } } } }
@Override public int compareTo(TablePropertyDefinition to) { return displayName.compareTo(to.getDisplayName()); }
private static TablePropertyDefinition getTablePropertyDefinition(Attribute attribute) { List<TablePropertyDefinition> dimensionalTableProperties = TablePropertyDefinitionUtils.getDimensionalTableProperties(); Class<? extends Constraint> constraintClass = getConstraintClass(attribute); for (TablePropertyDefinition property : dimensionalTableProperties) { String contextAttribute = property.getExpression().getMatchExpression().getContextAttribute(); if (contextAttribute.equals(attribute.getName())) { Constraints constraints = property.getConstraints(); if (constraints.size() == 1) { Constraint constraint = constraints.get(0); if (constraintClass == null || constraintClass.isAssignableFrom(constraint.getClass())) { return property; } } } } return null; }
/** * Gets the array of properties names that are dimensional. * * @return names of properties that are dimensional. */ public static List<TablePropertyDefinition> getDimensionalTableProperties() { if (dimensionalTableProperties == null) { List<TablePropertyDefinition> dimensionalProperties = new ArrayList<TablePropertyDefinition>(); TablePropertyDefinition[] definitions = DefaultPropertyDefinitions.getDefaultDefinitions(); for (TablePropertyDefinition definition : definitions) { if (definition.isDimensional()) { dimensionalProperties.add(definition); } } dimensionalTableProperties = Collections.unmodifiableList(dimensionalProperties); } return dimensionalTableProperties; }