/*==========================================================================*\ | _MeasureOfOffering.java |*-------------------------------------------------------------------------*| | Created by eogenerator | DO NOT EDIT. Make changes to MeasureOfOffering.java instead. |*-------------------------------------------------------------------------*| | Copyright (C) 2006-2009 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.outcomesmeasurement; 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; // ------------------------------------------------------------------------- /** * An automatically generated EOGenericRecord subclass. DO NOT EDIT. * To change, use EOModeler, or make additions in * MeasureOfOffering.java. * * @author Generated by eogenerator * @version version suppressed to control auto-generation */ public abstract class _MeasureOfOffering extends er.extensions.eof.ERXGenericRecord { //~ Constructors .......................................................... // ---------------------------------------------------------- /** * Creates a new _MeasureOfOffering object. */ public _MeasureOfOffering() { super(); } // ---------------------------------------------------------- /** * A static factory method for creating a new * MeasureOfOffering 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 MeasureOfOffering create( EOEditingContext editingContext ) { MeasureOfOffering eoObject = (MeasureOfOffering) EOUtilities.createAndInsertInstance( editingContext, _MeasureOfOffering.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 MeasureOfOffering localInstance( EOEditingContext editingContext, MeasureOfOffering eo) { return (eo == null) ? null : (MeasureOfOffering)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 MeasureOfOffering forId( EOEditingContext ec, int id ) { MeasureOfOffering obj = null; if (id > 0) { NSArray<MeasureOfOffering> results = objectsMatchingValues(ec, "id", new Integer(id)); if (results != null && results.count() > 0) { obj = results.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 MeasureOfOffering forId( EOEditingContext ec, String id ) { return forId( ec, er.extensions.foundation.ERXValueUtilities.intValue( id ) ); } //~ Constants (for key names) ............................................. // Attributes --- public static final String ADEQUATE_KEY = "adequate"; public static final ERXKey<Integer> adequate = new ERXKey<Integer>(ADEQUATE_KEY); public static final String ADEQUATE_CRITERIA_KEY = "adequateCriteria"; public static final ERXKey<String> adequateCriteria = new ERXKey<String>(ADEQUATE_CRITERIA_KEY); public static final String DATA_DESCRIPTION_KEY = "dataDescription"; public static final ERXKey<String> dataDescription = new ERXKey<String>(DATA_DESCRIPTION_KEY); public static final String EXCELLENT_KEY = "excellent"; public static final ERXKey<Integer> excellent = new ERXKey<Integer>(EXCELLENT_KEY); public static final String EXCELLENT_CRITERIA_KEY = "excellentCriteria"; public static final ERXKey<String> excellentCriteria = new ERXKey<String>(EXCELLENT_CRITERIA_KEY); public static final String UNSATISFACTORY_KEY = "unsatisfactory"; public static final ERXKey<Integer> unsatisfactory = new ERXKey<Integer>(UNSATISFACTORY_KEY); public static final String UNSATISFACTORY_CRITERIA_KEY = "unsatisfactoryCriteria"; public static final ERXKey<String> unsatisfactoryCriteria = new ERXKey<String>(UNSATISFACTORY_CRITERIA_KEY); // To-one relationships --- 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); public static final String MEASURE_KEY = "measure"; public static final ERXKey<org.webcat.outcomesmeasurement.Measure> measure = new ERXKey<org.webcat.outcomesmeasurement.Measure>(MEASURE_KEY); // To-many relationships --- public static final String MEASURE_CHANGES_KEY = "measureChanges"; public static final ERXKey<org.webcat.outcomesmeasurement.MeasureChange> measureChanges = new ERXKey<org.webcat.outcomesmeasurement.MeasureChange>(MEASURE_CHANGES_KEY); public static final String USERS_KEY = "users"; public static final ERXKey<org.webcat.core.User> users = new ERXKey<org.webcat.core.User>(USERS_KEY); // Fetch specifications --- public static final String ENTITY_NAME = "MeasureOfOffering"; //~ 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 MeasureOfOffering localInstance(EOEditingContext editingContext) { return (MeasureOfOffering)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>adequate</code> value. * @return the value of the attribute */ public Integer adequate() { return (Integer)storedValueForKey( "adequate" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>adequate</code> * property. * * @param value The new value for this property */ public void setAdequate( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setAdequate(" + value + "): was " + adequate() ); } takeStoredValueForKey( value, "adequate" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>adequateCriteria</code> value. * @return the value of the attribute */ public String adequateCriteria() { return (String)storedValueForKey( "adequateCriteria" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>adequateCriteria</code> * property. * * @param value The new value for this property */ public void setAdequateCriteria( String value ) { if (log.isDebugEnabled()) { log.debug( "setAdequateCriteria(" + value + "): was " + adequateCriteria() ); } takeStoredValueForKey( value, "adequateCriteria" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>dataDescription</code> value. * @return the value of the attribute */ public String dataDescription() { return (String)storedValueForKey( "dataDescription" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>dataDescription</code> * property. * * @param value The new value for this property */ public void setDataDescription( String value ) { if (log.isDebugEnabled()) { log.debug( "setDataDescription(" + value + "): was " + dataDescription() ); } takeStoredValueForKey( value, "dataDescription" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>excellent</code> value. * @return the value of the attribute */ public Integer excellent() { return (Integer)storedValueForKey( "excellent" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>excellent</code> * property. * * @param value The new value for this property */ public void setExcellent( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setExcellent(" + value + "): was " + excellent() ); } takeStoredValueForKey( value, "excellent" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>excellentCriteria</code> value. * @return the value of the attribute */ public String excellentCriteria() { return (String)storedValueForKey( "excellentCriteria" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>excellentCriteria</code> * property. * * @param value The new value for this property */ public void setExcellentCriteria( String value ) { if (log.isDebugEnabled()) { log.debug( "setExcellentCriteria(" + value + "): was " + excellentCriteria() ); } takeStoredValueForKey( value, "excellentCriteria" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>unsatisfactory</code> value. * @return the value of the attribute */ public Integer unsatisfactory() { return (Integer)storedValueForKey( "unsatisfactory" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>unsatisfactory</code> * property. * * @param value The new value for this property */ public void setUnsatisfactory( Integer value ) { if (log.isDebugEnabled()) { log.debug( "setUnsatisfactory(" + value + "): was " + unsatisfactory() ); } takeStoredValueForKey( value, "unsatisfactory" ); } // ---------------------------------------------------------- /** * Retrieve this object's <code>unsatisfactoryCriteria</code> value. * @return the value of the attribute */ public String unsatisfactoryCriteria() { return (String)storedValueForKey( "unsatisfactoryCriteria" ); } // ---------------------------------------------------------- /** * Change the value of this object's <code>unsatisfactoryCriteria</code> * property. * * @param value The new value for this property */ public void setUnsatisfactoryCriteria( String value ) { if (log.isDebugEnabled()) { log.debug( "setUnsatisfactoryCriteria(" + value + "): was " + unsatisfactoryCriteria() ); } takeStoredValueForKey( value, "unsatisfactoryCriteria" ); } // ---------------------------------------------------------- /** * 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 entity pointed to by the <code>measure</code> * relationship. * @return the entity in the relationship */ public org.webcat.outcomesmeasurement.Measure measure() { return (org.webcat.outcomesmeasurement.Measure)storedValueForKey( "measure" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>measure</code> * relationship (DO NOT USE--instead, use * <code>setMeasureRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void setMeasure( org.webcat.outcomesmeasurement.Measure value ) { if (log.isDebugEnabled()) { log.debug( "setMeasure(" + value + "): was " + measure() ); } takeStoredValueForKey( value, "measure" ); } // ---------------------------------------------------------- /** * Set the entity pointed to by the <code>measure</code> * relationship. This method is a type-safe version of * <code>addObjectToBothSidesOfRelationshipWithKey()</code>. * * @param value The new entity to relate to */ public void setMeasureRelationship( org.webcat.outcomesmeasurement.Measure value ) { if (log.isDebugEnabled()) { log.debug( "setMeasureRelationship(" + value + "): was " + measure() ); } if ( value == null ) { org.webcat.outcomesmeasurement.Measure object = measure(); if ( object != null ) removeObjectFromBothSidesOfRelationshipWithKey( object, "measure" ); } else { addObjectToBothSidesOfRelationshipWithKey( value, "measure" ); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>measureChanges</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.outcomesmeasurement.MeasureChange> measureChanges() { return (NSArray)storedValueForKey( "measureChanges" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>measureChanges</code> relationship. * * @param value The new set of entities to relate to */ public void setMeasureChanges( NSMutableArray<org.webcat.outcomesmeasurement.MeasureChange> value ) { if (log.isDebugEnabled()) { log.debug( "setMeasureChanges(" + value + "): was " + measureChanges() ); } takeStoredValueForKey( value, "measureChanges" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>measureChanges</code> * relationship (DO NOT USE--instead, use * <code>addToMeasureChangesRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToMeasureChanges( org.webcat.outcomesmeasurement.MeasureChange value ) { if (log.isDebugEnabled()) { log.debug( "addToMeasureChanges(" + value + "): was " + measureChanges() ); } NSMutableArray<org.webcat.outcomesmeasurement.MeasureChange> array = (NSMutableArray<org.webcat.outcomesmeasurement.MeasureChange>)measureChanges(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>measureChanges</code> * relationship (DO NOT USE--instead, use * <code>removeFromMeasureChangesRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromMeasureChanges( org.webcat.outcomesmeasurement.MeasureChange value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromMeasureChanges(" + value + "): was " + measureChanges() ); } NSMutableArray<org.webcat.outcomesmeasurement.MeasureChange> array = (NSMutableArray<org.webcat.outcomesmeasurement.MeasureChange>)measureChanges(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>measureChanges</code> * relationship. * * @param value The new entity to relate to */ public void addToMeasureChangesRelationship( org.webcat.outcomesmeasurement.MeasureChange value ) { if (log.isDebugEnabled()) { log.debug( "addToMeasureChangesRelationship(" + value + "): was " + measureChanges() ); } addObjectToBothSidesOfRelationshipWithKey( value, "measureChanges" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>measureChanges</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromMeasureChangesRelationship( org.webcat.outcomesmeasurement.MeasureChange value ) { if (log.isDebugEnabled()) { log.debug( "removeFromMeasureChangesRelationship(" + value + "): was " + measureChanges() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "measureChanges" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>measureChanges</code> relationship. * * @return The new entity */ public org.webcat.outcomesmeasurement.MeasureChange createMeasureChangesRelationship() { if (log.isDebugEnabled()) { log.debug( "createMeasureChangesRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "MeasureChange" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "measureChanges" ); return (org.webcat.outcomesmeasurement.MeasureChange)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>measureChanges</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteMeasureChangesRelationship( org.webcat.outcomesmeasurement.MeasureChange value ) { if (log.isDebugEnabled()) { log.debug( "deleteMeasureChangesRelationship(" + value + "): was " + measureChanges() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "measureChanges" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>measureChanges</code> relationship. */ public void deleteAllMeasureChangesRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllMeasureChangesRelationships(): was " + measureChanges() ); } for (org.webcat.outcomesmeasurement.MeasureChange object : measureChanges()) { deleteMeasureChangesRelationship(object); } } // ---------------------------------------------------------- /** * Retrieve the entities pointed to by the <code>users</code> * relationship. * @return an NSArray of the entities in the relationship */ @SuppressWarnings("unchecked") public NSArray<org.webcat.core.User> users() { return (NSArray)storedValueForKey( "users" ); } // ---------------------------------------------------------- /** * Replace the list of entities pointed to by the * <code>users</code> relationship. * * @param value The new set of entities to relate to */ public void setUsers( NSMutableArray<org.webcat.core.User> value ) { if (log.isDebugEnabled()) { log.debug( "setUsers(" + value + "): was " + users() ); } takeStoredValueForKey( value, "users" ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>users</code> * relationship (DO NOT USE--instead, use * <code>addToUsersRelationship()</code>. * This method is provided for WebObjects use. * * @param value The new entity to relate to */ public void addToUsers( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToUsers(" + value + "): was " + users() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)users(); willChange(); array.addObject( value ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>users</code> * relationship (DO NOT USE--instead, use * <code>removeFromUsersRelationship()</code>. * This method is provided for WebObjects use. * * @param value The entity to remove from the relationship */ public void removeFromUsers( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "RemoveFromUsers(" + value + "): was " + users() ); } NSMutableArray<org.webcat.core.User> array = (NSMutableArray<org.webcat.core.User>)users(); willChange(); array.removeObject( value ); } // ---------------------------------------------------------- /** * Add a new entity to the <code>users</code> * relationship. * * @param value The new entity to relate to */ public void addToUsersRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "addToUsersRelationship(" + value + "): was " + users() ); } addObjectToBothSidesOfRelationshipWithKey( value, "users" ); } // ---------------------------------------------------------- /** * Remove a specific entity from the <code>users</code> * relationship. * * @param value The entity to remove from the relationship */ public void removeFromUsersRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "removeFromUsersRelationship(" + value + "): was " + users() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "users" ); } // ---------------------------------------------------------- /** * Create a brand new object that is a member of the * <code>users</code> relationship. * * @return The new entity */ public org.webcat.core.User createUsersRelationship() { if (log.isDebugEnabled()) { log.debug( "createUsersRelationship()" ); } EOClassDescription eoClassDesc = EOClassDescription .classDescriptionForEntityName( "User" ); EOEnterpriseObject eoObject = eoClassDesc .createInstanceWithEditingContext( editingContext(), null ); editingContext().insertObject( eoObject ); addObjectToBothSidesOfRelationshipWithKey( eoObject, "users" ); return (org.webcat.core.User)eoObject; } // ---------------------------------------------------------- /** * Remove and then delete a specific entity that is a member of the * <code>users</code> relationship. * * @param value The entity to remove from the relationship and then delete */ public void deleteUsersRelationship( org.webcat.core.User value ) { if (log.isDebugEnabled()) { log.debug( "deleteUsersRelationship(" + value + "): was " + users() ); } removeObjectFromBothSidesOfRelationshipWithKey( value, "users" ); editingContext().deleteObject( value ); } // ---------------------------------------------------------- /** * Remove (and then delete, if owned) all entities that are members of the * <code>users</code> relationship. */ public void deleteAllUsersRelationships() { if (log.isDebugEnabled()) { log.debug( "deleteAllUsersRelationships(): was " + users() ); } for (org.webcat.core.User object : users()) { deleteUsersRelationship(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<MeasureOfOffering> 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<MeasureOfOffering> 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<MeasureOfOffering> 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<MeasureOfOffering> objectsMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { EOFetchSpecification fspec = new EOFetchSpecification( 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 MeasureOfOffering firstObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { NSArray<MeasureOfOffering> results = objectsMatchingQualifier(context, qualifier, sortOrderings); return (results.size() > 0) ? results.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 MeasureOfOffering uniqueObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier) throws EOUtilities.MoreThanOneException { NSArray<MeasureOfOffering> results = objectsMatchingQualifier(context, qualifier); if (results.size() > 1) { throw new EOUtilities.MoreThanOneException(null); } return (results.size() > 0) ? results.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<MeasureOfOffering> objectsMatchingValues( EOEditingContext context, Object... keysAndValues) { if (keysAndValues.length % 2 != 0) { throw new IllegalArgumentException("There should a value " + "corresponding to every key that was passed."); } 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 instanceof String)) { throw new IllegalArgumentException("Keys should be strings."); } 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<MeasureOfOffering> 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 MeasureOfOffering 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."); } 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 instanceof String)) { throw new IllegalArgumentException("Keys should be strings."); } 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 MeasureOfOffering firstObjectMatchingValues( EOEditingContext context, NSArray<EOSortOrdering> sortOrderings, NSDictionary<String, Object> keysAndValues) { EOFetchSpecification fspec = new EOFetchSpecification( ENTITY_NAME, EOQualifier.qualifierToMatchAllValues(keysAndValues), sortOrderings); fspec.setFetchLimit(1); NSArray<MeasureOfOffering> result = objectsWithFetchSpecification( context, fspec ); if ( result.count() == 0 ) { return null; } else { return result.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 MeasureOfOffering 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."); } 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 instanceof String)) { throw new IllegalArgumentException("Keys should be strings."); } 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 MeasureOfOffering uniqueObjectMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) throws EOUtilities.MoreThanOneException { try { return (MeasureOfOffering)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."); } 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 instanceof String)) { throw new IllegalArgumentException("Keys should be strings."); } 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 */ @SuppressWarnings("unchecked") public static int countOfObjectsMatchingValues( EOEditingContext context, NSDictionary<String, Object> keysAndValues) { return countOfObjectsMatchingQualifier(context, EOQualifier.qualifierToMatchAllValues(keysAndValues)); } // ---------------------------------------------------------- /** * 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( MeasureOfOffering.class ); }