use of edu.stanford.bmir.protege.web.shared.collection.CollectionItem in project webprotege by protegeproject.
the class GetCollectionItemsActionHandler method execute.
@Nonnull
@Override
public GetCollectionItemsResult execute(@Nonnull GetCollectionItemsAction action, @Nonnull ExecutionContext executionContext) {
PageRequest pageRequest = action.getPageRequest();
List<CollectionItem> elementIdList = repository.list(action.getCollectionId(), pageRequest.getSkip(), pageRequest.getPageSize());
long totalItemsCount = repository.count(action.getCollectionId());
int pageCount = (int) (totalItemsCount / pageRequest.getPageSize()) + 1;
return new GetCollectionItemsResult(new Page<>(pageRequest.getPageNumber(), pageCount, elementIdList, elementIdList.size()), pageRequest);
}
use of edu.stanford.bmir.protege.web.shared.collection.CollectionItem in project webprotege by protegeproject.
the class CollectionViewPlaceTokenizer method getPlace.
@Override
public CollectionViewPlace getPlace(String token) {
MatchResult result = regExp.exec(token);
ProjectId projectId = ProjectId.get(result.getGroup(1));
CollectionId collectionId = CollectionId.get(result.getGroup(2));
FormId formId = new FormId(result.getGroup(3));
String selectionString = result.getGroup(5);
GWT.log("[CollectionViewPlaceTokenizer] Selection string: " + selectionString);
Optional<CollectionItem> selection = Optional.ofNullable(selectionString).map(CollectionItem::get);
return new CollectionViewPlace(projectId, collectionId, formId, selection);
}
use of edu.stanford.bmir.protege.web.shared.collection.CollectionItem in project webprotege by protegeproject.
the class CollectionPresenter method handleAddCollectionItems.
private void handleAddCollectionItems() {
current.ifPresent(subject -> {
addItemPromptProvider.get().showPrompt(itemNamesString -> {
// Create Empty Data for the fresh item
List<String> itemNames = Arrays.stream(itemNamesString.split("\n")).map(String::trim).collect(Collectors.toList());
if (itemNames.isEmpty()) {
return;
}
CollectionItem freshItem = CollectionItem.get(itemNames.get(0));
dispatchServiceManager.execute(new CreateCollectionItemsAction(subject.getProjectId(), subject.getCollectionId(), itemNames), result -> {
placeController.goTo(new CollectionViewPlace(subject.getProjectId(), subject.getCollectionId(), subject.getFormId(), Optional.of(freshItem)));
listPresenter.refresh(() -> {
});
});
});
});
}
use of edu.stanford.bmir.protege.web.shared.collection.CollectionItem in project webprotege by protegeproject.
the class CollectionItemListPresenter method refresh.
public void refresh(Runnable runnable) {
Place place = placeController.getWhere();
if (!(place instanceof CollectionViewPlace)) {
return;
}
CollectionViewPlace collectionViewPlace = (CollectionViewPlace) place;
dispatchServiceManager.execute(new GetCollectionItemsAction(collectionViewPlace.getProjectId(), collectionViewPlace.getCollectionId(), PageRequest.requestPage(view.getPageNumber())), busy -> {
}, result -> {
Page<CollectionItem> page = result.getElementIdPage();
view.setPageCount(page.getPageCount());
view.setPageNumber(page.getPageNumber());
view.setElements(page.getPageElements());
collectionViewPlace.getSelection().ifPresent(view::setSelection);
runnable.run();
});
}
Aggregations