Package HBaseIA.TwitBase.hbase

Examples of HBaseIA.TwitBase.hbase.UsersDAO$User


      System.out.println(usage);
      System.exit(0);
    }

    HTablePool pool = new HTablePool();
    UsersDAO dao = new UsersDAO(pool);

    if ("get".equals(args[0])) {
      log.debug(String.format("Getting user %s", args[1]));
      User u = dao.getUser(args[1]);
      System.out.println(u);
    }

    if ("add".equals(args[0])) {
      log.debug("Adding user...");
      dao.addUser(args[1], args[2], args[3], args[4]);
      User u = dao.getUser(args[1]);
      System.out.println("Successfully added user " + u);
    }

    if ("list".equals(args[0])) {
      List<User> users = dao.getUsers();
      log.info(String.format("Found %s users.", users.size()));
      for(User u : users) {
        System.out.println(u);
      }
    }
View Full Code Here


                         "destination tables first.");
      System.exit(0);
    }

    HTablePool pool = new HTablePool(conf, Integer.MAX_VALUE);
    UsersDAO users = new UsersDAO(pool);
    TwitsDAO twits = new TwitsDAO(pool);

    int count = Integer.parseInt(args[0]);
    List<String> words = LoadUtils.readResource(LoadUtils.WORDS_PATH);

    for(User u : users.getUsers()) {
      for (int i = 0; i < count; i++) {
        twits.postTwit(u.user, randDT(), randTwit(words));
      }
    }
View Full Code Here

      System.exit(0);
    }

    HTablePool pool = new HTablePool();
    TwitsDAO twitsDao = new TwitsDAO(pool);
    UsersDAO usersDao = new UsersDAO(pool);

    if ("post".equals(args[0])) {
      DateTime now = new DateTime();
      log.debug(String.format("Posting twit at ...", now));
      twitsDao.postTwit(args[1], now, args[2]);
      Twit t = twitsDao.getTwit(args[1], now);
      usersDao.incTweetCount(args[1]);
      System.out.println("Successfully posted " + t);
    }

    if ("list".equals(args[0])) {
      List<Twit> twits = twitsDao.list(args[1]);
View Full Code Here

      System.out.println(usage);
      System.exit(0);
    }

    HTablePool pool = new HTablePool();
    UsersDAO dao = new UsersDAO(pool);

    int count = Integer.parseInt(args[0]);
    List<String> names = LoadUtils.readResource(LoadUtils.NAMES_PATH);
    List<String> words = LoadUtils.readResource(LoadUtils.WORDS_PATH);

    for (int i = 0; i < count; i++) {
      String name = randName(names);
      String user = randUser(name);
      String email = randEmail(user, words);
      dao.addUser(user, name, email, "abc123");
    }

    pool.closeTablePool(UsersDAO.TABLE_NAME);
  }
View Full Code Here

  @Test
  public void otherModuleTransactional() {
    assertNull( userRepository.getUserWithId( 1 ) );

    User user = new User( 1, "user 1" );
    userRepository.save( user );

    closeSession();
    openSession();

    User other = userRepository.getUserWithId( 1 );
    assertNotNull( other );
    assertEquals( user, other );
  }
