Package org.drools.core.rule

Examples of org.drools.core.rule.TypeDeclaration$TimestampAccessorSetter


        boolean isSuperClassDeclared = true; //in the same package, or in a previous one

        if (pack != null) {

            // look for the supertype declaration in available packages
            TypeDeclaration superTypeDeclaration = pack.getTypeDeclaration(simpleSuperTypeName);

            if (superTypeDeclaration != null) {
                ClassDefinition classDef = superTypeDeclaration.getTypeClassDef();
                // inherit fields
                for (FactField fld : classDef.getFields()) {
                    TypeFieldDescr inheritedFlDescr = buildInheritedFieldDescrFromDefinition(fld, typeDescr);
                    fieldMap.put(inheritedFlDescr.getFieldName(),
                            inheritedFlDescr);
                }

                // new classes are already distinguished from tagged external classes
                isSuperClassTagged = !superTypeDeclaration.isNovel();
            } else {
                isSuperClassDeclared = false;
            }

        } else {
View Full Code Here


                    }
                }
            }

            // Go on with the build
            TypeDeclaration type = new TypeDeclaration(typeDescr.getTypeName());
            if (typeDescr.getResource() == null) {
                typeDescr.setResource(resource);
            }
            type.setResource(typeDescr.getResource());

            TypeDeclaration parent = null;
            if (!typeDescr.getSuperTypes().isEmpty()) {
                // parent might have inheritable properties
                PackageRegistry sup = pkgRegistryMap.get(typeDescr.getSuperTypeNamespace());
                if (sup != null) {
                    parent = sup.getPackage().getTypeDeclaration(typeDescr.getSuperTypeName());
                    if (parent == null) {
                        this.results.add(new TypeDeclarationError(typeDescr, "Declared class " + typeDescr.getTypeName() + " can't extend class " + typeDescr.getSuperTypeName() + ", it should be declared"));
                    } else {
                        if (parent.getNature() == TypeDeclaration.Nature.DECLARATION && ruleBase != null) {
                            // trying to find a definition
                            parent = ruleBase.getPackagesMap().get(typeDescr.getSuperTypeNamespace()).getTypeDeclaration(typeDescr.getSuperTypeName());
                        }
                    }
                }
            }

            // is it a regular fact or an event?
            AnnotationDescr annotationDescr = typeDescr.getAnnotation(TypeDeclaration.Role.ID);
            String role = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
            if (role != null) {
                type.setRole(TypeDeclaration.Role.parseRole(role));
            } else if (parent != null) {
                type.setRole(parent.getRole());
            }

            annotationDescr = typeDescr.getAnnotation(TypeDeclaration.ATTR_TYPESAFE);
            String typesafe = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
            if (typesafe != null) {
                type.setTypesafe(Boolean.parseBoolean(typesafe));
            } else if (parent != null) {
                type.setTypesafe(parent.isTypesafe());
            }

            // is it a pojo or a template?
            annotationDescr = typeDescr.getAnnotation(TypeDeclaration.Format.ID);
            String format = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
View Full Code Here

        if (type.isValid()) {
            // prefer definitions where possible
            if (type.getNature() == TypeDeclaration.Nature.DEFINITION) {
                pkgRegistry.getPackage().addTypeDeclaration(type);
            } else {
                TypeDeclaration oldType = pkgRegistry.getPackage().getTypeDeclaration(type.getTypeName());
                if (oldType == null) {
                    pkgRegistry.getPackage().addTypeDeclaration(type);
                } else {
                    if (type.getRole() == TypeDeclaration.Role.EVENT) {
                        oldType.setRole(TypeDeclaration.Role.EVENT);
                        if ( type.getDurationAttribute() != null ) {
                            oldType.setDurationAttribute( type.getDurationAttribute() );
                            oldType.setDurationExtractor( type.getDurationExtractor() );
                        }
                        if ( type.getTimestampAttribute() != null ) {
                            oldType.setTimestampAttribute( type.getTimestampAttribute() );
                            oldType.setTimestampExtractor( type.getTimestampExtractor() );
                        }
                        if ( type.getExpirationOffset() >= 0 ) {
                            oldType.setExpirationOffset( type.getExpirationOffset() );
                        }
                    }
                    if (type.isPropertyReactive()) {
                        oldType.setPropertyReactive(true);
                    }
                }
            }
        }
