Package org.apache.isis.applib.services.bookmark

Examples of org.apache.isis.applib.services.bookmark.Bookmark


            final String title = oidStr + ": " + actionIdentifier.toNameParmsIdentityString();
           
            final Command command = currentInvocation.getCommand();
            final String targetClass = command.getTargetClass();
            final String targetAction = command.getTargetAction();
            final Bookmark target = command.getTarget();
            final String memberIdentifier = command.getMemberIdentifier();
           
            final EventMetadata metadata = newEventMetadata(EventType.ACTION_INVOCATION, currentUser, timestamp, title, targetClass, targetAction, target, memberIdentifier);
            publishingService.publishAction(payloadFactory, metadata, currentInvocation, objectStringifier());
        } finally {
View Full Code Here


            final String title = oidStr;
       
            final EventType eventTypeFor = eventTypeFor(changeKind);
           
            final String enlistedAdapterClass = CommandUtil.targetClassNameFor(enlistedAdapter);
            final Bookmark enlistedTarget = enlistedAdapterOid.asBookmark();
           
            final EventMetadata metadata = newEventMetadata(eventTypeFor, currentUser, timestamp, title, enlistedAdapterClass, null, enlistedTarget, null);
       
            publishingService.publishObject(payloadFactory, metadata, enlistedAdapter, changeKind, objectStringifier());
        }
View Full Code Here

        final ObjectAssociation property = aap.getProperty();
        final String memberId = property.getIdentifier().toClassAndNameIdentityString();
        final String propertyId = property.getId();

        final String targetClass = CommandUtil.targetClassNameFor(adapter);
        final Bookmark target = new Bookmark(objectType, identifier);

        auditingService3.audit(getTransactionId(), targetClass, target, memberId, propertyId, preValue, postValue, user, timestamp);
    }
View Full Code Here

     */
    @Override
    @NotInServiceMenu
    @NotContributed(As.ASSOCIATION)
    public Object lookup(final BookmarkHolder bookmarkHolder) {
        Bookmark bookmark = bookmarkHolder.bookmark();
        return bookmark != null? lookup(bookmark): null;
    }
View Full Code Here

                final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
                final String targetClassName = CommandUtil.targetClassNameFor(targetAdapter);
                final String targetActionName = CommandUtil.targetActionNameFor(action);
                final String targetArgs = CommandUtil.argDescriptionFor(action, adaptersFor(args));
               
                final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);

                final List<Class<?>> argTypes = Lists.newArrayList();
                final List<Object> argObjs = Lists.newArrayList();
                CommandUtil.buildMementoArgLists(mementoService, bookmarkService, proxiedMethod, args, argTypes, argObjs);
View Full Code Here

        }

        final ObjectAction action = (ObjectAction) member;
        final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
       
        final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);

        final List<Class<?>> argTypes = Lists.newArrayList();
        final List<Object> argObjs = Lists.newArrayList();
        CommandUtil.buildMementoArgLists(mementoService, bookmarkService, method, args, argTypes, argObjs);
View Full Code Here

        memento.set("someBooleanFalse", Boolean.FALSE);
        memento.set("someBigInteger", new BigInteger("123456789012345678901234567890"));
        memento.set("someBigDecimal", new BigDecimal("123456789012345678901234567890.123456789"));
        memento.set("someLocalDate", new LocalDate(2013,9,3));
       
        memento.set("someBookmark", new Bookmark("CUS", "12345"));
        memento.set("someNullValue", null);
       
        memento.set("someEnum", DOW.Wed);
       
        final String str = memento.asString();
       
        final Memento memento2 = mementoService.parse(str);
       
        assertThat(memento2.get("someString", String.class), is("a string"));
        assertThat(memento2.get("someStringWithDoubleSpaces", String.class), is("a  string"));
        assertThat(memento2.get("someByte", Byte.class), is((byte)123));
        assertThat(memento2.get("someShort", Short.class), is((short)12345));
        assertThat(memento2.get("someInt", Integer.class), is(123456789));
        assertThat(memento2.get("someLong", Long.class), is(1234567890123456789L));
        assertThat(memento2.get("someFloat", Float.class), is(123.45F));
        assertThat(memento2.get("someDouble", Double.class), is(1234567890.123456));
        assertThat(memento2.get("someBooleanTrue", Boolean.class), is(Boolean.TRUE));
        assertThat(memento2.get("someBooleanFalse", Boolean.class), is(Boolean.FALSE));
        assertThat(memento2.get("someBigInteger", BigInteger.class), is(new BigInteger("123456789012345678901234567890")));
        assertThat(memento2.get("someBigDecimal", BigDecimal.class), is(new BigDecimal("123456789012345678901234567890.123456789")));
        assertThat(memento2.get("someLocalDate", LocalDate.class), is(new LocalDate(2013,9,3)));
        assertThat(memento2.get("someBookmark", Bookmark.class), is(new Bookmark("CUS", "12345")));
       
        // a nullValue can be grabbed as any type, will always succeed
        assertThat(memento2.get("someNullValue", Integer.class), is(nullValue()));
        assertThat(memento2.get("someNullValue", Bookmark.class), is(nullValue()));
        assertThat(memento2.get("someNullValue", LocalDate.class), is(nullValue()));
