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

Merge pull request #30 from autumnfound/malowe/master/28

Add maintainers to Listing #28
parents 25ff3436 7e4bfb45
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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());
......
......@@ -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";
......
......@@ -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)
};
}
......
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