protected Object getControlObject() { Project project1 = new Project(); project1.setId(CONTROL_PROJECT1_ID); project1.setName(CONTROL_PROJECT1_NAME); Project project2 = new Project(); project2.setId(CONTROL_PROJECT2_ID); project2.setName(CONTROL_PROJECT2_NAME); Project project3 = new Project(); project3.setId(CONTROL_PROJECT3_ID); project3.setName(CONTROL_PROJECT3_NAME); Employee employee1 = new Employee(); employee1.setFirstName(CONTROL_EMPLOYEE1_NAME); employee1.setProject(project3); ArrayList objects = new ArrayList(); objects.add(employee1); objects.add(project1); objects.add(project2); objects.add(project3); return objects; }
public ArrayList<Project> getProjects(String query) throws java.rmi.RemoteException, SQLException { ResultSet result = connection.createStatement().executeQuery(query); ArrayList<Project> projects = new ArrayList<Project>(); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); while (result.next()) { try { System.out.printf(result.getString(3)); Date projectDate = format.parse(result.getString(3)); Project p = new Project( result.getString(2), projectDate, result.getDouble(4), result.getString(5), result.getBoolean(6)); int projectId = result.getInt(1); p.setId(projectId); p.setPaths(this.getProjectPaths(projectId)); p.setMessages(this.getProjectMessages(projectId)); p.setRewards(this.getProjectRewards(projectId)); p.setExtras(this.getProjectExtraLevels(projectId)); projects.add(p); } catch (ParseException e) { e.printStackTrace(); } } return projects; }
public ArrayList<Project> getProjectsWithoutDetails() throws java.rmi.RemoteException, SQLException { ResultSet result = connection.createStatement().executeQuery("Select * from Projects where active = 1"); ArrayList<Project> projects = new ArrayList<Project>(); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); while (result.next()) { try { Date projectDate = format.parse(result.getString(3)); Project p = new Project( result.getString(2), projectDate, result.getDouble(4), result.getString(5), result.getBoolean(6)); int projectId = result.getInt(1); p.setId(projectId); projects.add(p); } catch (ParseException e) { e.printStackTrace(); } } System.out.println("Get Projects without Details Executed"); return projects; }
/* method initializes Issue fields */ private Issue initIssue(HttpServletRequest req, String issueID) throws LogicException { FeatureLogic fl = new FeatureLogic(); IssueLogic il = new IssueLogic(); Project project = new Project(); Build build = new Build(); HttpSession session = req.getSession(false); Member modifiedBy = (Member) session.getAttribute("member"); project.setId(Integer.parseInt(req.getParameter(PARAM_PROJECT))); build.setId(Integer.parseInt(req.getParameter(PARAM_BUILD))); Issue issue = il.issueToView(Integer.parseInt(issueID)); issue.setModifiedBy(modifiedBy); issue.setSummary(req.getParameter(PARAM_SUMMARY)); issue.setDescription(req.getParameter(PARAM_DESC)); issue.setStatus(fl.findFeature(STATUS, Integer.parseInt(req.getParameter(PARAM_STATUS)))); issue.setType(fl.findFeature(TYPE, Integer.parseInt(req.getParameter(PARAM_TYPE)))); issue.setPriority(fl.findFeature(PRIORITY, Integer.parseInt(req.getParameter(PARAM_PRIORITY)))); issue.setProject(project); issue.setBuild(build); if (req.getParameter(PARAM_ASSIGNEE) != null) { Member member = new Member(); member.setId(Integer.parseInt(req.getParameter(PARAM_ASSIGNEE))); issue.setAssignee(member); } return issue; }
@Before public void setup() { _context = new ClassPathXmlApplicationContext("metering-vnxfile-context.xml"); try { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/dbutils-conf.xml"); _dbClient = (DbClientImpl) ctx.getBean("dbclient"); _dbClient = Cassandraforplugin.returnDBClient(); final TenantOrg tenantorg = new TenantOrg(); tenantorg.setId(URIUtil.createId(TenantOrg.class)); tenantorg.setLabel("some org"); tenantorg.setParentTenant( new NamedURI(URIUtil.createId(TenantOrg.class), tenantorg.getLabel())); _logger.info("TenantOrg :" + tenantorg.getId()); _dbClient.persistObject(tenantorg); final Project proj = new Project(); proj.setId(URIUtil.createId(Project.class)); proj.setLabel("some name"); proj.setTenantOrg(new NamedURI(tenantorg.getId(), proj.getLabel())); _logger.info("Project :" + proj.getId()); _logger.info("TenantOrg-Proj :" + proj.getTenantOrg()); _dbClient.persistObject(proj); final FileShare fileShare = new FileShare(); fileShare.setId(URIUtil.createId(FileShare.class)); fileShare.setLabel("some fileshare"); fileShare.setNativeGuid("CELERRA+" + serialNumber); fileShare.setVirtualPool(URIUtil.createId(VirtualPool.class)); fileShare.setProject(new NamedURI(proj.getId(), fileShare.getLabel())); fileShare.setCapacity(12500L); _dbClient.persistObject(fileShare); } catch (final Exception ioEx) { _logger.error("Exception occurred while persisting objects in db {}", ioEx.getMessage()); _logger.error(ioEx.getMessage(), ioEx); } }
private Project buildProject() { Project newProject = new Project(); newProject.setId(ID); newProject.setName(NAME); newProject.setShortName(SHORT_NAME); newProject.setDescription(DESCRIPTION); return newProject; }
/** Test of getProjectStatus method, of class Project. */ @Test public void testGetProjectStatus() { try { System.out.println("getProjectStatus"); Project instance = new Project(); instance.setId("112"); Tasks t = new Tasks("1", "1"); t.setProjectID("112"); t.setStatus("inProgress"); Reference.tasks = new ArrayList<Tasks>(); Reference.tasks.add(t); String expResult = "In Progress"; String result = instance.getProjectStatus(); System.out.println("EXP result: " + expResult + "; " + result); assertEquals(expResult, result); } catch (Exception e) { fail("GetProjectStatus(), exception"); } }
/** * Creates draft copilot posting for the newly created project. * * @param directProject the direct project. * @return the created competition * @throws Exception if error happens when creating the contest. * @since 1.1 */ private SoftwareCompetition createCopilotDraftPosting(ProjectData directProject) throws Exception { SoftwareCompetition cp = new SoftwareCompetition(); cp.setAssetDTO(getAssetDTOForNewSoftware()); String name = getAssetDTO().getName(); if (name == null || name.equals("")) { name = directProject.getName(); } cp.getAssetDTO().setName(name); GregorianCalendar c = new GregorianCalendar(); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH, 2); XMLGregorianCalendar contestStartDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); cp.getAssetDTO().setProductionDate(contestStartDate); // build the project header Project projectHeader = new Project(); ProjectCategory projectCategory = new ProjectCategory(); projectCategory.setId(29); projectCategory.setName("Copilot Posting"); projectCategory.setProjectType(ProjectType.APPLICATION); projectHeader.setProjectCategory(projectCategory); projectHeader.setId(-1L); if (projectData.getProjectBillingAccountId() > 0) { projectHeader.setProperty( ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY, String.valueOf(projectData.getProjectBillingAccountId())); } else { projectHeader.setProperty(ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY, "0"); } projectHeader.setProperty("Confidentiality Type", "public"); projectHeader.setProperty("Copilot Cost", "0"); projectHeader.setProperty("Project Name", name); projectHeader.setTcDirectProjectId(directProject.getProjectId()); projectHeader.setTcDirectProjectName(directProject.getName()); // set spec info - do not need spec review ProjectSpec projectSpec = new ProjectSpec(); projectSpec.setProjectSpecId(0L); if (getProjectHeader() != null && getProjectHeader().getProjectSpec() != null) { projectSpec.setDetailedRequirements( getProjectHeader().getProjectSpec().getDetailedRequirements()); } projectHeader.setProjectSpec(projectSpec); // add prize List<Prize> prizes = new ArrayList<Prize>(); Prize firstPlace = new Prize(); firstPlace.setNumberOfSubmissions(1); firstPlace.setPlace(1); firstPlace.setPrizeAmount(150); firstPlace.setProjectId(directProject.getProjectId()); Prize secondPlace = new Prize(); secondPlace.setNumberOfSubmissions(1); secondPlace.setPlace(2); secondPlace.setPrizeAmount(75); secondPlace.setProjectId(directProject.getProjectId()); com.topcoder.management.project.PrizeType prizeType = new com.topcoder.management.project.PrizeType(); prizeType.setDescription("Contest Prize"); prizeType.setId(15L); firstPlace.setPrizeType(prizeType); prizes.add(firstPlace); secondPlace.setPrizeType(prizeType); prizes.add(secondPlace); projectHeader.setPrizes(prizes); projectHeader.setProperty(ProjectPropertyType.ADMIN_FEE_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.COPILOT_COST_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.DR_POINTS_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.PAYMENTS_PROJECT_PROPERTY_KEY, "150"); projectHeader.setProperty(ProjectPropertyType.FIRST_PLACE_COST_PROJECT_PROPERTY_KEY, "150"); projectHeader.setProperty(ProjectPropertyType.RELIABILITY_BONUS_COST_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.CHECKPOINT_BONUS_COST_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.SPEC_REVIEW_COSTS_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.SECOND_PLACE_COST_PROJECT_PROPERTY_KEY, "75"); projectHeader.setProperty(ProjectPropertyType.REVIEW_COSTS_PROJECT_PROPERTY_KEY, "0"); cp.setId(-1L); cp.setProjectHeader(projectHeader); initializeCompetition(cp); populateCompetition(cp); cp = getContestServiceFacade() .createSoftwareContest( DirectUtils.getTCSubjectFromSession(), cp, directProject.getProjectId(), null, null); return cp; }
public boolean createProject(Project project, int requestId, int userId) throws RemoteException, SQLException { System.out.println(userId); ResultSet result = connection .createStatement() .executeQuery( "select count(*) from logs where requestId = " + requestId + " and userId = " + userId); if (result.getInt(1) == 0) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); result = connection .createStatement() .executeQuery("select id from projects where Name = \"" + project.getName() + "\""); if (result.next()) { return false; } connection.setAutoCommit(false); connection .createStatement() .execute( "insert into projects (Name, Deadline, Objective, Description, OwnerUserId,Active) values (\"" + project.getName() + "\", \"" + dateFormat.format(project.getDeadline()) + "\"," + project.getObjective() + ", \"" + project.getDescription() + "\", " + userId + "," + 1 + ")"); result = connection .createStatement() .executeQuery("select id from projects where Name = \"" + project.getName() + "\""); int projectId = result.getInt(1); connection .createStatement() .execute( "insert into administrators (ProjectId, UserId) values (" + projectId + ", " + userId + ")"); connection .createStatement() .execute( "insert into logs (UserId, RequestId, Response) values (" + userId + ", " + requestId + ", 1)"); for (Reward reward : project.getRewards()) { this.createReward(reward, 0, projectId, userId); } for (Path path : project.getPaths()) { this.createPath(path, 0, userId, projectId); } project.setId(projectId); System.out.println("Created Proj"); User username = getUser(userId); if (isTumblr(username.getUsername())) { postinTumblr(username.getUsername(), project); } connection.commit(); return true; } else { System.out.println("OUPS"); result = connection .createStatement() .executeQuery( "select response from logs where requestId = " + requestId + " and userId = " + userId); return result.getBoolean(1); } }
private void updateProject(TracksAction act) { final boolean badcert = _prefs.getBoolean(PreferenceConstants.BADCERT, false); final String username = _prefs.getString(PreferenceConstants.USERNAME, null); final String password = _prefs.getString(PreferenceConstants.PASSWORD, null); Project p = (Project) act.target; Log.d(TAG, "Updating project " + String.valueOf(p.getId())); StringBuilder xml = new StringBuilder("<project>"); xml.append("<name>"); xml.append(p.getName()); xml.append("</name>"); xml.append("<description>"); xml.append(p.getDescription() == null ? "" : p.getDescription()); xml.append("</description>"); xml.append("</project>"); Log.v(TAG, "Sending: " + xml.toString()); try { HttpResponse r; int resp; if (p.getId() < 0) { Log.v(TAG, "Posting to contexts.xml to create new context"); r = HttpConnection.post( PreferenceUtils.getUri(_prefs, "projects.xml"), username, password, xml.toString(), badcert); } else { Log.v(TAG, "Putting to update existing context"); r = HttpConnection.put( PreferenceUtils.getUri(_prefs, "projects/" + String.valueOf(p.getId()) + ".xml"), username, password, xml.toString(), badcert); } resp = r.getStatusLine().getStatusCode(); if (resp == 200) { Log.d(TAG, "Successfully updated context"); act.notify.sendEmptyMessage(SUCCESS_CODE); } else if (resp == 201) { Log.d(TAG, "Successfully created context."); String got = r.getFirstHeader("Location").getValue(); got = got.substring(got.lastIndexOf('/') + 1); int pno = Integer.parseInt(got); p.setId(pno); Log.d(TAG, "ID of new project is: " + String.valueOf(pno)); act.notify.sendEmptyMessage(SUCCESS_CODE); } else { Log.w(TAG, "Unexpected response from server: " + String.valueOf(resp)); act.notify.sendEmptyMessage(UPDATE_FAIL_CODE); } } catch (Exception e) { Log.w(TAG, "Error updating context", e); act.notify.sendEmptyMessage(UPDATE_FAIL_CODE); } }