/** * Extracts the module name from the specified project. If empty then the provided default name is * used. * * @param defaultName the default module name to use * @param project the maven 2 project * @return the module name to use */ private String extractModuleName(final String defaultName, final Project project) { if (StringUtils.isBlank(project.getProjectName())) { return defaultName; } else { return project.getProjectName(); } }
private void initTargetDefinitionProject(Project baseProject, Arguments args) { File projectRootDir = getProjectDirectory(); TargetDataProvider targetDataProvider = new TargetDataProvider(baseProject.getProjectName(), args); // Add pom.xml file to target project File pomXMLFile = new File(projectRootDir, "pom.xml"); TemplateFileProvider pomXMLFileProvider = new TemplateFileProvider("common/target/pom.xml.ftl", targetDataProvider); addFileCreateTask(pomXMLFile, pomXMLFileProvider); // Add target file to target project String targetFilename = String.format("%s.target", getProjectName()); File targetFile = new File(projectRootDir, targetFilename); FileProvider targetFileProvider; String customFilePath = args.getTargetDefinitionFile(); if (customFilePath == null) { targetFileProvider = new TemplateFileProvider("common/target/target.ftl", targetDataProvider); } else { targetFileProvider = new CopyFileProvider(customFilePath); } addFileCreateTask(targetFile, targetFileProvider); }
@Override public View getView(int position, View convertView, ViewGroup parent) { final Project project = getItem(position); if (convertView == null) { convertView = LayoutInflater.from(getContext()) .inflate(R.layout.activity_custom_project_listview, parent, false); } TextView projectName = (TextView) convertView.findViewById(R.id.projectNameTextView); TextView partnerCount = (TextView) convertView.findViewById(R.id.partnerCountTextView); projectName.setText(project.getProjectName()); partnerCount.setText( Integer.toString(project.getPartnerCount()) + " Partner" + (project.getPartnerCount() == 1 ? "" : "s")); convertView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getContext(), ProjectHost.class); intent.putExtra("ProjectTitle", project.getProjectName()); intent.putExtra("BasePath", project.getFilepath()); // intent.putExtra("TopicSubject",topic.getTopicTitle()); // intent.putExtra("BoardId", topic.getOnBoard()); // intent.putExtra("UserId", UserId); mContext.startActivity(intent); } }); return convertView; }
@Test public void testCopyProject() throws IOException, NoProjectLoadedException, ProjectFileParsingException, Exception { System.out.println("--- testCopyAndRunProject"); String projNameNew = "TestingGranCell"; File projDirNew = new File(MainTest.getTempProjectDirectory(), projNameNew); if (projDirNew.exists()) { GeneralUtils.removeAllFiles(projDirNew, false, true, true); } System.out.println("Ex " + projDirNew.getCanonicalFile() + ": " + projDirNew.exists()); projDirNew.mkdir(); File projFile = new File(projDirNew, projNameNew + ".ncx"); File oldProjDir = new File(ProjectStructure.getnCModelsDir(), "GranuleCell"); File oldProj = new File(oldProjDir, "GranuleCell.ncx"); ProjectManager p = new ProjectManager(); Project proj = p.copyProject(oldProj, projFile); System.out.println("Created project at: " + proj.getProjectFile().getCanonicalPath()); assertEquals(proj.getProjectName(), projNameNew); assertTrue(projFile.exists()); }
public IProject getProject(String projectName) { // TODO: optimize the search IProject project = null; for (Project p : _projectSet) { if (projectName.equals(p.getProjectName())) { project = p; break; } } return project; }
/** Test of createNewProject method, of class Project. */ @Test public void testCreateNewProject() throws IOException, NoProjectLoadedException { System.out.println("--- testCreateNewProject"); String projName2 = "TestingFrameworkProject"; File projDir2 = new File(MainTest.getTempProjectDirectory(), projName2); Project proj = Project.createNewProject(projDir2.getAbsolutePath(), projName2, null); System.out.println("Created project at: " + proj.getProjectFile().getCanonicalPath()); proj.saveProject(); File projFileNew = proj.getProjectFile(); assertEquals(proj.getProjectName(), projName2); assertTrue(projFileNew.exists()); }
private void jMenuItemLoadProjectActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemLoadProjectActionPerformed { // GEN-HEADEREND:event_jMenuItemLoadProjectActionPerformed JFileChooser jfc = new JFileChooser(); if (lastPath != null) { jfc.setCurrentDirectory(lastPath); } int fileDialogReturnVal = jfc.showOpenDialog(this); if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) { try { File inputFile = jfc.getSelectedFile(); FileInputStream fis = new FileInputStream(inputFile); ObjectInputStream ois = new ObjectInputStream(fis); this.theProject = (Project) ois.readObject(); this.currentResults = (LSAResults) ois.readObject(); lastPath = new File(jfc.getSelectedFile().getPath()); } catch (IOException e) { if (this.theProject == null) { log.log(Log.ERROR, "Failed to load project"); } if (this.currentResults == null) { log.log(Log.WARNING, "Failed to load results"); } log.log(Log.WARNING, e.getMessage()); } catch (ClassNotFoundException e) { log.log(Log.ERROR, "Class not found error, version mismatch"); } } if (this.theProject != null) { jMenuItemViewDocuments.setEnabled(true); jMenuItemSaveProject.setEnabled(true); this.setTitle(theProject.getProjectName()); log.log(Log.INFO, "Project Loaded"); } if (this.currentResults != null) { log.log(Log.INFO, "Results loaded"); } } // GEN-LAST:event_jMenuItemLoadProjectActionPerformed
private MultiLoadParameter createMultiLoadParameter( String projectName, Project project, Sample sample, List<FileReadAttributeBean> frab) throws Exception { MultiLoadParameter loadParameter = new MultiLoadParameter(); boolean isSampleRegistration = false; boolean isProjectRegistration = false; if (this.eventName.equals(Constants.EVENT_PROJECT_REGISTRATION) && project.getProjectName() != null && !project.getProjectName().isEmpty()) { isProjectRegistration = true; List<Project> projectList = new ArrayList<Project>(); projectList.add(feedProjectData(project)); loadParameter.addProjects(projectList); /* * loads all event meta attributes from the parent * by hkim 6/11/13 */ List<EventMetaAttribute> emas = this.readPersister.getEventMetaAttributes( projectName, null); // , Constants.EVENT_PROJECT_REGISTRATION); if (emas != null && emas.size() > 0) { List<EventMetaAttribute> newEmas = new ArrayList<EventMetaAttribute>(emas.size()); for (EventMetaAttribute ema : emas) { EventMetaAttribute newEma = new EventMetaAttribute(); newEma.setProjectName(project.getProjectName()); newEma.setEventName(ema.getEventName()); newEma.setEventTypeLookupId(ema.getEventTypeLookupId()); newEma.setAttributeName(ema.getAttributeName()); newEma.setNameLookupId(ema.getNameLookupId()); newEma.setActive(ema.isActive()); newEma.setRequired(ema.isRequired()); newEma.setDesc(ema.getDesc()); newEma.setDataType(ema.getDataType()); newEma.setLabel(ema.getLabel()); newEma.setOntology(ema.getOntology()); newEma.setOptions(ema.getOptions()); newEma.setSampleRequired(ema.isSampleRequired()); newEmas.add(newEma); } loadParameter.addEventMetaAttributes(newEmas); } else { throw new Exception( String.format( "Event Metadata has not been set up for the parent project and the '%s' event type.", Constants.EVENT_PROJECT_REGISTRATION)); } List<SampleMetaAttribute> smas = this.readPersister.getSampleMetaAttributes(projectId); if (smas != null && smas.size() > 0) { List<SampleMetaAttribute> newSmas = new ArrayList<SampleMetaAttribute>(smas.size()); for (SampleMetaAttribute sma : smas) { SampleMetaAttribute newSma = new SampleMetaAttribute(); newSma.setProjectName(project.getProjectName()); newSma.setAttributeName(sma.getAttributeName()); newSma.setNameLookupId(sma.getNameLookupId()); newSma.setDataType(sma.getDataType()); newSma.setDesc(sma.getDesc()); newSma.setLabel(sma.getLabel()); newSma.setOntology(sma.getOntology()); newSma.setOptions(sma.getOptions()); newSma.setRequired(sma.isRequired()); newSma.setActive(sma.isActive()); newSmas.add(newSma); } loadParameter.addSampleMetaAttributes(newSmas); } List<ProjectMetaAttribute> pmas = this.readPersister.getProjectMetaAttributes(projectName); if (pmas != null && pmas.size() > 0) { List<ProjectMetaAttribute> newPmas = new ArrayList<ProjectMetaAttribute>(pmas.size()); for (ProjectMetaAttribute pma : pmas) { ProjectMetaAttribute newPma = new ProjectMetaAttribute(); newPma.setProjectName(project.getProjectName()); newPma.setAttributeName(pma.getAttributeName()); newPma.setDataType(pma.getDataType()); newPma.setDesc(pma.getDesc()); newPma.setLabel(pma.getLabel()); newPma.setNameLookupId(pma.getNameLookupId()); newPma.setOntology(pma.getOntology()); newPma.setOptions(pma.getOptions()); newPma.setRequired(pma.isRequired()); newPma.setActive(pma.isActive()); newPmas.add(newPma); } loadParameter.addProjectMetaAttributes(newPmas); } } else if (this.eventName.equals(Constants.EVENT_SAMPLE_REGISTRATION) && sample.getSampleName() != null && !sample.getSampleName().isEmpty()) { isSampleRegistration = true; List<Sample> sampleList = new ArrayList<Sample>(); sampleList.add(feedSampleData(sample)); loadParameter.addSamples(sampleList); } List<FileReadAttributeBean> loadingList = null; if (frab != null && frab.size() > 0) { loadingList = processFileReadBeans( isProjectRegistration ? project.getProjectName() : projectName, isSampleRegistration ? sample.getSampleName() : this.sampleName, frab); } if (loadingList != null && loadingList.size() > 0) { if (isProjectRegistration) { loadParameter.addProjectRegistrations(Constants.EVENT_PROJECT_REGISTRATION, loadingList); } else if (isSampleRegistration) { loadParameter.addSampleRegistrations(Constants.EVENT_SAMPLE_REGISTRATION, loadingList); } else { loadParameter.addEvents(this.eventName, loadingList); } } return loadParameter; }
@Override public int compare(Project proj1, Project proj2) { String proj1Name = proj1.getProjectName(); String proj2Name = proj2.getProjectName(); return proj2Name.compareTo(proj1Name); // descending }
Result build( String userName, ZipFile inputZip, File outputDir, boolean isForCompanion, int childProcessRam, String dexCachePath) { try { // Download project files into a temporary directory File projectRoot = createNewTempDir(); LOG.info("temporary project root: " + projectRoot.getAbsolutePath()); try { List<String> sourceFiles; try { sourceFiles = extractProjectFiles(inputZip, projectRoot); } catch (IOException e) { LOG.severe("unexpected problem extracting project file from zip"); return Result.createFailingResult("", "Problems processing zip file."); } try { genYailFilesIfNecessary(sourceFiles); } catch (YailGenerationException e) { // Note that we're using a special result code here for the case of a Yail gen error. return new Result(Result.YAIL_GENERATION_ERROR, "", e.getMessage(), e.getFormName()); } catch (Exception e) { LOG.severe("Unknown exception signalled by genYailFilesIf Necessary"); e.printStackTrace(); return Result.createFailingResult("", "Unexpected problems generating YAIL."); } File keyStoreFile = new File(projectRoot, KEYSTORE_FILE_NAME); String keyStorePath = keyStoreFile.getPath(); if (!keyStoreFile.exists()) { keyStorePath = createKeyStore(userName, projectRoot, KEYSTORE_FILE_NAME); saveKeystore = true; } // Create project object from project properties file. Project project = getProjectProperties(projectRoot); File buildTmpDir = new File(projectRoot, "build/tmp"); buildTmpDir.mkdirs(); // Prepare for redirection of compiler message output ByteArrayOutputStream output = new ByteArrayOutputStream(); PrintStream console = new PrintStream(output); ByteArrayOutputStream errors = new ByteArrayOutputStream(); PrintStream userErrors = new PrintStream(errors); Set<String> componentTypes = isForCompanion ? getAllComponentTypes() : getComponentTypes(sourceFiles, project.getAssetsDirectory()); // Invoke YoungAndroid compiler boolean success = Compiler.compile( project, componentTypes, console, console, userErrors, isForCompanion, keyStorePath, childProcessRam, dexCachePath); console.close(); userErrors.close(); // Retrieve compiler messages and convert to HTML and log String srcPath = projectRoot.getAbsolutePath() + "/" + PROJECT_DIRECTORY + "/../src/"; String messages = processCompilerOutput(output.toString(PathUtil.DEFAULT_CHARSET), srcPath); if (success) { // Locate output file File outputFile = new File(projectRoot, "build/deploy/" + project.getProjectName() + ".apk"); if (!outputFile.exists()) { LOG.warning("Young Android build - " + outputFile + " does not exist"); } else { outputApk = new File(outputDir, outputFile.getName()); Files.copy(outputFile, outputApk); if (saveKeystore) { outputKeystore = new File(outputDir, KEYSTORE_FILE_NAME); Files.copy(keyStoreFile, outputKeystore); } } } return new Result(success, messages, errors.toString(PathUtil.DEFAULT_CHARSET)); } finally { // On some platforms (OS/X), the java.io.tmpdir contains a symlink. We need to use the // canonical path here so that Files.deleteRecursively will work. // Note (ralph): deleteRecursively has been removed from the guava-11.0.1 lib // Replacing with deleteDirectory, which is supposed to delete the entire directory. FileUtils.deleteDirectory(new File(projectRoot.getCanonicalPath())); } } catch (Exception e) { e.printStackTrace(); return Result.createFailingResult("", "Server error performing build"); } }
private void saveActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveActionPerformed // TODO add your handling code here: currentProject.setProjectName(projectname.getText()); currentProject.setProjectDescription(projectdescription.getText()); try { File file = new File("projects.txt"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } // true = append file FileWriter fileWritter = new FileWriter(file.getName(), true); BufferedWriter bufferWritter = new BufferedWriter(fileWritter); bufferWritter.write( currentProject.getProjectID() + " " + currentProject.getProjectName() + " " + currentProject.getProjectDescription()); for (int i = 0; i < currentProject.getRequirements().size(); i++) { bufferWritter.write( currentProject.getRequirements().get(i).getRequirementID() + " " + currentProject.getRequirements().get(i).getRequirementDescription()); if (currentProject.getRequirements().get(i).getIsFunctionalRequirement() == false) { bufferWritter.write(" non-functional"); } else bufferWritter.write(" functional"); } for (int i = 0; i < currentProject.getTeamMembers().size(); i++) { bufferWritter.write( currentProject.getTeamMembers().get(i).getPersonID() + " " + currentProject.getTeamMembers().get(i).getFirstName() + " " + currentProject.getTeamMembers().get(i).getLastName() + " " + currentProject.getTeamMembers().get(i).getPosition()); } for (int i = 0; i < currentProject.getEfforts().size(); i++) { bufferWritter.write( currentProject.getEfforts().get(i).getEffortID() + " " + currentProject.getEfforts().get(i).getRequirementID() + " " + currentProject.getEfforts().get(i).getEffortDevPhase() + " " + currentProject.getEfforts().get(i).getEffortDate() + " " + currentProject.getEfforts().get(i).getEffortHours()); } for (int i = 0; i < currentProject.getGoals().size(); i++) { bufferWritter.write( currentProject.getGoals().get(i).getGoalID() + " " + currentProject.getGoals().get(i).getGoalType() + " " + currentProject.getGoals().get(i).getGoalDesc()); } for (int i = 0; i < currentProject.getRisks().size(); i++) { bufferWritter.write( currentProject.getRisks().get(i).getRiskID() + " " + currentProject.getRisks().get(i).getRiskName() + " " + currentProject.getRisks().get(i).getRiskStatus()); } bufferWritter.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Couldn't save", "Didn't work", INFORMATION_MESSAGE); } JOptionPane.showMessageDialog( this, "Project Successfully saved", "Success", INFORMATION_MESSAGE); try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection( "jdbc:mysql://127.0.0.1:3306/projectmanagementsystem?zeroDateTimeBehavior=convertToNull", "root", "password"); String query = "insert into project(projectname, projectdesc) values (?, ?)"; PreparedStatement pst = con.prepareStatement(query); pst.setString(1, currentProject.getProjectName()); pst.setString(2, currentProject.getProjectDescription()); pst.executeUpdate(); String query2 = "select idproject from project where projectdesc = ?"; PreparedStatement pst2 = con.prepareStatement(query2); String desc = currentProject.getProjectDescription(); pst2.setString(1, desc); ResultSet rs = pst2.executeQuery(); int id = 0; if (rs.next()) { id = rs.getInt("idproject"); } System.out.println(id); for (int i = 0; i < currentProject.getTeamMembers().size(); i++) { String query3 = "insert into teammember(firstname,lastname,position,teammember_FK) values (?,?,?,?)"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setString(1, currentProject.getTeamMembers().get(i).getFirstName()); pst3.setString(2, currentProject.getTeamMembers().get(i).getLastName()); pst3.setString(3, currentProject.getTeamMembers().get(i).getPosition()); pst3.setInt(4, id); pst3.executeUpdate(); } for (int i = 0; i < currentProject.getGoals().size(); i++) { String query3 = "insert into goal(goaldesc,goaltype,goal_FK) values (?,?,?)"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setString(1, currentProject.getGoals().get(i).getGoalDesc()); pst3.setString(2, currentProject.getGoals().get(i).getGoalType()); pst3.setInt(3, id); pst3.executeUpdate(); } for (int i = 0; i < currentProject.getRequirements().size(); i++) { int functional = 0; if (currentProject.getRequirements().get(i).getIsFunctionalRequirement() == true) { functional = 1; } String query3 = "insert into requirement(isFunctionalRequirement,requirementdesc,requirement_FK) values (?,?,?)"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setInt(1, functional); pst3.setString(2, currentProject.getRequirements().get(i).getRequirementDescription()); pst3.setInt(3, id); pst3.executeUpdate(); } for (int i = 0; i < currentProject.getRisks().size(); i++) { String query3 = "insert into risk(riskname,riskstatus,risk_FK) values (?,?,?)"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setString(1, currentProject.getRisks().get(i).getRiskName()); pst3.setString(2, currentProject.getRisks().get(i).getRiskStatus()); pst3.setInt(3, id); pst3.executeUpdate(); } for (int i = 0; i < currentProject.getEfforts().size(); i++) { String query4 = "select idrequirement from requirement where requirementdesc = ?"; PreparedStatement pst4 = con.prepareStatement(query4); String desc2 = currentProject.getEfforts().get(i).getRequirementDesc(); pst4.setString(1, desc2); ResultSet rs2 = pst4.executeQuery(); int reqid = 0; if (rs.next()) { reqid = rs2.getInt("idrequirement"); } System.out.println(reqid); String query3 = "insert into effort(effortdate,efforthours,effortdevphase,effort_FK) values (?,?,?,?)"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setString(1, currentProject.getEfforts().get(i).getEffortDate()); pst3.setInt(2, currentProject.getEfforts().get(i).getEffortHours()); pst3.setString(3, currentProject.getEfforts().get(i).getEffortDevPhase()); pst3.setInt(4, reqid); pst3.executeUpdate(); } } catch (Exception e) { System.out.println(e.toString()); } } // GEN-LAST:event_saveActionPerformed