public int createMeasures(MSLAGoal goal){
  String sql="SELECT M_InOut_ID, io.MovementDate-o.DatePromised," + " io.MovementDate, o.DatePromised, o.DocumentNo " + "FROM M_InOut io"+ " INNER JOIN C_Order o ON (io.C_Order_ID=o.C_Order_ID) "+ "WHERE io.C_BPartner_ID=?"+ " AND NOT EXISTS "+ "(SELECT * FROM PA_SLA_Measure m "+ "WHERE m.PA_SLA_Goal_ID=?"+ " AND m.AD_Table_ID=" + MInOut.Table_ID + " AND m.Record_ID=io.M_InOut_ID)";
  int counter=0;
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  try {
    pstmt=DB.prepareStatement(sql,null);
    pstmt.setInt(1,goal.getC_BPartner_ID());
    pstmt.setInt(2,goal.getPA_SLA_Goal_ID());
    rs=pstmt.executeQuery();
    while (rs.next()) {
      int M_InOut_ID=rs.getInt(1);
      BigDecimal MeasureActual=rs.getBigDecimal(2);
      Timestamp MovementDate=rs.getTimestamp(3);
      String Description=rs.getString(5) + ": " + rs.getTimestamp(4);
      if (goal.isDateValid(MovementDate)) {
        MSLAMeasure measure=new MSLAMeasure(goal,MovementDate,MeasureActual,Description);
        measure.setLink(MInOut.Table_ID,M_InOut_ID);
        if (measure.save())         counter++;
      }
    }
  }
 catch (  Exception e) {
    log.log(Level.SEVERE,"createMeasures",e);
  }
 finally {
    DB.close(rs,pstmt);
    rs=null;
    pstmt=null;
  }
  return counter;
}

public int createMeasures ( MSLAGoal goal ) { String sql = "SELECT M_InOut_ID, io.MovementDate-o.DatePromised," + " io.MovementDate, o.DatePromised, o.DocumentNo " + "FROM M_InOut io" + " INNER JOIN C_Order o ON (io.C_Order_ID=o.C_Order_ID) " + "WHERE io.C_BPartner_ID=?" + " AND NOT EXISTS " + "(SELECT * FROM PA_SLA_Measure m " + "WHERE m.PA_SLA_Goal_ID=?" + " AND m.AD_Table_ID=" + MInOut . Table_ID + " AND m.Record_ID=io.M_InOut_ID)" ; int counter = 0 ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { pstmt = DB . prepareStatement ( sql , null ) ; pstmt . setInt ( 1 , goal . getC_BPartner_ID ( ) ) ; pstmt . setInt ( 2 , goal . getPA_SLA_Goal_ID ( ) ) ; rs = pstmt . executeQuery ( ) ; while ( rs . next ( ) ) { int M_InOut_ID = rs . getInt ( 1 ) ; BigDecimal MeasureActual = rs . getBigDecimal ( 2 ) ; Timestamp MovementDate = rs . getTimestamp ( 3 ) ; String Description = rs . getString ( 5 ) + ": " + rs . getTimestamp ( 4 ) ; if ( goal . isDateValid ( MovementDate ) ) { MSLAMeasure measure = new MSLAMeasure ( goal , MovementDate , MeasureActual , Description ) ; measure . setLink ( MInOut . Table_ID , M_InOut_ID ) ; if ( measure . save ( ) ) counter ++ ; } } } catch ( Exception e ) { log . log ( Level . SEVERE , "createMeasures" , e ) ; } finally { DB . close ( rs , pstmt ) ; rs = null ; pstmt = null ; } return counter ; }
create new measures for the goal
