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

org.nakedobjects.example.expenses.claims.ClaimRepositoryAbstract Maven / Gradle / Ivy

package org.nakedobjects.example.expenses.claims;

import java.util.List;

import org.nakedobjects.applib.AbstractFactoryAndRepository;
import org.nakedobjects.applib.annotation.Debug;
import org.nakedobjects.applib.annotation.Exploration;
import org.nakedobjects.applib.annotation.Hidden;
import org.nakedobjects.example.expenses.employee.Employee;


public abstract class ClaimRepositoryAbstract extends AbstractFactoryAndRepository implements ClaimRepository {

    @Debug
    public List listAllCodes() {
        return (List) allInstances(ProjectCode.class, INCLUDING_SUBCLASSES);
    }

    @Exploration
    public List allClaims() {
        return allInstances(Claim.class, INCLUDING_SUBCLASSES);
    }

    @Hidden
    public boolean descriptionIsUniqueForClaimant(final Employee employee, final String initialDescription) {
        Claim claimPattern = newTransientInstance(Claim.class);
        claimPattern.setClaimant(employee);
        claimPattern.setDescription(initialDescription);
        claimPattern.setDateCreated(null);
        claimPattern.setStatus(null);
        List allClaims = allMatches(Claim.class, claimPattern, EXCLUDING_SUBCLASSES);
        return allClaims.size() == 0;
    }

    @Hidden
    public ClaimStatus findClaimStatus(String title) {
        return uniqueMatch(ClaimStatus.class, title, EXCLUDING_SUBCLASSES);
    }

    @Hidden
    public ExpenseItemStatus findExpenseItemStatus(String title) {
        return uniqueMatch(ExpenseItemStatus.class, title, EXCLUDING_SUBCLASSES);
    }

    @Hidden
    public List findExpenseItemsLike(final ExpenseItem item) {
        // Simple implementation: could be extended to compare any fields that have already been set on the
        // item provided.
        return findExpenseItemsOfType(item.getClaim().getClaimant(), item.getExpenseType());
    }

    @Hidden
    public abstract List findExpenseItemsOfType(final Employee employee, final ExpenseType type);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy