Пример #1
0
  public void testELEvalDisabledIfNoExpressionEvaluated() throws Exception {

    ResourceManager manager = new ResourceManager(null);
    ClientResourceInfo resource =
        (ClientResourceInfo)
            manager.findResource(null, "simple.css", "text/css", getFacesContext());
    assertNotNull(resource);
    assertTrue(resource.supportsEL());
    ResourceImpl resImpl = new ResourceImpl(resource, "text/css", 0, 0);
    InputStream in = resImpl.getInputStream();
    for (int i = in.read(); i != -1; i = in.read()) {}
    try {
      in.close();
    } catch (Exception ioe) {
      fail(ioe.toString());
    }
    assertTrue(!resource.supportsEL());

    resource =
        (ClientResourceInfo)
            manager.findResource(null, "simple-with-el.css", "text/css", getFacesContext());

    assertNotNull(resource);
    assertTrue(resource.supportsEL());
    resImpl = new ResourceImpl(resource, "text/css", 0, 0);
    in = resImpl.getInputStream();
    for (int i = in.read(); i != -1; i = in.read()) {}
    try {
      in.close();
    } catch (Exception ioe) {
      fail(ioe.toString());
    }
    assertTrue(resource.supportsEL());
  }
 public VmResource getVProjectVmResource(IFile file) {
   VmResourceId resourceId = resourceManager.getResourceId(file);
   if (resourceId == null) {
     return null;
   }
   return resourceManager.getVmResource(resourceId);
 }
  /** Inserts a new row in the carrito_compras table. */
  public CarritoComprasPk insert(CarritoCompras dto) throws CarritoComprasDaoException {
    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);
      int index = 1;
      stmt.setString(index++, dto.getIdCarrito());
      stmt.setDouble(index++, dto.getTotal());
      stmt.setDouble(index++, dto.getSubtotal());
      stmt.setDouble(index++, dto.getImpuestos());
      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)");
      reset(dto);
      return dto.createPk();
    } catch (Exception _e) {
      _e.printStackTrace();
      throw new CarritoComprasDaoException("Exception: " + _e.getMessage(), _e);
    } finally {
      ResourceManager.close(stmt);
      if (!isConnSupplied) {
        ResourceManager.close(conn);
      }
    }
  }
Пример #4
0
  /**
   * public MutableStatusBar(String s1, String s2, String s3) { super(); status_1 = new JLabel(s1);
   * status_2 = new JLabel(s2); status_3 = new JLabel(s3); this.init(); }.
   */
  protected void init() {
    this.setLayout(new GridBagLayout());
    this.setBorder(BorderFactory.createEmptyBorder(3, 2, 1, 1));
    final GridBagConstraints constraints = new GridBagConstraints();

    // status_1.setHorizontalAlignment(JLabel.CENTER);
    status_1.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_1.setPreferredSize(new Dimension(180, 16));

    status_2.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_2.setPreferredSize(new Dimension(200, 16));

    status_3.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_3.setPreferredSize(new Dimension(300, 16));

    greenStatusIcon =
        new MutableImageLabel(resource.getIcon("green_off.gif"), resource.getIcon("green_on.gif"));
    greenStatusIcon.setBorder(new EmptyBorder(2, 2, 2, 1));

    redStatusIcon =
        new MutableImageLabel(resource.getIcon("red_off.gif"), resource.getIcon("red_on.gif"));
    redStatusIcon.setBorder(new EmptyBorder(2, 1, 2, 3));
    // =====================================================================

    constraints.insets = new Insets(0, 0, 0, 4);
    constraints.anchor = GridBagConstraints.EAST;
    constraints.fill = GridBagConstraints.VERTICAL;

    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    this.add(status_1, constraints);

    constraints.weightx = 0.0;
    constraints.gridx++;
    this.add(status_2, constraints);

    constraints.gridx = 2;
    this.add(status_3, constraints);

    constraints.gridx++;
    if (greenStatusIcon != null) {
      this.add(greenStatusIcon, constraints);
    }

    constraints.insets = new Insets(0, 0, 0, 0);
    constraints.gridx++;
    if (redStatusIcon != null) {
      this.add(redStatusIcon, constraints);
    }
  }
