@Override public String getName() { return field.getName().getPrefixedName(); }
@Override public String getName() { return field.getName().getPrefixedName(); }
@Override public String getName() { return field.getName().getPrefixedName(); }
public final Property getNonPhantomChild(Field field) { String name = field.getName().getPrefixedName(); Property property = children.get(name); if (property == null) { property = internalGetChild(field); if (property == null) { return null; } children.put(name, property); } return property; }
protected String getName(Property property) { QName name = property.getField().getName(); return prefixed ? name.getPrefixedName() : name.getLocalName(); }
pathTokens.add(schema.getName()); for (PathNode node : path) { String name = node.getField().getName().getLocalName(); pathTokens.add(name);
/** * 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; }
int index = Integer.parseInt(xpathToken); path.add(new PathNode(field, index)); } else if (xpathToken.equals(itemField.getName().getLocalName())) {
/** * Finds strings from the document for a given set of included and excluded paths. * <p> * Paths must be specified with a schema prefix in all cases (normalized). * * @param document the document * @param includedPaths the paths to include, or {@code null} for all paths * @param excludedPaths the paths to exclude, or {@code null} for none * @return a list of strings (each string is never {@code null}) */ public List<String> findStrings(DocumentModel document, Set<String> includedPaths, Set<String> excludedPaths) { this.document = document; this.includedPaths = includedPaths; this.excludedPaths = excludedPaths; strings = new ArrayList<>(); for (String schema : document.getSchemas()) { for (Property property : document.getPropertyObjects(schema)) { String path = property.getField().getName().getPrefixedName(); if (!path.contains(":")) { // add schema name as prefix if the schema doesn't have a prefix path = property.getSchema().getName() + ":" + path; } findStrings(property, path); } } return strings; }
@Override public DocumentValidationReport validate(DocumentModel document, boolean dirtyOnly) { List<ConstraintViolation> violations = new ArrayList<>(); DocumentType docType = document.getDocumentType(); if (dirtyOnly) { for (DataModel dataModel : document.getDataModels().values()) { Schema schemaDef = getSchemaManager().getSchema(dataModel.getSchema()); for (String fieldName : dataModel.getDirtyFields()) { Field field = schemaDef.getField(fieldName); Property property = document.getProperty(field.getName().getPrefixedName()); List<PathNode> path = singletonList(new PathNode(property.getField())); violations.addAll(validateAnyTypeProperty(property.getSchema(), path, property, true, true)); } } } else { for (Schema schema : docType.getSchemas()) { for (Field field : schema.getFields()) { Property property = document.getProperty(field.getName().getPrefixedName()); List<PathNode> path = singletonList(new PathNode(property.getField())); violations.addAll(validateAnyTypeProperty(property.getSchema(), path, property, false, true)); } } } return new DocumentValidationReport(violations); }
String pp = p.getField().getName().getPrefixedName(); findStrings(p, path + '/' + pp);
public static DataModel cloneDataModel(Schema schema, DataModel data) { DataModel dm = new DataModelImpl(schema.getName()); for (Field field : schema.getFields()) { String key = field.getName().getLocalName(); Object value; try { value = data.getData(key); } catch (PropertyException e1) { continue; } if (value == null) { continue; } Object clone = cloneField(field, key, value); dm.setData(key, clone); } return dm; }
protected boolean compatibleTypes(Type targetType, Type sourceType) { if (!sourceType.getName().equals(targetType.getName())) { return false; } if (sourceType.isComplexType()) { for (Field field : ((ComplexType) sourceType).getFields()) { Field targetField = ((ComplexType) targetType).getField(field.getName()); if (targetField == null || !field.getType().equals(targetField.getType())) { return false; } } } if (sourceType.isListType()) { if (!((ListType) sourceType).getFieldType().equals(((ListType) targetType).getFieldType())) { return false; } if (((ListType) sourceType).getFieldType().isComplexType()) { return compatibleTypes(((ListType) targetType).getFieldType(), ((ListType) sourceType).getFieldType()); } } return true; } }
protected void findBlobPaths(ComplexType complexType, String path, Schema schema, List<String> paths) { for (Field field : complexType.getFields()) { String fieldPath = field.getName().getPrefixedName(); if (path == null) {
protected void addField(Field field) { QName name = field.getName(); fields.put(name, field); fieldsByName.put(name.getLocalName(), field); fieldsByName.put(name.getPrefixedName(), field); }
protected String getPrefixedIdField() { Field idField = directory.getSchemaFieldMap().get(getIdField()); if (idField == null) { return null; } return idField.getName().getPrefixedName(); }
@Override public DocumentModel getEntryFromSource(String id, boolean fetchReferences) { String idFieldName = directory.getSchemaFieldMap().get(getIdField()).getName().getPrefixedName(); DocumentModelList result = query(Collections.singletonMap(idFieldName, id), Collections.emptySet(), Collections.emptyMap(), true); return result.isEmpty() ? null : result.get(0); }
protected void walkComplexType(ComplexType complexType, String path, String addPrefix) { for (Field field : complexType.getFields()) { String name = field.getName().getPrefixedName(); String fieldPath = path == null ? name : path + '/' + name; walkType(field.getType(), fieldPath, addPrefix); } }
@Override protected FieldInfo walkReference(String name) { Field field = directory.getSchemaFieldMap().get(name); if (field == null) { throw new QueryParseException("No column: " + name + " for directory: " + getDirectory().getName()); } String key = field.getName().getPrefixedName(); String queryField = stripElemMatchPrefix(key); return new FieldInfo(name, queryField, key, field.getType(), false); }