Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Implement new project and version page
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 008a773
Merge: fff7d31 c325fcf
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Mar 12 09:51:59 2014 +1000

    Merge branch 'integration/master' into project-page

commit fff7d31
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Mar 12 09:50:53 2014 +1000

    implement security check for mark obsolete in UI

commit 68d2e01
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Mar 12 08:52:54 2014 +1000

    project and version page

commit a7240c0
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Mar 11 16:12:04 2014 +1000

    WIP: pager

commit 830275f
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Mar 10 16:07:17 2014 +1000

    WIP : paging and filtering component

commit b78c2c0
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Mar 7 15:27:25 2014 +1000

    WIP: version settings document tab

commit 4a49da9
Merge: 4d6b11b 86bf324
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Mar 6 20:36:13 2014 +1000

    Merge branch 'integration/master' into project-page

    Conflicts:
    	zanata-war/src/main/java/org/zanata/action/CopyTransAction.java
    	zanata-war/src/main/java/org/zanata/action/ViewAllStatusAction.java
    	zanata-war/src/main/webapp/WEB-INF/layout/validation_options.xhtml

commit 4d6b11b
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Mar 6 16:00:34 2014 +1000

    WIP: documents tab

commit bbce1e1
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Mar 6 15:16:39 2014 +1000

    Project and version page

commit 4e27af8
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Mar 6 07:32:45 2014 +1000

    Progress bar

commit 849dc1f
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Mar 5 12:40:17 2014 +1000

    create new version page

commit bd8ace9
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Mar 4 15:26:19 2014 +1000

    WIP: create new version

commit 1e69b71
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Mar 3 16:08:02 2014 +1000

    WIP: progress bar

commit 91e33c5
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Mar 3 15:25:03 2014 +1000

    WIP: progress bar

commit ceb6937
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Mar 3 11:23:12 2014 +1000

    WIP: progress bar

commit f23a39c
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 27 21:50:03 2014 +1000

    WIP: progress bar

commit 069ee88
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 27 16:11:20 2014 +1000

    WIP: progress bar

commit 9b1b534
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Feb 26 16:03:33 2014 +1000

    WIP: progress bar

commit 0fb212e
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Feb 25 16:05:21 2014 +1000

    WIP: progress bar component

commit 29f0e4c
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Feb 21 16:05:09 2014 +1000

    WIP: version settings - translation tab

commit e56caf4
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Feb 21 15:01:26 2014 +1000

    WIP: version settings - language tab

commit e9f9baf
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Feb 21 13:11:13 2014 +1000

    Version settings - general

commit 2ff17a6
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Feb 21 08:52:13 2014 +1000

    project settings page, create new project

commit a95212b
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 20 14:09:09 2014 +1000

    WIP: project settings

commit e29c006
Merge: 707928c 6846a85
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 20 11:16:10 2014 +1000

    WIP: project language tab

commit 707928c
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Feb 18 14:07:23 2014 +1000

    WIP: checkbox component

commit c7e7b8f
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Feb 18 08:49:58 2014 +1000

    WIP: project restriction role

commit ebf3af7
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Feb 17 16:10:23 2014 +1000

    WIP: project settings - role restriction

commit e1dba82
Merge: 4d01e6f ab6f3e1
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Feb 17 11:17:14 2014 +1000

    Merge branch 'integration/master' into project-page

commit 4d01e6f
Merge: 1a69a3d 5c53092
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Feb 17 09:50:40 2014 +1000

    WIP: project settings, translation tab

commit 1a69a3d
Merge: b405d37 f933e19
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 13 16:15:46 2014 +1000

    Merge branch 'integration/master' into project-page

    Conflicts:
    	zanata-war/src/main/java/org/zanata/action/ProjectIterationFilesAction.java

commit b405d37
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 13 16:14:46 2014 +1000

    WIP: project language settings

commit 811bb92
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 13 14:31:18 2014 +1000

    Rename var in messages.properties

commit fca2020
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 13 14:28:13 2014 +1000

    Project Copy trans options

commit edb0c5c
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Feb 13 07:40:44 2014 +1000

    WIP: project copy trans

