From 9445586090a9352f4a4142cc620a0e9d644d4e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Fri, 26 Feb 2021 03:37:33 +0100 Subject: [PATCH] Solve issues with handling of group items and functions. #27 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Łukasz Dywicki --- .../internal/items/GroupFunctionHelper.java | 28 ++++++-------- .../items/ItemBuilderFactoryImpl.java | 7 ++-- .../internal/items/StorageItemProvider.java | 2 +- .../{DimensionalAvg.java => Avg.java} | 4 +- .../{DimensionalMax.java => Max.java} | 4 +- .../{DimensionalMin.java => Min.java} | 4 +- .../{DimensionalSum.java => Sum.java} | 4 +- ...antityTypeArithmeticGroupFunctionTest.java | 37 +++++++++---------- .../core/items/ItemBuilderFactory.java | 3 +- .../openhab/core/items/dto/ItemDTOMapper.java | 4 +- .../core/items/dto/ItemDTOMapperTest.java | 11 +++++- .../item/internal/GenericItemProvider.java | 6 ++- 12 files changed, 61 insertions(+), 53 deletions(-) rename bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/{DimensionalAvg.java => Avg.java} (94%) rename bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/{DimensionalMax.java => Max.java} (92%) rename bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/{DimensionalMin.java => Min.java} (92%) rename bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/{DimensionalSum.java => Sum.java} (93%) diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/GroupFunctionHelper.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/GroupFunctionHelper.java index 82e0be933..c55f9b2f8 100755 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/GroupFunctionHelper.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/GroupFunctionHelper.java @@ -21,20 +21,16 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.internal.items.function.And; -import org.openhab.core.internal.items.function.Avg; import org.openhab.core.internal.items.function.Count; import org.openhab.core.internal.items.function.Earliest; import org.openhab.core.internal.items.function.Latest; -import org.openhab.core.internal.items.function.Max; -import org.openhab.core.internal.items.function.Min; import org.openhab.core.internal.items.function.NAnd; import org.openhab.core.internal.items.function.NOr; import org.openhab.core.internal.items.function.Or; -import org.openhab.core.internal.items.function.Sum; -import org.openhab.core.internal.items.function.dimensional.DimensionalAvg; -import org.openhab.core.internal.items.function.dimensional.DimensionalMax; -import org.openhab.core.internal.items.function.dimensional.DimensionalMin; -import org.openhab.core.internal.items.function.dimensional.DimensionalSum; +import org.openhab.core.internal.items.function.dimensional.Avg; +import org.openhab.core.internal.items.function.dimensional.Max; +import org.openhab.core.internal.items.function.dimensional.Min; +import org.openhab.core.internal.items.function.dimensional.Sum; import org.openhab.core.items.GroupFunction; import org.openhab.core.items.Item; import org.openhab.core.items.dto.GroupFunctionDTO; @@ -105,13 +101,13 @@ private GroupFunction createDimensionGroupFunction(GroupFunctionDTO function, @N final String functionName = function.name; switch (functionName.toUpperCase()) { case "AVG": - return new DimensionalAvg(dimension); + return new Avg(dimension); case "SUM": - return new DimensionalSum(dimension); + return new Sum(dimension); case "MIN": - return new DimensionalMin(dimension); + return new Min(dimension); case "MAX": - return new DimensionalMax(dimension); + return new Max(dimension); default: return createDefaultGroupFunction(function, baseItem); } @@ -163,13 +159,13 @@ private GroupFunction createDefaultGroupFunction(GroupFunctionDTO function, @Nul } break; case "AVG": - return new Avg(); + return new org.openhab.core.internal.items.function.Avg(); case "SUM": - return new Sum(); + return new org.openhab.core.internal.items.function.Sum(); case "MIN": - return new Min(); + return new org.openhab.core.internal.items.function.Min(); case "MAX": - return new Max(); + return new org.openhab.core.internal.items.function.Max(); case "LATEST": return new Latest(); case "EARLIEST": diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java index 3f7fda34d..2a3381577 100755 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java @@ -16,6 +16,7 @@ import java.util.concurrent.CopyOnWriteArraySet; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.items.GroupFunction; import org.openhab.core.items.Item; import org.openhab.core.items.ItemBuilder; @@ -44,7 +45,7 @@ public class ItemBuilderFactoryImpl implements ItemBuilderFactory { @Activate public ItemBuilderFactoryImpl( - final @Reference(target = "(component.name=org.openhab.core.library.CoreItemFactory)") ItemFactory coreItemFactory) { + final @Reference(target = "(component.name=org.openhab.core.library.CoreItemFactory)") ItemFactory coreItemFactory) { itemFactories.add(coreItemFactory); } @@ -59,8 +60,8 @@ public ItemBuilder newItemBuilder(String itemType, String itemName) { } @Override - public GroupFunction newFunctionBuilder(Item baseItem, GroupFunctionDTO function) { - throw new AbstractMethodError("Not implemented yet"); + public GroupFunction newFunctionBuilder(@Nullable Item baseItem, GroupFunctionDTO function) { + return new GroupFunctionHelper().createGroupFunction(function, baseItem); } @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/StorageItemProvider.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/StorageItemProvider.java index aa601fbe7..3316988ec 100644 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/StorageItemProvider.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/StorageItemProvider.java @@ -269,7 +269,7 @@ private GroupFunction getGroupFunction(PersistedItem persistedItem, @Nullable It if (persistedItem.functionParams != null) { functionDTO.params = persistedItem.functionParams.toArray(new String[persistedItem.functionParams.size()]); } - return ItemDTOMapper.mapFunction(baseItem, functionDTO); + return ItemDTOMapper.mapFunction(baseItem, functionDTO, itemBuilderFactory); } private void configureItem(PersistedItem persistedItem, GenericItem item) { diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalAvg.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Avg.java similarity index 94% rename from bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalAvg.java rename to bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Avg.java index 6b5220041..a6cbcf298 100644 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalAvg.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Avg.java @@ -32,9 +32,9 @@ * @author Henning Treu - Initial contribution */ @NonNullByDefault -public class DimensionalAvg extends DimensionalGroupFunction { +public class Avg extends DimensionalGroupFunction { - public DimensionalAvg(Class> dimension) { + public Avg(Class> dimension) { super(dimension); } diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalMax.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Max.java similarity index 92% rename from bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalMax.java rename to bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Max.java index 8453b8c48..6f10c3436 100644 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalMax.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Max.java @@ -27,9 +27,9 @@ * @author Henning Treu - Initial contribution */ @NonNullByDefault -public class DimensionalMax extends DimensionalGroupFunction { +public class Max extends DimensionalGroupFunction { - public DimensionalMax(Class> dimension) { + public Max(Class> dimension) { super(dimension); } diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalMin.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Min.java similarity index 92% rename from bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalMin.java rename to bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Min.java index cc4d45c82..90a9df605 100644 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalMin.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Min.java @@ -27,9 +27,9 @@ * @author Henning Treu - Initial contribution */ @NonNullByDefault -public class DimensionalMin extends DimensionalGroupFunction { +public class Min extends DimensionalGroupFunction { - public DimensionalMin(Class> dimension) { + public Min(Class> dimension) { super(dimension); } diff --git a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalSum.java b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Sum.java similarity index 93% rename from bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalSum.java rename to bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Sum.java index 32ef9b709..4ddae66ea 100644 --- a/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/DimensionalSum.java +++ b/bundles/org.opensmarthouse.core.item.core/src/main/java/org/openhab/core/internal/items/function/dimensional/Sum.java @@ -27,9 +27,9 @@ * @author Henning Treu - Initial contribution */ @NonNullByDefault -public class DimensionalSum extends DimensionalGroupFunction { +public class Sum extends DimensionalGroupFunction { - public DimensionalSum(Class> dimension) { + public Sum(Class> dimension) { super(dimension); } diff --git a/bundles/org.opensmarthouse.core.item.core/src/test/java/org/openhab/core/internal/items/function/QuantityTypeArithmeticGroupFunctionTest.java b/bundles/org.opensmarthouse.core.item.core/src/test/java/org/openhab/core/internal/items/function/QuantityTypeArithmeticGroupFunctionTest.java index 9b347fc48..f29ef8f06 100755 --- a/bundles/org.opensmarthouse.core.item.core/src/test/java/org/openhab/core/internal/items/function/QuantityTypeArithmeticGroupFunctionTest.java +++ b/bundles/org.opensmarthouse.core.item.core/src/test/java/org/openhab/core/internal/items/function/QuantityTypeArithmeticGroupFunctionTest.java @@ -29,14 +29,13 @@ import org.junit.Test; import org.mockito.Mock; import org.openhab.core.i18n.UnitProvider; -import org.openhab.core.internal.items.function.dimensional.DimensionalAvg; -import org.openhab.core.internal.items.function.dimensional.DimensionalMax; -import org.openhab.core.internal.items.function.dimensional.DimensionalMin; -import org.openhab.core.internal.items.function.dimensional.DimensionalSum; +import org.openhab.core.internal.items.function.dimensional.Avg; +import org.openhab.core.internal.items.function.dimensional.Max; +import org.openhab.core.internal.items.function.dimensional.Min; +import org.openhab.core.internal.items.function.dimensional.Sum; import org.openhab.core.items.GroupFunction; import org.openhab.core.items.GroupItem; import org.openhab.core.items.Item; -import org.openhab.core.items.QuantityTypeArithmeticGroupFunction; import org.openhab.core.library.CoreItemFactory; import org.openhab.core.library.items.NumberItem; import org.openhab.core.library.types.QuantityType; @@ -72,7 +71,7 @@ public void testSumFunctionQuantityType() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("122.41 °C"))); - function = new DimensionalSum(Temperature.class); + function = new Sum(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("234.95 °C"), state); @@ -86,7 +85,7 @@ public void testSumFunctionQuantityTypeDifferentUnits() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("395.56 K"))); - function = new DimensionalSum(Temperature.class); + function = new Sum(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("234.95 °C"), state); @@ -99,7 +98,7 @@ public void testSumFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); - function = new DimensionalSum(Temperature.class); + function = new Sum(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); @@ -113,7 +112,7 @@ public void testAvgFunctionQuantityType() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("300 °C"))); - function = new DimensionalAvg(Temperature.class); + function = new Avg(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("200 °C"), state); @@ -127,7 +126,7 @@ public void testAvgFunctionQuantityTypeDifferentUnits() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("294.15 K"))); - function = new DimensionalAvg(Temperature.class); + function = new Avg(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("55.33 °C"), state); @@ -139,7 +138,7 @@ public void testAvgFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); - function = new DimensionalAvg(Temperature.class); + function = new Avg(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); @@ -153,7 +152,7 @@ public void testMaxFunctionQuantityType() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("300 °C"))); - function = new DimensionalMax(Temperature.class); + function = new Max(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("300 °C"), state); @@ -167,7 +166,7 @@ public void testMaxFunctionQuantityTypeDifferentUnits() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("294.15 K"))); - function = new DimensionalMax(Temperature.class); + function = new Max(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("100 °C"), state); @@ -179,7 +178,7 @@ public void testMaxFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); - function = new DimensionalMax(Temperature.class); + function = new Max(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); @@ -193,7 +192,7 @@ public void testMinFunctionQuantityType() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("300 °C"))); - function = new DimensionalMin(Temperature.class); + function = new Min(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("100 °C"), state); @@ -208,7 +207,7 @@ public void testMaxFunctionQuantityTypeOnDimensionless() { items.add(createNumberItem("TestItem5", Dimensionless.class, new QuantityType<>("0 %"))); items.add(createNumberItem("TestItem6", Dimensionless.class, new QuantityType<>("0 %"))); - function = new DimensionalMax(Dimensionless.class); + function = new Max(Dimensionless.class); State state = function.calculate(items); assertEquals(new QuantityType<>("48 %"), state); @@ -222,7 +221,7 @@ public void testMinFunctionQuantityTypeDifferentUnits() { items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("294.15 K"))); - function = new DimensionalMin(Temperature.class); + function = new Min(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("294.15 K"), state); @@ -234,7 +233,7 @@ public void testMinFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); - function = new DimensionalMin(Temperature.class); + function = new Min(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); @@ -245,7 +244,7 @@ public void testSumFunctionQuantityTypeWithGroups() { items.add(createNumberItem("TestItem1", Power.class, new QuantityType<>("5 W"))); items.add(createGroupItem("TestGroup1", Power.class, new QuantityType<>("5 W"))); - function = new DimensionalSum(Power.class); + function = new Sum(Power.class); State state = function.calculate(items); assertEquals(new QuantityType<>("10 W"), state); diff --git a/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/ItemBuilderFactory.java b/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/ItemBuilderFactory.java index 1dbb39430..4d17bc90f 100755 --- a/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/ItemBuilderFactory.java +++ b/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/ItemBuilderFactory.java @@ -13,6 +13,7 @@ package org.openhab.core.items; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.items.dto.GroupFunctionDTO; /** @@ -41,5 +42,5 @@ public interface ItemBuilderFactory { ItemBuilder newItemBuilder(String itemType, String itemName); // FIXME verify if that's valid approach - GroupFunction newFunctionBuilder(Item baseItem, GroupFunctionDTO function); + GroupFunction newFunctionBuilder(@Nullable Item baseItem, GroupFunctionDTO function); } diff --git a/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java b/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java index 094df4446..9b9ec0882 100755 --- a/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java +++ b/bundles/org.opensmarthouse.core.item/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java @@ -86,8 +86,8 @@ public class ItemDTOMapper { return null; } - public static GroupFunction mapFunction(@Nullable Item baseItem, GroupFunctionDTO function) { - throw new AbstractMethodError("This method has been moved!"); + public static GroupFunction mapFunction(@Nullable Item baseItem, GroupFunctionDTO function, ItemBuilderFactory itemBuilderFactory) { + return itemBuilderFactory.newFunctionBuilder(baseItem, function); } /** diff --git a/bundles/org.opensmarthouse.core.item/src/test/java/org/openhab/core/items/dto/ItemDTOMapperTest.java b/bundles/org.opensmarthouse.core.item/src/test/java/org/openhab/core/items/dto/ItemDTOMapperTest.java index f05fcc44e..601d89c17 100755 --- a/bundles/org.opensmarthouse.core.item/src/test/java/org/openhab/core/items/dto/ItemDTOMapperTest.java +++ b/bundles/org.opensmarthouse.core.item/src/test/java/org/openhab/core/items/dto/ItemDTOMapperTest.java @@ -20,18 +20,25 @@ import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.openhab.core.items.GenericItem; import org.openhab.core.items.GroupFunction; +import org.openhab.core.items.ItemBuilderFactory; import org.openhab.core.items.TestNumberItem; import org.openhab.core.library.types.StringType; /** * @author Stefan Triller - Initial contribution */ +@RunWith(MockitoJUnitRunner.class) public class ItemDTOMapperTest { + @Mock + private ItemBuilderFactory factory; + @Test - @Ignore public void testMapFunctionWithNumberItemAndCountFunction() { // testing Group:Number:Count(".*hello.*") GenericItem item1 = new TestNumberItem("item1"); @@ -41,7 +48,7 @@ public void testMapFunctionWithNumberItemAndCountFunction() { gFuncDTO.params = new String[] { ".*hello.*" }; // FIXME This gonna fail - GroupFunction gFunc = ItemDTOMapper.mapFunction(item1, gFuncDTO); + GroupFunction gFunc = ItemDTOMapper.mapFunction(item1, gFuncDTO, factory); assertThat(gFunc, instanceOf(GroupFunction.class)); assertThat(gFunc.getParameters().length, is(1)); diff --git a/bundles/org.opensmarthouse.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java b/bundles/org.opensmarthouse.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java index f2277150a..99813329c 100755 --- a/bundles/org.opensmarthouse.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java +++ b/bundles/org.opensmarthouse.core.model.item/src/org/openhab/core/model/item/internal/GenericItemProvider.java @@ -36,6 +36,7 @@ import org.openhab.core.items.GroupItem; import org.openhab.core.items.Item; import org.openhab.core.items.ItemFactory; +import org.openhab.core.items.ItemBuilderFactory; import org.openhab.core.items.ItemProvider; import org.openhab.core.items.ItemUtil; import org.openhab.core.items.dto.GroupFunctionDTO; @@ -85,6 +86,7 @@ public class GenericItemProvider extends AbstractProvider private final GenericMetadataProvider genericMetaDataProvider; private final StateDescriptionFragmentBuilderFactory stateDescriptionFragmentBuilderFactory; + private final ItemBuilderFactory itemBuilderFactory; private final Map> itemsMap = new ConcurrentHashMap<>(); @@ -98,10 +100,12 @@ public class GenericItemProvider extends AbstractProvider public GenericItemProvider(final @Reference ModelRepository modelRepository, final @Reference GenericMetadataProvider genericMetadataProvider, final @Reference StateDescriptionFragmentBuilderFactory stateDescriptionFragmentBuilderFactory, + final @Reference ItemBuilderFactory itemBuilderFactory, Map properties) { this.modelRepository = modelRepository; this.genericMetaDataProvider = genericMetadataProvider; this.stateDescriptionFragmentBuilderFactory = stateDescriptionFragmentBuilderFactory; + this.itemBuilderFactory = itemBuilderFactory; Object serviceRanking = properties.get(Constants.SERVICE_RANKING); if (serviceRanking instanceof Integer) { @@ -295,7 +299,7 @@ private GroupItem applyGroupFunction(Item baseItem, ModelGroupItem modelGroupIte dto.name = function.getName(); dto.params = modelGroupItem.getArgs().toArray(new String[modelGroupItem.getArgs().size()]); - GroupFunction groupFunction = ItemDTOMapper.mapFunction(baseItem, dto); + GroupFunction groupFunction = ItemDTOMapper.mapFunction(baseItem, dto, itemBuilderFactory); return new GroupItem(modelGroupItem.getName(), baseItem, groupFunction); }