use of org.kie.workbench.common.services.shared.kmodule.KSessionModel in project kie-wb-common by kiegroup.
the class KBaseConverter method marshal.
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
KBaseModel kBase = (KBaseModel) value;
writer.addAttribute("name", kBase.getName());
writer.addAttribute("default", Boolean.toString(kBase.isDefault()));
if (kBase.getEventProcessingMode() != null) {
writer.addAttribute("eventProcessingMode", kBase.getEventProcessingMode().getMode());
}
if (kBase.getEqualsBehavior() != null) {
writer.addAttribute("equalsBehavior", kBase.getEqualsBehavior().toString());
}
if (kBase.getDeclarativeAgenda() != null) {
writer.addAttribute("declarativeAgenda", kBase.getDeclarativeAgenda().toString());
}
if (kBase.getScope() != null) {
writer.addAttribute("scope", kBase.getScope());
}
if (!kBase.getPackages().isEmpty()) {
StringBuilder buf = new StringBuilder();
boolean first = true;
for (String pkg : kBase.getPackages()) {
if (first) {
first = false;
} else {
buf.append(", ");
}
buf.append(pkg);
}
writer.addAttribute("packages", buf.toString());
}
if (!kBase.getIncludes().isEmpty()) {
StringBuilder sb = new StringBuilder();
boolean insertComma = false;
for (String include : kBase.getIncludes()) {
if (insertComma) {
sb.append(", ");
}
sb.append(include);
if (!insertComma) {
insertComma = true;
}
}
writer.addAttribute("includes", sb.toString());
}
for (KSessionModel kSessionModel : kBase.getKSessions()) {
writeObject(writer, context, "ksession", kSessionModel);
}
}
use of org.kie.workbench.common.services.shared.kmodule.KSessionModel in project kie-wb-common by kiegroup.
the class KSessionConverter method unmarshal.
public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
final KSessionModel kSession = new KSessionModel();
kSession.setName(reader.getAttribute("name"));
kSession.setDefault("true".equals(reader.getAttribute("default")));
String kSessionType = reader.getAttribute("type");
kSession.setType(kSessionType != null ? kSessionType : "stateful");
String clockType = reader.getAttribute("clockType");
if (clockType != null) {
kSession.setClockType(ClockTypeOption.get(clockType));
}
String scope = reader.getAttribute("scope");
if (scope != null) {
kSession.setScope(scope);
}
readNodes(reader, new AbstractXStreamConverter.NodeReader() {
public void onNode(HierarchicalStreamReader reader, String name, String value) {
if ("listeners".equals(name)) {
while (reader.hasMoreChildren()) {
reader.moveDown();
kSession.getListeners().add(readObject(reader, context, ListenerModel.class));
reader.moveUp();
}
} else if ("workItemHandlers".equals(name)) {
kSession.getWorkItemHandelerModels().addAll(readObjectList(reader, context, WorkItemHandlerModel.class));
}
// else if ("consoleLogger".equals(name)){
// kSession.setLogger(readObject(reader, context, ConsoleLogger.class));
// } else if ("fileLogger".equals(name)){
// kSession.setLogger(readObject(reader, context, FileLogger.class));
// }
}
});
return kSession;
}
use of org.kie.workbench.common.services.shared.kmodule.KSessionModel in project kie-wb-common by kiegroup.
the class KSessionConverter method marshal.
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
KSessionModel kSession = (KSessionModel) value;
writer.addAttribute("name", kSession.getName());
writer.addAttribute("type", kSession.getType());
writer.addAttribute("default", Boolean.toString(kSession.isDefault()));
if (kSession.getClockType() != null) {
writer.addAttribute("clockType", kSession.getClockType().getClockTypeAsString());
}
if (kSession.getScope() != null) {
writer.addAttribute("scope", kSession.getScope().toString());
}
writeObjectList(writer, context, "workItemHandlers", "workItemHandler", kSession.getWorkItemHandelerModels());
if (!kSession.getListeners().isEmpty()) {
writer.startNode("listeners");
for (ListenerModel listener : kSession.getListeners()) {
writeObject(writer, context, listener.getKind().toString(), listener);
}
writer.endNode();
}
}
Aggregations