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 {
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();
}
......
......@@ -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()
......
......@@ -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";
......
......@@ -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"]
};
}
......
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