View Full Code Here

                    final String memento = command.getMemento();
                    final ActionInvocationMemento aim = new ActionInvocationMemento(mementoService, memento);

                    final String actionId = aim.getActionId();

                    final Bookmark targetBookmark = aim.getTarget();
                    final Object targetObject = bookmarkService.lookup(targetBookmark);

                    final ObjectAdapter targetAdapter = adapterFor(targetObject);
                    final ObjectSpecification specification = targetAdapter.getSpecification();

                    final ObjectAction objectAction = findAction(specification, actionId);
                    if(objectAction == null) {
                        throw new Exception("Unknown action '" + actionId + "'");
                    }

                    final ObjectAdapter[] argAdapters = argAdaptersFor(aim);
                    final ObjectAdapter resultAdapter = objectAction.execute(targetAdapter, argAdapters);
                    if(resultAdapter != null) {
                        Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter);
                        command.setResult(resultBookmark);
                    }

                } catch (Exception e) {
                    command.setException(Throwables.getStackTraceAsString(e));
View Full Code Here

            return null;
        }
        if(Bookmark.class != argType) {
            return adapterFor(arg);
        } else {
            final Bookmark argBookmark = (Bookmark)arg;
            final RootOid rootOid = RootOidDefault.create(argBookmark);
            return adapterFor(rootOid);
        }
    }
View Full Code Here

                } else {
                    command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
                    command.setTargetAction(CommandUtil.targetActionNameFor(owningAction));
                    command.setArguments(CommandUtil.argDescriptionFor(owningAction, arguments));
                   
                    final Bookmark targetBookmark = CommandUtil.bookmarkFor(targetAdapter);
                    command.setTarget(targetBookmark);
                }

                command.setMemberIdentifier(CommandUtil.actionIdentifierFor(owningAction));

                // the background service is used here merely as a means to capture an invocation memento
                final BackgroundService backgroundService = getServicesInjector().lookupService(BackgroundService.class);
                if(backgroundService != null) {
                    final Object targetObject = unwrap(targetAdapter);
                    final Object[] args = CommandUtil.objectsFor(arguments);
                    ActionInvocationMemento aim = backgroundService.asActionInvocationMemento(method, targetObject, args);

                    if(aim != null) {
                        command.setMemento(aim.asMementoString());
                    } else {
                        throw new IsisException(
                            "Unable to build memento for action " +
                            owningAction.getIdentifier().toClassAndNameIdentityString());
                    }
                }

                // copy over the command execution 'context' (if available)
                final CommandFacet commandFacet = getFacetHolder().getFacet(CommandFacet.class);
                if(commandFacet != null && !commandFacet.isDisabled()) {
                    command.setExecuteIn(commandFacet.executeIn());
                    command.setPersistence(commandFacet.persistence());
                } else {
                    // if no facet, assume do want to execute right now, but only persist (eventually) if hinted.
                    command.setExecuteIn(ExecuteIn.FOREGROUND);
                    command.setPersistence(Persistence.IF_HINTED);
                }
            }
           
           
            if( command != null &&
                command.getExecutor() == Executor.USER &&
                command.getExecuteIn() == ExecuteIn.BACKGROUND) {
               
                // persist command so can be this command can be in the 'background'
                final CommandService commandService = getServicesInjector().lookupService(CommandService.class);
                if(commandService.persistIfPossible(command)) {
                    // force persistence, then return the command itself.
                    final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(command);
                    return InvocationResult.forActionThatReturned(resultAdapter);
                } else {
                    throw new IsisException(
                            "Unable to schedule action '"
                            + owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
                            + "CommandService does not support persistent commands " );
                }
            } else {
               
                // otherwise, go ahead and execute action in the 'foreground'

                if(command != null) {
                    command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
                }
               
                final Object result = method.invoke(object, executionParameters);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(" action result " + result);
                }
                if (result == null) {
                  return InvocationResult.forActionThatReturned(null);
                }

                final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(result);

                // copy over TypeOfFacet if required
                final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
                resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));

                if(command != null) {
                    if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
                        final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
                        command.setResult(bookmark);
                    }
                }
               
                final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.services.bookmark.Bookmark

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.