Пример #5
0
  public Tray() {

    mSprite = new Sprite(ResourceManager.get("tray"));
    mWheelCoverSprite = new Sprite(ResourceManager.get("wheelcover"));

    for (int i = 0; i < MAX_COGS_REALLY_BIG; i++) {
      mCogs_ReallyBig.add(Cog.getCog(5));
    }

    for (int i = 0; i < MAX_COGS_BIG; i++) {
      mCogs_Big.add(Cog.getCog(4));
    }

    for (int i = 0; i < MAX_COGS_MEDIUM; i++) {
      mCogs_Medium.add(Cog.getCog(3));
    }

    for (int i = 0; i < MAX_COGS_SMALL; i++) {
      mCogs_Small.add(Cog.getCog(2));
    }

    for (int i = 0; i < MAX_COGS_TINY; i++) {
      mCogs_Tiny.add(Cog.getCog(1));
    }
  }
Пример #6
0
 @Test
 public void testLoadNull() {
   initializeExpectedProject(1);
   expect(resourceManager.get(PROJECT_INFO.projectId())).andReturn(null);
   replay(resourceManager);
   assertNull(resourceManager.get(PROJECT_INFO.projectId()));
 }
Пример #7
0
  public void showRedScreen() {
    final Sprite redScreen =
        new Sprite(
            0.0f,
            0.0f,
            ResourceManager.getInstance().getRedScreen(),
            ResourceManager.getInstance().getVbom()) {
          @Override
          protected void preDraw(GLState pGLState, Camera pCamera) {
            super.preDraw(pGLState, pCamera);
            pGLState.enableDither();
          }
        };

    this.attachChild(redScreen);

    if (lives == 0) {
      displayLoseScreen();
    } else {

      this.registerUpdateHandler(
          new TimerHandler(
              0.25f,
              new ITimerCallback() {

                @Override
                public void onTimePassed(TimerHandler pTimerHandler) {
                  redScreen.detachSelf();
                  unregisterUpdateHandler(pTimerHandler);
                }
              }));
    }
  }
  public boolean enlist(int xid, ResourceManager rm) throws RemoteException {
    if (enlistList.containsKey(xid)) {
      Set<ResourceManager> set = enlistList.get(xid);
      Iterator<ResourceManager> i = set.iterator();
      ResourceManager r = null;
      while (i.hasNext()) {
        try {
          r = i.next();
          r.getMyRMIName();
        } catch (Exception e) {
          enlistList.get(xid).remove(r);
          System.out.println("A hole in enlist.");
        }
      }
      enlistList.get(xid).add(rm);
      protocolDB.get(xid).put(rm.getMyRMIName(), rm.getStatus(xid));
    } else {
      Set<ResourceManager> set = new HashSet<ResourceManager>();
      set.add(rm);
      enlistList.put(xid, set);

      HashMap<String, TwoPC_ST> map = new HashMap<String, TwoPC_ST>();
      map.put(rm.getMyRMIName(), TwoPC_ST.Initiated);
      protocolDB.put(xid, map);
    }
    return true;
  }
