Esempio n. 1
1
 public ReturnTuple<Integer> newCustomer(int id, Timestamp timestamp)
     throws RemoteException, TransactionAbortedException, InvalidTransactionException {
   if (!isMaster) {
     System.out.println("Slave retransmitting newCustomer to master");
     return this.getMaster().newCustomer(id, timestamp);
   } else {
     timestamp.stamp();
     int rid =
         Integer.parseInt(
             String.valueOf(id)
                 + String.valueOf(Calendar.getInstance().get(Calendar.MILLISECOND))
                 + String.valueOf(Math.round(Math.random() * 100 + 1)));
     NewCustomerWithIdRMICommand nc =
         new NewCustomerWithIdRMICommand(carGroup, flightGroup, roomGroup, id, rid);
     nc.setTimestampObject(timestamp);
     ReturnTuple<Integer> result = null;
     try {
       overseer.validTransaction(id);
       lm.Lock(id, Customer.getKey(rid), nc.getRequiredLock());
       nc.execute();
       result = new ReturnTuple<Integer>(rid, nc.success.timestamp);
       overseer.addCommandToTransaction(id, nc);
     } catch (DeadlockException d) {
       timestamp.stamp();
       overseer.abort(id);
       timestamp.stamp();
       throw new TransactionAbortedException(timestamp);
     } catch (TransactionAbortedException tae) {
       tae.t = timestamp;
       throw tae;
     } catch (InvalidTransactionException ite) {
       ite.t = timestamp;
       throw ite;
     }
     result.timestamp.stamp();
     return result;
   }
 }
Esempio n. 2
0
  public void mouseClicked(MouseEvent e) {
    int x;
    int y;

    e.consume();

    if (mouseEventsEnabled) {

      x = Math.round(e.getX() / scale);
      y = Math.round(e.getY() / scale);

      // allow for the canvas margin
      y -= margin;

      // System.out.println("Mouse Click: (" + x + ", " + y + ")");

      if (e.getClickCount() < 2) {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }
      } else {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }

        editSelected();
        parentFTAFrame.updateFrame();
      }

      if (focusEventsEnabled) {
        // tell the main Canvas to point to this coordinate
        parentFTAFrame.setCanvasFocus(x, y);
      }
    }
  }
Esempio n. 3
0
  /**
   * Draw picture (gif, jpg, or png) centered on (x, y).
   *
   * @param x the center x-coordinate of the image
   * @param y the center y-coordinate of the image
   * @param s the name of the image/picture, e.g., "ball.gif"
   * @throws RuntimeException if the image is corrupt
   */
  public static void picture(double x, double y, String s) {
    Image image = getImage(s);
    double xs = scaleX(x);
    double ys = scaleY(y);
    int ws = image.getWidth(null);
    int hs = image.getHeight(null);
    if (ws < 0 || hs < 0) throw new RuntimeException("image " + s + " is corrupt");

    offscreen.drawImage(
        image, (int) Math.round(xs - ws / 2.0), (int) Math.round(ys - hs / 2.0), null);
    draw();
  }
Esempio n. 4
0
  /* move the ball */
  public void move(ArrayList movingObjects, int objectCounter) {
    // EFFECT OF GRAVITY
    gravityEffect(movingObjects);

    // MOVE
    pos_x += Math.round(x_speed);
    pos_y += Math.round(y_speed);

    // IS BALL OUT OF BOUNDS?
    isOut();

    // HAS BALL COLLIDED WITH ANYTHING?
    objectCollision(movingObjects);
  }
Esempio n. 5
0
  private void loadHint(TTGlyph a_glyph, EContourPoint a_point, int a_index) {
    double x = a_point.getX();
    double y = a_point.getY();

    XHint[] hints = a_point.getHint();

    for (int i = 0; i < hints.length; i++) {
      EHint hint = (EHint) hints[i];
      double xHint = hint.getX();
      double yHint = hint.getY();

      if (x == xHint && y == yHint) {
        continue;
      } // if

      double xDelta = xHint - x;
      double yDelta = yHint - y;
      int instruction = TTGlyph.DELTAP1;
      double deltaStep = ((double) Engine.getEm()) / hint.getPpem() / 8;
      int xShift = (int) Math.round(xDelta / deltaStep);
      int yShift = (int) Math.round(yDelta / deltaStep);

      if (xShift == 0 && yShift == 0) {
        continue;
      } // if

      a_glyph.addInstruction(TTGlyph.PUSHB000);
      a_glyph.addInstruction((int) hint.getPpem());
      a_glyph.addInstruction(TTGlyph.SDB);

      if (xShift != 0) {
        a_glyph.addInstruction(TTGlyph.SVTCA1);
        a_glyph.addInstruction(TTGlyph.PUSHB010);
        a_glyph.addInstruction(TTGlyph.toDeltaArg(0, xShift));
        a_glyph.addInstruction(a_index);
        a_glyph.addInstruction(1);
        a_glyph.addInstruction(TTGlyph.DELTAP1);
      } // if

      if (yShift != 0) {
        a_glyph.addInstruction(TTGlyph.SVTCA0);
        a_glyph.addInstruction(TTGlyph.PUSHB010);
        a_glyph.addInstruction(TTGlyph.toDeltaArg(0, yShift));
        a_glyph.addInstruction(a_index);
        a_glyph.addInstruction(1);
        a_glyph.addInstruction(TTGlyph.DELTAP1);
      } // if
    } // for i
  }
