Commit 1b7e6117 authored by Jörg Richter's avatar Jörg Richter

ChildTopics API: remove setRef() method (4x) (#341)

BREAKING CHANGE

systems.dmx.core.ChildTopics

remove the 4 setRef() methods:

ChildTopics setRef(String compDefUri, long refTopicId);
ChildTopics setRef(String compDefUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics);
ChildTopics setRef(String compDefUri, String refTopicUri);
ChildTopics setRef(String compDefUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics);

CODE TRANSFORMATION

Instead of

    topic.getChildTopics().setRef(compDefUri, ...);

write

    topic.update(mf.newChildTopicsModel().set(compDefUri, mf.newTopicReferenceModel(...)));

Note: "newTopicReferenceModel" is about to get a shorter Name, e.g. "topicRef"
parent fb60938a
Pipeline #9901 passed with stages
in 7 minutes and 53 seconds
......@@ -121,16 +121,6 @@ public interface ChildTopics extends Iterable<String> {
// --- Single-valued Children ---
ChildTopics setRef(String compDefUri, long refTopicId);
ChildTopics setRef(String compDefUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics);
ChildTopics setRef(String compDefUri, String refTopicUri);
ChildTopics setRef(String compDefUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics);
// ---
ChildTopics setDeletionRef(String compDefUri, long refTopicId);
ChildTopics setDeletionRef(String compDefUri, String refTopicUri);
......
......@@ -208,28 +208,6 @@ class ChildTopicsImpl implements ChildTopics {
// --- Single-valued Children ---
@Override
public ChildTopics setRef(String compDefUri, long refTopicId) {
return _updateOne(compDefUri, mf.newTopicReferenceModel(refTopicId));
}
@Override
public ChildTopics setRef(String compDefUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics) {
return _updateOne(compDefUri, mf.newTopicReferenceModel(refTopicId, relatingAssocChildTopics));
}
@Override
public ChildTopics setRef(String compDefUri, String refTopicUri) {
return _updateOne(compDefUri, mf.newTopicReferenceModel(refTopicUri));
}
@Override
public ChildTopics setRef(String compDefUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics) {
return _updateOne(compDefUri, mf.newTopicReferenceModel(refTopicUri, relatingAssocChildTopics));
}
// ---
@Override
public ChildTopics setDeletionRef(String compDefUri, long refTopicId) {
return _updateOne(compDefUri, mf.newTopicDeletionModel(refTopicId));
......
......@@ -152,8 +152,6 @@ public interface ModelFactory {
// === TopicReferenceModel ===
// TODO: make internal?
TopicReferenceModel newTopicReferenceModel(long topicId);
TopicReferenceModel newTopicReferenceModel(long topicId, AssocModel relatingAssoc);
......
......@@ -285,7 +285,9 @@ public class CoreServiceTest extends CoreServiceTestEnvironment {
//
// "Comment"
Topic comment = dmx.createTopic(mf.newTopicModel("dmx.test.comment"));
comment.getChildTopics().setRef("dmx.test.person_name", karl.getId());
comment.update(mf.newChildTopicsModel().set(
"dmx.test.person_name", mf.newTopicReferenceModel(karl.getId())
));
//
assertEquals(karl.getId(), comment.getChildTopics().getTopic("dmx.test.person_name").getId());
assertEquals("Karl Albrecht", comment.getSimpleValue().toString());
......@@ -330,7 +332,9 @@ public class CoreServiceTest extends CoreServiceTestEnvironment {
//
// "Comment"
Topic comment = dmx.createTopic(mf.newTopicModel("dmx.test.comment"));
comment.getChildTopics().setRef("dmx.test.person_name", karl.getId());
comment.update(mf.newChildTopicsModel().set(
"dmx.test.person_name", mf.newTopicReferenceModel(karl.getId())
));
//
assertEquals(karl.getId(), comment.getChildTopics().getTopic("dmx.test.person_name").getId());
assertEquals("Karl Albrecht", comment.getSimpleValue().toString());
......@@ -505,8 +509,9 @@ public class CoreServiceTest extends CoreServiceTestEnvironment {
DMXTransaction tx = dmx.beginTx();
try {
// set Custom Assoc Type (via comp def)
dmx.getTopicType(PLUGIN).getCompDef(PLUGIN_NAME).getChildTopics()
.setRef("dmx.core.assoc_type#dmx.core.custom_assoc_type", ASSOCIATION);
dmx.getTopicType(PLUGIN).getCompDef(PLUGIN_NAME).update(mf.newChildTopicsModel().set(
"dmx.core.assoc_type#dmx.core.custom_assoc_type", mf.newTopicReferenceModel(ASSOCIATION)
));
//
// get Custom Assoc Type
Topic assocType = dmx.getTopicType(PLUGIN)
......@@ -528,8 +533,9 @@ public class CoreServiceTest extends CoreServiceTestEnvironment {
try {
// set Custom Assoc Type (via association)
long compDefId = dmx.getTopicType(PLUGIN).getCompDef(PLUGIN_NAME).getId();
dmx.getAssoc(compDefId).getChildTopics()
.setRef("dmx.core.assoc_type#dmx.core.custom_assoc_type", ASSOCIATION);
dmx.getAssoc(compDefId).update(mf.newChildTopicsModel().set(
"dmx.core.assoc_type#dmx.core.custom_assoc_type", mf.newTopicReferenceModel(ASSOCIATION)
));
//
// get Custom Assoc Type
Topic assocType = dmx.getTopicType(PLUGIN)
......
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