Package com.rapleaf.jack.test_project.database_1.models

Examples of com.rapleaf.jack.test_project.database_1.models.User


    IImagePersistence images = dbs.getDatabase1().images();

    Image i1 = images.createDefaultInstance();
    i1.save();

    User u1 = i1.createUser();
    assertEquals(Long.valueOf(u1.getId()), Long.valueOf(i1.getUserId()));
    IUserPersistence users = dbs.getDatabase1().users();
    User userInDb = users.find(i1.getUserId());
    assertEquals(u1, userInDb);
    Image imageInDb = images.find(i1.getId());
    assertEquals(i1, imageInDb);
  }
View Full Code Here


        } else {
          stmt.setBoolean(10, some_boolean);
        }
      }
    }, getInsertStatement(Arrays.<String>asList("handle", "created_at_millis", "num_posts", "some_date", "some_datetime", "bio", "some_binary", "some_float", "some_decimal", "some_boolean")));
    User newInst = new User(__id, handle, created_at_millis, num_posts, some_date, some_datetime, bio, some_binary, some_float, some_decimal, some_boolean, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

      public void set(PreparedStatement stmt) throws SQLException {
          stmt.setString(1, handle);
          stmt.setInt(2, num_posts);
      }
    }, getInsertStatement(Arrays.<String>asList("handle", "num_posts")));
    User newInst = new User(__id, handle, null, num_posts, null, null, null, null, null, null, null, databases);
    newInst.setCreated(true);
    cachedById.put(__id, newInst);
    clearForeignKeyCache();
    return newInst;
  }
View Full Code Here

  }

  @Override
  protected User instanceFromResultSet(ResultSet rs, Set<Enum> selectedFields) throws SQLException {
    boolean allFields = selectedFields == null || selectedFields.isEmpty();
    return new User(rs.getLong("id"),
      allFields || selectedFields.contains(User._Fields.handle) ? rs.getString("handle") : "",
      allFields || selectedFields.contains(User._Fields.created_at_millis) ? getLongOrNull(rs, "created_at_millis") : null,
      allFields || selectedFields.contains(User._Fields.num_posts) ? getIntOrNull(rs, "num_posts") : 0,
      allFields || selectedFields.contains(User._Fields.some_date) ? getDateAsLong(rs, "some_date") : null,
      allFields || selectedFields.contains(User._Fields.some_datetime) ? getDateAsLong(rs, "some_datetime") : null,
View Full Code Here

            if (node.size() > 0) {
                item = Item.parseItemFromJSON(node);
            }

            String endpoint = conn.getURL().toString();
            User user = new User();
            user = user.getUserFromSession(session());
            return ok(views.html.item.detail.render(user, item, "Single Item", contentString.toString(), endpoint));

        } catch (MalformedURLException e) {
            return badRequest(e.getMessage());
        } catch (IOException e) {
View Full Code Here

            }

            String endpoint = conn.getURL().toString();
            conn.disconnect();

            User user = new User();
            user = user.getUserFromSession(session());

            ObjectMapper mapper = new ObjectMapper();
            String pretty = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode);

            return ok(views.html.community.index.render(user, communities, "Top Level Communities", pretty, endpoint));
View Full Code Here

    public static Result show(Long id) {
        Logger.info("SHOW");
        RestResponse response = Community.findByID(id);
        if(response.modelObject instanceof Community) {
            Community community = (Community) response.modelObject;
            User user = new User();
            user = user.getUserFromSession(session());

            String flash = flash("success");
            return ok(views.html.community.detail.render(user, community, "Single Community", response.jsonString, response.endpoint, flash));
        } else {
            return internalServerError();
View Full Code Here

            return internalServerError();
        }
    }
    public static Result editForm(Long id) {
        Logger.info("EDITFORM");
        User user = new User();
        user = user.getUserFromSession(session());
        Form<Community> communityForm = form(Community.class);

        RestResponse response = Community.findByID(id);
        if(response.modelObject instanceof Community) {
            Community community = (Community) response.modelObject;
View Full Code Here

    public static Result edit(Long id) {
        Logger.info("EDIT");
        try {
            Logger.info("Community Edit for id:" + id);
            User user = new User();
            user = user.getUserFromSession(session());
            //specify which fields are allowed to be set, to prevent against mass-assignment
            Form<Community> filledForm = form(Community.class).bindFromRequest("name", "copyrightText", "introductoryText", "shortDescription", "sidebarText");
            if(filledForm.hasErrors()){
                return badRequest(views.html.community.edit.render(user, filledForm, "Edit Comm", "", ""));
            }

            Community editCommunity = filledForm.get();

            //Determine if the edited community is changed from original. i.e. don't update unless necessary
            RestResponse originalCommunityResponse = Community.findByID(id);
            Community originalCommunity = null;
            if(originalCommunityResponse.modelObject instanceof Community) {
                originalCommunity = (Community) originalCommunityResponse.modelObject;
            }

            if(editCommunity.equals(originalCommunity)) {
                Logger.info("Communities are equal, nothing to do");
                flash("success", "No changes to community detected");
                return redirect(routes.Communities.show(id));
            } else {
                editCommunity.id = originalCommunity.id;

                RestResponse restResponse = editCommunity.update(user.token());
                HttpResponse httpResponse = restResponse.httpResponse;
                if(httpResponse.getStatusLine().getStatusCode() == 200) {
                    Logger.info("ok");
                    flash("success", "Community has been updated.");
                    return redirect(routes.Communities.show(id));
View Full Code Here

        return internalServerError();
    }

    public static Result createForm() {
        Logger.info("CREATEFORM");
        User user = new User();
        user = user.getUserFromSession(session());
        Form<Community> communityForm = form(Community.class);
        return ok(views.html.community.create.render(user, communityForm, "Create Community", "", ""));
    }
View Full Code Here

TOP

Related Classes of com.rapleaf.jack.test_project.database_1.models.User

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.