Package org.zanata.model

Examples of org.zanata.model.HTextFlowTarget


        HPerson alice = new HPerson();
        alice.setName("Alice");
        alice.setEmail("alice@example.org");
        List<HTextFlowTarget> hTargets = new ArrayList<HTextFlowTarget>();
        HTextFlowTarget tft1 = new HTextFlowTarget();
        tft1.setLastChanged(new Date(1302671654000L)); // 13 Apr 2011
        tft1.setLastModifiedBy(alice);
        hTargets.add(tft1);

        HTextFlowTarget tft2 = new HTextFlowTarget();
        tft2.setLastChanged(new Date(1304329523000L)); // 2 May 2011
        tft2.setLastModifiedBy(alice);
        hTargets.add(tft2);

        HTextFlowTarget tft3 = new HTextFlowTarget();
        tft3.setLastChanged(new Date(1262419384000L)); // 2 Jan 2010
        tft3.setLastModifiedBy(alice);
        hTargets.add(tft3);

        resourceUtils.pullPoTargetComment(fromHeader, toHeader, hTargets);

        assertThat("", toHeader.getComment(), is(expectedComment));
View Full Code Here


        }
    }

    private static ContentState getContentState(HTextFlow hTextFlow,
            HLocale hLocale) {
        HTextFlowTarget target = hTextFlow.getTargets().get(hLocale.getId());
        return target == null ? ContentState.New : target.getState();
    }
View Full Code Here

        hTextFlow.getDocument().setProjectIteration(projectIteration);
    }

    private static HTextFlowTarget addHTextFlowTarget(HLocale hLocale,
            HTextFlow hTextFlow, String username) {
        HTextFlowTarget hTextFlowTarget =
                new HTextFlowTarget(hTextFlow, hLocale);
        HPerson lastModifiedBy = new HPerson();
        HAccount account = new HAccount();
        account.setUsername(username);
        lastModifiedBy.setAccount(account);
        hTextFlowTarget.setLastModifiedBy(lastModifiedBy);
        hTextFlowTarget.setLastChanged(new Date());
        return hTextFlowTarget;
    }
View Full Code Here

            willRejectIfThereIsOldTranslationButCanNotFindTranslationToSetAsApproved() {
        TransMemoryDetails tmDetail =
                tmDetail("different project name", docId, resId, msgContext);
        action = mergeTMActionWhenProjectNameIsDifferent(MergeRule.FUZZY);

        HTextFlowTarget oldTarget =
                new HTextFlowTarget(textFlow, new HLocale());
        oldTarget.setState(ContentState.NeedReview);

        assertThat(resolver.decideStatus(action, textFlow, tmDetail,
                tmResultWithSimilarity(100), oldTarget), is(nullValue()));
    }
View Full Code Here

        if (hasValidationError) {
            return;
        }

        HTextFlowTarget hTarget =
                textFlowTargetDAO.getOrCreateTarget(originalTf,
                        matchingTarget.getLocale());
        ContentState prevState =
                hTarget.getId() == null ? ContentState.New : hTarget.getState();
        if (shouldOverwrite(hTarget, copyState)) {
            // NB we don't touch creationDate
            hTarget.setTextFlowRevision(originalTf.getRevision());
            hTarget.setLastChanged(matchingTarget.getLastChanged());
            hTarget.setLastModifiedBy(matchingTarget.getLastModifiedBy());
            hTarget.setTranslator(matchingTarget.getTranslator());
            // TODO rhbz953734 - will need a new copyTran option for
            // review state
            if (copyState == ContentState.Approved) {
                hTarget.setReviewer(matchingTarget.getReviewer());
            }
            hTarget.setContents(matchingTarget.getContents());
            hTarget.setState(copyState);
            HSimpleComment hcomment = hTarget.getComment();
            if (hcomment == null) {
                hcomment = new HSimpleComment();
                hTarget.setComment(hcomment);
            }
            hcomment.setComment(createComment(matchingTarget));

            // TODO Maybe we should think about registering a Hibernate
            // integrator for these updates
View Full Code Here

     * target locale, or if it is already good enough.
     */
    private boolean shouldFindMatch(HTextFlow textFlow, HLocale locale,
            boolean requireTranslationReview) {
        // TODO getTargets will fill up ehcache for large textflows and locales. Check which one is more efficient
        HTextFlowTarget targetForLocale =
                textFlow.getTargets().get(locale.getId());
//        HTextFlowTarget targetForLocale = textFlowTargetDAO.getTextFlowTarget(
//                textFlow, locale);

        if (targetForLocale == null
                || targetForLocale.getState() == ContentState.NeedReview) {
            return true;
        } else if (requireTranslationReview
                && targetForLocale.getState() != ContentState.Approved) {
            return true;
        } else if (!requireTranslationReview
                && targetForLocale.getState() != ContentState.Translated) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

        Long actorId = event.getActorId();
        if (actorId != null) {
            Lock lock = activityLockManager.getLock(actorId);
            lock.lock();
            try {
                HTextFlowTarget target =
                        textFlowTargetDAO.findById(event.getTextFlowTargetId(),
                                false);
                HDocument document = documentDAO.getById(event.getDocumentId());
                ActivityType activityType =
                        event.getNewState().isReviewed() ? ActivityType.REVIEWED_TRANSLATION
                                : ActivityType.UPDATE_TRANSLATION;

                logActivityAlreadyLocked(actorId,
                        document.getProjectIteration(), target, activityType,
                        target.getTextFlow().getWordCount().intValue());
            } finally {
                lock.unlock();
            }
        }
    }
View Full Code Here

        List<HTextFlowTarget> copyTargets =
                textFlowTargetDAO
                        .getByTextFlowId(tfId, batchStart, batchLength);

        for (HTextFlowTarget tft : copyTargets) {
            HTextFlowTarget newTextFlowTarget =
                    copyVersionService.copyTextFlowTarget(newTextFlow, tft);

            newTextFlow.getTargets()
                    .put(newTextFlowTarget.getLocale().getId(),
                            newTextFlowTarget);
        }
        textFlowDAO.makePersistent(newTextFlow);
        textFlowDAO.flush();
        return copyTargets.size();
View Full Code Here

    private void updateDocStatusCache(DocumentLocaleKey key,
            Long updatedTargetId) {
        DocumentStatus documentStatus = docStatusCache.get(key);
        if(documentStatus != null) {
            HTextFlowTarget target =
                getTextFlowTargetDAO().findById(updatedTargetId, false);
            updateDocumentStatus(getDocumentDAO(), documentStatus,
                key.getDocumentId(), target);
        }
    }
View Full Code Here

        }
    }

    private Boolean loadTargetValidation(Long textFlowTargetId,
            ValidationId validationId) {
        HTextFlowTarget tft =
                getTextFlowTargetDAO().findById(textFlowTargetId, false);
        if (tft != null) {
            ValidationAction action =
                    ValidationFactoryProvider.getFactoryInstance()
                            .getValidationAction(validationId);
            List<String> errorList =
                    action.validate(tft.getTextFlow().getContents().get(0), tft
                            .getContents().get(0));
            return !errorList.isEmpty();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.HTextFlowTarget

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.