commit 60043cd
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Feb 12 14:23:12 2014 +1000

    WIP: project copy trans

commit d18f385
Merge: 5fd9d62 29de499
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Feb 12 11:22:48 2014 +1000

    Merge branch 'integration/master' into project-page

    Conflicts:
    	zanata-war/src/main/webapp/iteration/view.xhtml

commit 5fd9d62
Merge: b69520f 14576f5
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Feb 11 13:01:23 2014 +1000

    Merge branch 'integration/master' into project-page

    Conflicts:
    	zanata-war/src/main/java/org/zanata/action/AbstractSortAction.java
    	zanata-war/src/main/java/org/zanata/action/SortingType.java
    	zanata-war/src/main/java/org/zanata/action/VersionGroupHomeAction.java
    	zanata-war/src/main/webapp/WEB-INF/layout/version-group/languages-tab.xhtml
    	zanata-war/src/main/webapp/WEB-INF/layout/version-group/settings-tab.xhtml
    	zanata-war/src/main/webapp/iteration/view.xhtml
    	zanata-war/src/main/webapp/resources/script/component-autocomplete.js
    	zanata-war/src/main/webapp/resources/zanata/loader.xhtml
    	zanata-war/src/main/webapp/resources/zanata/maintainers-tab.xhtml
    	zanata-war/src/main/webapp/version-group/version_group.xhtml

commit b69520f
Merge: c586fcd 93560ad
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Feb 11 07:23:03 2014 +1000

    Merge branch 'integration/master' into project-page

commit c586fcd
Merge: 9bcc434 6d62fa3
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Feb 10 08:36:59 2014 +1000

    Merge branch 'integration/master' into project-page

    Conflicts:
    	zanata-war/src/main/resources/messages.properties

commit 9bcc434
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Jan 23 10:48:52 2014 +1000

    WIP: Project setting page - translation tab(validation section)

commit 516529f
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Jan 22 16:17:48 2014 +1000

    WIP: validation options for project settings

commit e37fc29
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Jan 22 11:29:00 2014 +1000

    Project setting page - general tab

commit f269815
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Jan 21 16:00:35 2014 +1000

    WIP: project setting page - general tab

commit f07ace1
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Jan 21 13:30:27 2014 +1000

    project setting page - permission tab

commit dfcae5c
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Jan 20 15:55:00 2014 +1000

    Refactor search to a component

commit 8675093
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Jan 20 11:23:11 2014 +1000

    fix source and translation upload

commit aebf9ef
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 17 16:01:04 2014 +1000

    Fix document range display in version page

commit e94ebe5
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 17 15:40:24 2014 +1000

    WIP: version page - source file upload

commit b04e6ce
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 17 10:48:52 2014 +1000

    WIP: version page - document tab

commit b17373b
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Jan 16 16:01:27 2014 +1000

    WIP: version page-documents tab

commit 937881b
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Jan 16 15:21:06 2014 +1000

    version page - language tab

commit b13a13e
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Jan 15 16:03:55 2014 +1000

    WIP: paging for document list

commit 50e2d62
Merge: bdb7c70 45ca2dd
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Jan 15 13:35:48 2014 +1000

    Merge branch 'integration/master' into project-page

commit bdb7c70
Author: Alex Eng <aeng@redhat.com>
Date:   Wed Jan 15 13:30:54 2014 +1000

    WIP: export of files in zip

commit fd6975b
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Jan 14 15:57:35 2014 +1000

    WIP: version page

commit c4ff2d4
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 10 16:12:59 2014 +1000

    WIP: implement 'latest' for version list

commit e32da76
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 10 15:52:58 2014 +1000

    Implement filter list component

commit 9ddaa36
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 10 14:11:54 2014 +1000

    Implement filter list component

commit bc739fb
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 10 11:09:57 2014 +1000

    Update group page - language tab to filter project

commit 3b1732f
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Jan 9 16:02:38 2014 +1000

    WIP: updating group page with new markup and search

commit 984867e
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Jan 9 14:03:38 2014 +1000

    WIP - versions tab, maintainers tab, and notes tab in new project page

commit 4adf511
Author: Alex Eng <aeng@redhat.com>
Date:   Thu Jan 9 08:49:29 2014 +1000

    Make Maintainer tab a share component

