-
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.
- Loading branch information
Showing
33 changed files
with
1,710 additions
and
791 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.
83 changes: 83 additions & 0 deletions
83
...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,83 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2020 - 2022 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.apache.commons.collections.CollectionUtils; | ||
import org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl; | ||
import org.exoplatform.gamification.github.entity.WebhookEntity; | ||
|
||
import javax.persistence.NoResultException; | ||
import javax.persistence.Tuple; | ||
import javax.persistence.TypedQuery; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
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); | ||
query.setMaxResults(1); | ||
try { | ||
return query.getSingleResult(); | ||
} catch (NoResultException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public List<Long> getWebhookIds(int offset, int limit) { | ||
TypedQuery<Tuple> query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebhookIds", Tuple.class); | ||
List<Tuple> result = query.getResultList(); | ||
if (CollectionUtils.isEmpty(result)) { | ||
return Collections.emptyList(); | ||
} else { | ||
Stream<Long> resultStream = result.stream().map(tuple -> tuple.get(0, Long.class)); | ||
if (offset > 0) { | ||
resultStream = resultStream.skip(offset); | ||
} | ||
if (limit > 0) { | ||
resultStream = resultStream.limit(limit); | ||
} | ||
return resultStream.toList(); | ||
} | ||
} | ||
|
||
public String getWebHookHookSecret(long organizationId) { | ||
TypedQuery<String> query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebHookHookSecret", String.class); | ||
query.setParameter(ORGANIZATION_ID, organizationId); | ||
query.setMaxResults(1); | ||
try { | ||
return query.getSingleResult(); | ||
} catch (NoResultException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public String getWebHookAccessToken(long organizationId) { | ||
TypedQuery<String> query = getEntityManager().createNamedQuery("GitHubWebhooks.getWebHookAccessToken", String.class); | ||
query.setParameter(ORGANIZATION_ID, organizationId); | ||
query.setMaxResults(1); | ||
try { | ||
return query.getSingleResult(); | ||
} catch (NoResultException e) { | ||
return null; | ||
} | ||
} | ||
} |
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 javax.persistence.*; | ||
|
||
import org.exoplatform.commons.api.persistence.ExoEntity; | ||
|
||
import lombok.Data; | ||
|
||
@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.getWebHookHookSecret", | ||
query = "SELECT gitHubWebhook.secret FROM GitHubWebhooks gitHubWebhook" | ||
+ " WHERE gitHubWebhook.organizationId = :organizationId") | ||
@NamedQuery( | ||
name = "GitHubWebhooks.getWebHookAccessToken", | ||
query = "SELECT gitHubWebhook.token FROM GitHubWebhooks gitHubWebhook" | ||
+ " WHERE gitHubWebhook.organizationId = :organizationId") | ||
@NamedQuery( | ||
name = "GitHubWebhooks.getWebhookIds", | ||
query = "SELECT gitHubWebhook.id FROM GitHubWebhooks gitHubWebhook") | ||
@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") | ||
protected Long id; | ||
|
||
@Column(name = "WEBHOOK_ID") | ||
protected Long webhookId; | ||
|
||
@Column(name = "ORGANIZATION_ID", nullable = false) | ||
protected Long organizationId; | ||
|
||
@Column(name = "ENABLED", nullable = false) | ||
protected Boolean enabled; | ||
|
||
@Column(name = "WATCHED_DATE", nullable = false) | ||
protected Date watchedDate; | ||
|
||
@Column(name = "WATCHED_BY", nullable = false) | ||
protected Long watchedBy; | ||
|
||
@Column(name = "UPDATED_DATE", nullable = false) | ||
protected Date updatedDate; | ||
|
||
@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
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.