Пример #9
0
 /**
  * Display a message
  *
  * @param title the message's title
  * @param msg the message itself
  */
 public void display(String title, String msg) {
   JOptionPane.showMessageDialog(
       mOwner,
       ResourceManager.getInstance().getString(msg),
       ResourceManager.getInstance().getString(title),
       JOptionPane.ERROR_MESSAGE);
 }
  /** Deletes a single row in the carrito_compras table. */
  public void delete(CarritoComprasPk pk) throws CarritoComprasDaoException {
    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_DELETE + " with PK: " + pk);
      stmt = conn.prepareStatement(SQL_DELETE);
      stmt.setString(1, pk.getIdCarrito());
      int rows = stmt.executeUpdate();
      long t2 = System.currentTimeMillis();
      System.out.println(rows + " rows affected (" + (t2 - t1) + " ms)");
    } catch (Exception _e) {
      _e.printStackTrace();
      throw new CarritoComprasDaoException("Exception: " + _e.getMessage(), _e);
    } finally {
      ResourceManager.close(stmt);
      if (!isConnSupplied) {
        ResourceManager.close(conn);
      }
    }
  }
 @Override
 public List<MotInteInventario> findByInternamiento(Long codigo)
     throws MotInteInventarioDaoException {
   Connection conn = null;
   CallableStatement stmt = null;
   ResultSet rs = null;
   List<MotInteInventario> list = null;
   try {
     conn = ResourceManager.getConnection();
     stmt = conn.prepareCall("{call SP_MOT_GET_INTEINVENTARIOBYINTERNAMIENTO;1(?)}");
     stmt.setLong(1, codigo);
     boolean results = stmt.execute();
     if (results) {
       list = new ArrayList<MotInteInventario>();
       rs = stmt.getResultSet();
       MotInteInventario inventario = null;
       while (rs.next()) {
         inventario = new MotInteInventario();
         inventario.getInternamiento().setIntcodigoD(rs.getLong("INTCODIGO"));
         inventario.getInventarioTipo().setBitcodigoI(rs.getInt("BITCODIGO"));
         inventario.setBivcantidadI(rs.getInt("CANTIDAD"));
         inventario.setBivestadoC(rs.getString("ESTADO"));
         list.add(inventario);
       }
     }
   } catch (SQLException e) {
     throw new MotInteInventarioDaoException(e.getMessage(), e);
   } finally {
     ResourceManager.close(rs);
     ResourceManager.close(stmt);
     ResourceManager.close(conn);
   }
   return list;
 }
Пример #12
0
  @Override
  public void drawLevel(Level level) {
    int baseX = 0;
    int baseY = Client.UI_SIZE;

    for (int x = 0; x < level.getDimensions().x; x++) {
      for (int y = 0; y < level.getDimensions().y; y++) {

        ResourceManager.bindTexture(level.getTileType(x, y));
        drawSprite(baseX, baseY, Client.PIXELS_PER_TILE, Client.PIXELS_PER_TILE);

        Tower tower = level.getTower(x, y);
        if (tower != null) {
          ResourceManager.bindTower(tower.getTowerType());
          drawSprite(baseX, baseY, Client.PIXELS_PER_TILE, Client.PIXELS_PER_TILE);
        }

        baseY += Client.PIXELS_PER_TILE;
      }
      baseY = Client.UI_SIZE;
      baseX += Client.PIXELS_PER_TILE;
    }

    drawUnits(level);
  }
Пример #13
0
 @Test
 public void testGet() {
   initializeExpectedProject(1);
   expect(resourceManager.get(PROJECT_INFO.projectId())).andReturn(expectedProject);
   replay(resourceManager);
   Project loadedProject = resourceManager.get(PROJECT_INFO.projectId());
   assertEquals(expectedProject, loadedProject);
 }
Пример #14
0
 @Test
 public void testReplacePolicy() {
   expect(resourceManager.options()).andReturn(mockOptions).times(1);
   expect(resourceManager.replacePolicy(PROJECT_ID, POLICY)).andReturn(POLICY);
   replay(resourceManager);
   initializeProject();
   assertEquals(POLICY, project.replacePolicy(POLICY));
 }
  /** Inserts a new row in the project_phases table. */
  public ProjectPhasesPk insert(ProjectPhases dto) throws ProjectPhasesDaoException {
    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.getIdprojectPhases());
      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.isProjectIdNull()) {
        stmt.setNull(index++, java.sql.Types.INTEGER);
      } else {
        stmt.setInt(index++, dto.getProjectId());
      }

      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.setIdprojectPhases(rs.getInt(1));
      }

      reset(dto);
      return dto.createPk();
    } catch (Exception _e) {
      _e.printStackTrace();
      throw new ProjectPhasesDaoException("Exception: " + _e.getMessage(), _e);
    } finally {
      ResourceManager.close(stmt);
      if (!isConnSupplied) {
        ResourceManager.close(conn);
      }
    }
  }
Пример #16
0
 public ScrollSurface(Context context, ResourceManager resourceManager, DisplayMetrics metrics) {
   super(context);
   surfaceHolder = getHolder();
   DISPLAY_WIDTH = metrics.widthPixels;
   DISPLAY_HEIGHT = metrics.heightPixels;
   resourceManager.load(context, ResourceManager.SCROLL_MODE);
   foo_forward_walk = resourceManager.getImageSet(ResourceManager.FOO_FORWARD_WALK);
   background = resourceManager.getImageSet(ResourceManager.BACKGROUND);
 }
