package performa.orm;

import oneit.logging.LoggingArea;
import oneit.objstore.*;
import oneit.utils.*;


public class CompanyUser extends BaseCompanyUser
{
    private static final long serialVersionUID = 0L;
        
    public  static LoggingArea  LOG = LoggingArea.createLoggingArea("CompanyUser");

    // This constructor should not be called
    public CompanyUser ()
    {
        // Do not add any code to this, always put it in initialiseNewObject
    }
    
    
    public static CompanyUser getCompanyUserForForgotPassword(ObjectTransaction transaction, String userIDStr, String code)
    {
        userIDStr   =   StringUtils.subBlanks(userIDStr);
        code        =   StringUtils.subBlanks(code);
        
        if(userIDStr != null && code!=null)
        {
            CompanyUser companyUser =   CompanyUser.getCompanyUserByID(transaction, Long.parseLong(userIDStr));
                        
            if(companyUser != null && CollectionUtils.equals(companyUser.getForgotPasswordKey(), code))
            {
                return companyUser;
            }
        }
        
        return null;
    }

    
    @Override
    public String getToString() 
    {
        return getUser().getName();
    }
}