public void clear() { NakedObject parentObject = getParent(); OneToManyAssociation association = getOneToManyAssociation(); LOG.debug("remove " + element + " from " + parentObject); association.removeElement(parentObject, element); }
private void updateOneToManyAssociation( final NakedObject object, final OneToManyAssociation field, final CollectionData collectionData) { NakedCollection collection = (NakedCollection) field.get(object); Vector original = new Vector(); Enumeration elements = collection.elements(); while (elements.hasMoreElements()) { original.addElement(elements.nextElement()); } for (int j = 0; j < collectionData.elements.length; j++) { NakedObject element = recreateReference((Data) collectionData.elements[j]); if (!collection.contains(element)) { LOG.debug(" association " + field + " changed, added " + element.getOid()); field.addElement(object, element); } else { field.removeElement(object, element); } } int size = original.size(); for (int i = 0; i < size; i++) { NakedObject element = (NakedObject) original.elementAt(i); LOG.debug(" association " + field + " changed, removed " + element.getOid()); field.removeElement(object, element); } }
public void removeFromCollection(NakedObject nakedObject) { getOneToManyAssociation().removeElement(getNakedObject(), nakedObject); fireObjectRemovedEvent(nakedObject); }
public void removeObject(final NakedObject object) { final NakedObject perspective = (NakedObject) getContent().getNaked(); OneToManyAssociation fld = (OneToManyAssociation) perspective.getSpecification().getField("objects"); fld.removeElement(perspective, object); }
public void testClear() { association.removeElement(nakedObject, associate); associationDelegate.assertAction(0, "remove " + nakedObject); associationDelegate.assertAction(1, "remove " + associate); }
public void testClearWithNull() { try { association.removeElement(nakedObject, null); fail(); } catch (IllegalArgumentException expected) {} associationDelegate.assertActions(0); }
public void execute(Workspace workspace, View view, Location at) { ObjectContent parent = (ObjectContent) view.getParent().getContent(); NakedObject perspective = parent.getObject(); OneToManyAssociation fld = (OneToManyAssociation) perspective.getSpecification().getField("services"); ServiceObject service = (ServiceObject) view.getContent(); NakedObject element = service.getObject(); fld.removeElement(perspective, element); super.execute(workspace, view, at); } });
public ObjectData[] clearAssociation( final Session session, final String fieldIdentifier, final IdentityData target, final IdentityData associated) { LOG.debug("request clearAssociation " + fieldIdentifier + " on " + target + " of " + associated + " for " + session); NakedObject inObject = getPersistentNakedObject(session, target); NakedObject associate = getPersistentNakedObject(session, associated); NakedObjectSpecification specification = inObject.getSpecification(); NakedObjectField association = (NakedObjectField) specification.getField(fieldIdentifier); if (!association.isVisible() || association.isUsable(inObject).isVetoed()) { throw new IllegalRequestException("can't modify field as not visible or editable"); } if (association instanceof OneToOneAssociation) { ((OneToOneAssociation) association).clearAssociation(inObject, associate); } else { ((OneToManyAssociation) association).removeElement(inObject, associate); } return getUpdates(); }