public boolean accept(NakedObjectField f) { return f.isVisible(); } };
private NakedObjectField[] tableFields(final NakedObjectField[] viewFields) { for (int i = 0; i < viewFields.length; i++) { if (viewFields[i].getSpecification().isOfType( NakedObjectsContext.getReflector().loadSpecification(ImageValue.class))) { continue; } if (!viewFields[i].isVisible()) { continue; } LOG.debug("column " + viewFields[i].getSpecification()); // if(viewFields[i].getSpecification().isOfType(NakedObjects.getSpecificationLoader().lo)); } NakedObjectField[] tableFields = new NakedObjectField[viewFields.length]; int c = 0; for (int i = 0; i < viewFields.length; i++) { if (!(viewFields[i] instanceof OneToManyAssociation)) { tableFields[c++] = viewFields[i]; } } NakedObjectField[] results = new NakedObjectField[c]; System.arraycopy(tableFields, 0, results, 0, c); return results; } }
public ObjectData[] setAssociation( final Session session, final String fieldIdentifier, final IdentityData target, final IdentityData associated) { LOG.debug("request setAssociation " + fieldIdentifier + " on " + target + " with " + associated + " for " + session); NakedObject inObject = getPersistentNakedObject(session, target); NakedObject associate = getPersistentNakedObject(session, associated); NakedObjectField association = (NakedObjectField) inObject.getSpecification().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).setAssociation(inObject, associate); } else { ((OneToManyAssociation) association).addElement(inObject, associate); } return getUpdates(); }
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(); }
Naked value = field.get(object); if (field.isValue()) { boolean visiblityChange = !field.isVisible(object) ^ (subview instanceof BlankView); Naked naked = subview.getContent().getNaked(); boolean valueChange = value != null && value.getObject() != null && !value.getObject().equals(naked.getObject());