Пример #17
0
 @Test
 public void testUndelete() {
   initializeExpectedProject(1);
   expect(resourceManager.options()).andReturn(mockOptions);
   resourceManager.undelete(PROJECT_INFO.projectId());
   replay(resourceManager);
   initializeProject();
   project.undelete();
 }
  public List func_135056_b(ResourceLocation par1ResourceLocation) throws IOException {
    ResourceManager resourcemanager =
        (ResourceManager) this.field_110548_a.get(par1ResourceLocation.func_110624_b());

    if (resourcemanager != null) {
      return resourcemanager.func_135056_b(par1ResourceLocation);
    } else {
      throw new FileNotFoundException(par1ResourceLocation.toString());
    }
  }
Пример #19
0
 @Test
 public void testReloadNull() {
   initializeExpectedProject(1);
   expect(resourceManager.options()).andReturn(mockOptions);
   expect(resourceManager.get(PROJECT_INFO.projectId())).andReturn(null);
   replay(resourceManager);
   Project reloadedProject =
       new Project(resourceManager, new ProjectInfo.BuilderImpl(PROJECT_INFO)).reload();
   assertNull(reloadedProject);
 }
Пример #20
0
 /**
  * Shutdown a specific member.
  *
  * @param m
  */
 private void shutdownMember(MemberInfo m) {
   ResourceManager rm = GroupMember.memberInfoToResourceManager(m);
   if (rm != null) {
     try {
       rm.shutdown(FORCE_SHUTDOWN);
     } catch (Exception e) {
       // do nothing.
     }
   }
 }
  @Override
  public List<MotEmpConductor> findByCriterio(String criterio, String texto, Long empcodigoD)
      throws MotEmpConductorDaoException {

    Connection conn = null;
    CallableStatement stmt = null;
    ResultSet rs = null;

    List<MotEmpConductor> list = new ArrayList<MotEmpConductor>();
    try {
      conn = ResourceManager.getConnection();
      stmt = conn.prepareCall("{call SP_MOT_GET_LISTADO_CONDUCTORPORRITERIO;1(?,?,?)}");
      stmt.setString(1, criterio);
      stmt.setString(2, texto);
      stmt.setLong(3, empcodigoD);
      boolean results = stmt.execute();
      if (results) {
        rs = stmt.getResultSet();
        MotPersona persona = null;
        MotConductor conductor = null;
        MotEmpConductor empresaconductor = null; // ???

        while (rs.next()) {

          persona = new MotPersona();
          persona.setPernombresV(rs.getString("Nombres"));
          persona.setPerpaternoV(rs.getString("Paterno"));
          persona.setPermaternoV(rs.getString("Materno"));
          persona.setPerdniV(rs.getString("DNI"));

          conductor = new MotConductor();
          conductor.setConcodigoD(rs.getLong("CONDCODIGO"));
          conductor.setPersona(persona);

          empresaconductor = new MotEmpConductor();
          empresaconductor.setMotosasignadasI(rs.getInt("Motos Asignadas"));
          empresaconductor.setEcofechainicioF(rs.getString("Fecha Inicio"));
          empresaconductor.setEcofechaceseF(rs.getString("Fecha Cese"));
          empresaconductor.setConductor(conductor);
          list.add(empresaconductor);
        }
      }

    } catch (SQLException ex) {
      throw new MotEmpConductorDaoException(ex.getMessage());
    } finally {

      ResourceManager.close(rs);
      ResourceManager.close(stmt);
      ResourceManager.close(conn);
    }

    return list;
  }
