Examples of MementoService


Examples of org.apache.isis.applib.services.memento.MementoService

    }

    @Override
    public void initialize(Object viewModelPojo, String mementoStr) {

        final MementoService mementoService = servicesInjector.lookupService(MementoService.class);
        final BookmarkService bookmarkService = servicesInjector.lookupService(BookmarkService.class);

        final MementoService.Memento memento = mementoService.parse(mementoStr);

        final Set<String> mementoKeys = memento.keySet();

        // manually recreate the adapter in order to be able to query state via the metamodel
        ObjectAdapter viewModelAdapter = adapterManager.getAdapterFor(viewModelPojo);
View Full Code Here

Examples of org.apache.isis.applib.services.memento.MementoService

    }
   
    @Override
    public String memento(Object viewModelPojo) {

        final MementoService mementoService = servicesInjector.lookupService(MementoService.class);
        final BookmarkService bookmarkService = servicesInjector.lookupService(BookmarkService.class);

        final MementoService.Memento memento = mementoService.create();

        // this is horrible, but there's a catch-22 here...
        // we need an adapter in order to query the state of the object via the metamodel, on the other hand
        // we can't create an adapter without the identifier, which is what we're trying to derive
        // so... we create a temporary transient adapter, use it to wrap this adapter and interrogate this pojo,
        // then throw away that adapter (remove from the adapter map)
        boolean createdTemporaryAdapter = false;
        ObjectAdapter viewModelAdapter = adapterManager.getAdapterFor(viewModelPojo);
        if(viewModelAdapter == null) {
            final ObjectSpecification objectSpecification = specificationLoader.loadSpecification(viewModelPojo.getClass());
            final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
            viewModelAdapter = adapterManager.mapRecreatedPojo(RootOidDefault.create(objectSpecId, UUID.randomUUID().toString()), viewModelPojo);

            createdTemporaryAdapter = true;
        }

        try {
            final ObjectSpecification spec = viewModelAdapter.getSpecification();
            final List<OneToOneAssociation> properties = spec.getProperties(Contributed.EXCLUDED);
            for (OneToOneAssociation property : properties) {
                // ignore read-only
                if(!property.containsDoOpFacet(PropertySetterFacet.class)) {
                    continue;
                }
                // ignore those explicitly annotated as @NotPersisted
                if(property.isNotPersisted()) {
                    continue;
                }

                // otherwise, include
                final ObjectAdapter propertyValueAdapter = property.get(adapterManager.adapterFor(viewModelPojo));
                if(propertyValueAdapter != null) {
                    final Object propertyValue = propertyValueAdapter.getObject();
                    if(mementoService.canSet(propertyValue)) {
                        memento.set(property.getId(), propertyValue);
                    } else {
                        final Bookmark propertyValueBookmark = bookmarkService.bookmarkFor(propertyValue);
                        memento.set(property.getId() + ".bookmark", propertyValueBookmark);
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.