Commit a3d5a946 authored by femiadeyemi's avatar femiadeyemi
Browse files

adjust market-user and organisation entity

Motivation:

Meeting up with the new API design requires that the market-user
and organisation entity are realign.

Modification:

- factor out some part of market-user and create a new class (person)
- make organisation enity to extend audit-metadata and some properties
    were added.
- use the lombok project to reduce the boilerplate code in both
    the market-user and organisation entities.
- add 'person' to the list of PrefixEnum in the CerebrumEntityUuidGenerator

Result:

Market-user and Organisation entity are now re-worked

Target: master
parent 90b6d9ff
Pipeline #73481 failed with stages
in 11 minutes and 40 seconds
......@@ -2,57 +2,29 @@ package de.helmholtz.marketplace.cerebrum.entities;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Objects;
import de.helmholtz.marketplace.cerebrum.entities.relationship.Affiliation;
import de.helmholtz.marketplace.cerebrum.entities.relationship.Management;
import de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerator;
import static de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerator.generate;
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
@NodeEntity
public class MarketUser
public class MarketUser extends Person
{
@Schema(description = "Unique identifier of the marketplace user.",
example = "usr-01eac6d7-0d35-1812-a3ed-24aec4231940", required = true)
@Id @GeneratedValue(strategy = CerebrumEntityUuidGenerator.class)
private String uuid;
@Schema(description = "first name of the user.",
example = "Paul", required = true)
@NotBlank
@Size(max = 100)
private String firstName;
@Schema(description = "last name or surname of the user.",
example = "Millar", required = true)
@NotBlank
@Size(max = 100)
private String lastName;
@Schema(description = "User chosen name to represent him or herself", example = "pm")
@Size(max = 20)
private String screenName;
@Schema(description = "Email address of the user.",
example = "paul.millar@hifis.net", required = true)
@Email(message = "Email Address")
@NotBlank
@Size(max = 100)
private String email;
@Schema(description = "Helmholtz AAI generated unique user identifier",
example = "110248495921238986420", required = true)
@NotBlank
private String sub;
@JsonIgnoreProperties("user")
......@@ -62,104 +34,4 @@ public class MarketUser
@JsonIgnoreProperties("marketUser")
@Relationship(type = "MANAGES")
private List<Management> managedServices;
public String getUuid()
{
return uuid;
}
public void setUuid(String uuid)
{
this.uuid = Boolean.TRUE.equals(CerebrumEntityUuidGenerator.isValid(uuid)) ?
uuid : generate("usr");
}
public String getFirstName()
{
return firstName;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public String getLastName()
{
return lastName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getScreenName()
{
return screenName;
}
public void setScreenName(String screenName)
{
this.screenName = screenName;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
public String getSub()
{
return sub;
}
public void setSub(String sub)
{
this.sub = sub;
}
public List<Affiliation> getAffiliations()
{
return affiliations;
}
public void setAffiliations(List<Affiliation> affiliations)
{
this.affiliations = affiliations;
}
public List<Management> getManagedServices()
{
return managedServices;
}
public void setManagedServices(List<Management> managedServices)
{
this.managedServices = managedServices;
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MarketUser that = (MarketUser) o;
return firstName.equals(that.firstName) &&
lastName.equals(that.lastName) &&
Objects.equals(screenName, that.screenName) &&
email.equals(that.email) &&
sub.equals(that.sub);
}
@Override
public int hashCode()
{
return Objects.hash(firstName, lastName, screenName, email, sub);
}
}
......@@ -2,6 +2,9 @@ package de.helmholtz.marketplace.cerebrum.entities;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.URL;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
......@@ -20,11 +23,14 @@ import static de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerato
import static org.neo4j.ogm.annotation.Relationship.INCOMING;
@Schema(name = "Organization", description = "POJO that represents a single organization entry.")
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
@NodeEntity
public class Organization
{
@Schema(description = "Unique identifier of the organisation",
example = "org-01eac6d7-0d35-1812-a3ed-24aec4231940", required = true)
@Setter(AccessLevel.NONE)
@Id @GeneratedValue(strategy = CerebrumEntityUuidGenerator.class)
private String uuid;
......@@ -33,9 +39,13 @@ public class Organization
@NotNull
private String name;
@Schema(description = "Name of the organisation in German")
private String nameDE;
@Schema(description = "The shortened form of an organisation's name - this " +
"can be an acronym or initial",
example = "DESY")
@Setter(AccessLevel.NONE)
private String abbreviation;
@Schema(description = "Valid web address link to the organisation logo " +
......@@ -49,6 +59,9 @@ public class Organization
@NotNull
private String url;
@Schema(description = "", example = "HELMHOLTZ_CENTRE")
private Type type;
@JsonIgnoreProperties({"organization"})
@Schema(description = "A list of Services which are provided by the organization")
@Relationship(type = "HOSTED_BY", direction = INCOMING)
......@@ -59,11 +72,6 @@ public class Organization
@Relationship(type = "BELONGS_TO", direction = INCOMING)
private List<Affiliation> members;
public String getUuid()
{
return uuid;
}
public void setUuid(String uuid)
{
this.uuid = Boolean.TRUE.equals(
......@@ -71,64 +79,9 @@ public class Organization
? uuid : generate("org");
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getAbbreviation()
{
return abbreviation;
}
public void setAbbreviation(String abbreviation)
{
this.abbreviation = abbreviation;
}
public String getImg()
{
return img;
}
public void setImg(String img)
{
this.img = img;
}
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
public List<ServiceProvider> getHostedServices()
{
return hostedServices;
}
public void setHostedServices(List<ServiceProvider> serviceHosted)
{
this.hostedServices = serviceHosted;
}
public List<Affiliation> getMembers()
{
return members;
}
public void setMembers(List<Affiliation> members)
{
this.members = members;
this.abbreviation = abbreviation.toUpperCase();
}
@Override
......@@ -149,3 +102,12 @@ public class Organization
return Objects.hash(name, abbreviation, img, url);
}
}
enum Type
{
HELMHOLTZ_CENTRE,
DEPARTMENT,
GROUP,
UNIT,
OTHERS
}
package de.helmholtz.marketplace.cerebrum.entities;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Objects;
import de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerator;
import static de.helmholtz.marketplace.cerebrum.utils.CerebrumEntityUuidGenerator.generate;
@Setter(AccessLevel.PUBLIC)
@Getter(AccessLevel.PUBLIC)
public class Person extends AuditMetadata
{
@Schema(description = "Unique identifier of the marketplace user.",
example = "usr-01eac6d7-0d35-1812-a3ed-24aec4231940", required = true)
@Setter(AccessLevel.NONE)
@Id @GeneratedValue(strategy = CerebrumEntityUuidGenerator.class)
private String uuid;
@Schema(description = "first name of the user.",
example = "Paul", required = true)
@NotBlank
@Size(max = 100)
private String firstName;
@Schema(description = "last name or surname of the user.",
example = "Miller", required = true)
@NotBlank
@Size(max = 100)
private String lastName;
@Schema(description = "Email address of the user.",
example = "paul.miller@hifis.net", required = true)
@Email(message = "Email Address")
@NotBlank
@Size(max = 100)
private String email;
public void setUuid(String uuid)
{
this.uuid = Boolean.TRUE.equals(CerebrumEntityUuidGenerator.isValid(uuid)) ?
uuid : generate("usr");
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person that = (Person) o;
return firstName.equals(that.firstName) &&
lastName.equals(that.lastName) &&
email.equals(that.email);
}
@Override
public int hashCode()
{
return Objects.hash(firstName, lastName, email);
}
}
......@@ -17,6 +17,7 @@ public class CerebrumEntityUuidGenerator implements IdStrategy
{
ORGANIZATION("org", "organization"),
HELMHOLTZMARKETUSER ("usr", "marketuser"),
PERSON ("usr", "person"),
MARKETSERVICE ("svc", "marketservice");
private final String prefix;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment