The HideUnitsService service delivers a filter capability to all current methods present in the UnitsResource (used by the frontend in many situations including dashboards and channels management).
This service is customizable since plugin-liverig 3.7.0, hiding the Unit on all frontend (HIDE_ALL) or maintaining the autocomplete feature on the channels management screen (NOT_INPUT_CHANNEL). The HIDE_ALL type of filtering is the default type, even if it is not specified. This service is exposed to be used by any plugin.
This service provides two methods on 3.3.0 release:
hideUnits - hide desired units
contains - check whether a unit is already hidden
This service provides five more methods on 3.7.0release:
applyFilter - returns a boolean that represents if a unit is being hidden on all frontend (HIDE_ALL) or maintaining the autocomplete feature on the channels management screen (NOT_INPUT_CHANNEL).
filtersUOM - returns a list containing all filtered units (only the unit).
filters - returns a list containing all filtered units and their respective filterTyper (HIDE_ALL or NOT_INPUT_CHANNEL).
filtersByUnit - returns a UnitsFilter.Type if the filter list contains specified unit
filtersByType - returns all filtered units by filter type (UnitsFilter.Type)
The following Groovy plugin example hides "UGT" and "rad" units on all frontend (HIDE_ALL) and "miUS2" unit while maintaining the autocomplete feature on the channels management screen (NOT_INPUT_CHANNEL):
//@liveplugin [email protected]//@requirePlugins plugin-liverigimportnet.intelie.live.Liveimportnet.intelie.liverig.plugin.units.HideUnitsService//UnitsFilter package required to customize the filter type after live-rig 3.7.0importnet.intelie.liverig.plugin.units.UnitsFilterHideUnitsService service = live.system().getPluginService(HideUnitsService.class)service.hideUnits(live, "UGT")service.hideUnits(live, UnitsFilter.Type.HIDE_ALL, "rad")service.hideUnits(live, UnitsFilter.Type.NOT_INPUT_CHANNEL, "miUS2")// how to hide an units collectionList<String> thousands =newArrayList()for ( i in (0..1000).toArray() ) { thousands.add("example"+ i)}// single method call will work with any number of unitsservice.hideUnits(live, thousands.toArray(newString[0]))
It's expected the following behaviors in case an unit be hidden but was being used at:
It's expected the following behaviors in case an unit be hidden but was being used at:
Standard Channels: the user will receive an warning
Display Units: the user will be prevented from saving until they modify the hidden variable. This can break some widgets, just like when an alias or an unit extension is modified (see more)
Data Normalization (either as the source or target channel unit): no warning is shown at the Data Management screen, and the normalization will be executed as the unit was visible.
Asset Parameters, Data Management or Unit Management Tools: The user will receive no warning, but the unit will not be suggested by the autocomplete (HIDE_ALL) or retain the suggestion by the autocomplete (NOT_INPUT_CHANNEL).