Skip to content

Commit 48f91b5

Browse files
authored
Merge pull request #41 from reTHINK-project/develop
dev to master
2 parents 917fe04 + 49b9c21 commit 48f91b5

39 files changed

Lines changed: 3430 additions & 376 deletions

docs/CRM/readme.md

Lines changed: 88 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,70 @@
11
## CRM Hyperty
22

3-
The CRM hyperty manages CRM Agents and forwards tickets to available Agents.
3+
The CRM hyperty manages CRM Agents, forwards tickets to available Agents.
4+
5+
It also provides functionalities to support data streams synchronisation setup between Agents and Users without requiring to have both online simultaneously.
46

57
### Configuration:
68

7-
* `agents`: list of JSON with agent address and associated registration code.
89

9-
`{address: '<agent adddress>',
10-
code: '<agent code>'}`
10+
* `agents`: list of JSON with agent registration codes.
11+
12+
`{code: '<agent code>'}`
13+
1114

1215
### Storage
1316

14-
The Hyperty handles AgentsPool data collection and associated tickets. The first time the hyperty is executed the collection is initialised based on the `config.agents` info.
17+
The Hyperty handles the `agents` data collection and associated tickets. The first time the hyperty is executed the collection is initialised based on the `config.agents` info.
18+
19+
**Agents Collection**
1520

1621
```
1722
{
18-
address: <address>,
23+
address: <url of agent's Group Chat Manager hyperty>,
1924
code: <code>,
2025
user: <cguid of the user registered with this agent address>,
21-
tickets: [{
22-
user: <cguid of user that created the ticket>
23-
status: <pending/ongoing/closed>,
24-
creation: <date>,
25-
lastModified: <data>,
26-
message: <received invitation msg>
27-
}
28-
}],
26+
tickets: [<ticketUrl>],
2927
openedTickets: <int>,
3028
status: <online/offline>
31-
3229
}
3330
```
3431

32+
**Tickets Collection**
33+
34+
```
35+
{
36+
url: <data object url>,
37+
user: <cguid of user that created the ticket>,
38+
status: <new (still not accepted)|pending|ongoing (accepted by agent)/closed>,
39+
created: <date>,
40+
lastModified: <data>,
41+
message: <received invitation msg>,
42+
agent: <cguid>
43+
}
44+
```
45+
46+
**pendingSubscriptions data collection**
47+
48+
```
49+
{
50+
user:<cguid>,
51+
message: <subscribeMsg>
52+
}
53+
```
54+
55+
56+
### resolve-role handler
57+
58+
**handlers:** /resolve-role
59+
60+
**message:**
61+
62+
Message containing agent code.
63+
64+
**logic:**
65+
66+
It Checks that received `code` is in the `config.agents` array and if there is still no user allocated in the `agents` collection, it returns `role: "agent"`, otherwise returns `role: "user"`.
67+
3568
### Agent Registration handler
3669

3770
**handlers:** CRM Address.
@@ -42,35 +75,66 @@ Invitation message sent by Wallet Manager to observers.
4275

4376
**logic:**
4477

45-
It Checks that received `body.code` is in the `config.agents` array and if there is still no user allocated in the AgentsPool, it updates it the new user agent CGUID.
78+
It Checks that received `body.code` is in the `config.agents` array and if there is still no user allocated in the `agents` collection, it updates it the new user agent CGUID and its address.
4679

4780
### New Ticket handlers
4881

