use of org.structr.core.property.PropertyKey in project structr by structr.
the class AbstractNode method evaluate.
@Override
public final Object evaluate(final ActionContext actionContext, final String key, final String defaultValue) throws FrameworkException {
switch(key) {
case "owner":
return getOwnerNode();
case "_path":
if (rawPathSegment != null) {
return new RelationshipFactory<>(actionContext.getSecurityContext()).adapt(rawPathSegment);
} else {
return null;
}
default:
// evaluate object value or return default
final PropertyKey propertyKey = StructrApp.getConfiguration().getPropertyKeyForJSONName(entityType, key, false);
if (propertyKey != null) {
final Object value = getProperty(propertyKey, actionContext.getPredicate());
if (value != null) {
return value;
}
}
final Object value = invokeMethod(key, Collections.EMPTY_MAP, false);
if (value != null) {
return value;
}
return Function.numberOrString(defaultValue);
}
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class AbstractRelationship method getDynamicProperties.
public PropertyMap getDynamicProperties() {
final PropertyMap propertyMap = new PropertyMap();
final Class type = getClass();
for (final PropertyKey key : StructrApp.getConfiguration().getPropertySet(type, PropertyView.All)) {
// include all dynamic keys in definition
if (key.isDynamic() || key.isCMISProperty()) {
// only include primitives here
final PropertyType dataType = key.getDataType();
if (dataType != null) {
propertyMap.put(key, getProperty(key));
}
}
}
return propertyMap;
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class SchemaNode method getPropertyKeys.
@Override
public Set<PropertyKey> getPropertyKeys(final String propertyView) {
final List<PropertyKey> propertyKeys = new LinkedList<>(Iterables.toList(super.getPropertyKeys(propertyView)));
// add "custom" property keys as String properties
for (final String key : SchemaHelper.getProperties(getNode())) {
final PropertyKey newKey = new StringProperty(key);
newKey.setDeclaringClass(getClass());
propertyKeys.add(newKey);
}
Collections.sort(propertyKeys, (o1, o2) -> {
return o1.jsonName().compareTo(o2.jsonName());
});
return new LinkedHashSet<>(propertyKeys);
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class SchemaNode method getRelatedType.
@Override
public String getRelatedType(final String propertyNameToCheck) {
String relatedType = getRelatedType(this, propertyNameToCheck);
if (relatedType == null) {
try {
final String parentClass = getProperty(SchemaNode.extendsClass);
if (parentClass != null) {
// check if property is defined in parent class
final SchemaNode parentSchemaNode = StructrApp.getInstance().nodeQuery(SchemaNode.class).andName(StringUtils.substringAfterLast(parentClass, ".")).getFirst();
if (parentSchemaNode != null) {
relatedType = getRelatedType(parentSchemaNode, propertyNameToCheck);
}
}
} catch (FrameworkException ex) {
logger.warn("Can't find schema node for parent class!", ex);
}
}
if (relatedType != null) {
return relatedType;
}
// fallback, search NodeInterface (this allows the owner relationship to be used in Notions!)
final PropertyKey key = StructrApp.getConfiguration().getPropertyKeyForJSONName(NodeInterface.class, propertyNameToCheck, false);
if (key != null) {
final Class relatedTypeClass = key.relatedType();
if (relatedTypeClass != null) {
return relatedTypeClass.getSimpleName();
}
}
return null;
}
use of org.structr.core.property.PropertyKey in project structr by structr.
the class SchemaRelationshipNode method getPropertyKeys.
@Override
public Set<PropertyKey> getPropertyKeys(final String propertyView) {
final Set<PropertyKey> propertyKeys = new LinkedHashSet<>(Iterables.toList(super.getPropertyKeys(propertyView)));
// add "custom" property keys as String properties
for (final String key : SchemaHelper.getProperties(getNode())) {
final PropertyKey newKey = new StringProperty(key);
newKey.setDeclaringClass(getClass());
propertyKeys.add(newKey);
}
return propertyKeys;
}
Aggregations