code: public ResourceAssignment addResourceAssignment(Resource resource)
     {
        ResourceAssignment assignment = getExistingResourceAssignment(resource);
  
        if (assignment == null)
        {
           assignment = new ResourceAssignment(getParentFile(), this);
           m_assignments.add(assignment);
           getParentFile().getResourceAssignments().add(assignment);
  
           assignment.setTaskUniqueID(getUniqueID());
           assignment.setWork(getDuration());
           assignment.setUnits(ResourceAssignment.DEFAULT_UNITS);
  
           if (resource != null)
           {
              assignment.setResourceUniqueID(resource.getUniqueID());
              resource.addResourceAssignment(assignment);
           }
        }
  
        return (assignment);
     }
docs: This method allows a resource assignment to be added to the
  current task.
  
  @param resource the resource to assign
  @return ResourceAssignment object