Commit 9695c1a5 authored by Jörg Richter's avatar Jörg Richter

DMXObject API: setChildTopics() -> update() (#341)

BREAKING CHANGE

systems.dmx.core.DMXObject

change 1 method:

void setChildTopics(ChildTopicsModel childTopics)
->
void update(ChildTopicsModel updateModel)

Now update() is convenience that constructs a DMXObjectModel from a ChildTopicsModel and calls canonic update() with it.
parent 0bd515bc
Pipeline #9895 passed with stages
in 8 minutes and 17 seconds
......@@ -45,8 +45,6 @@ public interface DMXObject extends Identifiable, JSONEnabled {
ChildTopics getChildTopics();
void setChildTopics(ChildTopicsModel childTopics);
// ---
<O extends DMXObject> O loadChildTopics();
......@@ -73,6 +71,11 @@ public interface DMXObject extends Identifiable, JSONEnabled {
<M extends DMXObjectModel> void update(M updateModel);
/**
* Convenience that constructs a DMXObjectModel from a ChildTopicsModel and calls canonic update() with it.
*/
void update(ChildTopicsModel updateModel);
/**
* Note: this method is meant only for facet updates.
*/
......
......@@ -332,12 +332,12 @@ class ChildTopicsImpl implements ChildTopics {
// hierarchy. See the missingMultipleDispatch tests in JavaAPITest.java (in module dmx-test). ### still true?
private ChildTopics _updateOne(String compDefUri, RelatedTopicModel newChildTopic) {
parent.updateChildTopics(mf.newChildTopicsModel().set(compDefUri, newChildTopic));
parent.update(mf.newChildTopicsModel().set(compDefUri, newChildTopic));
return this;
}
private ChildTopics _updateMany(String compDefUri, RelatedTopicModel newChildTopic) {
parent.updateChildTopics(mf.newChildTopicsModel().add(compDefUri, newChildTopic));
parent.update(mf.newChildTopicsModel().add(compDefUri, newChildTopic));
return this;
}
......
......@@ -6,6 +6,7 @@ import systems.dmx.core.DMXType;
import systems.dmx.core.RelatedAssoc;
import systems.dmx.core.RelatedTopic;
import systems.dmx.core.model.ChildTopicsModel;
import systems.dmx.core.model.DMXObjectModel;
import systems.dmx.core.model.SimpleValue;
import org.codehaus.jettison.json.JSONObject;
......@@ -127,11 +128,6 @@ abstract class DMXObjectImpl implements DMXObject {
return new ChildTopicsImpl(model.childTopics, model, al);
}
@Override
public final void setChildTopics(ChildTopicsModel childTopics) {
model.updateChildTopics(childTopics);
}
// ---
@Override
......@@ -162,7 +158,12 @@ abstract class DMXObjectImpl implements DMXObject {
// === Updating ===
// Note: update() is implemented in sub-interfaces
// Note: update() is implemented in sub-classes
@Override
public final void update(ChildTopicsModel updateModel) {
update(model.createModelWithChildTopics(updateModel));
}
@Override
public final void updateChildTopics(ChildTopicsModel updateModel, CompDef compDef) {
......
......@@ -384,19 +384,11 @@ public class DMXObjectModelImpl implements DMXObjectModel {
// === Update (memory + DB) ===
final void updateChildTopics(ChildTopicsModel childTopics) {
// TODO: drop it
final void update(ChildTopicsModel childTopics) {
update(createModelWithChildTopics(childTopics));
}
final void updateChildTopics(ChildTopicsModel updateModel, CompDefModel compDef) {
// ### TODO: think about: no directives are added, no events are fired, no core internal hooks are invoked.
// Possibly this is not wanted for facet updates. This method is solely used for facet updates.
// Compare to update() method.
new ValueIntegrator(al).integrate(createModelWithChildTopics(updateModel), this, compDef);
}
// ---
/**
* @param updateModel The data to update.
* If the URI is <code>null</code> it is not updated.
......@@ -429,6 +421,13 @@ public class DMXObjectModelImpl implements DMXObjectModel {
}
}
final void updateChildTopics(ChildTopicsModel updateModel, CompDefModel compDef) {
// ### TODO: think about: no directives are added, no events are fired, no core internal hooks are invoked.
// Possibly this is not wanted for facet updates. This method is solely used for facet updates.
// Compare to update() method.
new ValueIntegrator(al).integrate(createModelWithChildTopics(updateModel), this, compDef);
}
// ---
final void updateUri(String uri) {
......
......@@ -90,9 +90,9 @@ class ViewConfigurationImpl implements ViewConfiguration {
TopicModelImpl configTopic = model.getConfigTopic(configTypeUri);
if (configTopic == null) {
configTopic = mf.newTopicModel(configTypeUri, children);
_addConfigTopic(configTopic); // update memory + DB
_addConfigTopic(configTopic); // update memory + DB
} else {
configTopic.updateChildTopics(children); // update memory + DB
configTopic.update(children); // update memory + DB
}
}
......
......@@ -8,7 +8,7 @@
</div>
<div class="field">
<div class="field-label">Released</div>
Apr 24, 2020
Apr 25, 2020
</div>
<div class="field">
<div class="field-label">License</div>
......
......@@ -177,13 +177,13 @@ public class CoreServiceTest extends CoreServiceTestEnvironment {
// ---
@Test
public void changeLabelWithSetChildTopics() {
public void changeLabelWithUpdateChildTopics() {
DMXTransaction tx = dmx.beginTx();
try {
Topic topic = dmx.createTopic(mf.newTopicModel(PLUGIN));
assertEquals("", topic.getSimpleValue().toString());
//
topic.setChildTopics(mf.newChildTopicsModel().set(PLUGIN_NAME, "My Plugin"));
topic.update(mf.newChildTopicsModel().set(PLUGIN_NAME, "My Plugin"));
assertEquals("My Plugin", topic.getChildTopics().getString(PLUGIN_NAME));
assertEquals("My Plugin", topic.getSimpleValue().toString());
//
......
......@@ -9,7 +9,7 @@ import extraElementUI from './element-ui'
import 'font-awesome/css/font-awesome.css'
import './websocket'
console.log('[DMX] 2020/04/24')
console.log('[DMX] 2020/04/25')
// 1) Init dm5 library
// The dm5 library must be inited *before* the dm5-webclient component is instantiated.
......
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