Search in sources :

Example 1 with Asset

use of org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset in project kie-wb-common by kiegroup.

the class WorkItemDefinitionRemoteDeployService method deploy.

void deploy(final Metadata metadata, final String url, final String names) {
    if (null != url && url.trim().length() > 0) {
        final Collection<WorkItemDefinition> items = remoteLookupService.execute(WorkItemDefinitionRemoteRequest.build(url, names));
        final List<Asset> assets = items.stream().flatMap(this::toAssets).collect(Collectors.toList());
        if (!assets.isEmpty()) {
            // Deploy into file system.
            backendFileSystemManager.deploy(resources.resolveResourcesPath(metadata), new Assets(assets), DEPLOY_MESSAGE + url);
            // Install into current KIE runtime.
            projectInstaller.install(items, metadata);
        }
    }
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Assets(org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Assets) Asset(org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset)

Example 2 with Asset

use of org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset in project kie-wb-common by kiegroup.

the class WorkItemDefinitionRemoteDeployService method createIconAsset.

private static Optional<Asset> createIconAsset(final WorkItemDefinition item) {
    final IconDefinition icon = item.getIconDefinition();
    if (null != icon && null != icon.getUri()) {
        final String path = parsePath(item.getUri());
        final String iconUri = icon.getUri();
        final Asset iconAsset;
        try {
            iconAsset = new AssetBuilder().setFileName(parseFileName(iconUri)).binaryFromURI(path + "/" + iconUri).build();
            return Optional.of(iconAsset);
        } catch (IOException e) {
            LOG.error("Error reading work item definition asset from URL [" + item.getUri() + "]", e);
        }
    }
    return Optional.empty();
}
Also used : AssetBuilder(org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.AssetBuilder) Asset(org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset) IOException(java.io.IOException) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)

Aggregations

Asset (org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset)2 IOException (java.io.IOException)1 IconDefinition (org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)1 WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)1 AssetBuilder (org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.AssetBuilder)1 Assets (org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Assets)1