private static int size(final NakedObject object) { final NakedObjectAssociation[] fields = object.getSpecification().getAssociations( NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); return fields.length; }
private static int size(final NakedObject object) { final NakedObjectAssociation[] fields = object.getSpecification().getAssociations( NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); return fields.length; }
public boolean canDisplay(final Content content, ViewRequirement requirement) { if (requirement.is(ViewRequirement.CLOSED)) { return false; } else { int collections = 0; if (content instanceof ObjectContent) { final NakedObject object = content.getNaked(); final NakedObjectAssociation[] fields = object.getSpecification().getAssociations( NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); for (int i = 0; i < fields.length; i++) { if (fields[i].isOneToManyAssociation()) { collections++; } } } return collections == 1; } }
@Override public void build(final View view) { Assert.assertEquals("ensure the view is the complete decorated view", view.getView(), view); final Content content = view.getContent(); final NakedObject object = ((ObjectContent) content).getObject(); LOG.debug("build view " + view + " for " + object); NakedObjectSpecification spec = object.getSpecification(); Filter<NakedObjectAssociation> filter = NakedObjectAssociationFilters.dynamicallyVisible( NakedObjectsContext.getAuthenticationSession(), object); final NakedObjectAssociation[] flds = spec.getAssociations(filter); if (view.getSubviews().length == 0) { newBuild(view, object, flds); } else { updateBuild(view, object, flds); } }
/** * This is only used to control root nodes. Therefore a object tree can only be displayed for an object * with fields that are collections. */ public boolean canDisplay(final Content content, ViewRequirement requirement) { if (content.isObject() && content.getNaked() != null) { final NakedObject object = content.getNaked(); final NakedObjectAssociation[] fields = object.getSpecification().getAssociations( NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); for (int i = 0; i < fields.length; i++) { if (fields[i].isOneToManyAssociation()) { return true; } } } return false; }
@Override public int canOpen(final Content content) { final NakedObject object = ((ObjectContent) content).getObject(); final NakedObjectAssociation[] fields = object.getSpecification().getAssociations( NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); for (int i = 0; i < fields.length; i++) { if (fields[i].isOneToManyAssociation()) { return CAN_OPEN; } if ( showObjectContents && fields[i].isOneToOneAssociation() && !(SpecificationFacets.isBoundedSet(object.getSpecification()))) { return CAN_OPEN; } } return CANT_OPEN; }
private Content fieldContent(Content content) { NakedObjectSpecification spec = content.getSpecification(); NakedObject target = content.getNaked(); AuthenticationSession session = NakedObjectsContext.getAuthenticationSession(); NakedObjectAssociation[] fields = spec.getAssociations(NakedObjectAssociationFilters.dynamicallyVisible(session, target)); for (NakedObjectAssociation field : fields) { if (field.isOneToOneAssociation() && !field.getSpecification().isParseable()) { return Toolkit.getContentFactory().createFieldContent(field, target); } } return null; }
private Consent setFieldOfMatchingType(final NakedObject targetAdapter, final NakedObject sourceAdapter) { if (targetAdapter.isTransient() && sourceAdapter.isPersistent()) { // TODO: use Facet for this test instead. return new Veto("Can't set field in persistent object with reference to non-persistent object"); } final NakedObjectAssociation[] fields = targetAdapter.getSpecification().getAssociations( NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), targetAdapter)); for (final NakedObjectAssociation fld : fields) { if (!fld.isOneToOneAssociation()) { continue; } if (!sourceAdapter.getSpecification().isOfType(fld.getSpecification())) { continue; } if (fld.get(targetAdapter) != null) { continue; } final Consent associationValid = ((OneToOneAssociation) fld).isAssociationValid(targetAdapter, sourceAdapter); if (associationValid.isAllowed()) { return associationValid.setDescription("Set field " + fld.getName()); } } // TODO: use Facet for this test instead return new Veto(String.format("No empty field accepting object of type %s in %s", sourceAdapter.getSpecification() .getSingularName(), title())); }
NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), target));
NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object));
NakedObjectAssociationFilters.dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object));
private void createObjectView(final Context context, final NakedObject object, final ViewPane pane, final String id) { final NakedObjectSpecification specification = object.getSpecification(); final NakedObjectAssociation[] visibleFields = specification.getAssociations(NakedObjectAssociationFilters .dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); for (int i = 0; i < visibleFields.length; i++) { final NakedObjectAssociation field = visibleFields[i];
private void createObjectView(final Context context, final NakedObject object, final ViewPane pane, final String id) { final NakedObjectSpecification specification = object.getSpecification(); final NakedObjectAssociation[] visibleFields = specification.getAssociations(NakedObjectAssociationFilters .dynamicallyVisible(NakedObjectsContext.getAuthenticationSession(), object)); for (int i = 0; i < visibleFields.length; i++) { final NakedObjectAssociation field = visibleFields[i];