-
Notifications
You must be signed in to change notification settings - Fork 49
Feature/simple rules #470
base: main
Are you sure you want to change the base?
Feature/simple rules #470
Conversation
…he aca-py event handler Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
… to a partner Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
Signed-off-by: Philipp Etschel <[email protected]>
…-partner-agent into feature/simple-rules Signed-off-by: Philipp Etschel <[email protected]> # Conflicts: # backend/README.md # backend/pom.xml
Signed-off-by: Philipp Etschel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some minor suggestions.
|
||
@Inject | ||
@Named("rules") | ||
EventHandler rulesEventHandler; | ||
|
||
@Post(WEBHOOK_CONTROLLER_PATH + "/{eventType}") | ||
public void logEvent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename method? It does not solely log.
accept event? consume?
abstract boolean apply(EventContext ctx); | ||
|
||
@SuppressWarnings("unused") | ||
private String type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this field? It's not used via accessors and builders. The database stores Triggers as jsonb.
How about pulling this field into the subclasses, if there is a purpose for it. And then change Trigger to an interface, which is the also a functional one. Or does that create serialization issues?
abstract void run(EventContext ctx); | ||
|
||
@SuppressWarnings("unused") | ||
private String type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as Trigger.type?
|
||
@Override | ||
public boolean apply(EventContext ctx) { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a TODO, that this can be implemented as soon as proof templates are available?
public static final String CONNECTION_TRIGGER_NAME = "connection"; | ||
public static final String PROOF_RECEIVED_TRIGGER_NAME = "proof_received"; | ||
|
||
abstract boolean apply(EventContext ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply is a very generic name.
shallApplyAction
applicableRule
@Override | ||
public boolean apply(EventContext ctx) { | ||
ConnectionRecord connRec = ctx.getConnRec(); | ||
boolean apply = connRec != null && ConnectionState.REQUEST.equals(connRec.getState()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean isRequest = connRec != null && ConnectionState.REQUEST.equals(connRec.getState());
boolean roleMatches = role==null || connRec != null && role.equals(connRec.getTheirRole());
return isRequest && roleMatches;
ConnectionRecord connRec = ctx.getConnRec(); | ||
boolean apply = connRec != null && ConnectionState.REQUEST.equals(connRec.getState()); | ||
if (role != null) { | ||
apply = apply && role.equals(connRec.getTheirRole()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connRec could be null?
private Trigger trigger; | ||
private Action action; | ||
|
||
@JsonTypeInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) to store the type information. Is there a decision, which one to use?
|
||
public List<RulesData> getAll() { | ||
List<RulesData> result = new ArrayList<>(); | ||
rr.findAll().forEach(active -> result.add(RulesData.fromActive(active))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return rr.findAll().stream().map(RulesData::fromActive).collect(Collectors.toList());
Partner p = ModelBuilder.buildDefaultPartner().setConnectionId(connectionId); | ||
pr.save(p); | ||
|
||
rs.add(new RulesData.Trigger.ConnectionTrigger(), new RulesData.Action.TagConnection()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe put a special action for the rule to verify it's execution? There are mutltiple path, where the ruleExecution is stopped before that.
Signed-off-by: Philipp Etschel <[email protected]> # Conflicts: # backend/business-partner-agent/pom.xml # backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/AriesWebhookController.java # backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/ConnectionManager.java
Signed-off-by: Philipp Etschel <[email protected]>
https://hackmd.io/2m16i56sTtmYi9tVuklVVw?view