org.nuxeo.ecm.core.api.model.Property.getXPath()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中org.nuxeo.ecm.core.api.model.Property.getXPath()方法的一些代码示例,展示了Property.getXPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getXPath()方法的具体详情如下:
包路径:org.nuxeo.ecm.core.api.model.Property
类名称:Property
方法名:getXPath

Property.getXPath介绍

[英]Gets the xpath of this property.

The xpath is of the form pref:foo/mylist/123/elem, of note:

  • there is no initial /
  • the schema prefix is only present if a prefix is configured for the base property's schema
  • list elements indexes start at 0
  • list elements aren't using the old syntax foo/bar[123]/baz but the new syntax foo/123/baz
    [中]获取此属性的xpath。
    xpath的格式为pref:foo/mylist/123/elem,值得注意的是:
    *没有首字母/
    *仅当为基本属性的架构配置了前缀时,架构前缀才存在
    *列表元素索引从0开始
    *列表元素使用的不是旧语法foo/bar[123]/baz,而是新语法foo/123/baz

代码示例

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

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. ");
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public void internalSetValue(Serializable value) throws PropertyException {
  StringBuilder msg = newRemovedMessage();
  if (fallback == null) {
    msg.append("Do nothing");
  } else {
    msg.append("Set value to fallback property '").append(fallback.getXPath()).append("'");
  }
  if (log.isTraceEnabled()) {
    log.error(msg, new NuxeoException("debug stack trace"));
  } else {
    log.error(msg);
  }
  if (fallback != null) {
    fallback.setValue(value);
  }
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

/**
 * 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;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public Serializable internalGetValue() throws PropertyException {
  StringBuilder msg = newRemovedMessage();
  if (fallback == null) {
    msg.append("Return null");
  } else {
    msg.append("Return value from '").append(fallback.getXPath()).append("'");
  }
  if (log.isTraceEnabled()) {
    log.error(msg, new NuxeoException());
  } else {
    log.error(msg);
  }
  if (fallback == null) {
    return null;
  }
  return fallback.getValue();
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

/**
 * @return the fallback value if this property is deprecated and has a fallback, otherwise return null
 */
protected Serializable getValueDeprecation() {
  if (isDeprecated()) {
    // Check if we need to log deprecation message
    if (log.isWarnEnabled()) {
      StringBuilder msg = newDeprecatedMessage();
      if (deprecatedFallback == null) {
        msg.append("Return value from deprecated property");
      } else {
        msg.append("Return value from '").append(deprecatedFallback.getXPath()).append(
            "' if not null, from deprecated property otherwise");
      }
      if (log.isTraceEnabled()) {
        log.warn(msg, new NuxeoException());
      } else {
        log.warn(msg);
      }
    }
    if (deprecatedFallback != null) {
      return deprecatedFallback.getValue();
    }
  }
  return null;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

/**
 * If this property is deprecated and has a fallback, set value to fallback.
 */
protected void setValueDeprecation(Object value, boolean setFallback) throws PropertyException {
  if (isDeprecated()) {
    // First check if we need to set the fallback value
    if (setFallback && deprecatedFallback != null) {
      deprecatedFallback.setValue(value);
    }
    // Second check if we need to log deprecation message
    if (log.isWarnEnabled()) {
      StringBuilder msg = newDeprecatedMessage();
      msg.append("Set value to deprecated property");
      if (deprecatedFallback != null) {
        msg.append(" and to fallback property '").append(deprecatedFallback.getXPath()).append("'");
      }
      if (log.isTraceEnabled()) {
        log.warn(msg, new NuxeoException("debug stack trace"));
      } else {
        log.warn(msg);
      }
    }
  }
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public void mapProperties(CoreSession session, DocumentModel sourceDoc, DocumentModel targetDoc, String mapping)
    {
  Map<String, String> properties = getMapping(mapping);
  for (String keyProp : properties.keySet()) {
    // verify that mapping can be done
    Property sourceProperty = sourceDoc.getProperty(keyProp);
    Property targetProperty = targetDoc.getProperty(properties.get(keyProp));
    Type sourceType = sourceProperty.getType();
    Type targetType = targetProperty.getType();
    if (!compatibleTypes(targetType, sourceType)) {
      throw new NuxeoException(
          String.format("Invalid mapping. Cannot map %s on type %s ", sourceType, targetType));
    }
    targetDoc.setPropertyValue(targetProperty.getXPath(), sourceProperty.getValue());
  }
  session.saveDocument(targetDoc);
}

代码示例来源:origin: org.nuxeo.ecm.automation/nuxeo-automation-core

/**
 * Gets the full URL of where a blob can be downloaded.
 *
 * @since 5.9.3
 */
private static String getBlobUrl(Property prop, String filesBaseUrl) throws PropertyException {
  StringBuilder blobUrlBuilder = new StringBuilder(filesBaseUrl);
  String xpath = prop.getXPath();
  if (!xpath.contains(":")) {
    // if no prefix, use schema name as prefix:
    xpath = prop.getSchema().getName() + ":" + xpath;
  }
  blobUrlBuilder.append(xpath);
  blobUrlBuilder.append("/");
  String filename = ((Blob) prop.getValue()).getFilename();
  if (filename != null) {
    blobUrlBuilder.append(URIUtils.quoteURIPathComponent(filename, true));
  }
  return blobUrlBuilder.toString();
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

Blob blob = readEntity(Blob.class, Blob.class, jn);
if (blob == null) {
  throw new MarshallingException("Unable to parse the property " + property.getXPath());
throw new MarshallingException("Unable to parse the property " + property.getXPath());
throw new MarshallingException("Property " + property.getXPath()
    + " value cannot be resolved by the matching resolver " + resolver.getName());

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

protected void writeListProperty(JsonGenerator jg, Property prop) throws IOException {
  jg.writeStartArray();
  if (prop instanceof ArrayProperty) {
    Object[] ar = (Object[]) prop.getValue();
    if (ar == null) {
      jg.writeEndArray();
      return;
    }
    Type itemType = ((ListType) prop.getType()).getFieldType();
    ObjectResolver resolver = itemType.getObjectResolver();
    String path = prop.getXPath();
    for (Object o : ar) {
      if (!fetchProperty(jg, resolver, o, path)) {
        writeScalarPropertyValue(jg, ((SimpleType) itemType).getPrimitiveType(), o);
      }
    }
  } else {
    ListProperty listp = (ListProperty) prop;
    for (Property p : listp.getChildren()) {
      writeProperty(jg, p);
    }
  }
  jg.writeEndArray();
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

/**
 * Gets the full URL of where a blob can be downloaded.
 *
 * @since 7.2
 */
private String getBlobUrl(Property prop) {
  DocumentModel doc = ctx.getParameter(ENTITY_TYPE);
  if (doc == null) {
    return "";
  }
  DownloadService downloadService = Framework.getService(DownloadService.class);
  String xpath = prop.getXPath();
  // if no prefix, use schema name as prefix:
  if (!xpath.contains(":")) {
    xpath = prop.getSchema().getName() + ":" + xpath;
  }
  String filename = ((Blob) prop.getValue()).getFilename();
  return ctx.getBaseUrl() + downloadService.getDownloadUrl(doc, xpath, filename);
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-query-api

if (prop.isList()) {
  if (ArrayUtils.isNotEmpty(prop.getValue(Object[].class))) {
    searchFields.add(prop.getXPath());
  searchFields.add(prop.getXPath());

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

protected void writeScalarProperty(JsonGenerator jg, Property prop) throws IOException {
  Type type = prop.getType();
  Object value = prop.getValue();
  if (!fetchProperty(jg, prop.getType().getObjectResolver(), value, prop.getXPath())) {
    writeScalarPropertyValue(jg, ((SimpleType) type).getPrimitiveType(), value);
  }
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core

if (p != null && charsToRemove.matchesAnyOf(p)) {
  String filteredProp = filter(p);
  docModel.setPropertyValue(prop.getXPath(), filteredProp);
    docModel.setPropertyValue(prop.getXPath(), arrayProp);

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

private static void avoidBlobUpdate(Property propToClean, DocumentModel docRef) {
  if (propToClean instanceof BlobProperty) {
    // if the blob used to exist
    if (propToClean.getValue() == null) {
      try {
        Serializable value = docRef.getPropertyValue(propToClean.getXPath());
        propToClean.setValue(value);
      } catch (PropertyNotFoundException e) {
        // As the blob property doesn't exist in the document in the first place, ignore the operation
      }
    }
  } else if (propToClean instanceof ComplexProperty) {
    ComplexProperty complexPropToClean = (ComplexProperty) propToClean;
    for (Field field : complexPropToClean.getType().getFields()) {
      Property childPropToClean = complexPropToClean.get(field.getName().getLocalName());
      avoidBlobUpdate(childPropToClean, docRef);
    }
  } else if (propToClean instanceof ListProperty) {
    ListProperty listPropToClean = (ListProperty) propToClean;
    for (int i = 0; i < listPropToClean.size(); i++) {
      Property elPropToClean = listPropToClean.get(i);
      avoidBlobUpdate(elPropToClean, docRef);
    }
  }
}

相关文章