Fxing and adding rules

This commit is contained in:
Luca Frosini 2020-04-10 15:07:54 +02:00
parent e229f7278e
commit e3d4611bb9
5 changed files with 27 additions and 8 deletions

View File

@ -48,16 +48,21 @@ public class Harmonizer implements FieldAction {
List<MatcherReplace> matcherReplaceList = RegexRulesAggregator.getInstance().getMatcherReplaceList(); List<MatcherReplace> matcherReplaceList = RegexRulesAggregator.getInstance().getMatcherReplaceList();
String calledMethod = (String) value;
for(MatcherReplace matcherReplace : matcherReplaceList) { for(MatcherReplace matcherReplace : matcherReplaceList) {
Replace replace = matcherReplace.check(serviceClass, serviceName, (String) value); Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
if(replace != null) { if(replace != null) {
serviceUsageRecord.setServiceClass(replace.getServiceClass()); serviceClass = replace.getServiceClass();
serviceUsageRecord.setServiceName(replace.getServiceName()); serviceName = replace.getServiceName();
return replace.getCalledMethod(); calledMethod = replace.getCalledMethod();
} }
} }
return value; serviceUsageRecord.setServiceClass(serviceClass);
serviceUsageRecord.setServiceName(serviceName);
return calledMethod;
} }
} }

View File

@ -219,8 +219,8 @@ public class TestRules extends ContextTest {
public void testSingleRule() throws Exception { public void testSingleRule() throws Exception {
allRules(); allRules();
File rulesDirectory = getRulesDirectory(); File rulesDirectory = getRulesDirectory();
File rulesDirFile = new File(rulesDirectory, "SmartExecutor"); File rulesDirFile = new File(rulesDirectory, "WhnManager");
File ruleFile = new File(rulesDirFile, "SmartExecutor-getAvailablePlugins.json"); File ruleFile = new File(rulesDirFile, "WhnManager-OTHER.json");
testRule(ruleFile); testRule(ruleFile);
} }

View File

@ -2,7 +2,7 @@
"match": { "match": {
"serviceClassRegex": "VREManagement", "serviceClassRegex": "VREManagement",
"serviceNameRegex": "(SmartExecutor)|(smart-executor)", "serviceNameRegex": "(SmartExecutor)|(smart-executor)",
"calledMethodRegex": ".*(UNKNOWN)|(OTHER).*" "calledMethodRegex": "^((UNKNOWN)|(OTHER))$"
}, },
"replace": { "replace": {
"serviceClass": "VREManagement", "serviceClass": "VREManagement",

View File

@ -0,0 +1,2 @@
VREManagement,WhnManager,OTHER
VREManagement,WhnManager,gcube/vremanagement/ws/whnmanager
1 VREManagement WhnManager OTHER
2 VREManagement WhnManager gcube/vremanagement/ws/whnmanager

View File

@ -0,0 +1,12 @@
{
"match": {
"serviceClassRegex": "VREManagement",
"serviceNameRegex": "WhnManager",
"calledMethodRegex": "(OTHER)|((\/){0,1}gcube\/vremanagement\/ws\/whnmanager)"
},
"replace": {
"serviceClass": "VREManagement",
"serviceName": "WhnManager",
"calledMethod": "OTHER"
}
}