/*==========================================================================*\ | _Submission.java |*-------------------------------------------------------------------------*| | Created by eogenerator | DO NOT EDIT. Make changes to Submission.java instead. |*-------------------------------------------------------------------------*| | Copyright (C) 2006-2012 Virginia Tech | | This file is part of Web-CAT. | | Web-CAT is free software; you can redistribute it and/or modify | it under the terms of the GNU Affero General Public License as published | by the Free Software Foundation; either version 3 of the License, or | (at your option) any later version. | | Web-CAT is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General Public License for more details. | | You should have received a copy of the GNU Affero General Public License | along with Web-CAT; if not, see <http://www.gnu.org/licenses/>. \*==========================================================================*/ package org.webcat.grader; import com.webobjects.eoaccess.*; import com.webobjects.eocontrol.*; import com.webobjects.foundation.*; import er.extensions.eof.ERXEOControlUtilities; import er.extensions.eof.ERXKey; import org.apache.log4j.Logger; import org.webcat.core.EOBasedKeyGenerator; import org.webcat.woextensions.WCFetchSpecification; // ------------------------------------------------------------------------- /** * An automatically generated EOGenericRecord subclass. DO NOT EDIT. * To change, use EOModeler, or make additions in * Submission.java. * * @author Generated by eogenerator * @version version suppressed to control auto-generation */ public abstract class _Submission extends org.webcat.core.EOBase implements org.webcat.core.MigratoryAttributeOwner { //~ Constructors .......................................................... // ---------------------------------------------------------- /** * Creates a new _Submission object. */ public _Submission() { super(); } // ---------------------------------------------------------- /** * A static factory method for creating a new * Submission object given required * attributes and relationships. * @param editingContext The context in which the new object will be * inserted * @param partnerLinkValue * @return The newly created object */ public static Submission create( EOEditingContext editingContext, boolean partnerLinkValue ) { Submission eoObject = (Submission) EOUtilities.createAndInsertInstance( editingContext, _Submission.ENTITY_NAME); eoObject.setPartnerLink(partnerLinkValue); return eoObject; } // ---------------------------------------------------------- /** * Get a local instance of the given object in another editing context. * @param editingContext The target editing context * @param eo The object to import * @return An instance of the given object in the target editing context */ public static Submission localInstance( EOEditingContext editingContext, Submission eo) { return (eo == null) ? null : (Submission)EOUtilities.localInstanceOfObject( editingContext, eo); } // ---------------------------------------------------------- /** * Look up an object by id number. Assumes the editing * context is appropriately locked. * @param ec The editing context to use * @param id The id to look up * @return The object, or null if no such id exists */ public static Submission forId( EOEditingContext ec, int id) { Submission obj = null; if (id > 0) { NSArray<Submission> objects = objectsMatchingValues(ec, "id", new Integer(id)); if (objects != null && objects.count() > 0) { obj = objects.objectAtIndex(0); } } return obj; } // ---------------------------------------------------------- /** * Look up an object by id number. Assumes the editing * context is appropriately locked. * @param ec The editing context to use * @param id The id to look up * @return The object, or null if no such id exists */ public static Submission forId( EOEditingContext ec, String id) { return forId(ec, er.extensions.foundation.ERXValueUtilities.intValue(id)); } //~ Constants (for key names) ............................................. // Attributes --- public static final String FILE_NAME_KEY = "fileName"; public static final ERXKey<String> fileName = new ERXKey<String>(FILE_NAME_KEY); public static final String IS_SUBMISSION_FOR_GRADING_KEY = "isSubmissionForGrading"; public static final ERXKey<Integer> isSubmissionForGrading = new ERXKey<Integer>(IS_SUBMISSION_FOR_GRADING_KEY); public static final String PARTNER_LINK_KEY = "partnerLink"; public static final ERXKey<Integer> partnerLink = new ERXKey<Integer>(PARTNER_LINK_KEY); public static final String SUBMIT_NUMBER_KEY = "submitNumber"; public static final ERXKey<Integer> submitNumber = new ERXKey<Integer>(SUBMIT_NUMBER_KEY); public static final String SUBMIT_TIME_KEY = "submitTime"; public static final ERXKey<NSTimestamp> submitTime = new ERXKey<NSTimestamp>(SUBMIT_TIME_KEY); // To-one relationships --- public static final String ASSIGNMENT_OFFERING_KEY = "assignmentOffering"; public static final ERXKey<org.webcat.grader.AssignmentOffering> assignmentOffering = new ERXKey<org.webcat.grader.AssignmentOffering>(ASSIGNMENT_OFFERING_KEY); public static final String PRIMARY_SUBMISSION_KEY = "primarySubmission"; public static final ERXKey<org.webcat.grader.Submission> primarySubmission = new ERXKey<org.webcat.grader.Submission>(PRIMARY_SUBMISSION_KEY); public static final String RESULT_KEY = "result"; public static final ERXKey<org.webcat.grader.SubmissionResult> result = new ERXKey<org.webcat.grader.SubmissionResult>(RESULT_KEY); public static final String USER_KEY = "user"; public static final ERXKey<org.webcat.core.User> user = new ERXKey<org.webcat.core.User>(USER_KEY); // To-many relationships --- public static final String ENQUEUED_JOBS_KEY = "enqueuedJobs"; public static final ERXKey<org.webcat.grader.EnqueuedJob> enqueuedJobs = new ERXKey<org.webcat.grader.EnqueuedJob>(ENQUEUED_JOBS_KEY); public static final String GRADER_PREFS_KEY = "graderPrefs"; public static final ERXKey<org.webcat.grader.GraderPrefs> graderPrefs = new ERXKey<org.webcat.grader.GraderPrefs>(GRADER_PREFS_KEY); public static final String PARTNERED_SUBMISSIONS_KEY = "partneredSubmissions"; public static final ERXKey<org.webcat.grader.Submission> partneredSubmissions = new ERXKey<org.webcat.grader.Submission>(PARTNERED_SUBMISSIONS_KEY); // Fetch specifications --- public static final String EARLIEST_SUBMISSION_FOR_ASSIGNMENT_OFFERING_AND_USER_FSPEC = "earliestSubmissionForAssignmentOfferingAndUser"; public static final String EARLIEST_SUBMISSION_FOR_COURSE_OFFERING_FSPEC = "earliestSubmissionForCourseOffering"; public static final String LATEST_SUBMISSION_FOR_ASSIGNMENT_AND_USER_FSPEC = "latestSubmissionForAssignmentAndUser"; public static final String LATEST_SUBMISSION_FOR_ASSIGNMENT_OFFERING_AND_USER_FSPEC = "latestSubmissionForAssignmentOfferingAndUser"; public static final String LATEST_SUBMISSION_FOR_COURSE_OFFERING_FSPEC = "latestSubmissionForCourseOffering"; public static final String SPECIFIC_SUBMISSION_FSPEC = "specificSubmission"; public static final String SUBMISSIONS_FOR_ASSIGNMENT_AND_USER_DESCENDING_FSPEC = "submissionsForAssignmentAndUserDescending"; public static final String SUBMISSIONS_FOR_ASSIGNMENT_OFFERING_AND_USER_FSPEC = "submissionsForAssignmentOfferingAndUser"; public static final String SUBMISSIONS_FOR_ASSIGNMENT_OFFERING_AND_USER_DESCENDING_FSPEC = "submissionsForAssignmentOfferingAndUserDescending"; public static final String SUBMISSIONS_FOR_GRADING_FSPEC = "submissionsForGrading"; public static final String SUBMISSIONS_WITH_FEEDBACK_FSPEC = "submissionsWithFeedback"; public static final String ENTITY_NAME = "Submission"; public transient final EOBasedKeyGenerator generateKey = new EOBasedKeyGenerator(this); //~ Methods ............................................................... // ---------------------------------------------------------- /** * Get a local instance of this object in another editing context. * @param editingContext The target editing context * @return An instance of this object in the target editing context */ public Submission localInstance(EOEditingContext editingContext) { return (Submission)EOUtilities.localInstanceOfObject( editingContext, this); } // ---------------------------------------------------------- /** * Get a list of changes between this object's current state and the * last committed version. * @return a dictionary of the changes that have not yet been committed */ @SuppressWarnings("unchecked") public NSDictionary<String, Object> changedProperties() { return changesFromSnapshot( editingContext().committedSnapshotForObject(this)); } // ---------------------------------------------------------- /** * Retrieve this object's <code>id</code> value. * @return the value of the attribute */ public Number id() { try { return (Number)EOUtilities.primaryKeyForObject( editingContext() , this).objectForKey("id"); } catch (Exception e) { return er.extensions.eof.ERXConstant.ZeroInteger; } } // ---------------------------------------------------------- /** * Retrieve this object's <code>fileName</code> value. * @return the value of the attribute */ public String fileName() { return (String)storedValueForKey( "fileName" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>fileName</code> * property. * * @param value The new value for this property */ public void setFileName( String value ) { if (log.isDebugEnabled()) { log.debug( "setFileName(" + value + "): was " + fileName() ); } takeStoredValueForKey( value, "fileName" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>isSubmissionForGrading</code> value. * @return the value of the attribute */ public boolean isSubmissionForGrading() { Integer returnValue = (Integer)storedValueForKey( "isSubmissionForGrading" ); return ( returnValue == null ) ? false : ( returnValue.intValue() > 0 ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>isSubmissionForGrading</code> * property. * * @param value The new value for this property */ public void setIsSubmissionForGrading( boolean value ) { if (log.isDebugEnabled()) { log.debug( "setIsSubmissionForGrading(" + value + "): was " + isSubmissionForGrading() ); } Integer actual = er.extensions.eof.ERXConstant.integerForInt( value ? 1 : 0 ); setIsSubmissionForGradingRaw( actual ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>isSubmissionForGrading</code> value. * @return the value of the attribute */ public Integer isSubmissionForGradingRaw() { return (Integer)storedValueForKey( "isSubmissionForGrading" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>isSubmissionForGrading</code> * property. * * @param value The new value for this property */ public void setIsSubmissionForGradingRaw( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setIsSubmissionForGradingRaw(" + value + "): was " + isSubmissionForGradingRaw() ); } takeStoredValueForKey( value, "isSubmissionForGrading" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>partnerLink</code> value. * @return the value of the attribute */ public boolean partnerLink() { Integer returnValue = (Integer)storedValueForKey( "partnerLink" ); return ( returnValue == null ) ? false : ( returnValue.intValue() > 0 ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>partnerLink</code> * property. * * @param value The new value for this property */ public void setPartnerLink( boolean value ) { if (log.isDebugEnabled()) { log.debug( "setPartnerLink(" + value + "): was " + partnerLink() ); } Integer actual = er.extensions.eof.ERXConstant.integerForInt( value ? 1 : 0 ); setPartnerLinkRaw( actual ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>partnerLink</code> value. * @return the value of the attribute */ public Integer partnerLinkRaw() { return (Integer)storedValueForKey( "partnerLink" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>partnerLink</code> * property. * * @param value The new value for this property */ public void setPartnerLinkRaw( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setPartnerLinkRaw(" + value + "): was " + partnerLinkRaw() ); } takeStoredValueForKey( value, "partnerLink" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>submitNumber</code> value. * @return the value of the attribute */ public int submitNumber() { Integer returnValue = (Integer)storedValueForKey( "submitNumber" ); return ( returnValue == null ) ? 0 : returnValue.intValue(); } // ---------------------------------------------------------- /** * Change the value of this object's <code>submitNumber</code> * property. * * @param value The new value for this property */ public void setSubmitNumber( int value ) { if (log.isDebugEnabled()) { log.debug( "setSubmitNumber(" + value + "): was " + submitNumber() ); } Integer actual = er.extensions.eof.ERXConstant.integerForInt( value ); setSubmitNumberRaw( actual ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>submitNumber</code> value. * @return the value of the attribute */ public Integer submitNumberRaw() { return (Integer)storedValueForKey( "submitNumber" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>submitNumber</code> * property. * * @param value The new value for this property */ public void setSubmitNumberRaw( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setSubmitNumberRaw(" + value + "): was " + submitNumberRaw() ); } takeStoredValueForKey( value, "submitNumber" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>submitTime</code> value. * @return the value of the attribute */ public NSTimestamp submitTime() { return (NSTimestamp)storedValueForKey( "submitTime" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>submitTime</code> * property. * * @param value The new value for this property */ public void setSubmitTime( NSTimestamp value ) { if (log.isDebugEnabled()) { log.debug( "setSubmitTime(" + value + "): was " + submitTime() ); } takeStoredValueForKey( value, "submitTime" ); } // ---------------------------------------------------------- @Override public void awakeFromFetch(EOEditingContext ec) { super.awakeFromFetch(ec); // Only try to migrate if the EC isn't a migrating context. If it is, // we're already trying to migrate and this "awake" is coming from the // child migration context. if (!(ec instanceof org.webcat.woextensions.MigratingEditingContext)) { migrateAttributeValuesIfNeeded(); } } // ---------------------------------------------------------- /** * Called by {@link #awake} to migrate attribute values if needed when the * object is retrieved. */ public final void migrateAttributeValuesIfNeeded() { log.debug("migrateAttributeValuesIfNeeded()"); if ( shouldMigrateIsSubmissionForGrading() || shouldMigratePartnerLink() ) { new org.webcat.woextensions.ECAction( org.webcat.woextensions.MigratingEditingContext .newEditingContext()) { public void action() { migrateAttributeValues( (org.webcat.woextensions.MigratingEditingContext)ec, localInstance(ec)); ec.saveChanges(); } }.run(); } } // ---------------------------------------------------------- /** * Called by {@link #awake} to migrate attribute values when the * object is retrieved. */ protected void migrateAttributeValues( org.webcat.woextensions.MigratingEditingContext mec, Submission migratingObject ) { log.debug("migrateAttributeValues()"); if ( migratingObject.shouldMigrateIsSubmissionForGrading() ) { migratingObject.migrateIsSubmissionForGrading(mec); } if ( migratingObject.shouldMigratePartnerLink() ) { migratingObject.migratePartnerLink(mec); } } // ---------------------------------------------------------- /** * Called by {@link #migrateAttributeValues} to migrate the * isSubmissionForGrading attribute. */ protected abstract boolean shouldMigrateIsSubmissionForGrading(); // ---------------------------------------------------------- /** * Called by {@link #migrateAttributeValues} to migrate the * isSubmissionForGrading attribute. */ protected abstract void migrateIsSubmissionForGrading( org.webcat.woextensions.MigratingEditingContext mec); // ---------------------------------------------------------- /** * Called by {@link #migrateAttributeValues} to migrate the * partnerLink attribute. */ protected abstract boolean shouldMigratePartnerLink(); // ---------------------------------------------------------- /** * Called by {@link #migrateAttributeValues} to migrate the * partnerLink attribute. */ protected abstract void migratePartnerLink( org.webcat.woextensions.MigratingEditingContext mec); // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>assignmentOffering</code> * relationship. * @return the entity in the relationship */ public org.webcat.grader.AssignmentOffering assignmentOffering() { return (org.webcat.grader.AssignmentOffering)storedValueForKey( "assignmentOffering" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>assignmentOffering</code> * relationship (DO NOT USE--instead, use * <code>setAssignmentOfferingRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setAssignmentOffering( org.webcat.grader.AssignmentOffering value ) { if (log.isDebugEnabled()) { log.debug( "setAssignmentOffering(" + value + "): was " + assignmentOffering() ); } takeStoredValueForKey( value, "assignmentOffering" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>assignmentOffering</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setAssignmentOfferingRelationship( org.webcat.grader.AssignmentOffering value ) { if (log.isDebugEnabled()) { log.debug( "setAssignmentOfferingRelationship(" + value + "): was " + assignmentOffering() ); } if ( value == null ) { org.webcat.grader.AssignmentOffering object = assignmentOffering(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "assignmentOffering" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "assignmentOffering" ); } } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>primarySubmission</code> * relationship. * @return the entity in the relationship */ public org.webcat.grader.Submission primarySubmission() { return (org.webcat.grader.Submission)storedValueForKey( "primarySubmission" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>primarySubmission</code> * relationship (DO NOT USE--instead, use * <code>setPrimarySubmissionRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setPrimarySubmission( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "setPrimarySubmission(" + value + "): was " + primarySubmission() ); } takeStoredValueForKey( value, "primarySubmission" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>primarySubmission</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setPrimarySubmissionRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "setPrimarySubmissionRelationship(" + value + "): was " + primarySubmission() ); } if ( value == null ) { org.webcat.grader.Submission object = primarySubmission(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "primarySubmission" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "primarySubmission" ); } } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>result</code> * relationship. * @return the entity in the relationship */ public org.webcat.grader.SubmissionResult result() { return (org.webcat.grader.SubmissionResult)storedValueForKey( "result" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>result</code> * relationship (DO NOT USE--instead, use * <code>setResultRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setResult( org.webcat.grader.SubmissionResult value ) { if (log.isDebugEnabled()) { log.debug( "setResult(" + value + "): was " + result() ); } takeStoredValueForKey( value, "result" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>result</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setResultRelationship( org.webcat.grader.SubmissionResult value ) { if (log.isDebugEnabled()) { log.debug( "setResultRelationship(" + value + "): was " + result() ); } if ( value == null ) { org.webcat.grader.SubmissionResult object = result(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "result" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "result" ); } } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>user</code> * relationship. * @return the entity in the relationship */ public org.webcat.core.User user() { return (org.webcat.core.User)storedValueForKey( "user" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>user</code> * relationship (DO NOT USE--instead, use * <code>setUserRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setUser( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "setUser(" + value + "): was " + user() ); } takeStoredValueForKey( value, "user" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>user</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setUserRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "setUserRelationship(" + value + "): was " + user() ); } if ( value == null ) { org.webcat.core.User object = user(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "user" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "user" ); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>enqueuedJobs</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.grader.EnqueuedJob> enqueuedJobs() { return (NSArray)storedValueForKey( "enqueuedJobs" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>enqueuedJobs</code> relationship. * * @param value The new set of entities to relate to */ public void setEnqueuedJobs( NSMutableArray<org.webcat.grader.EnqueuedJob> value ) { if (log.isDebugEnabled()) { log.debug( "setEnqueuedJobs(" + value + "): was " + enqueuedJobs() ); } takeStoredValueForKey( value, "enqueuedJobs" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>enqueuedJobs</code> * relationship (DO NOT USE--instead, use * <code>addToEnqueuedJobsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToEnqueuedJobs( org.webcat.grader.EnqueuedJob value ) { if (log.isDebugEnabled()) { log.debug( "addToEnqueuedJobs(" + value + "): was " + enqueuedJobs() ); } NSMutableArray<org.webcat.grader.EnqueuedJob> array = (NSMutableArray<org.webcat.grader.EnqueuedJob>)enqueuedJobs(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>enqueuedJobs</code> * relationship (DO NOT USE--instead, use * <code>removeFromEnqueuedJobsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromEnqueuedJobs( org.webcat.grader.EnqueuedJob value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromEnqueuedJobs(" + value + "): was " + enqueuedJobs() ); } NSMutableArray<org.webcat.grader.EnqueuedJob> array = (NSMutableArray<org.webcat.grader.EnqueuedJob>)enqueuedJobs(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>enqueuedJobs</code> * relationship. * * @param value The new entity to relate to */ public void addToEnqueuedJobsRelationship( org.webcat.grader.EnqueuedJob value ) { if (log.isDebugEnabled()) { log.debug( "addToEnqueuedJobsRelationship(" + value + "): was " + enqueuedJobs() ); } addObjectToBothSidesOfRelationshipWithKey( value, "enqueuedJobs" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>enqueuedJobs</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromEnqueuedJobsRelationship( org.webcat.grader.EnqueuedJob value ) { if (log.isDebugEnabled()) { log.debug( "removeFromEnqueuedJobsRelationship(" + value + "): was " + enqueuedJobs() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "enqueuedJobs" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>enqueuedJobs</code> relationship. * * @return The new entity */ public org.webcat.grader.EnqueuedJob createEnqueuedJobsRelationship() { if (log.isDebugEnabled()) { log.debug( "createEnqueuedJobsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "EnqueuedJob" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "enqueuedJobs" ); return (org.webcat.grader.EnqueuedJob)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>enqueuedJobs</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteEnqueuedJobsRelationship( org.webcat.grader.EnqueuedJob value ) { if (log.isDebugEnabled()) { log.debug( "deleteEnqueuedJobsRelationship(" + value + "): was " + enqueuedJobs() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "enqueuedJobs" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>enqueuedJobs</code> relationship. */ public void deleteAllEnqueuedJobsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllEnqueuedJobsRelationships(): was " + enqueuedJobs() ); } for (org.webcat.grader.EnqueuedJob object : enqueuedJobs()) { deleteEnqueuedJobsRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>graderPrefs</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.grader.GraderPrefs> graderPrefs() { return (NSArray)storedValueForKey( "graderPrefs" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>graderPrefs</code> relationship. * * @param value The new set of entities to relate to */ public void setGraderPrefs( NSMutableArray<org.webcat.grader.GraderPrefs> value ) { if (log.isDebugEnabled()) { log.debug( "setGraderPrefs(" + value + "): was " + graderPrefs() ); } takeStoredValueForKey( value, "graderPrefs" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>graderPrefs</code> * relationship (DO NOT USE--instead, use * <code>addToGraderPrefsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToGraderPrefs( org.webcat.grader.GraderPrefs value ) { if (log.isDebugEnabled()) { log.debug( "addToGraderPrefs(" + value + "): was " + graderPrefs() ); } NSMutableArray<org.webcat.grader.GraderPrefs> array = (NSMutableArray<org.webcat.grader.GraderPrefs>)graderPrefs(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>graderPrefs</code> * relationship (DO NOT USE--instead, use * <code>removeFromGraderPrefsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromGraderPrefs( org.webcat.grader.GraderPrefs value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromGraderPrefs(" + value + "): was " + graderPrefs() ); } NSMutableArray<org.webcat.grader.GraderPrefs> array = (NSMutableArray<org.webcat.grader.GraderPrefs>)graderPrefs(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>graderPrefs</code> * relationship. * * @param value The new entity to relate to */ public void addToGraderPrefsRelationship( org.webcat.grader.GraderPrefs value ) { if (log.isDebugEnabled()) { log.debug( "addToGraderPrefsRelationship(" + value + "): was " + graderPrefs() ); } addObjectToBothSidesOfRelationshipWithKey( value, "graderPrefs" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>graderPrefs</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromGraderPrefsRelationship( org.webcat.grader.GraderPrefs value ) { if (log.isDebugEnabled()) { log.debug( "removeFromGraderPrefsRelationship(" + value + "): was " + graderPrefs() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "graderPrefs" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>graderPrefs</code> relationship. * * @return The new entity */ public org.webcat.grader.GraderPrefs createGraderPrefsRelationship() { if (log.isDebugEnabled()) { log.debug( "createGraderPrefsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "GraderPrefs" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "graderPrefs" ); return (org.webcat.grader.GraderPrefs)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>graderPrefs</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteGraderPrefsRelationship( org.webcat.grader.GraderPrefs value ) { if (log.isDebugEnabled()) { log.debug( "deleteGraderPrefsRelationship(" + value + "): was " + graderPrefs() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "graderPrefs" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>graderPrefs</code> relationship. */ public void deleteAllGraderPrefsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllGraderPrefsRelationships(): was " + graderPrefs() ); } for (org.webcat.grader.GraderPrefs object : graderPrefs()) { deleteGraderPrefsRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>partneredSubmissions</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.grader.Submission> partneredSubmissions() { return (NSArray)storedValueForKey( "partneredSubmissions" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>partneredSubmissions</code> relationship. * * @param value The new set of entities to relate to */ public void setPartneredSubmissions( NSMutableArray<org.webcat.grader.Submission> value ) { if (log.isDebugEnabled()) { log.debug( "setPartneredSubmissions(" + value + "): was " + partneredSubmissions() ); } takeStoredValueForKey( value, "partneredSubmissions" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>partneredSubmissions</code> * relationship (DO NOT USE--instead, use * <code>addToPartneredSubmissionsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToPartneredSubmissions( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "addToPartneredSubmissions(" + value + "): was " + partneredSubmissions() ); } NSMutableArray<org.webcat.grader.Submission> array = (NSMutableArray<org.webcat.grader.Submission>)partneredSubmissions(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>partneredSubmissions</code> * relationship (DO NOT USE--instead, use * <code>removeFromPartneredSubmissionsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromPartneredSubmissions( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromPartneredSubmissions(" + value + "): was " + partneredSubmissions() ); } NSMutableArray<org.webcat.grader.Submission> array = (NSMutableArray<org.webcat.grader.Submission>)partneredSubmissions(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>partneredSubmissions</code> * relationship. * * @param value The new entity to relate to */ public void addToPartneredSubmissionsRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "addToPartneredSubmissionsRelationship(" + value + "): was " + partneredSubmissions() ); } addObjectToBothSidesOfRelationshipWithKey( value, "partneredSubmissions" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>partneredSubmissions</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromPartneredSubmissionsRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "removeFromPartneredSubmissionsRelationship(" + value + "): was " + partneredSubmissions() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "partneredSubmissions" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>partneredSubmissions</code> relationship. * * @return The new entity */ public org.webcat.grader.Submission createPartneredSubmissionsRelationship() { if (log.isDebugEnabled()) { log.debug( "createPartneredSubmissionsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "Submission" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "partneredSubmissions" ); return (org.webcat.grader.Submission)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>partneredSubmissions</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deletePartneredSubmissionsRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "deletePartneredSubmissionsRelationship(" + value + "): was " + partneredSubmissions() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "partneredSubmissions" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>partneredSubmissions</code> relationship. */ public void deleteAllPartneredSubmissionsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllPartneredSubmissionsRelationships(): was " + partneredSubmissions() ); } for (org.webcat.grader.Submission object : partneredSubmissions()) { deletePartneredSubmissionsRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve objects using a fetch specification. * * @param context The editing context to use * @param fspec The fetch specification to use * * @return an NSArray of the entities retrieved */ @SuppressWarnings("unchecked") public static NSArray<Submission> objectsWithFetchSpecification( EOEditingContext context, EOFetchSpecification fspec) { return context.objectsWithFetchSpecification(fspec); } // ---------------------------------------------------------- /** * Retrieve all objects of this type. * * @param context The editing context to use * * @return an NSArray of the entities retrieved */ public static NSArray<Submission> allObjects( EOEditingContext context) { return objectsMatchingQualifier(context, null, null); } // ---------------------------------------------------------- /** * Retrieve objects using a qualifier. * * @param context The editing context to use * @param qualifier The qualifier to use * * @return an NSArray of the entities retrieved */ public static NSArray<Submission> objectsMatchingQualifier( EOEditingContext context, EOQualifier qualifier) { return objectsMatchingQualifier(context, qualifier, null); } // ---------------------------------------------------------- /** * Retrieve objects using a qualifier and sort orderings. * * @param context The editing context to use * @param qualifier The qualifier to use * @param sortOrderings The sort orderings to use * * @return an NSArray of the entities retrieved */ public static NSArray<Submission> objectsMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { @SuppressWarnings("unchecked") EOFetchSpecification fspec = new WCFetchSpecification( ENTITY_NAME, qualifier, sortOrderings); fspec.setUsesDistinct(true); return objectsWithFetchSpecification(context, fspec); } // ---------------------------------------------------------- /** * Retrieve the first object that matches a qualifier, when * sorted with the specified sort orderings. * * @param context The editing context to use * @param qualifier The qualifier to use * @param sortOrderings the sort orderings * * @return the first entity that was retrieved, or null if there was none */ public static Submission firstObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { NSArray<Submission> objects = objectsMatchingQualifier(context, qualifier, sortOrderings); return (objects.size() > 0) ? objects.get(0) : null; } // ---------------------------------------------------------- /** * Retrieve a single object using a list of keys and values to match. * * @param context The editing context to use * @param qualifier The qualifier to use * * @return the single entity that was retrieved * * @throws EOUtilities.MoreThanOneException * if there is more than one matching object */ public static Submission uniqueObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier) throws EOUtilities.MoreThanOneException { NSArray<Submission> objects = objectsMatchingQualifier(context, qualifier); if (objects.size() > 1) { String msg = "fetching Submission"; try { if (qualifier != null) { msg += " where " + qualifier; } msg += ", result = " + objects; } catch (Exception e) { log.error("Exception building MoreThanOneException message, " + "contents so far: " + msg, e); } throw new EOUtilities.MoreThanOneException(msg); } return (objects.size() > 0) ? objects.get(0) : null; } // ---------------------------------------------------------- /** * Retrieve objects using a list of keys and values to match. * * @param context The editing context to use * @param keysAndValues a list of keys and values to match, alternating * "key", "value", "key", "value"... * * @return an NSArray of the entities retrieved */ public static NSArray<Submission> objectsMatchingValues( EOEditingContext context, Object... keysAndValues) { if (keysAndValues.length % 2 != 0) { throw new IllegalArgumentException("There should a value " + "corresponding to every key that was passed. Args = " + java.util.Arrays.toString(keysAndValues)); } NSMutableDictionary<String, Object> valueDictionary = new NSMutableDictionary<String, Object>(); for (int i = 0; i < keysAndValues.length; i += 2) { Object key = keysAndValues[i]; Object value = keysAndValues[i + 1]; if (key == null) { throw new IllegalArgumentException( "Found null where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } else if (!(key instanceof String)) { throw new IllegalArgumentException( "Found a " + key.getClass().getName() + " [" + key + "]" + " where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } valueDictionary.setObjectForKey(value, key); } return objectsMatchingValues(context, valueDictionary); } // ---------------------------------------------------------- /** * Retrieve objects using a dictionary of keys and values to match. * * @param context The editing context to use * @param keysAndValues a dictionary of keys and values to match * * @return an NSArray of the entities retrieved */ @SuppressWarnings("unchecked") public static NSArray<Submission> objectsMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) { return EOUtilities.objectsMatchingValues(context, ENTITY_NAME, keysAndValues); } // ---------------------------------------------------------- /** * Retrieve the first object that matches a set of keys and values, when * sorted with the specified sort orderings. * * @param context The editing context to use * @param sortOrderings the sort orderings * @param keysAndValues a list of keys and values to match, alternating * "key", "value", "key", "value"... * * @return the first entity that was retrieved, or null if there was none */ public static Submission firstObjectMatchingValues( EOEditingContext context, NSArray<EOSortOrdering> sortOrderings, Object... keysAndValues) { if (keysAndValues.length % 2 != 0) { throw new IllegalArgumentException("There should a value " + "corresponding to every key that was passed. Args = " + java.util.Arrays.toString(keysAndValues)); } NSMutableDictionary<String, Object> valueDictionary = new NSMutableDictionary<String, Object>(); for (int i = 0; i < keysAndValues.length; i += 2) { Object key = keysAndValues[i]; Object value = keysAndValues[i + 1]; if (key == null) { throw new IllegalArgumentException( "Found null where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } else if (!(key instanceof String)) { throw new IllegalArgumentException( "Found a " + key.getClass().getName() + " [" + key + "]" + " where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } valueDictionary.setObjectForKey(value, key); } return firstObjectMatchingValues( context, sortOrderings, valueDictionary); } // ---------------------------------------------------------- /** * Retrieves the first object that matches a set of keys and values, when * sorted with the specified sort orderings. * * @param context The editing context to use * @param sortOrderings the sort orderings * @param keysAndValues a dictionary of keys and values to match * * @return the first entity that was retrieved, or null if there was none */ public static Submission firstObjectMatchingValues( EOEditingContext context, NSArray<EOSortOrdering> sortOrderings, NSDictionary<String, Object> keysAndValues) { @SuppressWarnings("unchecked") EOFetchSpecification fspec = new WCFetchSpecification( ENTITY_NAME, EOQualifier.qualifierToMatchAllValues(keysAndValues), sortOrderings); fspec.setFetchLimit(1); NSArray<Submission> objects = objectsWithFetchSpecification( context, fspec ); if ( objects.count() == 0 ) { return null; } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve a single object using a list of keys and values to match. * * @param context The editing context to use * @param keysAndValues a list of keys and values to match, alternating * "key", "value", "key", "value"... * * @return the single entity that was retrieved, or null if there was none * * @throws EOUtilities.MoreThanOneException * if there is more than one matching object */ public static Submission uniqueObjectMatchingValues( EOEditingContext context, Object... keysAndValues) throws EOUtilities.MoreThanOneException { if (keysAndValues.length % 2 != 0) { throw new IllegalArgumentException("There should a value " + "corresponding to every key that was passed. Args = " + java.util.Arrays.toString(keysAndValues)); } NSMutableDictionary<String, Object> valueDictionary = new NSMutableDictionary<String, Object>(); for (int i = 0; i < keysAndValues.length; i += 2) { Object key = keysAndValues[i]; Object value = keysAndValues[i + 1]; if (key == null) { throw new IllegalArgumentException( "Found null where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } else if (!(key instanceof String)) { throw new IllegalArgumentException( "Found a " + key.getClass().getName() + " [" + key + "]" + " where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } valueDictionary.setObjectForKey(value, key); } return uniqueObjectMatchingValues(context, valueDictionary); } // ---------------------------------------------------------- /** * Retrieve an object using a dictionary of keys and values to match. * * @param context The editing context to use * @param keysAndValues a dictionary of keys and values to match * * @return the single entity that was retrieved, or null if there was none * * @throws EOUtilities.MoreThanOneException * if there is more than one matching object */ public static Submission uniqueObjectMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) throws EOUtilities.MoreThanOneException { try { return (Submission)EOUtilities.objectMatchingValues( context, ENTITY_NAME, keysAndValues); } catch (EOObjectNotAvailableException e) { return null; } } // ---------------------------------------------------------- /** * Retrieve the count of all objects of this type. * * @param context The editing context to use * * @return the count of all objects */ public static int countOfAllObjects(EOEditingContext context) { return countOfObjectsMatchingQualifier(context, null); } // ---------------------------------------------------------- /** * Retrieve the count of objects that match a qualifier. * * @param context The editing context to use * @param qualifier The qualifier to use * * @return the count of objects matching the qualifier */ public static int countOfObjectsMatchingQualifier( EOEditingContext context, EOQualifier qualifier) { return ERXEOControlUtilities.objectCountWithQualifier( context, ENTITY_NAME, qualifier); } // ---------------------------------------------------------- /** * Retrieve the count of objects using a list of keys and values to match. * * @param context The editing context to use * @param keysAndValues a list of keys and values to match, alternating * "key", "value", "key", "value"... * * @return the count of objects that match the specified values */ public static int countOfObjectsMatchingValues( EOEditingContext context, Object... keysAndValues) { if (keysAndValues.length % 2 != 0) { throw new IllegalArgumentException("There should a value " + "corresponding to every key that was passed. Args = " + java.util.Arrays.toString(keysAndValues)); } NSMutableDictionary<String, Object> valueDictionary = new NSMutableDictionary<String, Object>(); for (int i = 0; i < keysAndValues.length; i += 2) { Object key = keysAndValues[i]; Object value = keysAndValues[i + 1]; if (key == null) { throw new IllegalArgumentException( "Found null where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } else if (!(key instanceof String)) { throw new IllegalArgumentException( "Found a " + key.getClass().getName() + " [" + key + "]" + " where a String key was expected, arguments = " + java.util.Arrays.toString(keysAndValues)); } valueDictionary.setObjectForKey(value, key); } return countOfObjectsMatchingValues(context, valueDictionary); } // ---------------------------------------------------------- /** * Retrieve the count of objects using a dictionary of keys and values to * match. * * @param context The editing context to use * @param keysAndValues a dictionary of keys and values to match * * @return the count of objects that matched the specified values */ public static int countOfObjectsMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) { return countOfObjectsMatchingQualifier(context, EOQualifier.qualifierToMatchAllValues(keysAndValues)); } // ---------------------------------------------------------- /** * Retrieve an object according to the <code>earliestSubmissionForAssignmentOfferingAndUser</code> * fetch specification. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param userBinding fetch spec parameter * @return the object retrieved, or null if one was not found */ public static Submission earliestSubmissionForAssignmentOfferingAndUser( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, org.webcat.core.User userBinding ) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("earliestSubmissionForAssignmentOfferingAndUser", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if ( assignmentOfferingBinding != null ) { bindings.setObjectForKey( assignmentOfferingBinding, "assignmentOffering" ); } if ( userBinding != null ) { bindings.setObjectForKey( userBinding, "user" ); } spec = spec.fetchSpecificationWithQualifierBindings( bindings ); NSArray<Submission> objects = objectsWithFetchSpecification( context, spec ); if (log.isDebugEnabled()) { log.debug( "earliestSubmissionForAssignmentOfferingAndUser(ec" + ", " + assignmentOfferingBinding + ", " + userBinding + "): " + objects ); } if ( objects.count() == 0 ) { return null; } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve an object according to the <code>earliestSubmissionForCourseOffering</code> * fetch specification. * * @param context The editing context to use * @param courseOfferingBinding fetch spec parameter * @return the object retrieved, or null if one was not found */ public static Submission earliestSubmissionForCourseOffering( EOEditingContext context, org.webcat.core.CourseOffering courseOfferingBinding ) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("earliestSubmissionForCourseOffering", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if ( courseOfferingBinding != null ) { bindings.setObjectForKey( courseOfferingBinding, "courseOffering" ); } spec = spec.fetchSpecificationWithQualifierBindings( bindings ); NSArray<Submission> objects = objectsWithFetchSpecification( context, spec ); if (log.isDebugEnabled()) { log.debug( "earliestSubmissionForCourseOffering(ec" + ", " + courseOfferingBinding + "): " + objects ); } if ( objects.count() == 0 ) { return null; } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve an object according to the <code>latestSubmissionForAssignmentAndUser</code> * fetch specification. * * @param context The editing context to use * @param assignmentBinding fetch spec parameter * @param userBinding fetch spec parameter * @return the object retrieved, or null if one was not found */ public static Submission latestSubmissionForAssignmentAndUser( EOEditingContext context, org.webcat.grader.Assignment assignmentBinding, org.webcat.core.User userBinding ) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("latestSubmissionForAssignmentAndUser", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if ( assignmentBinding != null ) { bindings.setObjectForKey( assignmentBinding, "assignment" ); } if ( userBinding != null ) { bindings.setObjectForKey( userBinding, "user" ); } spec = spec.fetchSpecificationWithQualifierBindings( bindings ); NSArray<Submission> objects = objectsWithFetchSpecification( context, spec ); if (log.isDebugEnabled()) { log.debug( "latestSubmissionForAssignmentAndUser(ec" + ", " + assignmentBinding + ", " + userBinding + "): " + objects ); } if ( objects.count() == 0 ) { return null; } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve an object according to the <code>latestSubmissionForAssignmentOfferingAndUser</code> * fetch specification. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param userBinding fetch spec parameter * @return the object retrieved, or null if one was not found */ public static Submission latestSubmissionForAssignmentOfferingAndUser( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, org.webcat.core.User userBinding ) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("latestSubmissionForAssignmentOfferingAndUser", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if ( assignmentOfferingBinding != null ) { bindings.setObjectForKey( assignmentOfferingBinding, "assignmentOffering" ); } if ( userBinding != null ) { bindings.setObjectForKey( userBinding, "user" ); } spec = spec.fetchSpecificationWithQualifierBindings( bindings ); NSArray<Submission> objects = objectsWithFetchSpecification( context, spec ); if (log.isDebugEnabled()) { log.debug( "latestSubmissionForAssignmentOfferingAndUser(ec" + ", " + assignmentOfferingBinding + ", " + userBinding + "): " + objects ); } if ( objects.count() == 0 ) { return null; } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve an object according to the <code>latestSubmissionForCourseOffering</code> * fetch specification. * * @param context The editing context to use * @param courseOfferingBinding fetch spec parameter * @return the object retrieved, or null if one was not found */ public static Submission latestSubmissionForCourseOffering( EOEditingContext context, org.webcat.core.CourseOffering courseOfferingBinding ) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("latestSubmissionForCourseOffering", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if ( courseOfferingBinding != null ) { bindings.setObjectForKey( courseOfferingBinding, "courseOffering" ); } spec = spec.fetchSpecificationWithQualifierBindings( bindings ); NSArray<Submission> objects = objectsWithFetchSpecification( context, spec ); if (log.isDebugEnabled()) { log.debug( "latestSubmissionForCourseOffering(ec" + ", " + courseOfferingBinding + "): " + objects ); } if ( objects.count() == 0 ) { return null; } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve an object according to the <code>specificSubmission</code> * fetch specification. If more than one object is found, an exception is * thrown. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param submitNumberBinding fetch spec parameter * @param userBinding fetch spec parameter * @return the object retrieved, or null if one was not found * @throws EOUtilities.MoreThanOneException if more than one object is found */ public static Submission specificSubmission( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, Integer submitNumberBinding, org.webcat.core.User userBinding ) throws EOUtilities.MoreThanOneException { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("specificSubmission", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (assignmentOfferingBinding != null) { bindings.setObjectForKey(assignmentOfferingBinding, "assignmentOffering"); } if (submitNumberBinding != null) { bindings.setObjectForKey(submitNumberBinding, "submitNumber"); } if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<Submission> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug( "specificSubmission(ec" + ", " + assignmentOfferingBinding + ", " + submitNumberBinding + ", " + userBinding + "): " + objects ); } if ( objects.count() == 0 ) { return null; } else if ( objects.count() > 1 ) { String msg = "fetching Submission using specificSubmission"; try { if (bindings.size() != 0) { msg += " where bindings = " + bindings; } msg += ", result = " + objects; } catch (Exception e) { log.error("Exception building MoreThanOneException message, " + "contents so far: " + msg, e); } throw new EOUtilities.MoreThanOneException(msg); } else { return objects.objectAtIndex(0); } } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>submissionsForAssignmentAndUserDescending</code> * fetch specification. * * @param context The editing context to use * @param assignmentBinding fetch spec parameter * @param semesterBinding fetch spec parameter * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<Submission> submissionsForAssignmentAndUserDescending( EOEditingContext context, org.webcat.grader.Assignment assignmentBinding, org.webcat.core.Semester semesterBinding, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("submissionsForAssignmentAndUserDescending", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (assignmentBinding != null) { bindings.setObjectForKey(assignmentBinding, "assignment"); } if (semesterBinding != null) { bindings.setObjectForKey(semesterBinding, "semester"); } if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<Submission> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("submissionsForAssignmentAndUserDescending(ec" + ", " + assignmentBinding + ", " + semesterBinding + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>submissionsForAssignmentOfferingAndUser</code> * fetch specification. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<Submission> submissionsForAssignmentOfferingAndUser( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("submissionsForAssignmentOfferingAndUser", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (assignmentOfferingBinding != null) { bindings.setObjectForKey(assignmentOfferingBinding, "assignmentOffering"); } if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<Submission> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("submissionsForAssignmentOfferingAndUser(ec" + ", " + assignmentOfferingBinding + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>submissionsForAssignmentOfferingAndUserDescending</code> * fetch specification. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<Submission> submissionsForAssignmentOfferingAndUserDescending( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("submissionsForAssignmentOfferingAndUserDescending", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (assignmentOfferingBinding != null) { bindings.setObjectForKey(assignmentOfferingBinding, "assignmentOffering"); } if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<Submission> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("submissionsForAssignmentOfferingAndUserDescending(ec" + ", " + assignmentOfferingBinding + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>submissionsForGrading</code> * fetch specification. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<Submission> submissionsForGrading( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("submissionsForGrading", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (assignmentOfferingBinding != null) { bindings.setObjectForKey(assignmentOfferingBinding, "assignmentOffering"); } if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<Submission> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("submissionsForGrading(ec" + ", " + assignmentOfferingBinding + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>submissionsWithFeedback</code> * fetch specification. * * @param context The editing context to use * @param assignmentOfferingBinding fetch spec parameter * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<Submission> submissionsWithFeedback( EOEditingContext context, org.webcat.grader.AssignmentOffering assignmentOfferingBinding, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("submissionsWithFeedback", "Submission"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (assignmentOfferingBinding != null) { bindings.setObjectForKey(assignmentOfferingBinding, "assignmentOffering"); } if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<Submission> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("submissionsWithFeedback(ec" + ", " + assignmentOfferingBinding + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Produce a string representation of this object. This implementation * calls UserPresentableDescription(), which uses WebObjects' internal * mechanism to print out the visible fields of this object. Normally, * subclasses would override userPresentableDescription() to change * the way the object is printed. * * @return A string representation of the object's value */ public String toString() { return userPresentableDescription(); } //~ Instance/static variables ............................................. static Logger log = Logger.getLogger(Submission.class); }