Package org.zanata.webtrans.server

Examples of org.zanata.webtrans.server.TranslationWorkspace


    @Override
    public NoOpResult execute(PublishWorkspaceChatAction action,
            ExecutionContext context) throws ActionException {
        identity.checkLoggedIn();

        TranslationWorkspace workspace =
                translationWorkspaceManager.getOrRegisterWorkspace(action
                        .getWorkspaceId());
        // Send PublishWorkspaceChat event to client

        Date currentDate = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy h:mm:ss");

        PublishWorkspaceChat event =
                new PublishWorkspaceChat(action.getPerson(),
                        formatter.format(currentDate), action.getMsg(),
                        action.getMessageType());
        workspace.publish(event);

        return new NoOpResult();
    }
View Full Code Here


    @Override
    public NoOpResult execute(EventServiceConnectedAction action,
            ExecutionContext context) throws ActionException {
        identity.checkLoggedIn();
        TranslationWorkspace workspace =
                translationWorkspaceManager.getOrRegisterWorkspace(action
                        .getWorkspaceId());
        workspace.onEventServiceConnected(action.getEditorClientId(),
                action.getConnectionId());
        return new NoOpResult();
    }
View Full Code Here

    @Override
    public GetTranslatorListResult execute(GetTranslatorList action,
            ExecutionContext context) throws ActionException {
        identity.checkLoggedIn();

        TranslationWorkspace translationWorkspace =
                translationWorkspaceManager.getOrRegisterWorkspace(action
                        .getWorkspaceId());

        Map<EditorClientId, PersonSessionDetails> result =
                translationWorkspace.getUsers();

        // Use AccountDAO to convert the PersonId to Person
        Map<EditorClientId, PersonSessionDetails> translators =
                new HashMap<EditorClientId, PersonSessionDetails>();
        for (Map.Entry<EditorClientId, PersonSessionDetails> entry : result
View Full Code Here

        HLocale locale =
                localeServiceImpl.getByLocaleId(workspaceId.getLocaleId());

        identity.checkPermission("review-comment", locale, project);

        TranslationWorkspace workspace =
                translationWorkspaceManager.getOrRegisterWorkspace(workspaceId);

        HTextFlowTargetReviewComment hComment =
                hTextFlowTarget.addReviewComment(action.getContent(),
                        authenticatedAccount.getPerson());
        textFlowTargetReviewCommentsDAO.makePersistent(hComment);
        textFlowTargetReviewCommentsDAO.flush();

        AddReviewComment commentEvent = new AddReviewComment(
                new TransUnitId(hTextFlowTarget.getTextFlow().getId()),
                hTextFlowTarget.getReviewComments().size());
        workspace.publish(commentEvent);
        return new AddReviewCommentResult(toDTO(hComment));
    }
View Full Code Here

    public NoOpResult execute(ExitWorkspaceAction action,
            ExecutionContext context) throws ActionException {

        identity.checkLoggedIn();

        TranslationWorkspace workspace =
                translationWorkspaceManager.getOrRegisterWorkspace(action
                        .getWorkspaceId());

        // Send ExitWorkspace event to client
        workspace.removeEditorClient(action.getEditorClientId());
        return new NoOpResult();
    }
View Full Code Here

    @Override
    public NoOpResult execute(TransUnitEditAction action,
            ExecutionContext context) throws ActionException {
        identity.checkLoggedIn();

        TranslationWorkspace workspace =
                translationWorkspaceManager.getOrRegisterWorkspace(action
                        .getWorkspaceId());
        // Send TranslatorStatusUpdate event to client
        TransUnitEdit event =
                new TransUnitEdit(action.getEditorClientId(),
                        action.getPerson(), action.getSelectedTransUnitId());

        workspace.updateUserSelection(action.getEditorClientId(),
                action.getSelectedTransUnitId());

        workspace.publish(event);

        return new NoOpResult();
    }
View Full Code Here

            ExecutionContext context) throws ActionException {
        identity.checkLoggedIn();
        Person person = retrievePerson();

        WorkspaceId workspaceId = action.getWorkspaceId();
        TranslationWorkspace workspace =
                translationWorkspaceManager.getOrRegisterWorkspace(workspaceId);
        String httpSessionId = getHttpSessionId();
        EditorClientId editorClientId =
                new EditorClientId(httpSessionId, generateEditorClientNum());
        workspace
                .addEditorClient(httpSessionId, editorClientId, person.getId());
        // Send EnterWorkspace event to clients
        EnterWorkspace event = new EnterWorkspace(editorClientId, person);
        workspace.publish(event);

        HLocale locale =
                localeServiceImpl.getByLocaleId(workspaceId.getLocaleId());
        HProject project =
                projectDAO.getBySlug(workspaceId.getProjectIterationId()
                        .getProjectSlug());
        HProjectIteration projectIteration =
                projectIterationDAO.getBySlug(workspaceId
                        .getProjectIterationId().getProjectSlug(), workspaceId
                        .getProjectIterationId().getIterationSlug());

        boolean isProjectActive =
                isProjectIterationActive(project.getStatus(),
                        projectIteration.getStatus());
        boolean hasWriteAccess = hasWritePermission(project, locale);
        boolean hasGlossaryUpdateAccess = hasGlossaryUpdatePermission();
        boolean requireReview = projectIteration.getRequireTranslationReview();
        boolean hasReviewAccess = hasReviewerPermission(locale, project);

        WorkspaceRestrictions workspaceRestrictions =
                new WorkspaceRestrictions(isProjectActive, hasWriteAccess,
                        hasGlossaryUpdateAccess, hasReviewAccess, requireReview);
        log.debug("workspace restrictions: {}", workspaceRestrictions);

        LoadOptionsResult loadOptsRes =
                loadOptionsHandler
                        .execute(new LoadOptionsAction(null), context);

        GetValidationRulesResult validationRulesResult =
                getValidationRulesHandler.execute(new GetValidationRulesAction(
                        workspaceId), context);

        Identity identity = new Identity(editorClientId, person);
        workspace.getWorkspaceContext().getWorkspaceId()
                .getProjectIterationId()
                .setProjectType(projectIteration.getProjectType());
        UserWorkspaceContext userWorkspaceContext =
                new UserWorkspaceContext(workspace.getWorkspaceContext(),
                        workspaceRestrictions);
        return new ActivateWorkspaceResult(userWorkspaceContext, identity,
                loadOptsRes.getConfiguration(),
                validationRulesResult.getValidationRules());
    }
View Full Code Here

            HAccount translator, LocaleId localeId, String translation,
            ContentState translationState) throws Exception {
        SeamAutowire seamAutowire = getSeamAutowire();

        // Mock certain objects
        TranslationWorkspace transWorkspace = mock(TranslationWorkspace.class);

        WorkspaceId workspaceId =
                new WorkspaceId(new ProjectIterationId(projectSlug,
                        iterationSlug, ProjectType.Podir), localeId);
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.server.TranslationWorkspace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.