Пример #22
0
  public static void showTaskProgressDialog(
      Window ownerWindow, Task task, boolean showTaskMessage) {
    final Stage dialog = new Stage();
    task.setOnSucceeded(event -> dialog.close());
    task.setOnCancelled(event -> dialog.close());
    dialog.initStyle(StageStyle.UTILITY);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(ownerWindow);
    dialog.titleProperty().bind(task.titleProperty());
    //        dialog.setTitle(ResourceManager.getMessage("title.dialog.processing"));
    dialog.setOnCloseRequest(
        event ->
            Logger.getLogger(Dialogs.class)
                .info(ResourceManager.getMessage("notification.task.terminatedByUser")));

    ProgressBar progressBar = new ProgressBar(0);
    progressBar.progressProperty().bind(task.progressProperty());
    progressBar.setMaxWidth(Double.MAX_VALUE);
    progressBar.getStyleClass().add("dark");

    Label label = new Label(ResourceManager.getMessage("label.pleaseWaitWhile"));
    Label taskMessage = new Label();
    taskMessage.textProperty().bind(task.messageProperty());

    Button cancelButton = new Button(ResourceManager.getMessage("label.button.cancel"));
    cancelButton.setOnAction(
        event -> {
          task.cancel();
          Logger.getLogger(Dialogs.class)
              .info(ResourceManager.getMessage("notification.task.terminatedByUser"));
        });

    ButtonBar buttonBar = new ButtonBar();
    buttonBar.getButtons().add(cancelButton);

    VBox dialogVBox = new VBox();
    dialogVBox.setFillWidth(true);
    dialogVBox.setSpacing(5);
    dialogVBox.setPadding(new Insets(5));
    dialogVBox.setPrefSize(300, VBox.USE_COMPUTED_SIZE);
    dialogVBox.getChildren().add(label);
    if (showTaskMessage) {
      dialogVBox.getChildren().add(taskMessage);
    }
    dialogVBox.getChildren().add(progressBar);
    dialogVBox.getChildren().add(buttonBar);

    Scene dialogScene = new Scene(dialogVBox);
    dialogScene.getStylesheets().add(ResourceManager.getUIThemeStyle());
    dialog.setScene(dialogScene);
    dialog.setResizable(false);
    dialog.show();
  }
 private void formatFileNode(FileNode pNode) {
   if (pNode.isTestcaseDir()) {
     if (pNode.isTestcaseCheckOk()) {
       Icon icon = ResourceManager.getInstance().getImageIcon("icons/tc16");
       setIcon(icon);
     } else {
       setIcon(ResourceManager.getInstance().getImageIcon("icons/tc16_nodata"));
       this.setToolTipText("no TestData.csv file found");
     }
   } else {
     setIcon(ResourceManager.getInstance().getImageIcon("icons/dir16"));
   }
 }
Пример #24
0
 @Test
 public void testReplace() {
   initializeExpectedProject(2);
   Project expectedReplacedProject = expectedProject.toBuilder().addLabel("k3", "v3").build();
   expect(resourceManager.options()).andReturn(mockOptions).times(2);
   expect(resourceManager.replace(anyObject(Project.class))).andReturn(expectedReplacedProject);
   replay(resourceManager);
   initializeProject();
   Project newProject =
       new Project(resourceManager, new ProjectInfo.BuilderImpl(expectedReplacedProject));
   Project actualReplacedProject = newProject.replace();
   compareProjectInfos(expectedReplacedProject, actualReplacedProject);
 }
 public void abort(int xid) throws RemoteException, InvalidTransactionException {
   if (!xidIsValid(xid)) throw new InvalidTransactionException(xid, "");
   Set<ResourceManager> abortSet = enlistList.get(xid);
   for (ResourceManager rm : abortSet) {
     try {
       rm.abort(xid);
     } catch (Exception e) {
       System.out.println("Abort has invalid rm.");
     }
   }
   enlistList.remove(xid);
   protocolDB.remove(xid);
 }
