Package org.zanata.webtrans.shared.model

Examples of org.zanata.webtrans.shared.model.TransUnitUpdateInfo


        DocumentId documentId =
                new DocumentId(document.getId(), document.getDocId());
        int wordCount = textFlow.getWordCount().intValue();

        TransUnitUpdateInfo updateInfo =
                createTransUnitUpdateInfo(transUnit, documentId, wordCount,
                        previousVersionNum, previousState);

        CacheValue context =
                updateContext.getIfPresent(new CacheKey(transUnit.getId(),
View Full Code Here


    }

    private static TransUnitUpdateInfo createTransUnitUpdateInfo(
            TransUnit transUnit, DocumentId documentId, int wordCount,
            int previousVersionNum, ContentState previousState) {
        return new TransUnitUpdateInfo(true, true, documentId, transUnit,
                wordCount, previousVersionNum, previousState, null);
    }
View Full Code Here

    }

    @Override
    public void onTransUnitUpdated(TransUnitUpdatedEvent event) {
        TransUnitUpdateInfo updateInfo = event.getUpdateInfo();
        // update stats for containing document
        DocumentInfo updatedDoc = getDocumentInfo(updateInfo.getDocumentId());
        ContainerTranslationStatistics currentStats = updatedDoc.getStats();
        if (currentStats != null) {
            adjustStats(currentStats, updateInfo);
            updatedDoc.setStats(currentStats);
View Full Code Here

                new TransUnitUpdatedEventHandler() {

                    @Override
                    public void onTransUnitUpdated(
                            final TransUnitUpdatedEvent event) {
                        TransUnitUpdateInfo updateInfo = event.getUpdateInfo();
                        TransUnitReplaceInfo replaceInfo =
                                allReplaceInfos.get(updateInfo.getTransUnit()
                                        .getId());
                        if (replaceInfo == null) {
                            Log.debug("no matching TU in document for TU update, id: "
                                    + updateInfo.getTransUnit().getId().getId());
                            return;
                        }
                        Log.debug("found matching TU for TU update, id: "
                                + updateInfo.getTransUnit().getId().getId());

                        if (replaceInfo.getReplaceState() == ReplacementState.Replaced
                                && !(replaceInfo.getTransUnit().getVerNum()
                                        .equals(updateInfo.getTransUnit()
                                                .getVerNum()))) {
                            // can't undo after additional update
                            setReplaceState(replaceInfo,
                                    ReplacementState.NotReplaced);
                            replaceInfo.setReplaceInfo(null);
                            replaceInfo
                                    .setPreviewState(PreviewState.NotFetched);
                            replaceInfo.setPreview(null);

                            MultiSelectionModel<TransUnitReplaceInfo> selectionModel =
                                    documentSelectionModels.get(updateInfo
                                            .getDocumentId().getId());
                            if (selectionModel == null) {
                                Log.error("missing selection model for document, id: "
                                        + updateInfo.getDocumentId().getId());
                            } else {
                                // clear selection to avoid accidental inclusion
                                // in batch
                                // operations
                                selectionModel.setSelected(replaceInfo, false);
                            }
                        }
                        replaceInfo.setTransUnit(updateInfo.getTransUnit());
                        refreshInfoDisplay(replaceInfo);
                    }
                }));

        registerHandler(eventBus.addHandler(
View Full Code Here

                    return;
                }

                String message;
                if (updateInfoList.size() == 1) {
                    TransUnitUpdateInfo info = updateInfoList.get(0);
                    String text = info.getTransUnit().getTargets().get(0);
                    String truncatedText =
                            text.substring(
                                    0,
                                    (text.length() <= TRUNCATED_TARGET_LENGTH ? text
                                            .length() : TRUNCATED_TARGET_LENGTH));
                    int oneBasedRowIndex =
                            info.getTransUnit().getRowIndex() + 1;
                    String docName = docPaths.get(info.getDocumentId().getId());
                    message =
                            messages.replacedTextInOneTextFlow(searchText,
                                    replacement, docName, oneBasedRowIndex,
                                    truncatedText);
                } else {
View Full Code Here

    }

    @Test
    public void testExecute() throws Exception {
        List<TransUnitUpdateInfo> updatesToRevert =
                Lists.newArrayList(new TransUnitUpdateInfo(true, true,
                        new DocumentId(new Long(1), ""), TestFixture
                                .makeTransUnit(1), 0, 0, ContentState.Approved));
        RevertTransUnitUpdates action =
                new RevertTransUnitUpdates(updatesToRevert);
        action.setWorkspaceId(new WorkspaceId(new ProjectIterationId("", "",
View Full Code Here

                TransUnit.Builder.newTransUnitBuilder()
                        .setId(firstTu.getTransUnitId().getId())
                        .setVerNum(firstTu.getBaseTranslationVersion() + 1)
                        .setResId("dummyRestId").setLocaleId(LocaleId.EN_US)
                        .setSources(firstTu.getNewContents()).build();
        TransUnitUpdateInfo updateInfo =
                new TransUnitUpdateInfo(true, true, new DocumentId(new Long(0),
                        ""), tu, 5, firstTu.getBaseTranslationVersion(),
                        ContentState.NeedReview);
        UpdateTransUnitResult result = new UpdateTransUnitResult(updateInfo);
        callback.onSuccess(result);
        Log.info("EXIT DummyUpdateTransUnitCommand.execute()");
View Full Code Here

    }

    private static UpdateTransUnitResult
            result(boolean success, TransUnit transUnit,
                    ContentState previousState, String errorMessage) {
        return new UpdateTransUnitResult(new TransUnitUpdateInfo(success, true,
                new DocumentId(new Long(1), ""), transUnit, 9, VER_NUM,
                previousState, errorMessage));
    }
View Full Code Here

                        .setTargets(targets).setStatus(ContentState.Approved)
                        .setLastModifiedBy("lastModifiedBy")
                        .setLastModifiedTime(new Date())
                        .setMsgContext("msgContext").setRowIndex(1)
                        .setVerNum(1).build();
        TransUnitUpdateInfo updateInfo =
                new TransUnitUpdateInfo(true, true, new DocumentId(2222L,
                        "match/exact/filter"), newTransUnit, 3, 0,
                        ContentState.NeedReview);
        TransUnitUpdatedEvent mockEvent = mock(TransUnitUpdatedEvent.class);

        when(mockEvent.getUpdateInfo()).thenReturn(updateInfo);
View Full Code Here

                callbackCaptor.capture());
        AsyncCallback<UpdateTransUnitResult> callback =
                callbackCaptor.getValue();
        // rpc call success and result has some updated info
        UpdateTransUnitResult result = new UpdateTransUnitResult();
        result.addUpdateResult(new TransUnitUpdateInfo(true, true, documentId,
                currentPageRows.get(0), 0, 0, ContentState.Approved));
        // add an unsuccessful result
        result.addUpdateResult(new TransUnitUpdateInfo(false, true, documentId,
                currentPageRows.get(1), 0, 0, ContentState.Approved));
        result.addUpdateResult(new TransUnitUpdateInfo(true, true, documentId,
                currentPageRows.get(2), 0, 0, ContentState.Approved));
        result.addUpdateResult(new TransUnitUpdateInfo(true, true, documentId,
                currentPageRows.get(3), 0, 0, ContentState.Approved));
        callback.onSuccess(result);

        // Then:
        verify(messages).mergeTMSuccess(Lists.newArrayList("1", "3", "4"));
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.shared.model.TransUnitUpdateInfo

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.