Search in sources :

Example 1 with SchemaMethodParameter

use of org.structr.core.entity.SchemaMethodParameter in project structr by structr.

the class StructrMethodDefinition method deserialize.

void deserialize(final SchemaMethod method) {
    setName(method.getName());
    setSource(method.getProperty(SchemaMethod.source));
    setComment(method.getProperty(SchemaMethod.comment));
    setCodeType(method.getProperty(SchemaMethod.codeType));
    setReturnType(method.getProperty(SchemaMethod.returnType));
    setCallSuper(method.getProperty(SchemaMethod.callSuper));
    setOverridesExisting(method.getProperty(SchemaMethod.overridesExisting));
    setDoExport(method.getProperty(SchemaMethod.doExport));
    final String[] exceptionArray = method.getProperty(SchemaMethod.exceptions);
    if (exceptionArray != null) {
        for (final String fqcn : exceptionArray) {
            addException(fqcn);
        }
    }
    for (final SchemaMethodParameter param : method.getProperty(SchemaMethod.parameters)) {
        final StructrParameterDefinition parameter = StructrParameterDefinition.deserialize(this, param);
        if (parameter != null) {
            parameters.add(parameter);
        }
    }
}
Also used : SchemaMethodParameter(org.structr.core.entity.SchemaMethodParameter)

Example 2 with SchemaMethodParameter

use of org.structr.core.entity.SchemaMethodParameter in project structr by structr.

the class StructrParameterDefinition method createDatabaseSchema.

// ----- package methods -----
SchemaMethodParameter createDatabaseSchema(final App app, final SchemaMethod schemaMethod, final int index) throws FrameworkException {
    final PropertyMap getOrCreateProperties = new PropertyMap();
    final PropertyMap updateProperties = new PropertyMap();
    getOrCreateProperties.put(SchemaMethodParameter.name, getName());
    getOrCreateProperties.put(SchemaMethodParameter.schemaMethod, schemaMethod);
    SchemaMethodParameter parameter = app.nodeQuery(SchemaMethodParameter.class).and(getOrCreateProperties).getFirst();
    if (parameter == null) {
        parameter = app.create(SchemaMethodParameter.class, getOrCreateProperties);
    }
    updateProperties.put(SchemaMethodParameter.parameterType, type);
    updateProperties.put(SchemaMethodParameter.index, index);
    // update properties
    parameter.setProperties(SecurityContext.getSuperUserInstance(), updateProperties);
    // return modified property
    return parameter;
}
Also used : PropertyMap(org.structr.core.property.PropertyMap) SchemaMethodParameter(org.structr.core.entity.SchemaMethodParameter)

Example 3 with SchemaMethodParameter

use of org.structr.core.entity.SchemaMethodParameter in project structr by structr.

the class StructrSchema method replaceDatabaseSchema.

/**
 * Replaces the current Structr schema with the given new schema. This
 * method is the reverse of createFromDatabase above.
 *
 * @param app
 * @param newSchema the new schema to replace the current Structr schema
 *
 * @throws FrameworkException
 * @throws URISyntaxException
 */
public static void replaceDatabaseSchema(final App app, final JsonSchema newSchema) throws FrameworkException, URISyntaxException {
    Services.getInstance().setOverridingSchemaTypesAllowed(true);
    try (final Tx tx = app.tx()) {
        for (final SchemaRelationshipNode schemaRelationship : app.nodeQuery(SchemaRelationshipNode.class).getAsList()) {
            app.delete(schemaRelationship);
        }
        for (final SchemaNode schemaNode : app.nodeQuery(SchemaNode.class).getAsList()) {
            app.delete(schemaNode);
        }
        for (final SchemaMethod schemaMethod : app.nodeQuery(SchemaMethod.class).getAsList()) {
            app.delete(schemaMethod);
        }
        for (final SchemaMethodParameter schemaMethodParameter : app.nodeQuery(SchemaMethodParameter.class).getAsList()) {
            app.delete(schemaMethodParameter);
        }
        for (final SchemaProperty schemaProperty : app.nodeQuery(SchemaProperty.class).getAsList()) {
            app.delete(schemaProperty);
        }
        for (final SchemaView schemaView : app.nodeQuery(SchemaView.class).getAsList()) {
            app.delete(schemaView);
        }
        newSchema.createDatabaseSchema(app, JsonSchema.ImportMode.replace);
        tx.success();
    }
}
Also used : SchemaView(org.structr.core.entity.SchemaView) SchemaNode(org.structr.core.entity.SchemaNode) SchemaProperty(org.structr.core.entity.SchemaProperty) Tx(org.structr.core.graph.Tx) SchemaMethod(org.structr.core.entity.SchemaMethod) SchemaRelationshipNode(org.structr.core.entity.SchemaRelationshipNode) SchemaMethodParameter(org.structr.core.entity.SchemaMethodParameter)

Aggregations

SchemaMethodParameter (org.structr.core.entity.SchemaMethodParameter)3 SchemaMethod (org.structr.core.entity.SchemaMethod)1 SchemaNode (org.structr.core.entity.SchemaNode)1 SchemaProperty (org.structr.core.entity.SchemaProperty)1 SchemaRelationshipNode (org.structr.core.entity.SchemaRelationshipNode)1 SchemaView (org.structr.core.entity.SchemaView)1 Tx (org.structr.core.graph.Tx)1 PropertyMap (org.structr.core.property.PropertyMap)1