use of org.kie.api.definition.type.Timestamp in project drools by kiegroup.
the class TypeDeclarationConfigurator method wireTimestampAccessor.
private static void wireTimestampAccessor(KnowledgeBuilderImpl kbuilder, Annotated annotated, TypeDeclaration type, PackageRegistry pkgRegistry) {
Timestamp timestamp = annotated.getTypedAnnotation(Timestamp.class);
if (timestamp != null) {
BaseDescr typeDescr = annotated instanceof BaseDescr ? ((BaseDescr) annotated) : new BaseDescr();
String timestampField;
try {
timestampField = timestamp.value();
} catch (Exception e) {
kbuilder.addBuilderResult(new TypeDeclarationError(typeDescr, e.getMessage()));
return;
}
type.setTimestampAttribute(timestampField);
InternalKnowledgePackage pkg = pkgRegistry.getPackage();
MVELAnalysisResult results = getMvelAnalysisResult(kbuilder, typeDescr, type, pkgRegistry, timestampField, pkg);
if (results != null) {
type.setTimestampExtractor(getFieldExtractor(type, timestampField, pkg, results));
} else {
kbuilder.addBuilderResult(new TypeDeclarationError(typeDescr, "Error creating field accessors for timestamp field '" + timestamp + "' for type '" + type.getTypeName() + "'"));
}
}
}
use of org.kie.api.definition.type.Timestamp in project drools by kiegroup.
the class TypeDeclarationUtil method createTypeDeclaration.
public static TypeDeclaration createTypeDeclaration(Class<?> cls) {
TypeDeclaration typeDeclaration = createTypeDeclarationForBean(cls);
Duration duration = cls.getAnnotation(Duration.class);
if (duration != null) {
wireDurationAccessor(duration.value(), typeDeclaration);
}
Timestamp timestamp = cls.getAnnotation(Timestamp.class);
if (timestamp != null) {
wireDurationAccessor(timestamp.value(), typeDeclaration);
}
return typeDeclaration;
}
Aggregations