use of org.drools.verifier.components.Field in project drools by kiegroup.
the class ExprConstraintDescrVisitor method createField.
private void createField(RelationalExprDescr descr, String fieldName) {
field = new Field(pattern.getDescr());
field.setName(fieldName);
field.setObjectTypePath(pattern.getObjectTypePath());
field.setObjectTypeName(pattern.getName());
data.add(field);
}
use of org.drools.verifier.components.Field in project drools by kiegroup.
the class ExprConstraintDescrVisitor method visit.
private void visit(BindingDescr descr) {
Field field = new Field(descr);
field.setName(descr.getExpression());
field.setObjectTypeName(pattern.getName());
field.setObjectTypePath(pattern.getObjectTypePath());
data.add(field);
FieldVariable fieldVariable = new FieldVariable(pattern);
fieldVariable.setParentPath(field.getPath());
fieldVariable.setName(descr.getVariable());
fieldVariable.setOrderNumber(orderNumber.next());
data.add(fieldVariable);
}
use of org.drools.verifier.components.Field in project drools by kiegroup.
the class PackageDescrVisitor method visitImports.
private void visitImports(List<ImportDescr> importDescrs) throws IOException, ClassNotFoundException {
HashSet<String> imports = new HashSet<String>();
for (ImportDescr i : importDescrs) {
String fullName = i.getTarget();
String name = fullName.substring(fullName.lastIndexOf(".") + 1);
imports.add(fullName);
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);
}
}
}
}
use of org.drools.verifier.components.Field in project drools by kiegroup.
the class PatternDescrVisitor method visitBindingDescr.
/**
* End
*
* @param descr
*/
private void visitBindingDescr(BindingDescr descr) {
Field field = new Field(descr);
field.setName(descr.getExpression());
field.setObjectTypeName(objectType.getName());
field.setObjectTypePath(objectType.getPath());
data.add(field);
FieldVariable fieldVariable = new FieldVariable(pattern);
fieldVariable.setParentPath(field.getPath());
fieldVariable.setName(descr.getVariable());
fieldVariable.setOrderNumber(orderNumber.next());
data.add(fieldVariable);
}
use of org.drools.verifier.components.Field in project drools by kiegroup.
the class TypeDeclarationDescrVisitor method visit.
public void visit(List<TypeDeclarationDescr> typeDeclarationDescrs) {
for (TypeDeclarationDescr typeDeclaration : typeDeclarationDescrs) {
Import objectImport = data.getImportByName(typeDeclaration.getTypeName());
String objectTypeName;
if (objectImport == null) {
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);
}
}
}
}
Aggregations