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

Add maintainers to Listing #28


Added maintainers, and fixed organizations.

Change-Id: Ic62b0580be1c0ac5fc107ce3f7ebca8598403601
Signed-off-by: Martin Lowe's avatarMartin Lowe <martin.lowe@eclipse-foundation.org>
parent 25ff3436
No related branches found
No related tags found
1 merge request!30Add maintainers to Listing #28
...@@ -59,21 +59,22 @@ public class Listing extends NodeBase { ...@@ -59,21 +59,22 @@ public class Listing extends NodeBase {
private String license; private String license;
private List<String> categoryIds; private List<String> categoryIds;
private List<Category> categories; private List<Category> categories;
private List<Organization> organizations; private Organization organization;
private List<Author> authors; private List<Author> authors;
private List<Tag> tags; private List<Tag> tags;
private List<SolutionVersion> versions; private List<SolutionVersion> versions;
private String maintainers;
/** /**
* Default constructor, sets lists to empty lists to stop null pointers * Default constructor, sets lists to empty lists to stop null pointers
*/ */
public Listing() { public Listing() {
this.authors = new ArrayList<>(); this.authors = new ArrayList<>();
this.organizations = new ArrayList<>();
this.tags = new ArrayList<>(); this.tags = new ArrayList<>();
this.versions = new ArrayList<>(); this.versions = new ArrayList<>();
this.categoryIds = new ArrayList<>(); this.categoryIds = new ArrayList<>();
this.categories = new ArrayList<>(); this.categories = new ArrayList<>();
} }
/** /**
...@@ -290,18 +291,17 @@ public class Listing extends NodeBase { ...@@ -290,18 +291,17 @@ public class Listing extends NodeBase {
} }
/** /**
* @return the organizations * @return the organization
*/ */
public List<Organization> getOrganizations() { public Organization getOrganization() {
return new ArrayList<>(organizations); return organization;
} }
/** /**
* @param organizations the organizations to set * @param organization the organization to set
*/ */
public void setOrganizations(List<Organization> organizations) { public void setOrganization(Organization organization) {
Objects.requireNonNull(organizations); this.organization = organization;
this.organizations = new ArrayList<>(organizations);
} }
/** /**
...@@ -349,13 +349,27 @@ public class Listing extends NodeBase { ...@@ -349,13 +349,27 @@ public class Listing extends NodeBase {
this.versions = new ArrayList<>(versions); 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 @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = super.hashCode(); int result = super.hashCode();
result = prime * result + Objects.hash(authors, body, categories, categoryIds, creationDate, favoriteCount, result = prime * result + Objects.hash(authors, body, categories, categoryIds, creationDate, favoriteCount,
foundationMember, homepageUrl, installsRecent, installsTotal, license, logo, organizations, status, foundationMember, homepageUrl, installsRecent, installsTotal, license, logo, organization, status,
supportUrl, tags, teaser, updateDate, versions); supportUrl, tags, teaser, updateDate, versions, maintainers);
return result; return result;
} }
...@@ -376,11 +390,12 @@ public class Listing extends NodeBase { ...@@ -376,11 +390,12 @@ public class Listing extends NodeBase {
&& creationDate == other.creationDate && favoriteCount == other.favoriteCount && creationDate == other.creationDate && favoriteCount == other.favoriteCount
&& foundationMember == other.foundationMember && Objects.equals(homepageUrl, other.homepageUrl) && foundationMember == other.foundationMember && Objects.equals(homepageUrl, other.homepageUrl)
&& installsRecent == other.installsRecent && installsTotal == other.installsTotal && 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(organizations, other.organizations) && Objects.equals(status, other.status)
&& Objects.equals(supportUrl, other.supportUrl) && Objects.equals(tags, other.tags) && Objects.equals(supportUrl, other.supportUrl) && Objects.equals(tags, other.tags)
&& Objects.equals(teaser, other.teaser) && updateDate == other.updateDate && 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 @Override
...@@ -402,10 +417,11 @@ public class Listing extends NodeBase { ...@@ -402,10 +417,11 @@ public class Listing extends NodeBase {
sb.append(", creationDate=").append(creationDate); sb.append(", creationDate=").append(creationDate);
sb.append(", updateDate=").append(updateDate); sb.append(", updateDate=").append(updateDate);
sb.append(", license=").append(license); sb.append(", license=").append(license);
sb.append(", organizations=").append(organizations); sb.append(", organization=").append(organization);
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(", maintainers=").append(maintainers);
return sb.toString(); return sb.toString();
} }
} }
\ No newline at end of file
...@@ -80,11 +80,11 @@ public class ListingCodec implements CollectibleCodec<Listing> { ...@@ -80,11 +80,11 @@ 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.MAINTAINERS, value.getMaintainers());
// for nested document types, use the converters to safely transform into BSON // for nested document types, use the converters to safely transform into BSON
// documents // documents
doc.put(DatabaseFieldNames.LISTING_ORGANIZATIONS, doc.put(DatabaseFieldNames.LISTING_ORGANIZATIONS, organizationConverter.convert(value.getOrganization()));
value.getOrganizations().stream().map(organizationConverter::convert).collect(Collectors.toList()));
doc.put(DatabaseFieldNames.LISTING_AUTHORS, doc.put(DatabaseFieldNames.LISTING_AUTHORS,
value.getAuthors().stream().map(authorConverter::convert).collect(Collectors.toList())); value.getAuthors().stream().map(authorConverter::convert).collect(Collectors.toList()));
doc.put(DatabaseFieldNames.LISTING_TAGS, doc.put(DatabaseFieldNames.LISTING_TAGS,
...@@ -119,19 +119,20 @@ public class ListingCodec implements CollectibleCodec<Listing> { ...@@ -119,19 +119,20 @@ public class ListingCodec implements CollectibleCodec<Listing> {
out.setFavoriteCount(document.getLong(DatabaseFieldNames.MARKETPLACE_FAVORITES)); out.setFavoriteCount(document.getLong(DatabaseFieldNames.MARKETPLACE_FAVORITES));
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.setMaintainers(document.getString(DatabaseFieldNames.MAINTAINERS));
// 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()
.map(authorConverter::convert).collect(Collectors.toList())); .map(authorConverter::convert).collect(Collectors.toList()));
out.setOrganizations(document.getList(DatabaseFieldNames.LISTING_ORGANIZATIONS, Document.class).stream() out.setOrganization(
.map(organizationConverter::convert).collect(Collectors.toList())); organizationConverter.convert(document.get(DatabaseFieldNames.LISTING_ORGANIZATIONS, Document.class)));
out.setTags(document.getList(DatabaseFieldNames.LISTING_TAGS, Document.class).stream().map(tagConverter::convert) out.setTags(document.getList(DatabaseFieldNames.LISTING_TAGS, Document.class).stream()
.collect(Collectors.toList())); .map(tagConverter::convert).collect(Collectors.toList()));
out.setVersions(document.getList(DatabaseFieldNames.LISTING_VERSIONS, Document.class).stream() out.setVersions(document.getList(DatabaseFieldNames.LISTING_VERSIONS, Document.class).stream()
.map(versionConverter::convert).collect(Collectors.toList())); .map(versionConverter::convert).collect(Collectors.toList()));
out.setCategories(document.getList(DatabaseFieldNames.LISTING_CATEGORIES, Document.class).stream() out.setCategories(document.getList(DatabaseFieldNames.LISTING_CATEGORIES, Document.class).stream()
.map(categoryConverter::convert).collect(Collectors.toList())); .map(categoryConverter::convert).collect(Collectors.toList()));
// convert date to epoch milli // convert date to epoch milli
out.setCreationDate(document.getDate(DatabaseFieldNames.CREATION_DATE).toInstant().toEpochMilli()); out.setCreationDate(document.getDate(DatabaseFieldNames.CREATION_DATE).toInstant().toEpochMilli());
out.setUpdateDate(document.getDate(DatabaseFieldNames.UPDATE_DATE).toInstant().toEpochMilli()); out.setUpdateDate(document.getDate(DatabaseFieldNames.UPDATE_DATE).toInstant().toEpochMilli());
......
...@@ -43,6 +43,7 @@ public final class DatabaseFieldNames { ...@@ -43,6 +43,7 @@ public final class DatabaseFieldNames {
public static final String LISTING_TAGS = "tags"; public static final String LISTING_TAGS = "tags";
public static final String CATEGORY_IDS = "category_ids"; public static final String CATEGORY_IDS = "category_ids";
public static final String LISTING_CATEGORIES = "categories"; public static final String LISTING_CATEGORIES = "categories";
public static final String MAINTAINERS = "maintainers";
// catalog fields // catalog fields
public static final String CATALOG_TABS = "tabs"; public static final String CATALOG_TABS = "tabs";
......
...@@ -112,16 +112,10 @@ function generateJSON(id) { ...@@ -112,16 +112,10 @@ function generateJSON(id) {
"username": "autumnfound" "username": "autumnfound"
} }
], ],
"organizations": [ "organization": {
{ "name": "Eclipse Foundation",
"name": "Eclipse Foundation", "id": 1
"id": 1 },
},
{
"name": "Eclipse inc.",
"id": 2
}
],
"tags": [ "tags": [
{ {
"name": "Build tools", "name": "Build tools",
...@@ -130,6 +124,7 @@ function generateJSON(id) { ...@@ -130,6 +124,7 @@ function generateJSON(id) {
} }
], ],
"versions": solutions, "versions": solutions,
"maintainers": "Bill and Ted",
"category_ids": splice(categoryIds).splice(0,Math.ceil(Math.random()*5)+1) "category_ids": splice(categoryIds).splice(0,Math.ceil(Math.random()*5)+1)
}; };
} }
......
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