本文整理汇总了Java中org.alfresco.service.cmr.dictionary.PropertyDefinition.isMultiValued方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyDefinition.isMultiValued方法的具体用法?Java PropertyDefinition.isMultiValued怎么用?Java PropertyDefinition.isMultiValued使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.dictionary.PropertyDefinition
的用法示例。
在下文中一共展示了PropertyDefinition.isMultiValued方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CustomModelProperty
import org.alfresco.service.cmr.dictionary.PropertyDefinition; //导入方法依赖的package包/类
public CustomModelProperty(PropertyDefinition propertyDefinition, MessageLookup messageLookup)
{
this.name = propertyDefinition.getName().getLocalName();
this.prefixedName = propertyDefinition.getName().toPrefixString();
this.title = propertyDefinition.getTitle(messageLookup);
this.dataType = propertyDefinition.getDataType().getName().toPrefixString();
this.description = propertyDefinition.getDescription(messageLookup);
this.isMandatory = propertyDefinition.isMandatory();
this.isMandatoryEnforced = propertyDefinition.isMandatoryEnforced();
this.isMultiValued = propertyDefinition.isMultiValued();
this.defaultValue = propertyDefinition.getDefaultValue();
this.isIndexed = propertyDefinition.isIndexed();
this.facetable = propertyDefinition.getFacetable();
this.indexTokenisationMode = propertyDefinition.getIndexTokenisationMode();
List<ConstraintDefinition> constraintDefs = propertyDefinition.getConstraints();
if (constraintDefs.size() > 0)
{
this.constraintRefs = new ArrayList<>();
this.constraints = new ArrayList<>();
for (ConstraintDefinition cd : constraintDefs)
{
if (cd.getRef() != null)
{
constraintRefs.add(cd.getRef().toPrefixString());
}
else
{
constraints.add(new CustomModelConstraint(cd, messageLookup));
}
}
}
}
示例2: loadMetadataInternal
import org.alfresco.service.cmr.dictionary.PropertyDefinition; //导入方法依赖的package包/类
private void loadMetadataInternal(Metadata metadata, final Path metadataFile)
{
final String metadataFilePath = FileUtils.getFileName(metadataFile);
if (Files.isReadable(metadataFile))
{
Map<String, Serializable> metadataProperties = loadMetadataFromFile(metadataFile);
for (String key : metadataProperties.keySet())
{
if (PROPERTY_NAME_TYPE.equals(key))
{
String typeName = (String) metadataProperties.get(key);
QName type = QName.createQName(typeName, namespaceService);
metadata.setType(type);
}
else if (PROPERTY_NAME_ASPECTS.equals(key))
{
String[] aspectNames = ((String) metadataProperties.get(key)).split(",");
for (final String aspectName : aspectNames)
{
QName aspect = QName.createQName(aspectName.trim(), namespaceService);
metadata.addAspect(aspect);
}
}
else // Any other key => property
{
// ####TODO: figure out how to handle properties of type cm:content - they need to be streamed in via a Writer
QName name = QName.createQName(key, namespaceService);
PropertyDefinition propertyDefinition = dictionaryService.getProperty(name);// TODO: measure performance impact of this API call!!
if (propertyDefinition != null)
{
if (propertyDefinition.isMultiValued())
{
// Multi-valued property
ArrayList<Serializable> values = new ArrayList<Serializable>(
Arrays.asList(((String) metadataProperties.get(key)).split(multiValuedSeparator)));
metadata.addProperty(name, values);
}
else
{
// Single value property
metadata.addProperty(name, metadataProperties.get(key));
}
}
else
{
if (log.isWarnEnabled())
{
log.warn("Property " + String.valueOf(name) + " from '" + metadataFilePath
+ "' doesn't exist in the Data Dictionary. Ignoring it.");
}
}
}
}
}
else
{
if (log.isWarnEnabled())
{
log.warn("Metadata file '" + metadataFilePath + "' is not readable.");
}
}
}
示例3: getValue
import org.alfresco.service.cmr.dictionary.PropertyDefinition; //导入方法依赖的package包/类
public Serializable getValue(Object value, PropertyDefinition propDef)
{
if (value == null)
{
return null;
}
// before persisting check data type of property
if (propDef.isMultiValued())
{
return processMultiValuedType(value);
}
if (isBooleanProperty(propDef))
{
return processBooleanValue(value);
}
else if (isLocaleProperty(propDef))
{
return processLocaleValue(value);
}
else if (value instanceof String)
{
String valStr = (String) value;
// make sure empty strings stay as empty strings, everything else
// should be represented as null
if (isTextProperty(propDef))
{
return valStr;
}
if(valStr.isEmpty())
{
return null;
}
if(isDateProperty(propDef) && !ISO8601DateFormat.isTimeComponentDefined(valStr))
{
// Special handling for day-only date storage (ALF-10243)
return ISO8601DateFormat.parseDayOnly(valStr, TimeZone.getDefault());
}
}
if (value instanceof Serializable)
{
return (Serializable) DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
}
else
{
throw new FormException("Property values must be of a Serializable type! Value type: " + value.getClass());
}
}
示例4: getPropertyValue
import org.alfresco.service.cmr.dictionary.PropertyDefinition; //导入方法依赖的package包/类
private PropertyValue getPropertyValue(PropertyDefinition propertyDef, Object value) throws JSONException
{
PropertyValue ret = null;
if(value == null || value == JSONObject.NULL)
{
ret = null;
}
else if(propertyDef == null)
{
// assume a string
ret = new StringPropertyValue((String)value);
}
else
{
DataTypeDefinition dataType = propertyDef.getDataType();
boolean isMulti = propertyDef.isMultiValued();
if(isMulti)
{
if(!(value instanceof JSONArray))
{
throw new IllegalArgumentException("Expected json array, got " + value.getClass().getName());
}
MultiPropertyValue multi = new MultiPropertyValue();
JSONArray array = (JSONArray)value;
for(int j = 0; j < array.length(); j++)
{
multi.addValue(getSinglePropertyValue(dataType, array.get(j)));
}
ret = multi;
}
else
{
ret = getSinglePropertyValue(dataType, value);
}
}
return ret;
}
示例5: serialize
import org.alfresco.service.cmr.dictionary.PropertyDefinition; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public PropertyValue serialize(QName propName, Serializable value) throws IOException, JSONException
{
if(value == null)
{
return new PropertyValue(false, "null");
}
PropertyDefinition propertyDef = dictionaryService.getProperty(propName);
if (propertyDef == null)
{
// Treat it as text
return new PropertyValue(true, serializeToJSONString(value));
}
DataTypeDefinition dataType = propertyDef.getDataType();
QName dataTypeName = dataType.getName();
if (propertyDef.isMultiValued())
{
if(!(value instanceof Collection))
{
throw new IllegalArgumentException("Multi value: expected a collection, got " + value.getClass().getName());
}
Collection<Serializable> c = (Collection<Serializable>)value;
JSONArray body = new JSONArray();
for(Serializable o : c)
{
if(dataTypeName.equals(DataTypeDefinition.MLTEXT))
{
MLText source = (MLText)o;
JSONArray array = new JSONArray();
for(Locale locale : source.getLocales())
{
JSONObject json = new JSONObject();
json.put("locale", DefaultTypeConverter.INSTANCE.convert(String.class, locale));
json.put("value", source.getValue(locale));
array.put(json);
}
body.put(array);
}
else if(dataTypeName.equals(DataTypeDefinition.CONTENT))
{
throw new RuntimeException("Multi-valued content properties are not supported");
}
else
{
body.put(serializeToJSONString(o));
}
}
return new PropertyValue(false, body.toString());
}
else
{
boolean encodeString = true;
if(dataTypeName.equals(DataTypeDefinition.MLTEXT))
{
encodeString = false;
}
else if(dataTypeName.equals(DataTypeDefinition.CONTENT))
{
encodeString = false;
}
else
{
encodeString = true;
}
String sValue = null;
if (value instanceof String && encodeString) {
sValue = (String)jsonUtils.encodeJSONString(value);
} else {
sValue = serializeToJSONString(value);
}
return new PropertyValue(encodeString, sValue);
}
}