diff --git a/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java b/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java index a6450655534f251ae3f97f685931a5cc46c3a574..a6ff060de366a5cdc76ab5807c580c90ab0c20e6 100644 --- a/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java +++ b/src/main/java/org/eclipsefoundation/marketplace/dto/Listing.java @@ -59,21 +59,22 @@ public class Listing extends NodeBase { private String license; private List<String> categoryIds; private List<Category> categories; - private List<Organization> organizations; + private Organization organization; private List<Author> authors; private List<Tag> tags; private List<SolutionVersion> versions; + private String maintainers; /** * Default constructor, sets lists to empty lists to stop null pointers */ public Listing() { this.authors = new ArrayList<>(); - this.organizations = new ArrayList<>(); this.tags = new ArrayList<>(); this.versions = new ArrayList<>(); this.categoryIds = new ArrayList<>(); this.categories = new ArrayList<>(); + } /** @@ -290,18 +291,17 @@ public class Listing extends NodeBase { } /** - * @return the organizations + * @return the organization */ - public List<Organization> getOrganizations() { - return new ArrayList<>(organizations); + public Organization getOrganization() { + return organization; } /** - * @param organizations the organizations to set + * @param organization the organization to set */ - public void setOrganizations(List<Organization> organizations) { - Objects.requireNonNull(organizations); - this.organizations = new ArrayList<>(organizations); + public void setOrganization(Organization organization) { + this.organization = organization; } /** @@ -349,13 +349,27 @@ public class Listing extends NodeBase { this.versions = new ArrayList<>(versions); } + + * @return the maintainers + */ + public String getMaintainers() { + return maintainers; + } + + /** + * @param maintainers the maintainers to set + */ + public void setMaintainers(String maintainers) { + this.maintainers = maintainers; + } + @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + Objects.hash(authors, body, categories, categoryIds, creationDate, favoriteCount, - foundationMember, homepageUrl, installsRecent, installsTotal, license, logo, organizations, status, - supportUrl, tags, teaser, updateDate, versions); + foundationMember, homepageUrl, installsRecent, installsTotal, license, logo, organization, status, + supportUrl, tags, teaser, updateDate, versions, maintainers); return result; } @@ -376,11 +390,12 @@ public class Listing extends NodeBase { && creationDate == other.creationDate && favoriteCount == other.favoriteCount && foundationMember == other.foundationMember && Objects.equals(homepageUrl, other.homepageUrl) && installsRecent == other.installsRecent && installsTotal == other.installsTotal - && Objects.equals(license, other.license) && Objects.equals(logo, other.logo) + && Objects.equals(logo, other.logo) && Objects.equals(organization, other.organization) && Objects.equals(organizations, other.organizations) && 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); + && Objects.equals(url, other.url) && Objects.equals(versions, other.versions); + && Objects.equals(maintainers, other.maintainers); } @Override @@ -402,10 +417,11 @@ public class Listing extends NodeBase { sb.append(", creationDate=").append(creationDate); sb.append(", updateDate=").append(updateDate); sb.append(", license=").append(license); - sb.append(", organizations=").append(organizations); + sb.append(", organization=").append(organization); sb.append(", authors=").append(authors); sb.append(", tags=").append(tags); sb.append(", versions=").append(versions); + sb.append(", maintainers=").append(maintainers); return sb.toString(); } } \ No newline at end of file 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 7962ee20e7fc8349b7ca038c77ebf31a40829d0f..71330c37fbb2e0c718241e936b4610a43095172a 100644 --- a/src/main/java/org/eclipsefoundation/marketplace/dto/codecs/ListingCodec.java +++ b/src/main/java/org/eclipsefoundation/marketplace/dto/codecs/ListingCodec.java @@ -80,11 +80,11 @@ 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.MAINTAINERS, value.getMaintainers()); // for nested document types, use the converters to safely transform into BSON // documents - doc.put(DatabaseFieldNames.LISTING_ORGANIZATIONS, - value.getOrganizations().stream().map(organizationConverter::convert).collect(Collectors.toList())); + doc.put(DatabaseFieldNames.LISTING_ORGANIZATIONS, organizationConverter.convert(value.getOrganization())); doc.put(DatabaseFieldNames.LISTING_AUTHORS, value.getAuthors().stream().map(authorConverter::convert).collect(Collectors.toList())); doc.put(DatabaseFieldNames.LISTING_TAGS, @@ -119,19 +119,20 @@ public class ListingCodec implements CollectibleCodec<Listing> { out.setFavoriteCount(document.getLong(DatabaseFieldNames.MARKETPLACE_FAVORITES)); out.setFoundationMember(document.getBoolean(DatabaseFieldNames.FOUNDATION_MEMBER_FLAG)); out.setCategoryIds(document.getList(DatabaseFieldNames.CATEGORY_IDS, String.class)); + out.setMaintainers(document.getString(DatabaseFieldNames.MAINTAINERS)); // for nested document types, use the converters to safely transform into POJO out.setAuthors(document.getList(DatabaseFieldNames.LISTING_AUTHORS, Document.class).stream() .map(authorConverter::convert).collect(Collectors.toList())); - out.setOrganizations(document.getList(DatabaseFieldNames.LISTING_ORGANIZATIONS, Document.class).stream() - .map(organizationConverter::convert).collect(Collectors.toList())); - out.setTags(document.getList(DatabaseFieldNames.LISTING_TAGS, Document.class).stream().map(tagConverter::convert) - .collect(Collectors.toList())); + out.setOrganization( + organizationConverter.convert(document.get(DatabaseFieldNames.LISTING_ORGANIZATIONS, Document.class))); + out.setTags(document.getList(DatabaseFieldNames.LISTING_TAGS, Document.class).stream() + .map(tagConverter::convert).collect(Collectors.toList())); out.setVersions(document.getList(DatabaseFieldNames.LISTING_VERSIONS, Document.class).stream() .map(versionConverter::convert).collect(Collectors.toList())); out.setCategories(document.getList(DatabaseFieldNames.LISTING_CATEGORIES, Document.class).stream() .map(categoryConverter::convert).collect(Collectors.toList())); - + // convert date to epoch milli out.setCreationDate(document.getDate(DatabaseFieldNames.CREATION_DATE).toInstant().toEpochMilli()); out.setUpdateDate(document.getDate(DatabaseFieldNames.UPDATE_DATE).toInstant().toEpochMilli()); diff --git a/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java b/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java index dbcac257ecfb078b4271bf63dc279b73f2e0cf5b..12ff8a9ef8b7403568d2e44970af818d05e328bc 100644 --- a/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java +++ b/src/main/java/org/eclipsefoundation/marketplace/namespace/DatabaseFieldNames.java @@ -43,6 +43,7 @@ public final class DatabaseFieldNames { public static final String LISTING_TAGS = "tags"; public static final String CATEGORY_IDS = "category_ids"; public static final String LISTING_CATEGORIES = "categories"; + public static final String MAINTAINERS = "maintainers"; // catalog fields public static final String CATALOG_TABS = "tabs"; diff --git a/src/main/node/index.js b/src/main/node/index.js index 03d5f459365f43493561d3e52e09ba563aca541f..cb2aa1a79c3b5beee4e9cfd597112b142ec9467b 100644 --- a/src/main/node/index.js +++ b/src/main/node/index.js @@ -112,16 +112,10 @@ function generateJSON(id) { "username": "autumnfound" } ], - "organizations": [ - { - "name": "Eclipse Foundation", - "id": 1 - }, - { - "name": "Eclipse inc.", - "id": 2 - } - ], + "organization": { + "name": "Eclipse Foundation", + "id": 1 + }, "tags": [ { "name": "Build tools", @@ -130,6 +124,7 @@ function generateJSON(id) { } ], "versions": solutions, + "maintainers": "Bill and Ted", "category_ids": splice(categoryIds).splice(0,Math.ceil(Math.random()*5)+1) }; }