Exclude status if includeStatus != true

This commit is contained in:
CalDescent 2023-05-07 17:21:41 +01:00
parent d03a2d7da9
commit cdcb268bd9
3 changed files with 15 additions and 8 deletions

View File

@ -135,7 +135,7 @@ public class ArbitraryResource {
List<ArbitraryResourceData> 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<ArbitraryResourceData> 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<>();

View File

@ -37,9 +37,9 @@ public interface ArbitraryRepository {
public List<ArbitraryResourceData> getArbitraryResources(Integer limit, Integer offset, Boolean reverse) throws DataException;
public List<ArbitraryResourceData> getArbitraryResources(Service service, String identifier, List<String> names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Integer limit, Integer offset, Boolean reverse) throws DataException;
public List<ArbitraryResourceData> getArbitraryResources(Service service, String identifier, List<String> names, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException;
public List<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly, List<String> namesFilter, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Integer limit, Integer offset, Boolean reverse) throws DataException;
public List<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly, List<String> namesFilter, boolean defaultResource, Boolean followedOnly, Boolean excludeBlocked, Boolean includeMetadata, Boolean includeStatus, Integer limit, Integer offset, Boolean reverse) throws DataException;
// Arbitrary resources cache save/load

View File

@ -488,7 +488,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
@Override
public List<ArbitraryResourceData> getArbitraryResources(Service service, String identifier, List<String> 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<Object> 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<ArbitraryResourceData> searchArbitraryResources(Service service, String query, String identifier, List<String> names, boolean prefixOnly,
List<String> 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<Object> 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();