use of org.eclipse.smarthome.core.extension.ExtensionType in project smarthome by eclipse.
the class SampleExtensionService method activate.
protected void activate() {
types.add(new ExtensionType("binding", "Bindings"));
types.add(new ExtensionType("ui", "User Interfaces"));
types.add(new ExtensionType("persistence", "Persistence Services"));
for (ExtensionType type : types) {
for (int i = 0; i < 10; i++) {
String id = type.getId() + Integer.toString(i);
boolean installed = Math.random() > 0.5;
String name = RandomStringUtils.randomAlphabetic(5);
String label = name + " " + StringUtils.capitalize(type.getId());
String typeId = type.getId();
String version = "1.0";
String link = (Math.random() < 0.5) ? null : "http://lmgtfy.com/?q=" + name;
String description = createDescription();
String imageLink = null;
String backgroundColor = createRandomColor();
Extension extension = new Extension(id, typeId, label, version, link, installed, description, backgroundColor, imageLink);
extensions.put(extension.getId(), extension);
}
}
}
use of org.eclipse.smarthome.core.extension.ExtensionType in project smarthome by eclipse.
the class ExtensionResource method getAllExtensionTypes.
private Set<ExtensionType> getAllExtensionTypes(Locale locale) {
final Collator coll = Collator.getInstance(locale);
coll.setStrength(Collator.PRIMARY);
Set<ExtensionType> ret = new TreeSet<>(new Comparator<ExtensionType>() {
@Override
public int compare(ExtensionType o1, ExtensionType o2) {
return coll.compare(o1.getLabel(), o2.getLabel());
}
});
for (ExtensionService extensionService : extensionServices) {
ret.addAll(extensionService.getTypes(locale));
}
return ret;
}
use of org.eclipse.smarthome.core.extension.ExtensionType in project smarthome by eclipse.
the class ExtensionResource method getTypes.
@GET
@Path("/types")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all extension types.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class) })
public Response getTypes(@HeaderParam("Accept-Language") @ApiParam(value = "language") String language) {
logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath());
Locale locale = LocaleUtil.getLocale(language);
Stream<ExtensionType> extensionTypeStream = getAllExtensionTypes(locale).stream().distinct();
return Response.ok(new Stream2JSONInputStream(extensionTypeStream)).build();
}
use of org.eclipse.smarthome.core.extension.ExtensionType in project smarthome by eclipse.
the class MarketplaceExtensionService method getTypes.
@Override
public List<ExtensionType> getTypes(Locale locale) {
ArrayList<ExtensionType> types = new ArrayList<>(2);
List<Extension> exts = getExtensions(locale);
if (includeBindings) {
for (Extension ext : exts) {
if (ext.getType().equals(MarketplaceExtension.EXT_TYPE_BINDING)) {
types.add(new ExtensionType(MarketplaceExtension.EXT_TYPE_BINDING, "Bindings"));
break;
}
}
}
if (includeRuleTemplates) {
for (Extension ext : exts) {
if (ext.getType().equals(MarketplaceExtension.EXT_TYPE_RULE_TEMPLATE)) {
types.add(new ExtensionType(MarketplaceExtension.EXT_TYPE_RULE_TEMPLATE, "Rule Templates"));
break;
}
}
}
return Collections.unmodifiableList(types);
}
Aggregations