@Override public String getName() { return schema.getName(); }
path = schema.getName() + ":" + path; break;
@Override public String getSchema() { return dp.getSchema().getName(); }
fieldPath = schema.getName() + ":" + fieldPath;
protected StringBuilder newRemovedMessage() { StringBuilder builder = new StringBuilder().append("Property '") .append(getXPath()) .append("' is marked as removed from '") .append(getSchema().getName()) .append("' schema"); RemovedProperty removedParent = getRemovedParent(); if (removedParent != this) { builder.append(" because property '").append(removedParent.getXPath()).append("' is marked as removed"); } return builder.append(", don't use it anymore. "); }
protected void registerSchema(Schema schema) { schemas.put(schema.getName(), schema); Namespace ns = schema.getNamespace(); uriToSchema.put(ns.uri, schema); if (!StringUtils.isBlank(ns.prefix)) { prefixToSchema.put(ns.prefix, schema); } }
protected StringBuilder newDeprecatedMessage() { StringBuilder builder = new StringBuilder().append("Property '") .append(getXPath()) .append("' is marked as deprecated from '") .append(getSchema().getName()) .append("' schema"); Property deprecatedParent = getDeprecatedParent(); if (deprecatedParent != this) { builder.append(" because property '") .append(deprecatedParent.getXPath()) .append("' is marked as deprecated"); } return builder.append(", don't use it anymore. "); }
/** * Gets the full xpath for a property, including schema prefix in all cases. * * @since 9.3 */ protected String getFullXPath(Property property) { String xpath = property.getXPath(); if (xpath.indexOf(':') < 0) { // add schema name as prefix xpath = property.getSchema().getName() + ':' + xpath; } return xpath; }
/** * Obtains the schema name from the full propertyName. * * @throws IllegalArgumentException if the propertyName does not have a schema:field pattern */ public static String getSchemaName(String propertyName) { String[] s = propertyName.split(":"); if (s.length != 2) { throw new IllegalArgumentException("offending value: " + propertyName); } String prefix = s[0]; Schema schema = null; SchemaManager tm = Framework.getService(SchemaManager.class); schema = tm.getSchemaFromPrefix(prefix); if (schema == null) { // fall back on prefix as it may be the schema name return prefix; } else { return schema.getName(); } }
/** * Recomputes effective schemas from a type + instance facets. */ public static Set<String> computeSchemas(DocumentType type, Collection<String> instanceFacets, boolean isProxy) { Set<String> schemas = new HashSet<>(); schemas.addAll(Arrays.asList(type.getSchemaNames())); TypeProvider typeProvider = getSchemaManager(); for (String facet : instanceFacets) { CompositeType facetType = typeProvider.getFacet(facet); if (facetType != null) { // ignore pseudo-facets like Immutable schemas.addAll(Arrays.asList(facetType.getSchemaNames())); } } if (isProxy) { for (Schema schema : typeProvider.getProxySchemas(type.getName())) { schemas.add(schema.getName()); } } return schemas; }
pathTokens.add(Constraint.MESSAGES_KEY); pathTokens.add(constraint.getDescription().getName()); pathTokens.add(schema.getName()); for (PathNode node : path) { String name = node.getField().getName().getLocalName();
@Override public Type getType() { if (fallback == null) { // TODO try to do something better - currently RemovedProperty is always a container if there's no fallback // Simulate a complex type return new ComplexTypeImpl(getSchema(), getSchema().getName(), fieldName); } return fallback.getType(); }
String schema = getSchema().getName();
/** * 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; }
String schema = getSchema().getName(); SchemaManager schemaManager = Framework.getService(SchemaManager.class); PropertyDeprecationHandler deprecatedProperties = schemaManager.getDeprecatedProperties();
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; }
private void logUnsupportedFacetRestriction(Schema schema, String fieldName, SimpleTypeImpl simpleType, String... facetNames) { StringBuilder msg = new StringBuilder(); msg.append("schema|field|type : ").append(schema.getName()); msg.append("|").append(fieldName); msg.append("|").append(simpleType.getPrimitiveType()); msg.append(" following restriction facet are not handled by constraints API for this type :"); for (String facetName : facetNames) { msg.append(facetName).append(" "); } log.warn(msg.toString()); }
private static String getSchemaName(String propertyName) { String[] s = propertyName.split(":"); String prefix = s[0]; SchemaManager tm = Framework.getService(SchemaManager.class); Schema schema = tm.getSchemaFromPrefix(prefix); if (schema == null) { // fall back on prefix as it may be the schema name return prefix; } else { return schema.getName(); } }
private void setStillSchema(Schema schema, DocumentModel doc) { Map<String, Object> data = new HashMap<String, Object>(); Collection<Field> fields = schema.getFields(); Iterator<Field> iterator = fields.iterator(); while(iterator.hasNext()){ Field field = iterator.next(); String name = field.getName().getLocalName(); data.put(name, null); } doc.setProperties(schema.getName(), data); }