mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Mantis connector.Serialization fix, retrieving comments and correct extractID method.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.tasks;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -88,7 +89,13 @@ public abstract class Task {
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return isIssue() ? getId() : getSummary();
|
||||
String text;
|
||||
if (isIssue()) {
|
||||
text = getId() + ": " + getSummary();
|
||||
} else {
|
||||
text = getSummary();
|
||||
}
|
||||
return StringUtil.first(text, 60, true);
|
||||
}
|
||||
|
||||
public String getPresentableName() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.intellij.tasks.mantis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -8,6 +9,7 @@ import java.util.List;
|
||||
*/
|
||||
public class MantisProject {
|
||||
public final static MantisProject ALL_PROJECTS = new MantisProject(0, "All Projects");
|
||||
public static final ArrayList<MantisFilter> EMPTY_LIST = new ArrayList<MantisFilter>();
|
||||
|
||||
private List<MantisFilter> myFilters;
|
||||
|
||||
@@ -40,7 +42,7 @@ public class MantisProject {
|
||||
}
|
||||
|
||||
public List<MantisFilter> getFilters() {
|
||||
return myFilters;
|
||||
return myFilters == null ? EMPTY_LIST : myFilters;
|
||||
}
|
||||
|
||||
public void setFilters(final List<MantisFilter> filters) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.intellij.tasks.mantis;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.tasks.Comment;
|
||||
import com.intellij.tasks.Task;
|
||||
import com.intellij.tasks.TaskRepositoryType;
|
||||
import com.intellij.tasks.actions.TaskSearchSupport;
|
||||
@@ -12,6 +13,7 @@ import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.apache.axis.utils.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.rpc.ServiceException;
|
||||
@@ -19,7 +21,10 @@ import java.math.BigInteger;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
@@ -52,6 +57,13 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
return new MantisRepository(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String extractId(final String taskName) {
|
||||
Matcher matcher = Pattern.compile("\\d+").matcher(taskName);
|
||||
return matcher.find() ? matcher.group() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getIssues(@Nullable String request, int max, long since) throws Exception {
|
||||
MantisConnectPortType soap = createSoap();
|
||||
@@ -123,6 +135,35 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
public String getDescription() {
|
||||
return data.getDescription();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Comment[] getComments() {
|
||||
final List<Comment> comments = ContainerUtil.map(data.getNotes(), new Function<IssueNoteData, Comment>() {
|
||||
@Override
|
||||
public Comment fun(final IssueNoteData data) {
|
||||
return new Comment() {
|
||||
@Override
|
||||
public String getText() {
|
||||
return data.getText();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return data.getReporter().getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Date getDate() {
|
||||
return data.getDate_submitted().getTime();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
return comments.toArray(new Comment[comments.size()]);
|
||||
}
|
||||
};
|
||||
|
||||
task.setUpdated(data.getLast_updated().getTime());
|
||||
@@ -184,6 +225,8 @@ public class MantisRepository extends BaseRepositoryImpl {
|
||||
project.setFilters(filters);
|
||||
myProjects.add(project);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private synchronized MantisConnectPortType createSoap() throws ServiceException, MalformedURLException {
|
||||
|
||||
@@ -2,15 +2,16 @@ package com.intellij.tasks.mantis;
|
||||
|
||||
import com.intellij.tasks.TaskRepository;
|
||||
import com.intellij.tasks.impl.LocalTaskImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MantisTask extends LocalTaskImpl {
|
||||
private MantisProject myProject;
|
||||
private String myProjectName;
|
||||
private MantisRepository myRepository;
|
||||
|
||||
public MantisTask(final String id, final String summary, MantisProject project, MantisRepository repository) {
|
||||
super(id, summary);
|
||||
myProject = project;
|
||||
myProjectName = !MantisProject.ALL_PROJECTS.equals(project) ? project.getName() : null;
|
||||
myRepository = repository;
|
||||
}
|
||||
|
||||
@@ -27,6 +28,14 @@ public class MantisTask extends LocalTaskImpl {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getProject() {
|
||||
return !MantisProject.ALL_PROJECTS.equals(myProject) ? myProject.getName() : null;
|
||||
return myProjectName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getNumber() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user