From cdcb268bd9ae45977edd43ef0da0c7f3a94eaa9d Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 7 May 2023 17:21:41 +0100 Subject: [PATCH] Exclude status if includeStatus != true --- .../qortal/api/resource/ArbitraryResource.java | 4 ++-- .../qortal/repository/ArbitraryRepository.java | 4 ++-- .../hsqldb/HSQLDBArbitraryRepository.java | 15 +++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/qortal/api/resource/ArbitraryResource.java b/src/main/java/org/qortal/api/resource/ArbitraryResource.java index 2b3b986f..08a9b73c 100644 --- a/src/main/java/org/qortal/api/resource/ArbitraryResource.java +++ b/src/main/java/org/qortal/api/resource/ArbitraryResource.java @@ -135,7 +135,7 @@ public class ArbitraryResource { List resources = repository.getArbitraryRepository() .getArbitraryResources(service, identifier, names, defaultRes, followedOnly, excludeBlocked, - includeMetadata, limit, offset, reverse); + includeMetadata, includeStatus, limit, offset, reverse); if (resources == null) { return new ArrayList<>(); @@ -202,7 +202,7 @@ public class ArbitraryResource { List resources = repository.getArbitraryRepository() .searchArbitraryResources(service, query, identifier, names, usePrefixOnly, exactMatchNames, - defaultRes, followedOnly, excludeBlocked, includeMetadata, limit, offset, reverse); + defaultRes, followedOnly, excludeBlocked, includeMetadata, includeStatus, limit, offset, reverse); if (resources == null) { return new ArrayList<>(); diff --git a/src/main/java/org/qortal/repository/ArbitraryRepository.java b/src/main/java/org/qortal/repository/ArbitraryRepository.java index 7a21a1a2..572d2a59 100644 --- a/src/main/java/org/qortal/repository/ArbitraryRepository.java +++ b/src/main/java/org/qortal/repository/ArbitraryRepository.java @@ -37,9 +37,9 @@ public interface ArbitraryRepository { public List getArbitraryResources(Integer limit, Integer offset, Boolean reverse) throws DataException; - public List getArbitraryResources(Service service, String identifier, List names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Integer limit, Integer offset, Boolean reverse) throws DataException; + public List getArbitraryResources(Service service, String identifier, List names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException; - public List searchArbitraryResources(Service service, String query, String identifier, List names, boolean prefixOnly, List namesFilter, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Integer limit, Integer offset, Boolean reverse) throws DataException; + public List searchArbitraryResources(Service service, String query, String identifier, List names, boolean prefixOnly, List namesFilter, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException; // Arbitrary resources cache save/load diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBArbitraryRepository.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBArbitraryRepository.java index 5564d1d3..71428cb6 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBArbitraryRepository.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBArbitraryRepository.java @@ -488,7 +488,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository { @Override public List getArbitraryResources(Service service, String identifier, List names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, - Boolean includeMetadata, Integer limit, Integer offset, Boolean reverse) throws DataException { + Boolean includeMetadata, Boolean includeStatus, + Integer limit, Integer offset, Boolean reverse) throws DataException { StringBuilder sql = new StringBuilder(512); List bindParams = new ArrayList<>(); @@ -600,10 +601,13 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository { arbitraryResourceData.service = serviceResult; arbitraryResourceData.identifier = identifierResult; arbitraryResourceData.size = sizeResult; - arbitraryResourceData.setStatus(ArbitraryResourceStatus.Status.valueOf(status)); arbitraryResourceData.created = created; arbitraryResourceData.updated = (updated == 0) ? null : updated; + if (includeStatus != null && includeStatus) { + arbitraryResourceData.setStatus(ArbitraryResourceStatus.Status.valueOf(status)); + } + if (includeMetadata != null && includeMetadata) { // TODO: we could avoid the join altogether ArbitraryResourceMetadata metadata = new ArbitraryResourceMetadata(); @@ -636,7 +640,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository { @Override public List searchArbitraryResources(Service service, String query, String identifier, List names, boolean prefixOnly, List exactMatchNames, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, - Boolean includeMetadata, Integer limit, Integer offset, Boolean reverse) throws DataException { + Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException { StringBuilder sql = new StringBuilder(512); List bindParams = new ArrayList<>(); @@ -778,10 +782,13 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository { arbitraryResourceData.service = serviceResult; arbitraryResourceData.identifier = identifierResult; arbitraryResourceData.size = sizeResult; - arbitraryResourceData.setStatus(ArbitraryResourceStatus.Status.valueOf(status)); arbitraryResourceData.created = created; arbitraryResourceData.updated = (updated == 0) ? null : updated; + if (includeStatus != null && includeStatus) { + arbitraryResourceData.setStatus(ArbitraryResourceStatus.Status.valueOf(status)); + } + if (includeMetadata != null && includeMetadata) { // TODO: we could avoid the join altogether ArbitraryResourceMetadata metadata = new ArbitraryResourceMetadata();