我尝试使用以下代码从文件部署流程定义
#import "ALISBNScanViewController.h"
#import <Anyline/Anyline.h>
NSString * const kISBNLicenseKey = Anyline_LICENSE_KEY;
@interface ALISBNScanViewController ()<AnylineOCRModuleDelegate>
// The Anyline module used for OCR
@property (nonatomic, strong) AnylineOCRModuleView *ocrModuleView;
@end
@implementation ALISBNScanViewController
/*
We will do our main setup in viewDidLoad. Its called once the view controller is getting ready to be displayed.
*/
- (void)viewDidLoad {
[super viewDidLoad];
// Set the background color to black to have a nicer transition
self.view.backgroundColor = [UIColor blackColor];
self.title = @"Text Recognition";
// Initializing the module. Its a UIView subclass. We set the frame to fill the whole screen
CGRect frame = [[UIScreen mainScreen] applicationFrame];
frame = CGRectMake(frame.origin.x, frame.origin.y + self.navigationController.navigationBar.frame.size.height, frame.size.width, frame.size.height - self.navigationController.navigationBar.frame.size.height);
self.ocrModuleView = [[AnylineOCRModuleView alloc] initWithFrame:frame];
ALOCRConfig *config = [[ALOCRConfig alloc] init];
config.tesseractLanguages = @[@"eng_no_dict", @"deu"];
config.charWhiteList = @"PMMDOBCPSKA1234_/ ";
config.scanMode = ALAuto;
NSError *error = nil;
BOOL success = [self.ocrModuleView setupWithLicenseKey:kISBNLicenseKey delegate:self ocrConfig:config error:&error];
if (!success) {
NSAssert(success, @"Setup Error: %@", error.debugDescription);
}
NSString *confPath = [[NSBundle mainBundle] pathForResource:@"isbn_config" ofType:@"json"];
ALUIConfiguration *isbnconf = [ALUIConfiguration cutoutConfigurationFromJsonFile:confPath];
self.ocrModuleView.currentConfiguration = isbnconf;
[self.view addSubview:self.ocrModuleView];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self startAnyline];
}
/*
Cancel scanning to allow the module to clean up
*/
- (void)viewWillDisappear:(BOOL)animated {
[self.ocrModuleView cancelScanningAndReturnError:nil];
}
- (void)startAnyline {
NSError *error;
BOOL success = [self.ocrModuleView startScanningAndReturnError:&error];
if( !success ) {
NSAssert(success, @"Start Scanning Error: %@", error.debugDescription);
}
}
#pragma mark -- AnylineOCRModuleDelegate
/*
This is the main delegate method Anyline uses to report its results
*/
- (void)anylineOCRModuleView:(AnylineOCRModuleView *)anylineOCRModuleView
didFindResult:(ALOCRResult *)result {
NSString *label = result.result;
DLog(@"LABEL:%@",label);
NSString *message = [NSString stringWithFormat:@"Testo riconosciuto: %@",label];
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"Testo riconosciuto" message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okBtn = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
[self startAnyline];
}];
[alert addAction:okBtn];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSError *error = nil;
BOOL success = [self.ocrModuleView startScanningAndReturnError:&error];
NSAssert(success, @"We failed starting: %@",error.debugDescription);
}
@end
上面的代码成功运行,并打印出新的deploymentId。
稍后,我尝试使用以下代码列出已部署的流程定义
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name(definitionName);
deploymentBuilder.addInputStream(definitionName, definitionFileInputStream);
String deploymentId = deploymentBuilder.deploy().getId();
System.out.println(deploymentId);
以上代码成功运行,但输出始终为0.
我做了一些调查,发现在 List<ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery().list();
System.out.println(definitions.size());
表中存在一个带有相应ACT_GE_BYTEARRAY
的条目,deploymentId
列包含定义文件的内容。< / p>
我还发现在BYTES_
表中找不到相应的条目。
有什么东西搞乱吗?从API和示例中我发现上面的代码似乎已经足够了,或者是否有缺失的步骤?
感谢您的帮助
答案 0 :(得分:5)
事实证明,该问题与definitionName
(thanks thorben!)有关,因为它必须以.bpmn20.xml
或.bpmn
结束。
进一步测试后,以下definitionName
代码
deploymentBuilder.addInputStream(definitionName, definitionFileInputStream);
离开以下definitionName
没有后缀是没错的
repositoryService.createDeployment().name(definitionName);
答案 1 :(得分:2)
您似乎忘记了部署的流程定义上的isExecutable
标志。请检查您的流程模型是否包含isExecutable
标志。如果使用camunda建模器,只需在过程的属性面板中设置此选项。
如果使用非可执行定义调用#deploy()
,则会创建部署,但由于流程定义不可执行,因此未部署流程定义。
在最新版本的camunda平台(7.7)上,DeploymentBuilder
添加了一个名为#deployWithResult()的新方法。此方法返回已部署的流程定义,因此很容易检查是否已部署流程定义。