/*==========================================================================*\ | _AssignmentOffering.java |*-------------------------------------------------------------------------*| | Created by eogenerator | DO NOT EDIT. Make changes to AssignmentOffering.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 * AssignmentOffering.java. * * @author Generated by eogenerator * @version version suppressed to control auto-generation */ public abstract class _AssignmentOffering extends org.webcat.core.EOBase implements org.webcat.core.MutableContainer.MutableContainerOwner { //~ Constructors .......................................................... // ---------------------------------------------------------- /** * Creates a new _AssignmentOffering object. */ public _AssignmentOffering() { super(); } // ---------------------------------------------------------- /** * A static factory method for creating a new * AssignmentOffering object given required * attributes and relationships. * @param editingContext The context in which the new object will be * inserted * @param gradingSuspendedValue * @param publishValue * @param updateMutableFieldsValue * @return The newly created object */ public static AssignmentOffering create( EOEditingContext editingContext, boolean gradingSuspendedValue, boolean publishValue, boolean updateMutableFieldsValue ) { AssignmentOffering eoObject = (AssignmentOffering) EOUtilities.createAndInsertInstance( editingContext, _AssignmentOffering.ENTITY_NAME); eoObject.setGradingSuspended(gradingSuspendedValue); eoObject.setPublish(publishValue); eoObject.setUpdateMutableFields(updateMutableFieldsValue); 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 AssignmentOffering localInstance( EOEditingContext editingContext, AssignmentOffering eo) { return (eo == null) ? null : (AssignmentOffering)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 AssignmentOffering forId( EOEditingContext ec, int id) { AssignmentOffering obj = null; if (id > 0) { NSArray<AssignmentOffering> 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 AssignmentOffering forId( EOEditingContext ec, String id) { return forId(ec, er.extensions.foundation.ERXValueUtilities.intValue(id)); } //~ Constants (for key names) ............................................. // Attributes --- public static final String CLOSED_ON_DATE_KEY = "closedOnDate"; public static final ERXKey<NSTimestamp> closedOnDate = new ERXKey<NSTimestamp>(CLOSED_ON_DATE_KEY); public static final String DUE_DATE_KEY = "dueDate"; public static final ERXKey<NSTimestamp> dueDate = new ERXKey<NSTimestamp>(DUE_DATE_KEY); public static final String GRADING_SUSPENDED_KEY = "gradingSuspended"; public static final ERXKey<Integer> gradingSuspended = new ERXKey<Integer>(GRADING_SUSPENDED_KEY); public static final String GRAPH_SUMMARY_KEY = "graphSummary"; public static final ERXKey<NSData> graphSummary = new ERXKey<NSData>(GRAPH_SUMMARY_KEY); public static final String LAST_MODIFIED_KEY = "lastModified"; public static final ERXKey<NSTimestamp> lastModified = new ERXKey<NSTimestamp>(LAST_MODIFIED_KEY); public static final String MOODLE_ID_KEY = "moodleId"; public static final ERXKey<Long> moodleId = new ERXKey<Long>(MOODLE_ID_KEY); public static final String PUBLISH_KEY = "publish"; public static final ERXKey<Integer> publish = new ERXKey<Integer>(PUBLISH_KEY); public static final String UPDATE_MUTABLE_FIELDS_KEY = "updateMutableFields"; public static final ERXKey<Integer> updateMutableFields = new ERXKey<Integer>(UPDATE_MUTABLE_FIELDS_KEY); // To-one relationships --- public static final String ASSIGNMENT_KEY = "assignment"; public static final ERXKey<org.webcat.grader.Assignment> assignment = new ERXKey<org.webcat.grader.Assignment>(ASSIGNMENT_KEY); public static final String COURSE_OFFERING_KEY = "courseOffering"; public static final ERXKey<org.webcat.core.CourseOffering> courseOffering = new ERXKey<org.webcat.core.CourseOffering>(COURSE_OFFERING_KEY); // To-many relationships --- 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 SUBMISSIONS_KEY = "submissions"; public static final ERXKey<org.webcat.grader.Submission> submissions = new ERXKey<org.webcat.grader.Submission>(SUBMISSIONS_KEY); // Fetch specifications --- public static final String ALL_OFFERINGS_ORDERED_BY_DUE_DATE_FSPEC = "allOfferingsOrderedByDueDate"; public static final String OFFERINGS_FOR_COURSE_FSPEC = "offeringsForCourse"; public static final String OFFERINGS_FOR_COURSE_OFFERING_FSPEC = "offeringsForCourseOffering"; public static final String OFFERINGS_WITH_USER_AS_STAFF_FSPEC = "offeringsWithUserAsStaff"; public static final String OFFERINGS_WITH_USER_AS_STUDENT_FSPEC = "offeringsWithUserAsStudent"; public static final String ENTITY_NAME = "AssignmentOffering"; 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 AssignmentOffering localInstance(EOEditingContext editingContext) { return (AssignmentOffering)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>closedOnDate</code> value. * @return the value of the attribute */ public NSTimestamp closedOnDate() { return (NSTimestamp)storedValueForKey( "closedOnDate" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>closedOnDate</code> * property. * * @param value The new value for this property */ public void setClosedOnDate( NSTimestamp value ) { if (log.isDebugEnabled()) { log.debug( "setClosedOnDate(" + value + "): was " + closedOnDate() ); } takeStoredValueForKey( value, "closedOnDate" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>dueDate</code> value. * @return the value of the attribute */ public NSTimestamp dueDate() { return (NSTimestamp)storedValueForKey( "dueDate" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>dueDate</code> * property. * * @param value The new value for this property */ public void setDueDate( NSTimestamp value ) { if (log.isDebugEnabled()) { log.debug( "setDueDate(" + value + "): was " + dueDate() ); } takeStoredValueForKey( value, "dueDate" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>gradingSuspended</code> value. * @return the value of the attribute */ public boolean gradingSuspended() { Integer returnValue = (Integer)storedValueForKey( "gradingSuspended" ); return ( returnValue == null ) ? false : ( returnValue.intValue() > 0 ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>gradingSuspended</code> * property. * * @param value The new value for this property */ public void setGradingSuspended( boolean value ) { if (log.isDebugEnabled()) { log.debug( "setGradingSuspended(" + value + "): was " + gradingSuspended() ); } Integer actual = er.extensions.eof.ERXConstant.integerForInt( value ? 1 : 0 ); setGradingSuspendedRaw( actual ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>gradingSuspended</code> value. * @return the value of the attribute */ public Integer gradingSuspendedRaw() { return (Integer)storedValueForKey( "gradingSuspended" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>gradingSuspended</code> * property. * * @param value The new value for this property */ public void setGradingSuspendedRaw( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setGradingSuspendedRaw(" + value + "): was " + gradingSuspendedRaw() ); } takeStoredValueForKey( value, "gradingSuspended" ); } //-- Local mutable cache -- private org.webcat.grader.graphs.AssignmentSummary graphSummaryCache; private NSData graphSummaryRawCache; // ---------------------------------------------------------- /** * Retrieve this object's <code>graphSummary</code> value. * @return the value of the attribute */ public org.webcat.grader.graphs.AssignmentSummary graphSummary() { NSData dbValue = (NSData)storedValueForKey("graphSummary"); if (graphSummaryRawCache != dbValue) { if (dbValue != null && dbValue.equals( graphSummaryRawCache)) { // They are still equal, so just update the raw cache graphSummaryRawCache = dbValue; } else { // Underlying attribute may have changed because // of a concurrent update through another editing // context, so throw away current values. graphSummaryRawCache = dbValue; org.webcat.grader.graphs.AssignmentSummary newValue = org.webcat.grader.graphs.AssignmentSummary .objectWithArchiveData( dbValue ); if ( graphSummaryCache != null ) { graphSummaryCache.copyFrom( newValue ); } else { graphSummaryCache = newValue; } graphSummaryCache.setOwner( this ); setUpdateMutableFields( true ); } } else if ( dbValue == null && graphSummaryCache == null ) { graphSummaryCache = org.webcat.grader.graphs.AssignmentSummary .objectWithArchiveData( dbValue ); graphSummaryCache.setOwner( this ); setUpdateMutableFields( true ); } return graphSummaryCache; } // ---------------------------------------------------------- /** * Change the value of this object's <code>graphSummary</code> * property. * * @param value The new value for this property */ public void setGraphSummary( org.webcat.grader.graphs.AssignmentSummary value ) { if (log.isDebugEnabled()) { log.debug( "setGraphSummary(" + value + ")" ); } if ( graphSummaryCache == null ) { graphSummaryCache = value; value.setHasChanged( false ); graphSummaryRawCache = value.archiveData(); takeStoredValueForKey( graphSummaryRawCache, "graphSummary" ); } else if ( graphSummaryCache != value ) // ( graphSummaryCache != null ) { graphSummaryCache.copyFrom( value ); setUpdateMutableFields( true ); } else // ( graphSummaryCache == non-null value ) { // no nothing } } // ---------------------------------------------------------- /** * Clear the value of this object's <code>graphSummary</code> * property. */ public void clearGraphSummary() { if (log.isDebugEnabled()) { log.debug( "clearGraphSummary()" ); } takeStoredValueForKey( null, "graphSummary" ); graphSummaryRawCache = null; graphSummaryCache = null; } // ---------------------------------------------------------- /** * Retrieve this object's <code>lastModified</code> value. * @return the value of the attribute */ public NSTimestamp lastModified() { return (NSTimestamp)storedValueForKey( "lastModified" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>lastModified</code> * property. * * @param value The new value for this property */ public void setLastModified( NSTimestamp value ) { if (log.isDebugEnabled()) { log.debug( "setLastModified(" + value + "): was " + lastModified() ); } takeStoredValueForKey( value, "lastModified" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>moodleId</code> value. * @return the value of the attribute */ public Long moodleId() { return (Long)storedValueForKey( "moodleId" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>moodleId</code> * property. * * @param value The new value for this property */ public void setMoodleId( Long value ) { if (log.isDebugEnabled()) { log.debug( "setMoodleId(" + value + "): was " + moodleId() ); } takeStoredValueForKey( value, "moodleId" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>publish</code> value. * @return the value of the attribute */ public boolean publish() { Integer returnValue = (Integer)storedValueForKey( "publish" ); return ( returnValue == null ) ? false : ( returnValue.intValue() > 0 ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>publish</code> * property. * * @param value The new value for this property */ public void setPublish( boolean value ) { if (log.isDebugEnabled()) { log.debug( "setPublish(" + value + "): was " + publish() ); } Integer actual = er.extensions.eof.ERXConstant.integerForInt( value ? 1 : 0 ); setPublishRaw( actual ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>publish</code> value. * @return the value of the attribute */ public Integer publishRaw() { return (Integer)storedValueForKey( "publish" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>publish</code> * property. * * @param value The new value for this property */ public void setPublishRaw( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setPublishRaw(" + value + "): was " + publishRaw() ); } takeStoredValueForKey( value, "publish" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>updateMutableFields</code> value. * @return the value of the attribute */ public boolean updateMutableFields() { Integer returnValue = (Integer)storedValueForKey( "updateMutableFields" ); return ( returnValue == null ) ? false : ( returnValue.intValue() > 0 ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>updateMutableFields</code> * property. * * @param value The new value for this property */ public void setUpdateMutableFields( boolean value ) { if (log.isDebugEnabled()) { log.debug( "setUpdateMutableFields(" + value + "): was " + updateMutableFields() ); } Integer actual = er.extensions.eof.ERXConstant.integerForInt( value ? 1 : 0 ); setUpdateMutableFieldsRaw( actual ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>updateMutableFields</code> value. * @return the value of the attribute */ public Integer updateMutableFieldsRaw() { return (Integer)storedValueForKey( "updateMutableFields" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>updateMutableFields</code> * property. * * @param value The new value for this property */ public void setUpdateMutableFieldsRaw( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setUpdateMutableFieldsRaw(" + value + "): was " + updateMutableFieldsRaw() ); } takeStoredValueForKey( value, "updateMutableFields" ); } // ---------------------------------------------------------- /** * Called just before this object is saved to the database. */ public void saveMutables() { log.debug("saveMutables()"); if ( graphSummaryCache != null && graphSummaryCache.hasChanged() ) { graphSummaryRawCache = graphSummaryCache.archiveData(); takeStoredValueForKey( graphSummaryRawCache, "graphSummary" ); graphSummaryCache.setHasChanged( false ); } setUpdateMutableFields( false ); } // ---------------------------------------------------------- /** * Called just before this object is saved to the database. */ public void willUpdate() { log.debug("willUpdate()"); saveMutables(); super.willUpdate(); } // ---------------------------------------------------------- /** * Called just before this object is inserted into the database. */ public void willInsert() { log.debug("willInsert()"); saveMutables(); super.willInsert(); } // ---------------------------------------------------------- /** * Called when the object is invalidated. */ public void flushCaches() { log.debug("flushCaches()"); graphSummaryCache = null; graphSummaryRawCache = null; super.flushCaches(); } // ---------------------------------------------------------- /** * Called when an owned mutable container object is changed. */ public void mutableContainerHasChanged() { setUpdateMutableFields( true ); } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>assignment</code> * relationship. * @return the entity in the relationship */ public org.webcat.grader.Assignment assignment() { return (org.webcat.grader.Assignment)storedValueForKey( "assignment" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>assignment</code> * relationship (DO NOT USE--instead, use * <code>setAssignmentRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setAssignment( org.webcat.grader.Assignment value ) { if (log.isDebugEnabled()) { log.debug( "setAssignment(" + value + "): was " + assignment() ); } takeStoredValueForKey( value, "assignment" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>assignment</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setAssignmentRelationship( org.webcat.grader.Assignment value ) { if (log.isDebugEnabled()) { log.debug( "setAssignmentRelationship(" + value + "): was " + assignment() ); } if ( value == null ) { org.webcat.grader.Assignment object = assignment(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "assignment" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "assignment" ); } } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>courseOffering</code> * relationship. * @return the entity in the relationship */ public org.webcat.core.CourseOffering courseOffering() { return (org.webcat.core.CourseOffering)storedValueForKey( "courseOffering" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>courseOffering</code> * relationship (DO NOT USE--instead, use * <code>setCourseOfferingRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setCourseOffering( org.webcat.core.CourseOffering value ) { if (log.isDebugEnabled()) { log.debug( "setCourseOffering(" + value + "): was " + courseOffering() ); } takeStoredValueForKey( value, "courseOffering" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>courseOffering</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setCourseOfferingRelationship( org.webcat.core.CourseOffering value ) { if (log.isDebugEnabled()) { log.debug( "setCourseOfferingRelationship(" + value + "): was " + courseOffering() ); } if ( value == null ) { org.webcat.core.CourseOffering object = courseOffering(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "courseOffering" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "courseOffering" ); } } // ---------------------------------------------------------- /** * 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>submissions</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.grader.Submission> submissions() { return (NSArray)storedValueForKey( "submissions" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>submissions</code> relationship. * * @param value The new set of entities to relate to */ public void setSubmissions( NSMutableArray<org.webcat.grader.Submission> value ) { if (log.isDebugEnabled()) { log.debug( "setSubmissions(" + value + "): was " + submissions() ); } takeStoredValueForKey( value, "submissions" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>submissions</code> * relationship (DO NOT USE--instead, use * <code>addToSubmissionsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToSubmissions( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "addToSubmissions(" + value + "): was " + submissions() ); } NSMutableArray<org.webcat.grader.Submission> array = (NSMutableArray<org.webcat.grader.Submission>)submissions(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>submissions</code> * relationship (DO NOT USE--instead, use * <code>removeFromSubmissionsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromSubmissions( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromSubmissions(" + value + "): was " + submissions() ); } NSMutableArray<org.webcat.grader.Submission> array = (NSMutableArray<org.webcat.grader.Submission>)submissions(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>submissions</code> * relationship. * * @param value The new entity to relate to */ public void addToSubmissionsRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "addToSubmissionsRelationship(" + value + "): was " + submissions() ); } addObjectToBothSidesOfRelationshipWithKey( value, "submissions" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>submissions</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromSubmissionsRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "removeFromSubmissionsRelationship(" + value + "): was " + submissions() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "submissions" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>submissions</code> relationship. * * @return The new entity */ public org.webcat.grader.Submission createSubmissionsRelationship() { if (log.isDebugEnabled()) { log.debug( "createSubmissionsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "Submission" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "submissions" ); return (org.webcat.grader.Submission)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>submissions</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteSubmissionsRelationship( org.webcat.grader.Submission value ) { if (log.isDebugEnabled()) { log.debug( "deleteSubmissionsRelationship(" + value + "): was " + submissions() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "submissions" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>submissions</code> relationship. */ public void deleteAllSubmissionsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllSubmissionsRelationships(): was " + submissions() ); } for (org.webcat.grader.Submission object : submissions()) { deleteSubmissionsRelationship(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<AssignmentOffering> 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<AssignmentOffering> 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<AssignmentOffering> 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<AssignmentOffering> 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 AssignmentOffering firstObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { NSArray<AssignmentOffering> 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 AssignmentOffering uniqueObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier) throws EOUtilities.MoreThanOneException { NSArray<AssignmentOffering> objects = objectsMatchingQualifier(context, qualifier); if (objects.size() > 1) { String msg = "fetching AssignmentOffering"; 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<AssignmentOffering> 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<AssignmentOffering> 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 AssignmentOffering 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 AssignmentOffering 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<AssignmentOffering> 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 AssignmentOffering 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 AssignmentOffering uniqueObjectMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) throws EOUtilities.MoreThanOneException { try { return (AssignmentOffering)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 objects according to the <code>allOfferingsOrderedByDueDate</code> * fetch specification. * * @param context The editing context to use * @return an NSArray of the entities retrieved */ public static NSArray<AssignmentOffering> allOfferingsOrderedByDueDate( EOEditingContext context) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("allOfferingsOrderedByDueDate", "AssignmentOffering"); NSArray<AssignmentOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("allOfferingsOrderedByDueDate(ec" + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsForCourse</code> * fetch specification. * * @param context The editing context to use * @param courseBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<AssignmentOffering> offeringsForCourse( EOEditingContext context, org.webcat.core.Course courseBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsForCourse", "AssignmentOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (courseBinding != null) { bindings.setObjectForKey(courseBinding, "course"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<AssignmentOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsForCourse(ec" + ", " + courseBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsForCourseOffering</code> * fetch specification. * * @param context The editing context to use * @param courseOfferingBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<AssignmentOffering> offeringsForCourseOffering( EOEditingContext context, org.webcat.core.CourseOffering courseOfferingBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsForCourseOffering", "AssignmentOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (courseOfferingBinding != null) { bindings.setObjectForKey(courseOfferingBinding, "courseOffering"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<AssignmentOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsForCourseOffering(ec" + ", " + courseOfferingBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsWithUserAsStaff</code> * fetch specification. * * @param context The editing context to use * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<AssignmentOffering> offeringsWithUserAsStaff( EOEditingContext context, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsWithUserAsStaff", "AssignmentOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<AssignmentOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsWithUserAsStaff(ec" + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsWithUserAsStudent</code> * fetch specification. * * @param context The editing context to use * @param userBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<AssignmentOffering> offeringsWithUserAsStudent( EOEditingContext context, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsWithUserAsStudent", "AssignmentOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<AssignmentOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsWithUserAsStudent(ec" + ", " + 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(AssignmentOffering.class); }