package com.microstar.tap3.common;

public class Permissions {

	public enum Control {
		PROCESS_KMPI,
		PROCESS_ADJFEES,
		PROCESS_SENDTOGP,
		PROCESS_GENINVOICES,
		PROCESS_MBA,
		CONTACTS,
		INVENTORY,
		USERS,
		COLLARS,
		ORDERS,
		SHIPMENTS,
		SHIPMENTS_BULKIMPORT,
		SHIPMENTS_APPROVE,
		SHIPMENTS_CORRECTIONS,
		CUSTOMER,
		CUSTOMER_PROJECTIONS,
		CUSTOMER_NOTES,
		CUSTOMER_NOTIFICATIONS,
		CUSTOMER_CONTRACTS,
		CUSTOMER_RELATIONSHIPS,
		CUSTOMER_ADDRESSES
	}
	
	public enum Access {
		N ("None"),
		R ("Read Only"),
		W ("Write"),
		E ("Execute");
		
		private String description;
		
		Access(String description)
		{
			this.setDescription(description);
		}

		public String getDescription() {
			return description;
		}

		public void setDescription(String description) {
			this.description = description;
		}
	}
	
	public static boolean isAuthorized(Control control, Access access, String permissionString)
	{
		boolean ret = false;
		
		String permToCheckString = control.toString() + ":" + access.name();
		
		ret = permissionString.contains(permToCheckString);
		
		return ret;
	}
}