Esempio n. 6
0
  /**
   * Draw picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees
   *
   * @param x the center x-coordinate of the image
   * @param y the center y-coordinate of the image
   * @param s the name of the image/picture, e.g., "ball.gif"
   * @param degrees is the number of degrees to rotate counterclockwise
   * @throws IllegalArgumentException if the image is corrupt
   */
  public static void picture(double x, double y, String s, double degrees) {
    Image image = getImage(s);
    double xs = scaleX(x);
    double ys = scaleY(y);
    int ws = image.getWidth(null);
    int hs = image.getHeight(null);
    if (ws < 0 || hs < 0) throw new IllegalArgumentException("image " + s + " is corrupt");

    offscreen.rotate(Math.toRadians(-degrees), xs, ys);
    offscreen.drawImage(
        image, (int) Math.round(xs - ws / 2.0), (int) Math.round(ys - hs / 2.0), null);
    offscreen.rotate(Math.toRadians(+degrees), xs, ys);

    draw();
  }
Esempio n. 7
0
  // ------------------------------------------------------------------
  // the UserCanvas constructor
  UserCanvas(
      ForcesMaster f,
      int p,
      int m,
      int pM,
      String w,
      String an,
      String ac,
      String cS,
      ProblemCanvas v) {

    problemNo = p;
    maxTriesEachForce = m;
    problemMode = pM;
    cgiScript = cS;
    problemCanvas = v;
    forcesMaster = f;
    weightIn = w;
    angleIn = an;
    accelerationIn = ac;
    problemSelector = new ProblemSelector(problemNo, angleIn, weightIn, accelerationIn);
    problemCanvas.setProblemSelectorHandle(problemSelector);

    numForces = problemSelector.getNumForces();
    matchForceComps = problemSelector.getMatchForceComps();
    numEquations = problemSelector.getNumEquations();
    units = problemSelector.getUnits();
    scale = problemSelector.getScale();
    // if (!weightIn.equals("none")) {scale = 18 * scale /(double)(Integer.parseInt(weightIn));}
    forceTolerance = (int) Math.round(scale * userTolerance);
    resultsSpacingStrings = problemSelector.getResultsSpacingStrings();
    blinkerStrings = problemSelector.getBlinkerStrings();
    messageStrings = problemSelector.getMessageStrings();
    forceNames = problemSelector.getForceNames();
    truAnsX = problemSelector.getTruAnsX();
    truAnsY = problemSelector.getTruAnsY();
    tailPosX = problemSelector.getTailPosX();
    tailPosY = problemSelector.getTailPosY();
    cosSin = problemSelector.getCosSin();
    truHdsX = problemSelector.getTruHdsX();
    truHdsY = problemSelector.getTruHdsY();
    cost = cosSin[0];
    sint = cosSin[1];

    // initialize the force variables
    maxForceNumber = numForces - 1;
    mouseUpsString = "";
    for (int n = 0; n <= numForces; n++) {
      mouseUpsString += "0";
    }

    ifBrowserPaint = false;

    // initialize to the "see data" message
    ifDataMessage = true;
    forceNumber = -1;
    fInit = mUp = mDown = mDrag = false;
  }
Esempio n. 8
0
 public int getHeight() {
   float fHeight;
   int height;
   fHeight = scale * nativeGetMaxDepth();
   height = Math.round(fHeight) + (2 * margin);
   if (parentContainer == null) {
     return height;
   } else {
     return FTAUtilities.max(height, parentContainer.getHeight());
   }
 }
