Package org.drools.verifier.components

Examples of org.drools.verifier.components.ObjectType


    public Collection<ObjectType> getObjectTypesByRuleName(String ruleName) {
        Set<ObjectType> set = new HashSet<ObjectType>();

        for ( Pattern pattern : patternsByRuleName.get( ruleName ) ) {
            ObjectType objectType = (ObjectType) getVerifierObject( VerifierComponentType.OBJECT_TYPE,
                                                                    pattern.getObjectTypePath() );
            set.add( objectType );
        }

        return set;
View Full Code Here


    }

    public void add(VerifierComponent object) {
        if ( VerifierComponentType.FIELD.equals( object.getVerifierComponentType() ) ) {
            Field field = (Field) object;
            ObjectType objectType = (ObjectType) getVerifierObject( VerifierComponentType.OBJECT_TYPE,
                                                                    field.getObjectTypePath() );
            fieldsByObjectTypeAndFieldName.put( objectType.getFullName() + "." + field.getName(),
                                                field );

            fieldsByObjectTypeId.put( field.getObjectTypePath(),
                                      field );
        } else if ( VerifierComponentType.RULE.equals( object.getVerifierComponentType() ) ) {
            VerifierRule rule = (VerifierRule) object;
            rulesByName.put( rule.getName(),
                             rule );
            if ( rule.getMetadata().containsKey( "category" ) ) {
                rulesByCategory.put( rule.getMetaAttribute("category"),
                                     rule );
            }
        } else if ( VerifierComponentType.VARIABLE.equals( object.getVerifierComponentType() ) ) {
            Variable variable = (Variable) object;
            variablesByRuleAndVariableName.put( variable.getRuleName() + "." + variable.getName(),
                                                variable );
        } else if ( VerifierComponentType.PATTERN.equals( object.getVerifierComponentType() ) ) {
            Pattern pattern = (Pattern) object;

            patternsByObjectTypeId.put( pattern.getObjectTypePath(),
                                        pattern );
            patternsByRuleName.put( pattern.getRuleName(),
                                    pattern );
        } else if ( VerifierComponentType.RESTRICTION.equals( object.getVerifierComponentType() ) ) {
            Restriction restriction = (Restriction) object;

            restrictionsByFieldId.put( restriction.getFieldPath(),
                                       restriction );
        } else if ( VerifierComponentType.RULE_PACKAGE.equals( object.getVerifierComponentType() ) ) {
            RulePackage rulePackage = (RulePackage) object;

            packagesByName.put( rulePackage.getName(),
                                rulePackage );
        } else if ( VerifierComponentType.IMPORT.equals( object.getVerifierComponentType() ) ) {
            Import objectImport = (Import) object;
            importsByName.put( objectImport.getName(),
                               objectImport );
        } else if ( VerifierComponentType.OBJECT_TYPE.equals( object.getVerifierComponentType() ) ) {
            ObjectType objectType = (ObjectType) object;
            objectTypesByFullName.put( objectType.getFullName(),
                                       objectType );
        } else if ( VerifierComponentType.ENTRY_POINT_DESCR.equals( object.getVerifierComponentType() ) ) {
            EntryPoint entryPoint = (EntryPoint) object;
            entryPointsByEntryId.put( entryPoint.getEntryPointName(),
                                      entryPoint );
View Full Code Here

            EnumField enumField = (EnumField) data.getFieldByObjectTypeAndFieldName( base,
                                                                                     fieldName );
            if ( enumField == null ) {

                ObjectType objectType = data.getObjectTypeByFullName( base );

                if ( objectType == null ) {
                    Import objectImport = data.getImportByName( base );

                    if ( objectImport != null ) {
                        objectType = ObjectTypeFactory.createObjectType( objectImport );
                    } else {
                        objectType = ObjectTypeFactory.createObjectType( base );
                    }

                    data.add( objectType );
                }

                enumField = new EnumField();

                enumField.setObjectTypePath( objectType.getPath() );
                enumField.setObjectTypeName( objectType.getName() );
                enumField.setName( fieldName );

                objectType.getFields().add( enumField );

                data.add( enumField );
            }

            EnumRestriction restriction = new EnumRestriction( pattern );
View Full Code Here

            Import objectImport = new Import( rulePackage );
            objectImport.setName( fullPath );
            objectImport.setShortName( name );
            data.add( objectImport );

            ObjectType objectType = this.data.getObjectTypeByFullName( fullPath );

            if ( objectType == null ) {
                objectType = new ObjectType();
            }

            objectType.setName( name );
            objectType.setFullName( fullPath );
            data.add( objectType );
        }

        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        SuggestionCompletionEngine engine = loader.getSuggestionEngine( header.toString(),
                                                                        jars,
                                                                        Collections.EMPTY_LIST );
        for ( String factTypeName : engine.getFactTypes() ) {
            for ( String fieldName : engine.getFieldCompletions( factTypeName ) ) {
                ObjectType objectType = this.data.getObjectTypeByObjectTypeNameAndPackageName( factTypeName,
                                                                                               rulePackage.getName() );

                Field field = data.getFieldByObjectTypeAndFieldName( objectType.getFullName(),
                                                                     fieldName );
                if ( field == null ) {
                    field = ObjectTypeFactory.createField( fieldName,
                                                           objectType );
                    field.setFieldType( engine.getFieldType( objectType.getName(),
                                                             fieldName ) );
                    data.add( field );
                }
            }
        }
View Full Code Here

    public static String visitField(String sourceFolder,
                                    Field field,
                                    VerifierReport result) {
        VerifierData data = result.getVerifierData();
        ObjectType objectType = data.getVerifierObject( VerifierComponentType.OBJECT_TYPE,
                                                        field.getObjectTypePath() );
        Collection<VerifierRule> rules = data.getRulesByFieldPath( field.getPath() );

        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "sourceFolder",
View Full Code Here

                objectTypeName = typeDeclaration.getTypeName();
            } else {
                objectTypeName = objectImport.getName();
            }

            ObjectType objectType = this.data.getObjectTypeByFullName( objectTypeName );

            if ( objectType == null ) {
                objectType = new ObjectType();
                objectType.setName( typeDeclaration.getTypeName() );
                objectType.setFullName( typeDeclaration.getTypeName() );
                data.add( objectType );
            }

            for ( String fieldName : typeDeclaration.getFields().keySet() ) {

                Field field = data.getFieldByObjectTypeAndFieldName( objectType.getFullName(),
                                                                     fieldName );
                if ( field == null ) {
                    field = ObjectTypeFactory.createField( fieldName,
                                                           objectType );
                    field.setFieldType( typeDeclaration.getFields().get( fieldName ).getPattern().getObjectType() );
                    data.add( field );
                }
            }
            for ( String metadata : typeDeclaration.getMetaAttributes().keySet() ) {
                objectType.getMetadata().put( metadata,
                                              typeDeclaration.getMetaAttribute( metadata ) );
            }
        }
    }
