本文整理汇总了Java中org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint类的典型用法代码示例。如果您正苦于以下问题:Java ListOfValuesConstraint类的具体用法?Java ListOfValuesConstraint怎么用?Java ListOfValuesConstraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListOfValuesConstraint类属于org.alfresco.repo.dictionary.constraint包,在下文中一共展示了ListOfValuesConstraint类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createList
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
/**
* @return List of SelectItem components
*/
protected List<SelectItem> createList()
{
List<SelectItem> items = new ArrayList<SelectItem>(5);
Constraint storesConstraint = ConstraintRegistry.getInstance().getConstraint("defaultStoreSelector");
for(String store : ((ListOfValuesConstraint) storesConstraint).getAllowedValues())
{
items.add(new SelectItem(store, store));
}
// make sure the list is sorted by the values
QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return items;
}
示例2: buildPropertyLabels
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
private Map<String, String> buildPropertyLabels(WorkflowTask task, Map<String, Object> properties)
{
TypeDefinition taskType = task.getDefinition().getMetadata();
final Map<QName, PropertyDefinition> propDefs = taskType.getProperties();
return CollectionUtils.transform(properties, new Function<Entry<String, Object>, Pair<String, String>>()
{
@Override
public Pair<String, String> apply(Entry<String, Object> entry)
{
String propName = entry.getKey();
PropertyDefinition propDef = propDefs.get(qNameConverter.mapNameToQName(propName));
if(propDef != null )
{
List<ConstraintDefinition> constraints = propDef.getConstraints();
for (ConstraintDefinition constraintDef : constraints)
{
Constraint constraint = constraintDef.getConstraint();
if (constraint instanceof ListOfValuesConstraint)
{
ListOfValuesConstraint listConstraint = (ListOfValuesConstraint) constraint;
String label = listConstraint.getDisplayLabel(String.valueOf(entry.getValue()), dictionaryService);
return new Pair<String, String>(propName, label);
}
}
}
return null;
}
});
}
示例3: afterPropertiesSet_setupConstraint
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
private void afterPropertiesSet_setupConstraint()
{
if (this.selectorValuesConstraintShortName != null && !this.selectorValuesConstraintShortName.trim().isEmpty())
{
final ListOfValuesConstraint lovConstraint = new ListOfValuesConstraint();
lovConstraint.setShortName(this.selectorValuesConstraintShortName);
lovConstraint.setRegistry(this.constraintRegistry);
lovConstraint.setAllowedValues(new ArrayList<>(this.storeBySelectorPropertyValue.keySet()));
lovConstraint.initialize();
}
}
示例4: setupConstraints
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
/**
* Sets up client validation rules for any constraints the property has.
*
* @param context FacesContext
* propertySheet The property sheet being generated
* @param property The property being generated
* @param propertyDef The data dictionary definition of the property
* @param component The component representing the property
*/
protected void setupConstraints(FacesContext context,
UIPropertySheet propertySheet, PropertySheetItem property,
PropertyDefinition propertyDef, UIComponent component)
{
// only setup constraints if the property sheet is in edit mode,
// validation is enabled
if (propertySheet.inEditMode() && propertySheet.isValidationEnabled() &&
propertyDef != null)
{
List<ConstraintDefinition> constraints = propertyDef.getConstraints();
for (ConstraintDefinition constraintDef : constraints)
{
Constraint constraint = constraintDef.getConstraint();
if (constraint instanceof RegexConstraint)
{
setupRegexConstraint(context, propertySheet, property, component,
(RegexConstraint)constraint, false);
}
else if (constraint instanceof StringLengthConstraint)
{
setupStringLengthConstraint(context, propertySheet, property, component,
(StringLengthConstraint)constraint, false);
}
else if (constraint instanceof NumericRangeConstraint)
{
setupNumericRangeConstraint(context, propertySheet, property, component,
(NumericRangeConstraint)constraint, false);
}
else if (constraint instanceof ListOfValuesConstraint)
{
// NOTE: This is dealt with at the component creation stage
// as a different component is usually required.
}
}
}
}
示例5: makeFieldConstraints
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
private List<FieldConstraint> makeFieldConstraints(PropertyDefinition propDef)
{
List<FieldConstraint> fieldConstraints = null;
List<ConstraintDefinition> constraints = propDef.getConstraints();
if (constraints != null && constraints.size() > 0)
{
fieldConstraints = new ArrayList<FieldConstraint>(constraints.size());
for (ConstraintDefinition constraintDef : constraints)
{
Constraint constraint = constraintDef.getConstraint();
String type = constraint.getType();
Map<String, Object> params = constraint.getParameters();
//ListOfValuesConstraints have special handling for localising their allowedValues.
//If the constraint that we are currently handling is a registered constraint then
//we need to examine the underlying constraint to see if it is a LIST constraint
if (RegisteredConstraint.class.isAssignableFrom(constraint.getClass()))
{
constraint = ((RegisteredConstraint)constraint).getRegisteredConstraint();
}
if (ListOfValuesConstraint.class.isAssignableFrom(constraint.getClass()))
{
ListOfValuesConstraint lovConstraint = (ListOfValuesConstraint) constraint;
List<String> allowedValues = lovConstraint.getAllowedValues();
List<String> localisedValues = new ArrayList<String>(allowedValues.size());
// Look up each localised display-label in turn.
for (String value : allowedValues)
{
String displayLabel = lovConstraint.getDisplayLabel(value, dictionaryService);
// Change the allowedValue entry to the format the FormsService expects for localised strings: "value|label"
// If there is no localisation defined for any value, then this will give us "value|value".
localisedValues.add(value + "|" + displayLabel);
}
// Now replace the allowedValues param with our localised version.
params.put(ListOfValuesConstraint.ALLOWED_VALUES_PARAM, localisedValues);
}
FieldConstraint fieldConstraint = new FieldConstraint(type, params);
fieldConstraints.add(fieldConstraint);
}
}
return fieldConstraints;
}
示例6: newInstance
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
@Override
protected Constraint newInstance()
{
return new ListOfValuesConstraint();
}
示例7: setupConverter
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; //导入依赖的package包/类
protected void setupConverter(FacesContext context,
UIPropertySheet propertySheet, PropertySheetItem property,
PropertyDefinition propertyDef, UIComponent component)
{
// do default processing
super.setupConverter(context, propertySheet, property, propertyDef, component);
// if there isn't a converter and the property has a list of values constraint
// on a number property we need to add the appropriate one.
if (propertySheet.inEditMode() && propertyDef != null &&
component instanceof UIOutput)
{
Converter converter = ((UIOutput)component).getConverter();
if (converter == null)
{
ListOfValuesConstraint constraint = getListOfValuesConstraint(context,
propertySheet, property);
if (constraint != null)
{
String converterId = null;
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.INT))
{
converterId = IntegerConverter.CONVERTER_ID;
}
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.LONG))
{
converterId = LongConverter.CONVERTER_ID;
}
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE))
{
// NOTE: the constant for the double converter is wrong in MyFaces!!
converterId = "javax.faces.Double";
}
else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.FLOAT))
{
converterId = FloatConverter.CONVERTER_ID;
}
if (converterId != null)
{
createAndSetConverter(context, converterId, component);
}
}
}
}
}