Search in sources :

Example 1 with SelectedWorkspace

use of io.lumeer.api.SelectedWorkspace in project engine by Lumeer.

the class LumeerBridge method printText.

@SuppressWarnings("unused")
public void printText(final String text) {
    final SelectedWorkspace workspace = task.getDaoContextSnapshot().getSelectedWorkspace();
    if (!printed && workspace.getOrganization().isPresent() && workspace.getProject().isPresent()) {
        final TextPrintRequest pq = new TextPrintRequest(workspace.getOrganization().get().getCode(), workspace.getProject().get().getCode(), text);
        operations.add(new PrintTextOperation(pq));
        // we can trigger this only once per rule/function
        printed = true;
    }
}
Also used : SelectedWorkspace(io.lumeer.api.SelectedWorkspace) TextPrintRequest(io.lumeer.core.task.executor.request.TextPrintRequest) PrintTextOperation(io.lumeer.core.task.executor.operation.PrintTextOperation)

Example 2 with SelectedWorkspace

use of io.lumeer.api.SelectedWorkspace in project engine by Lumeer.

the class LumeerBridge method shareView.

@SuppressWarnings("unused")
public void shareView(final String viewId, final String userEmail, final String roles) {
    try {
        final SelectedWorkspace workspace = task.getDaoContextSnapshot().getSelectedWorkspace();
        if (workspace.getOrganization().isPresent() && workspace.getProject().isPresent()) {
            final View view = task.getDaoContextSnapshot().getViewDao().getViewById(viewId);
            if (view != null) {
                // can the initiator share the view?
                if (PermissionUtils.hasRole(workspace.getOrganization().get(), workspace.getProject().get(), view, RoleType.UserConfig, task.getInitiator(), task.getGroups())) {
                    final User newUser = task.getDaoContextSnapshot().getUserDao().getUserByEmail(userEmail);
                    final Set<RoleType> userRoles = StringUtils.isNotEmpty(roles) && !"none".equals(roles) ? Arrays.stream(roles.split(",")).map(RoleType::fromString).collect(toSet()) : Set.of();
                    operations.add(new ViewPermissionsOperation(view, newUser.getId(), userRoles));
                }
            }
        }
    } catch (Exception e) {
        cause = e;
        throw e;
    }
}
Also used : ViewPermissionsOperation(io.lumeer.core.task.executor.operation.ViewPermissionsOperation) User(io.lumeer.api.model.User) RoleType(io.lumeer.api.model.RoleType) SelectedWorkspace(io.lumeer.api.SelectedWorkspace) View(io.lumeer.api.model.View) IOException(java.io.IOException)

Example 3 with SelectedWorkspace

use of io.lumeer.api.SelectedWorkspace in project engine by Lumeer.

the class LumeerBridge method printAttribute.

@SuppressWarnings("unused")
public void printAttribute(final LinkBridge l, final String attrId) {
    final SelectedWorkspace workspace = task.getDaoContextSnapshot().getSelectedWorkspace();
    if (!printed && workspace.getOrganization().isPresent() && workspace.getProject().isPresent()) {
        final PrintRequest pq = new PrintRequest(workspace.getOrganization().get().getCode(), workspace.getProject().get().getCode(), l.getLink().getLinkTypeId(), l.getLink().getId(), attrId, ResourceType.LINK);
        operations.add(new PrintAttributeOperation(pq));
        // we can trigger this only once per rule/function
        printed = true;
    }
}
Also used : TextPrintRequest(io.lumeer.core.task.executor.request.TextPrintRequest) PrintRequest(io.lumeer.core.task.executor.request.PrintRequest) PrintAttributeOperation(io.lumeer.core.task.executor.operation.PrintAttributeOperation) SelectedWorkspace(io.lumeer.api.SelectedWorkspace)

Example 4 with SelectedWorkspace

use of io.lumeer.api.SelectedWorkspace in project engine by Lumeer.

the class LumeerBridge method navigate.

