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

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

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

Property.getType介绍

[英]Get the type of the field corresponding to this property.
[中]获取与此属性对应的字段的类型。

代码示例

代码示例来源: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.core/nuxeo-core-api

@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();
}

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

/**
 * Gets the {@link Schema} at the top-level of the type hierarchy for this {@link Property}.
 *
 * @since 9.3
 */
protected Schema getTopLevelSchema(Property property) {
  for (;;) {
    Type type = property.getType();
    if (type instanceof Schema) {
      return (Schema) type;
    }
    property = property.getParent();
  }
}

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

private void fillScalarProperty(Property property, JsonNode jn) throws IOException {
  if ((property instanceof ArrayProperty) && jn.isArray()) {
    List<Object> values = new ArrayList<>();
    Iterator<JsonNode> it = jn.elements();
    JsonNode item;
    Type fieldType = ((ListType) property.getType()).getFieldType();
    while (it.hasNext()) {
      item = it.next();
      values.add(getScalarPropertyValue(property, item, fieldType));
    }
    property.setValue(castArrayPropertyValue(((SimpleType) fieldType).getPrimitiveType(), values));
  } else {
    property.setValue(getScalarPropertyValue(property, jn, property.getType()));
  }
}

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

private void fillListProperty(Property property, JsonNode jn) throws IOException {
  ListType listType = (ListType) property.getType();
  if (property instanceof ArrayProperty) {
    fillScalarProperty(property, jn);
  } else {
    JsonNode elNode;
    Iterator<JsonNode> it = jn.elements();
    while (it.hasNext()) {
      elNode = it.next();
      Property child = readProperty(property, listType.getField(), elNode);
      property.addValue(child.getValue());
    }
  }
}

代码示例来源: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-storage-sql

@Override
protected List<Node> updateList(Node node, String name, Property property) throws PropertyException {
  Collection<Property> properties = property.getChildren();
  List<Node> childNodes = getChildAsList(node, name);
  int oldSize = childNodes.size();
  int newSize = properties.size();
  // remove extra list elements
  if (oldSize > newSize) {
    for (int i = oldSize - 1; i >= newSize; i--) {
      session.removeProperty(childNodes.remove(i));
    }
  }
  // add new list elements
  if (oldSize < newSize) {
    String typeName = ((ListType) property.getType()).getFieldType().getName();
    for (int i = oldSize; i < newSize; i++) {
      Node childNode = session.addChildProperty(node, name, Long.valueOf(i), typeName);
      childNodes.add(childNode);
    }
  }
  return childNodes;
}

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

protected void writeScalarProperty(JsonGenerator jg, Property prop, PropertyConsumer fieldNameWriter)
    throws PropertyException, IOException {
  Type type = prop.getType();
  if (type instanceof SimpleType) {
    type = ((SimpleType) type).getPrimitiveType();

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

@OperationMethod(collector = DocumentModelCollector.class)
public DocumentModel run(DocumentModel doc) throws OperationException {
  Property p = doc.getProperty(xpath);
  Type type = p.getType();
  checkFieldType(type, value);
  List<Serializable> array = Arrays.asList((Serializable[]) p.getValue());
  if (array == null) {
    log.info(String.format("Value \"%s\" not found in %s, can't remove it", value, doc.getPathAsString()));
    return doc;
  }
  List<Serializable> list = new ArrayList<Serializable>(array);
  if (!list.contains(value)) {
    log.info(String.format("Value \"%s\" not found in %s, can't remove it", value, doc.getPathAsString()));
    return doc;
  }
  do {
    list.remove(value);
    p.setValue(list);
  } while (list.contains(value) && isRemoveAll);
  if (save) {
    doc = session.saveDocument(doc);
    session.save();
  }
  return doc;
}

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

protected void writeListProperty(JsonGenerator jg, Property prop, PropertyConsumer fieldNameWriter)
    throws PropertyException, IOException {
  // test if array/list is empty - don't write empty case
  if (!writeEmpty && (prop == null || (prop instanceof ArrayProperty && prop.getValue() == null)
      || (prop instanceof ListProperty && prop.getChildren().isEmpty()))) {
    return;
  }
  fieldNameWriter.accept(jg, prop);
  jg.writeStartArray();
  if (prop instanceof ArrayProperty) {
    Object[] ar = (Object[]) prop.getValue();
    if (ar == null) {
      jg.writeEndArray();
      return;
    }
    Type type = ((ListType) prop.getType()).getFieldType();
    for (Object o : ar) {
      jg.writeString(type.encode(o));
    }
  } else {
    for (Property p : prop.getChildren()) {
      // it's a list of complex object, don't write field names
      writeProperty(jg, p, PropertyConsumer.nothing());
    }
  }
  jg.writeEndArray();
}

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

p.setValue(ar);
} else {
  Type elType = ((ListType) p.getType()).getFieldType();
  if (elType.isSimpleType()) {
    p.setValue(ar);

代码示例来源: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

if (input.getType().isListType()) {
  Collection<Object> objects;
  if (((ListType) input.getType()).isArray()) {
    objects = Arrays.asList((Object[]) input.getValue());
  } else {

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

ListType t = (ListType) prop.getType();
t.getField();
prop = PropertyFactory.createProperty(part, t.getField(), Property.NONE);

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

@OperationMethod(collector = DocumentModelCollector.class)
public DocumentModel run(DocumentModel doc) throws OperationException {
  Property p = doc.getProperty(xpath);
  Type type = p.getType();
  checkFieldType(type, value);
  List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null;
  Serializable newValue = addValueIntoList(array, value);
  p.setValue(newValue);
  if (save) {
    doc = session.saveDocument(doc);
    session.save();
  }
  return doc;
}

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

return TemplateModel.NOTHING;
if (property.getType() == DateType.INSTANCE) {
  return new SimpleDate(((Calendar) value).getTime(), TemplateDateModel.DATETIME);

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

changed = true;
Type type = property.getType();
if (type.isSimpleType()) {

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

Type pType = property.getType();
if (pType.getName().equals(BooleanType.ID)) {
  context.put(param.getName(), new Boolean(false));

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

Type type = property.getType();
boolean equals;
if (type.isSimpleType()) {

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

String name = property.getField().getName().getPrefixedName();
name = internalName(name);
Type type = property.getType();
if (type.isSimpleType()) {

相关文章