-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement Category API - MEED-7944 - Meeds-io/MIPs#170
- Loading branch information
Showing
27 changed files
with
2,175 additions
and
142 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
component/api/src/main/java/io/meeds/social/category/model/Category.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.social.category.model; | ||
|
||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Category implements Cloneable { | ||
|
||
/** | ||
* Technical identifier of the element | ||
*/ | ||
private long id; | ||
|
||
/** | ||
* Parent Tree identifier, 0 when it's the root element | ||
*/ | ||
private long parentId; | ||
|
||
/** | ||
* The designation of the category, null when no user locale is chosen, else | ||
* it will depends from user Locale | ||
*/ | ||
private String name; | ||
|
||
/** | ||
* Fontawesome Icon identifier | ||
*/ | ||
private String icon; | ||
|
||
/** | ||
* Identity Id of the category creator | ||
*/ | ||
private long creatorId; | ||
|
||
/** | ||
* Identity Id of the owner of the tree (Owner Id who can manage the tree) | ||
*/ | ||
private long ownerId; | ||
|
||
/** | ||
* Access Permissions of the category | ||
*/ | ||
private List<Long> accessPermissionIds; | ||
|
||
/** | ||
* Link/Use Permissions of the category | ||
*/ | ||
private List<Long> linkPermissionIds; | ||
|
||
@Override | ||
protected Category clone() { // NOSONAR | ||
return new Category(id, | ||
parentId, | ||
name, | ||
icon, | ||
creatorId, | ||
ownerId, | ||
accessPermissionIds, | ||
linkPermissionIds); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
component/api/src/main/java/io/meeds/social/category/model/CategoryFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.social.category.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CategoryFilter { | ||
|
||
private long ownerId; | ||
|
||
private long parentId; | ||
|
||
private long depth; | ||
|
||
private long offset; | ||
|
||
private long limit; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
component/api/src/main/java/io/meeds/social/category/model/CategoryObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.social.category.model; | ||
|
||
import org.exoplatform.social.metadata.model.MetadataObject; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@EqualsAndHashCode(callSuper = true) | ||
public class CategoryObject extends MetadataObject { | ||
|
||
public CategoryObject(String type, String id, long spaceId) { | ||
super(type, id, null, spaceId); | ||
} | ||
|
||
public CategoryObject(String type, String id, String parentObjectId, long spaceId) { | ||
super(type, id, parentObjectId, spaceId); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
component/api/src/main/java/io/meeds/social/category/model/CategorySearchFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.social.category.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CategorySearchFilter implements Cloneable { | ||
|
||
private String term; | ||
|
||
private long ownerId; | ||
|
||
private long parentId; | ||
|
||
private long offset; | ||
|
||
private long limit; | ||
|
||
private boolean linkPermission; | ||
|
||
@Override | ||
public CategorySearchFilter clone() { // NOSONAR | ||
return new CategorySearchFilter(term, | ||
ownerId, | ||
parentId, | ||
offset, | ||
limit, | ||
linkPermission); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
component/api/src/main/java/io/meeds/social/category/model/CategoryTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.social.category.model; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@EqualsAndHashCode(callSuper = true) | ||
public class CategoryTree extends Category { | ||
|
||
private List<CategoryTree> categories; | ||
|
||
public CategoryTree(Category category) { | ||
super(category.getId(), | ||
category.getParentId(), | ||
category.getName(), | ||
category.getIcon(), | ||
category.getCreatorId(), | ||
category.getOwnerId(), | ||
category.getAccessPermissionIds(), | ||
category.getLinkPermissionIds()); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
component/api/src/main/java/io/meeds/social/category/plugin/CategoryPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.social.category.plugin; | ||
|
||
public interface CategoryPlugin { | ||
|
||
/** | ||
* @return The managed Object Type (Space, Activity...) | ||
**/ | ||
public String getType(); | ||
|
||
/** | ||
* Checks whether an associated object to a category is accessible to a user. | ||
* This check will be called after checking whether the user can access or not | ||
* to the category an object (generic ACL check made in Category API switch | ||
* Category properties) | ||
* | ||
* @id Object technical identifier | ||
* @username User technical name (login identifier) | ||
* @return true if the user has access permission to the designated Object | ||
* Type | ||
**/ | ||
public boolean canAccess(String objectId, String username); | ||
|
||
/** | ||
* Checks whether an associated object to a category is editable to a user. | ||
* This check will be used mainly used to know if a user can modify the object | ||
* in order to associate/link a category into it. This check will be called | ||
* after checking whether the user can link or not to the category an object | ||
* (generic ACL check made in Category API switch Category properties) | ||
* | ||
* @id Object technical identifier | ||
* @username User technical name (login identifier) | ||
* @return true if the user has access permission to the designated Object | ||
* Type identified by its Id | ||
**/ | ||
public boolean canEdit(String objectId, String username); | ||
|
||
} |
Oops, something went wrong.