All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nakedobjects.example.expenses.employee.EmployeeRepositoryAbstract Maven / Gradle / Ivy

The newest version!
package org.nakedobjects.example.expenses.employee;

import java.util.List;

import org.nakedobjects.applib.AbstractFactoryAndRepository;
import org.nakedobjects.applib.annotation.Debug;
import org.nakedobjects.applib.annotation.Executed;
import org.nakedobjects.applib.annotation.Hidden;
import org.nakedobjects.example.expenses.services.UserFinder;



public abstract class EmployeeRepositoryAbstract extends AbstractFactoryAndRepository implements EmployeeRepository, UserFinder {
    public String iconName() {
        return "Employee";
    }

    @Debug
    public List allEmployees() {
        return allInstances(Employee.class, INCLUDING_SUBCLASSES);
    }

    private Employee findEmployeeForUserName(final String userName) {
        Employee pattern = newTransientInstance(Employee.class);
        pattern.setUserName(userName);
        return firstMatch(Employee.class, pattern, EXCLUDING_SUBCLASSES);
    }

    @Hidden
    public List findEmployeeByName(final String name) {
        return allMatches(Employee.class, name, EXCLUDING_SUBCLASSES);
    }

    // {{ User Finder
    // private Employee currentUser;

    @Executed(Executed.Where.LOCALLY)
    public Object currentUserAsObject() {
        // if (currentUser == null) {
        // String userName = getUser().getName();
        // currentUser = findEmployeeForUserName(userName);
        // }
        return findEmployeeForUserName(getUser().getName());
    }

    // }}

    @Executed(Executed.Where.LOCALLY)
    @Hidden
    public Employee me() {
        return (Employee) currentUserAsObject();
    }

   

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy