Search in sources :

Example 1 with PropertyDefinition

use of org.structr.schema.parser.PropertyDefinition in project structr by structr.

the class SchemaHelper method getSourceGenerator.

// ----- private methods -----
private static PropertySourceGenerator getSourceGenerator(final ErrorBuffer errorBuffer, final String className, final PropertyDefinition propertyDefinition) throws FrameworkException {
    final String propertyName = propertyDefinition.getPropertyName();
    final Type propertyType = propertyDefinition.getPropertyType();
    final Class<? extends PropertySourceGenerator> parserClass = parserMap.get(propertyType);
    try {
        return parserClass.getConstructor(ErrorBuffer.class, String.class, PropertyDefinition.class).newInstance(errorBuffer, className, propertyDefinition);
    } catch (Throwable t) {
        logger.warn("", t);
    }
    errorBuffer.add(new InvalidPropertySchemaToken(SchemaProperty.class.getSimpleName(), propertyName, propertyName, "invalid_property_definition", "Unknow value type " + source + ", options are " + Arrays.asList(Type.values()) + "."));
    throw new FrameworkException(422, "Invalid property definition for property " + propertyDefinition.getPropertyName(), errorBuffer);
}
Also used : GraphQLScalarType(graphql.schema.GraphQLScalarType) GraphQLOutputType(graphql.schema.GraphQLOutputType) ErrorBuffer(org.structr.common.error.ErrorBuffer) FrameworkException(org.structr.common.error.FrameworkException) InvalidPropertySchemaToken(org.structr.common.error.InvalidPropertySchemaToken) StringBasedPropertyDefinition(org.structr.schema.parser.StringBasedPropertyDefinition) PropertyDefinition(org.structr.schema.parser.PropertyDefinition)

Aggregations

GraphQLOutputType (graphql.schema.GraphQLOutputType)1 GraphQLScalarType (graphql.schema.GraphQLScalarType)1 ErrorBuffer (org.structr.common.error.ErrorBuffer)1 FrameworkException (org.structr.common.error.FrameworkException)1 InvalidPropertySchemaToken (org.structr.common.error.InvalidPropertySchemaToken)1 PropertyDefinition (org.structr.schema.parser.PropertyDefinition)1 StringBasedPropertyDefinition (org.structr.schema.parser.StringBasedPropertyDefinition)1