-
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.
feat: Crowdin connector Improve & clean code - Meeds-io/MIPs#121
- Loading branch information
Showing
53 changed files
with
2,029 additions
and
1,842 deletions.
There are no files selected for viewing
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,8 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2023 Meeds Lab [email protected] | ||
* | ||
* Copyright (C) 2020 - 2024 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 | ||
|
@@ -9,43 +11,17 @@ | |
* 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 io.meeds.gamification.crowdin.dao; | ||
|
||
import io.meeds.gamification.crowdin.entity.WebhookEntity; | ||
import jakarta.persistence.NoResultException; | ||
import jakarta.persistence.TypedQuery; | ||
import org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
@Component | ||
public class WebHookDAO extends GenericDAOJPAImpl<WebhookEntity, Long> { | ||
public interface WebHookDAO extends JpaRepository<WebhookEntity, Long> { | ||
|
||
public static final String PROJECT_ID = "projectId"; | ||
|
||
public WebhookEntity getWebhookByProjectId(long projectId) { | ||
TypedQuery<WebhookEntity> query = getEntityManager().createNamedQuery("CrowdinWebhooks.getWebhookByProjectId", | ||
WebhookEntity.class); | ||
query.setParameter(PROJECT_ID, projectId); | ||
try { | ||
return query.getSingleResult(); | ||
} catch (NoResultException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public List<Long> getWebhookIds(int offset, int limit) { | ||
TypedQuery<Long> query = getEntityManager().createNamedQuery("CrowdinWebhooks.getWebhookIds", Long.class); | ||
if (offset > 0) { | ||
query.setFirstResult(offset); | ||
} | ||
if (limit > 0) { | ||
query.setMaxResults(limit); | ||
} | ||
return query.getResultList(); | ||
} | ||
WebhookEntity findWebhookEntityByProjectId(long projectId); | ||
} |
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,8 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2023 Meeds Lab [email protected] | ||
* | ||
* Copyright (C) 2020 - 2024 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 | ||
|
@@ -9,30 +11,23 @@ | |
* 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 io.meeds.gamification.crowdin.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
import org.exoplatform.commons.api.persistence.ExoEntity; | ||
import org.exoplatform.commons.utils.StringListConverter; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
import org.exoplatform.commons.utils.StringListConverter; | ||
|
||
@Entity(name = "CrowdinWebhooks") | ||
@ExoEntity | ||
@Table(name = "CROWDIN_WEBHOOKS") | ||
@NamedQuery(name = "CrowdinWebhooks.getWebhookByProjectId", | ||
query = "SELECT crowdinWebhook FROM CrowdinWebhooks crowdinWebhook" | ||
+ " WHERE crowdinWebhook.projectId = :projectId") | ||
@NamedQuery(name = "CrowdinWebhooks.getWebhookIds", | ||
query = "SELECT crowdinWebhook.id FROM CrowdinWebhooks crowdinWebhook" | ||
+ " ORDER BY crowdinWebhook.id ASC") | ||
@Data | ||
public class WebhookEntity implements Serializable { | ||
|
||
|
@@ -51,7 +46,7 @@ public class WebhookEntity implements Serializable { | |
private Long projectId; | ||
|
||
@Column(name = "PROJECT_NAME", nullable = false) | ||
private String projectName; | ||
private String projectName; | ||
|
||
@Convert(converter = StringListConverter.class) | ||
@Column(name = "TRIGGERS", nullable = false) | ||
|
33 changes: 25 additions & 8 deletions
33
...ces/src/main/java/io/meeds/gamification/crowdin/exception/CrowdinConnectionException.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 |
---|---|---|
@@ -1,15 +1,32 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 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 io.meeds.gamification.crowdin.exception; | ||
|
||
public class CrowdinConnectionException extends Exception { | ||
|
||
private static final long serialVersionUID = -2437500058122638710L; | ||
private static final long serialVersionUID = -2437500058122638710L; | ||
|
||
public CrowdinConnectionException(String e) { | ||
super(e); | ||
} | ||
|
||
public CrowdinConnectionException(String message, Exception e) { | ||
super(message, e); | ||
} | ||
public CrowdinConnectionException(String e) { | ||
super(e); | ||
} | ||
|
||
public CrowdinConnectionException(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 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 io.meeds.gamification.crowdin.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
@@ -8,7 +26,10 @@ | |
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class RemoteDirectory { | ||
private long id; | ||
private long projectId; | ||
private String path; | ||
|
||
private long id; | ||
|
||
private long projectId; | ||
|
||
private String path; | ||
} |
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,3 +1,21 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 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 io.meeds.gamification.crowdin.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
@@ -8,6 +26,8 @@ | |
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class RemoteLanguage { | ||
private String id; | ||
private String name; | ||
|
||
private String id; | ||
|
||
private String name; | ||
} |
47 changes: 35 additions & 12 deletions
47
...ion-crowdin-services/src/main/java/io/meeds/gamification/crowdin/model/RemoteProject.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 |
---|---|---|
@@ -1,25 +1,48 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 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 io.meeds.gamification.crowdin.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class RemoteProject implements Cloneable { | ||
private long id; | ||
private String identifier; | ||
private String name; | ||
private String description; | ||
private String avatarUrl; | ||
private List<RemoteLanguage> languages; | ||
|
||
@Override | ||
public RemoteProject clone() { | ||
return new RemoteProject(id, identifier, name, description, avatarUrl, languages); | ||
} | ||
|
||
private long id; | ||
|
||
private String identifier; | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
private String avatarUrl; | ||
|
||
private List<RemoteLanguage> languages; | ||
|
||
@Override | ||
public RemoteProject clone() { // NOSONAR | ||
return new RemoteProject(id, identifier, name, description, avatarUrl, languages); | ||
} | ||
} |
10 changes: 6 additions & 4 deletions
10
gamification-crowdin-services/src/main/java/io/meeds/gamification/crowdin/model/WebHook.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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* Copyright (C) 2023 Meeds Lab | ||
* [email protected] | ||
* | ||
* Copyright (C) 2020 - 2024 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 | ||
* 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. | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.gamification.crowdin.model; | ||
|
||
|
Oops, something went wrong.