use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.
the class ConfigDescriptionParameterConverter method readParameterOptions.
private List<ParameterOption> readParameterOptions(Object rawNodeValueList) {
if (rawNodeValueList instanceof List<?>) {
List<?> list = (List<?>) rawNodeValueList;
List<ParameterOption> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof NodeValue) {
NodeValue nodeValue = (NodeValue) object;
String value = nodeValue.getAttributes().get("value");
String label = nodeValue.getValue().toString();
result.add(new ParameterOption(value, label));
}
}
return result;
}
return null;
}
use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.
the class VoiceManagerImpl method getParameterOptions.
@Override
public Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale) {
if (uri.toString().equals(CONFIG_URI)) {
if (CONFIG_DEFAULT_HLI.equals(param)) {
List<ParameterOption> options = new ArrayList<>();
for (HumanLanguageInterpreter hli : humanLanguageInterpreters.values()) {
ParameterOption option = new ParameterOption(hli.getId(), hli.getLabel(locale));
options.add(option);
}
return options;
} else if (CONFIG_DEFAULT_KS.equals(param)) {
List<ParameterOption> options = new ArrayList<>();
for (KSService ks : ksServices.values()) {
ParameterOption option = new ParameterOption(ks.getId(), ks.getLabel(locale));
options.add(option);
}
return options;
} else if (CONFIG_DEFAULT_STT.equals(param)) {
List<ParameterOption> options = new ArrayList<>();
for (STTService stt : sttServices.values()) {
ParameterOption option = new ParameterOption(stt.getId(), stt.getLabel(locale));
options.add(option);
}
return options;
} else if (CONFIG_DEFAULT_TTS.equals(param)) {
List<ParameterOption> options = new ArrayList<>();
for (TTSService tts : ttsServices.values()) {
ParameterOption option = new ParameterOption(tts.getId(), tts.getLabel(locale));
options.add(option);
}
return options;
} else if (CONFIG_DEFAULT_VOICE.equals(param)) {
List<ParameterOption> options = new ArrayList<>();
for (Voice voice : getAllVoices()) {
ParameterOption option = new ParameterOption(voice.getUID(), voice.getLabel() + " - " + voice.getLocale().getDisplayName());
options.add(option);
}
return options;
}
}
return null;
}
use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.
the class VoiceManagerTest method getParameterOptionsForTheDefaultKs.
@Test
public void getParameterOptionsForTheDefaultKs() throws URISyntaxException {
ksService = new KSServiceStub();
registerService(ksService);
boolean isKSStubInTheOptions = false;
Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultKS", null);
assertNotNull(options);
for (ParameterOption option : options) {
String optionValue = option.getValue();
String optionLabel = option.getLabel();
String ksStubId = ksService.getId();
String ksLabel = ksService.getLabel(null);
if (optionValue.equals(ksStubId) && optionLabel.equals(ksLabel)) {
isKSStubInTheOptions = true;
}
}
assertTrue(isKSStubInTheOptions);
}
use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.
the class VoiceManagerTest method getParameterOptionsForTheDefaultTts.
@Test
public void getParameterOptionsForTheDefaultTts() throws URISyntaxException {
ttsService = new TTSServiceStub();
registerService(ttsService);
boolean isTTSStubInTheOptions = false;
Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultTTS", null);
assertNotNull(options);
for (ParameterOption option : options) {
String optionValue = option.getValue();
String optionLabel = option.getLabel();
String ttsStubId = ttsService.getId();
String ttsLabel = ttsService.getLabel(null);
if (optionValue.equals(ttsStubId) && optionLabel.equals(ttsLabel)) {
isTTSStubInTheOptions = true;
}
}
assertTrue(isTTSStubInTheOptions);
}
use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.
the class VoiceManagerTest method getParameterOptionsForTheDefaultSTT.
@Test
public void getParameterOptionsForTheDefaultSTT() throws URISyntaxException {
sttService = new STTServiceStub();
registerService(sttService);
boolean isSTTStubInTheOptions = false;
Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultSTT", null);
assertNotNull(options);
for (ParameterOption option : options) {
String optionValue = option.getValue();
String optionLabel = option.getLabel();
String sttStubId = sttService.getId();
String sttLabel = sttService.getLabel(null);
if (optionValue.equals(sttStubId) && optionLabel.equals(sttLabel)) {
isSTTStubInTheOptions = true;
}
}
assertTrue(isSTTStubInTheOptions);
}
Aggregations