/*==========================================================================*\
| _OutcomeSet.java
|*-------------------------------------------------------------------------*|
| Created by eogenerator
| DO NOT EDIT. Make changes to OutcomeSet.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
* OutcomeSet.java.
*
* @author Generated by eogenerator
* @version version suppressed to control auto-generation
*/
public abstract class _OutcomeSet
extends er.extensions.eof.ERXGenericRecord
{
//~ Constructors ..........................................................
// ----------------------------------------------------------
/**
* Creates a new _OutcomeSet object.
*/
public _OutcomeSet()
{
super();
}
// ----------------------------------------------------------
/**
* A static factory method for creating a new
* OutcomeSet object given required
* attributes and relationships.
* @param editingContext The context in which the new object will be
* inserted
* @param semesterValue
* @return The newly created object
*/
public static OutcomeSet create(
EOEditingContext editingContext,
org.webcat.core.Semester semesterValue
)
{
OutcomeSet eoObject = (OutcomeSet)
EOUtilities.createAndInsertInstance(
editingContext,
_OutcomeSet.ENTITY_NAME);
eoObject.setSemesterRelationship(semesterValue);
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 OutcomeSet localInstance(
EOEditingContext editingContext, OutcomeSet eo)
{
return (eo == null)
? null
: (OutcomeSet)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 OutcomeSet forId(
EOEditingContext ec, int id )
{
OutcomeSet obj = null;
if (id > 0)
{
NSArray<OutcomeSet> 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 OutcomeSet forId(
EOEditingContext ec, String id )
{
return forId( ec, er.extensions.foundation.ERXValueUtilities.intValue( id ) );
}
//~ Constants (for key names) .............................................
// Attributes ---
// To-one relationships ---
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 ACCREDITING_BODIES_KEY = "accreditingBodies";
public static final ERXKey<org.webcat.outcomesmeasurement.AccreditingBody> accreditingBodies =
new ERXKey<org.webcat.outcomesmeasurement.AccreditingBody>(ACCREDITING_BODIES_KEY);
public static final String OUTCOMES_KEY = "outcomes";
public static final ERXKey<org.webcat.outcomesmeasurement.Outcome> outcomes =
new ERXKey<org.webcat.outcomesmeasurement.Outcome>(OUTCOMES_KEY);
public static final String PROGRAMS_KEY = "programs";
public static final ERXKey<org.webcat.outcomesmeasurement.Program> programs =
new ERXKey<org.webcat.outcomesmeasurement.Program>(PROGRAMS_KEY);
// Fetch specifications ---
public static final String ENTITY_NAME = "OutcomeSet";
//~ 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 OutcomeSet localInstance(EOEditingContext editingContext)
{
return (OutcomeSet)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 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>accreditingBodies</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.outcomesmeasurement.AccreditingBody> accreditingBodies()
{
return (NSArray)storedValueForKey( "accreditingBodies" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>accreditingBodies</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setAccreditingBodies( NSMutableArray<org.webcat.outcomesmeasurement.AccreditingBody> value )
{
if (log.isDebugEnabled())
{
log.debug( "setAccreditingBodies("
+ value + "): was " + accreditingBodies() );
}
takeStoredValueForKey( value, "accreditingBodies" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>accreditingBodies</code>
* relationship (DO NOT USE--instead, use
* <code>addToAccreditingBodiesRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToAccreditingBodies( org.webcat.outcomesmeasurement.AccreditingBody value )
{
if (log.isDebugEnabled())
{
log.debug( "addToAccreditingBodies("
+ value + "): was " + accreditingBodies() );
}
NSMutableArray<org.webcat.outcomesmeasurement.AccreditingBody> array =
(NSMutableArray<org.webcat.outcomesmeasurement.AccreditingBody>)accreditingBodies();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>accreditingBodies</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromAccreditingBodiesRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromAccreditingBodies( org.webcat.outcomesmeasurement.AccreditingBody value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromAccreditingBodies("
+ value + "): was " + accreditingBodies() );
}
NSMutableArray<org.webcat.outcomesmeasurement.AccreditingBody> array =
(NSMutableArray<org.webcat.outcomesmeasurement.AccreditingBody>)accreditingBodies();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>accreditingBodies</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToAccreditingBodiesRelationship( org.webcat.outcomesmeasurement.AccreditingBody value )
{
if (log.isDebugEnabled())
{
log.debug( "addToAccreditingBodiesRelationship("
+ value + "): was " + accreditingBodies() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "accreditingBodies" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>accreditingBodies</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromAccreditingBodiesRelationship( org.webcat.outcomesmeasurement.AccreditingBody value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromAccreditingBodiesRelationship("
+ value + "): was " + accreditingBodies() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "accreditingBodies" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>accreditingBodies</code> relationship.
*
* @return The new entity
*/
public org.webcat.outcomesmeasurement.AccreditingBody createAccreditingBodiesRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createAccreditingBodiesRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "AccreditingBody" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "accreditingBodies" );
return (org.webcat.outcomesmeasurement.AccreditingBody)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>accreditingBodies</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteAccreditingBodiesRelationship( org.webcat.outcomesmeasurement.AccreditingBody value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteAccreditingBodiesRelationship("
+ value + "): was " + accreditingBodies() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "accreditingBodies" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>accreditingBodies</code> relationship.
*/
public void deleteAllAccreditingBodiesRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllAccreditingBodiesRelationships(): was "
+ accreditingBodies() );
}
for (org.webcat.outcomesmeasurement.AccreditingBody object : accreditingBodies())
{
deleteAccreditingBodiesRelationship(object);
}
}
// ----------------------------------------------------------
/**
* Retrieve the entities pointed to by the <code>outcomes</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.outcomesmeasurement.Outcome> outcomes()
{
return (NSArray)storedValueForKey( "outcomes" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>outcomes</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setOutcomes( NSMutableArray<org.webcat.outcomesmeasurement.Outcome> value )
{
if (log.isDebugEnabled())
{
log.debug( "setOutcomes("
+ value + "): was " + outcomes() );
}
takeStoredValueForKey( value, "outcomes" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>outcomes</code>
* relationship (DO NOT USE--instead, use
* <code>addToOutcomesRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToOutcomes( org.webcat.outcomesmeasurement.Outcome value )
{
if (log.isDebugEnabled())
{
log.debug( "addToOutcomes("
+ value + "): was " + outcomes() );
}
NSMutableArray<org.webcat.outcomesmeasurement.Outcome> array =
(NSMutableArray<org.webcat.outcomesmeasurement.Outcome>)outcomes();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>outcomes</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromOutcomesRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromOutcomes( org.webcat.outcomesmeasurement.Outcome value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromOutcomes("
+ value + "): was " + outcomes() );
}
NSMutableArray<org.webcat.outcomesmeasurement.Outcome> array =
(NSMutableArray<org.webcat.outcomesmeasurement.Outcome>)outcomes();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>outcomes</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToOutcomesRelationship( org.webcat.outcomesmeasurement.Outcome value )
{
if (log.isDebugEnabled())
{
log.debug( "addToOutcomesRelationship("
+ value + "): was " + outcomes() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "outcomes" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>outcomes</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromOutcomesRelationship( org.webcat.outcomesmeasurement.Outcome value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromOutcomesRelationship("
+ value + "): was " + outcomes() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "outcomes" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>outcomes</code> relationship.
*
* @return The new entity
*/
public org.webcat.outcomesmeasurement.Outcome createOutcomesRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createOutcomesRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "Outcome" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "outcomes" );
return (org.webcat.outcomesmeasurement.Outcome)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>outcomes</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteOutcomesRelationship( org.webcat.outcomesmeasurement.Outcome value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteOutcomesRelationship("
+ value + "): was " + outcomes() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "outcomes" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>outcomes</code> relationship.
*/
public void deleteAllOutcomesRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllOutcomesRelationships(): was "
+ outcomes() );
}
for (org.webcat.outcomesmeasurement.Outcome object : outcomes())
{
deleteOutcomesRelationship(object);
}
}
// ----------------------------------------------------------
/**
* Retrieve the entities pointed to by the <code>programs</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.outcomesmeasurement.Program> programs()
{
return (NSArray)storedValueForKey( "programs" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>programs</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setPrograms( NSMutableArray<org.webcat.outcomesmeasurement.Program> value )
{
if (log.isDebugEnabled())
{
log.debug( "setPrograms("
+ value + "): was " + programs() );
}
takeStoredValueForKey( value, "programs" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>programs</code>
* relationship (DO NOT USE--instead, use
* <code>addToProgramsRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToPrograms( org.webcat.outcomesmeasurement.Program value )
{
if (log.isDebugEnabled())
{
log.debug( "addToPrograms("
+ value + "): was " + programs() );
}
NSMutableArray<org.webcat.outcomesmeasurement.Program> array =
(NSMutableArray<org.webcat.outcomesmeasurement.Program>)programs();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>programs</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromProgramsRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromPrograms( org.webcat.outcomesmeasurement.Program value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromPrograms("
+ value + "): was " + programs() );
}
NSMutableArray<org.webcat.outcomesmeasurement.Program> array =
(NSMutableArray<org.webcat.outcomesmeasurement.Program>)programs();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>programs</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToProgramsRelationship( org.webcat.outcomesmeasurement.Program value )
{
if (log.isDebugEnabled())
{
log.debug( "addToProgramsRelationship("
+ value + "): was " + programs() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "programs" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>programs</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromProgramsRelationship( org.webcat.outcomesmeasurement.Program value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromProgramsRelationship("
+ value + "): was " + programs() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "programs" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>programs</code> relationship.
*
* @return The new entity
*/
public org.webcat.outcomesmeasurement.Program createProgramsRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createProgramsRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "Program" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "programs" );
return (org.webcat.outcomesmeasurement.Program)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>programs</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteProgramsRelationship( org.webcat.outcomesmeasurement.Program value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteProgramsRelationship("
+ value + "): was " + programs() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "programs" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>programs</code> relationship.
*/
public void deleteAllProgramsRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllProgramsRelationships(): was "
+ programs() );
}
for (org.webcat.outcomesmeasurement.Program object : programs())
{
deleteProgramsRelationship(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<OutcomeSet> 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<OutcomeSet> 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<OutcomeSet> 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<OutcomeSet> 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 OutcomeSet firstObjectMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier,
NSArray<EOSortOrdering> sortOrderings)
{
NSArray<OutcomeSet> 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 OutcomeSet uniqueObjectMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier) throws EOUtilities.MoreThanOneException
{
NSArray<OutcomeSet> 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<OutcomeSet> 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<OutcomeSet> 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 OutcomeSet 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 OutcomeSet firstObjectMatchingValues(
EOEditingContext context,
NSArray<EOSortOrdering> sortOrderings,
NSDictionary<String, Object> keysAndValues)
{
EOFetchSpecification fspec = new EOFetchSpecification(
ENTITY_NAME,
EOQualifier.qualifierToMatchAllValues(keysAndValues),
sortOrderings);
fspec.setFetchLimit(1);
NSArray<OutcomeSet> 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 OutcomeSet 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 OutcomeSet uniqueObjectMatchingValues(
EOEditingContext context,
NSDictionary<String, Object> keysAndValues)
throws EOUtilities.MoreThanOneException
{
try
{
return (OutcomeSet)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( OutcomeSet.class );
}