예제 #1
0
 public Boolean deleteVSByName(String name) {
   Query query =
       em.createQuery("SELECT v FROM VirtualStorage v WHERE v.nombre=:name")
           .setParameter("nombre", name);
   VirtualStorage virtualStorage = (VirtualStorage) query.getResultList().get(0);
   virtualStorage.setEnabled(false);
   em.merge(virtualStorage);
   return true;
 }
예제 #2
0
 public int AVPorUsuario(String nick) {
   Query query = em.createQuery("SELECT vs FROM VirtualStorage vs ");
   List<VirtualStorage> retorno = query.getResultList();
   int total = 0;
   for (VirtualStorage vs : retorno) {
     if (vs.getOwner().getNick().equals(nick)) {
       total++;
     }
   }
   return total;
 }
예제 #3
0
 public String insertVS(VirtualStorage vs, int idCreador) {
   Usuario creador = udao.buscarID(idCreador);
   if (creador == null) {
     return "500-Error-Sin_Usuario";
   }
   if (searchVSByName(vs.getName()) == null) {
     return "501-Error-Ya existe AV";
   } else {
     vs.setOwner(creador);
     em.persist(vs);
     em.flush();
     return vs.getName();
   }
 }
예제 #4
0
 public String createVS(VirtualStorage vs, int ownerId) {
   try {
     Usuario owner = udao.buscarID(ownerId);
     if (owner != null) {
       vs.setOwner(owner);
       vs.setCreatedDate(new Date());
       em.persist(vs);
       em.flush();
       return String.valueOf(vs.getId());
     }
     return "500-Error-no_existe_usuario";
   } catch (Exception ex) {
     return "500-Error-" + ex.getMessage();
   }
 }