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);
}
}
}
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;
}
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();
}
}
Aggregations