use of org.structr.common.error.InvalidPropertySchemaToken in project structr by structr.
the class IdNotionPropertyParser method parseFormatString.
@Override
public void parseFormatString(final Schema entity, String expression) throws FrameworkException {
if (StringUtils.isBlank(expression)) {
// reportError(new InvalidPropertySchemaToken(SchemaNode.class.getSimpleName(), expression, "invalid_property_definition", "Empty notion property expression."));
throw new FrameworkException(422, "Empty notion property expression for property " + source.getPropertyName() + ".", new InvalidPropertySchemaToken(SchemaNode.class.getSimpleName(), this.source.getPropertyName(), expression, "invalid_property_definition", "Empty notion property expression."));
}
final StringBuilder buf = new StringBuilder();
final String[] parts = expression.split("[, ]+");
if (parts.length > 0) {
boolean isBuiltinProperty = false;
baseProperty = parts[0];
multiplicity = entity.getMultiplicity(baseProperty);
if (multiplicity != null) {
switch(multiplicity) {
case "1X":
// this line exists because when a NotionProperty is set up for a builtin propery
// (like for example "owner", there must not be the string "Property" appended
// to the property name, and the SchemaNode returns the above "extended" multiplicity
// string when it has detected a fallback property name like "owner" from NodeInterface.
// no break!
isBuiltinProperty = true;
case "1":
propertyType = EntityIdProperty.class.getSimpleName();
break;
case "*X":
// this line exists because when a NotionProperty is set up for a builtin propery
// (like for example "owner", there must not be the string "Property" appended
// to the property name, and the SchemaNode returns the above "extended" multiplicity
// string when it has detected a fallback property name like "owner" from NodeInterface.
// no break!
isBuiltinProperty = true;
case "*":
propertyType = CollectionIdProperty.class.getSimpleName();
break;
default:
break;
}
buf.append(", ");
buf.append(entity.getClassName());
buf.append(".");
buf.append(baseProperty);
// append "Property" only if it is NOT a builtin property!
if (!isBuiltinProperty) {
buf.append("Property");
}
if (parts.length == 3 && "true".equals(parts[2].toLowerCase())) {
isAutocreate = true;
buf.append(", true");
}
} else {
throw new FrameworkException(422, "Invalid notion property expression for property " + source.getPropertyName() + ".", new InvalidPropertySchemaToken(SchemaNode.class.getSimpleName(), this.source.getPropertyName(), expression, "invalid_property_definition", "Invalid notion property expression."));
}
}
parameters = buf.toString();
}
Aggregations