49-
**handlers:** CRM Address + `/agents`.
82+
**handler:** CRM Address + `/tickets`.
83+
84+
**message:**
85+
86+
Standard create message sent to [invite Data Object observers](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#observer-invitation).
87+
88+
**logic**
89+
90+
It forwards the message to all agents (`msg.to = <agent address>` and `eb.send(<cguid>, msg)` ) and adds the new ticket to the `tickets` collection (status: new).
91+
92+
There is a timer to process `new` tickets running every X seconds (eg 300 secs) to change their status to `pending`, in case no agent accepts new tickets ie if `timeNow - createdData > x`.
93+
94+
### Update Tickets
95+
96+
**handler:** CRM Address + `/tickets`.
5097

5198
**message:**
5299

53-
Standard create message sent to invite Data Object observers.
100+
```javascript
101+
{
102+
type: "update",
103+
from: "object url",
104+
identity: <identity>,
105+
body: {
106+
status: "new-participant|closed",
107+
participant: <hyperty-url>
108+
}
109+
}
110+
```
54111

55112
**logic**
56113

57-
1- It forwards the message to all agents and add the new ticket to newTickets array.
114+
`status: "new-participant"`: checks the ticket is still in the `new` or `pending` status and belongs to the user then it executes the `ticketAccepted` function. Otherwise, the message is ignored.
58115

59-
2- The first agent executes `ticketAccepted` function: the ticket is allocated to the agent in the agentsPool collection, the ticket is removed from the pendingTickets array and a delete message is sent to all remaining invited Agents (todo: specify this new message that should be similar to delete msg used to remove user from chat).
116+
**`ticketAccepted` function:** the ticket is associated to the agent, its status changed to `ongoing` and a delete message is sent to all remaining invited Agents. The delete message is similar to this [one](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#delete-data-object-requested-by-reporter):
60117

61-
3- In case no agent accepts the ticket, ie a timeout message is received for all invited Agents the message is moved from newTickets array to pendingTickets array.
118+
```javascript
119+
"type" : "delete",
120+
"from" : "CRM Address",
121+
"to" : "Agente Hyperty URL",
122+
"body" : { "resource" : "<ObjectURL>" }
123+
```
124+
125+
`status: "closed"`: Checks if ticket belongs to user, change its status to closed and update collection.
62126

63127
### status handler
64128

65-
**handler:** <runtime>/status.
129+
**handler:** CRM Address + `/status`.
66130

67131
**message:**
68132

69133
Status event message sent by the Vertx Runtime Registry.
70134

71135
**logic**
72136

73-
For all `live` events received it checks if the CGUID is associated to any agent and forwards to it pending tickets. Execute funtion `ticketAccepted` for 200 ok accepting messages.
137+
For all `online` events received it checks if the CGUID is associated to any agent and forwards to it pending tickets. Execute funtion `ticketAccepted` for 200 ok accepting messages.
74138

75139

76140
### unregistration of Agents
@@ -89,6 +153,5 @@ from: <wallet observer hyperty address>
89153

90154
**logic**
91155

92-
It checks there is an Agent for the identity, changing the status to "inactive" and moving its pending / opened tickets to other agents.
93-
156+
It checks there is an Agent for the identity, changing the status to "offline" and moving its opened tickets to other agents.
94157

docs/offlineSubscriptionManager/readme.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,64 @@ Provides functionalities to support data streams synchronisation setup between p
55

66
### Storage
77

8-
The Hyperty handles pendingSubscriptions data collection.
8+
The Hyperty handles two collections:
9+
10+
**pendingSubscriptions data collection**
11+
12+
```
13+
{
14+
user:<cguid>,
15+
message: <subscribeMsg>
16+
}
17+
```
18+
19+
**dataObjectsRegistry data collection**
920

1021
```
1122
{
12-
<cguid>: {<subscribeMsg>
23+
user:<cguid>,
24+
message: <inviteMsg>
1325
}
1426
```
1527

28+
### Data Object Registration handler
29+
30+
**handlers:** <Hyperty Address>/register.
31+
32+
**message:**
33+
34+
Forward of [Data Object Creation Message](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#hyperty-data-object-creation) message sent by runtime sync manager.
35+
36+
**logic:**
37+
38+
Stores message at dataObjectsRegistry data collection and it replies with 200 OK.
39+
40+
### Data Object Unregistration handler
41+
42+
**handlers:** <Hyperty Address>/register.
43+
44+
**message:**
45+
46+
Forward of [Data Object Delete Message](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#delete-data-object-requested-by-reporter) message sent by runtime sync manager.
47+
48+
**logic:**
49+
50+
Removes data object message from dataObjectsRegistry data collection and it replies with 200 OK.
51+
1652
### Subscription handler
1753

18-
**handlers:** Hyperty Address.
54+
**handlers:** Hyperty Address /subscription.
1955

2056
**message:**
2157

22-
Forward of [Subscribe](https://rethink-project.github.io/specs/messages/data-sync-messages/#observer-subscription-request-sent-to-data-object-subscription-handler) message sent by runtime sync manager as specified at .
58+
Forward of [Subscribe](https://rethink-project.github.io/specs/messages/data-sync-messages/#observer-subscription-request-sent-to-data-object-subscription-handler) message sent by runtime sync manager.
2359

2460
**logic:**
2561

26-
1- It replies with 200 OK.
62+
1- It queries the Data Objects Registry collection for the data object URL to be subscribed (`message.body.body.resource`), and replies with 200 OK where `reply.body.value = message.body.body.value`.
63+
2764
2- Queries the registry about cguid status.
65+
2866
3- If online it executes the `processPendingSubscription(subscribeMsg)` otherwise it stores it in the pendingSubscriptions collection.
2967

3068
### status handler
@@ -37,9 +75,10 @@ Status event message sent by the Vertx Runtime Registry.
3775

3876
**logic**
3977

40-
For all `live` events received it checks if the CGUID is associated to any pending subscription and if yes the `processPendingSubscription(subscribeMsg)` function is executed.
78+
For all `online` events received it checks if the CGUID is associated to any pending subscription at pendingSubscriptions collection and if yes the `processPendingSubscription(subscribeMsg)` function is executed
79+
4180

4281
### `processPendingSubscription(subscribeMsg)`
4382

44-
Subscribe message is forwarded to `subscribeMsg.to` and in case a 200 Ok response is received the `subscribeMsg` is removed from pendingSubscription collection.
83+
Subscribe message is forwarded to `subscribeMsg.to` and in case a 200 Ok response is received it executes the `subscribeMsg` is removed from pendingSubscription collection.
4584

docs/registry.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,24 @@ body: {
7575
}
7676
}
7777
```
78+
### create status entry
79+
80+
81+
**handler:** <runtime-address> + `/status`.
82+
83+
**message:**
84+
85+
```javascript
86+
{
87+
type: "create",
88+
body: {
89+
resource: <cguid>,
90+
status: "online|offline>"
91+
}
92+
}
93+
```
94+
95+
**logic**
96+
97+
It create the status entry with received info.
7898

docs/wallet-manager/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ A new entry is created in the Wallet Manager store.
8383

8484
An invitation is sent to `config.observers`.
8585

86+
If there is an associated code for the user, the `resolve-role` endpoint is called, which retrieves the following response:
87+
```
88+
role: <role, e.g. agent, user>
89+
```
90+
8691
### Wallet address request
8792

8893
**handler:** wallet manager address.

java-mongo-script/.classpath

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="test" value="true"/>
17+
<attribute name="optional" value="true"/>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
22+
<attributes>
23+
<attribute name="test" value="true"/>
24+
<attribute name="maven.pomderived" value="true"/>
25+
</attributes>
26+
</classpathentry>
27+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
28+
<attributes>
29+
<attribute name="maven.pomderived" value="true"/>
30+
</attributes>
31+
</classpathentry>
32+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
33+
<attributes>
34+
<attribute name="maven.pomderived" value="true"/>
35+
</attributes>
36+
</classpathentry>
37+
<classpathentry kind="output" path="target/classes"/>
38+
</classpath>

java-mongo-script/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>mongo-script</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
5+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6+
org.eclipse.jdt.core.compiler.compliance=1.8
7+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
13+
org.eclipse.jdt.core.compiler.release=disabled
14+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

0 commit comments

Comments
 (0)