use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class BaseBreadcrumbNavigatorTest method testLoadContentEmpty.
@Test
public void testLoadContentEmpty() {
final BreadcrumbNavigator navigator = spy(new BreadcrumbNavigator(activeOptions, hiddenTypeDef, user));
final FolderItem item = new FolderItem(path, "item1", FolderItemType.FILE);
final List<FolderItem> content = new ArrayList<FolderItem>();
final List<FolderItem> segments = new ArrayList<FolderItem>();
final FolderListing listing = new FolderListing(item, content, segments);
navigator.loadContent(listing);
verify(navigator).setupBreadcrumb(listing);
verify(navigator).setupUpFolder(listing);
verify(navigator).setupContent(listing);
verifyNavigatorPanelVisibility(navigator);
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class LibraryServiceImpl method getProjectAssets.
@Override
public AssetQueryResult getProjectAssets(final ProjectAssetsQuery query) {
checkNotNull("query", query);
final boolean projectStillExists = ioService.exists(Paths.convert(query.getProject().getBranch().getPath()));
if (!projectStillExists) {
return AssetQueryResult.nonexistent();
} else if (!indexOracle.isIndexed(query.getProject())) {
return AssetQueryResult.unindexed();
}
final HashSet<ValueIndexTerm> queryTerms = buildProjectAssetsQuery(query);
final PageResponse<RefactoringPageRow> findRulesByProjectQuery = refactoringQueryService.query(new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, queryTerms, query.getStartIndex(), query.getAmount(), Boolean.TRUE));
final List<FolderItem> assets = findRulesByProjectQuery.getPageRowList().stream().map(row -> {
final Path path = (Path) row.getValue();
return new FolderItem(path, path.getFileName(), FolderItemType.FILE, false, Paths.readLockedBy(path), Collections.<String>emptyList(), explorerServiceHelper.getRestrictedOperations(path));
}).collect(Collectors.toList());
return AssetQueryResult.normal(assets.stream().map(asset -> {
AssetInfo info = null;
try {
final Map<String, Object> attributes = ioService.readAttributes(Paths.convert((Path) asset.getItem()));
final FileTime lastModifiedFileTime = (FileTime) getAttribute(LibraryService.LAST_MODIFIED_TIME, attributes).get();
final FileTime createdFileTime = (FileTime) getAttribute(LibraryService.CREATED_TIME, attributes).get();
final Date lastModifiedTime = new Date(lastModifiedFileTime.toMillis());
final Date createdTime = new Date(createdFileTime.toMillis());
info = new AssetInfo(asset, lastModifiedTime, createdTime);
} catch (NoSuchFileException nfe) {
log.debug("File '" + asset.getFileName() + "' in LibraryIndex but not VFS. Suspected deletion. Skipping.");
}
return Optional.ofNullable(info);
}).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()));
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ExplorerServiceHelper method getPackageSegments.
public List<FolderItem> getPackageSegments(final Package _pkg) {
List<FolderItem> result = new ArrayList<FolderItem>();
Package pkg = _pkg;
while (pkg != null) {
final Package parent = moduleService.resolveParentPackage(pkg);
if (parent != null) {
result.add(toFolderItem(parent));
}
pkg = parent;
}
return Lists.reverse(result);
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ExplorerServiceHelper method getFolderListing.
public FolderListing getFolderListing(final Path path, final ActiveOptions options) {
// Get list of files and folders contained in the path
final List<FolderItem> folderItems = new ArrayList<FolderItem>();
final boolean includeTags = options.contains(Option.SHOW_TAG_FILTER);
// Scan upwards until the path exists (as the current path could have been deleted)
org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
while (!Files.exists(nioPath)) {
nioPath = nioPath.getParent();
}
final Path basePath = Paths.convert(nioPath);
final DirectoryStream<org.uberfire.java.nio.file.Path> nioPaths = ioService.newDirectoryStream(nioPath, dotFileFilter);
for (org.uberfire.java.nio.file.Path np : nioPaths) {
if (Files.isRegularFile(np)) {
final org.uberfire.backend.vfs.Path p = Paths.convert(np);
final String lockedBy = Paths.readLockedBy(p);
final FolderItem folderItem = new FolderItem(p, p.getFileName(), FolderItemType.FILE, false, lockedBy, includeTags ? metadataService.getTags(p) : Collections.<String>emptyList(), getRestrictedOperations(p));
folderItems.add(folderItem);
} else if (Files.isDirectory(np)) {
final org.uberfire.backend.vfs.Path p = Paths.convert(np);
boolean lockedItems = !lockService.retrieveLockInfos(Paths.convert(np), true).isEmpty();
final FolderItem folderItem = new FolderItem(p, p.getFileName(), FolderItemType.FOLDER, lockedItems, null, Collections.<String>emptyList(), getRestrictedOperations(p));
folderItems.add(folderItem);
}
}
Collections.sort(folderItems, Sorters.ITEM_SORTER);
return new FolderListing(toFolderItem(nioPath), folderItems, getPathSegments(basePath));
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ExplorerServiceHelper method getItems.
public List<FolderItem> getItems(final Package pkg, final ActiveOptions options) {
final List<FolderItem> folderItems = new ArrayList<FolderItem>();
if (pkg == null) {
return emptyList();
}
final Set<Package> childPackages = moduleService.resolvePackages(pkg);
for (final Package childPackage : childPackages) {
folderItems.add(toFolderItem(childPackage));
}
folderItems.addAll(getItems(pkg.getPackageMainSrcPath(), options));
folderItems.addAll(getItems(pkg.getPackageTestSrcPath(), options));
folderItems.addAll(getItems(pkg.getPackageMainResourcesPath(), options));
folderItems.addAll(getItems(pkg.getPackageTestResourcesPath(), options));
Collections.sort(folderItems, Sorters.ITEM_SORTER);
return folderItems;
}
Aggregations