List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:com.haulmont.cuba.web.sys.VaadinSessionScope.java
License:Apache License
@Override public String getConversationId() { if (VaadinSession.getCurrent() == null || !VaadinSession.getCurrent().hasLock()) { throw new IllegalStateException("Unable to use VaadinSessionScope from non-Vaadin thread"); }/*from ww w .java 2s .co m*/ return VaadinSession.getCurrent().getSession().getId(); }
From source file:com.haulmont.cuba.web.sys.WebVaadinCompatibleSecurityContextHolder.java
License:Apache License
@Override public SecurityContext get() { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession != null && vaadinSession.hasLock()) { return vaadinSession.getAttribute(SecurityContext.class); }// w w w. jav a 2s .c om return super.get(); }
From source file:com.haulmont.cuba.web.sys.WebVaadinCompatibleSecurityContextHolder.java
License:Apache License
@Override public void set(SecurityContext securityContext) { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession != null && vaadinSession.hasLock()) { vaadinSession.setAttribute(SecurityContext.class, securityContext); } else {//from w w w . jav a2 s.c om super.set(securityContext); } }
From source file:com.hivesys.core.db.DocumentDB.java
public int createNewDocumentRecord(Document doc) throws SQLException { Connection conn = DBConnectionPool.getInstance().reserveConnection(); SQLTemplates config = DBConnectionPool.getInstance().getSQLTemplates(); QDocument qdocument = QDocument.Document; Timestamp stampUploaded = new Timestamp(doc.getDateUploaded().getTime()); Timestamp stampCreated = new Timestamp(doc.getDateCreated().getTime()); final User user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName()); new SQLInsertClause(conn, config, qdocument).set(qdocument.uploadDate, stampUploaded) .set(qdocument.createdDate, stampCreated).set(qdocument.hash, doc.getHash()) .set(qdocument.description, doc.getDescription()).set(qdocument.author, doc.getAuthor()) .set(qdocument.userId, user.getId()).set(qdocument.fileName, doc.getRootFileName()) .set(qdocument.filePath, doc.getContentFilepath()).set(qdocument.boxViewID, doc.getBoxViewID()) .execute();// w w w. j a v a 2 s . c o m int docID = getDocumentIDFromHash(doc.getHash()); DBConnectionPool.getInstance().releaseConnection(conn); return docID; }
From source file:com.hivesys.dashboard.view.preferences.PreferencesView.java
License:Apache License
public PreferencesView() { user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName()); setSpacing(true);//from w w w .j av a 2 s .com setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); firstNameField = new TextField("First Name"); firstNameField.setWidth("50%"); form.addComponent(firstNameField); lastNameField = new TextField("Last Name"); lastNameField.setWidth("50%"); form.addComponent(lastNameField); titleField = new ComboBox("Title"); titleField.setInputPrompt("Please specify"); titleField.addItem("Mr."); titleField.addItem("Mrs."); titleField.addItem("Ms."); titleField.setNewItemsAllowed(true); form.addComponent(titleField); usernameField = new TextField("Username"); usernameField.setRequired(true); form.addComponent(usernameField); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); form.addComponent(sexField); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("50%"); emailField.setRequired(true); form.addComponent(emailField); locationField = new TextField("Location"); locationField.setWidth("50%"); locationField.setNullRepresentation(""); form.addComponent(locationField); phoneField = new TextField("Phone"); phoneField.setWidth("50%"); phoneField.setNullRepresentation(""); form.addComponent(phoneField); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); websiteField = new TextField("Website"); websiteField.setInputPrompt("http://"); websiteField.setWidth("100%"); form.addComponent(websiteField); bioField = new RichTextArea("Bio"); bioField.setWidth("100%"); bioField.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bioField); Button edit = new Button("Edit", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bioField.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bioField.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); fieldGroup = new BeanFieldGroup<>(User.class); fieldGroup.bindMemberFields(this); fieldGroup.setItemDataSource(user); form.setReadOnly(true); bioField.setReadOnly(true); }
From source file:com.hris.serviceprovider.UserServiceImpl.java
@Override public boolean loggedIn(String username, String password) { Connection conn = DBConnection.connect(); PreparedStatement pstmt = null; ResultSet rs = null;/*w w w . j ava 2 s .co m*/ boolean isResult = false; try { pstmt = conn.prepareStatement("SELECT COUNT(*) AS LoginValue, " + "u.id AS id, " + "u.username_ AS username, " + "u.userRole AS userRole " + "FROM user_ u " + "WHERE u.username_ = ? AND u.password_ = ? " + "AND u.UserStatus = 0 " + "GROUP BY u.id "); pstmt.setString(1, username); pstmt.setString(2, password); rs = pstmt.executeQuery(); while (rs.next()) { // SystemLog sl = new SystemLog(); // sl.setUserId(CommonUtil.convertStringToInteger(rs.getString("UserID"))); // sl.setEntryDateTime(new Date()); if (!rs.getString("LoginValue").equals("0")) { // sl.setActivity(SystemLogDefaults.LOGGED_IN); // sls.insert(sl); VaadinSession.getCurrent().setAttribute("username", rs.getString("username")); VaadinSession.getCurrent().setAttribute("userId", rs.getString("id")); VaadinSession.getCurrent().setAttribute("userRole", rs.getString("userRole")); isResult = true; } // else { // sl.setActivity(SystemLogDefaults.UNSUCCESSFUL_LOGGED_IN+" with USERNAME: "+username); // sls.insert(sl); // } } } catch (SQLException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.getMessage(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null || !conn.isClosed()) { pstmt.close(); rs.close(); conn.close(); } } catch (SQLException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.getMessage(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } } return isResult; }
From source file:com.hybridbpm.ui.HybridbpmUI.java
License:Apache License
public static DevelopmentAPI getDevelopmentAPI() { return DevelopmentAPI.get(getCurrent().user, VaadinSession.getCurrent().getSession().getId()); }
From source file:com.hybridbpm.ui.HybridbpmUI.java
License:Apache License
public static DocumentAPI getDocumentAPI() { return DocumentAPI.get(getCurrent().user, VaadinSession.getCurrent().getSession().getId()); }
From source file:com.hybridbpm.ui.HybridbpmUI.java
License:Apache License
public static CommentAPI getCommentAPI() { return CommentAPI.get(getCurrent().user, VaadinSession.getCurrent().getSession().getId()); }
From source file:com.hybridbpm.ui.HybridbpmUI.java
License:Apache License
public static DashboardAPI getDashboardAPI() { return DashboardAPI.get(getCurrent().user, VaadinSession.getCurrent().getSession().getId()); }