@SuppressWarnings("unchecked") public static void load(String[] args) throws Exception { ArrayMap params = makeDefaultConfig(args); if (args.length == 0) { if (params == null) return; } else { String path = args[0]; if (".".equals(path)) { File thisPath = new File(""); args[0] = thisPath.getAbsolutePath() + "\\build.txt"; args[0] = StringUtils.replace(args[0], "\\", "/"); } String fileContext = readString(new FileInputStream(args[0]), LSystem.ENCODING); ArrayMap map = (ArrayMap) ParseData.parseAll(fileContext); params.putAll(map); } String pb1 = (String) params.get("sourceDir"); String outputDir = (String) params.get("outputDir"); String javaHome = JVM.getJavaHome((String) params.get("javaHome")); if (outputDir == null) { outputDir = "."; } if (!StringUtils.isEmpty(javaHome)) { log("found latest JDK:" + javaHome); } else { log("didnot found JDK"); } Object prjList = params.get("list"); Projects prjs1 = new Projects(); prjs1.verbose = true; prjs1.addPrjs((List<Object>) prjList); prjs1.sourceDir = args.length == 0 ? "." : addPath(new File(args[0]).getParent(), pb1).getCanonicalPath(); prjs1.javaHome = javaHome; long t1 = System.currentTimeMillis(); if (args.length > 1 && args[1].equals("clean")) { new JavaBuild(params).clean(prjs1); } new JavaBuild(params).build(prjs1, outputDir); long t2 = System.currentTimeMillis(); log( String.format( "Compile end. time cost %,d ms, javac(compiled):%,d, copy:%,d(%,d bytes), jar:%,d, java(exec):%,d.", t2 - t1, prjs1.totalJavac, prjs1.totalCopy, prjs1.totalCopys, prjs1.totalJar, prjs1.totalJava)); }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: if (NameField.getText().equals("")) { Message.setText("Fill Your Name field"); } else if (UsernameField.getText().equals("") || UsernameField.getText().contains(" ")) { Message.setText("Enter a User Name (without spaces)"); } else if (new String(jPasswordField1.getPassword()).equals("")) { Message.setText(" Enter a Password to login with."); } else if (!new String(jPasswordField1.getPassword()) .equals(new String(jPasswordField2.getPassword()))) { Message.setText("Passwords didn't match."); } else if (newUser()) { Projects p = new Projects(); this.setVisible(false); p.setVisible(true); } } // GEN-LAST:event_jButton1ActionPerformed
/** Populates a DTO with data from a ResultSet */ protected void populateDto(Projects dto, ResultSet rs) throws SQLException { dto.setIdprojects(rs.getInt(COLUMN_IDPROJECTS)); dto.setName(rs.getString(COLUMN_NAME)); dto.setDescription(rs.getString(COLUMN_DESCRIPTION)); dto.setStartDate(rs.getDate(COLUMN_START_DATE)); dto.setEndDate(rs.getDate(COLUMN_END_DATE)); dto.setStatus(rs.getInt(COLUMN_STATUS)); if (rs.wasNull()) { dto.setStatusNull(true); } dto.setType(rs.getInt(COLUMN_TYPE)); if (rs.wasNull()) { dto.setTypeNull(true); } dto.setCompanyId(rs.getInt(COLUMN_COMPANY_ID)); if (rs.wasNull()) { dto.setCompanyIdNull(true); } dto.setBranchId(rs.getInt(COLUMN_BRANCH_ID)); if (rs.wasNull()) { dto.setBranchIdNull(true); } }
/** Inserts a new row in the projects table. */ public ProjectsPk insert(Projects dto) throws ProjectsDaoException { long t1 = System.currentTimeMillis(); // declare variables final boolean isConnSupplied = (userConn != null); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; try { // get the user-specified connection or get a connection from the ResourceManager conn = isConnSupplied ? userConn : ResourceManager.getConnection(); stmt = conn.prepareStatement(SQL_INSERT, Statement.RETURN_GENERATED_KEYS); int index = 1; stmt.setInt(index++, dto.getIdprojects()); stmt.setString(index++, dto.getName()); stmt.setString(index++, dto.getDescription()); stmt.setDate( index++, dto.getStartDate() == null ? null : new java.sql.Date(dto.getStartDate().getTime())); stmt.setDate( index++, dto.getEndDate() == null ? null : new java.sql.Date(dto.getEndDate().getTime())); if (dto.isStatusNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getStatus()); } if (dto.isTypeNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getType()); } if (dto.isCompanyIdNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getCompanyId()); } if (dto.isBranchIdNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getBranchId()); } System.out.println("Executing " + SQL_INSERT + " with DTO: " + dto); int rows = stmt.executeUpdate(); long t2 = System.currentTimeMillis(); System.out.println(rows + " rows affected (" + (t2 - t1) + " ms)"); // retrieve values from auto-increment columns rs = stmt.getGeneratedKeys(); if (rs != null && rs.next()) { dto.setIdprojects(rs.getInt(1)); } reset(dto); return dto.createPk(); } catch (Exception _e) { _e.printStackTrace(); throw new ProjectsDaoException("Exception: " + _e.getMessage(), _e); } finally { ResourceManager.close(stmt); if (!isConnSupplied) { ResourceManager.close(conn); } } }
/** Updates a single row in the projects table. */ public void update(ProjectsPk pk, Projects dto) throws ProjectsDaoException { long t1 = System.currentTimeMillis(); // declare variables final boolean isConnSupplied = (userConn != null); Connection conn = null; PreparedStatement stmt = null; try { // get the user-specified connection or get a connection from the ResourceManager conn = isConnSupplied ? userConn : ResourceManager.getConnection(); System.out.println("Executing " + SQL_UPDATE + " with DTO: " + dto); stmt = conn.prepareStatement(SQL_UPDATE); int index = 1; stmt.setInt(index++, dto.getIdprojects()); stmt.setString(index++, dto.getName()); stmt.setString(index++, dto.getDescription()); stmt.setDate( index++, dto.getStartDate() == null ? null : new java.sql.Date(dto.getStartDate().getTime())); stmt.setDate( index++, dto.getEndDate() == null ? null : new java.sql.Date(dto.getEndDate().getTime())); if (dto.isStatusNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getStatus()); } if (dto.isTypeNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getType()); } if (dto.isCompanyIdNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getCompanyId()); } if (dto.isBranchIdNull()) { stmt.setNull(index++, java.sql.Types.INTEGER); } else { stmt.setInt(index++, dto.getBranchId()); } stmt.setInt(10, pk.getIdprojects()); int rows = stmt.executeUpdate(); reset(dto); long t2 = System.currentTimeMillis(); System.out.println(rows + " rows affected (" + (t2 - t1) + " ms)"); } catch (Exception _e) { _e.printStackTrace(); throw new ProjectsDaoException("Exception: " + _e.getMessage(), _e); } finally { ResourceManager.close(stmt); if (!isConnSupplied) { ResourceManager.close(conn); } } }