View Full Code Here

        //look among local declarations
        if (pkgRegistry != null) {
            for (String declaredName : pkgRegistry.getPackage().getTypeDeclarations().keySet()) {
                if (declaredName.equals(klass)) {
                    TypeDeclaration typeDeclaration = pkgRegistry.getPackage().getTypeDeclaration(declaredName);
                    if ( typeDeclaration.getTypeClass() != null ) {
                        klass = typeDeclaration.getTypeClass().getName();
                    }
                }
            }
        }
View Full Code Here

        clone.currentRulePackage = currentRulePackage;
        return clone;
    }

    private void initBuiltinTypeDeclarations() {
        TypeDeclaration colType = new TypeDeclaration( "Collection" );
        colType.setTypesafe( false );
        colType.setTypeClass( Collection.class );
        builtinTypes.put( "java.util.Collection",
                          colType );

        TypeDeclaration mapType = new TypeDeclaration( "Map" );
        mapType.setTypesafe( false );
        mapType.setTypeClass( Map.class );
        builtinTypes.put( "java.util.Map",
                          mapType );

        TypeDeclaration activationType = new TypeDeclaration( "Match" );
        activationType.setTypesafe( false );
        activationType.setTypeClass( Match.class );
        builtinTypes.put( Match.class.getCanonicalName(),
                          activationType );

        TypeDeclaration thingType = new TypeDeclaration( Thing.class.getSimpleName() );
        thingType.setKind( TypeDeclaration.Kind.TRAIT );
        thingType.setTypeClass( Thing.class );
        builtinTypes.put( Thing.class.getCanonicalName(),
                          thingType );
    }
View Full Code Here

        }
        pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
        pkg.getDialectRuntimeRegistry().onBeforeExecute();

        // we have to do this before the merging, as it does some classloader resolving
        TypeDeclaration lastType = null;
        try {
            // Resolve the class for the type declaation
            if ( newPkg.getTypeDeclarations() != null ) {
                // add type declarations
                for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
                    lastType = type;
                    type.setTypeClass( this.rootClassLoader.loadClass( type.getTypeClassName() ) );
                }
            }
        } catch ( ClassNotFoundException e ) {
            throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName() +
                                              "'" );
        }

        // now merge the new package into the existing one
        mergePackage( pkg,
View Full Code Here

    public TypeDeclaration getAndRegisterTypeDeclaration( Class<?> cls, String packageName ) {
        if (cls.isPrimitive() || cls.isArray()) {
            return null;
        }
        TypeDeclaration typeDeclaration = getCachedTypeDeclaration( cls );
        if ( typeDeclaration != null ) {
            registerTypeDeclaration( packageName, typeDeclaration );
            return typeDeclaration;
        }
        typeDeclaration = getExistingTypeDeclaration( cls );
View Full Code Here

    public TypeDeclaration getTypeDeclaration(Class< ? > cls) {
        if ( cls.isPrimitive() || cls.isArray() ) return null;

        // If this class has already been accessed, it'll be in the cache
        TypeDeclaration tdecl = getCachedTypeDeclaration( cls );
        return tdecl != null ? tdecl : createTypeDeclaration( cls );
    }
View Full Code Here

        TypeDeclaration tdecl = getCachedTypeDeclaration( cls );
        return tdecl != null ? tdecl : createTypeDeclaration( cls );
    }

    private TypeDeclaration createTypeDeclaration(Class< ? > cls) {
        TypeDeclaration typeDeclaration = getExistingTypeDeclaration( cls );

        if ( typeDeclaration == null ) {
            typeDeclaration = createTypeDeclarationForBean( cls );
        }
View Full Code Here

        }
    }

    private TypeDeclaration getExistingTypeDeclaration(Class< ? > cls) {
        // Check if we are in the built-ins
        TypeDeclaration typeDeclaration = this.builtinTypes.get( (cls.getName()) );
        if ( typeDeclaration == null ) {
            // No built-in
            // Check if there is a user specified typedeclr
            PackageRegistry pkgReg = this.pkgRegistryMap.get( ClassUtils.getPackage( cls ) );
            if ( pkgReg != null ) {
View Full Code Here

TOP

Related Classes of org.drools.core.rule.TypeDeclaration$TimestampAccessorSetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.