public Target getTarget() { final ExecutedFacet facet = getFacet(ExecutedFacet.class); final Where executeWhere = facet.value(); if (executeWhere == Where.LOCALLY) { return NakedObjectActionConstants.LOCAL; } else if (executeWhere == Where.REMOTELY) { return NakedObjectActionConstants.REMOTE; } else if (executeWhere == Where.DEFAULT) { return NakedObjectActionConstants.DEFAULT; } else { throw new UnknownTypeException(executeWhere); } }
public Target getTarget() { final ExecutedFacet facet = getFacet(ExecutedFacet.class); final Where executeWhere = facet.value(); if (executeWhere == Where.LOCALLY) { return NakedObjectActionConstants.LOCAL; } else if (executeWhere == Where.REMOTELY) { return NakedObjectActionConstants.REMOTE; } else if (executeWhere == Where.DEFAULT) { return NakedObjectActionConstants.DEFAULT; } else { throw new UnknownTypeException(executeWhere); } }
public static NakedObject createAdapter(final Class<?> type, final Object object, AdapterManager adapterManager, SpecificationLoader specificationLoader) { final NakedObjectSpecification specification = specificationLoader.loadSpecification(type); if (specification.isObject()) { return adapterManager.adapterFor(object); } else { throw new UnknownTypeException("not an object, is this a collection?"); } }
private NakedObjectAssociation[] orderFields(final OrderSet order) { final NakedObjectAssociation[] fields = new NakedObjectAssociation[order.size()]; final Enumeration<NakedObjectAssociation> elements = CastUtils.enumerationOver(order.elements(), NakedObjectAssociation.class); int actionCnt = 0; while (elements.hasMoreElements()) { final Object element = elements.nextElement(); if (element instanceof JavaNakedObjectAssociationPeer) { final JavaNakedObjectAssociationPeer javaNakedObjectAssociationPeer = (JavaNakedObjectAssociationPeer) element; final NakedObjectAssociation nakedObjectAssociation = createNakedObjectField(javaNakedObjectAssociationPeer); fields[actionCnt++] = nakedObjectAssociation; } else if (element instanceof OrderSet) { // Not supported at present } else { throw new UnknownTypeException(element); } } if (actionCnt < fields.length) { final NakedObjectAssociation[] actualActions = new NakedObjectAssociation[actionCnt]; System.arraycopy(fields, 0, actualActions, 0, actionCnt); return actualActions; } return fields; }
private NakedObjectAssociation[] orderFields(final OrderSet order) { final NakedObjectAssociation[] fields = new NakedObjectAssociation[order.size()]; final Enumeration<NakedObjectAssociation> elements = CastUtils.enumerationOver(order.elements(), NakedObjectAssociation.class); int actionCnt = 0; while (elements.hasMoreElements()) { final Object element = elements.nextElement(); if (element instanceof JavaNakedObjectAssociationPeer) { final JavaNakedObjectAssociationPeer javaNakedObjectAssociationPeer = (JavaNakedObjectAssociationPeer) element; final NakedObjectAssociation nakedObjectAssociation = createNakedObjectField(javaNakedObjectAssociationPeer); fields[actionCnt++] = nakedObjectAssociation; } else if (element instanceof OrderSet) { // Not supported at present } else { throw new UnknownTypeException(element); } } if (actionCnt < fields.length) { final NakedObjectAssociation[] actualActions = new NakedObjectAssociation[actionCnt]; System.arraycopy(fields, 0, actualActions, 0, actionCnt); return actualActions; } return fields; }
private NakedObject deserializeObject(final Data data, final KnownObjectsRequest knownObjects) { if (data instanceof NullData) { return null; } else if (data instanceof ObjectData) { ObjectData objectData = (ObjectData) data; return deserializeObjectFromObjectData(objectData, knownObjects); } else if (data instanceof IdentityData) { IdentityData identityData = (IdentityData) data; return deserializeObjectFromIdentityData(identityData, knownObjects); } else if (data instanceof EncodableObjectData) { EncodableObjectData encodableObjectData = (EncodableObjectData) data; return deserializeObjectFromEncodableObjectData(encodableObjectData); } else { throw new UnknownTypeException(data); } }
private NakedObject deserializeObject(final Data data, final KnownObjectsRequest knownObjects) { if (data instanceof NullData) { return null; } else if (data instanceof ObjectData) { ObjectData objectData = (ObjectData) data; return deserializeObjectFromObjectData(objectData, knownObjects); } else if (data instanceof IdentityData) { IdentityData identityData = (IdentityData) data; return deserializeObjectFromIdentityData(identityData, knownObjects); } else if (data instanceof EncodableObjectData) { EncodableObjectData encodableObjectData = (EncodableObjectData) data; return deserializeObjectFromEncodableObjectData(encodableObjectData); } else { throw new UnknownTypeException(data); } }
protected NakedObject createAdapter(final Class<?> type, final Object object) { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(type); if (specification.isObject()) { return getRuntimeContext().adapterFor(object); } else { throw new UnknownTypeException("not an object, is this a collection?"); } }
private NakedObject createAdapter(final Class<?> type, final Object object) { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(type); if (specification.isObject()) { return getRuntimeContext().adapterFor(object); } else { throw new UnknownTypeException("not an object, is this a collection?"); } }
private NakedObject createAdapter(final Class<?> type, final Object object) { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(type); if (specification.isObject()) { return getRuntimeContext().adapterFor(object); } else { throw new UnknownTypeException("not an object, is this a collection?"); } }
protected NakedObject createAdapter(final Class<?> type, final Object object) { final NakedObjectSpecification specification = getSpecificationLoader().loadSpecification(type); if (specification.isObject()) { return getRuntimeContext().adapterFor(object); } else { throw new UnknownTypeException("not an object, is this a collection?"); } }
/** * Build lazily by {@link #getParameters()}. * * <p> * Although this is lazily loaded, the method is also <tt>synchronized</tt> so there shouldn't be any * thread race conditions. */ public synchronized NakedObjectActionParameter[] getParameters() { if (this.parameters == null) { final int parameterCount = getParameterCount(); final NakedObjectActionParameter[] parameters = new NakedObjectActionParameter[parameterCount]; final NakedObjectActionParamPeer[] paramPeers = nakedObjectActionPeer.getParameters(); for (int i = 0; i < parameterCount; i++) { final NakedObjectSpecification specification = paramPeers[i].getSpecification(); if (specification.isParseable()) { parameters[i] = new NakedObjectActionParameterParseable(i, this, paramPeers[i]); } else if (specification.isObject()) { parameters[i] = new OneToOneActionParameterImpl(i, this, paramPeers[i]); } else if (specification.isCollection()) { throw new UnknownTypeException("collections not supported as parameters: " + getIdentifier()); } else { throw new UnknownTypeException(specification); } } this.parameters = parameters; } return parameters; }
private NakedObjectAction[] orderActions(final OrderSet order) { final NakedObjectAction[] actions = new NakedObjectAction[order.size()]; final Enumeration<NakedObjectAction> elements = CastUtils.enumerationOver(order.elements(), NakedObjectAction.class); int actionCnt = 0; while (elements.hasMoreElements()) { final Object element = elements.nextElement(); if (element instanceof JavaNakedObjectActionPeer) { final JavaNakedObjectActionPeer javaNakedObjectActionPeer = (JavaNakedObjectActionPeer) element; final String actionId = javaNakedObjectActionPeer.getIdentifier().getMemberName(); final NakedObjectAction nakedObjectAction = new NakedObjectActionImpl(actionId, javaNakedObjectActionPeer, getRuntimeContext()); actions[actionCnt++] = nakedObjectAction; } else if (element instanceof OrderSet) { final OrderSet set = ((OrderSet) element); actions[actionCnt++] = new NakedObjectActionSet("", set.getGroupFullName(), orderActions(set), getRuntimeContext()); } else { throw new UnknownTypeException(element); } } if (actionCnt < actions.length) { final NakedObjectAction[] actualActions = new NakedObjectAction[actionCnt]; System.arraycopy(actions, 0, actualActions, 0, actionCnt); return actualActions; } return actions; }
/** * Build lazily by {@link #getParameters()}. * * <p> * Although this is lazily loaded, the method is also <tt>synchronized</tt> so there shouldn't be any * thread race conditions. */ public synchronized NakedObjectActionParameter[] getParameters() { if (this.parameters == null) { final int parameterCount = getParameterCount(); final NakedObjectActionParameter[] parameters = new NakedObjectActionParameter[parameterCount]; final NakedObjectActionParamPeer[] paramPeers = nakedObjectActionPeer.getParameters(); for (int i = 0; i < parameterCount; i++) { final NakedObjectSpecification specification = paramPeers[i].getSpecification(); if (specification.isParseable()) { parameters[i] = new NakedObjectActionParameterParseable(i, this, paramPeers[i]); } else if (specification.isObject()) { parameters[i] = new OneToOneActionParameterImpl(i, this, paramPeers[i]); } else if (specification.isCollection()) { throw new UnknownTypeException("collections not supported as parameters: " + getIdentifier()); } else { throw new UnknownTypeException(specification); } } this.parameters = parameters; } return parameters; }
private NakedObjectAction[] orderActions(final OrderSet order) { final NakedObjectAction[] actions = new NakedObjectAction[order.size()]; final Enumeration<NakedObjectAction> elements = CastUtils.enumerationOver(order.elements(), NakedObjectAction.class); int actionCnt = 0; while (elements.hasMoreElements()) { final Object element = elements.nextElement(); if (element instanceof JavaNakedObjectActionPeer) { final JavaNakedObjectActionPeer javaNakedObjectActionPeer = (JavaNakedObjectActionPeer) element; final String actionId = javaNakedObjectActionPeer.getIdentifier().getMemberName(); final NakedObjectAction nakedObjectAction = new NakedObjectActionImpl(actionId, javaNakedObjectActionPeer, getRuntimeContext()); actions[actionCnt++] = nakedObjectAction; } else if (element instanceof OrderSet) { final OrderSet set = ((OrderSet) element); actions[actionCnt++] = new NakedObjectActionSet("", set.getGroupFullName(), orderActions(set), getRuntimeContext()); } else { throw new UnknownTypeException(element); } } if (actionCnt < actions.length) { final NakedObjectAction[] actualActions = new NakedObjectAction[actionCnt]; System.arraycopy(actions, 0, actualActions, 0, actionCnt); return actualActions; } return actions; }
private final Data createParameter(final String type, final NakedObject adapter, final KnownObjectsRequest knownObjects) { if (adapter == null) { return dataFactory.createNullData(type); } if (!adapter.getSpecification().isObject()) { throw new UnknownTypeException(adapter.getSpecification()); } if (adapter.getSpecification().isEncodeable()) { return serializer.serializeEncodeable(adapter); } else { return encode(adapter, clientSideActionParameterGraphDepth, knownObjects); } }
private final Data createParameter(final String type, final NakedObject adapter, final KnownObjectsRequest knownObjects) { if (adapter == null) { return dataFactory.createNullData(type); } if (!adapter.getSpecification().isObject()) { throw new UnknownTypeException(adapter.getSpecification()); } if (adapter.getSpecification().isEncodeable()) { return serializer.serializeEncodeable(adapter); } else { return encode(adapter, clientSideActionParameterGraphDepth, knownObjects); } }
private NakedObject[] getParameters(final AuthenticationSession session, final Data[] parameterData, final KnownObjectsRequest knownObjects) { final NakedObject[] parameters = new NakedObject[parameterData.length]; for (int i = 0; i < parameters.length; i++) { final Data data = parameterData[i]; if (data instanceof NullData) { continue; } if (data instanceof IdentityData) { parameters[i] = getPersistentNakedObject(session, (IdentityData) data); } else if (data instanceof ObjectData) { parameters[i] = encoderDecoder.decode(data, knownObjects); } else if (data instanceof EncodableObjectData) { final NakedObjectSpecification valueSpecification = getSpecificationLoader().loadSpecification( data.getType()); final String valueData = ((EncodableObjectData) data).getEncodedObjectData(); final NakedObject value = restoreLeafObject(valueData, valueSpecification); /* * NakedValue value = * NakedObjectsContext.getObjectLoader().createValueInstance(valueSpecification); * value.restoreFromEncodedString(valueData); */ parameters[i] = value; } else { throw new UnknownTypeException(data); } } return parameters; }
public void listObjects(final Context context, final Block navigation) { final Block taskBar = context.getComponentFactory().createBlock("history", null); taskBar.add(context.getComponentFactory().createHeading("History")); for (int i = history.size() - 1; i >= 0; i--) { final HistoryEntry item = (HistoryEntry) history.elementAt(i); Component icon; if (item.type == HistoryEntry.OBJECT) { final NakedObject object = context.getMappedObject(item.id); NakedObjectsContext.getPersistenceSession().resolveImmediately(object); icon = context.getComponentFactory().createObjectIcon(object, item.id, "item"); } else if (item.type == HistoryEntry.COLLECTION) { final NakedObject object = context.getMappedCollection(item.id); icon = context.getComponentFactory().createCollectionIcon(object, item.id); } else { throw new UnknownTypeException(item); } taskBar.add(icon); } navigation.add(taskBar); }
public void listObjects(final Context context, final Block navigation) { final Block taskBar = context.getComponentFactory().createBlock("history", null); taskBar.add(context.getComponentFactory().createHeading("History")); for (int i = history.size() - 1; i >= 0; i--) { final HistoryEntry item = history.get(i); Component icon; if (item.type == HistoryEntry.OBJECT) { final NakedObject object = context.getMappedObject(item.id); NakedObjectsContext.getPersistenceSession().resolveImmediately(object); icon = context.getComponentFactory().createObjectIcon(object, item.id, "item"); } else if (item.type == HistoryEntry.COLLECTION) { final NakedObject object = context.getMappedCollection(item.id); icon = context.getComponentFactory().createCollectionIcon(object, item.id); } else { throw new UnknownTypeException(item); } taskBar.add(icon); } navigation.add(taskBar); }