Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement Category API - MEED-7944 - Meeds-io/MIPs#170 #4273

Draft
wants to merge 1 commit into
base: feature/whitepaper
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
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;

}
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);
}

}
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);
}
}
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());
}

}
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);

}
Loading
Loading