Пример #1
0
  @Override
  public GetDocumentListResult execute(GetDocumentList action, ExecutionContext context)
      throws ActionException {
    identity.checkLoggedIn();

    LocaleId localeId = action.getWorkspaceId().getLocaleId();
    ProjectIterationId iterationId = action.getProjectIterationId();
    ArrayList<DocumentInfo> docs = new ArrayList<DocumentInfo>();
    HProjectIteration hProjectIteration =
        projectIterationDAO.getBySlug(iterationId.getProjectSlug(), iterationId.getIterationSlug());
    Collection<HDocument> hDocs = hProjectIteration.getDocuments().values();
    for (HDocument hDoc : hDocs) {
      if (action.getFilters() == null
          || action.getFilters().isEmpty()
          || action.getFilters().contains(hDoc.getPath() + hDoc.getName())) {
        DocumentId docId = new DocumentId(hDoc.getId(), hDoc.getDocId());
        TranslationStats stats = documentDAO.getStatistics(hDoc.getId(), localeId);
        String lastModifiedBy = "";
        HPerson person = hDoc.getLastModifiedBy();
        if (person != null) {
          lastModifiedBy = person.getAccount().getUsername();
        }

        Map<String, String> downloadExtensions = new HashMap<String, String>();
        downloadExtensions.put(".po", "po?docId=" + hDoc.getDocId());
        if (translationFileServiceImpl.hasPersistedDocument(
            iterationId.getProjectSlug(),
            iterationId.getIterationSlug(),
            hDoc.getPath(),
            hDoc.getName())) {
          String extension =
              "."
                  + translationFileServiceImpl.getFileExtension(
                      iterationId.getProjectSlug(),
                      iterationId.getIterationSlug(),
                      hDoc.getPath(),
                      hDoc.getName());
          downloadExtensions.put(extension, "baked?docId=" + hDoc.getDocId());
        }

        DocumentInfo doc =
            new DocumentInfo(
                docId,
                hDoc.getName(),
                hDoc.getPath(),
                hDoc.getLocale().getLocaleId(),
                stats,
                lastModifiedBy,
                hDoc.getLastChanged(),
                downloadExtensions);
        docs.add(doc);
      }
    }
    return new GetDocumentListResult(iterationId, docs);
  }
Пример #2
0
  @Override
  public GetDocumentListResult execute(GetDocumentList action, ExecutionContext context)
      throws ActionException {

    ZanataIdentity.instance().checkLoggedIn();

    ProjectIterationId iterationId = action.getProjectIterationId();
    ArrayList<DocumentInfo> docs = new ArrayList<DocumentInfo>();
    HProjectIteration hProjectIteration =
        projectIterationDAO.getBySlug(iterationId.getProjectSlug(), iterationId.getIterationSlug());
    Collection<HDocument> hDocs = hProjectIteration.getDocuments().values();
    for (HDocument hDoc : hDocs) {
      DocumentId docId = new DocumentId(hDoc.getId());
      DocumentInfo doc = new DocumentInfo(docId, hDoc.getName(), hDoc.getPath());
      docs.add(doc);
    }
    return new GetDocumentListResult(iterationId, docs);
  }