package com.libreecm.commonAPI.model;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class PermissionMapping extends LibreECMObject {

	String CAN_GET_DESCENDENTS_FOLDER = "canGetDescendents.Folder";
	String CAN_GET_CHILDREN_FOLDER = "canGetChildren.Folder";
	String CAN_GET_PARENTS_FOLDER = "canGetParents.Folder";
	String CAN_GET_FOLDER_PARENT_OBJECT = "canGetFolderParent.Object";
	String CAN_CREATE_DOCUMENT_FOLDER = "canCreateDocument.Folder";
	String CAN_CREATE_FOLDER_FOLDER = "canCreateFolder.Folder";
	String CAN_CREATE_POLICY_FOLDER = "canCreatePolicy.Folder";
	String CAN_CREATE_RELATIONSHIP_SOURCE = "canCreateRelationship.Source";
	String CAN_CREATE_RELATIONSHIP_TARGET = "canCreateRelationship.Target";
	String CAN_GET_PROPERTIES_OBJECT = "canGetProperties.Object";
	String CAN_VIEW_CONTENT_OBJECT = "canViewContent.Object";
	String CAN_UPDATE_PROPERTIES_OBJECT = "canUpdateProperties.Object";
	String CAN_MOVE_OBJECT = "canMove.Object";
	String CAN_MOVE_TARGET = "canMove.Target";
	String CAN_MOVE_SOURCE = "canMove.Source";
	String CAN_DELETE_OBJECT = "canDelete.Object";
	String CAN_DELETE_TREE_FOLDER = "canDeleteTree.Folder";
	String CAN_SET_CONTENT_DOCUMENT = "canSetContent.Document";
	String CAN_DELETE_CONTENT_DOCUMENT = "canDeleteContent.Document";
	String CAN_ADD_TO_FOLDER_OBJECT = "canAddToFolder.Object";
	String CAN_ADD_TO_FOLDER_FOLDER = "canAddToFolder.Folder";
	String CAN_REMOVE_FROM_FOLDER_OBJECT = "canRemoveFromFolder.Object";
	String CAN_REMOVE_FROM_FOLDER_FOLDER = "canRemoveFromFolder.Folder";
	String CAN_CHECKOUT_DOCUMENT = "canCheckout.Document";
	String CAN_CANCEL_CHECKOUT_DOCUMENT = "canCancelCheckout.Document";
	String CAN_CHECKIN_DOCUMENT = "canCheckin.Document";
	String CAN_GET_ALL_VERSIONS_VERSION_SERIES = "canGetAllVersions.VersionSeries";
	String CAN_GET_OBJECT_RELATIONSHIPS_OBJECT = "canGetObjectRelationships.Object";
	String CAN_ADD_POLICY_OBJECT = "canAddPolicy.Object";
	String CAN_ADD_POLICY_POLICY = "canAddPolicy.Policy";
	String CAN_REMOVE_POLICY_OBJECT = "canRemovePolicy.Object";
	String CAN_REMOVE_POLICY_POLICY = "canRemovePolicy.Policy";
	String CAN_GET_APPLIED_POLICIES_OBJECT = "canGetAppliedPolicies.Object";
	String CAN_GET_ACL_OBJECT = "canGetACL.Object";
	String CAN_APPLY_ACL_OBJECT = "canApplyACL.Object";
	
	
	public static HashMap<String,String> getPermissionActions(){
		HashMap<String,String> map = new HashMap<>();
		map.put("CAN_GET_DESCENDENTS_FOLDER", "canGetDescendents.Folder");
		map.put("CAN_GET_CHILDREN_FOLDER", "canGetChildren.Folder");
		map.put("CAN_GET_PARENTS_FOLDER", "canGetParents.Folder");
		map.put("CAN_GET_FOLDER_PARENT_OBJECT", "canGetFolderParent.Object");
		map.put("CAN_CREATE_DOCUMENT_FOLDER", "canCreateDocument.Folder");
		map.put("CAN_CREATE_FOLDER_FOLDER", "canCreateFolder.Folder");
		map.put("CAN_CREATE_POLICY_FOLDER", "canCreatePolicy.Folder");
		map.put("CAN_CREATE_RELATIONSHIP_SOURCE", "canCreateRelationship.Source");
		map.put("CAN_CREATE_RELATIONSHIP_TARGET", "canCreateRelationship.Target");
		map.put("CAN_GET_PROPERTIES_OBJECT", "canGetProperties.Object");
		map.put("CAN_VIEW_CONTENT_OBJECT", "canViewContent.Object");
		map.put("CAN_UPDATE_PROPERTIES_OBJECT", "canUpdateProperties.Object");
		map.put("CAN_MOVE_OBJECT", "canMove.Object");
		map.put("CAN_MOVE_TARGET", "canMove.Target");
		map.put("CAN_MOVE_SOURCE", "canMove.Source");
		map.put("CAN_DELETE_OBJECT", "canDelete.Object");
		map.put("CAN_DELETE_TREE_FOLDER", "canDeleteTree.Folder");
		map.put("CAN_SET_CONTENT_DOCUMENT", "canSetContent.Document");
		map.put("CAN_DELETE_CONTENT_DOCUMENT", "canDeleteContent.Document");
		map.put("CAN_ADD_TO_FOLDER_OBJECT", "canAddToFolder.Object");
		map.put("CAN_ADD_TO_FOLDER_FOLDER", "canAddToFolder.Folder");
		map.put("CAN_REMOVE_FROM_FOLDER_OBJECT", "canRemoveFromFolder.Object");
		map.put("CAN_REMOVE_FROM_FOLDER_FOLDER", "canRemoveFromFolder.Folder");
		map.put("CAN_CHECKOUT_DOCUMENT", "canCheckout.Document");
		map.put("CAN_CANCEL_CHECKOUT_DOCUMENT", "canCancelCheckout.Document");
		map.put("CAN_CHECKIN_DOCUMENT", "canCheckin.Document");
		map.put("CAN_GET_ALL_VERSIONS_VERSION_SERIES", "canGetAllVersions.VersionSeries");
		map.put("CAN_GET_OBJECT_RELATIONSHIPS_OBJECT", "canGetObjectRelationships.Object");
		map.put("CAN_ADD_POLICY_OBJECT", "canAddPolicy.Object");
		map.put("CAN_ADD_POLICY_POLICY", "canAddPolicy.Policy");
		map.put("CAN_REMOVE_POLICY_OBJECT", "canRemovePolicy.Object");
		map.put("CAN_REMOVE_POLICY_POLICY", "canRemovePolicy.Policy");
		map.put("CAN_GET_APPLIED_POLICIES_OBJECT", "canGetAppliedPolicies.Object");
		map.put("CAN_GET_ACL_OBJECT", "canGetACL.Object");
		map.put("CAN_APPLY_ACL_OBJECT", "canApplyACL.Object");
		return map;
	}
	/** 
	 * 
	 */
	private static final long serialVersionUID = 6066353858545354499L;

	private Integer id;

	private List<CmisExtensionElement> extensions;

	private List<String> permissions;

	private String key;

	public PermissionMapping()  {
	}

	public PermissionMapping(List<CmisExtensionElement> extensions, List<String> permissions, String key) {
		super();
		this.extensions = extensions;
		this.permissions = permissions;
		this.key = key;
		this.id = 0;
	}

	public List<CmisExtensionElement> getExtensions() {
		if (this.extensions == null) {
			this.extensions = new ArrayList<CmisExtensionElement>();
		}
		return (this.extensions);
	}

	public void setExtensions(List<CmisExtensionElement> arg0) {
		this.extensions = arg0;
	}

	public String getId() {
		if (id == null) {
			return null;
		}
		return id.toString();
	}

	public void setId(String id) {
		this.id = Integer.parseInt(id);
	}

	public void setPermissions(List<String> permissions) {
		this.permissions = permissions;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getKey() {
		return key;
	}

	public List<String> getPermissions() {
		return permissions;
	}

}
