Package edu.wpi.cs.wpisuitetng.modules.core.models

Examples of edu.wpi.cs.wpisuitetng.modules.core.models.Project


  }
 
  @Test
  public void testGetProject()
  {
    Project p1 = new Project("defectTracker", "proj1");
    Session projectSes = new Session(u2, p1, ssid1);
   
    assertTrue(p1.equals(projectSes.getProject()));
  }
View Full Code Here


   
    String originalSsid = sessions.createSession(u2);
    Session originalSession = sessions.getSession(originalSsid);
   
    String projectId = "proj1";
    Project p = new Project("wpisuite", projectId);
   
    try
    {
      projects.makeEntity(originalSession, p.toJSON());
    }
    catch(ConflictException e)
    {
      // this is okay because it means the project already exists in the database.
    }
   
    String newSsid = sessions.switchToProject(originalSsid, projectId);
    Session projectSession = sessions.getSession(newSsid);
   
    assertFalse(sessions.sessionExists(originalSsid));
    assertTrue(projectSession != null);
   
    assertTrue(originalSession.getProject() == null);
    assertTrue(projectSession.getProject().equals(p));
   
    try
    {
      projects.deleteEntity(projectSession, p.toJSON())
    }
    catch(NotFoundException e)
    {
      // this is okay since we are trying to make the project 'not found'
    }
View Full Code Here

  public void deserializeProjectFull()
  {
    String jsonProject ="{\"name\":\"TestProj\", \"idNum\":\"1\"}";
    Gson deserializer = this.gson.create();
   
    Project inflated = deserializer.fromJson(jsonProject, Project.class);
   
    assertTrue(inflated.getName().equals("TestProj"));
    assertTrue(inflated.getIdNum().equals("1"));
  }
View Full Code Here

  public void deserializeProjectMissingFields()
  {
    String jsonProject ="{\"name\":\"\", \"idNum\":\"2\"}";
    Gson deserializer = this.gson.create();
   
    Project inflated = deserializer.fromJson(jsonProject, Project.class);
   
    assertTrue(inflated.getIdNum().equals("2"));
    assertTrue(inflated.getName().equals(""));
  }
View Full Code Here

  public void deserializeProjectMissingId()
  {
    String jsonProject ="{\"name\":\"Tester\"}";
    Gson deserializer = this.gson.create();
   
    Project inflated = deserializer.fromJson(jsonProject, Project.class); // exception expected.
   
    fail("exception not thrown");
  }
View Full Code Here

  public Project makeEntity(Session s, String content) throws WPISuiteException
    User theUser = s.getUser();
   
    logger.log(Level.FINER, "Attempting new Project creation...");
   
    Project p;
    try{
      p = Project.fromJSON(content);
    } catch(JsonSyntaxException e){
      logger.log(Level.WARNING, "Invalid Project entity creation string.");
      throw new BadRequestException("The entity creation string had invalid format. Entity String: " + content);
    }
   
    
    logger.log(Level.FINE, "New project: "+ p.getName() +" submitted by: "+ theUser.getName() );
    p.setOwner(theUser);
   
    if(getEntity(s,p.getIdNum())[0] == null)
    {
      if(getEntityByName(s, p.getName())[0] == null)
      {
        save(s,p);
      }
      else
      {
View Full Code Here

  }

  @Override
  public Project[] getAll(Session s) {
    Project[] ret = new Project[1];
    ret = data.retrieveAll(new Project("","")).toArray(ret);
    return ret;
  }
View Full Code Here

  @Override
  public void deleteAll(Session s) throws WPISuiteException {
    User theUser = s.getUser();
    logger.log(Level.INFO, "ProjectManager invoking DeleteAll...");
    if(theUser.getRole().equals(Role.ADMIN)){
    data.deleteAll(new Project("",""));
    }
    else
    {
      logger.log(Level.WARNING, "ProjectManager DeleteAll attempted by user with insufficient permission");
      throw new UnauthorizedException("You do not have the required permissions to perform this action.");
View Full Code Here

   
      // convert updateString into a Map, then load into the User
      try
      {
        logger.log(Level.FINE, "Project update being attempted...");
        Project change = Project.fromJSON(changeSet);
     
        // check if the changes contains each field of name
        if(change.getName() != null && !change.getName().equals(""))
        {
          // check for conflict for changing the project name
          Project isConflict = getEntityByName(s, change.getName())[0];
          if(isConflict != null && !isConflict.getIdNum().equals(change.getIdNum()))
          {
            throw new ConflictException("ProjectManager attempted to update a Project's name to be the same as an existing project");
          }
         
          toUpdate.setName(change.getName());
View Full Code Here

  }
 
  @Override
  public String advancedPut(Session s, String[] args, String content) throws WPISuiteException
  {
    Project p = getEntity(args[2])[0];
    String[] names = null;
   
    try{
      names = gson.fromJson(content, String[].class);
    }catch(JsonSyntaxException j)
    {
      throw new BadRequestException("Could not parse JSON");
    }
   
    ArrayList<String> success = new ArrayList<String>();
   
    UserManager u = ManagerLayer.getInstance().getUsers();
   
    if(args.length > 3)
    {
      if("add".equals(args[3]))
      {
        for(String person : names)
        {
          if(p.addTeamMember(u.getEntity(s, person)[0]))
            success.add(person);
        }
      }
      else if("remove".equals(args[3]))
      {
        for(String person : names)
        {
          if(p.removeTeamMember(u.getEntity(s, person)[0]))
            success.add(person);
        }
      }
    }
   
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.modules.core.models.Project

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.