commit a110284
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Jan 7 15:56:52 2014 +1000

    Project page - maintainers tab

commit 24b752d
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Jan 7 15:48:16 2014 +1000

    WIP: project page - main content

commit 40d67d0
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Jan 7 10:27:50 2014 +1000

    WIP: extract activity entry into component

commit c6c54a0
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Jan 6 15:44:59 2014 +1000

    WIP: project page - activity section

commit 9224c02
Author: Alex Eng <aeng@redhat.com>
Date:   Mon Jan 6 12:57:17 2014 +1000

    Fix key navtigation in project search drop down

commit 60ad23f
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 3 15:18:53 2014 +1000

    WIP: scrolling for project search

commit 57e5194
Author: Alex Eng <aeng@redhat.com>
Date:   Fri Jan 3 10:22:21 2014 +1000

    Update markup for group page

commit bb726ce
Author: Alex Eng <aeng@redhat.com>
Date:   Tue Dec 24 11:20:39 2013 +1000

    WIP: update settings markup
  • Loading branch information
Alex Eng committed Mar 12, 2014
1 parent c325fcf commit aaafe38
Show file tree
Hide file tree
Showing 118 changed files with 7,876 additions and 6,372 deletions.
Expand Up @@ -72,7 +72,7 @@ public void uploadHTMLFile() {
"<html><title>Test content</title><br>This is <b>Bold</b> text</html>");
String testFileName = htmlfile.getName();
String successfullyUploaded =
"Document file " + testFileName + " uploaded.";
"Document " + testFileName + " uploaded.";
ProjectSourceDocumentsPage projectSourceDocumentsPage =
new LoginWorkFlow().signIn("admin", "admin").goToProjects()
.goToProject("about fedora").goToVersion("master")
Expand Down
Expand Up @@ -79,7 +79,7 @@ public void uploadedDocumentIsInFilesystem() {
"This is a test file");
String testFileName = originalFile.getName();
String successfullyUploaded =
"Document file " + testFileName + " uploaded.";
"Document " + testFileName + " uploaded.";

