Commit ed818c79 authored by Jörg Richter's avatar Jörg Richter

Fix: client-sync for newly created role types (#207)

parent 991c2dd5
Pipeline #6508 passed with stages
in 3 minutes and 26 seconds
......@@ -9,7 +9,7 @@ import 'font-awesome/css/font-awesome.css'
import './element-ui'
import './websocket'
console.log('[DMX] 2019/05/21')
console.log('[DMX] 2019/05/22')
// 1) Init dm5 library
// The dm5 library must be inited *before* the dm5-webclient component is instantiated.
......
......@@ -287,7 +287,7 @@ public class WebservicePlugin extends PluginActivator {
@GET
@Path("/assoctype/all")
public List<AssociationType> getAssociationAllTypes() {
public List<AssociationType> getAllAssociationTypes() {
return dmx.getAllAssociationTypes();
}
......@@ -324,7 +324,9 @@ public class WebservicePlugin extends PluginActivator {
@Path("/roletype")
@Transactional
public Topic createRoleType(TopicModel model) {
return dmx.createRoleType(model);
Topic roleType = dmx.createRoleType(model);
me.newRoleType(roleType);
return roleType;
}
......@@ -525,33 +527,32 @@ public class WebservicePlugin extends PluginActivator {
// ---
private void newTopicType(TopicType topicType) {
try {
messageToAllButOne(new JSONObject()
.put("type", "newTopicType")
.put("args", new JSONObject()
.put("topicType", topicType.toJSON())
)
);
} catch (Exception e) {
logger.log(Level.WARNING, "Error while sending a \"newTopicType\" message:", e);
}
newType(topicType, "topicType", "newTopicType");
}
private void newAssocType(AssociationType assocType) {
newType(assocType, "assocType", "newAssocType");
}
private void newRoleType(Topic roleType) {
newType(roleType, "roleType", "newRoleType");
}
// ---
private void newType(Topic type, String argName, String messageType) {
try {
messageToAllButOne(new JSONObject()
.put("type", "newAssocType")
.put("type", messageType)
.put("args", new JSONObject()
.put("assocType", assocType.toJSON())
.put(argName, type.toJSON())
)
);
} catch (Exception e) {
logger.log(Level.WARNING, "Error while sending a \"newAssocType\" message:", e);
logger.log(Level.WARNING, "Error while sending a \"" + messageType + "\" message:", e);
}
}
// ---
private void messageToAllButOne(JSONObject message) {
dmx.getWebSocketsService().messageToAllButOne(request, pluginUri, message.toString());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment