public int size() { return wrappedCollection.size(); }
private ObjectData[] convertToNakedCollection(final NakedCollection instances) { ObjectData[] data = new ObjectData[instances.size()]; Enumeration elements = instances.elements(); int i = 0; while (elements.hasMoreElements()) { NakedObject element = (NakedObject) elements.nextElement(); data[i++] = encoder.createCompletePersistentGraph(element ); } return data; }
public NakedObject[] elements() { NakedCollection collection = getCollection(); if (collection == null) { return new NakedObject[0]; } final NakedObject[] elementsArray = new NakedObject[collection.size()]; int i = 0; Enumeration elements = collection.elements(); while (elements.hasMoreElements()) { elementsArray[i++] = (NakedObject) elements.nextElement(); } return elementsArray; }
public boolean hasInstances(final NakedObjectSpecification specification, final boolean includeSubclasses) { LOG.debug("hasInstances of " + specification); if (cache.containsKey(specification)) { Object collection = cache.get(specification); if (collection instanceof NakedCollection) { return ((NakedCollection) collection).size() > 0; } } // TODO includeInstances flag is not passed to server return connection.hasInstances(NakedObjectsContext.getSession(), specification.getFullName()); }
/** * A collection tree can only be displayed for a collection that has elements. */ public boolean canDisplay(final Content content) { return content.isCollection() && ((CollectionContent) content).getCollection().size() > 0; }
private Data createCollectionData(final Naked object) { NakedCollection coll = (NakedCollection) object; Data[] collData = new Data[coll.size()]; Enumeration elements = coll.elements(); int i = 0; while (elements.hasMoreElements()) { NakedObject ref = (NakedObject) elements.nextElement(); collData[i++] = createReferenceData(ref); // collData[i] = new Data(ref.getOid(), ref.getResolveState().name(), ref.getSpecification().getFullName()); } return new CollectionData(coll.getOid(), NakedCollection.class.getName(), collData); }
public int canOpen(final Content content) { NakedCollection collection = ((CollectionContent) content).getCollection(); if (collection.getResolveState().isGhost()) { return UNKNOWN; } else { return collection.size() > 0 ? CAN_OPEN : CANT_OPEN; } }
public int size() { NakedCollection nakedColl = (NakedCollection) getOneToManyAssociation().get(getNakedObject()); return nakedColl.size(); }
int size = collection.size();
/** * Adds <code>nof:feature="collection"</code> attribute, the * <code>nof:type="e;..."</code> and the <code>nof:size="e;..."</code> for the * supplied element. * * Additionally, if the <code>addOids</code> parameter is set, also adds <code><oids></code> * child elements. */ void setNofCollection( Element element, String prefix, String fullyQualifiedClassName, NakedCollection collection, boolean addOids) { setAttribute(element, "feature", NOF_METAMODEL_FEATURE_COLLECTION); setAttribute(element, "type", prefix + ":" + fullyQualifiedClassName); setAttribute(element, "size", "" + collection.size()); if (addOids) { throw new NakedObjectRuntimeException(); /* * Element oidsElement = appendElement(element, "oids"); for (Enumeration e = collection.oids(); * e.hasMoreElements();) { Oid oid = (Oid) e.nextElement(); DomTransferableWriter dtw = new * DomTransferableWriter(oidsElement, this, oid.getClass().getName()); oid.writeData(dtw); * dtw.close(); } */ } }
NakedCollection collection = (NakedCollection) oneToManyAssociation.get(fieldPlace.getObject()); LOG.debug("includeField(Pl, Vec, Str): 1->M: " + log("collection.size", "" + collection.size())); boolean allFieldsNavigated = true; Enumeration elements = collection.elements();
public Naked[] getOptions(NakedObject target) { Object[] pojoOptions = reflectiveAdapter.getOptions(target); if (pojoOptions != null) { NakedObject[] options = new NakedObject[pojoOptions.length]; for (int i = 0; i < options.length; i++) { options[i] = NakedObjectsContext.getObjectLoader().getAdapterFor(pojoOptions[i]); } return options; } else if (Features.isBoundedSet(getSpecification())) { NakedCollection instances = NakedObjectsContext.getObjectPersistor().findInstances( new AllInstances(getSpecification(), false)); NakedObject[] options = new NakedObject[instances.size()]; int j = 0; for (Enumeration e = instances.elements(); e.hasMoreElements();) { options[j++] = ((NakedObject) e.nextElement()); } return options; } return null; }
public void execute() { Naked result; result = action.execute(target, null); if (result != null) { if (result instanceof NakedCollection) { NakedCollection collection = ((NakedCollection) result); if (collection.size() == 1) { result = collection.firstElement(); } } view.objectActionResult(result, at); } view.getViewManager().disposeUnneededViews(); view.getFeedbackManager().showMessagesAndWarnings(); }
public void execute() { ActionContent actionContent = ((ActionContent) view.getContent()); Naked result = actionContent.execute(); LOG.debug("action invoked with result " + result); if (result != null) { Location dialogLocation = view.getAbsoluteLocation(); move(dialogLocation); if (result instanceof NakedCollection) { NakedCollection collection = ((NakedCollection) result); if (collection.size() == 1) { result = collection.firstElement(); } } View newView = workspace.addOpenViewFor(result, dialogLocation); view.getViewManager().setKeyboardFocus(newView); } view.getViewManager().disposeUnneededViews(); view.getFeedbackManager().showMessagesAndWarnings(); }
NakedCollection instances = NakedObjectsContext.getObjectPersistor().findInstances( new AllInstances(parameterTypes[i], false)); options[i] = new NakedObject[instances.size()]; int j = 0; for (Enumeration e = instances.elements(); e.hasMoreElements();) {
public void setSelectedNode(final View view) { Content content = view.getContent(); Naked object = content.getNaked(); NakedObjectSpecification specification = object.getSpecification(); if (specification.getType() == NakedObjectSpecification.OBJECT) { if (object != null && mainViewFormSpec.canDisplay(content)) { selectedNode = view; showInRightPane(mainViewFormSpec.createView(content, null)); } } else if (specification.getType() == NakedObjectSpecification.COLLECTION && ((NakedCollection) object).size() > 0) { if (mainViewTableSpec.canDisplay(content)) { selectedNode = view; showInRightPane(mainViewTableSpec.createView(content, null)); } else if (mainViewListSpec.canDisplay(content)) { selectedNode = view; showInRightPane(mainViewListSpec.createView(content, null)); } } }
public void draw(final Canvas canvas) { icon.draw(canvas, 0, getBaseline()); CollectionContent content = (CollectionContent) getContent(); NakedCollection collection = content.getCollection(); if (collection == null || collection.size() == 0) { canvas.drawText("empty", left, getBaseline(), Toolkit.getColor("secondary2"), Toolkit.getText("normal")); } else { int x = icon.getSize().getWidth() / 2; int x2 = x + 4; int y = icon.getSize().getHeight() + 1; int y2 = getSize().getHeight() - 5; canvas.drawLine(x, y, x, y2, Toolkit.getColor("secondary2")); canvas.drawLine(x, y2, x2, y2, Toolkit.getColor("secondary2")); } super.draw(canvas); }
public void testFindInstances() throws Exception { system.setObjectPersistor(proxy); //system.addSpecificationToLoader(new MovieSpecification()); // The remote interface is asked for instances, which are returned as data objects DummyObjectData instanceData = new DummyObjectData(new DummyOid(12, true), Movie.class.getName(), true, new DummyVersion(3)); // The data then needs to be decoded into the naked objects DummyNakedObject dummyNakedObject = new DummyNakedObject(new DummyOid(12, true), ResolveState.GHOST, "test"); dummyNakedObject.setupObject(new Movie()); dummyNakedObject.setupSpecification(new MovieSpecification()); reset(encoder); expect(encoder.restore(instanceData)).andReturn(dummyNakedObject); CriteriaData c = new TestCriteria(); remoteInterface.findInstances(session, c); expectLastCall().andReturn(new ObjectData[] { instanceData }); // run test AllInstances criteria = new AllInstances(NakedObjectsContext.getReflector().loadSpecification(Movie.class), false); encoder.createCriteriaData(criteria); expectLastCall().andReturn(c); replay(); NakedCollection instances = proxy.findInstances(criteria); verify(); // the proxy should return one instance, which will be the dummy object created by the encoder's restore call assertEquals(1, instances.size()); assertEquals(dummyNakedObject, instances.firstElement()); }