RED-9472: seperation of system rules
refactored rules refactored pcackages
This commit is contained in:
parent
74599683a5
commit
370b76628b
@ -39,7 +39,6 @@ configurations.all {
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation(project(":rules-management"))
|
||||
implementation(project(":redaction-service-api-v1")) { exclude(group = "com.iqser.red.service", module = "persistence-service-internal-api-v1") }
|
||||
implementation("com.iqser.red.service:persistence-service-internal-api-v1:${persistenceServiceVersion}") { exclude(group = "org.springframework.boot") }
|
||||
implementation("com.iqser.red.service:persistence-service-shared-mongo-v1:${persistenceServiceVersion}")
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.knecon.fforesight.utility.rules.management;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package com.knecon.fforesight.utility.rules.management.factory;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.factory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.RuleManagementResources;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.factory;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.factory;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
@ -9,13 +9,13 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleClass;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleUnit;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.RuleManagementResources;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleClass;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleUnit;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.factory;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.factory;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
|
||||
@ -18,17 +18,17 @@ import org.drools.drl.ast.descr.RuleDescr;
|
||||
import org.drools.drl.parser.DrlParser;
|
||||
import org.kie.internal.builder.conf.LanguageLevelOption;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicDeclaration;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicFunction;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleClass;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleUnit;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.RuleManagementResources;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.BasicDeclaration;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.BasicFunction;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.BasicRule;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleClass;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleUnit;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.migration;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.migration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -6,12 +6,12 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileFactory;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileFactory;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.BasicRule;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -33,7 +33,7 @@ public class RuleFileMigrator {
|
||||
//replaceRules(ruleFileBluePrint, combinedBluePrint);
|
||||
replaceRuleIdentifiers(combinedBluePrint, ruleFileBluePrint);
|
||||
|
||||
String migratedRulesString = RuleFileFactory.buildRuleString(ruleFileBluePrint,false, false);
|
||||
String migratedRulesString = RuleFileFactory.buildRuleString(ruleFileBluePrint, false, false);
|
||||
String migratedFilePath = ruleFile.getAbsolutePath();
|
||||
try (var out = new FileOutputStream(migratedFilePath)) {
|
||||
out.write(migratedRulesString.getBytes(StandardCharsets.UTF_8));
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.migration;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.migration;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -9,16 +9,15 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileFactory;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleClass;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleUnit;
|
||||
import com.knecon.fforesight.utility.rules.management.translation.OldRulesParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileFactory;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.BasicRule;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleUnit;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleClass;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.RuleManagementResources;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -35,7 +34,6 @@ public class RuleIdentifierMigrator {
|
||||
@SneakyThrows
|
||||
public void migrateAllRuleIdentifiers() {
|
||||
|
||||
List<OldRulesParser.OldRulesCsvRecord> parsedRecords = OldRulesParser.getOldRulesCsvRecords(RuleManagementResources.getOldRulesCsvInputStream());
|
||||
RuleFileBluePrint bluePrint = getBluePrint(ApplicationType.RM);
|
||||
|
||||
// migrateIdentifier(RuleIdentifier.fromString("PII.10.0"), RuleIdentifier.fromString("CBI.20.0"), bluePrint, parsedRecords);
|
||||
@ -50,10 +48,6 @@ public class RuleIdentifierMigrator {
|
||||
try (var out = new FileOutputStream("/tmp/all_redact_manager_rules.drl")) {
|
||||
out.write(ruleString.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
String csvString = OldRulesParser.formatAsCsv(parsedRecords);
|
||||
try (var out = new FileOutputStream("/tmp/old_rules_with_translations.csv")) {
|
||||
out.write(csvString.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +118,7 @@ public class RuleIdentifierMigrator {
|
||||
}
|
||||
|
||||
|
||||
public void migrateIdentifier(RuleIdentifier oldIdentifier, RuleIdentifier newIdentifier, RuleFileBluePrint bluePrint, List<OldRulesParser.OldRulesCsvRecord> records) {
|
||||
public void migrateIdentifier(RuleIdentifier oldIdentifier, RuleIdentifier newIdentifier, RuleFileBluePrint bluePrint) {
|
||||
|
||||
BasicRule oldRule = bluePrint.findRuleClassByType(oldIdentifier.type())
|
||||
.orElseThrow().findRuleUnitByInteger(oldIdentifier.unit())
|
||||
@ -138,9 +132,6 @@ public class RuleIdentifierMigrator {
|
||||
bluePrint.removeRule(oldIdentifier);
|
||||
bluePrint.addRule(newRule);
|
||||
|
||||
records.stream()
|
||||
.filter(record -> record.translatesTo().contains(oldIdentifier))
|
||||
.forEach(record -> replaceOldIdentifier(oldIdentifier, newIdentifier, record.translatesTo()));
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +149,7 @@ public class RuleIdentifierMigrator {
|
||||
}
|
||||
|
||||
|
||||
public record Context(RuleFileBluePrint bluePrint, List<OldRulesParser.OldRulesCsvRecord> records) {
|
||||
public record Context(RuleFileBluePrint bluePrint) {
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import org.drools.drl.ast.descr.AbstractClassTypeDeclarationDescr;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import org.drools.drl.ast.descr.FunctionDescr;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import org.drools.drl.ast.descr.RuleDescr;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.utils.RuleFileIO;
|
||||
|
||||
public record BasicRule(RuleIdentifier identifier, String name, String code) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import org.drools.drl.ast.descr.RuleDescr;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.models;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.models;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.utils;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -12,12 +12,12 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.redaction.v1.model.RuleBuilderModel;
|
||||
import com.iqser.red.service.redaction.v1.server.model.RuleMergingResult;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileFactory;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleUnit;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileFactory;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleUnit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ import com.iqser.red.storage.commons.service.StorageService;
|
||||
import com.iqser.red.storage.commons.utils.FileSystemBackedStorageService;
|
||||
import com.knecon.fforesight.service.layoutparser.processor.LayoutParsingServiceProcessorConfiguration;
|
||||
import com.knecon.fforesight.tenantcommons.TenantContext;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
|
||||
@ -11,10 +11,10 @@ import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.BasicRule;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@ -27,10 +27,10 @@ public class DroolsCompilationTest {
|
||||
@Test
|
||||
public void testValidateRuleSyntax() throws IOException {
|
||||
|
||||
URL rmURL = Resources.getResource("all_redact_manager_rules.drl");
|
||||
URL rmURL = Resources.getResource("rulesmanagement/all_redact_manager_rules.drl");
|
||||
String rmRule = Resources.toString(rmURL, StandardCharsets.UTF_8);
|
||||
|
||||
URL dmURL = Resources.getResource("all_rules_documine.drl");
|
||||
URL dmURL = Resources.getResource("rulesmanagement/all_rules_documine.drl");
|
||||
String dmRule = Resources.toString(dmURL, StandardCharsets.UTF_8);
|
||||
|
||||
assertTrue(validateRuleSyntax(rmRule).isValid());
|
||||
@ -1,12 +1,12 @@
|
||||
package com.knecon.fforesight.utility.rules.management;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleFileBluePrint;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
|
||||
public class RuleCompilationResultMergingTest {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
@ -8,7 +8,7 @@ import java.util.List;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.migration.RuleFileMigrator;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.migration.RuleFileMigrator;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.knecon.fforesight.utility.rules.management.factory;
|
||||
package com.iqser.red.service.redaction.v1.server.rulesmanagement.factory;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ -19,10 +19,10 @@ import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.RuleManagementResources;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ -27,9 +27,10 @@ sourceSets {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(mapOf("path" to ":redaction-service-server-v1")))
|
||||
testImplementation(platform("org.junit:junit-bom:5.10.0"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
|
||||
implementation(project(":redaction-service-server-v1"))
|
||||
implementation("com.github.javaparser:javaparser-core:3.25.3")
|
||||
implementation("org.drools:drools-drl-parser:8.41.0.Final")
|
||||
implementation("org.apache.commons:commons-csv:1.10.0")
|
||||
|
||||
@ -17,12 +17,11 @@ import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileFactory;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.translation.OldRulesParser;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileFactory;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.factory.RuleFileParser;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.ApplicationType;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.models.RuleIdentifier;
|
||||
import com.iqser.red.service.redaction.v1.server.rulesmanagement.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ -72,7 +71,6 @@ public class Main {
|
||||
Set<RuleIdentifier> identifiers = switch (type) {
|
||||
case "list", "l" -> RuleIdentifier.fromListOfIdentifiersString(input);
|
||||
case "file", "f" -> RuleFileParser.parseRuleIdentifiersFromFile(input);
|
||||
case "old", "o" -> OldRulesParser.translateOldRulesStringToNewIdentifiers(RuleFileIO.getRulesString(input), applicationType);
|
||||
default -> throw new IllegalArgumentException(String.format("type \"%s\" is not valid", cmd.getOptionValue("t")));
|
||||
};
|
||||
ruleFileString = RuleFileFactory.createFileFromIdentifiers(identifiers, applicationType);
|
||||
@ -102,7 +100,6 @@ public class Main {
|
||||
String type = cmd.hasOption("t") ? cmd.getOptionValue("t") : "f";
|
||||
Map<Path, Set<RuleIdentifier>> identifiersPerFile = switch (type) {
|
||||
case "file", "f" -> parseIdentifiersFromFiles(Path.of(cmd.getOptionValue("input")));
|
||||
case "old", "o" -> translateIdentifiersFromOldFiles(Path.of(cmd.getOptionValue("input")), applicationType);
|
||||
default -> throw new IllegalArgumentException(String.format("type \"%s\" is not valid in combination with the \"recursive\" flag", cmd.getOptionValue("t")));
|
||||
};
|
||||
identifiersPerFile.keySet()
|
||||
@ -137,13 +134,6 @@ public class Main {
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private static Map<Path, Set<RuleIdentifier>> translateIdentifiersFromOldFiles(Path inputDirectory, ApplicationType applicationType) {
|
||||
|
||||
return RuleFileIO.streamAllRuleFilesInDirectory(inputDirectory)
|
||||
.collect(Collectors.toMap(file -> getRelativizedPath(inputDirectory, file), e -> OldRulesParser.translateOldRulesFileToNewIdentifiers(e, applicationType)));
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private static Map<Path, Set<RuleIdentifier>> parseIdentifiersFromFiles(Path inputDirectory) {
|
||||
|
||||
@ -1,203 +0,0 @@
|
||||
package com.knecon.fforesight.utility.rules.management.translation;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.drools.drl.ast.descr.PackageDescr;
|
||||
import org.drools.drl.ast.descr.RuleDescr;
|
||||
import org.drools.drl.parser.DrlParser;
|
||||
import org.kie.internal.builder.conf.LanguageLevelOption;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.OldRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleFileBluePrint;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class OldRulesParser {
|
||||
|
||||
static List<String> HEADERS = List.of("id", "old rule names", "old rule code", "translates to");
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public void createSetOfTranslatedRuleIdentifiersForEachFileInTheCsv() {
|
||||
|
||||
List<String> allHeaders = List.of();
|
||||
List<OldRulesCsvRecord> records = getOldRulesCsvRecords(RuleManagementResources.getOldRulesCsvInputStream());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Set<RuleIdentifier> translateOldRulesFileToNewIdentifiers(File oldRulesFile, ApplicationType applicationType) {
|
||||
|
||||
return translateOldRulesFileToNewIdentifiers(oldRulesFile.toString(), applicationType);
|
||||
}
|
||||
|
||||
|
||||
public Set<RuleIdentifier> translateOldRulesFileToNewIdentifiers(String oldRulesFile, ApplicationType applicationType) {
|
||||
|
||||
return translateOldRulesStringToNewIdentifiers(RuleFileIO.getRulesString(oldRulesFile), applicationType);
|
||||
}
|
||||
|
||||
|
||||
public Set<RuleIdentifier> translateEscapedOldRulesStringToNewIdentifiers(String escapedOldRulesString, ApplicationType applicationType) {
|
||||
|
||||
return translateOldRulesStringToNewIdentifiers(RuleFileIO.unescapeAndUnWrap(escapedOldRulesString), applicationType);
|
||||
}
|
||||
|
||||
|
||||
public Set<RuleIdentifier> translateOldRulesStringToNewIdentifiers(String oldRulesString, ApplicationType applicationType) {
|
||||
|
||||
List<OldRule> oldRules = parseOldRules(oldRulesString);
|
||||
List<OldRulesCsvRecord> records = getOldRulesCsvRecords(RuleManagementResources.getOldRulesCsvInputStream());
|
||||
Map<OldRule, List<RuleIdentifier>> translationPairs = new HashMap<>();
|
||||
for (OldRule oldRule : oldRules) {
|
||||
List<RuleIdentifier> translatedIdentifiers = records.stream()
|
||||
.filter(oldRulesCsvRecord -> oldRulesCsvRecord.code().equals(oldRule.code()))
|
||||
.map(OldRulesCsvRecord::translatesTo)
|
||||
.findAny()
|
||||
.orElse(Collections.emptyList());
|
||||
translationPairs.put(oldRule, translatedIdentifiers);
|
||||
}
|
||||
boolean allTranslated = true;
|
||||
for (OldRule oldRule : translationPairs.keySet()) {
|
||||
if (translationPairs.get(oldRule).isEmpty()) {
|
||||
allTranslated = false;
|
||||
records.add(new OldRulesCsvRecord(records.size(), oldRule.code(), oldRule.name(), Collections.emptyList()));
|
||||
System.out.printf(
|
||||
"Rule %s has not been translated yet! %nIt has been added to the bottom of the old_rules_with_translations.csv file. To continue, translate the rule and enter its identifier in the csv, then try again!%n",
|
||||
oldRule.name());
|
||||
}
|
||||
}
|
||||
if (!allTranslated) {
|
||||
String formattedAsCsv = formatAsCsv(records);
|
||||
String fileLocation = RuleManagementResources.createTempOldRulesCsv(formattedAsCsv);
|
||||
System.out.printf("CSV File with updated values is located at %s%n", fileLocation);
|
||||
throw new IllegalArgumentException("Non translated Rule found!");
|
||||
}
|
||||
RuleFileBluePrint bluePrint = RuleFileParser.buildBluePrintFromAllRulesFile(applicationType);
|
||||
|
||||
translationPairs.forEach((key, value) -> System.out.printf("Rule %s will be translated to %s \n",
|
||||
key.name(),
|
||||
String.format("%s: %s",
|
||||
value,
|
||||
value.stream()
|
||||
.map(bluePrint::findRuleByIdentifier)
|
||||
.flatMap(Collection::stream)
|
||||
.map(BasicRule::name)
|
||||
.toList())));
|
||||
|
||||
return Stream.concat(//
|
||||
Stream.of(RuleIdentifier.fromString("X"), RuleIdentifier.fromString("FA"), RuleIdentifier.fromString("LDS"), RuleIdentifier.fromString("MAN")),//
|
||||
translationPairs.values()
|
||||
.stream()
|
||||
.flatMap(Collection::stream))
|
||||
.map(ruleIdentifier -> new RuleIdentifier(ruleIdentifier.type(), ruleIdentifier.unit(), null))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public String formatAsCsv(List<OldRulesCsvRecord> records) {
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setHeader(HEADERS.toArray(String[]::new)).build();
|
||||
try (CSVPrinter printer = new CSVPrinter(sw, csvFormat)) {
|
||||
for (OldRulesCsvRecord record : records) {
|
||||
printer.printRecord(Stream.of(record.id, RuleFileIO.escapeAndWrap(record.names), RuleFileIO.escapeAndWrap(record.code), record.translatesTo));
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private List<OldRule> parseOldRules(String oldRuleString) {
|
||||
|
||||
DrlParser parser = new DrlParser(LanguageLevelOption.DRL6);
|
||||
PackageDescr packageDescr = parser.parse(false, oldRuleString);
|
||||
List<OldRule> oldRules = new LinkedList<>();
|
||||
for (RuleDescr rule : packageDescr.getRules()) {
|
||||
if (!rule.isRule()) {
|
||||
continue;
|
||||
}
|
||||
oldRules.add(OldRule.fromRuleDescr(rule, oldRuleString));
|
||||
}
|
||||
return oldRules;
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public List<OldRulesCsvRecord> getOldRulesCsvRecords(InputStream allRulesCsvInputStream) {
|
||||
|
||||
List<OldRulesCsvRecord> parsedRecords = new LinkedList<>();
|
||||
try (Reader reader = new InputStreamReader(allRulesCsvInputStream)) {
|
||||
Iterable<CSVRecord> records = CSVFormat.DEFAULT.withHeader().withSkipHeaderRecord().parse(reader);
|
||||
for (CSVRecord record : records) {
|
||||
String[] values = record.values();
|
||||
parsedRecords.add(new OldRulesCsvRecord(Long.parseLong(values[0]),
|
||||
RuleFileIO.unescapeAndUnWrap(values[2]),
|
||||
RuleFileIO.unescapeAndUnWrap(values[1]),
|
||||
parseRuleIdentifiers(values[3])));
|
||||
}
|
||||
}
|
||||
return parsedRecords;
|
||||
}
|
||||
|
||||
|
||||
private List<RuleIdentifier> parseRuleIdentifiers(String value) {
|
||||
|
||||
String cleanedValue = value;
|
||||
if (cleanedValue.startsWith("[")) {
|
||||
cleanedValue = cleanedValue.substring(1);
|
||||
}
|
||||
if (cleanedValue.endsWith("]")) {
|
||||
cleanedValue = cleanedValue.substring(0, cleanedValue.length() - 1);
|
||||
}
|
||||
if (cleanedValue.isEmpty() || cleanedValue.isBlank()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<RuleIdentifier> ruleIdentifiers = new LinkedList<>();
|
||||
for (String identifier : cleanedValue.split(", ")) {
|
||||
ruleIdentifiers.add(RuleIdentifier.fromString(identifier));
|
||||
}
|
||||
return ruleIdentifiers;
|
||||
}
|
||||
|
||||
|
||||
private List<Boolean> parseBooleanList(String[] values) {
|
||||
|
||||
return Arrays.stream(values)
|
||||
.map(Boolean::parseBoolean)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
public record OldRulesCsvRecord(long id, String code, String names, List<RuleIdentifier> translatesTo) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,176 +0,0 @@
|
||||
package com.knecon.fforesight.utility.rules.management.translation;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.knecon.fforesight.utility.rules.management.RuleManagementResources;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileFactory;
|
||||
import com.knecon.fforesight.utility.rules.management.factory.RuleFileParser;
|
||||
import com.knecon.fforesight.utility.rules.management.models.ApplicationType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.BasicRule;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleIdentifier;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleType;
|
||||
import com.knecon.fforesight.utility.rules.management.models.RuleUnit;
|
||||
import com.knecon.fforesight.utility.rules.management.utils.RuleFileIO;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@SuppressWarnings("PMD")
|
||||
class OldRulesParserTest {
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
@Disabled
|
||||
public void translateOldRulesToNewIdentifiersTest() {
|
||||
|
||||
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("efsa_regulation_rules.txt")) {
|
||||
String oldRulesString = new String(inputStream.readAllBytes());
|
||||
Set<RuleIdentifier> identifiers = OldRulesParser.translateEscapedOldRulesStringToNewIdentifiers(oldRulesString, ApplicationType.RM);
|
||||
System.out.println(identifiers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
@Disabled
|
||||
public void translateMoreOldRules() {
|
||||
|
||||
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("basf/demo/table_demo.drl")) {
|
||||
String oldRulesString = new String(inputStream.readAllBytes());
|
||||
Set<RuleIdentifier> identifiers = OldRulesParser.translateOldRulesStringToNewIdentifiers(oldRulesString, ApplicationType.RM);
|
||||
System.out.println(identifiers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void printTranslationsTest() {
|
||||
|
||||
List<OldRulesParser.OldRulesCsvRecord> records = OldRulesParser.getOldRulesCsvRecords(RuleManagementResources.getOldRulesCsvInputStream());
|
||||
List.of(RuleType.fromString("SYN"), RuleType.fromString("CBI"), RuleType.fromString("PII"), RuleType.fromString("ETC"), RuleType.fromString("AI"))
|
||||
.forEach(type -> {
|
||||
List<RuleUnit> rulesOfClass = RuleFileParser.buildBluePrintFromAllRulesFile(ApplicationType.RM).findRuleClassByType(type)
|
||||
.orElseThrow().ruleUnits();
|
||||
rulesOfClass.forEach(unit -> printOldRulesThatTranslatesToNewRule(unit, records));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void printOldRulesThatTranslatesToNewRule(RuleUnit ruleUnit, List<OldRulesParser.OldRulesCsvRecord> records) {
|
||||
|
||||
if (ruleUnit.rules().isEmpty()) {
|
||||
System.out.println("Rule unit empty, skipping!\n");
|
||||
return;
|
||||
}
|
||||
RuleIdentifier identifier = ruleUnit.rules()
|
||||
.get(0).identifier();
|
||||
RuleIdentifier unitIdentifier = new RuleIdentifier(identifier.type(), identifier.unit(), null);
|
||||
String oldNames = records.stream()
|
||||
.filter(r -> r.translatesTo()
|
||||
.stream()
|
||||
.anyMatch(i -> i.matches(unitIdentifier)))
|
||||
.map(OldRulesParser.OldRulesCsvRecord::names)
|
||||
.map(OldRulesParserTest::removeIdFromName)
|
||||
.distinct()
|
||||
.collect(Collectors.joining(", "));
|
||||
System.out.println(unitIdentifier.toRuleUnitString() + " " + ruleUnit.rules()
|
||||
.stream()
|
||||
.map(BasicRule::name)
|
||||
.collect(Collectors.joining(", ")));
|
||||
System.out.println("translate from");
|
||||
System.out.println(oldNames);
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
|
||||
private static String removeIdFromName(String name) {
|
||||
|
||||
String[] values = name.split(":");
|
||||
return String.join(":", Arrays.copyOfRange(values, 1, values.length));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
@SneakyThrows
|
||||
public void findAllCustomerRuleFilesInDossierTemplatesRepoAndTranslate() {
|
||||
|
||||
String dossierTemplatesRepo = getClass().getClassLoader().getResource("pilot/EFSA_sanitisation_GFL_v1").getFile();
|
||||
RuleFileIO.streamAllRuleFilesInDirectory(Path.of(dossierTemplatesRepo))
|
||||
.map(e -> OldRulesParser.translateOldRulesFileToNewIdentifiers(e, ApplicationType.RM))
|
||||
.map(e -> RuleFileFactory.createFileFromIdentifiers(e, ApplicationType.RM))
|
||||
.peek(System.out::println)
|
||||
.map(RuleFileIO::escapeAndWrap)
|
||||
.forEach(System.out::println);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
@SneakyThrows
|
||||
public void findAllRuleFilesInDossierTemplatesRepoAndTranslate() {
|
||||
|
||||
String dossierTemplatesRepo = getClass().getClassLoader().getResource("business-logic/Syngenta_RSS").getFile();
|
||||
RuleFileIO.streamAllRuleFilesInDirectory(Path.of(dossierTemplatesRepo))
|
||||
.map(e -> OldRulesParser.translateOldRulesFileToNewIdentifiers(e, ApplicationType.DM))
|
||||
.map(e -> RuleFileFactory.createFileFromIdentifiers(e, ApplicationType.DM))
|
||||
.peek(System.out::println)
|
||||
.map(RuleFileIO::escapeAndWrap)
|
||||
.forEach(System.out::println);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
@SneakyThrows
|
||||
public void translateDossierTemplatesV2() {
|
||||
|
||||
// String dossierTemplatesRepo = "/home/aoezyetimoglu/repositories/RED/dossier-templates-v2/";
|
||||
// Stream.of(Files.walk(Path.of(dossierTemplatesRepo + "dev")), Files.walk(Path.of(dossierTemplatesRepo + "docu")), Files.walk(Path.of(dossierTemplatesRepo + "qa")))
|
||||
String dossierTemplatesRepo = "/home/aoezyetimoglu/repositories/PROJECTMANAGEMENT/Syngenta/business-logic/";
|
||||
Stream.of(Files.walk(Path.of(dossierTemplatesRepo + "dev")),
|
||||
Files.walk(Path.of(dossierTemplatesRepo + "dev-v2")),
|
||||
Files.walk(Path.of(dossierTemplatesRepo + "prod-cp-eu-reg")),
|
||||
Files.walk(Path.of(dossierTemplatesRepo + "prod-cp-global-reg")),
|
||||
Files.walk(Path.of(dossierTemplatesRepo + "prod-seeds-reg"))
|
||||
//
|
||||
)
|
||||
.flatMap(Function.identity())//
|
||||
.filter(path -> path.getFileName().toString().equals("rules.drl"))//
|
||||
.map(Path::toFile)//
|
||||
.forEach(this::translateOldRuleFile);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private void translateOldRuleFile(File oldRulesFile) {
|
||||
|
||||
Set<RuleIdentifier> identifiers = OldRulesParser.translateOldRulesFileToNewIdentifiers(oldRulesFile, ApplicationType.RM);
|
||||
String newRulesString = RuleFileFactory.createFileFromIdentifiers(identifiers, ApplicationType.RM);
|
||||
String result = RuleFileIO.escapeAndWrap(newRulesString);
|
||||
|
||||
try (var out = new FileOutputStream(oldRulesFile)) {
|
||||
out.write(result.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user