Skip to content
Snippets Groups Projects
Commit e2eef209 authored by Martin Lowe's avatar Martin Lowe :flag_ca: Committed by Martin Lowe
Browse files

Add screenshots to listing entity #45


Change-Id: If9b8b12eb6d6b0c534d5dc2f459f2252e9f9be2d
Signed-off-by: Martin Lowe's avatarMartin Lowe <martin.lowe@eclipse-foundation.org>
parent a0f7aacb
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ public class Listing extends NodeBase { ...@@ -59,6 +59,7 @@ public class Listing extends NodeBase {
private String license; private String license;
private List<String> marketIds; private List<String> marketIds;
private List<String> categoryIds; private List<String> categoryIds;
private List<String> screenshots;
private List<Category> categories; private List<Category> categories;
private Organization organization; private Organization organization;
private List<Author> authors; private List<Author> authors;
...@@ -75,6 +76,7 @@ public class Listing extends NodeBase { ...@@ -75,6 +76,7 @@ public class Listing extends NodeBase {
this.marketIds = new ArrayList<>(); this.marketIds = new ArrayList<>();
this.categoryIds = new ArrayList<>(); this.categoryIds = new ArrayList<>();
this.categories = new ArrayList<>(); this.categories = new ArrayList<>();
this.screenshots = new ArrayList<>();
} }
/** /**
...@@ -290,6 +292,20 @@ public class Listing extends NodeBase { ...@@ -290,6 +292,20 @@ public class Listing extends NodeBase {
this.marketIds = new ArrayList<>(marketIds); 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 * @return the categories
*/ */
...@@ -394,7 +410,8 @@ public class Listing extends NodeBase { ...@@ -394,7 +410,8 @@ public class Listing extends NodeBase {
&& Objects.equals(logo, other.logo) && Objects.equals(organization, other.organization) && Objects.equals(logo, other.logo) && Objects.equals(organization, other.organization)
&& Objects.equals(status, other.status) && Objects.equals(supportUrl, other.supportUrl) && Objects.equals(status, other.status) && Objects.equals(supportUrl, other.supportUrl)
&& Objects.equals(tags, other.tags) && Objects.equals(teaser, other.teaser) && 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 @Override
...@@ -421,6 +438,7 @@ public class Listing extends NodeBase { ...@@ -421,6 +438,7 @@ public class Listing extends NodeBase {
sb.append(", authors=").append(authors); sb.append(", authors=").append(authors);
sb.append(", tags=").append(tags); sb.append(", tags=").append(tags);
sb.append(", versions=").append(versions); sb.append(", versions=").append(versions);
sb.append(", screenshots=").append(screenshots);
sb.append(']'); sb.append(']');
return sb.toString(); return sb.toString();
} }
......
...@@ -80,6 +80,7 @@ public class ListingCodec implements CollectibleCodec<Listing> { ...@@ -80,6 +80,7 @@ public class ListingCodec implements CollectibleCodec<Listing> {
doc.put(DatabaseFieldNames.CREATION_DATE, new Date(value.getCreationDate())); doc.put(DatabaseFieldNames.CREATION_DATE, new Date(value.getCreationDate()));
doc.put(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG, value.isFoundationMember()); doc.put(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG, value.isFoundationMember());
doc.put(DatabaseFieldNames.CATEGORY_IDS, value.getCategoryIds()); doc.put(DatabaseFieldNames.CATEGORY_IDS, value.getCategoryIds());
doc.put(DatabaseFieldNames.SCREENSHOTS, value.getScreenshots());
doc.put(DatabaseFieldNames.MARKET_IDS, value.getMarketIds()); doc.put(DatabaseFieldNames.MARKET_IDS, value.getMarketIds());
// for nested document types, use the converters to safely transform into BSON // for nested document types, use the converters to safely transform into BSON
...@@ -120,6 +121,7 @@ public class ListingCodec implements CollectibleCodec<Listing> { ...@@ -120,6 +121,7 @@ public class ListingCodec implements CollectibleCodec<Listing> {
out.setFoundationMember(document.getBoolean(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG)); out.setFoundationMember(document.getBoolean(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG));
out.setCategoryIds(document.getList(DatabaseFieldNames.CATEGORY_IDS, String.class)); out.setCategoryIds(document.getList(DatabaseFieldNames.CATEGORY_IDS, String.class));
out.setMarketIds(document.getList(DatabaseFieldNames.MARKET_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 // for nested document types, use the converters to safely transform into POJO
out.setAuthors(document.getList(DatabaseFieldNames.LISTING_AUTHORS, Document.class).stream() out.setAuthors(document.getList(DatabaseFieldNames.LISTING_AUTHORS, Document.class).stream()
......
...@@ -48,6 +48,7 @@ public final class DatabaseFieldNames { ...@@ -48,6 +48,7 @@ public final class DatabaseFieldNames {
public static final String FEATURE_IDS = "feature_ids"; public static final String FEATURE_IDS = "feature_ids";
public static final String FEATURE_ID = "feature_id"; public static final String FEATURE_ID = "feature_id";
public static final String INSTALL_STATE = "install_state"; public static final String INSTALL_STATE = "install_state";
public static final String SCREENSHOTS = "screenshots";
// catalog fields // catalog fields
public static final String CATALOG_TABS = "tabs"; public static final String CATALOG_TABS = "tabs";
......
...@@ -72,7 +72,7 @@ function createListing(count) { ...@@ -72,7 +72,7 @@ function createListing(count) {
console.log(`Generating listing ${count} of ${max}`); console.log(`Generating listing ${count} of ${max}`);
var json = generateJSON(uuid.v4()); var json = generateJSON(uuid.v4());
axios.post(argv.s+"/listings/", json) instance.put(argv.s+"/listings/", json)
.then(() => { .then(() => {
var installs = Math.floor(Math.random()*argv.i); var installs = Math.floor(Math.random()*argv.i);
console.log(`Generating ${installs} install records for listing '${json.id}'`); console.log(`Generating ${installs} install records for listing '${json.id}'`);
...@@ -152,7 +152,8 @@ function generateJSON(id) { ...@@ -152,7 +152,8 @@ function generateJSON(id) {
], ],
"versions": solutions, "versions": solutions,
"market_ids": splice(marketIds).splice(0,Math.ceil(Math.random()*2)), "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"]
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment