refactored worspace classes

This commit is contained in:
Massimiliano Assante 2022-05-04 11:26:41 +02:00
parent 0017e68b39
commit 2082216b0f
9 changed files with 99 additions and 99 deletions

View File

@ -1,28 +0,0 @@
package org.gcube.social_networking.socialnetworking.model.beans;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
/**
* The WorkspaceNotification super class
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
include = As.PROPERTY, property = "type") @JsonSubTypes({
@JsonSubTypes.Type(value = WorkspaceNotificationSharedFolder.class, name = "FOLDER_SHARE"),
@JsonSubTypes.Type(value = WorkspaceNotificationUnsharedFolder.class, name = "FOLDER_UNSHARE"),
@JsonSubTypes.Type(value = WorkspaceNotificationAddedItem.class, name = "ITEM_NEW")
})
public abstract class WorkspaceNotification {
protected final WorkspaceNotificationType TYPE;
WorkspaceNotification(WorkspaceNotificationType TYPE) {
this.TYPE = TYPE;
}
public WorkspaceNotificationType getType() {
return TYPE;
}
}

View File

@ -1,31 +0,0 @@
package org.gcube.social_networking.socialnetworking.model.beans;
public enum WorkspaceNotificationType {
/**
* use to notify a user she got a workspace item new in some of her workspace shared folder
*/
ITEM_NEW(WorkspaceNotificationAddedItem.class),
/**
* use to notify a user he got a workspace folder shared
*/
FOLDER_SHARE(WorkspaceNotificationSharedFolder.class),
/**
* use to notify a user he got a workspace folder Unshared
*/
FOLDER_UNSHARE(WorkspaceNotificationUnsharedFolder.class);
Class<? extends WorkspaceNotification> beanClass;
WorkspaceNotificationType(Class<? extends WorkspaceNotification> beanClass){
this.beanClass = beanClass;
}
public Class<? extends WorkspaceNotification> getNotificationClass(){
return this.beanClass;
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.social_networking.socialnetworking.model.beans;
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import javax.validation.constraints.NotNull;
@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("ITEM_NEW")
public class WorkspaceNotificationAddedItem extends WorkspaceNotification {
public class AddedItemEvent extends WorkspaceEvent {
/**
* the username of the user you wish to notify
*/
@ -18,15 +18,15 @@ public class WorkspaceNotificationAddedItem extends WorkspaceNotification {
@JsonProperty("fileItem")
@NotNull(message="fileItem cannot be missing")
private WorkspaceFileItemBean item;
private FileItemBean item;
public WorkspaceNotificationAddedItem() {
super(WorkspaceNotificationType.ITEM_NEW);
public AddedItemEvent() {
super(WorkspaceEventType.ITEM_NEW);
// TODO Auto-generated constructor stub
}
public WorkspaceNotificationAddedItem(String userIdToNotify, WorkspaceFileItemBean item) {
super(WorkspaceNotificationType.ITEM_NEW);
public AddedItemEvent(String userIdToNotify, FileItemBean item) {
super(WorkspaceEventType.ITEM_NEW);
this.userIdToNotify = userIdToNotify;
this.item = item;
}
@ -39,17 +39,17 @@ public class WorkspaceNotificationAddedItem extends WorkspaceNotification {
this.userIdToNotify = userIdToNotify;
}
public WorkspaceFileItemBean getItem() {
public FileItemBean getItem() {
return item;
}
public void setItem(WorkspaceFileItemBean item) {
public void setItem(FileItemBean item) {
this.item = item;
}
@Override
public String toString() {
return "WorkspaceNotificationAddedItem [userIdToNotify=" + userIdToNotify + ", item=" + item + "]";
return "AddedItemEvent [userIdToNotify=" + userIdToNotify + ", item=" + item + "]";
}

View File

@ -1,10 +1,10 @@
package org.gcube.social_networking.socialnetworking.model.beans;
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
public class WorkspaceFileItemBean {
public class FileItemBean {
@JsonProperty("id")
@NotNull
@ -24,13 +24,13 @@ public class WorkspaceFileItemBean {
@JsonProperty("parent")
@NotNull
private WorkspaceFolderBean parent;
private FolderBean parent;
public WorkspaceFileItemBean() {
public FileItemBean() {
super();
}
public WorkspaceFileItemBean(String id, String name, String title, String path, WorkspaceFolderBean parent) {
public FileItemBean(String id, String name, String title, String path, FolderBean parent) {
super();
this.id = id;
this.name = name;
@ -64,11 +64,11 @@ public class WorkspaceFileItemBean {
this.path = path;
}
public WorkspaceFolderBean getParent() {
public FolderBean getParent() {
return parent;
}
public void setParent(WorkspaceFolderBean parent) {
public void setParent(FolderBean parent) {
this.parent = parent;
}
@ -85,7 +85,7 @@ public class WorkspaceFileItemBean {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceFileItemBean [id=");
builder.append("FileItemBean [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);

View File

@ -1,11 +1,11 @@
package org.gcube.social_networking.socialnetworking.model.beans;
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
public class WorkspaceFolderBean {
public class FolderBean {
@ -37,12 +37,12 @@ public class WorkspaceFolderBean {
@NotNull
boolean vreFolder;
public WorkspaceFolderBean() {
public FolderBean() {
super();
// TODO Auto-generated constructor stub
}
public WorkspaceFolderBean(String id, String name, String title, String displayName, String path, String parentId, boolean vreFolder) {
public FolderBean(String id, String name, String title, String displayName, String path, String parentId, boolean vreFolder) {
super();
this.id = id;
this.name = name;
@ -118,7 +118,7 @@ public class WorkspaceFolderBean {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceFolderBean [id=");
builder.append("FolderBean [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);

View File

@ -1,4 +1,4 @@
package org.gcube.social_networking.socialnetworking.model.beans;
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import javax.validation.constraints.NotNull;
@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_SHARE")
public class WorkspaceNotificationSharedFolder extends WorkspaceNotification {
public class SharedFolderEvent extends WorkspaceEvent {
/**
* the username of the user you wish to notify
@ -20,15 +20,15 @@ public class WorkspaceNotificationSharedFolder extends WorkspaceNotification {
@JsonProperty("folderItem")
@NotNull(message="folderItem cannot be missing")
private WorkspaceFolderBean folder;
private FolderBean folder;
public WorkspaceNotificationSharedFolder() {
super(WorkspaceNotificationType.FOLDER_SHARE);
public SharedFolderEvent() {
super(WorkspaceEventType.FOLDER_SHARE);
}
public WorkspaceNotificationSharedFolder(String userIdToNotify, WorkspaceFolderBean folder) {
super(WorkspaceNotificationType.FOLDER_SHARE);
public SharedFolderEvent(String userIdToNotify, FolderBean folder) {
super(WorkspaceEventType.FOLDER_SHARE);
this.userIdToNotify = userIdToNotify;
this.folder = folder;
}
@ -41,16 +41,16 @@ public class WorkspaceNotificationSharedFolder extends WorkspaceNotification {
this.userIdToNotify = userIdToNotify;
}
public WorkspaceFolderBean getFolder() {
public FolderBean getFolder() {
return folder;
}
public void setFolder(WorkspaceFolderBean folder) {
public void setFolder(FolderBean folder) {
this.folder = folder;
}
@Override
public String toString() {
return "WorkspaceNotificationSharedFolder [userIdToNotify=" + userIdToNotify + ", folder=" + folder + "]";
return "SharedFolderEvent [userIdToNotify=" + userIdToNotify + ", folder=" + folder + "]";
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.social_networking.socialnetworking.model.beans;
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import javax.validation.constraints.NotNull;
@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_UNSHARE")
public class WorkspaceNotificationUnsharedFolder extends WorkspaceNotification {
public class UnsharedFolderEvent extends WorkspaceEvent {
/**
@ -27,13 +27,13 @@ public class WorkspaceNotificationUnsharedFolder extends WorkspaceNotification {
private String unsharedFolderName;
public WorkspaceNotificationUnsharedFolder() {
super(WorkspaceNotificationType.FOLDER_UNSHARE);
public UnsharedFolderEvent() {
super(WorkspaceEventType.FOLDER_UNSHARE);
// TODO Auto-generated constructor stub
}
public WorkspaceNotificationUnsharedFolder(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) {
super(WorkspaceNotificationType.FOLDER_UNSHARE);
public UnsharedFolderEvent(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) {
super(WorkspaceEventType.FOLDER_UNSHARE);
this.userIdToNotify = userIdToNotify;
this.unsharedFolderId = unsharedFolderId;
this.unsharedFolderName = unsharedFolderName;
@ -45,7 +45,7 @@ public class WorkspaceNotificationUnsharedFolder extends WorkspaceNotification {
@Override
public String toString() {
return "WorkspaceNotificationUnsharedFolder [userIdToNotify=" + userIdToNotify + ", unsharedFolderId="
return "UnsharedFolderEvent [userIdToNotify=" + userIdToNotify + ", unsharedFolderId="
+ unsharedFolderId + ", unsharedFolderName=" + unsharedFolderName + ", Type=" + TYPE + "]";
}

View File

@ -0,0 +1,28 @@
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
/**
* The WorkspaceEvent super class
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
include = As.PROPERTY, property = "type") @JsonSubTypes({
@JsonSubTypes.Type(value = SharedFolderEvent.class, name = "FOLDER_SHARE"),
@JsonSubTypes.Type(value = UnsharedFolderEvent.class, name = "FOLDER_UNSHARE"),
@JsonSubTypes.Type(value = AddedItemEvent.class, name = "ITEM_NEW")
})
public abstract class WorkspaceEvent {
protected final WorkspaceEventType TYPE;
WorkspaceEvent(WorkspaceEventType TYPE) {
this.TYPE = TYPE;
}
public WorkspaceEventType getType() {
return TYPE;
}
}

View File

@ -0,0 +1,31 @@
package org.gcube.social_networking.socialnetworking.model.beans.workspace;
public enum WorkspaceEventType {
/**
* use to notify a user she got a workspace item new in some of her workspace shared folder
*/
ITEM_NEW(AddedItemEvent.class),
/**
* use to notify a user he got a workspace folder shared
*/
FOLDER_SHARE(SharedFolderEvent.class),
/**
* use to notify a user he got a workspace folder Unshared
*/
FOLDER_UNSHARE(UnsharedFolderEvent.class);
Class<? extends WorkspaceEvent> beanClass;
WorkspaceEventType(Class<? extends WorkspaceEvent> beanClass){
this.beanClass = beanClass;
}
public Class<? extends WorkspaceEvent> getNotificationClass(){
return this.beanClass;
}
}