Permalink
Browse files

Merge pull request #1 from ITUBIDB/development

Development
  • Loading branch information...
dgkncelik committed Jun 6, 2018
2 parents 1b60800 + c77e635 commit ca8150fc017b2cce3fa7f78125bc539d916d59ac
Showing with 3,052 additions and 0 deletions.
  1. +4 −0 README.md
  2. +101 −0 pom.xml
  3. +146 −0 src/main/java/edu/itu/cavabunga/lib/entity/Component.java
  4. +62 −0 src/main/java/edu/itu/cavabunga/lib/entity/Parameter.java
  5. +56 −0 src/main/java/edu/itu/cavabunga/lib/entity/Participant.java
  6. +234 −0 src/main/java/edu/itu/cavabunga/lib/entity/Property.java
  7. +31 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Alarm.java
  8. +31 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Calendar.java
  9. +56 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/ComponentType.java
  10. +27 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Daylight.java
  11. +45 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Event.java
  12. +32 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Freebusy.java
  13. +37 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Journal.java
  14. +27 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Standard.java
  15. +30 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Timezone.java
  16. +47 −0 src/main/java/edu/itu/cavabunga/lib/entity/component/Todo.java
  17. +18 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Altrep.java
  18. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Cn.java
  19. +22 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Cutype.java
  20. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/DelegatedFrom.java
  21. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/DelegatedTo.java
  22. +18 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Dir.java
  23. +24 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Encoding.java
  24. +20 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Fbtype.java
  25. +18 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Fmttype.java
  26. +20 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Language.java
  27. +18 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Member.java
  28. +110 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/ParameterType.java
  29. +48 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Partstat.java
  30. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Range.java
  31. +18 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Related.java
  32. +20 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Reltype.java
  33. +21 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Role.java
  34. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Rsvp.java
  35. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/SentBy.java
  36. +26 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Tzid.java
  37. +30 −0 src/main/java/edu/itu/cavabunga/lib/entity/parameter/Value.java
  38. +9 −0 src/main/java/edu/itu/cavabunga/lib/entity/participant/Group.java
  39. +22 −0 src/main/java/edu/itu/cavabunga/lib/entity/participant/ParticipantType.java
  40. +6 −0 src/main/java/edu/itu/cavabunga/lib/entity/participant/Resource.java
  41. +9 −0 src/main/java/edu/itu/cavabunga/lib/entity/participant/User.java
  42. +27 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Acknowledged.java
  43. +21 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Action.java
  44. +18 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Attach.java
  45. +15 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Attendee.java
  46. +20 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Calscale.java
  47. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Catagories.java
  48. +21 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Class.java
  49. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Comment.java
  50. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Completed.java
  51. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Contact.java
  52. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Country.java
  53. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Created.java
  54. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Description.java
  55. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Dtend.java
  56. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Dtstamp.java
  57. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Dtstart.java
  58. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Due.java
  59. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Duration.java
  60. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Exdate.java
  61. +9 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Exrule.java
  62. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Freebusy.java
  63. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Geo.java
  64. +15 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Lastmod.java
  65. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Location.java
  66. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Method.java
  67. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Organizer.java
  68. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Percent.java
  69. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Priority.java
  70. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Prodid.java
  71. +255 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/PropertyType.java
  72. +29 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/PropertyValueType.java
  73. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Rdate.java
  74. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Recurid.java
  75. +11 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Related.java
  76. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Repeat.java
  77. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Resources.java
  78. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Rrule.java
  79. +9 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Rstatus.java
  80. +15 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Seq.java
  81. +27 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Status.java
  82. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Summary.java
  83. +20 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Transp.java
  84. +19 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Trigger.java
  85. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Tzid.java
  86. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Tzname.java
  87. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Tzoffsetfrom.java
  88. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Tzoffsetto.java
  89. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Tzurl.java
  90. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Uid.java
  91. +14 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Url.java
  92. +20 −0 src/main/java/edu/itu/cavabunga/lib/entity/property/Version.java
  93. +11 −0 src/main/java/edu/itu/cavabunga/lib/exception/Conflict.java
  94. +11 −0 src/main/java/edu/itu/cavabunga/lib/exception/NotFound.java
  95. +7 −0 src/main/java/edu/itu/cavabunga/lib/exception/Validation.java
  96. +20 −0 src/main/java/edu/itu/cavabunga/lib/factory/ComponentFactory.java
  97. +19 −0 src/main/java/edu/itu/cavabunga/lib/factory/ComponentFactoryImpl.java
  98. +20 −0 src/main/java/edu/itu/cavabunga/lib/factory/ParameterFactory.java
  99. +20 −0 src/main/java/edu/itu/cavabunga/lib/factory/ParameterFactoryImpl.java
  100. +20 −0 src/main/java/edu/itu/cavabunga/lib/factory/ParticipantFactory.java
  101. +22 −0 src/main/java/edu/itu/cavabunga/lib/factory/ParticipantFactoryImpl.java
  102. +20 −0 src/main/java/edu/itu/cavabunga/lib/factory/PropertyFactory.java
  103. +22 −0 src/main/java/edu/itu/cavabunga/lib/factory/PropertyFactoryImpl.java
  104. +47 −0 src/main/java/edu/itu/cavabunga/lib/http/ComponentResponse.java
  105. +29 −0 src/main/java/edu/itu/cavabunga/lib/http/ErrorResponse.java
  106. +46 −0 src/main/java/edu/itu/cavabunga/lib/http/ParameterResponse.java
  107. +46 −0 src/main/java/edu/itu/cavabunga/lib/http/ParticipantResponse.java
  108. +46 −0 src/main/java/edu/itu/cavabunga/lib/http/PropertyResponse.java
  109. +32 −0 src/main/java/edu/itu/cavabunga/lib/http/Response.java
