Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 145920 Details for
Bug 233757
sort jira versions shown in the task editor in reversed order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Show versions in reverse order like JIRA does with TEST
Show versions in reverse order like JIRA does with TESTS.txt (text/plain), 3.60 KB, created by
Jacek Jaroczynski
on 2009-08-28 06:44:12 EDT
(
hide
)
Description:
Show versions in reverse order like JIRA does with TEST
Filename:
MIME Type:
Creator:
Jacek Jaroczynski
Created:
2009-08-28 06:44:12 EDT
Size:
3.60 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.jira.core >Index: src/org/eclipse/mylyn/internal/jira/core/service/JiraClient.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.jira.core/src/org/eclipse/mylyn/internal/jira/core/service/JiraClient.java,v >retrieving revision 1.41 >diff -u -r1.41 JiraClient.java >--- src/org/eclipse/mylyn/internal/jira/core/service/JiraClient.java 24 Jul 2009 12:04:22 -0000 1.41 >+++ src/org/eclipse/mylyn/internal/jira/core/service/JiraClient.java 28 Aug 2009 10:39:22 -0000 >@@ -14,6 +14,10 @@ > > import java.io.File; > import java.io.OutputStream; >+import java.util.Arrays; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.List; > > import org.apache.commons.httpclient.methods.multipart.PartSource; > import org.eclipse.core.runtime.Assert; >@@ -389,8 +393,35 @@ > return (credentials != null) ? credentials.getUserName() : ""; //$NON-NLS-1$ > } > >+ /** >+ * Returns sorted array of versions in descended order (the same as JIRA presents) >+ * >+ * @param key >+ * @param monitor >+ * @return >+ * @throws JiraException >+ */ > public Version[] getVersions(String key, IProgressMonitor monitor) throws JiraException { >- return soapClient.getVersions(key, monitor); >+ return sortVersions(soapClient.getVersions(key, monitor)); >+ } >+ >+ /** >+ * Returns sorted array of versions in descended order (the same as JIRA presents) >+ * >+ * @param versions >+ * @return sorted list of versions >+ */ >+ public static Version[] sortVersions(Version[] versions) { >+ >+ List<Version> versionsList = Arrays.asList(versions); >+ >+ Collections.sort(versionsList, new Comparator<Version>() { >+ public int compare(Version o1, Version o2) { >+ return o1.getSequence() > o2.getSequence() ? -1 : (o1.getSequence() == o2.getSequence() ? 0 : 1); >+ } >+ }); >+ >+ return versionsList.toArray(new Version[0]); > } > > @Override >#P org.eclipse.mylyn.jira.tests >Index: src/org/eclipse/mylyn/jira/tests/client/JiraClientTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.jira.tests/src/org/eclipse/mylyn/jira/tests/client/JiraClientTest.java,v >retrieving revision 1.19 >diff -u -r1.19 JiraClientTest.java >--- src/org/eclipse/mylyn/jira/tests/client/JiraClientTest.java 24 Jul 2009 12:04:56 -0000 1.19 >+++ src/org/eclipse/mylyn/jira/tests/client/JiraClientTest.java 28 Aug 2009 10:39:26 -0000 >@@ -767,4 +767,34 @@ > Project project = client.getCache().getProjectById("10050"); > assertNotNull(project.getSecurityLevels()); > } >+ >+ public void testSortVersions() throws JiraException { >+ >+ Version version1 = buildVersion("0.1.0", 1); >+ Version version2 = buildVersion("0.2.0", 2); >+ Version version3 = buildVersion("0.2.1", 3); >+ Version version4 = buildVersion("1.0.0-beta1", 4); >+ Version version5 = buildVersion("1.0.0", 5); >+ >+ Version[] versions = { version2, version5, version3, version1, version4 }; >+ >+ Version[] sortedVersion = JiraClient.sortVersions(versions); >+ >+ assertEquals(versions.length, sortedVersion.length); >+ >+ assertEquals(version5, sortedVersion[0]); >+ assertEquals(version4, sortedVersion[1]); >+ assertEquals(version3, sortedVersion[2]); >+ assertEquals(version2, sortedVersion[3]); >+ assertEquals(version1, sortedVersion[4]); >+ >+ } >+ >+ private Version buildVersion(String name, long sequence) { >+ Version version = new Version(name + sequence); >+ version.setName(name); >+ version.setSequence(sequence); >+ >+ return version; >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 233757
:
145754
|
145858
| 145920 |
145921