Skip to content
Snippets Groups Projects
Commit a3876322 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DelegatingModelFactory: Do not duplicate contents and alike

* Ensure to avoid duplicate entries in the Lists returned by the
  delegating model factory.
* This avoids creating duplicate controllers and visuals for the same
  model elements.

Issue-Ref: 3883
Issue-Url: https://af3-developer.fortiss.org/issues/3883


Signed-off-by: default avatarAlexander Diewald <diewald@fortiss.org>
parent fd6e3fee
No related branches found
No related tags found
1 merge request!81JFX: Base classes
DelegatingControllerFactory.java ad214d83b5821b39862b7c382c91a13c3dfddbd0 GREEN
DelegatingFactoryBase.java f421742267610f41bb6196346026d2f239d90ed0 GREEN
DelegatingModelFactory.java 87ad29bc457b6316392625fb63221039bbb7c616 GREEN
DelegatingModelFactory.java 717b706781879efe9efcb5ce4bf53723e39a3e1b YELLOW
DelegatingVisualFactory.java 7e834acd12ae4d1c2b2b32a5456dc9f2b6d4e466 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.kernel.ui.extension.base.factory;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.reflect.ConstructorUtils.getMatchingAccessibleConstructor;
import static org.conqat.lib.commons.collections.CollectionUtils.isNullOrEmpty;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getInterfaceType;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
......@@ -80,7 +81,8 @@ public class DelegatingModelFactory extends DelegatingFactoryBase<IModelFactory>
@Override
public List<?> getContentAnchorageModels(Object parent) {
return getDelegateFactories().stream().map(f -> f.getContentAnchorageModels(parent))
.filter(cc -> cc != null).findFirst().orElse(null);
.filter(lm -> !isNullOrEmpty(lm)).flatMap(Collection::stream).distinct()
.collect(toList());
}
/** {@inheritDoc} */
......@@ -114,21 +116,24 @@ public class DelegatingModelFactory extends DelegatingFactoryBase<IModelFactory>
@Override
public List<?> getContentModels() {
return getDelegateFactories().stream().map(f -> f.getContentModels())
.flatMap(Collection::stream).collect(toList());
.filter(lm -> !isNullOrEmpty(lm)).flatMap(Collection::stream).distinct()
.collect(toList());
}
/** {@inheritDoc} */
@Override
public List<?> getDiagramAnchorageModels() {
return getDelegateFactories().stream().map(f -> f.getDiagramAnchorageModels())
.flatMap(Collection::stream).collect(toList());
.filter(lm -> !isNullOrEmpty(lm)).flatMap(Collection::stream).distinct()
.collect(toList());
}
/** {@inheritDoc} */
@Override
public List<?> getLinkModels() {
return getDelegateFactories().stream().map(f -> f.getLinkModels())
.flatMap(Collection::stream).collect(toList());
.filter(lm -> !isNullOrEmpty(lm)).flatMap(Collection::stream).distinct()
.collect(toList());
}
/** {@inheritDoc} */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment