// $LastChangedRevision: 4748 $ DO NOT EDIT.  Make changes to WiwoNameSpace.java instead.
package mildo.wiwo.data;

import com.webobjects.eoaccess.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import java.math.*;
import java.util.*;

public abstract class _WiwoNameSpace extends  EOGenericRecord {
	public static final String ENTITY_NAME = "WiwoNameSpace";

	// Attributes
	public static final String DESCRIPTION_KEY = "description";
	public static final String NAME_KEY = "name";

	// Relationships
	public static final String ADMINISTRATORS_KEY = "administrators";

  public WiwoNameSpace localInstanceOfWiwoNameSpaceIn(EOEditingContext editingContext) {
    WiwoNameSpace localInstance = (WiwoNameSpace)EOUtilities.localInstanceOfObject(editingContext, this);
    if (localInstance == null) {
      throw new IllegalStateException("You attempted to localInstance " + this + ", which has not yet committed.");
    }
    return localInstance;
  }

  public String description() {
    return (String) storedValueForKey("description");
  }

  public void setDescription(String value) {
    takeStoredValueForKey(value, "description");
  }

  public String name() {
    return (String) storedValueForKey("name");
  }

  public void setName(String value) {
    takeStoredValueForKey(value, "name");
  }

  public NSArray administrators() {
    return (NSArray)storedValueForKey("administrators");
  }

  public NSArray administrators(EOQualifier qualifier) {
    return administrators(qualifier, null);
  }

  public NSArray administrators(EOQualifier qualifier, NSArray sortOrderings) {
    NSArray results;
      results = administrators();
      if (qualifier != null) {
        results = (NSArray)EOQualifier.filteredArrayWithQualifier(results, qualifier);
      }
      if (sortOrderings != null) {
        results = (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray(results, sortOrderings);
      }
    return results;
  }
  
  public void addToAdministratorsRelationship(mildo.wiwo.data.WiwoUser object) {
    addObjectToBothSidesOfRelationshipWithKey(object, "administrators");
  }

  public void removeFromAdministratorsRelationship(mildo.wiwo.data.WiwoUser object) {
    removeObjectFromBothSidesOfRelationshipWithKey(object, "administrators");
  }

  public mildo.wiwo.data.WiwoUser createAdministratorsRelationship() {
    EOClassDescription eoClassDesc = EOClassDescription.classDescriptionForEntityName("WiwoUser");
    EOEnterpriseObject eo = eoClassDesc.createInstanceWithEditingContext(editingContext(), null);
    editingContext().insertObject(eo);
    addObjectToBothSidesOfRelationshipWithKey(eo, "administrators");
    return (mildo.wiwo.data.WiwoUser) eo;
  }

  public void deleteAdministratorsRelationship(mildo.wiwo.data.WiwoUser object) {
    removeObjectFromBothSidesOfRelationshipWithKey(object, "administrators");
    editingContext().deleteObject(object);
  }

  public void deleteAllAdministratorsRelationships() {
    Enumeration objects = administrators().immutableClone().objectEnumerator();
    while (objects.hasMoreElements()) {
      deleteAdministratorsRelationship((mildo.wiwo.data.WiwoUser)objects.nextElement());
    }
  }


  public static WiwoNameSpace createWiwoNameSpace(EOEditingContext editingContext, String description
, String name
) {
    WiwoNameSpace eo = (WiwoNameSpace) EOUtilities.createAndInsertInstance(editingContext, _WiwoNameSpace.ENTITY_NAME);    
		eo.setDescription(description);
		eo.setName(name);
    return eo;
  }

  public static NSArray fetchAllWiwoNameSpaces(EOEditingContext editingContext) {
    return _WiwoNameSpace.fetchAllWiwoNameSpaces(editingContext, null);
  }

  public static NSArray fetchAllWiwoNameSpaces(EOEditingContext editingContext, NSArray sortOrderings) {
    return _WiwoNameSpace.fetchWiwoNameSpaces(editingContext, null, sortOrderings);
  }

  public static NSArray fetchWiwoNameSpaces(EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) {
    EOFetchSpecification fetchSpec = new EOFetchSpecification(_WiwoNameSpace.ENTITY_NAME, qualifier, sortOrderings);
    fetchSpec.setIsDeep(true);
    NSArray eoObjects = (NSArray)editingContext.objectsWithFetchSpecification(fetchSpec);
    return eoObjects;
  }

  public static WiwoNameSpace fetchWiwoNameSpace(EOEditingContext editingContext, String keyName, Object value) {
    return _WiwoNameSpace.fetchWiwoNameSpace(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value));
  }

  public static WiwoNameSpace fetchWiwoNameSpace(EOEditingContext editingContext, EOQualifier qualifier) {
    NSArray eoObjects = _WiwoNameSpace.fetchWiwoNameSpaces(editingContext, qualifier, null);
    WiwoNameSpace eoObject;
    int count = eoObjects.count();
    if (count == 0) {
      eoObject = null;
    }
    else if (count == 1) {
      eoObject = (WiwoNameSpace)eoObjects.objectAtIndex(0);
    }
    else {
      throw new IllegalStateException("There was more than one WiwoNameSpace that matched the qualifier '" + qualifier + "'.");
    }
    return eoObject;
  }

  public static WiwoNameSpace fetchRequiredWiwoNameSpace(EOEditingContext editingContext, String keyName, Object value) {
    return _WiwoNameSpace.fetchRequiredWiwoNameSpace(editingContext, new EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual, value));
  }

  public static WiwoNameSpace fetchRequiredWiwoNameSpace(EOEditingContext editingContext, EOQualifier qualifier) {
    WiwoNameSpace eoObject = _WiwoNameSpace.fetchWiwoNameSpace(editingContext, qualifier);
    if (eoObject == null) {
      throw new NoSuchElementException("There was no WiwoNameSpace that matched the qualifier '" + qualifier + "'.");
    }
    return eoObject;
  }

  public static WiwoNameSpace localInstanceOfWiwoNameSpaceIn(EOEditingContext editingContext, WiwoNameSpace eo) {
    WiwoNameSpace localInstance = (eo == null) ? null : (WiwoNameSpace)EOUtilities.localInstanceOfObject(editingContext, eo);
    if (localInstance == null && eo != null) {
      throw new IllegalStateException("You attempted to localInstance " + eo + ", which has not yet committed.");
    }
    return localInstance;
  }
}
