Search in sources :

Example 1 with CollectionItem

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);
}
Also used : PageRequest(edu.stanford.bmir.protege.web.shared.pagination.PageRequest) GetCollectionItemsResult(edu.stanford.bmir.protege.web.shared.collection.GetCollectionItemsResult) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) Nonnull(javax.annotation.Nonnull)

Example 2 with CollectionItem

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);
}
Also used : CollectionId(edu.stanford.bmir.protege.web.shared.collection.CollectionId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) FormId(edu.stanford.bmir.protege.web.shared.form.FormId) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 3 with CollectionItem

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(() -> {
                });
            });
        });
    });
}
Also used : CreateCollectionItemsAction(edu.stanford.bmir.protege.web.shared.collection.CreateCollectionItemsAction) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem)

Example 4 with CollectionItem

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();
    });
}
Also used : CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) GetCollectionItemsAction(edu.stanford.bmir.protege.web.shared.collection.GetCollectionItemsAction) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) Place(com.google.gwt.place.shared.Place)

Aggregations

CollectionItem (edu.stanford.bmir.protege.web.shared.collection.CollectionItem)4 CollectionViewPlace (edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace)3 Place (com.google.gwt.place.shared.Place)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 CollectionId (edu.stanford.bmir.protege.web.shared.collection.CollectionId)1 CreateCollectionItemsAction (edu.stanford.bmir.protege.web.shared.collection.CreateCollectionItemsAction)1 GetCollectionItemsAction (edu.stanford.bmir.protege.web.shared.collection.GetCollectionItemsAction)1 GetCollectionItemsResult (edu.stanford.bmir.protege.web.shared.collection.GetCollectionItemsResult)1 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)1 PageRequest (edu.stanford.bmir.protege.web.shared.pagination.PageRequest)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 Nonnull (javax.annotation.Nonnull)1