Unverified Commit c5f43207 authored by Martin Lowe's avatar Martin Lowe 🇨🇦 Committed by GitHub
Browse files

Copyright headers, WG levels impl, openapi yaml (#82)

* Add copyright headers to Java files

* Add Working Group levels implementation

* Update OpenAPI yaml for new org and wg endpoints

* Added organizations and working_groups to docker vhost config

* Update to organizations endpoint spec
parent 435aac9f
......@@ -12,4 +12,12 @@ location /userinfo {
location /logout {
proxy_pass http://api:8090/logout;
}
location /working_groups {
proxy_pass http://api:8090/working_groups;
}
location /organizations {
proxy_pass http://api:8090/organizations;
}
\ No newline at end of file
openapi: 3.0.0
openapi: '3.0.0'
info:
version: 1.0.0
title: Membership portal
......@@ -13,6 +13,10 @@ tags:
description: Definitions related to membership form data in the database
- name: Contacts
description: Definitions related to membership form designated contacts
- name: Form Organizations
description: Definitions related to membership form organizations
- name: Form Working Groups
description: Definitions related to membership form working group targets
- name: Organizations
description: Definitions related to membership form organizations
- name: Working Groups
......@@ -219,36 +223,36 @@ paths:
$ref: '#/components/schemas/ObjectID'
get:
tags:
- Organizations
summary: Organizations list
- Form Organizations
summary: Form Organizations list
description: Returns a list of tracked organizationsfor the form
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/Organizations'
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/FormOrganizations'
500:
description: Error while retrieving data
post:
tags:
- Organizations
summary: Organizations create
- Form Organizations
summary: Form Organizations create
description: Using the passed organization object, a new organization object is saved to the dataset.
requestBody:
description: The organization to be updated or inserted into the data set.
content:
application/json:
schema:
$ref: '#/components/schemas/OrganizationPush'
$ref: '#/components/schemas/FormOrganizationPush'
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
$ref: '#/components/schemas/FormOrganization'
403:
description: Unauthorized
......@@ -268,28 +272,28 @@ paths:
$ref: '#/components/schemas/ObjectID'
put:
tags:
- Organizations
summary: Organizations update
- Form Organizations
summary: Form Organizations update
description: Using the passed organization object, updates or inserts are made to save the data.
requestBody:
description: The organization to be updated or inserted into the data set.
content:
application/json:
schema:
$ref: '#/components/schemas/OrganizationPush'
$ref: '#/components/schemas/FormOrganizationPush'
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
$ref: '#/components/schemas/FormOrganization'
403:
description: Unauthorized
delete:
tags:
- Organizations
summary: Organizations delete
- Form Organizations
summary: Form Organizations delete
description: Remove an organization for the form given a form ID
responses:
204:
......@@ -306,38 +310,38 @@ paths:
$ref: '#/components/schemas/ObjectID'
get:
tags:
- Working Groups
summary: Working Groups list
description: Returns a list of tracked Working Groups for membership form
- Form Working Groups
summary: Form Working Groups list
description: Returns a list of tracked Form Working Groups for membership form
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroups'
$ref: '#/components/schemas/FormWorkingGroups'
403:
description: Unauthorized
500:
description: Error while retrieving data
post:
tags:
- Working Groups
summary: Working Groups create
description: Using the passed Working Groups object, creates a new object in the dataset.
- Form Working Groups
summary: Form Working Groups create
description: Using the passed Form Working Groups object, creates a new object in the dataset.
requestBody:
description: The working group to be updated or inserted into the data set.
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroupPush'
$ref: '#/components/schemas/FormWorkingGroupPush'
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroup'
$ref: '#/components/schemas/FormWorkingGroup'
403:
description: Unauthorized
/form/{id}/working_groups/{workingGroupID}:
......@@ -356,8 +360,8 @@ paths:
$ref: '#/components/schemas/ObjectID'
get:
tags:
- Working Groups
summary: Working Group
- Form Working Groups
summary: Form Working Group
description: Returns a working group entry that has a matching ID
responses:
200:
......@@ -365,42 +369,115 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroup'
$ref: '#/components/schemas/FormWorkingGroup'
403:
description: Unauthorized
500:
description: Error while retrieving data
put:
tags:
- Working Groups
summary: Working Groups update
description: Using the passed Working Groups object, updates or inserts are made to save the data.
- Form Working Groups
summary: Form Working Groups update
description: Using the passed Form Working Groups object, updates or inserts are made to save the data.
requestBody:
description: The working group to be updated or inserted into the data set.
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroupPush'
$ref: '#/components/schemas/FormWorkingGroupPush'
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroup'
$ref: '#/components/schemas/FormWorkingGroup'
403:
description: Unauthorized
delete:
tags:
- Working Groups
summary: Working Groups delete
- Form Working Groups
summary: Form Working Groups delete
description: Remove a working group form entry with the given ID
responses:
204:
description: Success
403:
description: Unauthorized
/organizations:
get:
tags:
- Organizations
summary: Organizations List
description: Returns a list of organizations from the Eclipse API
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/Organizations'
500:
description: Error while retrieving data
/organizations/{organizationID}:
parameters:
- name: organizationID
in: path
description: The organization ID for the organization to retrieve
required: true
schema:
type: number
get:
tags:
- Organizations
summary: Organization
description: Returns a working group entry that has a matching ID
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
500:
description: Error while retrieving data
/working_groups:
get:
tags:
- Working Groups
summary: Working Group List
description: Returns a working group entry that has a matching ID
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroups'
500:
description: Error while retrieving data
/working_groups/{documentID}:
parameters:
- name: documentID
in: path
description: The document ID for the working group to retrieve
required: true
schema:
$ref: '#/components/schemas/ObjectID'
get:
tags:
- Working Groups
summary: Working Group
description: Returns a working group entry that has a matching ID
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/WorkingGroup'
500:
description: Error while retrieving data
components:
schemas:
ObjectID:
......@@ -463,12 +540,12 @@ components:
enum: [COMPANY, WORKING_GROUP, MARKETING, ACCOUNTING]
Organizations:
FormOrganizations:
type: array
items:
$ref: '#/components/schemas/Organization'
$ref: '#/components/schemas/FormOrganization'
Organization:
FormOrganization:
type: object
properties:
id:
......@@ -499,7 +576,7 @@ components:
postal_code:
type: string
description: The postal code of the physical address of the organization
OrganizationPush:
FormOrganizationPush:
type: object
properties:
legal_name:
......@@ -554,12 +631,11 @@ components:
signing_authority:
type: boolean
description: Whether the currently submitting user has signing authority for membership contracts.
WorkingGroups:
FormWorkingGroups:
type: array
items:
$ref: '#/components/schemas/WorkingGroup'
WorkingGroup:
$ref: '#/components/schemas/FormWorkingGroup'
FormWorkingGroup:
type: object
properties:
id:
......@@ -574,7 +650,7 @@ components:
$ref: '#/components/schemas/DateTime'
contact:
$ref: '#/components/schemas/Contact'
WorkingGroupPush:
FormWorkingGroupPush:
type: object
properties:
working_group:
......@@ -587,4 +663,81 @@ components:
$ref: '#/components/schemas/DateTime'
contact:
$ref: '#/components/schemas/Contact'
Organizations:
type: array
items:
$ref: '#/components/schemas/Organization'
Organization:
type: object
properties:
id:
$ref: '#/components/schemas/ObjectID'
name:
type: string
member_level:
type: object
properties:
level:
type: string
description:
type: string
description:
type: object
properties:
short:
type: string
full:
type: string
website:
type: string
logos:
type: object
properties:
small:
type: string
description: URL of compressed for web logo
full:
type: string
description: URL of full resolution logo
wgpa:
type: array
items:
type: object
properties:
document_id:
$ref: '#/components/schemas/ObjectID'
level:
type: string
working_group:
type: string
description:
type: string
WorkingGroups:
type: array
items:
$ref: '#/components/schemas/WorkingGroup'
WorkingGroup:
type: object
properties:
documentID:
$ref: '#/components/schemas/ObjectID'
name:
type: string
levels:
type: object
description: The ID of the working group relationship to be formed
properties:
document_id:
$ref: '#/components/schemas/ObjectID'
level:
type: string
price:
type: string
revenue_top:
type: number
revenue_bottom:
type: number
company_size:
type: number
/**
* Copyright (c) 2021 Eclipse Foundation
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.react.bootstrap;
import java.time.Instant;
......@@ -21,8 +32,8 @@ import org.eclipsefoundation.persistence.service.FilterService;
import org.eclipsefoundation.react.model.Address;
import org.eclipsefoundation.react.model.Contact;
import org.eclipsefoundation.react.model.MembershipForm;
import org.eclipsefoundation.react.model.Organization;
import org.eclipsefoundation.react.model.WorkingGroup;
import org.eclipsefoundation.react.model.FormOrganization;
import org.eclipsefoundation.react.model.FormWorkingGroup;
import org.eclipsefoundation.react.namespace.ContactTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -80,11 +91,11 @@ public class DataLoader {
// batch add the entities
forms = dao.add(new RDBMSQuery<>(wrap, filters.get(MembershipForm.class)), forms);
LOGGER.debug("Created {} forms", forms.size());
List<Organization> organizations = new ArrayList<>(forms.size());
List<FormOrganization> organizations = new ArrayList<>(forms.size());
List<Contact> contacts = new ArrayList<>(forms.size() * ContactTypes.values().length);
List<WorkingGroup> wgs = new ArrayList<>();
List<FormWorkingGroup> wgs = new ArrayList<>();
for (MembershipForm mf : forms) {
Organization o = new Organization();
FormOrganization o = new FormOrganization();
o.setForm(mf);
o.setLegalName(RandomStringUtils.randomAlphabetic(4, 10));
o.setTwitterHandle(RandomStringUtils.randomAlphabetic(4, 10));
......@@ -94,7 +105,7 @@ public class DataLoader {
a.setPostalCode(RandomStringUtils.randomAlphabetic(4, 10));
a.setProvinceState(RandomStringUtils.randomAlphabetic(2));
a.setStreet(RandomStringUtils.randomAlphabetic(4, 10));
a.setOrganizationID(o.getId());
a.setOrganization(o);
o.setAddress(a);
organizations.add(o);
for (int j = 0; j < ContactTypes.values().length; j++) {
......@@ -113,7 +124,7 @@ public class DataLoader {
}
// randomly create WG entries
while (Math.random() > 0.5) {
WorkingGroup wg = new WorkingGroup();
FormWorkingGroup wg = new FormWorkingGroup();
wg.setWorkingGroupID(config.getWorkingGroups().get(r.nextInt(config.getWorkingGroups().size())));
wg.setParticipationLevel(
config.getParticipationLevels().get(r.nextInt(config.getParticipationLevels().size())));
......@@ -125,9 +136,9 @@ public class DataLoader {
wgs.add(wg);
}
}
organizations = dao.add(new RDBMSQuery<>(wrap, filters.get(Organization.class)), organizations);
organizations = dao.add(new RDBMSQuery<>(wrap, filters.get(FormOrganization.class)), organizations);
contacts = dao.add(new RDBMSQuery<>(wrap, filters.get(Contact.class)), contacts);
wgs = dao.add(new RDBMSQuery<>(wrap, filters.get(WorkingGroup.class)), wgs);
wgs = dao.add(new RDBMSQuery<>(wrap, filters.get(FormWorkingGroup.class)), wgs);
LOGGER.debug("Created {} contacts", contacts.size());
LOGGER.debug("Created {} organizations", organizations.size());
LOGGER.debug("Created {} working groups", wgs.size());
......
/**
* Copyright (c) 2021 Eclipse Foundation
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.react.bootstrap;
import java.util.ArrayList;
......
/**
* Copyright (c) 2021 Eclipse Foundation
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.react.model;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.json.bind.annotation.JsonbTransient;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.ws.rs.core.MultivaluedMap;
......@@ -35,8 +48,10 @@ public class Address extends BareNode implements TargetedClone<Address> {
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;
@JoinColumn(table = "Organization", referencedColumnName = "id")
private String organizationID;
@JsonbTransient
@OneToOne
@JoinColumn(name = "organizationID", referencedColumnName = "id")
private FormOrganization organization;
private String street;
private String city;
......@@ -55,14 +70,14 @@ public class Address extends BareNode implements TargetedClone<Address> {
this.id = id;
}
/** @return the organizationID */
public String getOrganizationID() {
return organizationID;
/** @return the organization */
public FormOrganization getOrganization() {
return this.organization;
}
/** @param organizationID the organizationID to set */
public void setOrganizationID(String organizationID) {
this.organizationID = organizationID;
/** @param org the organization to set */
public void setOrganization(FormOrganization org) {
this.organization = org;
}
/** @return the steet */
......@@ -119,7 +134,6 @@ public class Address extends BareNode implements TargetedClone<Address> {
public Address cloneTo(Address target) {
target.setCity(getCity());
target.setCountry(getCountry());
target.setOrganizationID(getOrganizationID());
target.setPostalCode(getPostalCode());
target.setProvinceState(getProvinceState());
target.setStreet(getStreet());
......@@ -128,7 +142,7 @@ public class Address extends BareNode implements TargetedClone<Address> {
@Override
public int hashCode() {
return Objects.hash(city, country, id, organizationID, postalCode, provinceState, street);
return Objects.hash(city, country, id, postalCode, provinceState, street);
}
@Override
......@@ -141,9 +155,8 @@ public class Address extends BareNode implements TargetedClone<Address> {
return false;
Address other = (Address) obj;
return Objects.equals(city, other.city) && Objects.equals(country, other.country)
&& Objects.equals(id, other.id) && Objects.equals(organizationID, other.organizationID)
&& Objects.equals(postalCode, other.postalCode) && Objects.equals(provinceState, other.provinceState)
&& Objects.equals(street, other.street);
&& Objects.equals(id, other.id) && Objects.equals(postalCode, other.postalCode)
&& Objects.equals(provinceState, other.provinceState) && Objects.equals(street, other.street);
}
/**
......
/**
* Copyright (c) 2021 Eclipse Foundation
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipsefoundation.react.model;
import java.util.Objects;
......