/*==========================================================================*\ | _CourseOffering.java |*-------------------------------------------------------------------------*| | Created by eogenerator | DO NOT EDIT. Make changes to CourseOffering.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.core; 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 * CourseOffering.java. * * @author Generated by eogenerator * @version version suppressed to control auto-generation */ public abstract class _CourseOffering extends org.webcat.core.EOBase { //~ Constructors .......................................................... // ---------------------------------------------------------- /** * Creates a new _CourseOffering object. */ public _CourseOffering() { super(); } // ---------------------------------------------------------- /** * A static factory method for creating a new * CourseOffering object given required * attributes and relationships. * @param editingContext The context in which the new object will be * inserted * @return The newly created object */ public static CourseOffering create( EOEditingContext editingContext ) { CourseOffering eoObject = (CourseOffering) EOUtilities.createAndInsertInstance( editingContext, _CourseOffering.ENTITY_NAME); 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 CourseOffering localInstance( EOEditingContext editingContext, CourseOffering eo) { return (eo == null) ? null : (CourseOffering)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 CourseOffering forId( EOEditingContext ec, int id) { CourseOffering obj = null; if (id > 0) { NSArray<CourseOffering> 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 CourseOffering forId( EOEditingContext ec, String id) { return forId(ec, er.extensions.foundation.ERXValueUtilities.intValue(id)); } //~ Constants (for key names) ............................................. // Attributes --- public static final String CRN_KEY = "crn"; public static final ERXKey<String> crn = new ERXKey<String>(CRN_KEY); public static final String LABEL_KEY = "label"; public static final ERXKey<String> label = new ERXKey<String>(LABEL_KEY); public static final String MOODLE_GROUP_ID_KEY = "moodleGroupId"; public static final ERXKey<Long> moodleGroupId = new ERXKey<Long>(MOODLE_GROUP_ID_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 URL_KEY = "url"; public static final ERXKey<String> url = new ERXKey<String>(URL_KEY); // To-one relationships --- public static final String COURSE_KEY = "course"; public static final ERXKey<org.webcat.core.Course> course = new ERXKey<org.webcat.core.Course>(COURSE_KEY); public static final String SEMESTER_KEY = "semester"; public static final ERXKey<org.webcat.core.Semester> semester = new ERXKey<org.webcat.core.Semester>(SEMESTER_KEY); // To-many relationships --- public static final String CORE_SELECTIONS_KEY = "coreSelections"; public static final ERXKey<org.webcat.core.CoreSelections> coreSelections = new ERXKey<org.webcat.core.CoreSelections>(CORE_SELECTIONS_KEY); public static final String GRADERS_KEY = "graders"; public static final ERXKey<org.webcat.core.User> graders = new ERXKey<org.webcat.core.User>(GRADERS_KEY); public static final String INSTRUCTORS_KEY = "instructors"; public static final ERXKey<org.webcat.core.User> instructors = new ERXKey<org.webcat.core.User>(INSTRUCTORS_KEY); public static final String STUDENTS_KEY = "students"; public static final ERXKey<org.webcat.core.User> students = new ERXKey<org.webcat.core.User>(STUDENTS_KEY); // Fetch specifications --- public static final String OFFERINGS_FOR_SEMESTER_FSPEC = "offeringsForSemester"; public static final String OFFERINGS_FOR_SEMESTER_AND_COURSE_FSPEC = "offeringsForSemesterAndCourse"; public static final String OFFERINGS_WITHOUT_ANY_RELATIONSHIP_TO_USER_FSPEC = "offeringsWithoutAnyRelationshipToUser"; public static final String OFFERINGS_WITHOUT_STUDENT_FSPEC = "offeringsWithoutStudent"; public static final String OFFERINGS_WITHOUT_STUDENT_OR_GRADER_FSPEC = "offeringsWithoutStudentOrGrader"; public static final String OFFERINGS_WITHOUT_USER_AS_STAFF_FSPEC = "offeringsWithoutUserAsStaff"; public static final String ENTITY_NAME = "CourseOffering"; 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 CourseOffering localInstance(EOEditingContext editingContext) { return (CourseOffering)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>crn</code> value. * @return the value of the attribute */ public String crn() { return (String)storedValueForKey( "crn" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>crn</code> * property. * * @param value The new value for this property */ public void setCrn( String value ) { if (log.isDebugEnabled()) { log.debug( "setCrn(" + value + "): was " + crn() ); } takeStoredValueForKey( value, "crn" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>label</code> value. * @return the value of the attribute */ public String label() { return (String)storedValueForKey( "label" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>label</code> * property. * * @param value The new value for this property */ public void setLabel( String value ) { if (log.isDebugEnabled()) { log.debug( "setLabel(" + value + "): was " + label() ); } takeStoredValueForKey( value, "label" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>moodleGroupId</code> value. * @return the value of the attribute */ public Long moodleGroupId() { return (Long)storedValueForKey( "moodleGroupId" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>moodleGroupId</code> * property. * * @param value The new value for this property */ public void setMoodleGroupId( Long value ) { if (log.isDebugEnabled()) { log.debug( "setMoodleGroupId(" + value + "): was " + moodleGroupId() ); } takeStoredValueForKey( value, "moodleGroupId" ); } // ---------------------------------------------------------- /** * 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>url</code> value. * @return the value of the attribute */ public String url() { return (String)storedValueForKey( "url" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>url</code> * property. * * @param value The new value for this property */ public void setUrl( String value ) { if (log.isDebugEnabled()) { log.debug( "setUrl(" + value + "): was " + url() ); } takeStoredValueForKey( value, "url" ); } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>course</code> * relationship. * @return the entity in the relationship */ public org.webcat.core.Course course() { return (org.webcat.core.Course)storedValueForKey( "course" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>course</code> * relationship (DO NOT USE--instead, use * <code>setCourseRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setCourse( org.webcat.core.Course value ) { if (log.isDebugEnabled()) { log.debug( "setCourse(" + value + "): was " + course() ); } takeStoredValueForKey( value, "course" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>course</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setCourseRelationship( org.webcat.core.Course value ) { if (log.isDebugEnabled()) { log.debug( "setCourseRelationship(" + value + "): was " + course() ); } if ( value == null ) { org.webcat.core.Course object = course(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "course" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "course" ); } } // ---------------------------------------------------------- /** * Retrieve the entity pointed to by the <code>semester</code> * relationship. * @return the entity in the relationship */ public org.webcat.core.Semester semester() { return (org.webcat.core.Semester)storedValueForKey( "semester" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>semester</code> * relationship (DO NOT USE--instead, use * <code>setSemesterRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setSemester( org.webcat.core.Semester value ) { if (log.isDebugEnabled()) { log.debug( "setSemester(" + value + "): was " + semester() ); } takeStoredValueForKey( value, "semester" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>semester</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setSemesterRelationship( org.webcat.core.Semester value ) { if (log.isDebugEnabled()) { log.debug( "setSemesterRelationship(" + value + "): was " + semester() ); } if ( value == null ) { org.webcat.core.Semester object = semester(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "semester" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "semester" ); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>coreSelections</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.core.CoreSelections> coreSelections() { return (NSArray)storedValueForKey( "coreSelections" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>coreSelections</code> relationship. * * @param value The new set of entities to relate to */ public void setCoreSelections( NSMutableArray<org.webcat.core.CoreSelections> value ) { if (log.isDebugEnabled()) { log.debug( "setCoreSelections(" + value + "): was " + coreSelections() ); } takeStoredValueForKey( value, "coreSelections" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>coreSelections</code> * relationship (DO NOT USE--instead, use * <code>addToCoreSelectionsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToCoreSelections( org.webcat.core.CoreSelections value ) { if (log.isDebugEnabled()) { log.debug( "addToCoreSelections(" + value + "): was " + coreSelections() ); } NSMutableArray<org.webcat.core.CoreSelections> array = (NSMutableArray<org.webcat.core.CoreSelections>)coreSelections(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>coreSelections</code> * relationship (DO NOT USE--instead, use * <code>removeFromCoreSelectionsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromCoreSelections( org.webcat.core.CoreSelections value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromCoreSelections(" + value + "): was " + coreSelections() ); } NSMutableArray<org.webcat.core.CoreSelections> array = (NSMutableArray<org.webcat.core.CoreSelections>)coreSelections(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>coreSelections</code> * relationship. * * @param value The new entity to relate to */ public void addToCoreSelectionsRelationship( org.webcat.core.CoreSelections value ) { if (log.isDebugEnabled()) { log.debug( "addToCoreSelectionsRelationship(" + value + "): was " + coreSelections() ); } addObjectToBothSidesOfRelationshipWithKey( value, "coreSelections" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>coreSelections</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromCoreSelectionsRelationship( org.webcat.core.CoreSelections value ) { if (log.isDebugEnabled()) { log.debug( "removeFromCoreSelectionsRelationship(" + value + "): was " + coreSelections() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "coreSelections" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>coreSelections</code> relationship. * * @return The new entity */ public org.webcat.core.CoreSelections createCoreSelectionsRelationship() { if (log.isDebugEnabled()) { log.debug( "createCoreSelectionsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "CoreSelections" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "coreSelections" ); return (org.webcat.core.CoreSelections)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>coreSelections</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteCoreSelectionsRelationship( org.webcat.core.CoreSelections value ) { if (log.isDebugEnabled()) { log.debug( "deleteCoreSelectionsRelationship(" + value + "): was " + coreSelections() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "coreSelections" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>coreSelections</code> relationship. */ public void deleteAllCoreSelectionsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllCoreSelectionsRelationships(): was " + coreSelections() ); } for (org.webcat.core.CoreSelections object : coreSelections()) { deleteCoreSelectionsRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>graders</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.core.User> graders() { return (NSArray)storedValueForKey( "graders" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>graders</code> relationship. * * @param value The new set of entities to relate to */ public void setGraders( NSMutableArray<org.webcat.core.User> value ) { if (log.isDebugEnabled()) { log.debug( "setGraders(" + value + "): was " + graders() ); } takeStoredValueForKey( value, "graders" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>graders</code> * relationship (DO NOT USE--instead, use * <code>addToGradersRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToGraders( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToGraders(" + value + "): was " + graders() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)graders(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>graders</code> * relationship (DO NOT USE--instead, use * <code>removeFromGradersRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromGraders( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromGraders(" + value + "): was " + graders() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)graders(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>graders</code> * relationship. * * @param value The new entity to relate to */ public void addToGradersRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToGradersRelationship(" + value + "): was " + graders() ); } addObjectToBothSidesOfRelationshipWithKey( value, "graders" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>graders</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromGradersRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "removeFromGradersRelationship(" + value + "): was " + graders() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "graders" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>graders</code> relationship. * * @return The new entity */ public org.webcat.core.User createGradersRelationship() { if (log.isDebugEnabled()) { log.debug( "createGradersRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "User" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "graders" ); return (org.webcat.core.User)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>graders</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteGradersRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "deleteGradersRelationship(" + value + "): was " + graders() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "graders" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>graders</code> relationship. */ public void deleteAllGradersRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllGradersRelationships(): was " + graders() ); } for (org.webcat.core.User object : graders()) { deleteGradersRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>instructors</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.core.User> instructors() { return (NSArray)storedValueForKey( "instructors" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>instructors</code> relationship. * * @param value The new set of entities to relate to */ public void setInstructors( NSMutableArray<org.webcat.core.User> value ) { if (log.isDebugEnabled()) { log.debug( "setInstructors(" + value + "): was " + instructors() ); } takeStoredValueForKey( value, "instructors" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>instructors</code> * relationship (DO NOT USE--instead, use * <code>addToInstructorsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToInstructors( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToInstructors(" + value + "): was " + instructors() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)instructors(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>instructors</code> * relationship (DO NOT USE--instead, use * <code>removeFromInstructorsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromInstructors( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromInstructors(" + value + "): was " + instructors() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)instructors(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>instructors</code> * relationship. * * @param value The new entity to relate to */ public void addToInstructorsRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToInstructorsRelationship(" + value + "): was " + instructors() ); } addObjectToBothSidesOfRelationshipWithKey( value, "instructors" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>instructors</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromInstructorsRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "removeFromInstructorsRelationship(" + value + "): was " + instructors() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "instructors" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>instructors</code> relationship. * * @return The new entity */ public org.webcat.core.User createInstructorsRelationship() { if (log.isDebugEnabled()) { log.debug( "createInstructorsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "User" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "instructors" ); return (org.webcat.core.User)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>instructors</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteInstructorsRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "deleteInstructorsRelationship(" + value + "): was " + instructors() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "instructors" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>instructors</code> relationship. */ public void deleteAllInstructorsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllInstructorsRelationships(): was " + instructors() ); } for (org.webcat.core.User object : instructors()) { deleteInstructorsRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>students</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.core.User> students() { return (NSArray)storedValueForKey( "students" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>students</code> relationship. * * @param value The new set of entities to relate to */ public void setStudents( NSMutableArray<org.webcat.core.User> value ) { if (log.isDebugEnabled()) { log.debug( "setStudents(" + value + "): was " + students() ); } takeStoredValueForKey( value, "students" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>students</code> * relationship (DO NOT USE--instead, use * <code>addToStudentsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToStudents( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToStudents(" + value + "): was " + students() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)students(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>students</code> * relationship (DO NOT USE--instead, use * <code>removeFromStudentsRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromStudents( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromStudents(" + value + "): was " + students() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)students(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>students</code> * relationship. * * @param value The new entity to relate to */ public void addToStudentsRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToStudentsRelationship(" + value + "): was " + students() ); } addObjectToBothSidesOfRelationshipWithKey( value, "students" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>students</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromStudentsRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "removeFromStudentsRelationship(" + value + "): was " + students() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "students" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>students</code> relationship. * * @return The new entity */ public org.webcat.core.User createStudentsRelationship() { if (log.isDebugEnabled()) { log.debug( "createStudentsRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "User" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "students" ); return (org.webcat.core.User)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>students</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteStudentsRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "deleteStudentsRelationship(" + value + "): was " + students() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "students" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>students</code> relationship. */ public void deleteAllStudentsRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllStudentsRelationships(): was " + students() ); } for (org.webcat.core.User object : students()) { deleteStudentsRelationship(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<CourseOffering> 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<CourseOffering> 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<CourseOffering> 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<CourseOffering> 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 CourseOffering firstObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { NSArray<CourseOffering> 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 CourseOffering uniqueObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier) throws EOUtilities.MoreThanOneException { NSArray<CourseOffering> objects = objectsMatchingQualifier(context, qualifier); if (objects.size() > 1) { String msg = "fetching CourseOffering"; 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<CourseOffering> 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<CourseOffering> 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 CourseOffering 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 CourseOffering 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<CourseOffering> 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 CourseOffering 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 CourseOffering uniqueObjectMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) throws EOUtilities.MoreThanOneException { try { return (CourseOffering)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>offeringsForSemester</code> * fetch specification. * * @param context The editing context to use * @param semesterBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<CourseOffering> offeringsForSemester( EOEditingContext context, org.webcat.core.Semester semesterBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsForSemester", "CourseOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (semesterBinding != null) { bindings.setObjectForKey(semesterBinding, "semester"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<CourseOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsForSemester(ec" + ", " + semesterBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsForSemesterAndCourse</code> * fetch specification. * * @param context The editing context to use * @param courseBinding fetch spec parameter * @param semesterBinding fetch spec parameter * @return an NSArray of the entities retrieved */ public static NSArray<CourseOffering> offeringsForSemesterAndCourse( EOEditingContext context, org.webcat.core.Course courseBinding, org.webcat.core.Semester semesterBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsForSemesterAndCourse", "CourseOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (courseBinding != null) { bindings.setObjectForKey(courseBinding, "course"); } if (semesterBinding != null) { bindings.setObjectForKey(semesterBinding, "semester"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<CourseOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsForSemesterAndCourse(ec" + ", " + courseBinding + ", " + semesterBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsWithoutAnyRelationshipToUser</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<CourseOffering> offeringsWithoutAnyRelationshipToUser( EOEditingContext context, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsWithoutAnyRelationshipToUser", "CourseOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<CourseOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsWithoutAnyRelationshipToUser(ec" + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsWithoutStudent</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<CourseOffering> offeringsWithoutStudent( EOEditingContext context, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsWithoutStudent", "CourseOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<CourseOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsWithoutStudent(ec" + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsWithoutStudentOrGrader</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<CourseOffering> offeringsWithoutStudentOrGrader( EOEditingContext context, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsWithoutStudentOrGrader", "CourseOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<CourseOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsWithoutStudentOrGrader(ec" + ", " + userBinding + "): " + objects); } return objects; } // ---------------------------------------------------------- /** * Retrieve objects according to the <code>offeringsWithoutUserAsStaff</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<CourseOffering> offeringsWithoutUserAsStaff( EOEditingContext context, org.webcat.core.User userBinding) { EOFetchSpecification spec = WCFetchSpecification .fetchSpecificationNamed("offeringsWithoutUserAsStaff", "CourseOffering"); NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>(); if (userBinding != null) { bindings.setObjectForKey(userBinding, "user"); } spec = spec.fetchSpecificationWithQualifierBindings(bindings); NSArray<CourseOffering> objects = objectsWithFetchSpecification(context, spec); if (log.isDebugEnabled()) { log.debug("offeringsWithoutUserAsStaff(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(CourseOffering.class); }