use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.
the class KnowledgeBaseItemPresenter method addNewIncludedKnowledgeBase.
public void addNewIncludedKnowledgeBase() {
includedKnowledgeBasesListPresenter.add(new SingleValueItemObjectModel(""));
parentPresenter.fireChangeEvent();
;
}
use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.
the class KnowledgeBaseItemPresenter method addPackage.
public void addPackage() {
packageListPresenter.add(new SingleValueItemObjectModel(""));
parentPresenter.fireChangeEvent();
}
use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel 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 (SingleValueItemObjectModel pkg : kBase.getPackages()) {
if (first) {
first = false;
} else {
buf.append(", ");
}
buf.append(pkg.getValue());
}
writer.addAttribute("packages", buf.toString());
}
if (!kBase.getIncludes().isEmpty()) {
StringBuilder sb = new StringBuilder();
boolean insertComma = false;
for (SingleValueItemObjectModel include : kBase.getIncludes()) {
if (insertComma) {
sb.append(", ");
}
sb.append(include.getValue());
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.SingleValueItemObjectModel in project kie-wb-common by kiegroup.
the class KBaseConverter method unmarshal.
public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) {
final KBaseModel kBase = new KBaseModel();
kBase.setName(reader.getAttribute("name"));
kBase.setDefault("true".equals(reader.getAttribute("default")));
String eventMode = reader.getAttribute("eventProcessingMode");
if (eventMode != null) {
kBase.setEventProcessingMode(EventProcessingOption.determineEventProcessingMode(eventMode));
}
String equalsBehavior = reader.getAttribute("equalsBehavior");
if (equalsBehavior != null) {
kBase.setEqualsBehavior(AssertBehaviorOption.determineAssertBehaviorMode(equalsBehavior));
}
String declarativeAgenda = reader.getAttribute("declarativeAgenda");
if (declarativeAgenda != null) {
kBase.setDeclarativeAgenda(DeclarativeAgendaOption.determineDeclarativeAgendaMode(declarativeAgenda));
}
String scope = reader.getAttribute("scope");
if (scope != null) {
kBase.setScope(scope.trim());
}
String pkgs = reader.getAttribute("packages");
if (pkgs != null) {
for (String pkg : pkgs.split(",")) {
kBase.addPackage(new SingleValueItemObjectModel(pkg.trim()));
}
}
String includes = reader.getAttribute("includes");
if (includes != null) {
for (String include : includes.split(",")) {
kBase.addInclude(new SingleValueItemObjectModel(include.trim()));
}
}
readNodes(reader, new AbstractXStreamConverter.NodeReader() {
public void onNode(HierarchicalStreamReader reader, String name, String value) {
if ("ksession".equals(name)) {
KSessionModel kSession = readObject(reader, context, KSessionModel.class);
kBase.getKSessions().add(kSession);
} else if ("includes".equals(name)) {
for (String include : readList(reader)) {
kBase.addInclude(new SingleValueItemObjectModel(include));
}
}
}
});
return kBase;
}
use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.
the class ListPresenterTest method testSetup.
@Test
public void testSetup() {
doNothing().when(listPresenter).addToListElement(any());
final List<SingleValueItemObjectModel> objs = Arrays.asList(new SingleValueItemObjectModel("foo"), new SingleValueItemObjectModel("bar"));
listPresenter.setup(mock(HTMLElement.class), objs, (a, b) -> {
});
assertEquals(objs, listPresenter.getObjectsList());
verify(listPresenter, times(2)).addToListElement(any());
}
Aggregations