/*==========================================================================*\
| _Measure.java
|*-------------------------------------------------------------------------*|
| Created by eogenerator
| DO NOT EDIT. Make changes to Measure.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
* Measure.java.
*
* @author Generated by eogenerator
* @version version suppressed to control auto-generation
*/
public abstract class _Measure
extends er.extensions.eof.ERXGenericRecord
{
//~ Constructors ..........................................................
// ----------------------------------------------------------
/**
* Creates a new _Measure object.
*/
public _Measure()
{
super();
}
// ----------------------------------------------------------
/**
* A static factory method for creating a new
* Measure 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 Measure create(
EOEditingContext editingContext
)
{
Measure eoObject = (Measure)
EOUtilities.createAndInsertInstance(
editingContext,
_Measure.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 Measure localInstance(
EOEditingContext editingContext, Measure eo)
{
return (eo == null)
? null
: (Measure)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 Measure forId(
EOEditingContext ec, int id )
{
Measure obj = null;
if (id > 0)
{
NSArray<Measure> 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 Measure forId(
EOEditingContext ec, String id )
{
return forId( ec, er.extensions.foundation.ERXValueUtilities.intValue( id ) );
}
//~ Constants (for key names) .............................................
// Attributes ---
public static final String DESCRIPTION_KEY = "description";
public static final ERXKey<String> description =
new ERXKey<String>(DESCRIPTION_KEY);
public static final String KEY_PHRASE_KEY = "keyPhrase";
public static final ERXKey<String> keyPhrase =
new ERXKey<String>(KEY_PHRASE_KEY);
public static final String LABEL_KEY = "label";
public static final ERXKey<String> label =
new ERXKey<String>(LABEL_KEY);
// To-one relationships ---
// To-many relationships ---
public static final String COURSES_KEY = "courses";
public static final ERXKey<org.webcat.core.Course> courses =
new ERXKey<org.webcat.core.Course>(COURSES_KEY);
public static final String MEASURE_OF_OFFERINGS_KEY = "measureOfOfferings";
public static final ERXKey<org.webcat.outcomesmeasurement.MeasureOfOffering> measureOfOfferings =
new ERXKey<org.webcat.outcomesmeasurement.MeasureOfOffering>(MEASURE_OF_OFFERINGS_KEY);
public static final String OUTCOME_PAIRS_KEY = "outcomePairs";
public static final ERXKey<org.webcat.outcomesmeasurement.OutcomePair> outcomePairs =
new ERXKey<org.webcat.outcomesmeasurement.OutcomePair>(OUTCOME_PAIRS_KEY);
// Fetch specifications ---
public static final String ENTITY_NAME = "Measure";
//~ 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 Measure localInstance(EOEditingContext editingContext)
{
return (Measure)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>description</code> value.
* @return the value of the attribute
*/
public String description()
{
return (String)storedValueForKey( "description" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>description</code>
* property.
*
* @param value The new value for this property
*/
public void setDescription( String value )
{
if (log.isDebugEnabled())
{
log.debug( "setDescription("
+ value + "): was " + description() );
}
takeStoredValueForKey( value, "description" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>keyPhrase</code> value.
* @return the value of the attribute
*/
public String keyPhrase()
{
return (String)storedValueForKey( "keyPhrase" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>keyPhrase</code>
* property.
*
* @param value The new value for this property
*/
public void setKeyPhrase( String value )
{
if (log.isDebugEnabled())
{
log.debug( "setKeyPhrase("
+ value + "): was " + keyPhrase() );
}
takeStoredValueForKey( value, "keyPhrase" );
}
// ----------------------------------------------------------
/**
* 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 the entities pointed to by the <code>courses</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.core.Course> courses()
{
return (NSArray)storedValueForKey( "courses" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>courses</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setCourses( NSMutableArray<org.webcat.core.Course> value )
{
if (log.isDebugEnabled())
{
log.debug( "setCourses("
+ value + "): was " + courses() );
}
takeStoredValueForKey( value, "courses" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>courses</code>
* relationship (DO NOT USE--instead, use
* <code>addToCoursesRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToCourses( org.webcat.core.Course value )
{
if (log.isDebugEnabled())
{
log.debug( "addToCourses("
+ value + "): was " + courses() );
}
NSMutableArray<org.webcat.core.Course> array =
(NSMutableArray<org.webcat.core.Course>)courses();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>courses</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromCoursesRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromCourses( org.webcat.core.Course value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromCourses("
+ value + "): was " + courses() );
}
NSMutableArray<org.webcat.core.Course> array =
(NSMutableArray<org.webcat.core.Course>)courses();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>courses</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToCoursesRelationship( org.webcat.core.Course value )
{
if (log.isDebugEnabled())
{
log.debug( "addToCoursesRelationship("
+ value + "): was " + courses() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "courses" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>courses</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromCoursesRelationship( org.webcat.core.Course value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromCoursesRelationship("
+ value + "): was " + courses() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "courses" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>courses</code> relationship.
*
* @return The new entity
*/
public org.webcat.core.Course createCoursesRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createCoursesRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "Course" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "courses" );
return (org.webcat.core.Course)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>courses</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteCoursesRelationship( org.webcat.core.Course value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteCoursesRelationship("
+ value + "): was " + courses() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "courses" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>courses</code> relationship.
*/
public void deleteAllCoursesRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllCoursesRelationships(): was "
+ courses() );
}
for (org.webcat.core.Course object : courses())
{
deleteCoursesRelationship(object);
}
}
// ----------------------------------------------------------
/**
* Retrieve the entities pointed to by the <code>measureOfOfferings</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.outcomesmeasurement.MeasureOfOffering> measureOfOfferings()
{
return (NSArray)storedValueForKey( "measureOfOfferings" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>measureOfOfferings</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setMeasureOfOfferings( NSMutableArray<org.webcat.outcomesmeasurement.MeasureOfOffering> value )
{
if (log.isDebugEnabled())
{
log.debug( "setMeasureOfOfferings("
+ value + "): was " + measureOfOfferings() );
}
takeStoredValueForKey( value, "measureOfOfferings" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>measureOfOfferings</code>
* relationship (DO NOT USE--instead, use
* <code>addToMeasureOfOfferingsRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToMeasureOfOfferings( org.webcat.outcomesmeasurement.MeasureOfOffering value )
{
if (log.isDebugEnabled())
{
log.debug( "addToMeasureOfOfferings("
+ value + "): was " + measureOfOfferings() );
}
NSMutableArray<org.webcat.outcomesmeasurement.MeasureOfOffering> array =
(NSMutableArray<org.webcat.outcomesmeasurement.MeasureOfOffering>)measureOfOfferings();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>measureOfOfferings</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromMeasureOfOfferingsRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromMeasureOfOfferings( org.webcat.outcomesmeasurement.MeasureOfOffering value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromMeasureOfOfferings("
+ value + "): was " + measureOfOfferings() );
}
NSMutableArray<org.webcat.outcomesmeasurement.MeasureOfOffering> array =
(NSMutableArray<org.webcat.outcomesmeasurement.MeasureOfOffering>)measureOfOfferings();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>measureOfOfferings</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToMeasureOfOfferingsRelationship( org.webcat.outcomesmeasurement.MeasureOfOffering value )
{
if (log.isDebugEnabled())
{
log.debug( "addToMeasureOfOfferingsRelationship("
+ value + "): was " + measureOfOfferings() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "measureOfOfferings" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>measureOfOfferings</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromMeasureOfOfferingsRelationship( org.webcat.outcomesmeasurement.MeasureOfOffering value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromMeasureOfOfferingsRelationship("
+ value + "): was " + measureOfOfferings() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "measureOfOfferings" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>measureOfOfferings</code> relationship.
*
* @return The new entity
*/
public org.webcat.outcomesmeasurement.MeasureOfOffering createMeasureOfOfferingsRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createMeasureOfOfferingsRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "MeasureOfOffering" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "measureOfOfferings" );
return (org.webcat.outcomesmeasurement.MeasureOfOffering)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>measureOfOfferings</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteMeasureOfOfferingsRelationship( org.webcat.outcomesmeasurement.MeasureOfOffering value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteMeasureOfOfferingsRelationship("
+ value + "): was " + measureOfOfferings() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "measureOfOfferings" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>measureOfOfferings</code> relationship.
*/
public void deleteAllMeasureOfOfferingsRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllMeasureOfOfferingsRelationships(): was "
+ measureOfOfferings() );
}
for (org.webcat.outcomesmeasurement.MeasureOfOffering object : measureOfOfferings())
{
deleteMeasureOfOfferingsRelationship(object);
}
}
// ----------------------------------------------------------
/**
* Retrieve the entities pointed to by the <code>outcomePairs</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.outcomesmeasurement.OutcomePair> outcomePairs()
{
return (NSArray)storedValueForKey( "outcomePairs" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>outcomePairs</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setOutcomePairs( NSMutableArray<org.webcat.outcomesmeasurement.OutcomePair> value )
{
if (log.isDebugEnabled())
{
log.debug( "setOutcomePairs("
+ value + "): was " + outcomePairs() );
}
takeStoredValueForKey( value, "outcomePairs" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>outcomePairs</code>
* relationship (DO NOT USE--instead, use
* <code>addToOutcomePairsRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToOutcomePairs( org.webcat.outcomesmeasurement.OutcomePair value )
{
if (log.isDebugEnabled())
{
log.debug( "addToOutcomePairs("
+ value + "): was " + outcomePairs() );
}
NSMutableArray<org.webcat.outcomesmeasurement.OutcomePair> array =
(NSMutableArray<org.webcat.outcomesmeasurement.OutcomePair>)outcomePairs();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>outcomePairs</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromOutcomePairsRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromOutcomePairs( org.webcat.outcomesmeasurement.OutcomePair value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromOutcomePairs("
+ value + "): was " + outcomePairs() );
}
NSMutableArray<org.webcat.outcomesmeasurement.OutcomePair> array =
(NSMutableArray<org.webcat.outcomesmeasurement.OutcomePair>)outcomePairs();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>outcomePairs</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToOutcomePairsRelationship( org.webcat.outcomesmeasurement.OutcomePair value )
{
if (log.isDebugEnabled())
{
log.debug( "addToOutcomePairsRelationship("
+ value + "): was " + outcomePairs() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "outcomePairs" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>outcomePairs</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromOutcomePairsRelationship( org.webcat.outcomesmeasurement.OutcomePair value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromOutcomePairsRelationship("
+ value + "): was " + outcomePairs() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "outcomePairs" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>outcomePairs</code> relationship.
*
* @return The new entity
*/
public org.webcat.outcomesmeasurement.OutcomePair createOutcomePairsRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createOutcomePairsRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "OutcomePair" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "outcomePairs" );
return (org.webcat.outcomesmeasurement.OutcomePair)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>outcomePairs</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteOutcomePairsRelationship( org.webcat.outcomesmeasurement.OutcomePair value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteOutcomePairsRelationship("
+ value + "): was " + outcomePairs() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "outcomePairs" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>outcomePairs</code> relationship.
*/
public void deleteAllOutcomePairsRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllOutcomePairsRelationships(): was "
+ outcomePairs() );
}
for (org.webcat.outcomesmeasurement.OutcomePair object : outcomePairs())
{
deleteOutcomePairsRelationship(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<Measure> 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<Measure> 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<Measure> 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<Measure> 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 Measure firstObjectMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier,
NSArray<EOSortOrdering> sortOrderings)
{
NSArray<Measure> 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 Measure uniqueObjectMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier) throws EOUtilities.MoreThanOneException
{
NSArray<Measure> 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<Measure> 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<Measure> 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 Measure 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 Measure firstObjectMatchingValues(
EOEditingContext context,
NSArray<EOSortOrdering> sortOrderings,
NSDictionary<String, Object> keysAndValues)
{
EOFetchSpecification fspec = new EOFetchSpecification(
ENTITY_NAME,
EOQualifier.qualifierToMatchAllValues(keysAndValues),
sortOrderings);
fspec.setFetchLimit(1);
NSArray<Measure> 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 Measure 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 Measure uniqueObjectMatchingValues(
EOEditingContext context,
NSDictionary<String, Object> keysAndValues)
throws EOUtilities.MoreThanOneException
{
try
{
return (Measure)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( Measure.class );
}