View Full Code Here

        return field;
    }

    static ObjectType createObjectType(Import objectImport) {
        ObjectType objectType = new ObjectType();

        objectType.setName( objectImport.getShortName() );
        objectType.setFullName( objectImport.getName() );

        return objectType;
    }
View Full Code Here

        return objectType;
    }

    static ObjectType createObjectType(String shortName) {
        ObjectType objectType = new ObjectType();

        objectType.setName( shortName );
        objectType.setFullName( shortName );

        return objectType;
    }
View Full Code Here

                objectTypeName = typeDeclaration.getTypeName();
            } else {
                objectTypeName = objectImport.getName();
            }

            ObjectType objectType = this.data.getObjectTypeByFullName(objectTypeName);

            if (objectType == null) {
                objectType = new ObjectType(typeDeclaration);
                objectType.setName(typeDeclaration.getTypeName());
                objectType.setFullName(typeDeclaration.getTypeName());
                data.add(objectType);
            }

            for (String fieldName : typeDeclaration.getFields().keySet()) {

                Field field = data.getFieldByObjectTypeAndFieldName(objectType.getFullName(),
                        fieldName);
                if (field == null) {
                    field = ObjectTypeFactory.createField(typeDeclaration.getFields().get(fieldName),fieldName,
                            objectType);
                    field.setFieldType(typeDeclaration.getFields().get(fieldName).getPattern().getObjectType());
                    data.add(field);
                }
            }

            for (AnnotationDescr annDescr : typeDeclaration.getAnnotations()) {
                Map<String, Object> values = typeDeclaration.getAnnotation(annDescr.getName()).getValueMap();
                for (String value : values.keySet()) {
                    objectType.getMetadata().put(annDescr.getName(), value);
                }
            }
        }
    }
View Full Code Here

                objectTypeName = typeDeclaration.getTypeName();
            } else {
                objectTypeName = objectImport.getName();
            }

            ObjectType objectType = this.data.getObjectTypeByFullName(objectTypeName);

            if (objectType == null) {
                objectType = new ObjectType(typeDeclaration);
                objectType.setName(typeDeclaration.getTypeName());
                objectType.setFullName(typeDeclaration.getTypeName());
                data.add(objectType);
            }

            for (String fieldName : typeDeclaration.getFields().keySet()) {

                Field field = data.getFieldByObjectTypeAndFieldName(objectType.getFullName(),
                        fieldName);
                if (field == null) {
                    field = ObjectTypeFactory.createField(typeDeclaration.getFields().get(fieldName),fieldName,
                            objectType);
                    field.setFieldType(typeDeclaration.getFields().get(fieldName).getPattern().getObjectType());
                    data.add(field);
                }
            }

            for (String metadata : typeDeclaration.getAnnotations().keySet()) {
                Map<String, String> values = typeDeclaration.getAnnotation(metadata).getValueMap();
                for (String value : values.keySet()) {
                    objectType.getMetadata().put(metadata,
                            value);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.drools.verifier.components.ObjectType

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.