Package org.drools.verifier.components

Examples of org.drools.verifier.components.ObjectType


    }

    private void saveVerifierComponentAndGet(Field field) {
        VerifierData data = VerifierReportFactory.newVerifierData();

        ObjectType objectType = new ObjectType();

        field.setObjectTypePath( objectType.getPath() );

        data.add( objectType );
        data.add( field );

        Collection<VerifierComponent> all = data.getAll();

        assertEquals( 2,
                      all.size() );
        assertTrue( all.contains( objectType ) );
        assertTrue( all.contains( field ) );

        Collection<VerifierComponent> fields = data.getAll( field.getVerifierComponentType() );

        assertEquals( 1,
                      fields.size() );
        assertEquals( field,
                      fields.toArray()[0] );

        VerifierComponent field2 = data.getVerifierObject( field.getVerifierComponentType(),
                                                           field.getPath() );

        assertNotNull( field2 );
        assertEquals( field,
                      field2 );

        Collection<VerifierComponent> objectTypes = data.getAll( objectType.getVerifierComponentType() );

        assertEquals( 1,
                      objectTypes.size() );
        assertEquals( objectType,
                      objectTypes.toArray()[0] );

        VerifierComponent objectType2 = data.getVerifierObject( objectType.getVerifierComponentType(),
                                                                objectType.getPath() );

        assertNotNull( objectType2 );
        assertEquals( objectType,
                      objectType2 );
    }
View Full Code Here


    }

    private void saveVerifierComponentAndGet(Restriction component) {
        VerifierData data = VerifierReportFactory.newVerifierData();

        ObjectType objectType = new ObjectType();

        Field field = new Field();
        field.setObjectTypePath( objectType.getPath() );

        component.setFieldPath( field.getPath() );

        assertNotNull( component.getFieldPath() );

        data.add( objectType );
        data.add( field );
        data.add( component );

        Collection<VerifierComponent> all = data.getAll();

        assertEquals( 3,
                      all.size() );
        assertTrue( all.contains( objectType ) );
        assertTrue( all.contains( field ) );
        assertTrue( all.contains( component ) );

        Collection<VerifierComponent> components = data.getAll( component.getVerifierComponentType() );

        assertEquals( 1,
                      components.size() );
        assertEquals( component,
                      components.toArray()[0] );

        VerifierComponent component2 = data.getVerifierObject( component.getVerifierComponentType(),
                                                               component.getPath() );

        assertNotNull( component2 );
        assertEquals( component,
                      component2 );

        Collection<VerifierComponent> fields = data.getAll( field.getVerifierComponentType() );

        assertEquals( 1,
                      fields.size() );
        assertEquals( field,
                      fields.toArray()[0] );

        VerifierComponent field2 = data.getVerifierObject( field.getVerifierComponentType(),
                                                           field.getPath() );

        assertNotNull( field2 );
        assertEquals( field,
                      field2 );

        Collection<VerifierComponent> objectTypes = data.getAll( objectType.getVerifierComponentType() );

        assertEquals( 1,
                      objectTypes.size() );
        assertEquals( objectType,
                      objectTypes.toArray()[0] );

        VerifierComponent objectType2 = data.getVerifierObject( objectType.getVerifierComponentType(),
                                                                objectType.getPath() );

        assertNotNull( objectType2 );
        assertEquals( objectType,
                      objectType2 );
    }
View Full Code Here

        Collection<Object> data = new ArrayList<Object>();

        VerifierRule rule = VerifierComponentMockFactory.createRule1();

        ObjectType objectType = new ObjectType();
        objectType.setFullName( "org.test.Person" );

        Pattern pattern1 = VerifierComponentMockFactory.createPattern1();
        Pattern pattern2 = VerifierComponentMockFactory.createPattern2();

        /*
 
View Full Code Here

                System.out.println( "\t" + msg.getFaulty() );
            }

            Collection<ObjectType> classes = result.getVerifierData().getAll( VerifierComponentType.OBJECT_TYPE );
            for ( Iterator iterator = classes.iterator(); iterator.hasNext(); ) {
                ObjectType c = (ObjectType) iterator.next();

                Collection<VerifierRule> cr = result.getVerifierData().getRulesByObjectTypePath( c.getPath() );
                System.err.println( "Class rules:" + cr );
                Set<Field> flds = c.getFields();
                for ( Iterator iterator2 = flds.iterator(); iterator2.hasNext(); ) {
                    Field f = (Field) iterator2.next();
                    cr = result.getVerifierData().getRulesByFieldPath( f.getPath() );
                    System.err.println( "Field rules: " + cr );
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.getAnnotations().keySet()) {
                Map<String, String> values = typeDeclaration.getAnnotation(metadata).getValueMap();
                for (String value : values.keySet()) {
                    objectType.getMetadata().put(metadata,
                            value);
                }
            }
        }
    }
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

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

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

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

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

        PackageHeaderLoader packageHeaderLoader = new PackageHeaderLoader(imports, jars);

        for (String factTypeName : packageHeaderLoader.getClassNames()) {
            String name = factTypeName.substring(factTypeName.lastIndexOf(".") + 1);
            Collection<String> fieldNames = packageHeaderLoader.getFieldNames(factTypeName);
            for (String fieldName : fieldNames) {
                ObjectType objectType = this.data.getObjectTypeByObjectTypeNameAndPackageName(name, rulePackage.getName());

                Field field = data.getFieldByObjectTypeAndFieldName(objectType.getFullName(), fieldName);
                if (field == null) {
                    field = ObjectTypeFactory.createField(fieldName, objectType);
                    field.setFieldType(packageHeaderLoader.getFieldType(objectType.getName(), fieldName));
                    data.add(field);
                }
            }
        }
    }
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.