From e2eef209043b5b44b4b2a69382413802d37fdf08 Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Wed, 30 Oct 2019 11:13:33 -0400 Subject: [PATCH] Add screenshots to listing entity #45 Change-Id: If9b8b12eb6d6b0c534d5dc2f459f2252e9f9be2d Signed-off-by: Martin Lowe <martin.lowe@eclipse-foundation.org> --- .../marketplace/dto/Listing.java | 20 ++++++++++++++++++- .../marketplace/dto/codecs/ListingCodec.java | 2 ++ .../namespace/DatabaseFieldNames.java | 1 + src/main/node/index.js | 5 +++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java b/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java index 89b8e4c..cbc107c 100644 --- a/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java +++ b/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java @@ -59,6 +59,7 @@ public class Listing extends NodeBase { private String license; private List<String> marketIds; private List<String> categoryIds; + private List<String> screenshots; private List<Category> categories; private Organization organization; private List<Author> authors; @@ -75,6 +76,7 @@ public class Listing extends NodeBase { this.marketIds = new ArrayList<>(); this.categoryIds = new ArrayList<>(); this.categories = new ArrayList<>(); + this.screenshots = new ArrayList<>(); } /** @@ -290,6 +292,20 @@ public class Listing extends NodeBase { this.marketIds = new ArrayList<>(marketIds); } + /** + * @return the screenshots + */ + public List<String> getScreenshots() { + return new ArrayList<>(screenshots); + } + + /** + * @param screenshots the screenshots to set + */ + public void setScreenshots(List<String> screenshots) { + this.screenshots = new ArrayList<>(screenshots); + } + /** * @return the categories */ @@ -394,7 +410,8 @@ public class Listing extends NodeBase { && Objects.equals(logo, other.logo) && Objects.equals(organization, other.organization) && Objects.equals(status, other.status) && Objects.equals(supportUrl, other.supportUrl) && Objects.equals(tags, other.tags) && Objects.equals(teaser, other.teaser) - && updateDate == other.updateDate && Objects.equals(versions, other.versions); + && updateDate == other.updateDate && Objects.equals(versions, other.versions) + && Objects.equals(screenshots, other.screenshots); } @Override @@ -421,6 +438,7 @@ public class Listing extends NodeBase { sb.append(", authors=").append(authors); sb.append(", tags=").append(tags); sb.append(", versions=").append(versions); + sb.append(", screenshots=").append(screenshots); sb.append(']'); return sb.toString(); } diff --git a/src/main/java/org/eclipsefoundation/marketplace/dto/codecs/ListingCodec.java b/src/main/java/org/eclipsefoundation/marketplace/dto/codecs/ListingCodec.java index 944bf96..0ba97a3 100644 --- a/src/main/java/org/eclipsefoundation/marketplace/dto/codecs/ListingCodec.java +++ b/src/main/java/org/eclipsefoundation/marketplace/dto/codecs/ListingCodec.java @@ -80,6 +80,7 @@ public class ListingCodec implements CollectibleCodec<Listing> { doc.put(DatabaseFieldNames.CREATION_DATE, new Date(value.getCreationDate())); doc.put(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG, value.isFoundationMember()); doc.put(DatabaseFieldNames.CATEGORY_IDS, value.getCategoryIds()); + doc.put(DatabaseFieldNames.SCREENSHOTS, value.getScreenshots()); doc.put(DatabaseFieldNames.MARKET_IDS, value.getMarketIds()); // for nested document types, use the converters to safely transform into BSON @@ -120,6 +121,7 @@ public class ListingCodec implements CollectibleCodec<Listing> { out.setFoundationMember(document.getBoolean(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG)); out.setCategoryIds(document.getList(DatabaseFieldNames.CATEGORY_IDS, String.class)); out.setMarketIds(document.getList(DatabaseFieldNames.MARKET_IDS, String.class)); + out.setScreenshots(document.getList(DatabaseFieldNames.SCREENSHOTS, String.class)); // for nested document types, use the converters to safely transform into POJO out.setAuthors(document.getList(DatabaseFieldNames.LISTING_AUTHORS, Document.class).stream() diff --git a/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java b/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java index bad77d4..a205252 100644 --- a/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java +++ b/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java @@ -48,6 +48,7 @@ public final class DatabaseFieldNames { public static final String FEATURE_IDS = "feature_ids"; public static final String FEATURE_ID = "feature_id"; public static final String INSTALL_STATE = "install_state"; + public static final String SCREENSHOTS = "screenshots"; // catalog fields public static final String CATALOG_TABS = "tabs"; diff --git a/src/main/node/index.js b/src/main/node/index.js index 5bbf210..e5ccda6 100644 --- a/src/main/node/index.js +++ b/src/main/node/index.js @@ -72,7 +72,7 @@ function createListing(count) { console.log(`Generating listing ${count} of ${max}`); var json = generateJSON(uuid.v4()); - axios.post(argv.s+"/listings/", json) + instance.put(argv.s+"/listings/", json) .then(() => { var installs = Math.floor(Math.random()*argv.i); console.log(`Generating ${installs} install records for listing '${json.id}'`); @@ -152,7 +152,8 @@ function generateJSON(id) { ], "versions": solutions, "market_ids": splice(marketIds).splice(0,Math.ceil(Math.random()*2)), - "category_ids": splice(categoryIds).splice(0,Math.ceil(Math.random()*5)) + "category_ids": splice(categoryIds).splice(0,Math.ceil(Math.random()*5)+1), + "screenshots": ["http://www.example.com/img/sample.png"] }; } -- GitLab