Package org.drools.verifier.components

Examples of org.drools.verifier.components.ObjectType


  }

  public static String visitField(String sourceFolder, Field field,
      VerifierResult result) {
    VerifierData data = result.getVerifierData();
    ObjectType objectType = data.getObjectTypeById(field.getObjectTypeId());
    Collection<VerifierRule> rules = data.getRulesByFieldId(field.getId());

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


    objectTypesById.put(Integer.valueOf(objectType.getId()), objectType);
    objectTypesByName.put(objectType.getName(), objectType);
  }

  public void add(Field field) {
    ObjectType objectType = objectTypesById.get(Integer.valueOf(field
        .getObjectTypeId()));
    fieldsByObjectTypeAndFieldName.put(objectType.getName() + "."
        + field.getName(), field);

    fieldsById.put(field.getId(), field);

    fieldsByObjectTypeId.put(field.getObjectTypeId(), field);
View Full Code Here

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

    for (Pattern pattern : patternsByRuleName.getBranch(ruleName)) {
      ObjectType objectType = getObjectTypeById(pattern.getObjectTypeId());
      set.add(objectType);
    }

    return set;
  }
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(descr,objectImport);
                    } else {
                        objectType = ObjectTypeFactory.createObjectType(descr,base);
                    }

                    data.add(objectType);
                }

                enumField = new EnumField(descr);

                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

                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

        return field;
    }

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

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

        return objectType;
    }
View Full Code Here

        return objectType;
    }

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

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

        return objectType;
    }
View Full Code Here

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

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

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

            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(objectType.getDescr() ,fieldName, objectType);
                    field.setFieldType(packageHeaderLoader.getFieldType(objectType.getName(), fieldName));
                    data.add(field);
                }
            }
        }
    }
View Full Code Here

        Pattern pattern = VerifierComponentMockFactory.createPattern1();
        saveVerifierComponentAndGet( pattern );

        saveVerifierComponentAndGet( new Constraint( pattern ) );
        saveVerifierComponentAndGet( new InlineEvalDescr( pattern ) );
        saveVerifierComponentAndGet( new ObjectType() );
        saveVerifierComponentAndGet( new RuleOperatorDescr( rule,
                                                            OperatorDescrType.AND ) );
        saveVerifierComponentAndGet( new PatternOperatorDescr( pattern,
                                                               OperatorDescrType.AND ) );
        saveVerifierComponentAndGet( new SubPattern( pattern,
View Full Code Here

        VerifierRule rule = VerifierComponentMockFactory.createRule1();
        assertNotNull( rule.getName() );
        assertEquals( "testRule1",
                      rule.getName() );

        ObjectType objectType = new ObjectType();
        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        assertNotNull( pattern.getRulePath() );
        assertEquals( rule.getPath(),
                      pattern.getRulePath() );

        assertNotNull( pattern.getName() );
        assertEquals( rule.getName(),
                      pattern.getRuleName() );

        pattern.setObjectTypePath( objectType.getPath() );
        assertNotNull( pattern.getObjectTypePath() );
        assertEquals( objectType.getPath(),
                      pattern.getObjectTypePath() );

        data.add( rule );
        data.add( objectType );
        data.add( pattern );

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

        assertEquals( 3,
                      all.size() );
        assertTrue( all.contains( pattern ) );
        assertTrue( all.contains( objectType ) );
        assertTrue( all.contains( rule ) );

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

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

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

        assertNotNull( objectType2 );
        assertEquals( objectType,
                      objectType2 );
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.