mirror of
https://github.com/e1fueg0/intellij-gitea-plugin.git
synced 2024-10-27 20:34:04 +00:00
#9: - reworked offset/limit processing; - implemented 'assigned to me' filter
This commit is contained in:
parent
01a7e1a17f
commit
dc98e2adac
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright © 2019 by elfuego.biz
|
||||||
|
-->
|
||||||
|
|
||||||
<idea-plugin>
|
<idea-plugin>
|
||||||
<id>biz.elfuego.idea.issues.gitea</id>
|
<id>biz.elfuego.idea.issues.gitea</id>
|
||||||
<name>Gitea issues</name>
|
<name>Gitea issues</name>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea;
|
package biz.elfuego.idea.issues.gitea;
|
||||||
|
|
||||||
import biz.elfuego.idea.issues.gitea.model.GiteaTask;
|
import biz.elfuego.idea.issues.gitea.model.GiteaTask;
|
||||||
|
import biz.elfuego.idea.issues.gitea.model.GiteaUser;
|
||||||
import biz.elfuego.idea.issues.gitea.util.Consts;
|
import biz.elfuego.idea.issues.gitea.util.Consts;
|
||||||
import biz.elfuego.idea.issues.gitea.util.Consts.CommentFields;
|
import biz.elfuego.idea.issues.gitea.util.Consts.CommentFields;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
@ -31,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -43,12 +45,14 @@ import static biz.elfuego.idea.issues.gitea.util.Utils.*;
|
|||||||
@Tag("Gitea")
|
@Tag("Gitea")
|
||||||
class GiteaRepository extends BaseRepositoryImpl {
|
class GiteaRepository extends BaseRepositoryImpl {
|
||||||
private static final Logger logger = Logger.getInstance(GiteaRepository.class);
|
private static final Logger logger = Logger.getInstance(GiteaRepository.class);
|
||||||
|
private static final int DEFAULT_PAGE = 10;
|
||||||
|
|
||||||
private String userId = null;
|
private String userId = null;
|
||||||
private String userLogin = null;
|
private String userLogin = null;
|
||||||
private String repoName = null;
|
private String repoName = null;
|
||||||
private String projName = null;
|
private String projName = null;
|
||||||
private String token = null;
|
private String token = null;
|
||||||
|
private boolean assigned = false;
|
||||||
|
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public GiteaRepository() {
|
public GiteaRepository() {
|
||||||
@ -70,6 +74,7 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
repoName = other.repoName;
|
repoName = other.repoName;
|
||||||
projName = other.projName;
|
projName = other.projName;
|
||||||
token = other.token;
|
token = other.token;
|
||||||
|
assigned = other.assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,7 +86,8 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
equal(userLogin, other.userLogin) &&
|
equal(userLogin, other.userLogin) &&
|
||||||
equal(repoName, other.repoName) &&
|
equal(repoName, other.repoName) &&
|
||||||
equal(projName, other.projName) &&
|
equal(projName, other.projName) &&
|
||||||
equal(token, other.token);
|
equal(token, other.token) &&
|
||||||
|
equal(assigned, other.assigned);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equal(Object o1, Object o2) {
|
private boolean equal(Object o1, Object o2) {
|
||||||
@ -248,7 +254,7 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
return findIssues(null, -1, -1, false, null);
|
return findIssues(null, -1, -1, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task[] findIssues(String query, int offset, int limit, boolean withClosed, ProgressIndicator cancelled) throws Exception {
|
private Task[] findIssues(String query, int offset, int limit, boolean withClosed, @SuppressWarnings("unused") ProgressIndicator cancelled) throws Exception {
|
||||||
if (!ensureUserId())
|
if (!ensureUserId())
|
||||||
return new Task[]{};
|
return new Task[]{};
|
||||||
|
|
||||||
@ -263,11 +269,10 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
List<GiteaTaskImpl> result = new ArrayList<>();
|
List<GiteaTaskImpl> result = new ArrayList<>();
|
||||||
final String url = getApiUrl() + Consts.EndPoint.REPOS + getProject() + Consts.EndPoint.ISSUES + qu.toString();
|
final String url = getApiUrl() + Consts.EndPoint.REPOS + getProject() + Consts.EndPoint.ISSUES + qu.toString();
|
||||||
|
|
||||||
int firstPage = offset / 10;
|
int firstPage = offset / DEFAULT_PAGE;
|
||||||
int lastPage = (offset + limit) / 10;
|
for (int p = firstPage + 1; ; p++) {
|
||||||
|
if (!loadPage(url, result, p, limit - result.size(),
|
||||||
for (int p = firstPage + 1; p <= lastPage; p++) {
|
assigned ? ((task) -> task.isAssignedTo(userLogin)) : null))
|
||||||
if (!loadPage(url, result, p))
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +280,7 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
return result.toArray(new Task[0]);
|
return result.toArray(new Task[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean loadPage(String url, List<GiteaTaskImpl> result, int page) throws Exception {
|
private boolean loadPage(String url, List<GiteaTaskImpl> result, int page, int limit, Function<GiteaTask, Boolean> val) throws Exception {
|
||||||
final JsonElement response = executeMethod(new GetMethod(url + page));
|
final JsonElement response = executeMethod(new GetMethod(url + page));
|
||||||
if (response == null)
|
if (response == null)
|
||||||
return false;
|
return false;
|
||||||
@ -285,11 +290,15 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
for (int i = 0; i < tasks.size(); i++) {
|
for (int i = 0; i < tasks.size(); i++) {
|
||||||
JsonObject current = tasks.get(i).getAsJsonObject();
|
JsonObject current = tasks.get(i).getAsJsonObject();
|
||||||
GiteaTask raw = new GiteaTask(getProject(), current);
|
GiteaTask raw = new GiteaTask(getProject(), current);
|
||||||
if (!raw.isValid()) {
|
if (!raw.isValid())
|
||||||
|
continue;
|
||||||
|
if (val != null && !val.apply(raw))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
GiteaTaskImpl mapped = new GiteaTaskImpl(this, raw);
|
GiteaTaskImpl mapped = new GiteaTaskImpl(this, raw);
|
||||||
result.add(mapped);
|
result.add(mapped);
|
||||||
|
limit--;
|
||||||
|
if (limit < 1)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -313,10 +322,12 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
JsonObject current = comments.get(i).getAsJsonObject();
|
JsonObject current = comments.get(i).getAsJsonObject();
|
||||||
Date date = getDate(current, CommentFields.DATE);
|
Date date = getDate(current, CommentFields.DATE);
|
||||||
String text = getString(current, CommentFields.TEXT, "");
|
String text = getString(current, CommentFields.TEXT, "");
|
||||||
JsonObject user = getObject(current, CommentFields.USER);
|
JsonObject juser = getObject(current, CommentFields.USER);
|
||||||
String author = getString(user, CommentFields.FULLNAME, "");
|
String author = "";
|
||||||
if (author.isEmpty())
|
if (!juser.isJsonNull()) {
|
||||||
author = getString(user, CommentFields.USERNAME, "");
|
GiteaUser user = new GiteaUser(juser);
|
||||||
|
author = user.getName();
|
||||||
|
}
|
||||||
result.add(new SimpleComment(date, author, text));
|
result.add(new SimpleComment(date, author, text));
|
||||||
}
|
}
|
||||||
Comment[] primArray = new Comment[result.size()];
|
Comment[] primArray = new Comment[result.size()];
|
||||||
@ -405,4 +416,12 @@ class GiteaRepository extends BaseRepositoryImpl {
|
|||||||
public void setUserLogin(String userLogin) {
|
public void setUserLogin(String userLogin) {
|
||||||
this.userLogin = userLogin;
|
this.userLogin = userLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAssigned(boolean assigned) {
|
||||||
|
this.assigned = assigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAssigned() {
|
||||||
|
return assigned;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea;
|
package biz.elfuego.idea.issues.gitea;
|
||||||
|
|
||||||
@ -26,15 +26,20 @@ public class GiteaRepositoryEditor extends BaseRepositoryEditor<GiteaRepository>
|
|||||||
private JBLabel tokenLabel;
|
private JBLabel tokenLabel;
|
||||||
private JPasswordField token;
|
private JPasswordField token;
|
||||||
|
|
||||||
|
private JBLabel assignedLabel;
|
||||||
|
private JCheckBox assignedCheckBox;
|
||||||
|
|
||||||
GiteaRepositoryEditor(GiteaRepository repository, Project project, Consumer<GiteaRepository> consumer) {
|
GiteaRepositoryEditor(GiteaRepository repository, Project project, Consumer<GiteaRepository> consumer) {
|
||||||
super(project, repository, consumer);
|
super(project, repository, consumer);
|
||||||
|
|
||||||
repoName.setText(repository.getRepoName());
|
repoName.setText(repository.getRepoName());
|
||||||
projName.setText(repository.getProjName());
|
projName.setText(repository.getProjName());
|
||||||
token.setText(repository.getToken());
|
token.setText(repository.getToken());
|
||||||
|
assignedCheckBox.setSelected(repository.getAssigned());
|
||||||
installListener(repoName);
|
installListener(repoName);
|
||||||
installListener(projName);
|
installListener(projName);
|
||||||
installListener(token);
|
installListener(token);
|
||||||
|
installListener(assignedCheckBox);
|
||||||
|
|
||||||
myUserNameText.setVisible(false);
|
myUserNameText.setVisible(false);
|
||||||
myPasswordText.setVisible(false);
|
myPasswordText.setVisible(false);
|
||||||
@ -64,9 +69,14 @@ public class GiteaRepositoryEditor extends BaseRepositoryEditor<GiteaRepository>
|
|||||||
tokenLabel = new JBLabel("Token:", SwingConstants.RIGHT);
|
tokenLabel = new JBLabel("Token:", SwingConstants.RIGHT);
|
||||||
tokenLabel.setLabelFor(token);
|
tokenLabel.setLabelFor(token);
|
||||||
|
|
||||||
|
assignedCheckBox = new JCheckBox();
|
||||||
|
assignedLabel = new JBLabel("Only issues assigned to me:", SwingConstants.RIGHT);
|
||||||
|
assignedLabel.setLabelFor(assignedCheckBox);
|
||||||
|
|
||||||
return new FormBuilder().setAlignLabelOnRight(true)
|
return new FormBuilder().setAlignLabelOnRight(true)
|
||||||
.addLabeledComponent(repoLabel, panel)
|
.addLabeledComponent(repoLabel, panel)
|
||||||
.addLabeledComponent(tokenLabel, token)
|
.addLabeledComponent(tokenLabel, token)
|
||||||
|
.addLabeledComponent(assignedLabel, assignedCheckBox)
|
||||||
.getPanel();
|
.getPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +85,7 @@ public class GiteaRepositoryEditor extends BaseRepositoryEditor<GiteaRepository>
|
|||||||
super.setAnchor(anchor);
|
super.setAnchor(anchor);
|
||||||
repoLabel.setAnchor(anchor);
|
repoLabel.setAnchor(anchor);
|
||||||
tokenLabel.setAnchor(anchor);
|
tokenLabel.setAnchor(anchor);
|
||||||
|
// assignedLabel.setAnchor(anchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,6 +95,7 @@ public class GiteaRepositoryEditor extends BaseRepositoryEditor<GiteaRepository>
|
|||||||
myRepository.setProjName(projName.getText());
|
myRepository.setProjName(projName.getText());
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
myRepository.setToken(token.getText());
|
myRepository.setToken(token.getText());
|
||||||
|
myRepository.setAssigned(assignedCheckBox.isSelected());
|
||||||
myTestButton.setEnabled(myRepository.isConfigured());
|
myTestButton.setEnabled(myRepository.isConfigured());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea;
|
package biz.elfuego.idea.issues.gitea;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea;
|
package biz.elfuego.idea.issues.gitea;
|
||||||
|
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea.model;
|
package biz.elfuego.idea.issues.gitea.model;
|
||||||
|
|
||||||
import biz.elfuego.idea.issues.gitea.util.Consts.TaskFields;
|
import biz.elfuego.idea.issues.gitea.util.Consts.TaskFields;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.apache.http.util.TextUtils;
|
import org.apache.http.util.TextUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static biz.elfuego.idea.issues.gitea.util.Utils.getDate;
|
import static biz.elfuego.idea.issues.gitea.util.Utils.*;
|
||||||
import static biz.elfuego.idea.issues.gitea.util.Utils.getString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Roman Pedchenko <elfuego@elfuego.biz>
|
* @author Roman Pedchenko <elfuego@elfuego.biz>
|
||||||
@ -24,9 +27,10 @@ public class GiteaTask {
|
|||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
private Date updatedAt;
|
private Date updatedAt;
|
||||||
private String state;
|
private String state;
|
||||||
private String assignee;
|
private GiteaUser assignee;
|
||||||
|
private List<GiteaUser> assignees;
|
||||||
|
|
||||||
public GiteaTask(String project, JsonObject json) {
|
public GiteaTask(String project, JsonObject json) throws Exception {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.fromJson(json);
|
this.fromJson(json);
|
||||||
}
|
}
|
||||||
@ -94,15 +98,23 @@ public class GiteaTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public String getAssignee() {
|
public GiteaUser getAssignee() {
|
||||||
return assignee;
|
return assignee;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public void setAssignee(String assignee) {
|
public void setAssignee(GiteaUser assignee) {
|
||||||
this.assignee = assignee;
|
this.assignee = assignee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GiteaUser> getAssignees() {
|
||||||
|
return assignees;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssignees(List<GiteaUser> assignees) {
|
||||||
|
this.assignees = assignees;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return !(TextUtils.isEmpty(id) ||
|
return !(TextUtils.isEmpty(id) ||
|
||||||
TextUtils.isEmpty(title) ||
|
TextUtils.isEmpty(title) ||
|
||||||
@ -111,27 +123,32 @@ public class GiteaTask {
|
|||||||
TextUtils.isEmpty(state));
|
TextUtils.isEmpty(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fromJson(JsonObject current) {
|
public boolean isAssignedTo(String login) {
|
||||||
if (current.has(TaskFields.NUMBER)) {
|
if (assignee != null && assignee.getLogin().equals(login))
|
||||||
|
return true;
|
||||||
|
if (assignees != null)
|
||||||
|
for (GiteaUser u : assignees)
|
||||||
|
if (u.getLogin().equals(login))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fromJson(JsonObject current) throws Exception {
|
||||||
this.setId(getString(current, TaskFields.NUMBER, ""));
|
this.setId(getString(current, TaskFields.NUMBER, ""));
|
||||||
}
|
|
||||||
if (current.has(TaskFields.TITLE)) {
|
|
||||||
this.setTitle(getString(current, TaskFields.TITLE, ""));
|
this.setTitle(getString(current, TaskFields.TITLE, ""));
|
||||||
}
|
|
||||||
if (current.has(TaskFields.DESCRIPTION)) {
|
|
||||||
this.setDescription(getString(current, TaskFields.DESCRIPTION, ""));
|
this.setDescription(getString(current, TaskFields.DESCRIPTION, ""));
|
||||||
}
|
|
||||||
if (current.has(TaskFields.CREATEDAT)) {
|
|
||||||
this.setCreatedAt(getDate(current, TaskFields.CREATEDAT));
|
this.setCreatedAt(getDate(current, TaskFields.CREATEDAT));
|
||||||
}
|
|
||||||
if (current.has(TaskFields.UPDATEDAT)) {
|
|
||||||
this.setUpdatedAt(getDate(current, TaskFields.UPDATEDAT));
|
this.setUpdatedAt(getDate(current, TaskFields.UPDATEDAT));
|
||||||
}
|
|
||||||
if (current.has(TaskFields.STATE)) {
|
|
||||||
this.setState(getString(current, TaskFields.STATE, ""));
|
this.setState(getString(current, TaskFields.STATE, ""));
|
||||||
}
|
if (current.has(TaskFields.ASSIGNEE) && current.get(TaskFields.ASSIGNEE).isJsonObject())
|
||||||
if (current.has(TaskFields.ASSIGNEE)) {
|
this.setAssignee(new GiteaUser(getObject(current, TaskFields.ASSIGNEE)));
|
||||||
this.setAssignee(getString(current, TaskFields.ASSIGNEE, ""));
|
if (current.has(TaskFields.ASSIGNEES) && current.get(TaskFields.ASSIGNEES).isJsonArray()) {
|
||||||
|
JsonArray arr = getArray(current.get(TaskFields.ASSIGNEES));
|
||||||
|
List<GiteaUser> assignees1 = new ArrayList<>();
|
||||||
|
for (JsonElement el : arr)
|
||||||
|
if (el.isJsonObject())
|
||||||
|
assignees1.add(new GiteaUser(getObject(el)));
|
||||||
|
this.setAssignees(assignees1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
108
src/biz/elfuego/idea/issues/gitea/model/GiteaUser.java
Normal file
108
src/biz/elfuego/idea/issues/gitea/model/GiteaUser.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2019 by elfuego.biz
|
||||||
|
*/
|
||||||
|
package biz.elfuego.idea.issues.gitea.model;
|
||||||
|
|
||||||
|
import biz.elfuego.idea.issues.gitea.util.Consts;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import static biz.elfuego.idea.issues.gitea.util.Utils.getString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Roman Pedchenko <elfuego@elfuego.biz>
|
||||||
|
* @date 2019.04.04
|
||||||
|
*/
|
||||||
|
public class GiteaUser {
|
||||||
|
private String id;
|
||||||
|
private String login;
|
||||||
|
private String username;
|
||||||
|
private String full_name;
|
||||||
|
private String email;
|
||||||
|
private String avatar_url;
|
||||||
|
private String language;
|
||||||
|
|
||||||
|
public GiteaUser(JsonObject json) {
|
||||||
|
this.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setLogin(String login) {
|
||||||
|
this.login = login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFull_name() {
|
||||||
|
return full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setFull_name(String full_name) {
|
||||||
|
this.full_name = full_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar_url() {
|
||||||
|
return avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setAvatar_url(String avatar_url) {
|
||||||
|
this.avatar_url = avatar_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
public void setLanguage(String language) {
|
||||||
|
this.language = language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
if (!full_name.isEmpty())
|
||||||
|
return full_name;
|
||||||
|
if (!username.isEmpty())
|
||||||
|
return username;
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fromJson(JsonObject current) {
|
||||||
|
this.setId(getString(current, Consts.UserFields.ID, ""));
|
||||||
|
this.setLogin(getString(current, Consts.UserFields.LOGIN, ""));
|
||||||
|
this.setUsername(getString(current, Consts.UserFields.USERNAME, ""));
|
||||||
|
this.setFull_name(getString(current, Consts.UserFields.FULL_NAME, ""));
|
||||||
|
this.setEmail(getString(current, Consts.UserFields.EMAIL, ""));
|
||||||
|
this.setAvatar_url(getString(current, Consts.UserFields.AVATAR_URL, ""));
|
||||||
|
this.setLanguage(getString(current, Consts.UserFields.LANGUAGE, ""));
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea.util;
|
package biz.elfuego.idea.issues.gitea.util;
|
||||||
|
|
||||||
@ -55,13 +55,22 @@ public class Consts {
|
|||||||
String UPDATEDAT = "updated_at";
|
String UPDATEDAT = "updated_at";
|
||||||
String STATE = "state";
|
String STATE = "state";
|
||||||
String ASSIGNEE = "assignee";
|
String ASSIGNEE = "assignee";
|
||||||
|
String ASSIGNEES = "assignees";
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CommentFields {
|
public interface CommentFields {
|
||||||
String DATE = "updated_at";
|
String DATE = "updated_at";
|
||||||
String TEXT = "body";
|
String TEXT = "body";
|
||||||
String USER = "user";
|
String USER = "user";
|
||||||
String FULLNAME = "full_name";
|
}
|
||||||
|
|
||||||
|
public interface UserFields {
|
||||||
|
String ID = "id";
|
||||||
|
String LOGIN = "login";
|
||||||
|
String FULL_NAME = "full_name";
|
||||||
|
String EMAIL = "email";
|
||||||
|
String AVATAR_URL = "avatar_url";
|
||||||
|
String LANGUAGE = "language";
|
||||||
String USERNAME = "username";
|
String USERNAME = "username";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2018 by elfuego.biz
|
* Copyright © 2019 by elfuego.biz
|
||||||
*/
|
*/
|
||||||
package biz.elfuego.idea.issues.gitea.util;
|
package biz.elfuego.idea.issues.gitea.util;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class Utils {
|
|||||||
int inset = 6;
|
int inset = 6;
|
||||||
|
|
||||||
String s0 = input.substring(0, input.length() - inset);
|
String s0 = input.substring(0, input.length() - inset);
|
||||||
String s1 = input.substring(input.length() - inset, input.length());
|
String s1 = input.substring(input.length() - inset);
|
||||||
|
|
||||||
input = s0 + "GMT" + s1;
|
input = s0 + "GMT" + s1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user