use of org.eclipse.smarthome.core.extension.Extension 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.Extension in project smarthome by eclipse.
the class SampleExtensionService method install.
@Override
public void install(String id) {
try {
Thread.sleep((long) (Math.random() * 10000));
Extension extension = getExtension(id, null);
extension.setInstalled(true);
postInstalledEvent(id);
} catch (InterruptedException e) {
}
}
use of org.eclipse.smarthome.core.extension.Extension in project smarthome by eclipse.
the class ExtensionResource method getById.
@GET
@Path("/{extensionId: [a-zA-Z_0-9-]*}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get extension with given ID.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class), @ApiResponse(code = 404, message = "Not found") })
public Response getById(@HeaderParam("Accept-Language") @ApiParam(value = "language") String language, @PathParam("extensionId") @ApiParam(value = "extension ID", required = true) String extensionId) {
logger.debug("Received HTTP GET request at '{}'.", uriInfo.getPath());
Locale locale = LocaleUtil.getLocale(language);
ExtensionService extensionService = getExtensionService(extensionId);
Extension responseObject = extensionService.getExtension(extensionId, locale);
if (responseObject != null) {
return Response.ok(responseObject).build();
}
return Response.status(404).build();
}
use of org.eclipse.smarthome.core.extension.Extension in project smarthome by eclipse.
the class MarketplaceExtensionService method getExtensions.
@Override
public List<Extension> getExtensions(Locale locale) {
List<Node> nodes = proxy.getNodes();
List<Extension> exts = new ArrayList<>(nodes.size());
for (Node node : nodes) {
if (node.id == null) {
// workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=512493
continue;
}
if (toMaturityLevel(node.status) < this.maturityLevel) {
continue;
}
if (!includeBindings && node.packagetypes.equals(MP_PACKAGETYPE_BINDING)) {
continue;
}
if (!includeRuleTemplates && node.packagetypes.equals(MP_PACKAGETYPE_RULE_TEMPLATE)) {
continue;
}
MarketplaceExtension ext = convertToExtension(node);
if (ext != null) {
if (setInstalledFlag(ext)) {
exts.add(ext);
}
}
}
return exts;
}
use of org.eclipse.smarthome.core.extension.Extension in project smarthome by eclipse.
the class SampleExtensionService method uninstall.
@Override
public void uninstall(String id) {
try {
Thread.sleep((long) (Math.random() * 5000));
Extension extension = getExtension(id, null);
extension.setInstalled(false);
postUninstalledEvent(id);
} catch (InterruptedException e) {
}
}
Aggregations