Package hibernate

Examples of hibernate.UserRoleGroup


          Group newGroup = GroupFactory.createGroup(groupName, groupDescription);
            // apply data entry on the group instance
          int newGroupID = myTools.dataEntry(newGroup);
         
          // Creating the relational database entry - This is how the user and group are linked
          UserRoleGroup newRelationship = new UserRoleGroup(userId, newGroupID, 1, newGroup.getCreateDate());
          // Adding the relationship to the database
          int newUserRoleGroup = myTools.dataEntry(newRelationship);
           
          //Confirm Group exist by searching its id
          // WILL NEED TO ADD LOGIC IN THE FUTURE TO CLEAN THINGS UP IF ONLY ONE IS ADDED AND NOT THE OTHER
View Full Code Here


             //check to see if user has permission to delete group (admin)
             //set up retrieval tools
             ObjectRetrievalTools<UserRoleGroup> objTool = new ObjectRetrievalTools<UserRoleGroup>();
            
             //return the UserRoleGroup
             UserRoleGroup urg = (UserRoleGroup)objTool.getObject(Table.UserRoleGroup, "userId", userId, "groupId", groupId);
            
             //get role id
             int admin = urg.getRoleId();
            
             //check for admin
             if (admin == 0) {
              
               throw new Exception ("User does not have admin privledges");
             }
            
             //admin confirmed
             else {
              
               boolean answer;
              
               //first check to see if group has any questions first
               //if there are questions, there will be answers as well
               if (answer = myTools.dataSearch("Question", "groupId", groupId)){
                
                 //get all the questions associated with the group id
                    ObjectRetrievalTools<Question> objTool2 = new ObjectRetrievalTools<Question>();
                    List<Question> questionList = objTool2.getObjectList(Table.Question, "groupId", groupId);
                   
                    //delete the questions from the db
                    for (Iterator<Question> questIterator = questionList.iterator(); questIterator.hasNext();) {
                      Question questionDelete = questIterator.next();
                      //get questionId for answer deletion
                      int questionId = questionDelete.getId();
                      myTools.dataRemoval(questionDelete);
                     
                      //get all the answers associated with the question id
                         ObjectRetrievalTools<Answer> objTool3 = new ObjectRetrievalTools<Answer>();
                         List<Answer> answerList = objTool3.getObjectList(Table.Answer, "questionId", questionId);
                        
                         //delete all the answers from the db
                         for (Iterator<Answer> ansIterator = answerList.iterator(); ansIterator.hasNext();) {
                           Answer answerDelete = ansIterator.next();
                           myTools.dataRemoval(answerDelete);       
                         }
                    }
               }
                              
               //group has no questions/answers
               else {}
                      
               //get all the UserRoleGroup associated with the group id
               //there should be at least 1 for the group creator
               ObjectRetrievalTools<UserRoleGroup> objTool4 = new ObjectRetrievalTools<UserRoleGroup>();
               List<UserRoleGroup> urgList = objTool4.getObjectList(Table.UserRoleGroup, "groupId", groupId);
              
               //delete all the UserRoleGroup from db
               for (Iterator<UserRoleGroup> iterator = urgList.iterator(); iterator.hasNext();) {
                 UserRoleGroup urgDelete = iterator.next();
                 myTools.dataRemoval(urgDelete);
               }
              
               //lastly, retrieve the actual group for deletion
               ObjectRetrievalTools<Group> objTool5 = new ObjectRetrievalTools<Group>();
View Full Code Here

           
            //for loop counter
            int counter = 0;
           
            for (Iterator<UserRoleGroup> userRoleGroupIterator = groupList.iterator(); userRoleGroupIterator.hasNext();) {
                UserRoleGroup urg = userRoleGroupIterator.next();
               
                //gets the user's id
                int myId = urg.getUserId();
               
                //get date joined
                Date dateJoined = urg.getCreateDate();
               
                //set up object retrieval tool
                ObjectRetrievalTools<User> objRetrieval = new ObjectRetrievalTools<>();
               
                //use retrieval tool with the user id to get the user object
View Full Code Here

               
                //creates a new joined date to be added to the UserRoleGroup
                Date dateJoined = new Date();
               
                //creates the new UserRoleGroup for the invited user
                UserRoleGroup invitedUserUrg = new UserRoleGroup(invitedUserId, groupId, 0, dateJoined);
               
                //enters the new UserRoleGroup into the db, effectively adding the invited user to the group
                int newUserRoleGroupId = myTools.dataEntry(invitedUserUrg);
               
                //check to see that the new UserRoleGroup was created properly
View Full Code Here

    // create a new user
    int userID = myTools.dataEntry(UserFactory.createUser("Martha", "Stewart", "MS@hotmail.com", "Password7"));
    // create a new group
    int groupID = myTools.dataEntry(GroupFactory.createGroup("English", "my special group"));
    // create a new Role to link primary user
    UserRoleGroup newRole = new UserRoleGroup(userID, groupID, 0, new Date());
   
    // Enter info into the database and get the ID back
    int UserRoleID = myTools.dataEntry(newRole);
   
    if(UserRoleID <= 0) {Assert.fail("New Group Roles was suppose to have an ID > 0 but instead it was " + UserRoleID);}
View Full Code Here

TOP

Related Classes of hibernate.UserRoleGroup

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.