View Full Code Here

  }

  @Test
  public void combinedSave() {
    Product product = new Product( 2, "product 2" );
    User user = new User( 2, "user 2" );

    userRepository.save( user, product );

    closeSession();
    openSession();

    User otherUser = userRepository.getUserWithId( 2 );
    assertNotNull( otherUser );
    assertEquals( user, otherUser );

    Product otherProduct = productRepository.getProductWithId( 2 );
    assertNotNull( otherProduct );
View Full Code Here

          throws Exception {
    // Request the user service.
    UserRemote userService = dfaServices.get(session, UserRemote.class);

    // Retrieve the user who is to be modified.
    User user = userService.getUser(userId);

    // Create and configure a user filter.
    UserFilter filterToAdd = new UserFilter();
    // The following field has been filled in to make a filter that allows a
    // user to access only the assigned objects.
    // This value was determined using GetUserFilterCriteriaTypes.java.
    filterToAdd.setUserFilterCriteriaId(2);
    // Because this filter used the criteria type "Assigned" it is necessary
    // to specify what advertisers this user has access to. This next step
    // would be skipped for the criteria types "All" and "None".

    // Create an object filter to represent each object the user has access
    // to. Since this is an advertiser filter, an object filter represents an
    // advertiser. The total of object filter objects will need to match the
    // total of advertisers the user is assigned.
    ObjectFilter allowedObject = new ObjectFilter();
    // Insert the advertiser ID of an advertiser assigned to this user.
    allowedObject.setId(advertiserId);
    // Create any additional object filters that are needed, then create an
    // array of all of the object filters for this filter.
    ObjectFilter[] objectFilters = {allowedObject};
    // Add these settings to the user filter
    filterToAdd.setObjectFilters(objectFilters);

    // Add the filter to the user. The following method is specific to
    // advertiser filters. See the User class documentation for the names of
    // methods for other filters.
    user.setAdvertiserUserFilter(filterToAdd);

    // Save the changes made and display a success message.
    UserSaveResult userSaveResult = userService.saveUser(user);
    System.out.printf("User with ID \"%s\" was modified.", userSaveResult.getId());
  }
View Full Code Here

          throws Exception {
    // Request the user service.
    UserRemote userService = dfaServices.get(session, UserRemote.class);

    // Retrieve the user who is to be modified.
    User user = userService.getUser(userId);

    // Create and configure a user filter.
    UserFilter filterToAdd = new UserFilter();
    // The following field has been filled in to make a filter that allows a
    // user to access only the assigned objects.
    // This value was determined using GetUserFilterCriteriaTypes.java.
    filterToAdd.setUserFilterCriteriaId(2);
    // Because this filter used the criteria type "Assigned" it is necessary
    // to specify what advertisers this user has access to. This next step
    // would be skipped for the criteria types "All" and "None".

    // Create an object filter to represent each object the user has access
    // to. Since this is an advertiser filter, an object filter represents an
    // advertiser. The total of object filter objects will need to match the
    // total of advertisers the user is assigned.
    ObjectFilter allowedObject = new ObjectFilter();
    // Insert the advertiser ID of an advertiser assigned to this user.
    allowedObject.setId(advertiserId);
    // Create any additional object filters that are needed, then create an
    // array of all of the object filters for this filter.
    ObjectFilter[] objectFilters = {allowedObject};
    // Add these settings to the user filter
    filterToAdd.setObjectFilters(objectFilters);

    // Add the filter to the user. The following method is specific to
    // advertiser filters. See the User class documentation for the names of
    // methods for other filters.
    user.setAdvertiserUserFilter(filterToAdd);

    // Save the changes made and display a success message.
    UserSaveResult userSaveResult = userService.saveUser(user);
    System.out.printf("User with ID \"%s\" was modified.", userSaveResult.getId());
  }
View Full Code Here

  public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
    // Get the UserService.
    UserServiceInterface userService = dfpServices.get(session, UserServiceInterface.class);

    // Get the current user.
    User user = userService.getCurrentUser();

    System.out.printf(
        "User with ID \"%d\", name \"%s\", email \"%s\", and role \"%s\" is the current user.\n",
        user.getId(), user.getName(), user.getEmail(), user.getRoleName());
  }
View Full Code Here

      String name) throws Exception {
    // Get the UserService.
    UserServiceInterface userService = dfpServices.get(session, UserServiceInterface.class);

    // Create a user.
    User traffickerUser = new User();
    traffickerUser.setEmail(emailAddress);
    traffickerUser.setName(name);
    traffickerUser.setPreferredLocale("en_US");

    // Set the system defined ID of the trafficker role.
    // To determine what other roles exist, run GetAllRoles.java.
    traffickerUser.setRoleId(-7L);

    // Create the user on the server.
    User[] users = userService.createUsers(new User[] {traffickerUser});

    for (User createdUser : users) {
View Full Code Here

TOP

Related Classes of HBaseIA.TwitBase.hbase.UsersDAO$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.