ProjectSourceDocumentsPage projectSourceDocumentsPage =
new LoginWorkFlow().signIn("admin", "admin").goToProjects()
Expand Down Expand Up @@ -169,7 +169,7 @@ public void failOnInvalidFileUpload() {
testFileGenerator.generateTestFileWithContent("thereIsNoSpoon",
".txt", "This file will be deleted");
String successfullyUploaded =
"Document file " + noFile.getName() + " uploaded.";
"Document " + noFile.getName() + " uploaded.";

ProjectSourceDocumentsPage projectSourceDocumentsPage =
new LoginWorkFlow().signIn("admin", "admin").goToProjects()
Expand All @@ -194,7 +194,7 @@ public void handleVeryLongFileNames() {
testFileGenerator.longFileName(), ".txt",
"This filename is long");
String successfullyUploaded =
"Document file " + longFile.getName() + " uploaded.";
"Document " + longFile.getName() + " uploaded.";

ProjectSourceDocumentsPage projectSourceDocumentsPage =
new LoginWorkFlow().signIn("admin", "admin").goToProjects()
Expand All @@ -217,7 +217,7 @@ public void emptyFile() {
testFileGenerator.generateTestFileWithContent("emptyFile",
".txt", "");
String successfullyUploaded =
"Document file " + emptyFile.getName() + " uploaded.";
"Document " + emptyFile.getName() + " uploaded.";

assumeTrue("File is empty", emptyFile.length() == 0);

Expand Down
2 changes: 1 addition & 1 deletion zanata-war/pom.xml
Expand Up @@ -1926,7 +1926,7 @@
<dependency>
<groupId>org.ocpsoft.prettytime</groupId>
<artifactId>prettytime</artifactId>
<version>3.0.2.Final</version>
<version>3.2.4.Final</version>
</dependency>

<!-- openid4java -->
Expand Down
265 changes: 1 addition & 264 deletions zanata-war/src/main/java/org/zanata/action/ActivityAction.java
Expand Up @@ -30,20 +30,9 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.security.management.JpaIdentityStore;
import org.zanata.annotation.CachedMethodResult;
import org.zanata.common.ActivityType;
import org.zanata.dao.DocumentDAO;
import org.zanata.model.Activity;
import org.zanata.model.HAccount;
import org.zanata.model.HDocument;
import org.zanata.model.HProjectIteration;
import org.zanata.model.HTextFlowTarget;
import org.zanata.model.type.EntityType;
import org.zanata.service.ActivityService;
import org.zanata.util.DateUtil;
import org.zanata.util.ShortString;
import org.zanata.util.UrlUtil;
import org.zanata.util.ZanataMessages;

/**
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
Expand All @@ -54,22 +43,14 @@
public class ActivityAction implements Serializable {
private static final long serialVersionUID = 1L;

@In
private DocumentDAO documentDAO;

@In
private UrlUtil urlUtil;

@In
private ActivityService activityServiceImpl;

@In
private ZanataMessages zanataMessages;

@In(required = false, value = JpaIdentityStore.AUTHENTICATED_USER)
private HAccount authenticatedAccount;

private final int ACTIVITY_COUNT_PER_LOAD = 5;

private final int MAX_ACTIVITIES_COUNT_PER_PAGE = 20;

private int activityPageIndex = 0;
Expand All @@ -86,244 +67,10 @@ public List<Activity> getActivities() {
return activities;
}

public String getHowLongAgoDescription(Activity activity) {
return DateUtil.getHowLongAgoDescription(activity.getLastChanged());
}

public String getProjectName(Activity activity) {
Object context =
getEntity(activity.getContextType(), activity.getContextId());

if (isTranslationUpdateActivity(activity.getActivityType())
|| activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT
|| activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
return version.getProject().getName();
}
return "";
}

public String getProjectUrl(Activity activity) {
Object context =
getEntity(activity.getContextType(), activity.getContextId());

if (isTranslationUpdateActivity(activity.getActivityType())
|| activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT
|| activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
return urlUtil.projectUrl(version.getProject().getSlug());
}
return "";
}

public String getLastTextFlowContent(Activity activity) {
String content = "";
Object lastTarget =
getEntity(activity.getLastTargetType(),
activity.getLastTargetId());

if (isTranslationUpdateActivity(activity.getActivityType())) {
HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
content = tft.getTextFlow().getContents().get(0);
}

return ShortString.shorten(content);
}

public String getEditorUrl(Activity activity) {
String url = "";
Object context =
getEntity(activity.getContextType(), activity.getContextId());
Object lastTarget =
getEntity(activity.getLastTargetType(),
activity.getLastTargetId());

if (isTranslationUpdateActivity(activity.getActivityType())) {
HProjectIteration version = (HProjectIteration) context;
HTextFlowTarget tft = (HTextFlowTarget) lastTarget;

url =
urlUtil.editorTransUnitUrl(version.getProject().getSlug(),
version.getSlug(), tft.getLocaleId(), tft
.getTextFlow().getLocale(), tft
.getTextFlow().getDocument().getDocId(),
tft.getTextFlow().getId());
} else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
// not supported for upload source action
} else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
HDocument document = (HDocument) lastTarget;
HTextFlowTarget tft =
documentDAO.getLastTranslatedTargetOrNull(document.getId());

if (tft != null) {
url =
urlUtil.editorTransUnitUrl(version.getProject()
.getSlug(), version.getSlug(), tft
.getLocaleId(), document.getSourceLocaleId(),
tft.getTextFlow().getDocument().getDocId(), tft
.getTextFlow().getId());
}
}
return url;
}

public String getDocumentUrl(Activity activity) {
String url = "";
Object context =
getEntity(activity.getContextType(), activity.getContextId());
Object lastTarget =
getEntity(activity.getLastTargetType(),
activity.getLastTargetId());

if (isTranslationUpdateActivity(activity.getActivityType())) {
HProjectIteration version = (HProjectIteration) context;
HTextFlowTarget tft = (HTextFlowTarget) lastTarget;

url =
urlUtil.editorDocumentUrl(version.getProject().getSlug(),
version.getSlug(), tft.getLocaleId(), tft
.getTextFlow().getLocale(), tft
.getTextFlow().getDocument().getDocId());
} else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
url =
urlUtil.sourceFilesViewUrl(version.getProject().getSlug(),
version.getSlug());
} else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
HDocument document = (HDocument) lastTarget;
HTextFlowTarget tft =
documentDAO.getLastTranslatedTargetOrNull(document.getId());

if (tft != null) {
url =
urlUtil.editorDocumentUrl(version.getProject()
.getSlug(), version.getSlug(), tft
.getLocaleId(), document.getSourceLocaleId(),
tft.getTextFlow().getDocument().getDocId());
}
}
return url;
}

public String getDocumentName(Activity activity) {
Object lastTarget =
getEntity(activity.getLastTargetType(),
activity.getLastTargetId());
String docName = "";

if (isTranslationUpdateActivity(activity.getActivityType())) {
HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
docName = tft.getTextFlow().getDocument().getName();
} else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT
|| activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HDocument document = (HDocument) lastTarget;
docName = document.getName();
}
return docName;
}

public String getVersionUrl(Activity activity) {
Object context =
getEntity(activity.getContextType(), activity.getContextId());
String url = "";

if (isTranslationUpdateActivity(activity.getActivityType())
|| activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT
|| activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
url =
urlUtil.versionUrl(version.getProject().getSlug(),
version.getSlug());
}

return url;
}

public String getVersionName(Activity activity) {
Object context =
getEntity(activity.getContextType(), activity.getContextId());
String name = "";

if (isTranslationUpdateActivity(activity.getActivityType())
|| activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT
|| activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
name = version.getSlug();
}
return name;
}

public String getDocumentListUrl(Activity activity) {
Object context =
getEntity(activity.getContextType(), activity.getContextId());
Object lastTarget =
getEntity(activity.getLastTargetType(),
activity.getLastTargetId());
String url = "";

if (isTranslationUpdateActivity(activity.getActivityType())) {
HProjectIteration version = (HProjectIteration) context;
HTextFlowTarget tft = (HTextFlowTarget) lastTarget;

url =
urlUtil.editorDocumentListUrl(version.getProject()
.getSlug(), version.getSlug(), tft.getLocaleId(),
tft.getTextFlow().getLocale());
} else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
// not supported for upload source action
} else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HProjectIteration version = (HProjectIteration) context;
HDocument document = (HDocument) lastTarget;
HTextFlowTarget tft =
documentDAO.getLastTranslatedTargetOrNull(document.getId());

if (tft != null) {
url =
urlUtil.editorDocumentListUrl(version.getProject()
.getSlug(), version.getSlug(), tft
.getLocaleId(), tft.getTextFlow().getLocale());
}
}
return url;
}

public String getLanguageName(Activity activity) {
Object lastTarget =
getEntity(activity.getLastTargetType(),
activity.getLastTargetId());
String name = "";

if (isTranslationUpdateActivity(activity.getActivityType())) {
HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
name = tft.getLocaleId().getId();
} else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
// not supported for upload source action
} else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
HDocument document = (HDocument) lastTarget;
HTextFlowTarget tft =
documentDAO.getLastTranslatedTargetOrNull(document.getId());

if (tft != null) {
name = tft.getLocaleId().getId();
}
}

return name;
}

public void loadNextActivity() {
activityPageIndex++;
}

public String getWordsCountMessage(int wordCount) {
if (wordCount == 1) {
return wordCount + " word";
}
return wordCount + " words";
}

public boolean hasMoreActivities() {
int loadedActivitiesCount =
(activityPageIndex + 1) * ACTIVITY_COUNT_PER_LOAD;
Expand All @@ -338,14 +85,4 @@ public boolean hasMoreActivities() {
}
return false;
}

@CachedMethodResult
private Object getEntity(EntityType contextType, long id) {
return activityServiceImpl.getEntity(contextType, id);
}

private boolean isTranslationUpdateActivity(ActivityType activityType) {
return activityType == ActivityType.UPDATE_TRANSLATION
|| activityType == ActivityType.REVIEWED_TRANSLATION;
}
}

0 comments on commit aaafe38

Please sign in to comment.