RED-10200: refactor
This commit is contained in:
parent
6ad0367268
commit
c38edd0092
@ -377,6 +377,7 @@ public class DocumentTree {
|
||||
}
|
||||
|
||||
entity.computeRelations();
|
||||
entity.notifyEntityInserted();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -995,8 +995,8 @@ public class EntityCreationService {
|
||||
return Optional.empty(); // Entity has been resized, if there are duplicates they should be treated there
|
||||
}
|
||||
|
||||
addListenerToEntity(entity);
|
||||
node.getDocumentTree().addEntityToGraph(entity);
|
||||
insertToKieSession(entity);
|
||||
|
||||
entity.addEngines(engines);
|
||||
|
||||
@ -1422,8 +1422,8 @@ public class EntityCreationService {
|
||||
.ifPresent(e -> addDuplicateEntityToGraph(e, entity.getTextRange(), node));
|
||||
|
||||
} else {
|
||||
addListenerToEntity(entity);
|
||||
documentTree.addEntityToGraph(entity);
|
||||
insertToKieSession(entity);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1475,21 +1475,7 @@ public class EntityCreationService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a text entity into the kieSession for further processing.
|
||||
*
|
||||
* @param textEntity The merged text entity to insert.
|
||||
*/
|
||||
public void insertToKieSession(TextEntity textEntity) {
|
||||
|
||||
if(kieSessionUpdater != null) {
|
||||
kieSessionUpdater.insert(textEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(TextEntity textEntity) {
|
||||
private void addListenerToEntity(TextEntity textEntity) {
|
||||
|
||||
if(kieSessionUpdater != null) {
|
||||
textEntity.addEntityEventListener(kieSessionUpdater);
|
||||
|
||||
@ -28,7 +28,7 @@ import com.iqser.red.service.redaction.v1.server.logger.RulesLogger;
|
||||
import com.iqser.red.service.redaction.v1.server.logger.TrackingAgendaEventListener;
|
||||
import com.iqser.red.service.redaction.v1.server.model.NerEntities;
|
||||
import com.iqser.red.service.redaction.v1.server.model.dictionary.Dictionary;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.IEntity;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Image;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode;
|
||||
@ -121,14 +121,17 @@ public class EntityDroolsExecutionService {
|
||||
.flatMap(SemanticNode::streamAllSubNodes)
|
||||
.forEach(semanticNode -> {
|
||||
if (semanticNode instanceof Image image) {
|
||||
kieSessionUpdater.insert(image);
|
||||
image.addEntityEventListener(kieSessionUpdater);
|
||||
image.notifyEntityInserted();
|
||||
} else {
|
||||
kieSession.insert(semanticNode);
|
||||
}
|
||||
});
|
||||
|
||||
document.getEntities()
|
||||
.forEach(kieSessionUpdater::insert);
|
||||
for (TextEntity textEntity : document.getEntities()) {
|
||||
textEntity.addEntityEventListener(kieSessionUpdater);
|
||||
textEntity.notifyEntityInserted();
|
||||
}
|
||||
|
||||
document.getPages()
|
||||
.forEach(kieSession::insert);
|
||||
|
||||
@ -24,13 +24,6 @@ public class KieSessionUpdater implements EntityEventListener {
|
||||
KieSession kieSession;
|
||||
|
||||
|
||||
public void insert(IEntity entity) {
|
||||
|
||||
entity.addEntityEventListener(this);
|
||||
onEntityInserted(entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEntityInserted(IEntity entity) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user