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; import javax.validation.constraints.NotNull;
@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("ITEM_NEW") @JsonTypeName("ITEM_NEW")
public class WorkspaceNotificationAddedItem extends WorkspaceNotification { public class AddedItemEvent extends WorkspaceEvent {
/** /**
* the username of the user you wish to notify * the username of the user you wish to notify
*/ */
@ -18,15 +18,15 @@ public class WorkspaceNotificationAddedItem extends WorkspaceNotification {
@JsonProperty("fileItem") @JsonProperty("fileItem")
@NotNull(message="fileItem cannot be missing") @NotNull(message="fileItem cannot be missing")
private WorkspaceFileItemBean item; private FileItemBean item;
public WorkspaceNotificationAddedItem() { public AddedItemEvent() {
super(WorkspaceNotificationType.ITEM_NEW); super(WorkspaceEventType.ITEM_NEW);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public WorkspaceNotificationAddedItem(String userIdToNotify, WorkspaceFileItemBean item) { public AddedItemEvent(String userIdToNotify, FileItemBean item) {
super(WorkspaceNotificationType.ITEM_NEW); super(WorkspaceEventType.ITEM_NEW);
this.userIdToNotify = userIdToNotify; this.userIdToNotify = userIdToNotify;
this.item = item; this.item = item;
} }
@ -39,17 +39,17 @@ public class WorkspaceNotificationAddedItem extends WorkspaceNotification {
this.userIdToNotify = userIdToNotify; this.userIdToNotify = userIdToNotify;
} }
public WorkspaceFileItemBean getItem() { public FileItemBean getItem() {
return item; return item;
} }
public void setItem(WorkspaceFileItemBean item) { public void setItem(FileItemBean item) {
this.item = item; this.item = item;
} }
@Override @Override
public String toString() { 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 javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
public class WorkspaceFileItemBean { public class FileItemBean {
@JsonProperty("id") @JsonProperty("id")
@NotNull @NotNull
@ -24,13 +24,13 @@ public class WorkspaceFileItemBean {
@JsonProperty("parent") @JsonProperty("parent")
@NotNull @NotNull
private WorkspaceFolderBean parent; private FolderBean parent;
public WorkspaceFileItemBean() { public FileItemBean() {
super(); 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(); super();
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -64,11 +64,11 @@ public class WorkspaceFileItemBean {
this.path = path; this.path = path;
} }
public WorkspaceFolderBean getParent() { public FolderBean getParent() {
return parent; return parent;
} }
public void setParent(WorkspaceFolderBean parent) { public void setParent(FolderBean parent) {
this.parent = parent; this.parent = parent;
} }
@ -85,7 +85,7 @@ public class WorkspaceFileItemBean {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("WorkspaceFileItemBean [id="); builder.append("FileItemBean [id=");
builder.append(id); builder.append(id);
builder.append(", name="); builder.append(", name=");
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 javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
public class WorkspaceFolderBean { public class FolderBean {
@ -37,12 +37,12 @@ public class WorkspaceFolderBean {
@NotNull @NotNull
boolean vreFolder; boolean vreFolder;
public WorkspaceFolderBean() { public FolderBean() {
super(); super();
// TODO Auto-generated constructor stub // 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(); super();
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -118,7 +118,7 @@ public class WorkspaceFolderBean {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("WorkspaceFolderBean [id="); builder.append("FolderBean [id=");
builder.append(id); builder.append(id);
builder.append(", name="); builder.append(", name=");
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; import javax.validation.constraints.NotNull;
@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_SHARE") @JsonTypeName("FOLDER_SHARE")
public class WorkspaceNotificationSharedFolder extends WorkspaceNotification { public class SharedFolderEvent extends WorkspaceEvent {
/** /**
* the username of the user you wish to notify * the username of the user you wish to notify
@ -20,15 +20,15 @@ public class WorkspaceNotificationSharedFolder extends WorkspaceNotification {
@JsonProperty("folderItem") @JsonProperty("folderItem")
@NotNull(message="folderItem cannot be missing") @NotNull(message="folderItem cannot be missing")
private WorkspaceFolderBean folder; private FolderBean folder;
public WorkspaceNotificationSharedFolder() { public SharedFolderEvent() {
super(WorkspaceNotificationType.FOLDER_SHARE); super(WorkspaceEventType.FOLDER_SHARE);
} }
public WorkspaceNotificationSharedFolder(String userIdToNotify, WorkspaceFolderBean folder) { public SharedFolderEvent(String userIdToNotify, FolderBean folder) {
super(WorkspaceNotificationType.FOLDER_SHARE); super(WorkspaceEventType.FOLDER_SHARE);
this.userIdToNotify = userIdToNotify; this.userIdToNotify = userIdToNotify;
this.folder = folder; this.folder = folder;
} }
@ -41,16 +41,16 @@ public class WorkspaceNotificationSharedFolder extends WorkspaceNotification {
this.userIdToNotify = userIdToNotify; this.userIdToNotify = userIdToNotify;
} }
public WorkspaceFolderBean getFolder() { public FolderBean getFolder() {
return folder; return folder;
} }
public void setFolder(WorkspaceFolderBean folder) { public void setFolder(FolderBean folder) {
this.folder = folder; this.folder = folder;
} }
@Override @Override
public String toString() { 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; import javax.validation.constraints.NotNull;
@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeName("FOLDER_UNSHARE") @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; private String unsharedFolderName;
public WorkspaceNotificationUnsharedFolder() { public UnsharedFolderEvent() {
super(WorkspaceNotificationType.FOLDER_UNSHARE); super(WorkspaceEventType.FOLDER_UNSHARE);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public WorkspaceNotificationUnsharedFolder(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) { public UnsharedFolderEvent(String userIdToNotify, String unsharedFolderId, String unsharedFolderName) {
super(WorkspaceNotificationType.FOLDER_UNSHARE); super(WorkspaceEventType.FOLDER_UNSHARE);
this.userIdToNotify = userIdToNotify; this.userIdToNotify = userIdToNotify;
this.unsharedFolderId = unsharedFolderId; this.unsharedFolderId = unsharedFolderId;
this.unsharedFolderName = unsharedFolderName; this.unsharedFolderName = unsharedFolderName;
@ -45,7 +45,7 @@ public class WorkspaceNotificationUnsharedFolder extends WorkspaceNotification {
@Override @Override
public String toString() { public String toString() {
return "WorkspaceNotificationUnsharedFolder [userIdToNotify=" + userIdToNotify + ", unsharedFolderId=" return "UnsharedFolderEvent [userIdToNotify=" + userIdToNotify + ", unsharedFolderId="
+ unsharedFolderId + ", unsharedFolderName=" + unsharedFolderName + ", Type=" + TYPE + "]"; + 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;
}
}