Search in sources :

Example 1 with ModelVetoException

use of com.sun.jdo.api.persistence.model.ModelVetoException in project Payara by payara.

the class PersistenceClassElementImpl method setKeyClass.

/**
 * Set the primary key class for this class element.
 * @param name - the fully qualified name which represents the primary key
 * class.  This value is only used if <code>getObjectIdentityType</code>
 * returns <code>APPLICATION_IDENTITY</code>
 * @exception ModelException if impossible
 * @see #setObjectIdentityType
 * @see PersistenceClassElement#APPLICATION_IDENTITY
 */
public void setKeyClass(String name) throws ModelException {
    String old = getKeyClass();
    try {
        fireVetoableChange(PROP_KEY_CLASS, old, name);
        _keyClass = name;
        firePropertyChange(PROP_KEY_CLASS, old, name);
    } catch (PropertyVetoException e) {
        throw new ModelVetoException(e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ModelVetoException(com.sun.jdo.api.persistence.model.ModelVetoException)

Example 2 with ModelVetoException

use of com.sun.jdo.api.persistence.model.ModelVetoException in project Payara by payara.

the class PersistenceElementCollection method changeElements.

/**
 * Change the set of elements.
 * @param elements the new elements
 * @param action {@link com.sun.jdo.api.persistence.model.jdo.PersistenceElement.Impl#ADD},
 * {@link com.sun.jdo.api.persistence.model.jdo.PersistenceElement.Impl#REMOVE}, or
 * {@link com.sun.jdo.api.persistence.model.jdo.PersistenceElement.Impl#SET}
 * @exception ModelException if impossible
 */
public void changeElements(List elements, int action) throws ModelException {
    boolean changed = false;
    try {
        PersistenceElement[] oldElements = getElements();
        int oldLength = (oldElements == null) ? 0 : oldElements.length;
        int newLength = (elements == null) ? 0 : elements.size();
        List list = null;
        switch(action) {
            case PersistenceElement.Impl.SET:
                list = elements;
                changed = true;
                break;
            case PersistenceElement.Impl.ADD:
                if (newLength > 0) {
                    list = ((oldLength == 0) ? new ArrayList() : new ArrayList(Arrays.asList(oldElements)));
                    list.addAll(elements);
                    changed = true;
                }
                break;
            case PersistenceElement.Impl.REMOVE:
                if ((newLength > 0) && (oldLength > 0)) {
                    list = new ArrayList(Arrays.asList(oldElements));
                    list.removeAll(elements);
                    changed = true;
                }
                break;
        }
        if (changed) {
            try {
                _owner.fireVetoableChange(_propertyName, null, null);
                _elements = (PersistenceElement[]) list.toArray(_template);
            } catch (PropertyVetoException e) {
                throw new ModelVetoException(e);
            }
        }
    } finally {
        if (changed)
            _owner.firePropertyChange(_propertyName, null, null);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ModelVetoException(com.sun.jdo.api.persistence.model.ModelVetoException)

Example 3 with ModelVetoException

use of com.sun.jdo.api.persistence.model.ModelVetoException in project Payara by payara.

the class PersistenceElementImpl method setName.

/**
 * Set the name of this persistence element.
 * @param name the name
 * @exception ModelException if impossible
 */
public void setName(String name) throws ModelException {
    String old = getName();
    try {
        fireVetoableChange(PROP_NAME, old, name);
        _name = name;
        firePropertyChange(PROP_NAME, old, name);
    } catch (PropertyVetoException e) {
        throw new ModelVetoException(e);
    }
}
Also used : ModelVetoException(com.sun.jdo.api.persistence.model.ModelVetoException)

Example 4 with ModelVetoException

use of com.sun.jdo.api.persistence.model.ModelVetoException in project Payara by payara.

the class PersistenceFieldElementImpl method setKey.

/**
 * Set whether this field element is a key field or not.
 * @param flag - if <code>true</code>, the field element is marked
 * as a key field; otherwise, it is not
 * @exception ModelException if impossible
 * @see com.sun.jdo.api.persistence.model.jdo.impl.PersistenceClassElementImpl#getKeyClass
 */
public void setKey(boolean flag) throws ModelException {
    Boolean old = JavaTypeHelper.valueOf(isKey());
    Boolean newFlag = JavaTypeHelper.valueOf(flag);
    try {
        fireVetoableChange(PROP_KEY_FIELD, old, newFlag);
        _isKey = flag;
        firePropertyChange(PROP_KEY_FIELD, old, newFlag);
    } catch (PropertyVetoException e) {
        throw new ModelVetoException(e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ModelVetoException(com.sun.jdo.api.persistence.model.ModelVetoException)

Example 5 with ModelVetoException

use of com.sun.jdo.api.persistence.model.ModelVetoException in project Payara by payara.

the class RelationshipElementImpl method setLowerBound.

/**
 * Set the lower cardinality bound for this relationship element.
 * @param lowerBound - an integer indicating the lower cardinality bound
 * @exception ModelException if impossible
 */
public void setLowerBound(int lowerBound) throws ModelException {
    Integer old = new Integer(getLowerBound());
    Integer newBound = new Integer(lowerBound);
    try {
        fireVetoableChange(PROP_CARDINALITY, old, newBound);
        _lowerBound = lowerBound;
        firePropertyChange(PROP_CARDINALITY, old, newBound);
    } catch (PropertyVetoException e) {
        throw new ModelVetoException(e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ModelVetoException(com.sun.jdo.api.persistence.model.ModelVetoException)

Aggregations

ModelVetoException (com.sun.jdo.api.persistence.model.ModelVetoException)26 PropertyVetoException (java.beans.PropertyVetoException)24 ModelException (com.sun.jdo.api.persistence.model.ModelException)4 ArrayList (java.util.ArrayList)2 MappingTableElement (com.sun.jdo.api.persistence.model.mapping.MappingTableElement)1