Skip to content

fix: Drop dependency to com.google.common and upgrade Hibernate and bcprov - Meeds-io/meeds#3365 #1435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/**
* 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.
*/
/**
* 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 org.exoplatform.wiki.jpa.dao;

import java.util.List;
Expand All @@ -28,18 +28,16 @@
import jakarta.persistence.NoResultException;
import jakarta.persistence.TypedQuery;

/**
* Created by The eXo Platform SAS
* Author : eXoPlatform
* [email protected]
* Jun 24, 2015
*/
public class DraftPageDAO extends WikiBaseDAO<DraftPageEntity, Long> {

private static final String TARGET_PAGE_ID_PARAM = "targetPageId";

public DraftPageEntity findDraftPageByName(String draftPageName) {
TypedQuery<DraftPageEntity> query = getEntityManager().createNamedQuery("wikiDraftPage.findDraftPageByName", DraftPageEntity.class)
.setMaxResults(1)
.setParameter("draftPageName", draftPageName);
TypedQuery<DraftPageEntity> query = getEntityManager()
.createNamedQuery("wikiDraftPage.findDraftPageByName",
DraftPageEntity.class)
.setMaxResults(1)
.setParameter("draftPageName", draftPageName);

try {
return query.getSingleResult();
Expand All @@ -49,38 +47,48 @@ public DraftPageEntity findDraftPageByName(String draftPageName) {
}

public List<DraftPageEntity> findDraftPagesByTargetPage(long targetPageId) {
TypedQuery<DraftPageEntity> query = getEntityManager().createNamedQuery("wikiDraftPage.findDraftPageByTargetPage", DraftPageEntity.class)
.setParameter("targetPageId", targetPageId);
return query.getResultList();
return getEntityManager().createNamedQuery("wikiDraftPage.findDraftPageByTargetPage", DraftPageEntity.class)
.setParameter(TARGET_PAGE_ID_PARAM, targetPageId)
.getResultList();
}

public List<DraftPageEntity> findDraftPagesByParentPage(long parentPageId) {
TypedQuery<DraftPageEntity> query = getEntityManager().createNamedQuery("wikiDraftPage.findDraftPagesByParentPage", DraftPageEntity.class)
.setParameter("parentPageId", parentPageId);
TypedQuery<DraftPageEntity> query = getEntityManager()
.createNamedQuery("wikiDraftPage.findDraftPagesByParentPage",
DraftPageEntity.class)
.setParameter("parentPageId", parentPageId);
return query.getResultList();
}

@ExoTransactional
public void deleteDraftPagesByTargetPage(long targetPageId) {

List<DraftPageEntity> draftPages = findDraftPagesByTargetPage(targetPageId);
for (DraftPageEntity draftPage: draftPages) {
for (DraftPageEntity draftPage : draftPages) {
delete(draftPage);
}
}

@ExoTransactional
public void deleteDraftPagesByParentPage(long targetPageId) {
List<DraftPageEntity> draftPages = findDraftPagesByParentPage(targetPageId);
for (DraftPageEntity draftPage : draftPages) {
delete(draftPage);
}
}

@ExoTransactional
public void deleteDraftPagesByName(String draftName) {
DraftPageEntity draftPage = findDraftPageByName(draftName);
if(draftPage != null) {
if (draftPage != null) {
delete(draftPage);
}
}

public DraftPageEntity findLatestDraftPageByTargetPage(Long targetPageId) {
TypedQuery<DraftPageEntity> query = getEntityManager().createNamedQuery("wikiDraftPage.findLatestDraftPageByTargetPage", DraftPageEntity.class)
.setParameter("targetPageId", targetPageId);
TypedQuery<DraftPageEntity> query = getEntityManager()
.createNamedQuery("wikiDraftPage.findLatestDraftPageByTargetPage",
DraftPageEntity.class)
.setParameter(TARGET_PAGE_ID_PARAM, targetPageId);

try {
query.setMaxResults(1);
Expand All @@ -101,7 +109,7 @@ public DraftPageEntity findLatestDraftPageByTargetPageAndLang(Long targetPageId,
TypedQuery<DraftPageEntity> query =
getEntityManager().createNamedQuery("wikiDraftPage.findLatestDraftPageByTargetPageAndLang",
DraftPageEntity.class)
.setParameter("targetPageId", targetPageId)
.setParameter(TARGET_PAGE_ID_PARAM, targetPageId)
.setParameter("lang", lang);
query.setMaxResults(1);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.exoplatform.wiki.jpa.dao;

import org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl;
import org.exoplatform.wiki.jpa.entity.EmotionIconEntity;

import jakarta.persistence.NoResultException;
Expand Down
Loading
Loading