-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-2299 - Meeds-io/MIPs#64 (#81) Allow rewarding users to add GitHub organizations to watch.
- Loading branch information
Showing
45 changed files
with
2,615 additions
and
927 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
...-github-services/src/main/java/org/exoplatform/gamification/github/dao/GitHubHookDAO.java
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
...ion-github-services/src/main/java/org/exoplatform/gamification/github/dao/WebHookDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2020 - 2023 Meeds Association [email protected] | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.exoplatform.gamification.github.dao; | ||
|
||
import org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl; | ||
import org.exoplatform.gamification.github.entity.WebhookEntity; | ||
|
||
import javax.persistence.NoResultException; | ||
import javax.persistence.TypedQuery; | ||
import java.util.List; | ||
|
||
public class WebHookDAO extends GenericDAOJPAImpl<WebhookEntity, Long> { | ||
|
||
public static final String ORGANIZATION_ID = "organizationId"; | ||
|
||
public WebhookEntity getWebhookByOrganizationId(long organizationId) { | ||
TypedQuery<WebhookEntity> query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebhookByOrganizationId", | ||
WebhookEntity.class); | ||
query.setParameter(ORGANIZATION_ID, organizationId); | ||
try { | ||
return query.getSingleResult(); | ||
} catch (NoResultException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public List<Long> getWebhookIds(int offset, int limit) { | ||
TypedQuery<Long> query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebhookIds", Long.class); | ||
if (offset > 0) { | ||
query.setFirstResult(offset); | ||
} | ||
if (limit > 0) { | ||
query.setMaxResults(limit); | ||
} | ||
return query.getResultList(); | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
...b-services/src/main/java/org/exoplatform/gamification/github/entity/GitHubHookEntity.java
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
...thub-services/src/main/java/org/exoplatform/gamification/github/entity/WebhookEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2020 - 2023 Meeds Association [email protected] | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.exoplatform.gamification.github.entity; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import javax.persistence.*; | ||
|
||
import org.exoplatform.commons.api.persistence.ExoEntity; | ||
|
||
import lombok.Data; | ||
import org.exoplatform.gamification.github.utils.StringListConverter; | ||
|
||
@Entity(name = "GitHubWebhooks") | ||
@ExoEntity | ||
@Table(name = "GITHUB_WEBHOOKS") | ||
@NamedQuery(name = "GitHubWebhooks.getWebhookByOrganizationId", | ||
query = "SELECT gitHubWebhook FROM GitHubWebhooks gitHubWebhook" | ||
+ " WHERE gitHubWebhook.organizationId = :organizationId") | ||
@NamedQuery(name = "GitHubWebhooks.getWebhookIds", | ||
query = "SELECT gitHubWebhook.id FROM GitHubWebhooks gitHubWebhook" | ||
+ " ORDER BY gitHubWebhook.id ASC") | ||
@Data | ||
public class WebhookEntity implements Serializable { | ||
|
||
private static final long serialVersionUID = 2607146513663056421L; | ||
|
||
@Id | ||
@SequenceGenerator(name = "SEQ_GITHUB_WEBHOOKS_ID", sequenceName = "SEQ_GITHUB_WEBHOOKS_ID", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_GITHUB_WEBHOOKS_ID") | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@Column(name = "WEBHOOK_ID") | ||
private Long webhookId; | ||
|
||
@Column(name = "ORGANIZATION_ID", nullable = false) | ||
private Long organizationId; | ||
|
||
@Convert(converter = StringListConverter.class) | ||
@Column(name = "TRIGGERS", nullable = false) | ||
private List<String> triggers; | ||
|
||
@Column(name = "ENABLED", nullable = false) | ||
private Boolean enabled; | ||
|
||
@Column(name = "WATCHED_DATE", nullable = false) | ||
private Date watchedDate; | ||
|
||
@Column(name = "WATCHED_BY", nullable = false) | ||
private Long watchedBy; | ||
|
||
@Column(name = "UPDATED_DATE", nullable = false) | ||
private Date updatedDate; | ||
|
||
@Column(name = "REFRESH_DATE", nullable = false) | ||
private Date refreshDate; | ||
|
||
@Column(name = "SECRET", nullable = false) | ||
private String secret; | ||
|
||
@Column(name = "TOKEN", nullable = false) | ||
private String token; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2020 - 2022 Meeds Association [email protected] | ||
* Copyright (C) 2020 - 2023 Meeds Association [email protected] | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
|
@@ -15,14 +15,15 @@ | |
*/ | ||
package org.exoplatform.gamification.github.exception; | ||
|
||
public class GithubHookException extends Exception { | ||
public class GithubConnectionException extends Exception { | ||
|
||
private static final long serialVersionUID = -2836988837493225118L; | ||
private static final long serialVersionUID = -2437500058122638710L; | ||
|
||
public GithubHookException() { | ||
public GithubConnectionException(String message) { | ||
super(message); | ||
} | ||
|
||
public GithubHookException(String message) { | ||
super(message); | ||
public GithubConnectionException(String message, Exception e) { | ||
super(message, e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...-services/src/main/java/org/exoplatform/gamification/github/model/RemoteOrganization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2020 - 2023 Meeds Association | ||
* [email protected] | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package org.exoplatform.gamification.github.model; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class RemoteOrganization { | ||
|
||
long id; | ||
|
||
String name; | ||
|
||
String title; | ||
|
||
String description; | ||
|
||
String avatarUrl; | ||
} |
Oops, something went wrong.