本文整理了Java中org.nuxeo.ecm.core.schema.types.Field
类的一些代码示例,展示了Field
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field
类的具体详情如下:
包路径:org.nuxeo.ecm.core.schema.types.Field
类名称:Field
[英]A field is a member of a complex type.
It is defined by a name and a type.
[中]字段是复杂类型的成员。
它由名称和类型定义。
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public String toString() {
if (listItem) {
return field.getName().getPrefixedName();
} else {
return field.getName().getPrefixedName() + "[" + index + "]";
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* Validates sub fields for given complex field.
*
* @since 7.1
*/
@SuppressWarnings("unchecked")
private List<ConstraintViolation> validateComplexTypeField(Schema schema, List<PathNode> path, Field field,
Object value) {
assert field.getType().isComplexType();
List<ConstraintViolation> violations = new ArrayList<>();
ComplexType complexType = (ComplexType) field.getType();
// this code does not support other type than Map as value
if (!(value instanceof Map)) {
return violations;
}
Map<String, Object> map = (Map<String, Object>) value;
for (Field child : complexType.getFields()) {
Object item = map.get(child.getName().getLocalName());
List<PathNode> subPath = new ArrayList<>(path);
subPath.add(new PathNode(child));
violations.addAll(validateAnyTypeField(schema, subPath, child, item, true));
}
return violations;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* @since 7.1
*/
private List<ConstraintViolation> validateSimpleTypeProperty(Schema schema, List<PathNode> path, Property prop,
boolean dirtyOnly) {
Field field = prop.getField();
assert field.getType().isSimpleType() || prop.isScalar();
List<ConstraintViolation> violations = new ArrayList<>();
Serializable value = prop.getValue();
Object defaultValue = field.getDefaultValue();
// check nullity constraint only if field doesn't have a default value (phantom case)
if (prop.isPhantom() && defaultValue == null || value == null) {
if (!field.isNillable()) {
addNotNullViolation(violations, schema, path);
}
} else {
violations.addAll(validateSimpleTypeField(schema, path, field, value));
}
return violations;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
assert field.getType().isListType();
List<ConstraintViolation> violations = new ArrayList<>();
Collection<?> castedValue = null;
if (!field.isNillable() && value == null) {
addNotNullViolation(violations, schema, path);
if (!field.isNillable() && castedValue.isEmpty()) {
addNotNullViolation(violations, schema, path);
ListType listType = (ListType) field.getType();
Field listField = listType.getField();
int index = 0;
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public ComplexType getType() {
return (ComplexType) field.getType();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-schema
@Override
public Map<String, Object> newInstance() {
if (TypeConstants.isContentType(this)) {
// NXP-912: should return null for a blob. Since there is no
// pluggable adapter mechanism on types, and since document model
// properties consider that every complex property named "content"
// should be dealt with a BlobProperty, this is hardcoded here.
return null;
}
Map<String, Object> map = new HashMap<String, Object>();
for (Field field : fields.values()) {
Object value;
Type type = field.getType();
if (type.isComplexType()) {
value = type.newInstance();
} else if (type.isListType()) {
value = new ArrayList<Object>();
} else {
value = field.getDefaultValue();
}
map.put(field.getName().getLocalName(), value);
}
return map;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
if (field != null && field.getType().isListType()) {
Field itemField = ((ListType) field.getType()).getField();
if (xpathToken.matches("\\d+")) {
int index = Integer.parseInt(xpathToken);
path.add(new PathNode(field, index));
} else if (xpathToken.equals(itemField.getName().getLocalName())) {
Schema schema = field.getDeclaringType().getSchema(); // NOSONAR
return new DocumentValidationReport(validateAnyTypeField(schema, path, field, value, validateSubProperties));
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-schema
/**
* Create a schema from a ComplexType
*
* @since 5.7
* @param complexType
* @param name
* @param ns
*/
public SchemaImpl(ComplexType complexType, String name, Namespace ns, boolean isVersionWritabe) {
super(null, SchemaNames.SCHEMAS, name, ns);
this.isVersionWritabe = isVersionWritabe;
if (complexType != null) {
for (Field field : complexType.getFields()) {
QName fieldname = QName.valueOf(field.getName().getLocalName(), ns.prefix);
Type type = field.getType();
String defaultValue = type.encode(field.getDefaultValue());
Set<Constraint> constraint = field.getConstraints();
FieldImpl newField = new FieldImpl(fieldname, this, type, defaultValue, 0, constraint);
newField.setConstant(field.isConstant());
addField(newField);
}
}
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-sql
Field schemaIdField = schemaFieldMap.get(getIdField());
String idFieldName = schemaIdField.getName().getPrefixedName();
idColumn = column;
String prefixedName = schemaFieldMap.get(column.getKey()).getName().getPrefixedName();
if (prefixedField != null && prefixedField.getDefaultValue() != null) {
fieldMap.put(prefixedName, prefixedField.getDefaultValue());
} else {
i.remove();
List<Serializable> values = new ArrayList<>(columnList.size());
for (Column column : columnList) {
String prefixField = schemaFieldMap.get(column.getKey()).getName().getPrefixedName();
Object value = fieldMap.get(prefixField);
Serializable v;
String prefixField = schemaFieldMap.get(column.getKey()).getName().getPrefixedName();
Object value = fieldMap.get(prefixField);
setFieldValue(ps, index, column, value);
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io
String typeValue;
Set<Constraint> itemConstraints = null;
if (field.getType().isListType()) {
ListType lt = (ListType) field.getType();
Type type = lt.getFieldType();
itemConstraints = type.getConstraints();
Type type = field.getType();
while (!(type instanceof PrimitiveType)) {
type = type.getSuperType();
jg.writeObjectFieldStart(field.getName().getLocalName());
jg.writeStringField("type", typeValue);
Writer<Constraint> constraintWriter = registry.getWriter(ctx, Constraint.class, APPLICATION_JSON_TYPE);
OutputStream out = new OutputStreamWithJsonWriter(jg);
jg.writeArrayFieldStart("constraints");
for (Constraint c : field.getConstraints()) {
constraintWriter.write(c, Constraint.class, Constraint.class, APPLICATION_JSON_TYPE, out);
jg.writeStringField(field.getName().getLocalName(), typeValue);
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io
@Override
public Schema createSchema(ComplexType input) {
Schema schema = Schema.createRecord(getName(input), null, input.getNamespace().prefix, false);
List<Field> fields = new ArrayList<>(input.getFields().size());
for (org.nuxeo.ecm.core.schema.types.Field f : context.sort(input.getFields())) {
String fieldName = context.getService().encodeName(f.getName().getLocalName());
Schema fieldSchema = context.createSchema(f.getType());
if (f.isNillable()) {
fieldSchema = nullable(fieldSchema);
}
fields.add(new Field(fieldName, fieldSchema, null, (Object) null));
}
schema.setFields(fields);
return schema;
}
代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core
protected void writeBuckets(String fieldName, List<Bucket> buckets, Field field, JsonGenerator jg)
throws IOException, JsonGenerationException {
Schema schema = field.getDeclaringType().getSchema();
DocumentPartImpl part = new DocumentPartImpl(schema);
prop = PropertyFactory.createProperty(part, t.getField(), Property.NONE);
log.debug(String.format("Writing %s for field %s resolved to %s", fieldName, field.getName().toString(),
prop.getName()));
prop.setValue(bucket.getKey());
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* This method should be the only one to create {@link ConstraintViolation}.
*
* @since 7.1
*/
private List<ConstraintViolation> validateSimpleTypeField(Schema schema, List<PathNode> path, Field field,
Object value) {
Type type = field.getType();
assert type.isSimpleType() || type.isListType(); // list type to manage ArrayProperty
List<ConstraintViolation> violations = new ArrayList<>();
Set<Constraint> constraints;
if (type.isListType()) { // ArrayProperty
constraints = ((ListType) type).getFieldType().getConstraints();
} else {
constraints = field.getConstraints();
}
for (Constraint constraint : constraints) {
if (!constraint.validate(value)) {
ConstraintViolation violation = new ConstraintViolation(schema, path, constraint, value);
violations.add(violation);
}
}
return violations;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-ldap
Type type = field.getType();
if (type instanceof SimpleTypeImpl) {
Object defaultValue = field.getDefaultValue();
String typeName = type.getName();
if (attribute == null) {
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql
/**
* Gets the column type from a Nuxeo Schema field, including its constrained length if any.
*/
public static ColumnType fromField(Field field) {
return fromFieldType(field.getType(), field.getMaxLength());
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
protected Serializable getDefaultValue() {
Serializable value = (Serializable) field.getDefaultValue();
if (value == null) {
value = new ArrayList<Serializable>();
}
return value;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public DocumentValidationReport validate(Field field, Object value, boolean validateSubProperties) {
Schema schema = field.getDeclaringType().getSchema();
return new DocumentValidationReport(validate(schema, field, value, validateSubProperties));
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-schema
LengthConstraint lc = ConstraintUtils.getConstraint(field.getConstraints(), LengthConstraint.class);
if (lc != null && lc.getMax() != null) {
field.setMaxLength(lc.getMax().intValue());
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Type getType() {
return field.getType();
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-mongodb
Field field = entry.getValue();
if (field != null) {
String fieldName = field.getName().getPrefixedName();
Object value = newDocMap.get(fieldName);
Type type = field.getType();
if (value instanceof String) {
String v = (String) value;
Object defaultValue = field.getDefaultValue();
if (defaultValue != null) {
newDocMap.put(fieldName, defaultValue);
内容来源于网络,如有侵权,请联系作者删除!