@SuppressWarnings("unused")
private void navigate(final String viewId, final DocumentBridge documentBridge, final String search, final boolean sidebar, final boolean newWindow) {
    try {
        final SelectedWorkspace workspace = task.getDaoContextSnapshot().getSelectedWorkspace();
        if (workspace.getOrganization().isPresent() && workspace.getProject().isPresent()) {
            final View view = task.getDaoContextSnapshot().getViewDao().getViewById(viewId);
            if (view != null && view.getQuery().getStems().size() > 0 && StringUtils.isNotEmpty(view.getQuery().getStems().get(0).getCollectionId())) {
                final String collectionId = view.getQuery().getStems().get(0).getCollectionId();
                final String documentId = documentBridge != null ? documentBridge.getDocument().getId() : null;
                final Collection collection = task.getDaoContextSnapshot().getCollectionDao().getCollectionById(collectionId);
                final String attributeId = StringUtils.isNotEmpty(collection.getDefaultAttributeId()) ? collection.getDefaultAttributeId() : (collection.getAttributes() != null && !collection.getAttributes().isEmpty() ? collection.getAttributes().iterator().next().getId() : "");
                final NavigationRequest navigationRequest = new NavigationRequest(workspace.getOrganization().get().getCode(), workspace.getProject().get().getCode(), viewId, collectionId, documentId, attributeId, sidebar, newWindow, search);
                operations.add(new NavigationOperation(navigationRequest));
            }
        }
    } catch (Exception e) {
        cause = e;
        throw e;
    }
}
Also used : NavigationOperation(io.lumeer.core.task.executor.operation.NavigationOperation) NavigationRequest(io.lumeer.core.task.executor.request.NavigationRequest) Collection(io.lumeer.api.model.Collection) SelectedWorkspace(io.lumeer.api.SelectedWorkspace) View(io.lumeer.api.model.View) IOException(java.io.IOException)

Example 5 with SelectedWorkspace

use of io.lumeer.api.SelectedWorkspace in project engine by Lumeer.

the class LumeerBridge method printAttribute.

@SuppressWarnings("unused")
public void printAttribute(final DocumentBridge d, final String attrId) {
    final SelectedWorkspace workspace = task.getDaoContextSnapshot().getSelectedWorkspace();
    if (!printed && workspace.getOrganization().isPresent() && workspace.getProject().isPresent()) {
        final PrintRequest pq = new PrintRequest(workspace.getOrganization().get().getCode(), workspace.getProject().get().getCode(), d.getDocument().getCollectionId(), d.getDocument().getId(), attrId, ResourceType.COLLECTION);
        operations.add(new PrintAttributeOperation(pq));
        // we can trigger this only once per rule/function
        printed = true;
    }
}
Also used : TextPrintRequest(io.lumeer.core.task.executor.request.TextPrintRequest) PrintRequest(io.lumeer.core.task.executor.request.PrintRequest) PrintAttributeOperation(io.lumeer.core.task.executor.operation.PrintAttributeOperation) SelectedWorkspace(io.lumeer.api.SelectedWorkspace)

Aggregations

SelectedWorkspace (io.lumeer.api.SelectedWorkspace)5 TextPrintRequest (io.lumeer.core.task.executor.request.TextPrintRequest)3 View (io.lumeer.api.model.View)2 PrintAttributeOperation (io.lumeer.core.task.executor.operation.PrintAttributeOperation)2 PrintRequest (io.lumeer.core.task.executor.request.PrintRequest)2 IOException (java.io.IOException)2 Collection (io.lumeer.api.model.Collection)1 RoleType (io.lumeer.api.model.RoleType)1 User (io.lumeer.api.model.User)1 NavigationOperation (io.lumeer.core.task.executor.operation.NavigationOperation)1 PrintTextOperation (io.lumeer.core.task.executor.operation.PrintTextOperation)1 ViewPermissionsOperation (io.lumeer.core.task.executor.operation.ViewPermissionsOperation)1 NavigationRequest (io.lumeer.core.task.executor.request.NavigationRequest)1