Search in sources :

Example 1 with UnsupportedFeatureError

use of org.drools.modelcompiler.builder.errors.UnsupportedFeatureError in project drools by kiegroup.

the class ModelBuilderImpl method processTypeDeclarationDescr.

private void processTypeDeclarationDescr(InternalKnowledgePackage pkg, AbstractClassTypeDeclarationDescr typeDescr) {
    normalizeAnnotations(typeDescr, pkg.getTypeResolver(), false);
    try {
        Class<?> typeClass = pkg.getTypeResolver().resolveType(typeDescr.getTypeName());
        String typePkg = typeClass.getPackage().getName();
        String typeName = typeClass.getName().substring(typePkg.length() + 1);
        TypeDeclaration type = new TypeDeclaration(typeName);
        type.setTypeClass(typeClass);
        type.setResource(typeDescr.getResource());
        if (hasMvel()) {
            type.setTypeClassDef(createClassDefinition(typeClass, typeDescr.getResource()));
        }
        TypeDeclarationFactory.processAnnotations(typeDescr, type);
        if (!type.isTypesafe()) {
            addBuilderResult(new UnsupportedFeatureError("@typesafe(false) is not supported in executable model : " + type));
        }
        getOrCreatePackageRegistry(new PackageDescr(typePkg)).getPackage().addTypeDeclaration(type);
    } catch (ClassNotFoundException e) {
        TypeDeclaration type = new TypeDeclaration(typeDescr.getTypeName());
        type.setResource(typeDescr.getResource());
        TypeDeclarationFactory.processAnnotations(typeDescr, type);
        pkg.addTypeDeclaration(type);
    }
}
Also used : UnsupportedFeatureError(org.drools.modelcompiler.builder.errors.UnsupportedFeatureError) PackageDescr(org.drools.drl.ast.descr.PackageDescr) CompositePackageDescr(org.drools.compiler.lang.descr.CompositePackageDescr) TypeDeclaration(org.drools.core.rule.TypeDeclaration)

Aggregations

CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)1 TypeDeclaration (org.drools.core.rule.TypeDeclaration)1 PackageDescr (org.drools.drl.ast.descr.PackageDescr)1 UnsupportedFeatureError (org.drools.modelcompiler.builder.errors.UnsupportedFeatureError)1