Пример #26
0
 @Test
 public void testReload() {
   initializeExpectedProject(2);
   ProjectInfo newInfo = PROJECT_INFO.toBuilder().addLabel("k3", "v3").build();
   Project expectedProject =
       new Project(serviceMockReturnsOptions, new ProjectInfo.BuilderImpl(newInfo));
   expect(resourceManager.options()).andReturn(mockOptions);
   expect(resourceManager.get(PROJECT_INFO.projectId())).andReturn(expectedProject);
   replay(resourceManager);
   initializeProject();
   Project newProject = project.reload();
   assertEquals(expectedProject, newProject);
 }
 public void abortOtherRMsExcept(String rmName, int xid)
     throws RemoteException, InvalidTransactionException {
   Set<ResourceManager> set = enlistList.get(xid);
   Iterator<ResourceManager> i = set.iterator();
   ResourceManager r = null;
   while (i.hasNext()) {
     r = i.next();
     if (r.getMyRMIName().equals(rmName)) {
       enlistList.get(xid).remove(r);
       break;
     }
   }
   abort(xid);
 }
  @Override
  public void procesar(MotEmpConductor dto) throws MotEmpConductorDaoException {

    Connection conn = null;
    CallableStatement stmt = null;
    ResultSet rs = null;

    try {
      conn = ResourceManager.getConnection();
      stmt =
          conn.prepareCall(
              "{call SP_MOT_INS_PERSONA_CONDUCTOR;1(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
      stmt.registerOutParameter(1, Types.DECIMAL);
      stmt.setLong(1, dto.getConductor().getConcodigoD());
      stmt.setLong(2, dto.getConductor().getPersona().getPercodigoD());
      stmt.setString(3, dto.getConductor().getPersona().getPerdniV());
      stmt.setString(4, dto.getConductor().getPersona().getPernombresV());
      stmt.setString(5, dto.getConductor().getPersona().getPerpaternoV());
      stmt.setString(6, dto.getConductor().getPersona().getPermaternoV());
      stmt.setString(7, dto.getConductor().getPersona().getPernacimientoF());
      stmt.setString(8, dto.getConductor().getPersona().getPerestadocivilC());
      stmt.setString(9, dto.getConductor().getPersona().getPermovilclaV());
      stmt.setString(10, dto.getConductor().getPersona().getPermovilmovV());
      stmt.setString(11, dto.getConductor().getPersona().getPermovilnexV());
      stmt.setString(12, dto.getConductor().getPersona().getPerteleffijoV());
      stmt.setString(13, dto.getConductor().getPersona().getPeremailV());
      stmt.setString(14, dto.getConductor().getPersona().getPerdomicilioV());
      stmt.setString(15, dto.getConductor().getPersona().getPerubidistV());
      stmt.setString(16, dto.getConductor().getPersona().getPerubdptoV());
      stmt.setString(17, dto.getConductor().getPersona().getPerubprovV());
      stmt.setString(18, dto.getConductor().getPersona().getPersexoC());
      stmt.setLong(19, dto.getEmpresa().getEmpcodigoD());
      stmt.setString(20, dto.getEcofechainicioF());
      stmt.execute();

      Long codigo = stmt.getLong(1);
      if (codigo != null) {
        dto.getConductor().setConcodigoD(codigo);
      }

    } catch (Exception ex) {
      logger.error("Exception: " + ex.getMessage(), ex);
      throw new MotEmpConductorDaoException("Exception: " + ex.getMessage(), ex);
    } finally {
      ResourceManager.close(rs);
      ResourceManager.close(stmt);
      ResourceManager.close(conn);
    }
  }
  /** Updates a single row in the project_phases table. */
  public void update(ProjectPhasesPk pk, ProjectPhases dto) throws ProjectPhasesDaoException {
    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.getIdprojectPhases());
      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.isProjectIdNull()) {
        stmt.setNull(index++, java.sql.Types.INTEGER);
      } else {
        stmt.setInt(index++, dto.getProjectId());
      }

      stmt.setInt(8, pk.getIdprojectPhases());
      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 ProjectPhasesDaoException("Exception: " + _e.getMessage(), _e);
    } finally {
      ResourceManager.close(stmt);
      if (!isConnSupplied) {
        ResourceManager.close(conn);
      }
    }
  }
Пример #30
0
 @Test
 public void testTestPermissions() {
   List<Boolean> response = ImmutableList.of(true, true);
   String getPermission = "resourcemanager.projects.get";
   String deletePermission = "resourcemanager.projects.delete";
   expect(resourceManager.options()).andReturn(mockOptions).times(1);
   expect(
           resourceManager.testPermissions(
               PROJECT_ID, ImmutableList.of(getPermission, deletePermission)))
       .andReturn(response);
   replay(resourceManager);
   initializeProject();
   assertEquals(
       response, project.testPermissions(ImmutableList.of(getPermission, deletePermission)));
 }