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