FileDocCategorySizeDatePackage
Rules.javaAPI DocExample2098Tue Jun 08 11:26:42 BST 2004com.mycompany.expense

Rules

public class Rules extends Object
This class contains methods encoding the rules for how a report in the sample expense report application may be handled by the current user.
author
Hans Bergsten, Gefion Software
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public booleancanAccept(java.lang.String user, boolean isManager, Report report)
Returns "true" if the user is a manager and the report is "submitted".

	return isManager && report.getStatus() == Report.STATUS_SUBMITTED;
    
public booleancanDelete(java.lang.String user, boolean isManager, Report report)
Returns "true" if the user is the report owner and the report isn't locked.

	return report.getOwner().equals(user) && !isLocked(report);
    
public booleancanEdit(java.lang.String user, boolean isManager, Report report)
Returns "true" if the user is the report owner and the report isn't locked.

	return report.getOwner().equals(user) && !isLocked(report);
    
public booleancanReject(java.lang.String user, boolean isManager, Report report)
Returns "true" if the user is a manager and the report is "submitted".

	return isManager && report.getStatus() == Report.STATUS_SUBMITTED;
    
public booleancanSubmit(java.lang.String user, boolean isManager, Report report)
Returns "true" if the user is the report owner and the report isn't locked.

	return report.getOwner().equals(user) && !isLocked(report);
    
public booleancanView(java.lang.String user, boolean isManager, Report report)
Returns "true" if the user is a manager or the report owner.

	return isManager || report.getOwner().equals(user);
    
public booleanisLocked(Report report)
Returns "true" if the report is either "submitted" or "accepted".

	return report.getStatus() == Report.STATUS_SUBMITTED ||
	    report.getStatus() == Report.STATUS_ACCEPTED;