Search in sources :

Example 16 with SchemaProperty

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");
                    }
                }
            }
        }
    }
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaNode(org.structr.core.entity.SchemaNode) SchemaProperty(org.structr.core.entity.SchemaProperty) InvalidPropertySchemaToken(org.structr.common.error.InvalidPropertySchemaToken)

Example 17 with SchemaProperty

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;
}
Also used : SchemaProperty(org.structr.core.entity.SchemaProperty)

Example 18 with SchemaProperty

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;
}
Also used : SchemaProperty(org.structr.core.entity.SchemaProperty)

Example 19 with SchemaProperty

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;
}
Also used : SchemaProperty(org.structr.core.entity.SchemaProperty) PropertyMap(org.structr.core.property.PropertyMap)

Example 20 with SchemaProperty

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;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) SchemaProperty(org.structr.core.entity.SchemaProperty) JsonSchema(org.structr.schema.json.JsonSchema)

Aggregations

SchemaProperty (org.structr.core.entity.SchemaProperty)34 PropertyMap (org.structr.core.property.PropertyMap)23 FrameworkException (org.structr.common.error.FrameworkException)7 SchemaNode (org.structr.core.entity.SchemaNode)7 Tx (org.structr.core.graph.Tx)7 LinkedList (java.util.LinkedList)5 App (org.structr.core.app.App)5 StructrApp (org.structr.core.app.StructrApp)5 Test (org.junit.Test)4 SchemaMethod (org.structr.core.entity.SchemaMethod)4 SchemaView (org.structr.core.entity.SchemaView)4 AbstractSchemaNode (org.structr.core.entity.AbstractSchemaNode)3 FrontendTest (org.structr.web.basic.FrontendTest)3 ResourceAccessTest (org.structr.web.basic.ResourceAccessTest)3 LinkedHashSet (java.util.LinkedHashSet)2 TreeSet (java.util.TreeSet)2 PropertyContainer (org.structr.api.graph.PropertyContainer)2 NodeAttribute (org.structr.core.graph.NodeAttribute)2 StructrPath (org.structr.files.ssh.filesystem.StructrPath)2 URI (java.net.URI)1