use of org.structr.core.entity.SchemaProperty in project structr by structr.
the class ExtendNotionPropertyWithUuid method handleMigration.
@Override
public void handleMigration(final ErrorToken errorToken) throws FrameworkException {
final Object messageObject = errorToken.getDetail();
if (messageObject != null) {
final String message = (String) messageObject;
if (message.startsWith("Invalid notion property expression for property ") && message.endsWith(".")) {
if (errorToken instanceof InvalidPropertySchemaToken) {
final App app = StructrApp.getInstance();
final InvalidPropertySchemaToken token = (InvalidPropertySchemaToken) errorToken;
final String typeName = token.getType();
final String propertyName = token.getProperty();
final SchemaNode type = app.nodeQuery(SchemaNode.class).andName(typeName).getFirst();
if (type != null) {
final SchemaProperty property = app.nodeQuery(SchemaProperty.class).and(SchemaProperty.schemaNode, type).and(SchemaProperty.name, propertyName).getFirst();
if (property != null) {
// load format property
final String format = property.getProperty(SchemaProperty.format);
// store corrected version of format property
property.setProperty(SchemaProperty.format, format + ", id");
}
}
}
}
}
}
use of org.structr.core.entity.SchemaProperty in project structr by structr.
the class StructrBooleanArrayProperty method createDatabaseSchema.
@Override
SchemaProperty createDatabaseSchema(final App app, final AbstractSchemaNode schemaNode) throws FrameworkException {
final SchemaProperty property = super.createDatabaseSchema(app, schemaNode);
property.setProperty(SchemaProperty.propertyType, Type.BooleanArray.name());
return property;
}
use of org.structr.core.entity.SchemaProperty in project structr by structr.
the class StructrBooleanProperty method createDatabaseSchema.
@Override
SchemaProperty createDatabaseSchema(final App app, final AbstractSchemaNode schemaNode) throws FrameworkException {
final SchemaProperty property = super.createDatabaseSchema(app, schemaNode);
property.setProperty(SchemaProperty.propertyType, Type.Boolean.name());
return property;
}
use of org.structr.core.entity.SchemaProperty in project structr by structr.
the class StructrNumberArrayProperty method createDatabaseSchema.
@Override
SchemaProperty createDatabaseSchema(final App app, final AbstractSchemaNode schemaNode) throws FrameworkException {
final SchemaProperty property = super.createDatabaseSchema(app, schemaNode);
final PropertyMap properties = new PropertyMap();
properties.put(SchemaProperty.propertyType, Type.DoubleArray.name());
if (minimum != null && maximum != null) {
final StringBuilder range = new StringBuilder();
if (exclusiveMinimum) {
range.append("]");
} else {
range.append("[");
}
range.append(minimum);
range.append(",");
range.append(maximum);
if (exclusiveMaximum) {
range.append("[");
} else {
range.append("]");
}
properties.put(SchemaProperty.format, range.toString());
}
property.setProperties(SecurityContext.getSuperUserInstance(), properties);
return property;
}
use of org.structr.core.entity.SchemaProperty in project structr by structr.
the class StructrPropertyDefinition method createDatabaseSchema.
// ----- package methods -----
SchemaProperty createDatabaseSchema(final App app, final AbstractSchemaNode schemaNode) throws FrameworkException {
final PropertyMap getOrCreateProperties = new PropertyMap();
final PropertyMap updateProperties = new PropertyMap();
getOrCreateProperties.put(SchemaProperty.name, getName());
getOrCreateProperties.put(SchemaProperty.schemaNode, schemaNode);
SchemaProperty property = app.nodeQuery(SchemaProperty.class).and(getOrCreateProperties).getFirst();
if (property == null) {
getOrCreateProperties.put(SchemaProperty.compound, isCompoundUnique());
getOrCreateProperties.put(SchemaProperty.unique, isUnique());
getOrCreateProperties.put(SchemaProperty.indexed, isIndexed());
getOrCreateProperties.put(SchemaProperty.notNull, isRequired());
getOrCreateProperties.put(SchemaProperty.readOnly, isReadOnly());
getOrCreateProperties.put(SchemaProperty.format, getFormat());
getOrCreateProperties.put(SchemaProperty.hint, getHint());
getOrCreateProperties.put(SchemaProperty.category, getCategory());
getOrCreateProperties.put(SchemaProperty.validators, validators.toArray(new String[0]));
getOrCreateProperties.put(SchemaProperty.transformers, transformers.toArray(new String[0]));
getOrCreateProperties.put(SchemaProperty.defaultValue, defaultValue);
property = app.create(SchemaProperty.class, getOrCreateProperties);
}
if (parent != null) {
final JsonSchema root = parent.getSchema();
if (root != null) {
if (SchemaService.DynamicSchemaRootURI.equals(root.getId())) {
updateProperties.put(SchemaProperty.isPartOfBuiltInSchema, true);
}
}
}
// update properties
property.setProperties(SecurityContext.getSuperUserInstance(), updateProperties);
// return modified property
return property;
}
Aggregations