private JpaPageLayout createEntity(PageLayout source) { JpaPageLayout converted = null; if (source != null) { TypedQuery<JpaPageLayout> query = manager.createNamedQuery(JpaPageLayout.PAGELAYOUT_GET_BY_LAYOUT_CODE, JpaPageLayout.class); query.setParameter(JpaPageLayout.CODE_PARAM, source.getCode()); converted = getSingleResult(query.getResultList()); if (converted == null) { converted = new JpaPageLayout(); } updateProperties(source, converted); } return converted; }
@Override @Transactional public Page addNewDefaultUserPage(String userId) { User user = userService.getUserById(userId); return addNewUserPage(user, defaultPageName, user.getDefaultPageLayout().getCode()); }
public PageLayout(org.apache.rave.model.PageLayout source) { this.code = source.getCode(); this.numberOfRegions = source.getNumberOfRegions(); this.renderSequence = source.getRenderSequence(); this.userSelectable = source.isUserSelectable(); }
public PageTemplate(org.apache.rave.model.PageTemplate source) { this.id = source.getId(); this.name = source.getName(); this.description = source.getDescription(); this.pageType = source.getPageType(); this.pageLayoutCode = source.getPageLayout().getCode(); this.defaultTemplate = source.isDefaultTemplate(); }
public Page(org.apache.rave.model.Page source) { this.id = source.getId(); this.name = source.getName(); this.ownerId = source.getOwnerId(); this.pageType = source.getPageType().toString(); this.pageLayoutCode = source.getPageLayout().getCode(); this.properties = source.getProperties(); this.subPages = createSubPages(source); this.regions = createRegions(source); this.members = createPageUsers(source); }
@Transactional public Boolean clonePageForUser(String pageId, String userId, String pageName) { Page page = getPage(pageId); if(pageName == null || pageName.equals("null")){ // try to use the original page name if none supplied pageName = page.getName(); } Page clonedPage = addNewUserPage(userService.getUserById(userId), pageName, page.getPageLayout().getCode()); // populate all the widgets in cloned page from original for(int i=0; i<page.getRegions().size(); i++){ for(int j=0; j<page.getRegions().get(i).getRegionWidgets().size(); j++){ String widgetId = page.getRegions().get(i).getRegionWidgets().get(j).getWidgetId(); addWidgetToPageRegion(clonedPage.getId(), widgetId, clonedPage.getRegions().get(i).getId()); } } clonedPage = getFromRepository(clonedPage.getId(), pageRepository); // newly created page - so only one pageUser PageUser pageUser = clonedPage.getMembers().get(0); // update status to pending pageUser.setPageStatus(PageInvitationStatus.PENDING); if(pageRepository.save(clonedPage) != null){ return Boolean.TRUE; }else{ return Boolean.FALSE; } }
private void updateProperties(PageLayout source, JpaPageLayout converted) { converted.setCode(source.getCode()); converted.setNumberOfRegions(source.getNumberOfRegions()); converted.setRenderSequence(source.getRenderSequence()); converted.setUserSelectable(source.isUserSelectable()); } }
@RequestMapping(value = "/page/view/{pageId}", method = RequestMethod.GET) public String view(@PathVariable String pageId, Model model, HttpServletRequest request) { try { List<Page> pages = getAllPagesForAuthenticatedUser(); Page page = pageService.getPageFromList(pageId, pages); PageUser currentPageUser = null; User thisUser = userService.getAuthenticatedUser(); for(PageUser pageUser : page.getMembers()){ if(pageUser.getUserId().equals(thisUser.getId())){ currentPageUser = pageUser; } } List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable(); addAttributesToModel(model, page, currentPageUser, pages, pageLayouts); String view = ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME); ControllerUtils.addNavItemsToModel(view, model, page.getId(), thisUser, currentPageUser.isEditor()); return view; } catch (Exception e) { logger.info("unable to get page - possibly because a shared page was revoked by its owner"); } // Page could not be found or a shared page was removed, in which case return to default view return viewDefault(model, request); }
public void buildModel(Page page, String omdlUrl, String wookieUrl) { this.wookieUrl = wookieUrl; OmdlWidget omdlWidget = null; this.status = new Status(OmdlModelUtils.getDate(), DEFAULT_STATUS); this.page = page; this.identifier = omdlUrl; this.title = page.getName(); this.description = DEFAULT_DESCRIPTION; this.creator = getCreator(page); this.date = OmdlModelUtils.getDate(); this.layout = OmdlModelUtils.getOmdlLayoutForExport(page.getPageLayout().getCode()); widgetsList = new ArrayList<OmdlWidget>(); for(int i=0;i<page.getRegions().size(); i++){ for(int j=0;j<page.getRegions().get(i).getRegionWidgets().size();j++){ Widget widget = widgetService.getWidget(page.getRegions().get(i).getRegionWidgets().get(j).getWidgetId()); omdlWidget = new OmdlWidget(); omdlWidget.setUrl(widget.getUrl()); omdlWidget.setLink(createLinkElement(widget.getType(), widget.getUrl())); // figure out what positioning to use for this widget String position = OmdlModelUtils.getPositionString(i+1, page.getRegions().size(), j+1, page.getRegions().get(i).getRegionWidgets().size()); if(position != null && position !=""){ omdlWidget.setPosition(position); } omdlWidget.setWidgetType(UNKNOWN_VALUE); widgetsList.add(omdlWidget); } } }
private String viewProfileCommon(User user, ModelMap model, String referringPageId){ Page personProfilePage = pageService.getPersonProfilePage(user.getId()); addAttributesToModel(model, user, referringPageId); model.addAttribute(ModelKeys.PAGE, personProfilePage); String view = ViewNames.getPersonPageView(personProfilePage.getPageLayout().getCode()); List<Person> friendRequests = userService.getFriendRequestsReceived(user.getUsername()); addNavItemsToModel(view, model, referringPageId, user, friendRequests); return view; }
@RequestMapping(value = {"/page/view", "/index.html"}, method = RequestMethod.GET) public String viewDefault(Model model, HttpServletRequest request) { List<Page> pages = getAllPagesForAuthenticatedUser(); Page page = pageService.getDefaultPageFromList(pages); PageUser currentPageUser = null; User thisUser = userService.getAuthenticatedUser(); for(PageUser pageUser : page.getMembers()){ if(pageUser.getUserId().equals(thisUser.getId())){ currentPageUser = pageUser; } } List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable(); addAttributesToModel(model, page, currentPageUser, pages, pageLayouts); String view = ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME); ControllerUtils.addNavItemsToModel(view, model, page.getId(), userService.getAuthenticatedUser(), currentPageUser.isEditor()); return view; }