Package org.apache.cayenne

Examples of org.apache.cayenne.DataObject


        DataRow row = new DataRow(10);
        row.put("ARTIST_ID", new Integer(1));
        row.put("ARTIST_NAME", "ArtistXYZ");
        row.put("DATE_OF_BIRTH", new Date());
        DataObject object = context.objectFromDataRow(Artist.class, row);
        ObjectId oid = object.getObjectId();

        // insert object into the ObjectStore
        context.getObjectStore().registerNode(oid, object);
        assertSame(object, context.getObjectStore().getNode(oid));
        assertNotNull(context.getObjectStore().getCachedSnapshot(oid));

        context.getObjectStore().objectsUnregistered(Collections.singletonList(object));

        assertNull(object.getObjectId());
        assertNull(context.getObjectStore().getNode(oid));

        // in the future this may not be the case
        assertNull(context.getObjectStore().getCachedSnapshot(oid));
    }
View Full Code Here


     *
     * @return true if processing should continue, false otherwise
     */
    public boolean onSaveClick() {
        if (form.isValid()) {
            DataObject dataObject = form.getDataObject();

            saveDataObject(dataObject);

            clear();
        }
View Full Code Here

     * @return true if processing should continue, false otherwise
     */
    public boolean onEditClick() {
        Integer id = editLink.getValueInteger();
        if (id != null) {
            DataObject dataObject = getDataObject(id);
            form.setDataObject(dataObject);
        }
        return true;
    }
View Full Code Here

     * @return true if processing should continue, false otherwise
     */
    public boolean onRemoveClick() {
        Integer id = removeLink.getValueInteger();
        if (id != null) {
            DataObject dataObject = getDataObject(id);

            deleteDataObject(dataObject);

            clear();
        }
View Full Code Here

     *
     * @param object the object value to set
     */
    public void setValueObject(Object object) {
        if (object != null) {
            DataObject dataObject = (DataObject) object;
            valueObject = dataObject;

            CayenneForm form = (CayenneForm) getForm();
            String pkName = CayenneUtils.getPkName(form.getDataContext(),
                                                   dataObject.getClass());

            Object pk = dataObject.getObjectId().getIdSnapshot().get(pkName);

            if (pk != null) {
                value = pk.toString();
            }
        }
View Full Code Here

            DataContext dataContext = form.getDataContext();
            Class doClass = form.getDataObjectClass();
            Object doPk = form.getDataObjectPk();

            if (doPk != null) {
                DataObject dataObject =
                    CayenneUtils.getObjectForPK(dataContext, doClass, doPk);

                String getterName = ClickUtils.toGetterName(getName());

                try {
                    Method method = doClass.getMethod(getterName);

                    DataObject property =
                        (DataObject) method.invoke(dataObject);

                    if (property != null) {
                        Object propPk = DataObjectUtils.pkForObject(property);
                        setValue(propPk.toString());
View Full Code Here

            }

            Map cache = new HashMap();

            for (int i = 0; i < list.size(); i++) {
                DataObject dataObject = (DataObject) list.get(i);
                String value = DataObjectUtils.pkForObject(dataObject).toString();

                Object label = null;

                if (getDecorator() != null) {
View Full Code Here

     *
     * @return true if the <tt>DataObject</tt> was saved or false otherwise
     */
    public boolean saveChanges() {
        // Load data object into data context
        DataObject dataObject = getDataObject();

        if (!isPersistent(dataObject)) {
            getDataContext().registerNewObject(dataObject);
        }

View Full Code Here

            assertNotNull(toOnePrefetch);
            assertTrue(
                    "Expected DataObject, got: " + toOnePrefetch.getClass().getName(),
                    toOnePrefetch instanceof DataObject);

            DataObject pk1 = (DataObject) toOnePrefetch;
            assertEquals(PersistenceState.COMMITTED, pk1.getPersistenceState());
            assertEquals("CPK2", pk1.readPropertyDirectly("name"));
        }
        finally {
            unblockQueries();
        }
    }
View Full Code Here

                    // do not take the snapshot until generated columns are processed (see
                    // code above)
                    DataRow dataRow = parent.getContext().currentSnapshot(object);

                    if (object instanceof DataObject) {
                        DataObject dataObject = (DataObject) object;
                        dataRow.setReplacesVersion(dataObject.getSnapshotVersion());
                        dataObject.setSnapshotVersion(dataRow.getVersion());
                    }

                    modifiedSnapshots.put(finalId, dataRow);

                    // update Map reverse relationships
View Full Code Here

TOP

Related Classes of org.apache.cayenne.DataObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.