Esempio n. 9
0
 public int getWidth() {
   float fWidth;
   int width;
   fWidth = scale * nativeGetMaxWidth();
   width = Math.round(fWidth);
   if (parentContainer == null) {
     return width;
   } else {
     return FTAUtilities.max(width, parentContainer.getWidth());
   }
 }
Esempio n. 10
0
  /**
   * Draw picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees, rescaled
   * to w-by-h.
   *
   * @param x the center x-coordinate of the image
   * @param y the center y-coordinate of the image
   * @param s the name of the image/picture, e.g., "ball.gif"
   * @param w the width of the image
   * @param h the height of the image
   * @param degrees is the number of degrees to rotate counterclockwise
   * @throws RuntimeException if the image is corrupt
   */
  public static void picture(double x, double y, String s, double w, double h, double degrees) {
    Image image = getImage(s);
    double xs = scaleX(x);
    double ys = scaleY(y);
    double ws = factorX(w);
    double hs = factorY(h);
    if (ws < 0 || hs < 0) throw new RuntimeException("image " + s + " is corrupt");
    if (ws <= 1 && hs <= 1) pixel(x, y);

    offscreen.rotate(Math.toRadians(-degrees), xs, ys);
    offscreen.drawImage(
        image,
        (int) Math.round(xs - ws / 2.0),
        (int) Math.round(ys - hs / 2.0),
        (int) Math.round(ws),
        (int) Math.round(hs),
        null);
    offscreen.rotate(Math.toRadians(+degrees), xs, ys);

    draw();
  }
Esempio n. 11
0
 /**
  * Draw picture (gif, jpg, or png) centered on (x, y), rescaled to w-by-h.
  *
  * @param x the center x coordinate of the image
  * @param y the center y coordinate of the image
  * @param s the name of the image/picture, e.g., "ball.gif"
  * @param w the width of the image
  * @param h the height of the image
  * @throws RuntimeException if the width height are negative
  * @throws RuntimeException if the image is corrupt
  */
 public static void picture(double x, double y, String s, double w, double h) {
   Image image = getImage(s);
   double xs = scaleX(x);
   double ys = scaleY(y);
   if (w < 0) throw new RuntimeException("width is negative: " + w);
   if (h < 0) throw new RuntimeException("height is negative: " + h);
   double ws = factorX(w);
   double hs = factorY(h);
   if (ws < 0 || hs < 0) throw new RuntimeException("image " + s + " is corrupt");
   if (ws <= 1 && hs <= 1) pixel(x, y);
   else {
     offscreen.drawImage(
         image,
         (int) Math.round(xs - ws / 2.0),
         (int) Math.round(ys - hs / 2.0),
         (int) Math.round(ws),
         (int) Math.round(hs),
         null);
   }
   draw();
 }
Esempio n. 12
0
  public String createUID() {
    Long num;
    String uid;

    uid = "";
    num = new Date().getTime();
    while (num > 0) {
      uid += UIDMap[(int) (num % 62)];
      num /= 62;
    }

    uid += Math.round(Math.random() * 9.0);

    return uid;
  }
Esempio n. 13
0
  @Override
  public PluginResult execute(String action, JSONArray data, String callbackId) {
    // Log.d("OSCManager", "executing something " + action);
    PluginResult result = null;
    try {
      System.out.println("EXECUTING BONJOUR ********************************************");
      if (action.equals("start") || action.equals("browse")) {
        System.out.println("STARTING BONJOUR ********************************************");

        ServiceInfo[] infos = jmdns.list("_osc._udp.local.");
        for (int i = 0; i < infos.length; i++) {
          String jsString =
              "javascript:destinationManager.addDestination('"
                  + infos[i].getHostAddress()
                  + "',"
                  + infos[i].getPort()
                  + ", 0, 0);";
          System.out.println(jsString);
          webView.loadUrl(jsString);
          System.out.println("after sending to js");
        }
        if (action.equals("start")) {
          ServiceInfo serviceInfo =
              ServiceInfo.create(
                  "_osc._udp.local.",
                  "Control_" + (Math.round(Math.random() * 100000)),
                  8080,
                  "OSC reception for device running Control");
          jmdns.registerService(serviceInfo);
        }
      }
    } catch (Exception e) {
      System.out.println("after sending to js");
    }
    return result;
  }
 private int scy(int py) {
   return (int) Math.round(py * scaley);
 }
