mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
[DSL generator] Consider a bridge thing as bridge if it contains things (#4740)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
+4
-3
@@ -101,7 +101,8 @@ public class DslThingFileConverter extends AbstractThingFileGenerator {
|
||||
boolean topLevel, List<Thing> onlyThings, Set<Thing> handledThings) {
|
||||
ModelThing model;
|
||||
ModelBridge modelBridge;
|
||||
if (preferPresentationAsTree && thing instanceof Bridge bridge && !bridge.getThings().isEmpty()) {
|
||||
List<Thing> childThings = getChildThings(thing, onlyThings);
|
||||
if (preferPresentationAsTree && thing instanceof Bridge && !childThings.isEmpty()) {
|
||||
modelBridge = ThingFactory.eINSTANCE.createModelBridge();
|
||||
modelBridge.setBridge(true);
|
||||
model = modelBridge;
|
||||
@@ -135,8 +136,8 @@ public class DslThingFileConverter extends AbstractThingFileGenerator {
|
||||
|
||||
if (preferPresentationAsTree && modelBridge != null) {
|
||||
modelBridge.setThingsHeader(false);
|
||||
for (Thing child : getChildThings(thing)) {
|
||||
if (onlyThings.contains(child) && !handledThings.contains(child)) {
|
||||
for (Thing child : childThings) {
|
||||
if (!handledThings.contains(child)) {
|
||||
modelBridge.getThings()
|
||||
.add(buildModelThing(child, hideDefaultParameters, true, false, onlyThings, handledThings));
|
||||
}
|
||||
|
||||
+7
-5
@@ -63,16 +63,18 @@ public abstract class AbstractThingFileGenerator implements ThingFileGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the child things of a bridge thing, ordered by UID.
|
||||
* Get the child things of a bridge thing amongst a list of things, ordered by UID.
|
||||
*
|
||||
* @param thing the thing
|
||||
* @param fromThings the list of things to look for
|
||||
* @return the sorted list of child things or an empty list if the thing is not a bridge thing
|
||||
*/
|
||||
protected List<Thing> getChildThings(Thing thing) {
|
||||
protected List<Thing> getChildThings(Thing thing, List<Thing> fromThings) {
|
||||
if (thing instanceof Bridge bridge) {
|
||||
return bridge.getThings().stream().sorted((thing1, thing2) -> {
|
||||
return thing1.getUID().getAsString().compareTo(thing2.getUID().getAsString());
|
||||
}).collect(Collectors.toList());
|
||||
return fromThings.stream().filter(th -> bridge.getUID().equals(th.getBridgeUID()))
|
||||
.sorted((thing1, thing2) -> {
|
||||
return thing1.getUID().getAsString().compareTo(thing2.getUID().getAsString());
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user