Skip to content

Commit

Permalink
#30950 refactor done
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Dec 20, 2024
1 parent cf15906 commit 6bf2730
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ public boolean hasWorkingVersionInAnyOtherLanguage(Versionable versionable, fina

// only contents are multi language
return "contentlet".equals(identifier.getAssetType())?
!new DotConnect().setSQL("select working_inode, lang from contentlet_version_info where identifier = ? and lang != ?")
.addParam(identifier.getId()).addParam(versionableLanguageId).loadObjectResults().isEmpty():false;
!this.versionableFactory.getWorkingVersionsExcludingLanguage(identifier.getId(), versionableLanguageId).isEmpty():false;
}

@CloseDBIfOpened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dotcms.variant.model.Variant;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import com.dotmarketing.beans.Identifier;
Expand Down Expand Up @@ -108,6 +109,15 @@ public abstract class VersionableFactory {
*/
protected abstract VersionInfo getVersionInfo(String identifier) throws DotDataException, DotStateException;

/**
* Get a list of all the working versions of a contentlet excluding the one with the specified language id.
* @param identifier
* @param lang
* @return List of the rows (working_inode + lang)
* @throws DotDataException
*/
protected abstract List<Map<String, Object>> getWorkingVersionsExcludingLanguage(String identifier, long lang) throws DotDataException;

/**
*
* @param identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -239,6 +240,13 @@ protected List<Versionable> findAllVersions(final String id, final Optional<Int
}
}

@Override
protected List<Map<String, Object>> getWorkingVersionsExcludingLanguage(final String identifier, final long lang) throws DotDataException {

return new DotConnect().setSQL("select working_inode, lang from contentlet_version_info where identifier = ? and lang != ?")
.addParam(identifier).addParam(lang).loadObjectResults();
}

@Override
protected VersionInfo getVersionInfo(String identifier) throws DotDataException,
DotStateException {
Expand Down

0 comments on commit 6bf2730

Please sign in to comment.