Esempio n. 15
0
 /**
  * Draw one pixel at (x, y).
  *
  * @param x the x-coordinate of the pixel
  * @param y the y-coordinate of the pixel
  */
 private static void pixel(double x, double y) {
   offscreen.fillRect((int) Math.round(scaleX(x)), (int) Math.round(scaleY(y)), 1, 1);
 }
 private int scx(int px) {
   return (int) Math.round(px * scalex);
 }
Esempio n. 17
0
 // ---------------------------------------------------------------------------
 int p2fX(int x, int y) {
   return (int) Math.round(scale * (x - tailPosX));
 }
Esempio n. 18
0
  // ------------------------------------------------------------------
  // initialize the canvas contents or judge the user's mouse events and respond
  public void paint(Graphics g) {

    // if forceNumber < 0 and !mUp: do nothing until mUp

    // if forceNumber < 0 and mUp (click): start the forces
    if (forceNumber < 0 && mUp) {
      fInit = true;
      mDown = false;
      // next line added 4/17/08 (correction for case of zero force true answer)
      mUp = false;
      forceNumber = 0;
      forceName = forceNames[forceNumber];
      userPosX = tailPosX;
      userPosY = tailPosY;
      numTries = 0;
      messageCanvas.notifyMouseClick(blinkerStrings[forceNumber]);
      // create the force equation and vector objects
      canvasEquation = new CanvasEquation(g);
      canvasVector = new CanvasVector(g);
    }

    // if mouseDown and all forces finished: do end game
    if (mDown && (forceNumber == maxForceNumber + 1)) {
      endGame("OK", cgiScript, problemNo, mouseUpsString);
    }

    // if mouseDown or mouseDrag and really a force:
    //     erase user's old vector & eqn, update position
    if ((mDown || mDrag) && (forceNumber >= 0) && (forceNumber <= maxForceNumber)) {
      messageCanvas.notifyMouseDown(blinkerStrings[forceNumber]);
      eraseUserStuff(g, forceX[0], forceY[0], 0);
      if (numEquations == 2) {
        eraseUserStuff(g, forceX[1], forceY[1], 1);
      }
      userPosX = newUserPosX;
      userPosY = newUserPosY;
    }

    // if browserPaint or forceInit or mouseDown or mouseDrag and really a force:
    //     plot fixed & user's new stuff
    if ((ifBrowserPaint || fInit || mDown || mDrag)
        && (forceNumber >= 0)
        && (forceNumber <= maxForceNumber)) {

      // redraw the userCanvas bounding box and the apparatus
      g.setColor(Color.black);
      g.drawRect(0, 0, userFrameX, userFrameY);
      problemSelector.drawUserApparatus(g);

      // draw the user's previously-done correct vectors
      if (forceNumber > 0) {
        drawDoneVectors(forceNumber - 1, g);
      }

      // draw the user's new vector and equation
      canvasVector.plotVector(tailPosX, tailPosY, userPosX, userPosY, g);
      forceX[0] = p2fX(userPosX, userPosY);
      forceY[0] = p2fY(userPosX, userPosY);
      canvasEquation.plotEquation(g, forceName, units, forceX[0], forceY[0], 0);
      if (numEquations == 2) {
        forceX[1] = (int) Math.round(cost * forceX[0] - sint * forceY[0]);
        forceY[1] = (int) Math.round(sint * forceX[0] + cost * forceY[0]);
        canvasEquation.plotEquation(g, forceName, units, forceX[1], forceY[1], 1);
      }

      // get ready up for new input
      fInit = mDown = mDrag = false;
      if (ifBrowserPaint) {
        ifBrowserPaint = false;
      }
    }

    // if mouseUp, evaluate the user's answer
    if (mUp && (forceNumber >= 0) && (forceNumber < numForces)) {

      // keep track of the mouse ups
      String leftStr = "";
      String rightStr = "";
      String midStr = mouseUpsString.substring(forceNumber, forceNumber + 1);
      if (forceNumber > 0) {
        leftStr = mouseUpsString.substring(0, forceNumber);
      }
      if (forceNumber < numForces - 1) {
        rightStr = mouseUpsString.substring(forceNumber + 1, numForces);
      }
      int numTries = Integer.parseInt(midStr);
      numTries++;
      if (numTries <= 9) {
        midStr = Integer.toString(numTries);
      } else {
        midStr = "9";
      }
      mouseUpsString = leftStr + midStr + rightStr;

      // if correct, cycle to the next force or to the trailer message
      int matchIndex = matchForceComps[forceNumber] - 1;

      int depX = Math.abs(forceX[matchIndex] - truAnsX[forceNumber][matchIndex]);
      int depY = Math.abs(forceY[matchIndex] - truAnsY[forceNumber][matchIndex]);
      if ((depX <= forceTolerance) && (depY <= forceTolerance)) {

        // erase the user's stuff
        for (int n = 0; n <= numEquations - 1; n++) {
          eraseUserStuff(g, forceX[n], forceY[n], n);
        }

        // draw the apparatus
        problemSelector.drawUserApparatus(g);

        // draw the set of correctly done vectors
        drawDoneVectors(forceNumber, g);

        // notify the resultsCanvas of the user's correctly drawn force
        boolean ifResultsDone = false;
        if (forceNumber == maxForceNumber) {
          ifResultsDone = true;
        }
        resultsCanvas.notifyMouseUpOk(
            ifResultsDone,
            forceNumber,
            forceNames,
            units,
            truAnsX,
            truAnsY,
            resultsSpacingStrings,
            numEquations,
            numForces);

        // cycle the force or do the end game
        if (forceNumber < maxForceNumber) {
          forceNumber++;
          numTries = 0;
          forceName = forceNames[forceNumber];
          userPosX = tailPosX;
          userPosY = tailPosY;
          forceX[0] = forceY[0] = forceX[1] = forceY[1] = 0;
          // draw the equation and message for the *next* force
          for (int n = 0; n <= numEquations - 1; n++) {
            canvasEquation.plotEquation(g, forceName, units, forceX[n], forceY[n], n);
          }
          // notify the messageCanvas that there is a new force
          messageCanvas.notifyMouseUpOk(blinkerStrings[forceNumber]);
        } else {
          g.setColor(userTrailerColor);
          g.drawString(userTrailer, userTrailerPosX, userTrailerPosY);
          // notify the messageCanvas that we are all done
          messageCanvas.notifyMouseUpOk("done");
          forceNumber++;
        }
      }
      // if not correct and mode > 1, check # of tries
      else {
        if (problemMode > 1 && numTries >= maxTriesEachForce) {
          endGame("notOK", cgiScript, problemNo, mouseUpsString);
        }
      }
      fInit = mUp = mDown = false;
    }
  }
