public BookmarkWithHintId(final Bookmark bookmark, final String hintId) { super(bookmark.toString()); this.hintId = hintId; }
protected String sessionAttributeFor(final Bookmark bookmark) { return "hint-" + bookmark.toString(); }
@Deprecated public static String asString(Bookmark bookmark) { return bookmark != null? bookmark.toString(): null; }
@Override public String get(final Bookmark bookmark, final String key) { final Map<String, String> hintsForBookmark = hintsFor(bookmark); final String value = hintsForBookmark.get(key); if(LOG.isDebugEnabled()) { LOG.debug(String.format("GET %s / %s returns %s", bookmark.toString(), key, value)); } return value; }
@Override public void set(final Bookmark bookmark, final String key, final String value) { final Map<String, String> hintsForBookmark = hintsFor(bookmark); if(LOG.isDebugEnabled()) { LOG.debug(String.format("SET %s / %s to %s", bookmark.toString(), key, value)); } hintsForBookmark.put(key, value); }
@Programmatic @Override public void audit( final UUID transactionId, final String targetClassName, final Bookmark target, final String memberId, final String propertyName, final String preValue, final String postValue, final String user, final Timestamp timestamp) { String auditMessage = target.toString() + " by " + user + ", " + propertyName +": " + preValue + " -> " + postValue; System.err.println(auditMessage); } }
@Override public void remove(final Bookmark bookmark, final String key) { final Map<String, String> hintsForBookmark = hintsFor(bookmark); if(LOG.isDebugEnabled()) { LOG.debug(String.format("REMOVE %s / %s", bookmark.toString(), key)); } hintsForBookmark.remove(key); }
@Programmatic @Override public void audit( final UUID interactionId, int sequence, final String targetClassName, final Bookmark target, final String memberId, final String propertyName, final String preValue, final String postValue, final String user, final Timestamp timestamp) { String auditMessage = interactionId + "," + sequence + ": " + target.toString() + " by " + user + ", " + propertyName + ": " + preValue + " -> " + postValue; LOG.debug(auditMessage); }
@Programmatic public void setTarget(Bookmark target) { final String targetStr = target != null ? target.toString() : null; setTargetStr(targetStr); }
@Programmatic public List<Paperclip> findByAttachedTo(final Object attachedTo) { if(attachedTo == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(Paperclip.class, "findByAttachedTo", "attachedToStr", attachedToStr)); } //endregion
@Programmatic public List<Paperclip> findByAttachedTo(final Object attachedTo) { if(attachedTo == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(Paperclip.class, "findByAttachedTo", "attachedToStr", attachedToStr)); } //endregion
@Programmatic public List<Paperclip> findByAttachedToAndRoleName( final Object attachedTo, final String roleName) { if(attachedTo == null) { return null; } if(roleName == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(Paperclip.class, "findByAttachedToAndRoleName", "attachedToStr", attachedToStr, "roleName", roleName)); } //endregion
@Programmatic public List<Paperclip> findByDocumentAndAttachedTo( final DocumentAbstract<?> document, final Object attachedTo) { if(document == null) { return null; } if(attachedTo == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(Paperclip.class, "findByDocumentAndAttachedTo", "document", document, "attachedToStr", attachedToStr)); } //endregion
@Programmatic public List<Paperclip> findByDocumentAndAttachedTo( final DocumentAbstract<?> document, final Object attachedTo) { if(document == null) { return null; } if(attachedTo == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(Paperclip.class, "findByDocumentAndAttachedTo", "document", document, "attachedToStr", attachedToStr)); } //endregion
@Programmatic public List<Paperclip> findByAttachedToAndRoleName( final Object attachedTo, final String roleName) { if(attachedTo == null) { return null; } if(roleName == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(Paperclip.class, "findByAttachedToAndRoleName", "attachedToStr", attachedToStr, "roleName", roleName)); } //endregion
@Programmatic public Paperclip findByDocumentAndAttachedToAndRoleName( final DocumentAbstract<?> document, final Object attachedTo, final String roleName) { if(document == null) { return null; } if(attachedTo == null) { return null; } if(roleName == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo); if(bookmark == null) { return null; } final String attachedToStr = bookmark.toString(); return repositoryService.firstMatch( new QueryDefault<>(Paperclip.class, "findByDocumentAndAttachedToAndRoleName", "document", document, "attachedToStr", attachedToStr, "roleName", roleName)); } //endregion
private AdapterAndProperty(ObjectAdapter adapter, ObjectAssociation property) { this.objectAdapter = adapter; this.property = property; final RootOid oid = (RootOid) adapter.getOid(); final String objectType = oid.getObjectSpecId().asString(); final String identifier = oid.getIdentifier(); bookmark = new Bookmark(objectType, identifier); bookmarkStr = bookmark.toString(); propertyId = property.getId(); }
private EventMetadata newEventMetadata( final String currentUser, final Timestamp timestamp, final ChangeKind changeKind, final String enlistedAdapterClass, final Bookmark enlistedTarget) { final EventType eventType = PublishingServiceInternalDefault.eventTypeFor(changeKind); final Interaction interaction = interactionContext.getInteraction(); final int nextEventSequence = interaction.next(Interaction.Sequence.PUBLISHED_EVENT.id()); final UUID transactionId = interaction.getTransactionId(); return new EventMetadata( transactionId, nextEventSequence, eventType, currentUser, timestamp, enlistedTarget.toString(), enlistedAdapterClass, null, enlistedTarget, null, null, null, null); }
@Override @Programmatic public PropertyEditDto asPropertyEditDto( final OneToOneAssociation property, final ObjectAdapter targetAdapter, final ObjectAdapter newValueAdapterIfAny) { final Interaction interaction = interactionContext.getInteraction(); final int nextEventSequence = interaction.next(Interaction.Sequence.INTERACTION.id()); final Object targetPojo = targetAdapter.getObject(); final Bookmark targetBookmark = bookmarkService.bookmarkFor(targetPojo); final String propertyIdentifier = property.getIdentifier().toClassAndNameIdentityString(); final String propertyId = propertyIdentifier.substring(propertyIdentifier.indexOf('#')+1); final String targetTitle = targetBookmark.toString() + ": " + propertyId; final String currentUser = userService.getUser().getName(); final PropertyDto propertyDto = new PropertyDto(); commandDtoServiceInternal.addPropertyValue(property, propertyDto, newValueAdapterIfAny); final ValueWithTypeDto newValue = propertyDto.getNewValue(); return InteractionDtoUtils.newPropertyEdit( nextEventSequence, targetBookmark, targetTitle, propertyDto.getMemberIdentifier(), newValue, currentUser ); }
public CommandDto process(final Command command, CommandDto commandDto) { // for some reason this isn't being persisted initially, so patch it in. TODO: should fix this commandDto.setUser(command.getUser()); // the timestamp field was only introduced in v1.4 of cmd.xsd, so there's no guarantee // it will have been populated. We therefore copy the value in from CommandWithDto entity. if(commandDto.getTimestamp() == null) { final Timestamp timestamp = command.getTimestamp(); commandDto.setTimestamp(JavaSqlTimestampXmlGregorianCalendarAdapter.print(timestamp)); } CommandDtoUtils.setUserData(commandDto, CommandWithDto.USERDATA_KEY_TARGET_CLASS, command.getTargetClass()); CommandDtoUtils.setUserData(commandDto, CommandWithDto.USERDATA_KEY_TARGET_ACTION, command.getTargetAction()); CommandDtoUtils.setUserData(commandDto, CommandWithDto.USERDATA_KEY_ARGUMENTS, command.getArguments()); final Bookmark result = command.getResult(); CommandDtoUtils.setUserData(commandDto, CommandWithDto.USERDATA_KEY_RETURN_VALUE, result != null ? result.toString() : null); // knowing whether there was an exception is on the master is used to determine whether to // continue when replayed on the slave if an exception occurs there also CommandDtoUtils.setUserData(commandDto, CommandWithDto.USERDATA_KEY_EXCEPTION, command.getException()); PeriodDto timings = CommandDtoUtils.timingsFor(commandDto); timings.setStartedAt(JavaSqlTimestampXmlGregorianCalendarAdapter.print(command.getStartedAt())); timings.setCompletedAt(JavaSqlTimestampXmlGregorianCalendarAdapter.print(command.getCompletedAt())); return commandDto; } }