package com.dragonsoft.tryapp.sysinterface;

import com.dragonsoft.tryapp.common.AssignmentObj;
import com.dragonsoft.tryapp.common.ProcessMonitor;
import com.dragonsoft.tryapp.common.UserCredentials;

/**
 * An instance creates/edits/deletes assignments.
 * 
 * The constructor is private so that the number of instances may be 
 * managed. An instance should be obtain via the getInstance method.
 * 
 * The logic of how the calls are passed on to EJB instances should be 
 * contained here.
 */
public class AssignmentWorker {

    /**
     * Private constructor.
     */
    private AssignmentWorker() {

        // modify as needed
    }

    /**
     * Returns an instance. Called by an interface when it needs to 
     * do one or more create/edit/delete assignment operations.
     * 
     * @return    an instance if one is available
     */
    public static synchronized AssignmentWorker getInstance() {

        AssignmentWorker returnValue = new AssignmentWorker();

        // implement me as needed, but keep declaration the same

        return (returnValue);
    }

    /**
     * Called to create a new assignment.
     * 
     * @param    userCredentials    the user credentials
     * @param    assignment         the assignment to create
     * @param    processMonitor     this should not be a long operation, but 
     *                              in case something fails, this could be 
     *                              used to send back information
     */
    public void createAssignment(UserCredentials userCredentials,
            AssignmentObj assignment, ProcessMonitor processMonitor) {

        // implement me, call to EJB, etc
    }

    /**
     * Called to indicate that the properties of the given 
     * assignment have changed and should be updated in the rest of 
     * the system.
     * 
     * @param    userCredentials    the user credentials
     * @param    assignment         the assignment that was updated
     * @param    processMonitor     this should not be a long operation, but 
     *                              in case something fails, this could be 
     *                              used to send back information
     */
    public void editAssignment(UserCredentials userCredentials,
            AssignmentObj assignment, ProcessMonitor processMonitor) {

        // implement me, call to EJB, etc
    }

    /**
     * Called to indicate that the given assignment should be deleted 
     * (but not from the file system - archived).
     * 
     * @param    userCredentials    the user credentials
     * @param    assignmentID       the ID of the assignment to delete
     * @param    processMonitor     this should not be a long operation, but 
     *                              in case something fails, this could be 
     *                              used to send back information
     */
    public void deleteAssignment(UserCredentials userCredentials,
            String assignmentID, ProcessMonitor processMonitor) {

        // implement me, call to EJB, etc
    }

    /**
     * Should be called by the object that requested this instance, 
     * when that object is done, and just before the reference is removed.
     */
    public void referenceRemoved() {

        // implement me, add me back to pool of available workers
    }

} // AssignmentWorker