Esempio n. 19
0
 // ---------------------------------------------------------------------------
 int p2fY(int x, int y) {
   return (int) Math.round(scale * (y - tailPosY));
 }
Esempio n. 20
0
  // public List getUserStoryList(String sessionId,String iterationId,ServletOutputStream out) {
  public List getUserStoryList(String sessionId, String iterationId, PrintWriter out) {

    List<Map> list = new ArrayList<Map>();

    statusMap.put(sessionId, "0");

    try {

      String apiURL =
          rallyApiHost
              + "/hierarchicalrequirement?"
              + "query=(Iteration%20=%20"
              + rallyApiHost
              + "/iteration/"
              + iterationId
              + ")&fetch=true&start=1&pagesize=100";

      log.info("getUserStoryList apiURL=" + apiURL);

      String responseXML = getRallyXML(apiURL);

      org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder();
      org.jdom.Document doc = bSAX.build(new StringReader(responseXML));
      Element root = doc.getRootElement();

      XPath xpath = XPath.newInstance("//Object");
      List xlist = xpath.selectNodes(root);

      int totalSteps = xlist.size() + 1;
      int currentStep = 0;

      List taskRefLink = new ArrayList();

      Iterator iter = xlist.iterator();
      while (iter.hasNext()) {
        double totalTimeSpent = 0.0D;

        Map map = new HashMap();

        Element item = (Element) iter.next();
        String objId = item.getChildText("ObjectID");
        String name = item.getChildText("Name");
        String planEstimate = item.getChildText("PlanEstimate");
        String formattedId = item.getChildText("FormattedID");

        String taskActualTotal = item.getChildText("TaskActualTotal");
        String taskEstimateTotal = item.getChildText("TaskEstimateTotal");
        String taskRemainingTotal = item.getChildText("TaskRemainingTotal");
        String scheduleState = item.getChildText("ScheduleState");

        Element ownerElement = item.getChild("Owner");

        String owner = "";
        String ownerRef = "";

        if (ownerElement != null) {
          owner = ownerElement.getAttributeValue("refObjectName");
        }

        Element taskElements = item.getChild("Tasks");
        // List taskElementList=taskElements.getContent();
        List taskElementList = taskElements.getChildren();

        List taskList = new ArrayList();

        log.info("taskElements.getChildren=" + taskElements);
        log.info("taskList=" + taskElementList);

        for (int i = 0; i < taskElementList.size(); i++) {
          Element taskElement = (Element) taskElementList.get(i);

          String taskRef = taskElement.getAttributeValue("ref");

          String[] objectIdArr = taskRef.split("/");
          String objectId = objectIdArr[objectIdArr.length - 1];

          log.info("objectId=" + objectId);

          // Map taskMap=getTaskMap(taskRef);
          Map taskMap = getTaskMapBatch(objectId);

          double taskTimeSpentTotal =
              Double.parseDouble((String) taskMap.get("taskTimeSpentTotal"));
          totalTimeSpent += taskTimeSpentTotal;
          taskList.add(taskMap);
        }

        map.put("type", "userstory");
        map.put("formattedId", formattedId);
        map.put("name", name);
        map.put("taskStatus", scheduleState);
        map.put("owner", owner);
        map.put("planEstimate", planEstimate);
        map.put("taskEstimateTotal", taskEstimateTotal);
        map.put("taskRemainingTotal", taskRemainingTotal);
        map.put("taskTimeSpentTotal", "" + totalTimeSpent);

        list.add(map);
        list.addAll(taskList);

        ++currentStep;
        double percentage = 100.0D * currentStep / totalSteps;
        String status = "" + Math.round(percentage);
        statusMap.put(sessionId, status);

        out.println("<script>parent.updateProcessStatus('" + status + "%')</script>" + status);
        out.flush();
        log.info("out.flush..." + status);

        // log.info("status="+status+" sessionId="+sessionId);
        // log.info("L1 statusMap="+statusMap+" "+statusMap.hashCode());

      }

      double planEstimate = 0.0D;
      double taskEstimateTotal = 0.0D;
      double taskRemainingTotal = 0.0D;
      double taskTimeSpentTotal = 0.0D;
      Map iterationMap = new HashMap();
      for (Map map : list) {
        String type = (String) map.get("type");

        String planEstimateStr = (String) map.get("planEstimate");

        log.info("planEstimateStr=" + planEstimateStr);

        if ("userstory".equals(type)) {

          if (planEstimateStr != null) {
            planEstimate += Double.parseDouble(planEstimateStr);
          }
          taskEstimateTotal += Double.parseDouble((String) map.get("taskEstimateTotal"));
          taskRemainingTotal += Double.parseDouble((String) map.get("taskRemainingTotal"));
          taskTimeSpentTotal += Double.parseDouble((String) map.get("taskTimeSpentTotal"));
        }
      }

      apiURL = rallyApiHost + "/iteration/" + iterationId + "?fetch=true";
      log.info("iteration apiURL=" + apiURL);
      responseXML = getRallyXML(apiURL);

      bSAX = new org.jdom.input.SAXBuilder();
      doc = bSAX.build(new StringReader(responseXML));
      root = doc.getRootElement();

      xpath = XPath.newInstance("//Iteration");
      xlist = xpath.selectNodes(root);

      String projName = "";
      String iterName = "";
      String iterState = "";

      iter = xlist.iterator();
      while (iter.hasNext()) {
        Element item = (Element) iter.next();

        iterName = item.getChildText("Name");
        iterState = item.getChildText("State");
        Element projElement = item.getChild("Project");
        projName = projElement.getAttributeValue("refObjectName");
      }

      iterationMap.put("type", "iteration");
      iterationMap.put("formattedId", "");
      iterationMap.put("name", projName + " - " + iterName);
      iterationMap.put("taskStatus", iterState);
      iterationMap.put("owner", "");

      iterationMap.put("planEstimate", "" + planEstimate);
      iterationMap.put("taskEstimateTotal", "" + taskEstimateTotal);
      iterationMap.put("taskRemainingTotal", "" + taskRemainingTotal);
      iterationMap.put("taskTimeSpentTotal", "" + taskTimeSpentTotal);

      list.add(0, iterationMap);

      statusMap.put(sessionId, "100");

      log.info("L2 statusMap=" + statusMap);

      log.info("L2 verify=" + getProcessStatus(sessionId));
      log.info("-----------");

      // String jsonData=JsonUtil.encodeObj(list);
      String jsonData = JSONValue.toJSONString(list);

      out.println("<script>parent.tableResult=" + jsonData + "</script>");
      out.println("<script>parent.showTableResult()</script>");

    } catch (Exception ex) {
      log.error("ERROR: ", ex);
    }

    return list;
  }
Esempio n. 21
0
 long sleepTimeToAchieveLoad(long runDuration, float maxLoad) {
   return Math.round(((double) runDuration / maxLoad) - runDuration);
 }