private ApplicationSettingJdo newSetting( final String key, final String description, final SettingType settingType, final String valueRaw) { final ApplicationSettingJdo setting = repositoryService.instantiate(ApplicationSettingJdo.class); setting.setKey(key); setting.setDescription(description); setting.setValueRaw(valueRaw); setting.setType(settingType); repositoryService.persist(setting); return setting; } //endregion
private UserSettingJdo newSetting( final String user, final String key, final String description, final SettingType settingType, final String valueRaw) { final UserSettingJdo setting = repositoryService.instantiate(UserSettingJdo.class); setting.setUser(user); setting.setKey(key); setting.setType(settingType); setting.setDescription(description); setting.setValueRaw(valueRaw); repositoryService.persist(setting); return setting; } //endregion
final L link = repositoryService.instantiate(subtype); link.setPolymorphicReference(polymorphicReference);
/** * This is an idempotent operation. */ @Programmatic public Paperclip attach( final DocumentAbstract documentAbstract, final String roleName, final Object attachTo) { Paperclip paperclip = findByDocumentAndAttachedToAndRoleName( documentAbstract, attachTo, roleName); if(paperclip != null) { return paperclip; } final Class<? extends Paperclip> subtype = subtypeClassFor(attachTo); paperclip = repositoryService.instantiate(subtype); paperclip.setDocument(documentAbstract); paperclip.setRoleName(roleName); if(documentAbstract instanceof Document) { final Document document = (Document) documentAbstract; paperclip.setDocumentCreatedAt(document.getCreatedAt()); } if(!repositoryService.isPersistent(attachTo)) { transactionService.flushTransaction(); } final Bookmark bookmark = bookmarkService.bookmarkFor(attachTo); paperclip.setAttachedTo(attachTo); paperclip.setAttachedToStr(bookmark.toString()); repositoryService.persistAndFlush(paperclip); return paperclip; }
/** * This is an idempotent operation. */ @Programmatic public Paperclip attach( final DocumentAbstract documentAbstract, final String roleName, final Object attachTo) { Paperclip paperclip = findByDocumentAndAttachedToAndRoleName( documentAbstract, attachTo, roleName); if(paperclip != null) { return paperclip; } final Class<? extends Paperclip> subtype = subtypeClassFor(attachTo); paperclip = repositoryService.instantiate(subtype); paperclip.setDocument(documentAbstract); paperclip.setRoleName(roleName); if(documentAbstract instanceof Document) { final Document document = (Document) documentAbstract; paperclip.setDocumentCreatedAt(document.getCreatedAt()); } if(!repositoryService.isPersistent(attachTo)) { transactionService.flushTransaction(); } final Bookmark bookmark = bookmarkService.bookmarkFor(attachTo); paperclip.setAttachedTo(attachTo); paperclip.setAttachedToStr(bookmark.toString()); repositoryService.persistAndFlush(paperclip); return paperclip; }