View
@@ -0,0 +1,4 @@
# cavabunga-lib
cavabunga-lib is a package that includes core object specifications for Cavabunga calendaring applications.
View
101 pom.xml
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.itu</groupId>
<artifactId>cavabunga-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cavabunga-lib</name>
<description>Cavabunga calendaring application core object library</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.tngtech.java/junit-dataprovider -->
<dependency>
<groupId>com.tngtech.junit.dataprovider</groupId>
<artifactId>junit4-dataprovider</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- JaCoCo configuration -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,146 @@
package edu.itu.cavabunga.lib.entity;
import com.fasterxml.jackson.annotation.*;
import edu.itu.cavabunga.lib.entity.component.*;
import edu.itu.cavabunga.lib.entity.property.PropertyType;
import edu.itu.cavabunga.lib.exception.Validation;
import lombok.Data;
import org.hibernate.annotations.DiscriminatorOptions;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorOptions(force=true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = Alarm.class, name = "Alarm"),
@JsonSubTypes.Type(value = Calendar.class, name = "Calendar"),
@JsonSubTypes.Type(value = Daylight.class, name = "Daylight"),
@JsonSubTypes.Type(value = Event.class, name = "Event"),
@JsonSubTypes.Type(value = Freebusy.class, name = "Freebusy"),
@JsonSubTypes.Type(value = Journal.class, name = "Journal"),
@JsonSubTypes.Type(value = Standard.class, name = "Standard"),
@JsonSubTypes.Type(value = Timezone.class, name = "Timezone"),
@JsonSubTypes.Type(value = Todo.class, name = "Todo")
})
@Data
public abstract class Component {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="owner_uuid")
@JsonBackReference(value = "participantAndComponent")
private Participant owner;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="parent_id")
@JsonBackReference
private Component parent;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
@JsonManagedReference
private List<Component> components = new ArrayList<>();
@OneToMany(mappedBy = "component", cascade = CascadeType.ALL)
@JsonManagedReference
private List<Property> properties = new ArrayList<>();
@CreatedDate
private Date creationDate;
public void addComponent(Component component){
component.setParent(this);
component.setOwner(this.owner);
components.add(component);
}
public void addProperty(Property property){
property.setComponent(this);
properties.add(property);
}
public void validate(){
if(!components.isEmpty()){
for (Component c : components){
try {
c.validate();
}catch (Exception e){
throw new Validation(this.getClass().getName() + " component's sub component validation failed: " + e.getMessage());
}
}
}
if(!properties.isEmpty()){
for(Property p : properties){
try {
p.validate();
}catch (Exception e){
throw new Validation(this.getClass().getName() + " component property validateion failed " + e.getMessage());
}
}
}
}
public void validateOptionalOneProperties(List<PropertyType> propertyTypeList){
Integer propertyCount = 0;
for(PropertyType pt : propertyTypeList){
for(Property p : properties){
if(p.getClass().getName().equals(pt.create().getClass().getName())){
propertyCount++;
}
if(propertyCount >= 2){
throw new Validation("Component validation failed in optional-one properties check: " + p.getClass().getName());
}
}
propertyCount = 0;
}
}
public void validateOptionalManyProperties(){
//
}
public void validateRequiredOneProperties(List<PropertyType> propertyTypeList){
Integer propertyCount = 0;
for(PropertyType pt : propertyTypeList){
for(Property p : properties){
if(p.getClass().getName().equals(pt.create().getClass().getName())){
propertyCount++;
}
}
if(propertyCount != 1){
throw new Validation("Component validation failed in required-one properties check. Count " + propertyCount + ": " + pt.create().getClass().getName());
}
propertyCount = 0;
}
}
public void validateReqiredManyProperties(List<PropertyType> propertyTypeList){
Integer propertyCount = 0;
for(PropertyType pt : propertyTypeList){
for(Property p : properties){
if(p.getClass().getName().equals(pt.create().getClass().getName())){
propertyCount++;
}
}
if(propertyCount == 0){
throw new Validation("Component validation failed in required-many properties check: " + pt.create().getClass().getName());
}
}
}
}
@@ -0,0 +1,62 @@
package edu.itu.cavabunga.lib.entity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import edu.itu.cavabunga.lib.entity.parameter.*;
import edu.itu.cavabunga.lib.exception.Validation;
import lombok.Data;
import org.hibernate.annotations.DiscriminatorOptions;
import javax.persistence.*;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorOptions(force=true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = Altrep.class, name = "Altrep"),
@JsonSubTypes.Type(value = Cn.class, name = "Cn"),
@JsonSubTypes.Type(value = Cutype.class, name = "Cutype"),
@JsonSubTypes.Type(value = DelegatedFrom.class, name = "DelegatedFrom"),
@JsonSubTypes.Type(value = DelegatedTo.class, name = "DelegatedTo"),
@JsonSubTypes.Type(value = Dir.class, name = "Dir"),
@JsonSubTypes.Type(value = Encoding.class, name = "Encoding"),
@JsonSubTypes.Type(value = Fbtype.class, name = "Fbtype"),
@JsonSubTypes.Type(value = Fmttype.class, name = "Fmttype"),
@JsonSubTypes.Type(value = Language.class, name = "Language"),
@JsonSubTypes.Type(value = Member.class, name = "Member"),
@JsonSubTypes.Type(value = Partstat.class, name = "Partstat"),
@JsonSubTypes.Type(value = Range.class, name = "Range"),
@JsonSubTypes.Type(value = Related.class, name = "Related"),
@JsonSubTypes.Type(value = Reltype.class, name = "Reltype"),
@JsonSubTypes.Type(value = Role.class, name = "Role"),
@JsonSubTypes.Type(value = Rsvp.class, name = "Rsvp"),
@JsonSubTypes.Type(value = SentBy.class, name = "SentBy"),
@JsonSubTypes.Type(value = Tzid.class, name = "Tzid"),
@JsonSubTypes.Type(value = Value.class, name = "Value")
})
@Data
public abstract class Parameter {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String value;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "property_id")
@JsonBackReference
private Property property;
public void validate(){
if((this.value == null) || (this.value.trim().isEmpty())){
throw new Validation(this.getClass().getName() + " parameter cannot be empty");
}
}
}
@@ -0,0 +1,56 @@
package edu.itu.cavabunga.lib.entity;
import com.fasterxml.jackson.annotation.*;
import edu.itu.cavabunga.lib.entity.participant.Group;
import edu.itu.cavabunga.lib.entity.participant.Resource;
import edu.itu.cavabunga.lib.entity.participant.User;
import lombok.Data;
import org.hibernate.annotations.DiscriminatorOptions;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
@EntityListeners(AuditingEntityListener.class)
@DiscriminatorOptions(force=true)
@JsonIgnoreProperties(ignoreUnknown = true, value= {"components"}) //TODO: participants with no component will give error while building JSON
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = User.class, name = "User"),
@JsonSubTypes.Type(value = Group.class, name = "Group"),
@JsonSubTypes.Type(value = Resource.class, name = "Resource"),
})
@Data
public abstract class Participant {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "user_name")
private String userName;
@Column(name = "creation_date")
@CreatedDate
private Date creationDate;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "owner")
@JsonManagedReference(value = "participantAndComponent")
@JsonIgnore
private List<Component> components = new ArrayList<>();
public Participant(){
}
public void validate(){
}
}
Oops, something went wrong.

0 comments on commit ca8150f

Please sign in to comment.